id int32 0 24.9k | repo stringlengths 5 58 | path stringlengths 9 168 | func_name stringlengths 9 130 | original_string stringlengths 66 10.5k | language stringclasses 1
value | code stringlengths 66 10.5k | code_tokens list | docstring stringlengths 8 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 94 266 |
|---|---|---|---|---|---|---|---|---|---|---|---|
15,200 | mojombo/god | lib/god/process.rb | God.Process.signal | def signal(sig)
sig = sig.to_i if sig.to_i != 0
applog(self, :info, "#{self.name} sending signal '#{sig}' to pid #{self.pid}")
::Process.kill(sig, self.pid) rescue nil
end | ruby | def signal(sig)
sig = sig.to_i if sig.to_i != 0
applog(self, :info, "#{self.name} sending signal '#{sig}' to pid #{self.pid}")
::Process.kill(sig, self.pid) rescue nil
end | [
"def",
"signal",
"(",
"sig",
")",
"sig",
"=",
"sig",
".",
"to_i",
"if",
"sig",
".",
"to_i",
"!=",
"0",
"applog",
"(",
"self",
",",
":info",
",",
"\"#{self.name} sending signal '#{sig}' to pid #{self.pid}\"",
")",
"::",
"Process",
".",
"kill",
"(",
"sig",
"... | Send the given signal to this process.
Returns nothing | [
"Send",
"the",
"given",
"signal",
"to",
"this",
"process",
"."
] | 92c06aa5f6293cf26498a306e9bb7ac856d7dca0 | https://github.com/mojombo/god/blob/92c06aa5f6293cf26498a306e9bb7ac856d7dca0/lib/god/process.rb#L186-L190 |
15,201 | mojombo/god | lib/god/process.rb | God.Process.ensure_stop | def ensure_stop
applog(self, :warn, "#{self.name} ensuring stop...")
unless self.pid
applog(self, :warn, "#{self.name} stop called but pid is uknown")
return
end
# Poll to see if it's dead
@stop_timeout.times do
begin
::Process.kill(0, self.pid)
... | ruby | def ensure_stop
applog(self, :warn, "#{self.name} ensuring stop...")
unless self.pid
applog(self, :warn, "#{self.name} stop called but pid is uknown")
return
end
# Poll to see if it's dead
@stop_timeout.times do
begin
::Process.kill(0, self.pid)
... | [
"def",
"ensure_stop",
"applog",
"(",
"self",
",",
":warn",
",",
"\"#{self.name} ensuring stop...\"",
")",
"unless",
"self",
".",
"pid",
"applog",
"(",
"self",
",",
":warn",
",",
"\"#{self.name} stop called but pid is uknown\"",
")",
"return",
"end",
"# Poll to see if ... | Ensure that a stop command actually stops the process. Force kill
if necessary.
Returns nothing | [
"Ensure",
"that",
"a",
"stop",
"command",
"actually",
"stops",
"the",
"process",
".",
"Force",
"kill",
"if",
"necessary",
"."
] | 92c06aa5f6293cf26498a306e9bb7ac856d7dca0 | https://github.com/mojombo/god/blob/92c06aa5f6293cf26498a306e9bb7ac856d7dca0/lib/god/process.rb#L349-L372 |
15,202 | mojombo/god | lib/god/driver.rb | God.DriverEventQueue.pop | def pop
@monitor.synchronize do
if @events.empty?
raise ThreadError, "queue empty" if @shutdown
@resource.wait
else
delay = @events.first.at - Time.now
@resource.wait(delay) if delay > 0
end
@events.shift
end
end | ruby | def pop
@monitor.synchronize do
if @events.empty?
raise ThreadError, "queue empty" if @shutdown
@resource.wait
else
delay = @events.first.at - Time.now
@resource.wait(delay) if delay > 0
end
@events.shift
end
end | [
"def",
"pop",
"@monitor",
".",
"synchronize",
"do",
"if",
"@events",
".",
"empty?",
"raise",
"ThreadError",
",",
"\"queue empty\"",
"if",
"@shutdown",
"@resource",
".",
"wait",
"else",
"delay",
"=",
"@events",
".",
"first",
".",
"at",
"-",
"Time",
".",
"no... | Wait until the queue has something due, pop it off the queue, and return
it.
Returns the popped event. | [
"Wait",
"until",
"the",
"queue",
"has",
"something",
"due",
"pop",
"it",
"off",
"the",
"queue",
"and",
"return",
"it",
"."
] | 92c06aa5f6293cf26498a306e9bb7ac856d7dca0 | https://github.com/mojombo/god/blob/92c06aa5f6293cf26498a306e9bb7ac856d7dca0/lib/god/driver.rb#L116-L128 |
15,203 | mojombo/god | lib/god/driver.rb | God.Driver.schedule | def schedule(condition, delay = condition.interval)
applog(nil, :debug, "driver schedule #{condition} in #{delay} seconds")
@events.push(DriverEvent.new(delay, @task, condition))
end | ruby | def schedule(condition, delay = condition.interval)
applog(nil, :debug, "driver schedule #{condition} in #{delay} seconds")
@events.push(DriverEvent.new(delay, @task, condition))
end | [
"def",
"schedule",
"(",
"condition",
",",
"delay",
"=",
"condition",
".",
"interval",
")",
"applog",
"(",
"nil",
",",
":debug",
",",
"\"driver schedule #{condition} in #{delay} seconds\"",
")",
"@events",
".",
"push",
"(",
"DriverEvent",
".",
"new",
"(",
"delay"... | Create and schedule a new DriverEvent.
condition - The Condition.
delay - The Numeric number of seconds to delay (default: interval
defined in condition).
Returns nothing. | [
"Create",
"and",
"schedule",
"a",
"new",
"DriverEvent",
"."
] | 92c06aa5f6293cf26498a306e9bb7ac856d7dca0 | https://github.com/mojombo/god/blob/92c06aa5f6293cf26498a306e9bb7ac856d7dca0/lib/god/driver.rb#L232-L236 |
15,204 | mojombo/god | lib/god/watch.rb | God.Watch.call_action | def call_action(condition, action)
# Before.
before_items = self.behaviors
before_items += [condition] if condition
before_items.each do |b|
info = b.send("before_#{action}")
if info
msg = "#{self.name} before_#{action}: #{info} (#{b.base_name})"
applog(self, ... | ruby | def call_action(condition, action)
# Before.
before_items = self.behaviors
before_items += [condition] if condition
before_items.each do |b|
info = b.send("before_#{action}")
if info
msg = "#{self.name} before_#{action}: #{info} (#{b.base_name})"
applog(self, ... | [
"def",
"call_action",
"(",
"condition",
",",
"action",
")",
"# Before.",
"before_items",
"=",
"self",
".",
"behaviors",
"before_items",
"+=",
"[",
"condition",
"]",
"if",
"condition",
"before_items",
".",
"each",
"do",
"|",
"b",
"|",
"info",
"=",
"b",
".",... | Perform the specifics of the action.
condition - The Condition.
action - The Symbol action.
Returns nothing. | [
"Perform",
"the",
"specifics",
"of",
"the",
"action",
"."
] | 92c06aa5f6293cf26498a306e9bb7ac856d7dca0 | https://github.com/mojombo/god/blob/92c06aa5f6293cf26498a306e9bb7ac856d7dca0/lib/god/watch.rb#L286-L317 |
15,205 | activeadmin/inherited_resources | lib/inherited_resources/base_helpers.rb | InheritedResources.BaseHelpers.collection | def collection
get_collection_ivar || begin
c = end_of_association_chain
set_collection_ivar(c.respond_to?(:scoped) ? c.scoped : c.all)
end
end | ruby | def collection
get_collection_ivar || begin
c = end_of_association_chain
set_collection_ivar(c.respond_to?(:scoped) ? c.scoped : c.all)
end
end | [
"def",
"collection",
"get_collection_ivar",
"||",
"begin",
"c",
"=",
"end_of_association_chain",
"set_collection_ivar",
"(",
"c",
".",
"respond_to?",
"(",
":scoped",
")",
"?",
"c",
".",
"scoped",
":",
"c",
".",
"all",
")",
"end",
"end"
] | This is how the collection is loaded.
You might want to overwrite this method if you want to add pagination
for example. When you do that, don't forget to cache the result in an
instance_variable:
def collection
@projects ||= end_of_association_chain.paginate(params[:page]).all
end | [
"This",
"is",
"how",
"the",
"collection",
"is",
"loaded",
"."
] | 2ba6982ddd6a56e7ef9ed7396473e5500ad77126 | https://github.com/activeadmin/inherited_resources/blob/2ba6982ddd6a56e7ef9ed7396473e5500ad77126/lib/inherited_resources/base_helpers.rb#L22-L27 |
15,206 | activeadmin/inherited_resources | lib/inherited_resources/base_helpers.rb | InheritedResources.BaseHelpers.end_of_association_chain | def end_of_association_chain #:nodoc:
if chain = association_chain.last
if method_for_association_chain
apply_scopes_if_available(chain.send(method_for_association_chain))
else
# This only happens when we specify begin_of_association_chain in
# a singleton... | ruby | def end_of_association_chain #:nodoc:
if chain = association_chain.last
if method_for_association_chain
apply_scopes_if_available(chain.send(method_for_association_chain))
else
# This only happens when we specify begin_of_association_chain in
# a singleton... | [
"def",
"end_of_association_chain",
"#:nodoc:",
"if",
"chain",
"=",
"association_chain",
".",
"last",
"if",
"method_for_association_chain",
"apply_scopes_if_available",
"(",
"chain",
".",
"send",
"(",
"method_for_association_chain",
")",
")",
"else",
"# This only happens whe... | This methods gets your begin_of_association_chain, join it with your
parents chain and returns the scoped association. | [
"This",
"methods",
"gets",
"your",
"begin_of_association_chain",
"join",
"it",
"with",
"your",
"parents",
"chain",
"and",
"returns",
"the",
"scoped",
"association",
"."
] | 2ba6982ddd6a56e7ef9ed7396473e5500ad77126 | https://github.com/activeadmin/inherited_resources/blob/2ba6982ddd6a56e7ef9ed7396473e5500ad77126/lib/inherited_resources/base_helpers.rb#L172-L186 |
15,207 | activeadmin/inherited_resources | lib/inherited_resources/base_helpers.rb | InheritedResources.BaseHelpers.smart_collection_url | def smart_collection_url
url = nil
if respond_to? :index
url ||= collection_url rescue nil
end
if respond_to? :parent, true
url ||= parent_url rescue nil
end
url ||= root_url rescue nil
end | ruby | def smart_collection_url
url = nil
if respond_to? :index
url ||= collection_url rescue nil
end
if respond_to? :parent, true
url ||= parent_url rescue nil
end
url ||= root_url rescue nil
end | [
"def",
"smart_collection_url",
"url",
"=",
"nil",
"if",
"respond_to?",
":index",
"url",
"||=",
"collection_url",
"rescue",
"nil",
"end",
"if",
"respond_to?",
":parent",
",",
"true",
"url",
"||=",
"parent_url",
"rescue",
"nil",
"end",
"url",
"||=",
"root_url",
... | URL to redirect to when redirect implies collection url. | [
"URL",
"to",
"redirect",
"to",
"when",
"redirect",
"implies",
"collection",
"url",
"."
] | 2ba6982ddd6a56e7ef9ed7396473e5500ad77126 | https://github.com/activeadmin/inherited_resources/blob/2ba6982ddd6a56e7ef9ed7396473e5500ad77126/lib/inherited_resources/base_helpers.rb#L302-L311 |
15,208 | activeadmin/inherited_resources | lib/inherited_resources/base_helpers.rb | InheritedResources.BaseHelpers.build_resource_params | def build_resource_params
parameters = permitted_params || params
rparams = [parameters[resource_request_name] || parameters[resource_instance_name] || {}]
if without_protection_given?
rparams << without_protection
else
rparams << as_role if role_given?
end
... | ruby | def build_resource_params
parameters = permitted_params || params
rparams = [parameters[resource_request_name] || parameters[resource_instance_name] || {}]
if without_protection_given?
rparams << without_protection
else
rparams << as_role if role_given?
end
... | [
"def",
"build_resource_params",
"parameters",
"=",
"permitted_params",
"||",
"params",
"rparams",
"=",
"[",
"parameters",
"[",
"resource_request_name",
"]",
"||",
"parameters",
"[",
"resource_instance_name",
"]",
"||",
"{",
"}",
"]",
"if",
"without_protection_given?",... | extract attributes from params | [
"extract",
"attributes",
"from",
"params"
] | 2ba6982ddd6a56e7ef9ed7396473e5500ad77126 | https://github.com/activeadmin/inherited_resources/blob/2ba6982ddd6a56e7ef9ed7396473e5500ad77126/lib/inherited_resources/base_helpers.rb#L354-L364 |
15,209 | activeadmin/inherited_resources | lib/inherited_resources/class_methods.rb | InheritedResources.ClassMethods.actions | def actions(*actions_to_keep)
raise ArgumentError, 'Wrong number of arguments. You have to provide which actions you want to keep.' if actions_to_keep.empty?
options = actions_to_keep.extract_options!
actions_to_remove = Array(options[:except])
actions_to_remove += ACTIONS - actions_to_... | ruby | def actions(*actions_to_keep)
raise ArgumentError, 'Wrong number of arguments. You have to provide which actions you want to keep.' if actions_to_keep.empty?
options = actions_to_keep.extract_options!
actions_to_remove = Array(options[:except])
actions_to_remove += ACTIONS - actions_to_... | [
"def",
"actions",
"(",
"*",
"actions_to_keep",
")",
"raise",
"ArgumentError",
",",
"'Wrong number of arguments. You have to provide which actions you want to keep.'",
"if",
"actions_to_keep",
".",
"empty?",
"options",
"=",
"actions_to_keep",
".",
"extract_options!",
"actions_to... | Defines wich actions will be inherited from the inherited controller.
Syntax is borrowed from resource_controller.
actions :index, :show, :edit
actions :all, :except => :index | [
"Defines",
"wich",
"actions",
"will",
"be",
"inherited",
"from",
"the",
"inherited",
"controller",
".",
"Syntax",
"is",
"borrowed",
"from",
"resource_controller",
"."
] | 2ba6982ddd6a56e7ef9ed7396473e5500ad77126 | https://github.com/activeadmin/inherited_resources/blob/2ba6982ddd6a56e7ef9ed7396473e5500ad77126/lib/inherited_resources/class_methods.rb#L75-L85 |
15,210 | activeadmin/inherited_resources | lib/inherited_resources/class_methods.rb | InheritedResources.ClassMethods.polymorphic_belongs_to | def polymorphic_belongs_to(*symbols, &block)
options = symbols.extract_options!
options.merge!(polymorphic: true)
belongs_to(*symbols, options, &block)
end | ruby | def polymorphic_belongs_to(*symbols, &block)
options = symbols.extract_options!
options.merge!(polymorphic: true)
belongs_to(*symbols, options, &block)
end | [
"def",
"polymorphic_belongs_to",
"(",
"*",
"symbols",
",",
"&",
"block",
")",
"options",
"=",
"symbols",
".",
"extract_options!",
"options",
".",
"merge!",
"(",
"polymorphic",
":",
"true",
")",
"belongs_to",
"(",
"symbols",
",",
"options",
",",
"block",
")",... | A quick method to declare polymorphic belongs to. | [
"A",
"quick",
"method",
"to",
"declare",
"polymorphic",
"belongs",
"to",
"."
] | 2ba6982ddd6a56e7ef9ed7396473e5500ad77126 | https://github.com/activeadmin/inherited_resources/blob/2ba6982ddd6a56e7ef9ed7396473e5500ad77126/lib/inherited_resources/class_methods.rb#L229-L233 |
15,211 | activeadmin/inherited_resources | lib/inherited_resources/class_methods.rb | InheritedResources.ClassMethods.singleton_belongs_to | def singleton_belongs_to(*symbols, &block)
options = symbols.extract_options!
options.merge!(singleton: true)
belongs_to(*symbols, options, &block)
end | ruby | def singleton_belongs_to(*symbols, &block)
options = symbols.extract_options!
options.merge!(singleton: true)
belongs_to(*symbols, options, &block)
end | [
"def",
"singleton_belongs_to",
"(",
"*",
"symbols",
",",
"&",
"block",
")",
"options",
"=",
"symbols",
".",
"extract_options!",
"options",
".",
"merge!",
"(",
"singleton",
":",
"true",
")",
"belongs_to",
"(",
"symbols",
",",
"options",
",",
"block",
")",
"... | A quick method to declare singleton belongs to. | [
"A",
"quick",
"method",
"to",
"declare",
"singleton",
"belongs",
"to",
"."
] | 2ba6982ddd6a56e7ef9ed7396473e5500ad77126 | https://github.com/activeadmin/inherited_resources/blob/2ba6982ddd6a56e7ef9ed7396473e5500ad77126/lib/inherited_resources/class_methods.rb#L237-L241 |
15,212 | activeadmin/inherited_resources | lib/inherited_resources/class_methods.rb | InheritedResources.ClassMethods.optional_belongs_to | def optional_belongs_to(*symbols, &block)
options = symbols.extract_options!
options.merge!(optional: true)
belongs_to(*symbols, options, &block)
end | ruby | def optional_belongs_to(*symbols, &block)
options = symbols.extract_options!
options.merge!(optional: true)
belongs_to(*symbols, options, &block)
end | [
"def",
"optional_belongs_to",
"(",
"*",
"symbols",
",",
"&",
"block",
")",
"options",
"=",
"symbols",
".",
"extract_options!",
"options",
".",
"merge!",
"(",
"optional",
":",
"true",
")",
"belongs_to",
"(",
"symbols",
",",
"options",
",",
"block",
")",
"en... | A quick method to declare optional belongs to. | [
"A",
"quick",
"method",
"to",
"declare",
"optional",
"belongs",
"to",
"."
] | 2ba6982ddd6a56e7ef9ed7396473e5500ad77126 | https://github.com/activeadmin/inherited_resources/blob/2ba6982ddd6a56e7ef9ed7396473e5500ad77126/lib/inherited_resources/class_methods.rb#L245-L249 |
15,213 | activeadmin/inherited_resources | lib/inherited_resources/class_methods.rb | InheritedResources.ClassMethods.custom_actions | def custom_actions(options)
self.resources_configuration[:self][:custom_actions] = options
options.each do | resource_or_collection, actions |
[*actions].each do | action |
create_custom_action(resource_or_collection, action)
end
end
create_resources_url_h... | ruby | def custom_actions(options)
self.resources_configuration[:self][:custom_actions] = options
options.each do | resource_or_collection, actions |
[*actions].each do | action |
create_custom_action(resource_or_collection, action)
end
end
create_resources_url_h... | [
"def",
"custom_actions",
"(",
"options",
")",
"self",
".",
"resources_configuration",
"[",
":self",
"]",
"[",
":custom_actions",
"]",
"=",
"options",
"options",
".",
"each",
"do",
"|",
"resource_or_collection",
",",
"actions",
"|",
"[",
"actions",
"]",
".",
... | Defines custom restful actions by resource or collection basis.
custom_actions :resource => [:delete, :transit], :collection => :search
== Options
* <tt>:resource</tt> - Allows you to specify resource actions.
custom_actions :resource => :delete
This macro creates 'delete' method ... | [
"Defines",
"custom",
"restful",
"actions",
"by",
"resource",
"or",
"collection",
"basis",
"."
] | 2ba6982ddd6a56e7ef9ed7396473e5500ad77126 | https://github.com/activeadmin/inherited_resources/blob/2ba6982ddd6a56e7ef9ed7396473e5500ad77126/lib/inherited_resources/class_methods.rb#L269-L283 |
15,214 | activeadmin/inherited_resources | lib/inherited_resources/class_methods.rb | InheritedResources.ClassMethods.initialize_resources_class_accessors! | def initialize_resources_class_accessors! #:nodoc:
# First priority is the namespaced model, e.g. User::Group
self.resource_class ||= begin
namespaced_class = self.name.sub(/Controller$/, '').singularize
namespaced_class.constantize
rescue NameError
nil
end
... | ruby | def initialize_resources_class_accessors! #:nodoc:
# First priority is the namespaced model, e.g. User::Group
self.resource_class ||= begin
namespaced_class = self.name.sub(/Controller$/, '').singularize
namespaced_class.constantize
rescue NameError
nil
end
... | [
"def",
"initialize_resources_class_accessors!",
"#:nodoc:",
"# First priority is the namespaced model, e.g. User::Group",
"self",
".",
"resource_class",
"||=",
"begin",
"namespaced_class",
"=",
"self",
".",
"name",
".",
"sub",
"(",
"/",
"/",
",",
"''",
")",
".",
"singul... | Initialize resources class accessors and set their default values. | [
"Initialize",
"resources",
"class",
"accessors",
"and",
"set",
"their",
"default",
"values",
"."
] | 2ba6982ddd6a56e7ef9ed7396473e5500ad77126 | https://github.com/activeadmin/inherited_resources/blob/2ba6982ddd6a56e7ef9ed7396473e5500ad77126/lib/inherited_resources/class_methods.rb#L319-L394 |
15,215 | activeadmin/inherited_resources | lib/inherited_resources/polymorphic_helpers.rb | InheritedResources.PolymorphicHelpers.symbols_for_association_chain | def symbols_for_association_chain #:nodoc:
polymorphic_config = resources_configuration[:polymorphic]
parents_symbols.map do |symbol|
if symbol == :polymorphic
params_keys = params.keys
keys = polymorphic_config[:symbols].map do |poly|
params_keys.include... | ruby | def symbols_for_association_chain #:nodoc:
polymorphic_config = resources_configuration[:polymorphic]
parents_symbols.map do |symbol|
if symbol == :polymorphic
params_keys = params.keys
keys = polymorphic_config[:symbols].map do |poly|
params_keys.include... | [
"def",
"symbols_for_association_chain",
"#:nodoc:",
"polymorphic_config",
"=",
"resources_configuration",
"[",
":polymorphic",
"]",
"parents_symbols",
".",
"map",
"do",
"|",
"symbol",
"|",
"if",
"symbol",
"==",
":polymorphic",
"params_keys",
"=",
"params",
".",
"keys"... | Maps parents_symbols to build association chain.
If the parents_symbols find :polymorphic, it goes through the
params keys to see which polymorphic parent matches the given params.
When optional is given, it does not raise errors if the polymorphic
params are missing. | [
"Maps",
"parents_symbols",
"to",
"build",
"association",
"chain",
"."
] | 2ba6982ddd6a56e7ef9ed7396473e5500ad77126 | https://github.com/activeadmin/inherited_resources/blob/2ba6982ddd6a56e7ef9ed7396473e5500ad77126/lib/inherited_resources/polymorphic_helpers.rb#L148-L172 |
15,216 | unsplash/unsplash_rb | lib/unsplash/connection.rb | Unsplash.Connection.authorization_url | def authorization_url(requested_scopes = ["public"])
@oauth.auth_code.authorize_url(redirect_uri: Unsplash.configuration.application_redirect_uri,
scope: requested_scopes.join(" "))
end | ruby | def authorization_url(requested_scopes = ["public"])
@oauth.auth_code.authorize_url(redirect_uri: Unsplash.configuration.application_redirect_uri,
scope: requested_scopes.join(" "))
end | [
"def",
"authorization_url",
"(",
"requested_scopes",
"=",
"[",
"\"public\"",
"]",
")",
"@oauth",
".",
"auth_code",
".",
"authorize_url",
"(",
"redirect_uri",
":",
"Unsplash",
".",
"configuration",
".",
"application_redirect_uri",
",",
"scope",
":",
"requested_scopes... | Create a Connection object.
@param version [String] The Unsplash API version to use.
@param api_base_uri [String] Base URI at which to make API calls.
@param oauth_base_uri [String] Base URI for OAuth requests.
Get OAuth URL for user authentication and authorization.
@param requested_scopes [Array] An array of per... | [
"Create",
"a",
"Connection",
"object",
"."
] | d2b3f1721616941671621fca332b183d9b6053b4 | https://github.com/unsplash/unsplash_rb/blob/d2b3f1721616941671621fca332b183d9b6053b4/lib/unsplash/connection.rb#L39-L42 |
15,217 | unsplash/unsplash_rb | lib/unsplash/client.rb | Unsplash.Client.reload! | def reload!
if links && links["self"]
attrs = JSON.parse(connection.get(links["self"]).body)
@attributes = OpenStruct.new(attrs)
self
else
raise Unsplash::Error.new "Missing self link for #{self.class} with ID #{self.id}"
end
end | ruby | def reload!
if links && links["self"]
attrs = JSON.parse(connection.get(links["self"]).body)
@attributes = OpenStruct.new(attrs)
self
else
raise Unsplash::Error.new "Missing self link for #{self.class} with ID #{self.id}"
end
end | [
"def",
"reload!",
"if",
"links",
"&&",
"links",
"[",
"\"self\"",
"]",
"attrs",
"=",
"JSON",
".",
"parse",
"(",
"connection",
".",
"get",
"(",
"links",
"[",
"\"self\"",
"]",
")",
".",
"body",
")",
"@attributes",
"=",
"OpenStruct",
".",
"new",
"(",
"at... | Build an Unsplash object with the given attributes.
@param attrs [Hash]
(Re)load full object details from Unsplash.
@return [Unspash::Client] Itself, with full details reloaded. | [
"Build",
"an",
"Unsplash",
"object",
"with",
"the",
"given",
"attributes",
"."
] | d2b3f1721616941671621fca332b183d9b6053b4 | https://github.com/unsplash/unsplash_rb/blob/d2b3f1721616941671621fca332b183d9b6053b4/lib/unsplash/client.rb#L14-L22 |
15,218 | unsplash/unsplash_rb | lib/unsplash/user.rb | Unsplash.User.photos | def photos(page = 1, per_page = 10)
params = {
page: page,
per_page: per_page
}
list = JSON.parse(connection.get("/users/#{username}/photos", params).body)
list.map do |photo|
Unsplash::Photo.new photo.to_hash
end
end | ruby | def photos(page = 1, per_page = 10)
params = {
page: page,
per_page: per_page
}
list = JSON.parse(connection.get("/users/#{username}/photos", params).body)
list.map do |photo|
Unsplash::Photo.new photo.to_hash
end
end | [
"def",
"photos",
"(",
"page",
"=",
"1",
",",
"per_page",
"=",
"10",
")",
"params",
"=",
"{",
"page",
":",
"page",
",",
"per_page",
":",
"per_page",
"}",
"list",
"=",
"JSON",
".",
"parse",
"(",
"connection",
".",
"get",
"(",
"\"/users/#{username}/photos... | Get a list of photos uploaded by the user.
@param page [Integer] Which page of results to return.
@param per_page [Integer] The number of results per page.
@return [Array] a list of +Unsplash::Photo+ objects. | [
"Get",
"a",
"list",
"of",
"photos",
"uploaded",
"by",
"the",
"user",
"."
] | d2b3f1721616941671621fca332b183d9b6053b4 | https://github.com/unsplash/unsplash_rb/blob/d2b3f1721616941671621fca332b183d9b6053b4/lib/unsplash/user.rb#L48-L58 |
15,219 | unsplash/unsplash_rb | lib/unsplash/user.rb | Unsplash.User.collections | def collections(page = 1, per_page = 10)
params = {
page: page,
per_page: per_page
}
list = JSON.parse(connection.get("/users/#{username}/collections", params).body)
list.map do |collection|
Unsplash::Collection.new collection.to_hash
end
end | ruby | def collections(page = 1, per_page = 10)
params = {
page: page,
per_page: per_page
}
list = JSON.parse(connection.get("/users/#{username}/collections", params).body)
list.map do |collection|
Unsplash::Collection.new collection.to_hash
end
end | [
"def",
"collections",
"(",
"page",
"=",
"1",
",",
"per_page",
"=",
"10",
")",
"params",
"=",
"{",
"page",
":",
"page",
",",
"per_page",
":",
"per_page",
"}",
"list",
"=",
"JSON",
".",
"parse",
"(",
"connection",
".",
"get",
"(",
"\"/users/#{username}/c... | Get a list of collections created by the user.
@param page [Integer] Which page of results to return.
@param per_page [Integer] The number of results per page. (default: 10, maximum: 30)
@return [Array] a list of +Unsplash::Collection+ objects. | [
"Get",
"a",
"list",
"of",
"collections",
"created",
"by",
"the",
"user",
"."
] | d2b3f1721616941671621fca332b183d9b6053b4 | https://github.com/unsplash/unsplash_rb/blob/d2b3f1721616941671621fca332b183d9b6053b4/lib/unsplash/user.rb#L80-L90 |
15,220 | unsplash/unsplash_rb | lib/unsplash/collection.rb | Unsplash.Collection.update | def update(title: nil, description: nil, private: nil)
params = {
title: title,
description: description,
private: private
}.select { |k,v| v }
updated = JSON.parse(connection.put("/collections/#{id}", params).body)
self.title = updated["title"]
self.descr... | ruby | def update(title: nil, description: nil, private: nil)
params = {
title: title,
description: description,
private: private
}.select { |k,v| v }
updated = JSON.parse(connection.put("/collections/#{id}", params).body)
self.title = updated["title"]
self.descr... | [
"def",
"update",
"(",
"title",
":",
"nil",
",",
"description",
":",
"nil",
",",
"private",
":",
"nil",
")",
"params",
"=",
"{",
"title",
":",
"title",
",",
"description",
":",
"description",
",",
"private",
":",
"private",
"}",
".",
"select",
"{",
"|... | Update the collection's attributes.
@param title [String] The title of the collection.
@param description [String] The collection's description. (optional)
@param private [Boolean] Whether to make the collection private. (optional) | [
"Update",
"the",
"collection",
"s",
"attributes",
"."
] | d2b3f1721616941671621fca332b183d9b6053b4 | https://github.com/unsplash/unsplash_rb/blob/d2b3f1721616941671621fca332b183d9b6053b4/lib/unsplash/collection.rb#L81-L91 |
15,221 | unsplash/unsplash_rb | lib/unsplash/collection.rb | Unsplash.Collection.add | def add(photo)
response = JSON.parse(connection.post("/collections/#{id}/add", { photo_id: photo.id }).body)
{
photo_id: response["photo"]["id"],
collection_id: response["collection"]["id"],
user_id: response["user"]["id"],
created_at: response["created_at"]
... | ruby | def add(photo)
response = JSON.parse(connection.post("/collections/#{id}/add", { photo_id: photo.id }).body)
{
photo_id: response["photo"]["id"],
collection_id: response["collection"]["id"],
user_id: response["user"]["id"],
created_at: response["created_at"]
... | [
"def",
"add",
"(",
"photo",
")",
"response",
"=",
"JSON",
".",
"parse",
"(",
"connection",
".",
"post",
"(",
"\"/collections/#{id}/add\"",
",",
"{",
"photo_id",
":",
"photo",
".",
"id",
"}",
")",
".",
"body",
")",
"{",
"photo_id",
":",
"response",
"[",... | Add a photo to the collection. If the photo is already in the collection,
this action has no effect.
@param [Unsplash::Photo] The photo to add.
@return [Hash] Collected photo metadata. | [
"Add",
"a",
"photo",
"to",
"the",
"collection",
".",
"If",
"the",
"photo",
"is",
"already",
"in",
"the",
"collection",
"this",
"action",
"has",
"no",
"effect",
"."
] | d2b3f1721616941671621fca332b183d9b6053b4 | https://github.com/unsplash/unsplash_rb/blob/d2b3f1721616941671621fca332b183d9b6053b4/lib/unsplash/collection.rb#L118-L126 |
15,222 | unsplash/unsplash_rb | lib/unsplash/collection.rb | Unsplash.Collection.remove | def remove(photo)
response = connection.delete("/collections/#{id}/remove", photo_id: photo.id)
(200..299).include?(response.status)
end | ruby | def remove(photo)
response = connection.delete("/collections/#{id}/remove", photo_id: photo.id)
(200..299).include?(response.status)
end | [
"def",
"remove",
"(",
"photo",
")",
"response",
"=",
"connection",
".",
"delete",
"(",
"\"/collections/#{id}/remove\"",
",",
"photo_id",
":",
"photo",
".",
"id",
")",
"(",
"200",
"..",
"299",
")",
".",
"include?",
"(",
"response",
".",
"status",
")",
"en... | Remove a photo from the collection. If the photo is not in the collection,
this action has no effect.
@param [Unsplash::Photo] The photo to remove.
@return [Boolean] +true+ on success. | [
"Remove",
"a",
"photo",
"from",
"the",
"collection",
".",
"If",
"the",
"photo",
"is",
"not",
"in",
"the",
"collection",
"this",
"action",
"has",
"no",
"effect",
"."
] | d2b3f1721616941671621fca332b183d9b6053b4 | https://github.com/unsplash/unsplash_rb/blob/d2b3f1721616941671621fca332b183d9b6053b4/lib/unsplash/collection.rb#L132-L135 |
15,223 | floraison/fugit | lib/fugit/duration.rb | Fugit.Duration.drop_seconds | def drop_seconds
h = @h.dup
h.delete(:sec)
h[:min] = 0 if h.empty?
self.class.allocate.init(nil, { literal: true }, h)
end | ruby | def drop_seconds
h = @h.dup
h.delete(:sec)
h[:min] = 0 if h.empty?
self.class.allocate.init(nil, { literal: true }, h)
end | [
"def",
"drop_seconds",
"h",
"=",
"@h",
".",
"dup",
"h",
".",
"delete",
"(",
":sec",
")",
"h",
"[",
":min",
"]",
"=",
"0",
"if",
"h",
".",
"empty?",
"self",
".",
"class",
".",
"allocate",
".",
"init",
"(",
"nil",
",",
"{",
"literal",
":",
"true"... | Returns a copy of this duration, omitting its seconds. | [
"Returns",
"a",
"copy",
"of",
"this",
"duration",
"omitting",
"its",
"seconds",
"."
] | f9f5e48a06e615b1e29f8ec176c40bbd2cfaf151 | https://github.com/floraison/fugit/blob/f9f5e48a06e615b1e29f8ec176c40bbd2cfaf151/lib/fugit/duration.rb#L297-L304 |
15,224 | huacnlee/rucaptcha | lib/rucaptcha/controller_helpers.rb | RuCaptcha.ControllerHelpers.rucaptcha_sesion_key_key | def rucaptcha_sesion_key_key
session_id = session.respond_to?(:id) ? session.id : session[:session_id]
warning_when_session_invalid if session_id.blank?
['rucaptcha-session', session_id].join(':')
end | ruby | def rucaptcha_sesion_key_key
session_id = session.respond_to?(:id) ? session.id : session[:session_id]
warning_when_session_invalid if session_id.blank?
['rucaptcha-session', session_id].join(':')
end | [
"def",
"rucaptcha_sesion_key_key",
"session_id",
"=",
"session",
".",
"respond_to?",
"(",
":id",
")",
"?",
"session",
".",
"id",
":",
"session",
"[",
":session_id",
"]",
"warning_when_session_invalid",
"if",
"session_id",
".",
"blank?",
"[",
"'rucaptcha-session'",
... | session key of rucaptcha | [
"session",
"key",
"of",
"rucaptcha"
] | b7074ed9fd84e9768e91b39555ea037ffd327032 | https://github.com/huacnlee/rucaptcha/blob/b7074ed9fd84e9768e91b39555ea037ffd327032/lib/rucaptcha/controller_helpers.rb#L10-L14 |
15,225 | huacnlee/rucaptcha | lib/rucaptcha/controller_helpers.rb | RuCaptcha.ControllerHelpers.generate_rucaptcha | def generate_rucaptcha
res = RuCaptcha.generate()
session_val = {
code: res[0],
time: Time.now.to_i
}
RuCaptcha.cache.write(rucaptcha_sesion_key_key, session_val, expires_in: RuCaptcha.config.expires_in)
res[1]
end | ruby | def generate_rucaptcha
res = RuCaptcha.generate()
session_val = {
code: res[0],
time: Time.now.to_i
}
RuCaptcha.cache.write(rucaptcha_sesion_key_key, session_val, expires_in: RuCaptcha.config.expires_in)
res[1]
end | [
"def",
"generate_rucaptcha",
"res",
"=",
"RuCaptcha",
".",
"generate",
"(",
")",
"session_val",
"=",
"{",
"code",
":",
"res",
"[",
"0",
"]",
",",
"time",
":",
"Time",
".",
"now",
".",
"to_i",
"}",
"RuCaptcha",
".",
"cache",
".",
"write",
"(",
"rucapt... | Generate a new Captcha | [
"Generate",
"a",
"new",
"Captcha"
] | b7074ed9fd84e9768e91b39555ea037ffd327032 | https://github.com/huacnlee/rucaptcha/blob/b7074ed9fd84e9768e91b39555ea037ffd327032/lib/rucaptcha/controller_helpers.rb#L17-L25 |
15,226 | huacnlee/rucaptcha | lib/rucaptcha/controller_helpers.rb | RuCaptcha.ControllerHelpers.verify_rucaptcha? | def verify_rucaptcha?(resource = nil, opts = {})
opts ||= {}
store_info = RuCaptcha.cache.read(rucaptcha_sesion_key_key)
# make sure move used key
RuCaptcha.cache.delete(rucaptcha_sesion_key_key) unless opts[:keep_session]
# Make sure session exist
if store_info.blank?
retu... | ruby | def verify_rucaptcha?(resource = nil, opts = {})
opts ||= {}
store_info = RuCaptcha.cache.read(rucaptcha_sesion_key_key)
# make sure move used key
RuCaptcha.cache.delete(rucaptcha_sesion_key_key) unless opts[:keep_session]
# Make sure session exist
if store_info.blank?
retu... | [
"def",
"verify_rucaptcha?",
"(",
"resource",
"=",
"nil",
",",
"opts",
"=",
"{",
"}",
")",
"opts",
"||=",
"{",
"}",
"store_info",
"=",
"RuCaptcha",
".",
"cache",
".",
"read",
"(",
"rucaptcha_sesion_key_key",
")",
"# make sure move used key",
"RuCaptcha",
".",
... | Verify captcha code
params:
resource - [optional] a ActiveModel object, if given will add validation error message to object.
:keep_session - if true, RuCaptcha will not delete the captcha code session.
:captcha - if given, the value of it will be used to verify the captcha,
if do not give or blank, th... | [
"Verify",
"captcha",
"code"
] | b7074ed9fd84e9768e91b39555ea037ffd327032 | https://github.com/huacnlee/rucaptcha/blob/b7074ed9fd84e9768e91b39555ea037ffd327032/lib/rucaptcha/controller_helpers.rb#L42-L70 |
15,227 | oesmith/puffing-billy | lib/billy/ssl/authority.rb | Billy.Authority.generate | def generate
cert = OpenSSL::X509::Certificate.new
configure(cert)
add_extensions(cert)
cert.sign(key, OpenSSL::Digest::SHA256.new)
end | ruby | def generate
cert = OpenSSL::X509::Certificate.new
configure(cert)
add_extensions(cert)
cert.sign(key, OpenSSL::Digest::SHA256.new)
end | [
"def",
"generate",
"cert",
"=",
"OpenSSL",
"::",
"X509",
"::",
"Certificate",
".",
"new",
"configure",
"(",
"cert",
")",
"add_extensions",
"(",
"cert",
")",
"cert",
".",
"sign",
"(",
"key",
",",
"OpenSSL",
"::",
"Digest",
"::",
"SHA256",
".",
"new",
")... | Generate a fresh new certificate for the configured domain. | [
"Generate",
"a",
"fresh",
"new",
"certificate",
"for",
"the",
"configured",
"domain",
"."
] | e1a2e2a16fe1ed0a50a20bc01bd181628c6a57e2 | https://github.com/oesmith/puffing-billy/blob/e1a2e2a16fe1ed0a50a20bc01bd181628c6a57e2/lib/billy/ssl/authority.rb#L68-L73 |
15,228 | oesmith/puffing-billy | lib/billy/ssl/certificate_chain.rb | Billy.CertificateChain.file | def file
contents = certificates.map { |cert| cert.to_pem }.join
write_file("chain-#{domain}.pem", contents)
end | ruby | def file
contents = certificates.map { |cert| cert.to_pem }.join
write_file("chain-#{domain}.pem", contents)
end | [
"def",
"file",
"contents",
"=",
"certificates",
".",
"map",
"{",
"|",
"cert",
"|",
"cert",
".",
"to_pem",
"}",
".",
"join",
"write_file",
"(",
"\"chain-#{domain}.pem\"",
",",
"contents",
")",
"end"
] | Just pass all certificates into the new instance. We use the variadic
argument feature here to ease the usage and improve the readability.
Example:
certs_chain_file = Billy::CertificateChain.new('localhost',
cert1,
... | [
"Just",
"pass",
"all",
"certificates",
"into",
"the",
"new",
"instance",
".",
"We",
"use",
"the",
"variadic",
"argument",
"feature",
"here",
"to",
"ease",
"the",
"usage",
"and",
"improve",
"the",
"readability",
"."
] | e1a2e2a16fe1ed0a50a20bc01bd181628c6a57e2 | https://github.com/oesmith/puffing-billy/blob/e1a2e2a16fe1ed0a50a20bc01bd181628c6a57e2/lib/billy/ssl/certificate_chain.rb#L36-L39 |
15,229 | zendesk/active_record_shards | lib/active_record_shards/connection_switcher-4-0.rb | ActiveRecordShards.ConnectionSwitcher.connection_pool_name | def connection_pool_name # :nodoc:
name = current_shard_selection.shard_name(self)
if configurations[name].nil? && on_slave?
current_shard_selection.shard_name(self, false)
else
name
end
end | ruby | def connection_pool_name # :nodoc:
name = current_shard_selection.shard_name(self)
if configurations[name].nil? && on_slave?
current_shard_selection.shard_name(self, false)
else
name
end
end | [
"def",
"connection_pool_name",
"# :nodoc:",
"name",
"=",
"current_shard_selection",
".",
"shard_name",
"(",
"self",
")",
"if",
"configurations",
"[",
"name",
"]",
".",
"nil?",
"&&",
"on_slave?",
"current_shard_selection",
".",
"shard_name",
"(",
"self",
",",
"fals... | Name of the connection pool. Used by ConnectionHandler to retrieve the current connection pool. | [
"Name",
"of",
"the",
"connection",
"pool",
".",
"Used",
"by",
"ConnectionHandler",
"to",
"retrieve",
"the",
"current",
"connection",
"pool",
"."
] | a2a4daf8b1533e3b6de8447da759dca60a28e4e8 | https://github.com/zendesk/active_record_shards/blob/a2a4daf8b1533e3b6de8447da759dca60a28e4e8/lib/active_record_shards/connection_switcher-4-0.rb#L4-L12 |
15,230 | jimweirich/builder | lib/builder/xmlmarkup.rb | Builder.XmlMarkup.declare! | def declare!(inst, *args, &block)
_indent
@target << "<!#{inst}"
args.each do |arg|
case arg
when ::String
@target << %{ "#{arg}"} # " WART
when ::Symbol
@target << " #{arg}"
end
end
if ::Kernel::block_given?
@target << " ["
... | ruby | def declare!(inst, *args, &block)
_indent
@target << "<!#{inst}"
args.each do |arg|
case arg
when ::String
@target << %{ "#{arg}"} # " WART
when ::Symbol
@target << " #{arg}"
end
end
if ::Kernel::block_given?
@target << " ["
... | [
"def",
"declare!",
"(",
"inst",
",",
"*",
"args",
",",
"&",
"block",
")",
"_indent",
"@target",
"<<",
"\"<!#{inst}\"",
"args",
".",
"each",
"do",
"|",
"arg",
"|",
"case",
"arg",
"when",
"::",
"String",
"@target",
"<<",
"%{ \"#{arg}\"}",
"# \" WART",
"whe... | Insert an XML declaration into the XML markup.
For example:
xml.declare! :ELEMENT, :blah, "yada"
# => <!ELEMENT blah "yada"> | [
"Insert",
"an",
"XML",
"declaration",
"into",
"the",
"XML",
"markup",
"."
] | c80100f8205b2e918dbff605682b01ab0fabb866 | https://github.com/jimweirich/builder/blob/c80100f8205b2e918dbff605682b01ab0fabb866/lib/builder/xmlmarkup.rb#L214-L233 |
15,231 | jimweirich/builder | lib/builder/xmlmarkup.rb | Builder.XmlMarkup.instruct! | def instruct!(directive_tag=:xml, attrs={})
_ensure_no_block ::Kernel::block_given?
if directive_tag == :xml
a = { :version=>"1.0", :encoding=>"UTF-8" }
attrs = a.merge attrs
@encoding = attrs[:encoding].downcase
end
_special(
"<?#{directive_tag}",
"?>",
... | ruby | def instruct!(directive_tag=:xml, attrs={})
_ensure_no_block ::Kernel::block_given?
if directive_tag == :xml
a = { :version=>"1.0", :encoding=>"UTF-8" }
attrs = a.merge attrs
@encoding = attrs[:encoding].downcase
end
_special(
"<?#{directive_tag}",
"?>",
... | [
"def",
"instruct!",
"(",
"directive_tag",
"=",
":xml",
",",
"attrs",
"=",
"{",
"}",
")",
"_ensure_no_block",
"::",
"Kernel",
"::",
"block_given?",
"if",
"directive_tag",
"==",
":xml",
"a",
"=",
"{",
":version",
"=>",
"\"1.0\"",
",",
":encoding",
"=>",
"\"U... | Insert a processing instruction into the XML markup. E.g.
For example:
xml.instruct!
#=> <?xml version="1.0" encoding="UTF-8"?>
xml.instruct! :aaa, :bbb=>"ccc"
#=> <?aaa bbb="ccc"?>
Note: If the encoding is setup to "UTF-8" and the value of
$KCODE is "UTF8", then builder will emit UTF-8 e... | [
"Insert",
"a",
"processing",
"instruction",
"into",
"the",
"XML",
"markup",
".",
"E",
".",
"g",
"."
] | c80100f8205b2e918dbff605682b01ab0fabb866 | https://github.com/jimweirich/builder/blob/c80100f8205b2e918dbff605682b01ab0fabb866/lib/builder/xmlmarkup.rb#L247-L260 |
15,232 | jimweirich/builder | lib/builder/xmlmarkup.rb | Builder.XmlMarkup._special | def _special(open, close, data=nil, attrs=nil, order=[])
_indent
@target << open
@target << data if data
_insert_attributes(attrs, order) if attrs
@target << close
_newline
end | ruby | def _special(open, close, data=nil, attrs=nil, order=[])
_indent
@target << open
@target << data if data
_insert_attributes(attrs, order) if attrs
@target << close
_newline
end | [
"def",
"_special",
"(",
"open",
",",
"close",
",",
"data",
"=",
"nil",
",",
"attrs",
"=",
"nil",
",",
"order",
"=",
"[",
"]",
")",
"_indent",
"@target",
"<<",
"open",
"@target",
"<<",
"data",
"if",
"data",
"_insert_attributes",
"(",
"attrs",
",",
"or... | Insert special instruction. | [
"Insert",
"special",
"instruction",
"."
] | c80100f8205b2e918dbff605682b01ab0fabb866 | https://github.com/jimweirich/builder/blob/c80100f8205b2e918dbff605682b01ab0fabb866/lib/builder/xmlmarkup.rb#L285-L292 |
15,233 | jimweirich/builder | lib/builder/xmlbase.rb | Builder.XmlBase.method_missing | def method_missing(sym, *args, &block)
cache_method_call(sym) if ::Builder::XmlBase.cache_method_calls
tag!(sym, *args, &block)
end | ruby | def method_missing(sym, *args, &block)
cache_method_call(sym) if ::Builder::XmlBase.cache_method_calls
tag!(sym, *args, &block)
end | [
"def",
"method_missing",
"(",
"sym",
",",
"*",
"args",
",",
"&",
"block",
")",
"cache_method_call",
"(",
"sym",
")",
"if",
"::",
"Builder",
"::",
"XmlBase",
".",
"cache_method_calls",
"tag!",
"(",
"sym",
",",
"args",
",",
"block",
")",
"end"
] | Create XML markup based on the name of the method. This method
is never invoked directly, but is called for each markup method
in the markup block that isn't cached. | [
"Create",
"XML",
"markup",
"based",
"on",
"the",
"name",
"of",
"the",
"method",
".",
"This",
"method",
"is",
"never",
"invoked",
"directly",
"but",
"is",
"called",
"for",
"each",
"markup",
"method",
"in",
"the",
"markup",
"block",
"that",
"isn",
"t",
"ca... | c80100f8205b2e918dbff605682b01ab0fabb866 | https://github.com/jimweirich/builder/blob/c80100f8205b2e918dbff605682b01ab0fabb866/lib/builder/xmlbase.rb#L91-L94 |
15,234 | jimweirich/builder | lib/builder/xmlbase.rb | Builder.XmlBase.cache_method_call | def cache_method_call(sym)
class << self; self; end.class_eval do
unless method_defined?(sym)
define_method(sym) do |*args, &block|
tag!(sym, *args, &block)
end
end
end
end | ruby | def cache_method_call(sym)
class << self; self; end.class_eval do
unless method_defined?(sym)
define_method(sym) do |*args, &block|
tag!(sym, *args, &block)
end
end
end
end | [
"def",
"cache_method_call",
"(",
"sym",
")",
"class",
"<<",
"self",
";",
"self",
";",
"end",
".",
"class_eval",
"do",
"unless",
"method_defined?",
"(",
"sym",
")",
"define_method",
"(",
"sym",
")",
"do",
"|",
"*",
"args",
",",
"&",
"block",
"|",
"tag!"... | If XmlBase.cache_method_calls = true, we dynamicly create the method
missed as an instance method on the XMLBase object. Because XML
documents are usually very repetative in nature, the next node will
be handled by the new method instead of method_missing. As
method_missing is very slow, this speeds up document gen... | [
"If",
"XmlBase",
".",
"cache_method_calls",
"=",
"true",
"we",
"dynamicly",
"create",
"the",
"method",
"missed",
"as",
"an",
"instance",
"method",
"on",
"the",
"XMLBase",
"object",
".",
"Because",
"XML",
"documents",
"are",
"usually",
"very",
"repetative",
"in... | c80100f8205b2e918dbff605682b01ab0fabb866 | https://github.com/jimweirich/builder/blob/c80100f8205b2e918dbff605682b01ab0fabb866/lib/builder/xmlbase.rb#L186-L194 |
15,235 | senny/sablon | lib/sablon/template.rb | Sablon.Template.render_to_file | def render_to_file(output_path, context, properties = {})
File.open(output_path, 'wb') do |f|
f.write render_to_string(context, properties)
end
end | ruby | def render_to_file(output_path, context, properties = {})
File.open(output_path, 'wb') do |f|
f.write render_to_string(context, properties)
end
end | [
"def",
"render_to_file",
"(",
"output_path",
",",
"context",
",",
"properties",
"=",
"{",
"}",
")",
"File",
".",
"open",
"(",
"output_path",
",",
"'wb'",
")",
"do",
"|",
"f",
"|",
"f",
".",
"write",
"render_to_string",
"(",
"context",
",",
"properties",
... | Same as +render_to_string+ but writes the processed template to +output_path+. | [
"Same",
"as",
"+",
"render_to_string",
"+",
"but",
"writes",
"the",
"processed",
"template",
"to",
"+",
"output_path",
"+",
"."
] | c43be5847593a3ecaf40c2b6138e549e0446c7f8 | https://github.com/senny/sablon/blob/c43be5847593a3ecaf40c2b6138e549e0446c7f8/lib/sablon/template.rb#L41-L45 |
15,236 | senny/sablon | lib/sablon/configuration/configuration.rb | Sablon.Configuration.register_html_tag | def register_html_tag(tag_name, type = :inline, **options)
tag = HTMLTag.new(tag_name, type, **options)
@permitted_html_tags[tag.name] = tag
end | ruby | def register_html_tag(tag_name, type = :inline, **options)
tag = HTMLTag.new(tag_name, type, **options)
@permitted_html_tags[tag.name] = tag
end | [
"def",
"register_html_tag",
"(",
"tag_name",
",",
"type",
"=",
":inline",
",",
"**",
"options",
")",
"tag",
"=",
"HTMLTag",
".",
"new",
"(",
"tag_name",
",",
"type",
",",
"**",
"options",
")",
"@permitted_html_tags",
"[",
"tag",
".",
"name",
"]",
"=",
... | Adds a new tag to the permitted tags hash or replaces an existing one | [
"Adds",
"a",
"new",
"tag",
"to",
"the",
"permitted",
"tags",
"hash",
"or",
"replaces",
"an",
"existing",
"one"
] | c43be5847593a3ecaf40c2b6138e549e0446c7f8 | https://github.com/senny/sablon/blob/c43be5847593a3ecaf40c2b6138e549e0446c7f8/lib/sablon/configuration/configuration.rb#L17-L20 |
15,237 | celluloid/celluloid | lib/celluloid/supervision/container/behavior/pool.rb | Celluloid.ClassMethods.pool_link | def pool_link(klass, config = {}, &block)
Supervision::Container::Pool.new_link(pooling_options(config, block: block, actors: klass))
end | ruby | def pool_link(klass, config = {}, &block)
Supervision::Container::Pool.new_link(pooling_options(config, block: block, actors: klass))
end | [
"def",
"pool_link",
"(",
"klass",
",",
"config",
"=",
"{",
"}",
",",
"&",
"block",
")",
"Supervision",
"::",
"Container",
"::",
"Pool",
".",
"new_link",
"(",
"pooling_options",
"(",
"config",
",",
"block",
":",
"block",
",",
"actors",
":",
"klass",
")"... | Same as pool, but links to the pool manager | [
"Same",
"as",
"pool",
"but",
"links",
"to",
"the",
"pool",
"manager"
] | 2c21bbc481ae65ba527f415f52df4ae99700b72f | https://github.com/celluloid/celluloid/blob/2c21bbc481ae65ba527f415f52df4ae99700b72f/lib/celluloid/supervision/container/behavior/pool.rb#L18-L20 |
15,238 | celluloid/celluloid | lib/celluloid.rb | Celluloid.ClassMethods.new_link | def new_link(*args, &block)
raise NotActorError, "can't link outside actor context" unless Celluloid.actor?
proxy = Cell.new(allocate, behavior_options, actor_options).proxy
Actor.link(proxy)
proxy._send_(:initialize, *args, &block)
proxy
end | ruby | def new_link(*args, &block)
raise NotActorError, "can't link outside actor context" unless Celluloid.actor?
proxy = Cell.new(allocate, behavior_options, actor_options).proxy
Actor.link(proxy)
proxy._send_(:initialize, *args, &block)
proxy
end | [
"def",
"new_link",
"(",
"*",
"args",
",",
"&",
"block",
")",
"raise",
"NotActorError",
",",
"\"can't link outside actor context\"",
"unless",
"Celluloid",
".",
"actor?",
"proxy",
"=",
"Cell",
".",
"new",
"(",
"allocate",
",",
"behavior_options",
",",
"actor_opti... | Create a new actor and link to the current one | [
"Create",
"a",
"new",
"actor",
"and",
"link",
"to",
"the",
"current",
"one"
] | 2c21bbc481ae65ba527f415f52df4ae99700b72f | https://github.com/celluloid/celluloid/blob/2c21bbc481ae65ba527f415f52df4ae99700b72f/lib/celluloid.rb#L205-L212 |
15,239 | celluloid/celluloid | lib/celluloid/condition.rb | Celluloid.Condition.wait | def wait(timeout = nil)
raise ConditionError, "cannot wait for signals while exclusive" if Celluloid.exclusive?
if actor = Thread.current[:celluloid_actor]
task = Task.current
if timeout
bt = caller
timer = actor.timers.after(timeout) do
exception = Condition... | ruby | def wait(timeout = nil)
raise ConditionError, "cannot wait for signals while exclusive" if Celluloid.exclusive?
if actor = Thread.current[:celluloid_actor]
task = Task.current
if timeout
bt = caller
timer = actor.timers.after(timeout) do
exception = Condition... | [
"def",
"wait",
"(",
"timeout",
"=",
"nil",
")",
"raise",
"ConditionError",
",",
"\"cannot wait for signals while exclusive\"",
"if",
"Celluloid",
".",
"exclusive?",
"if",
"actor",
"=",
"Thread",
".",
"current",
"[",
":celluloid_actor",
"]",
"task",
"=",
"Task",
... | Wait for the given signal and return the associated value | [
"Wait",
"for",
"the",
"given",
"signal",
"and",
"return",
"the",
"associated",
"value"
] | 2c21bbc481ae65ba527f415f52df4ae99700b72f | https://github.com/celluloid/celluloid/blob/2c21bbc481ae65ba527f415f52df4ae99700b72f/lib/celluloid/condition.rb#L36-L63 |
15,240 | celluloid/celluloid | lib/celluloid/condition.rb | Celluloid.Condition.signal | def signal(value = nil)
@mutex.synchronize do
if waiter = @waiters.shift
waiter << SignalConditionRequest.new(waiter.task, value)
else
Internals::Logger.with_backtrace(caller(3)) do |logger|
logger.debug("Celluloid::Condition signaled spuriously")
end
... | ruby | def signal(value = nil)
@mutex.synchronize do
if waiter = @waiters.shift
waiter << SignalConditionRequest.new(waiter.task, value)
else
Internals::Logger.with_backtrace(caller(3)) do |logger|
logger.debug("Celluloid::Condition signaled spuriously")
end
... | [
"def",
"signal",
"(",
"value",
"=",
"nil",
")",
"@mutex",
".",
"synchronize",
"do",
"if",
"waiter",
"=",
"@waiters",
".",
"shift",
"waiter",
"<<",
"SignalConditionRequest",
".",
"new",
"(",
"waiter",
".",
"task",
",",
"value",
")",
"else",
"Internals",
"... | Send a signal to the first task waiting on this condition | [
"Send",
"a",
"signal",
"to",
"the",
"first",
"task",
"waiting",
"on",
"this",
"condition"
] | 2c21bbc481ae65ba527f415f52df4ae99700b72f | https://github.com/celluloid/celluloid/blob/2c21bbc481ae65ba527f415f52df4ae99700b72f/lib/celluloid/condition.rb#L66-L76 |
15,241 | celluloid/celluloid | lib/celluloid/condition.rb | Celluloid.Condition.broadcast | def broadcast(value = nil)
@mutex.synchronize do
@waiters.each { |waiter| waiter << SignalConditionRequest.new(waiter.task, value) }
@waiters.clear
end
end | ruby | def broadcast(value = nil)
@mutex.synchronize do
@waiters.each { |waiter| waiter << SignalConditionRequest.new(waiter.task, value) }
@waiters.clear
end
end | [
"def",
"broadcast",
"(",
"value",
"=",
"nil",
")",
"@mutex",
".",
"synchronize",
"do",
"@waiters",
".",
"each",
"{",
"|",
"waiter",
"|",
"waiter",
"<<",
"SignalConditionRequest",
".",
"new",
"(",
"waiter",
".",
"task",
",",
"value",
")",
"}",
"@waiters",... | Broadcast a value to all waiting tasks and threads | [
"Broadcast",
"a",
"value",
"to",
"all",
"waiting",
"tasks",
"and",
"threads"
] | 2c21bbc481ae65ba527f415f52df4ae99700b72f | https://github.com/celluloid/celluloid/blob/2c21bbc481ae65ba527f415f52df4ae99700b72f/lib/celluloid/condition.rb#L79-L84 |
15,242 | celluloid/celluloid | lib/celluloid/future.rb | Celluloid.Future.execute | def execute(receiver, method, args, block)
@mutex.synchronize do
raise "already calling" if @call
@call = Call::Sync.new(self, method, args, block)
end
receiver << @call
end | ruby | def execute(receiver, method, args, block)
@mutex.synchronize do
raise "already calling" if @call
@call = Call::Sync.new(self, method, args, block)
end
receiver << @call
end | [
"def",
"execute",
"(",
"receiver",
",",
"method",
",",
"args",
",",
"block",
")",
"@mutex",
".",
"synchronize",
"do",
"raise",
"\"already calling\"",
"if",
"@call",
"@call",
"=",
"Call",
"::",
"Sync",
".",
"new",
"(",
"self",
",",
"method",
",",
"args",
... | Execute the given method in future context | [
"Execute",
"the",
"given",
"method",
"in",
"future",
"context"
] | 2c21bbc481ae65ba527f415f52df4ae99700b72f | https://github.com/celluloid/celluloid/blob/2c21bbc481ae65ba527f415f52df4ae99700b72f/lib/celluloid/future.rb#L49-L56 |
15,243 | celluloid/celluloid | lib/celluloid/future.rb | Celluloid.Future.value | def value(timeout = nil)
ready = result = nil
begin
@mutex.lock
if @ready
ready = true
result = @result
else
case @forwards
when Array
@forwards << Celluloid.mailbox
when NilClass
@forwards = Celluloid.mailbo... | ruby | def value(timeout = nil)
ready = result = nil
begin
@mutex.lock
if @ready
ready = true
result = @result
else
case @forwards
when Array
@forwards << Celluloid.mailbox
when NilClass
@forwards = Celluloid.mailbo... | [
"def",
"value",
"(",
"timeout",
"=",
"nil",
")",
"ready",
"=",
"result",
"=",
"nil",
"begin",
"@mutex",
".",
"lock",
"if",
"@ready",
"ready",
"=",
"true",
"result",
"=",
"@result",
"else",
"case",
"@forwards",
"when",
"Array",
"@forwards",
"<<",
"Cellulo... | Obtain the value for this Future | [
"Obtain",
"the",
"value",
"for",
"this",
"Future"
] | 2c21bbc481ae65ba527f415f52df4ae99700b72f | https://github.com/celluloid/celluloid/blob/2c21bbc481ae65ba527f415f52df4ae99700b72f/lib/celluloid/future.rb#L64-L98 |
15,244 | celluloid/celluloid | lib/celluloid/future.rb | Celluloid.Future.signal | def signal(value)
return if @cancelled
result = Result.new(value, self)
@mutex.synchronize do
raise "the future has already happened!" if @ready
if @forwards
@forwards.is_a?(Array) ? @forwards.each { |f| f << result } : @forwards << result
end
@result = res... | ruby | def signal(value)
return if @cancelled
result = Result.new(value, self)
@mutex.synchronize do
raise "the future has already happened!" if @ready
if @forwards
@forwards.is_a?(Array) ? @forwards.each { |f| f << result } : @forwards << result
end
@result = res... | [
"def",
"signal",
"(",
"value",
")",
"return",
"if",
"@cancelled",
"result",
"=",
"Result",
".",
"new",
"(",
"value",
",",
"self",
")",
"@mutex",
".",
"synchronize",
"do",
"raise",
"\"the future has already happened!\"",
"if",
"@ready",
"if",
"@forwards",
"@for... | Signal this future with the given result value | [
"Signal",
"this",
"future",
"with",
"the",
"given",
"result",
"value"
] | 2c21bbc481ae65ba527f415f52df4ae99700b72f | https://github.com/celluloid/celluloid/blob/2c21bbc481ae65ba527f415f52df4ae99700b72f/lib/celluloid/future.rb#L102-L116 |
15,245 | celluloid/celluloid | lib/celluloid/actor.rb | Celluloid.Actor.run | def run
while @running
begin
@timers.wait do |interval|
interval = 0 if interval && interval < 0
if message = @mailbox.check(interval)
handle_message(message)
break unless @running
end
end
rescue MailboxShutdown
... | ruby | def run
while @running
begin
@timers.wait do |interval|
interval = 0 if interval && interval < 0
if message = @mailbox.check(interval)
handle_message(message)
break unless @running
end
end
rescue MailboxShutdown
... | [
"def",
"run",
"while",
"@running",
"begin",
"@timers",
".",
"wait",
"do",
"|",
"interval",
"|",
"interval",
"=",
"0",
"if",
"interval",
"&&",
"interval",
"<",
"0",
"if",
"message",
"=",
"@mailbox",
".",
"check",
"(",
"interval",
")",
"handle_message",
"(... | Run the actor loop | [
"Run",
"the",
"actor",
"loop"
] | 2c21bbc481ae65ba527f415f52df4ae99700b72f | https://github.com/celluloid/celluloid/blob/2c21bbc481ae65ba527f415f52df4ae99700b72f/lib/celluloid/actor.rb#L152-L176 |
15,246 | celluloid/celluloid | lib/celluloid/actor.rb | Celluloid.Actor.linking_request | def linking_request(receiver, type)
Celluloid.exclusive do
receiver.mailbox << LinkingRequest.new(Actor.current, type)
system_events = []
Timers::Wait.for(LINKING_TIMEOUT) do |remaining|
begin
message = @mailbox.receive(remaining) do |msg|
msg.is_a?(Lin... | ruby | def linking_request(receiver, type)
Celluloid.exclusive do
receiver.mailbox << LinkingRequest.new(Actor.current, type)
system_events = []
Timers::Wait.for(LINKING_TIMEOUT) do |remaining|
begin
message = @mailbox.receive(remaining) do |msg|
msg.is_a?(Lin... | [
"def",
"linking_request",
"(",
"receiver",
",",
"type",
")",
"Celluloid",
".",
"exclusive",
"do",
"receiver",
".",
"mailbox",
"<<",
"LinkingRequest",
".",
"new",
"(",
"Actor",
".",
"current",
",",
"type",
")",
"system_events",
"=",
"[",
"]",
"Timers",
"::"... | Perform a linking request with another actor | [
"Perform",
"a",
"linking",
"request",
"with",
"another",
"actor"
] | 2c21bbc481ae65ba527f415f52df4ae99700b72f | https://github.com/celluloid/celluloid/blob/2c21bbc481ae65ba527f415f52df4ae99700b72f/lib/celluloid/actor.rb#L184-L216 |
15,247 | celluloid/celluloid | lib/celluloid/actor.rb | Celluloid.Actor.receive | def receive(timeout = nil, &block)
loop do
message = @receivers.receive(timeout, &block)
return message unless message.is_a?(SystemEvent)
handle_system_event(message)
end
end | ruby | def receive(timeout = nil, &block)
loop do
message = @receivers.receive(timeout, &block)
return message unless message.is_a?(SystemEvent)
handle_system_event(message)
end
end | [
"def",
"receive",
"(",
"timeout",
"=",
"nil",
",",
"&",
"block",
")",
"loop",
"do",
"message",
"=",
"@receivers",
".",
"receive",
"(",
"timeout",
",",
"block",
")",
"return",
"message",
"unless",
"message",
".",
"is_a?",
"(",
"SystemEvent",
")",
"handle_... | Receive an asynchronous message | [
"Receive",
"an",
"asynchronous",
"message"
] | 2c21bbc481ae65ba527f415f52df4ae99700b72f | https://github.com/celluloid/celluloid/blob/2c21bbc481ae65ba527f415f52df4ae99700b72f/lib/celluloid/actor.rb#L234-L241 |
15,248 | celluloid/celluloid | lib/celluloid/actor.rb | Celluloid.Actor.handle_message | def handle_message(message)
# !!! DO NOT INTRODUCE ADDITIONAL GLOBAL VARIABLES !!!
# rubocop:disable Metrics/LineLength, Style/GlobalVars
Internals::Logger.debug "Discarded message (unhandled): #{message}" if !@handlers.handle_message(message) && !@receivers.handle_message(message) && $CELLULOID_DEBUG... | ruby | def handle_message(message)
# !!! DO NOT INTRODUCE ADDITIONAL GLOBAL VARIABLES !!!
# rubocop:disable Metrics/LineLength, Style/GlobalVars
Internals::Logger.debug "Discarded message (unhandled): #{message}" if !@handlers.handle_message(message) && !@receivers.handle_message(message) && $CELLULOID_DEBUG... | [
"def",
"handle_message",
"(",
"message",
")",
"# !!! DO NOT INTRODUCE ADDITIONAL GLOBAL VARIABLES !!!",
"# rubocop:disable Metrics/LineLength, Style/GlobalVars",
"Internals",
"::",
"Logger",
".",
"debug",
"\"Discarded message (unhandled): #{message}\"",
"if",
"!",
"@handlers",
".",
... | Handle standard low-priority messages | [
"Handle",
"standard",
"low",
"-",
"priority",
"messages"
] | 2c21bbc481ae65ba527f415f52df4ae99700b72f | https://github.com/celluloid/celluloid/blob/2c21bbc481ae65ba527f415f52df4ae99700b72f/lib/celluloid/actor.rb#L288-L295 |
15,249 | celluloid/celluloid | lib/celluloid/actor.rb | Celluloid.Actor.handle_crash | def handle_crash(exception)
# TODO: add meta info
Internals::Logger.crash("Actor crashed!", exception)
shutdown ExitEvent.new(behavior_proxy, exception)
rescue => ex
Internals::Logger.crash("Actor#handle_crash CRASHED!", ex)
end | ruby | def handle_crash(exception)
# TODO: add meta info
Internals::Logger.crash("Actor crashed!", exception)
shutdown ExitEvent.new(behavior_proxy, exception)
rescue => ex
Internals::Logger.crash("Actor#handle_crash CRASHED!", ex)
end | [
"def",
"handle_crash",
"(",
"exception",
")",
"# TODO: add meta info",
"Internals",
"::",
"Logger",
".",
"crash",
"(",
"\"Actor crashed!\"",
",",
"exception",
")",
"shutdown",
"ExitEvent",
".",
"new",
"(",
"behavior_proxy",
",",
"exception",
")",
"rescue",
"=>",
... | Handle any exceptions that occur within a running actor | [
"Handle",
"any",
"exceptions",
"that",
"occur",
"within",
"a",
"running",
"actor"
] | 2c21bbc481ae65ba527f415f52df4ae99700b72f | https://github.com/celluloid/celluloid/blob/2c21bbc481ae65ba527f415f52df4ae99700b72f/lib/celluloid/actor.rb#L302-L308 |
15,250 | celluloid/celluloid | lib/celluloid/actor.rb | Celluloid.Actor.shutdown | def shutdown(exit_event = ExitEvent.new(behavior_proxy))
@behavior.shutdown
cleanup exit_event
ensure
Thread.current[:celluloid_actor] = nil
Thread.current[:celluloid_mailbox] = nil
end | ruby | def shutdown(exit_event = ExitEvent.new(behavior_proxy))
@behavior.shutdown
cleanup exit_event
ensure
Thread.current[:celluloid_actor] = nil
Thread.current[:celluloid_mailbox] = nil
end | [
"def",
"shutdown",
"(",
"exit_event",
"=",
"ExitEvent",
".",
"new",
"(",
"behavior_proxy",
")",
")",
"@behavior",
".",
"shutdown",
"cleanup",
"exit_event",
"ensure",
"Thread",
".",
"current",
"[",
":celluloid_actor",
"]",
"=",
"nil",
"Thread",
".",
"current",
... | Handle cleaning up this actor after it exits | [
"Handle",
"cleaning",
"up",
"this",
"actor",
"after",
"it",
"exits"
] | 2c21bbc481ae65ba527f415f52df4ae99700b72f | https://github.com/celluloid/celluloid/blob/2c21bbc481ae65ba527f415f52df4ae99700b72f/lib/celluloid/actor.rb#L311-L317 |
15,251 | celluloid/celluloid | lib/celluloid/actor.rb | Celluloid.Actor.cleanup | def cleanup(exit_event)
# !!! DO NOT INTRODUCE ADDITIONAL GLOBAL VARIABLES !!!
# rubocop:disable Style/GlobalVars
Celluloid::Probe.actor_died(self) if $CELLULOID_MONITORING
# rubocop:enable Style/GlobalVars
@mailbox.shutdown
@links.each do |actor|
actor.mailbox << exit_event... | ruby | def cleanup(exit_event)
# !!! DO NOT INTRODUCE ADDITIONAL GLOBAL VARIABLES !!!
# rubocop:disable Style/GlobalVars
Celluloid::Probe.actor_died(self) if $CELLULOID_MONITORING
# rubocop:enable Style/GlobalVars
@mailbox.shutdown
@links.each do |actor|
actor.mailbox << exit_event... | [
"def",
"cleanup",
"(",
"exit_event",
")",
"# !!! DO NOT INTRODUCE ADDITIONAL GLOBAL VARIABLES !!!",
"# rubocop:disable Style/GlobalVars",
"Celluloid",
"::",
"Probe",
".",
"actor_died",
"(",
"self",
")",
"if",
"$CELLULOID_MONITORING",
"# rubocop:enable Style/GlobalVars",
"@mailbox... | Clean up after this actor | [
"Clean",
"up",
"after",
"this",
"actor"
] | 2c21bbc481ae65ba527f415f52df4ae99700b72f | https://github.com/celluloid/celluloid/blob/2c21bbc481ae65ba527f415f52df4ae99700b72f/lib/celluloid/actor.rb#L320-L341 |
15,252 | celluloid/celluloid | lib/celluloid/task.rb | Celluloid.Task.suspend | def suspend(status)
raise "Cannot suspend while in exclusive mode" if exclusive?
raise "Cannot suspend a task from outside of itself" unless Task.current == self
@status = status
# !!! DO NOT INTRODUCE ADDITIONAL GLOBAL VARIABLES !!!
# rubocop:disable Style/GlobalVars
if $CELLULOID... | ruby | def suspend(status)
raise "Cannot suspend while in exclusive mode" if exclusive?
raise "Cannot suspend a task from outside of itself" unless Task.current == self
@status = status
# !!! DO NOT INTRODUCE ADDITIONAL GLOBAL VARIABLES !!!
# rubocop:disable Style/GlobalVars
if $CELLULOID... | [
"def",
"suspend",
"(",
"status",
")",
"raise",
"\"Cannot suspend while in exclusive mode\"",
"if",
"exclusive?",
"raise",
"\"Cannot suspend a task from outside of itself\"",
"unless",
"Task",
".",
"current",
"==",
"self",
"@status",
"=",
"status",
"# !!! DO NOT INTRODUCE ADDI... | Suspend the current task, changing the status to the given argument | [
"Suspend",
"the",
"current",
"task",
"changing",
"the",
"status",
"to",
"the",
"given",
"argument"
] | 2c21bbc481ae65ba527f415f52df4ae99700b72f | https://github.com/celluloid/celluloid/blob/2c21bbc481ae65ba527f415f52df4ae99700b72f/lib/celluloid/task.rb#L60-L80 |
15,253 | celluloid/celluloid | lib/celluloid/task.rb | Celluloid.Task.resume | def resume(value = nil)
guard "Cannot resume a task from inside of a task" if Thread.current[:celluloid_task]
if running?
deliver(value)
else
# rubocop:disable Metrics/LineLength
Internals::Logger.warn "Attempted to resume a dead task: type=#{@type.inspect}, meta=#{@meta.inspec... | ruby | def resume(value = nil)
guard "Cannot resume a task from inside of a task" if Thread.current[:celluloid_task]
if running?
deliver(value)
else
# rubocop:disable Metrics/LineLength
Internals::Logger.warn "Attempted to resume a dead task: type=#{@type.inspect}, meta=#{@meta.inspec... | [
"def",
"resume",
"(",
"value",
"=",
"nil",
")",
"guard",
"\"Cannot resume a task from inside of a task\"",
"if",
"Thread",
".",
"current",
"[",
":celluloid_task",
"]",
"if",
"running?",
"deliver",
"(",
"value",
")",
"else",
"# rubocop:disable Metrics/LineLength",
"Int... | Resume a suspended task, giving it a value to return if needed | [
"Resume",
"a",
"suspended",
"task",
"giving",
"it",
"a",
"value",
"to",
"return",
"if",
"needed"
] | 2c21bbc481ae65ba527f415f52df4ae99700b72f | https://github.com/celluloid/celluloid/blob/2c21bbc481ae65ba527f415f52df4ae99700b72f/lib/celluloid/task.rb#L83-L93 |
15,254 | celluloid/celluloid | lib/celluloid/task.rb | Celluloid.Task.terminate | def terminate
raise "Cannot terminate an exclusive task" if exclusive?
if running?
# !!! DO NOT INTRODUCE ADDITIONAL GLOBAL VARIABLES !!!
# rubocop:disable Style/GlobalVars
if $CELLULOID_DEBUG
Internals::Logger.with_backtrace(backtrace) do |logger|
type = @dang... | ruby | def terminate
raise "Cannot terminate an exclusive task" if exclusive?
if running?
# !!! DO NOT INTRODUCE ADDITIONAL GLOBAL VARIABLES !!!
# rubocop:disable Style/GlobalVars
if $CELLULOID_DEBUG
Internals::Logger.with_backtrace(backtrace) do |logger|
type = @dang... | [
"def",
"terminate",
"raise",
"\"Cannot terminate an exclusive task\"",
"if",
"exclusive?",
"if",
"running?",
"# !!! DO NOT INTRODUCE ADDITIONAL GLOBAL VARIABLES !!!",
"# rubocop:disable Style/GlobalVars",
"if",
"$CELLULOID_DEBUG",
"Internals",
"::",
"Logger",
".",
"with_backtrace",
... | Terminate this task | [
"Terminate",
"this",
"task"
] | 2c21bbc481ae65ba527f415f52df4ae99700b72f | https://github.com/celluloid/celluloid/blob/2c21bbc481ae65ba527f415f52df4ae99700b72f/lib/celluloid/task.rb#L110-L130 |
15,255 | celluloid/celluloid | lib/celluloid/cell.rb | Celluloid.Cell.shutdown | def shutdown
return unless @finalizer && @subject.respond_to?(@finalizer, true)
task(:finalizer, @finalizer, { call: @finalizer, subject: @subject },
dangerous_suspend: true, &Cell.shutdown)
end | ruby | def shutdown
return unless @finalizer && @subject.respond_to?(@finalizer, true)
task(:finalizer, @finalizer, { call: @finalizer, subject: @subject },
dangerous_suspend: true, &Cell.shutdown)
end | [
"def",
"shutdown",
"return",
"unless",
"@finalizer",
"&&",
"@subject",
".",
"respond_to?",
"(",
"@finalizer",
",",
"true",
")",
"task",
"(",
":finalizer",
",",
"@finalizer",
",",
"{",
"call",
":",
"@finalizer",
",",
"subject",
":",
"@subject",
"}",
",",
"d... | Run the user-defined finalizer, if one is set | [
"Run",
"the",
"user",
"-",
"defined",
"finalizer",
"if",
"one",
"is",
"set"
] | 2c21bbc481ae65ba527f415f52df4ae99700b72f | https://github.com/celluloid/celluloid/blob/2c21bbc481ae65ba527f415f52df4ae99700b72f/lib/celluloid/cell.rb#L90-L95 |
15,256 | celluloid/celluloid | lib/celluloid/mailbox.rb | Celluloid.Mailbox.<< | def <<(message)
@mutex.lock
begin
if mailbox_full || @dead
dead_letter(message)
return
end
if message.is_a?(SystemEvent)
# SystemEvents are high priority messages so they get added to the
# head of our message queue instead of the end
... | ruby | def <<(message)
@mutex.lock
begin
if mailbox_full || @dead
dead_letter(message)
return
end
if message.is_a?(SystemEvent)
# SystemEvents are high priority messages so they get added to the
# head of our message queue instead of the end
... | [
"def",
"<<",
"(",
"message",
")",
"@mutex",
".",
"lock",
"begin",
"if",
"mailbox_full",
"||",
"@dead",
"dead_letter",
"(",
"message",
")",
"return",
"end",
"if",
"message",
".",
"is_a?",
"(",
"SystemEvent",
")",
"# SystemEvents are high priority messages so they g... | Add a message to the Mailbox | [
"Add",
"a",
"message",
"to",
"the",
"Mailbox"
] | 2c21bbc481ae65ba527f415f52df4ae99700b72f | https://github.com/celluloid/celluloid/blob/2c21bbc481ae65ba527f415f52df4ae99700b72f/lib/celluloid/mailbox.rb#L24-L48 |
15,257 | celluloid/celluloid | lib/celluloid/mailbox.rb | Celluloid.Mailbox.check | def check(timeout = nil, &block)
message = nil
@mutex.lock
begin
raise MailboxDead, "attempted to receive from a dead mailbox" if @dead
message = nil
Timers::Wait.for(timeout) do |remaining|
message = next_message(&block)
break if message
@cond... | ruby | def check(timeout = nil, &block)
message = nil
@mutex.lock
begin
raise MailboxDead, "attempted to receive from a dead mailbox" if @dead
message = nil
Timers::Wait.for(timeout) do |remaining|
message = next_message(&block)
break if message
@cond... | [
"def",
"check",
"(",
"timeout",
"=",
"nil",
",",
"&",
"block",
")",
"message",
"=",
"nil",
"@mutex",
".",
"lock",
"begin",
"raise",
"MailboxDead",
",",
"\"attempted to receive from a dead mailbox\"",
"if",
"@dead",
"message",
"=",
"nil",
"Timers",
"::",
"Wait"... | Receive a message from the Mailbox. May return nil and may return before
the specified timeout. | [
"Receive",
"a",
"message",
"from",
"the",
"Mailbox",
".",
"May",
"return",
"nil",
"and",
"may",
"return",
"before",
"the",
"specified",
"timeout",
"."
] | 2c21bbc481ae65ba527f415f52df4ae99700b72f | https://github.com/celluloid/celluloid/blob/2c21bbc481ae65ba527f415f52df4ae99700b72f/lib/celluloid/mailbox.rb#L52-L76 |
15,258 | celluloid/celluloid | lib/celluloid/mailbox.rb | Celluloid.Mailbox.receive | def receive(timeout = nil, &block)
message = nil
Timers::Wait.for(timeout) do |_remaining|
message = check(timeout, &block)
break if message
end
return message if message
raise TaskTimeout, "receive timeout exceeded"
end | ruby | def receive(timeout = nil, &block)
message = nil
Timers::Wait.for(timeout) do |_remaining|
message = check(timeout, &block)
break if message
end
return message if message
raise TaskTimeout, "receive timeout exceeded"
end | [
"def",
"receive",
"(",
"timeout",
"=",
"nil",
",",
"&",
"block",
")",
"message",
"=",
"nil",
"Timers",
"::",
"Wait",
".",
"for",
"(",
"timeout",
")",
"do",
"|",
"_remaining",
"|",
"message",
"=",
"check",
"(",
"timeout",
",",
"block",
")",
"break",
... | Receive a letter from the mailbox. Guaranteed to return a message. If
timeout is exceeded, raise a TaskTimeout. | [
"Receive",
"a",
"letter",
"from",
"the",
"mailbox",
".",
"Guaranteed",
"to",
"return",
"a",
"message",
".",
"If",
"timeout",
"is",
"exceeded",
"raise",
"a",
"TaskTimeout",
"."
] | 2c21bbc481ae65ba527f415f52df4ae99700b72f | https://github.com/celluloid/celluloid/blob/2c21bbc481ae65ba527f415f52df4ae99700b72f/lib/celluloid/mailbox.rb#L80-L88 |
15,259 | celluloid/celluloid | lib/celluloid/mailbox.rb | Celluloid.Mailbox.shutdown | def shutdown
raise MailboxDead, "mailbox already shutdown" if @dead
@mutex.lock
begin
yield if block_given?
messages = @messages
@messages = []
@dead = true
ensure
begin
@mutex.unlock
rescue
nil
end
end
mes... | ruby | def shutdown
raise MailboxDead, "mailbox already shutdown" if @dead
@mutex.lock
begin
yield if block_given?
messages = @messages
@messages = []
@dead = true
ensure
begin
@mutex.unlock
rescue
nil
end
end
mes... | [
"def",
"shutdown",
"raise",
"MailboxDead",
",",
"\"mailbox already shutdown\"",
"if",
"@dead",
"@mutex",
".",
"lock",
"begin",
"yield",
"if",
"block_given?",
"messages",
"=",
"@messages",
"@messages",
"=",
"[",
"]",
"@dead",
"=",
"true",
"ensure",
"begin",
"@mut... | Shut down this mailbox and clean up its contents | [
"Shut",
"down",
"this",
"mailbox",
"and",
"clean",
"up",
"its",
"contents"
] | 2c21bbc481ae65ba527f415f52df4ae99700b72f | https://github.com/celluloid/celluloid/blob/2c21bbc481ae65ba527f415f52df4ae99700b72f/lib/celluloid/mailbox.rb#L91-L113 |
15,260 | celluloid/celluloid | lib/celluloid/mailbox.rb | Celluloid.Mailbox.next_message | def next_message
message = nil
if block_given?
index = @messages.index do |msg|
yield(msg) || msg.is_a?(SystemEvent)
end
message = @messages.slice!(index, 1).first if index
else
message = @messages.shift
end
message
end | ruby | def next_message
message = nil
if block_given?
index = @messages.index do |msg|
yield(msg) || msg.is_a?(SystemEvent)
end
message = @messages.slice!(index, 1).first if index
else
message = @messages.shift
end
message
end | [
"def",
"next_message",
"message",
"=",
"nil",
"if",
"block_given?",
"index",
"=",
"@messages",
".",
"index",
"do",
"|",
"msg",
"|",
"yield",
"(",
"msg",
")",
"||",
"msg",
".",
"is_a?",
"(",
"SystemEvent",
")",
"end",
"message",
"=",
"@messages",
".",
"... | Retrieve the next message in the mailbox | [
"Retrieve",
"the",
"next",
"message",
"in",
"the",
"mailbox"
] | 2c21bbc481ae65ba527f415f52df4ae99700b72f | https://github.com/celluloid/celluloid/blob/2c21bbc481ae65ba527f415f52df4ae99700b72f/lib/celluloid/mailbox.rb#L143-L157 |
15,261 | celluloid/celluloid | lib/celluloid/logging/incident.rb | Celluloid.Incident.merge | def merge(*other_incidents)
merged_events = other_incidents.flatten.inject(events) do |events, incident|
events += incident.events
end
Incident.new(merged_events.sort, triggering_event)
end | ruby | def merge(*other_incidents)
merged_events = other_incidents.flatten.inject(events) do |events, incident|
events += incident.events
end
Incident.new(merged_events.sort, triggering_event)
end | [
"def",
"merge",
"(",
"*",
"other_incidents",
")",
"merged_events",
"=",
"other_incidents",
".",
"flatten",
".",
"inject",
"(",
"events",
")",
"do",
"|",
"events",
",",
"incident",
"|",
"events",
"+=",
"incident",
".",
"events",
"end",
"Incident",
".",
"new... | Merge two incidents together. This may be useful if two incidents occur at the same time. | [
"Merge",
"two",
"incidents",
"together",
".",
"This",
"may",
"be",
"useful",
"if",
"two",
"incidents",
"occur",
"at",
"the",
"same",
"time",
"."
] | 2c21bbc481ae65ba527f415f52df4ae99700b72f | https://github.com/celluloid/celluloid/blob/2c21bbc481ae65ba527f415f52df4ae99700b72f/lib/celluloid/logging/incident.rb#L14-L19 |
15,262 | celluloid/celluloid | lib/celluloid/system_events.rb | Celluloid.Actor.handle_system_event | def handle_system_event(event)
if handler = SystemEvent.handle(event.class)
send(handler, event)
else
# !!! DO NOT INTRODUCE ADDITIONAL GLOBAL VARIABLES !!!
# rubocop:disable Style/GlobalVars
Internals::Logger.debug "Discarded message (unhandled): #{message}" if $CELLULOID_DE... | ruby | def handle_system_event(event)
if handler = SystemEvent.handle(event.class)
send(handler, event)
else
# !!! DO NOT INTRODUCE ADDITIONAL GLOBAL VARIABLES !!!
# rubocop:disable Style/GlobalVars
Internals::Logger.debug "Discarded message (unhandled): #{message}" if $CELLULOID_DE... | [
"def",
"handle_system_event",
"(",
"event",
")",
"if",
"handler",
"=",
"SystemEvent",
".",
"handle",
"(",
"event",
".",
"class",
")",
"send",
"(",
"handler",
",",
"event",
")",
"else",
"# !!! DO NOT INTRODUCE ADDITIONAL GLOBAL VARIABLES !!!",
"# rubocop:disable Style/... | Handle high-priority system event messages | [
"Handle",
"high",
"-",
"priority",
"system",
"event",
"messages"
] | 2c21bbc481ae65ba527f415f52df4ae99700b72f | https://github.com/celluloid/celluloid/blob/2c21bbc481ae65ba527f415f52df4ae99700b72f/lib/celluloid/system_events.rb#L4-L13 |
15,263 | celluloid/celluloid | lib/celluloid/logging/incident_logger.rb | Celluloid.IncidentLogger.add | def add(severity, message = nil, progname = nil, &block)
progname ||= @progname
severity ||= UNKNOWN
return event.id if severity < @level
if message.nil? && !block_given?
message = progname
progname = @progname
end
event = LogEvent.new(severity, message, progname, ... | ruby | def add(severity, message = nil, progname = nil, &block)
progname ||= @progname
severity ||= UNKNOWN
return event.id if severity < @level
if message.nil? && !block_given?
message = progname
progname = @progname
end
event = LogEvent.new(severity, message, progname, ... | [
"def",
"add",
"(",
"severity",
",",
"message",
"=",
"nil",
",",
"progname",
"=",
"nil",
",",
"&",
"block",
")",
"progname",
"||=",
"@progname",
"severity",
"||=",
"UNKNOWN",
"return",
"event",
".",
"id",
"if",
"severity",
"<",
"@level",
"if",
"message",
... | Create a new IncidentLogger.
add an event. | [
"Create",
"a",
"new",
"IncidentLogger",
".",
"add",
"an",
"event",
"."
] | 2c21bbc481ae65ba527f415f52df4ae99700b72f | https://github.com/celluloid/celluloid/blob/2c21bbc481ae65ba527f415f52df4ae99700b72f/lib/celluloid/logging/incident_logger.rb#L66-L89 |
15,264 | sup-heliotrope/sup | lib/sup/crypto.rb | Redwood.CryptoManager.decrypt | def decrypt payload, armor=false # a RubyMail::Message object
return unknown_status(@not_working_reason) unless @not_working_reason.nil?
gpg_opts = {:protocol => GPGME::PROTOCOL_OpenPGP}
gpg_opts = HookManager.run("gpg-options",
{:operation => "decrypt", :options => gpg_opts}... | ruby | def decrypt payload, armor=false # a RubyMail::Message object
return unknown_status(@not_working_reason) unless @not_working_reason.nil?
gpg_opts = {:protocol => GPGME::PROTOCOL_OpenPGP}
gpg_opts = HookManager.run("gpg-options",
{:operation => "decrypt", :options => gpg_opts}... | [
"def",
"decrypt",
"payload",
",",
"armor",
"=",
"false",
"# a RubyMail::Message object",
"return",
"unknown_status",
"(",
"@not_working_reason",
")",
"unless",
"@not_working_reason",
".",
"nil?",
"gpg_opts",
"=",
"{",
":protocol",
"=>",
"GPGME",
"::",
"PROTOCOL_OpenPG... | returns decrypted_message, status, desc, lines | [
"returns",
"decrypted_message",
"status",
"desc",
"lines"
] | 36f95462e3014c354c577d63a78ba030c4b84474 | https://github.com/sup-heliotrope/sup/blob/36f95462e3014c354c577d63a78ba030c4b84474/lib/sup/crypto.rb#L288-L358 |
15,265 | sup-heliotrope/sup | lib/sup/logger.rb | Redwood.Logger.send_message | def send_message m
@mutex.synchronize do
@sinks.each do |sink|
sink << m
sink.flush if sink.respond_to?(:flush) and level == "debug"
end
@buf << m
end
end | ruby | def send_message m
@mutex.synchronize do
@sinks.each do |sink|
sink << m
sink.flush if sink.respond_to?(:flush) and level == "debug"
end
@buf << m
end
end | [
"def",
"send_message",
"m",
"@mutex",
".",
"synchronize",
"do",
"@sinks",
".",
"each",
"do",
"|",
"sink",
"|",
"sink",
"<<",
"m",
"sink",
".",
"flush",
"if",
"sink",
".",
"respond_to?",
"(",
":flush",
")",
"and",
"level",
"==",
"\"debug\"",
"end",
"@bu... | actually distribute the message | [
"actually",
"distribute",
"the",
"message"
] | 36f95462e3014c354c577d63a78ba030c4b84474 | https://github.com/sup-heliotrope/sup/blob/36f95462e3014c354c577d63a78ba030c4b84474/lib/sup/logger.rb#L61-L69 |
15,266 | sup-heliotrope/sup | lib/sup/mbox.rb | Redwood.MBox.each_raw_message_line | def each_raw_message_line offset
@mutex.synchronize do
ensure_open
@f.seek offset
until @f.eof? || MBox::is_break_line?(l = @f.gets)
yield l
end
end
end | ruby | def each_raw_message_line offset
@mutex.synchronize do
ensure_open
@f.seek offset
until @f.eof? || MBox::is_break_line?(l = @f.gets)
yield l
end
end
end | [
"def",
"each_raw_message_line",
"offset",
"@mutex",
".",
"synchronize",
"do",
"ensure_open",
"@f",
".",
"seek",
"offset",
"until",
"@f",
".",
"eof?",
"||",
"MBox",
"::",
"is_break_line?",
"(",
"l",
"=",
"@f",
".",
"gets",
")",
"yield",
"l",
"end",
"end",
... | apparently it's a million times faster to call this directly if
we're just moving messages around on disk, than reading things
into memory with raw_message. | [
"apparently",
"it",
"s",
"a",
"million",
"times",
"faster",
"to",
"call",
"this",
"directly",
"if",
"we",
"re",
"just",
"moving",
"messages",
"around",
"on",
"disk",
"than",
"reading",
"things",
"into",
"memory",
"with",
"raw_message",
"."
] | 36f95462e3014c354c577d63a78ba030c4b84474 | https://github.com/sup-heliotrope/sup/blob/36f95462e3014c354c577d63a78ba030c4b84474/lib/sup/mbox.rb#L130-L138 |
15,267 | sup-heliotrope/sup | lib/sup/account.rb | Redwood.AccountManager.add_account | def add_account hash, default=false
raise ArgumentError, "no email specified for account" unless hash[:email]
unless default
[:name, :sendmail, :signature, :gpgkey].each { |k| hash[k] ||= @default_account.send(k) }
end
hash[:alternates] ||= []
fail "alternative emails are not an array: #{hash[... | ruby | def add_account hash, default=false
raise ArgumentError, "no email specified for account" unless hash[:email]
unless default
[:name, :sendmail, :signature, :gpgkey].each { |k| hash[k] ||= @default_account.send(k) }
end
hash[:alternates] ||= []
fail "alternative emails are not an array: #{hash[... | [
"def",
"add_account",
"hash",
",",
"default",
"=",
"false",
"raise",
"ArgumentError",
",",
"\"no email specified for account\"",
"unless",
"hash",
"[",
":email",
"]",
"unless",
"default",
"[",
":name",
",",
":sendmail",
",",
":signature",
",",
":gpgkey",
"]",
".... | must be called first with the default account. fills in missing
values from the default account. | [
"must",
"be",
"called",
"first",
"with",
"the",
"default",
"account",
".",
"fills",
"in",
"missing",
"values",
"from",
"the",
"default",
"account",
"."
] | 36f95462e3014c354c577d63a78ba030c4b84474 | https://github.com/sup-heliotrope/sup/blob/36f95462e3014c354c577d63a78ba030c4b84474/lib/sup/account.rb#L47-L73 |
15,268 | sup-heliotrope/sup | lib/sup/modes/thread_index_mode.rb | Redwood.ThreadIndexMode.select | def select t=nil, when_done=nil
t ||= cursor_thread or return
Redwood::reporting_thread("load messages for thread-view-mode") do
num = t.size
message = "Loading #{num.pluralize 'message body'}..."
BufferManager.say(message) do |sid|
t.each_with_index do |(m, *_), i|
next unl... | ruby | def select t=nil, when_done=nil
t ||= cursor_thread or return
Redwood::reporting_thread("load messages for thread-view-mode") do
num = t.size
message = "Loading #{num.pluralize 'message body'}..."
BufferManager.say(message) do |sid|
t.each_with_index do |(m, *_), i|
next unl... | [
"def",
"select",
"t",
"=",
"nil",
",",
"when_done",
"=",
"nil",
"t",
"||=",
"cursor_thread",
"or",
"return",
"Redwood",
"::",
"reporting_thread",
"(",
"\"load messages for thread-view-mode\"",
")",
"do",
"num",
"=",
"t",
".",
"size",
"message",
"=",
"\"Loading... | open up a thread view window | [
"open",
"up",
"a",
"thread",
"view",
"window"
] | 36f95462e3014c354c577d63a78ba030c4b84474 | https://github.com/sup-heliotrope/sup/blob/36f95462e3014c354c577d63a78ba030c4b84474/lib/sup/modes/thread_index_mode.rb#L107-L135 |
15,269 | sup-heliotrope/sup | lib/sup/modes/thread_index_mode.rb | Redwood.ThreadIndexMode.multi_toggle_spam | def multi_toggle_spam threads
undos = threads.map { |t| actually_toggle_spammed t }
threads.each { |t| HookManager.run("mark-as-spam", :thread => t) }
UndoManager.register "marking/unmarking #{threads.size.pluralize 'thread'} as spam",
undos, lambda { regen_text }, lambda { threads... | ruby | def multi_toggle_spam threads
undos = threads.map { |t| actually_toggle_spammed t }
threads.each { |t| HookManager.run("mark-as-spam", :thread => t) }
UndoManager.register "marking/unmarking #{threads.size.pluralize 'thread'} as spam",
undos, lambda { regen_text }, lambda { threads... | [
"def",
"multi_toggle_spam",
"threads",
"undos",
"=",
"threads",
".",
"map",
"{",
"|",
"t",
"|",
"actually_toggle_spammed",
"t",
"}",
"threads",
".",
"each",
"{",
"|",
"t",
"|",
"HookManager",
".",
"run",
"(",
"\"mark-as-spam\"",
",",
":thread",
"=>",
"t",
... | both spam and deleted have the curious characteristic that you
always want to hide the thread after either applying or removing
that label. in all thread-index-views except for
label-search-results-mode, when you mark a message as spam or
deleted, you want it to disappear immediately; in LSRM, you only
see deleted... | [
"both",
"spam",
"and",
"deleted",
"have",
"the",
"curious",
"characteristic",
"that",
"you",
"always",
"want",
"to",
"hide",
"the",
"thread",
"after",
"either",
"applying",
"or",
"removing",
"that",
"label",
".",
"in",
"all",
"thread",
"-",
"index",
"-",
"... | 36f95462e3014c354c577d63a78ba030c4b84474 | https://github.com/sup-heliotrope/sup/blob/36f95462e3014c354c577d63a78ba030c4b84474/lib/sup/modes/thread_index_mode.rb#L474-L481 |
15,270 | sup-heliotrope/sup | lib/sup/modes/thread_index_mode.rb | Redwood.ThreadIndexMode.multi_toggle_deleted | def multi_toggle_deleted threads
undos = threads.map { |t| actually_toggle_deleted t }
UndoManager.register "deleting/undeleting #{threads.size.pluralize 'thread'}",
undos, lambda { regen_text }, lambda { threads.each { |t| Index.save_thread t } }
regen_text
threads.each { |t| I... | ruby | def multi_toggle_deleted threads
undos = threads.map { |t| actually_toggle_deleted t }
UndoManager.register "deleting/undeleting #{threads.size.pluralize 'thread'}",
undos, lambda { regen_text }, lambda { threads.each { |t| Index.save_thread t } }
regen_text
threads.each { |t| I... | [
"def",
"multi_toggle_deleted",
"threads",
"undos",
"=",
"threads",
".",
"map",
"{",
"|",
"t",
"|",
"actually_toggle_deleted",
"t",
"}",
"UndoManager",
".",
"register",
"\"deleting/undeleting #{threads.size.pluralize 'thread'}\"",
",",
"undos",
",",
"lambda",
"{",
"reg... | see comment for multi_toggle_spam | [
"see",
"comment",
"for",
"multi_toggle_spam"
] | 36f95462e3014c354c577d63a78ba030c4b84474 | https://github.com/sup-heliotrope/sup/blob/36f95462e3014c354c577d63a78ba030c4b84474/lib/sup/modes/thread_index_mode.rb#L489-L495 |
15,271 | sup-heliotrope/sup | lib/sup/modes/thread_index_mode.rb | Redwood.ThreadIndexMode.multi_kill | def multi_kill threads
UndoManager.register "killing/unkilling #{threads.size.pluralize 'threads'}" do
threads.each do |t|
if t.toggle_label :killed
add_or_unhide t.first
else
hide_thread t
end
end.each do |t|
UpdateManager.relay self, :labeled, t.firs... | ruby | def multi_kill threads
UndoManager.register "killing/unkilling #{threads.size.pluralize 'threads'}" do
threads.each do |t|
if t.toggle_label :killed
add_or_unhide t.first
else
hide_thread t
end
end.each do |t|
UpdateManager.relay self, :labeled, t.firs... | [
"def",
"multi_kill",
"threads",
"UndoManager",
".",
"register",
"\"killing/unkilling #{threads.size.pluralize 'threads'}\"",
"do",
"threads",
".",
"each",
"do",
"|",
"t",
"|",
"if",
"t",
".",
"toggle_label",
":killed",
"add_or_unhide",
"t",
".",
"first",
"else",
"hi... | m-m-m-m-MULTI-KILL | [
"m",
"-",
"m",
"-",
"m",
"-",
"m",
"-",
"MULTI",
"-",
"KILL"
] | 36f95462e3014c354c577d63a78ba030c4b84474 | https://github.com/sup-heliotrope/sup/blob/36f95462e3014c354c577d63a78ba030c4b84474/lib/sup/modes/thread_index_mode.rb#L509-L539 |
15,272 | sup-heliotrope/sup | lib/sup/modes/thread_index_mode.rb | Redwood.ThreadIndexMode.thread_matches? | def thread_matches? t, query
t.subj =~ query || t.snippet =~ query || t.participants.any? { |x| x.longname =~ query }
end | ruby | def thread_matches? t, query
t.subj =~ query || t.snippet =~ query || t.participants.any? { |x| x.longname =~ query }
end | [
"def",
"thread_matches?",
"t",
",",
"query",
"t",
".",
"subj",
"=~",
"query",
"||",
"t",
".",
"snippet",
"=~",
"query",
"||",
"t",
".",
"participants",
".",
"any?",
"{",
"|",
"x",
"|",
"x",
".",
"longname",
"=~",
"query",
"}",
"end"
] | used to tag threads by query. this can be made a lot more sophisticated,
but for right now we'll do the obvious this. | [
"used",
"to",
"tag",
"threads",
"by",
"query",
".",
"this",
"can",
"be",
"made",
"a",
"lot",
"more",
"sophisticated",
"but",
"for",
"right",
"now",
"we",
"ll",
"do",
"the",
"obvious",
"this",
"."
] | 36f95462e3014c354c577d63a78ba030c4b84474 | https://github.com/sup-heliotrope/sup/blob/36f95462e3014c354c577d63a78ba030c4b84474/lib/sup/modes/thread_index_mode.rb#L811-L813 |
15,273 | sup-heliotrope/sup | lib/sup/modes/thread_index_mode.rb | Redwood.ThreadIndexMode.author_names_and_newness_for_thread | def author_names_and_newness_for_thread t, limit=nil
new = {}
seen = {}
authors = t.map do |m, *o|
next unless m && m.from
new[m.from] ||= m.has_label?(:unread)
next if seen[m.from]
seen[m.from] = true
m.from
end.compact
result = []
authors.each do |a|
break ... | ruby | def author_names_and_newness_for_thread t, limit=nil
new = {}
seen = {}
authors = t.map do |m, *o|
next unless m && m.from
new[m.from] ||= m.has_label?(:unread)
next if seen[m.from]
seen[m.from] = true
m.from
end.compact
result = []
authors.each do |a|
break ... | [
"def",
"author_names_and_newness_for_thread",
"t",
",",
"limit",
"=",
"nil",
"new",
"=",
"{",
"}",
"seen",
"=",
"{",
"}",
"authors",
"=",
"t",
".",
"map",
"do",
"|",
"m",
",",
"*",
"o",
"|",
"next",
"unless",
"m",
"&&",
"m",
".",
"from",
"new",
"... | preserve author order from the thread | [
"preserve",
"author",
"order",
"from",
"the",
"thread"
] | 36f95462e3014c354c577d63a78ba030c4b84474 | https://github.com/sup-heliotrope/sup/blob/36f95462e3014c354c577d63a78ba030c4b84474/lib/sup/modes/thread_index_mode.rb#L892-L928 |
15,274 | sup-heliotrope/sup | lib/sup/buffer.rb | Redwood.Buffer.write | def write y, x, s, opts={}
return if x >= @width || y >= @height
@w.attrset Colormap.color_for(opts[:color] || :none, opts[:highlight])
s ||= ""
maxl = @width - x # maximum display width width
# fill up the line with blanks to overwrite old screen contents
@w.mvaddstr y, x, " " * maxl unless o... | ruby | def write y, x, s, opts={}
return if x >= @width || y >= @height
@w.attrset Colormap.color_for(opts[:color] || :none, opts[:highlight])
s ||= ""
maxl = @width - x # maximum display width width
# fill up the line with blanks to overwrite old screen contents
@w.mvaddstr y, x, " " * maxl unless o... | [
"def",
"write",
"y",
",",
"x",
",",
"s",
",",
"opts",
"=",
"{",
"}",
"return",
"if",
"x",
">=",
"@width",
"||",
"y",
">=",
"@height",
"@w",
".",
"attrset",
"Colormap",
".",
"color_for",
"(",
"opts",
"[",
":color",
"]",
"||",
":none",
",",
"opts",... | s nil means a blank line! | [
"s",
"nil",
"means",
"a",
"blank",
"line!"
] | 36f95462e3014c354c577d63a78ba030c4b84474 | https://github.com/sup-heliotrope/sup/blob/36f95462e3014c354c577d63a78ba030c4b84474/lib/sup/buffer.rb#L67-L78 |
15,275 | sup-heliotrope/sup | lib/sup/buffer.rb | Redwood.BufferManager.roll_buffers | def roll_buffers
bufs = rollable_buffers
bufs.last.force_to_top = false
raise_to_front bufs.first
end | ruby | def roll_buffers
bufs = rollable_buffers
bufs.last.force_to_top = false
raise_to_front bufs.first
end | [
"def",
"roll_buffers",
"bufs",
"=",
"rollable_buffers",
"bufs",
".",
"last",
".",
"force_to_top",
"=",
"false",
"raise_to_front",
"bufs",
".",
"first",
"end"
] | we reset force_to_top when rolling buffers. this is so that the
human can actually still move buffers around, while still
programmatically being able to pop stuff up in the middle of
drawing a window without worrying about covering it up.
if we ever start calling roll_buffers programmatically, we will
have to cha... | [
"we",
"reset",
"force_to_top",
"when",
"rolling",
"buffers",
".",
"this",
"is",
"so",
"that",
"the",
"human",
"can",
"actually",
"still",
"move",
"buffers",
"around",
"while",
"still",
"programmatically",
"being",
"able",
"to",
"pop",
"stuff",
"up",
"in",
"t... | 36f95462e3014c354c577d63a78ba030c4b84474 | https://github.com/sup-heliotrope/sup/blob/36f95462e3014c354c577d63a78ba030c4b84474/lib/sup/buffer.rb#L199-L203 |
15,276 | sup-heliotrope/sup | lib/sup/buffer.rb | Redwood.BufferManager.ask_for_labels | def ask_for_labels domain, question, default_labels, forbidden_labels=[]
default_labels = default_labels - forbidden_labels - LabelManager::RESERVED_LABELS
default = default_labels.to_a.join(" ")
default += " " unless default.empty?
# here I would prefer to give more control and allow all_labels instea... | ruby | def ask_for_labels domain, question, default_labels, forbidden_labels=[]
default_labels = default_labels - forbidden_labels - LabelManager::RESERVED_LABELS
default = default_labels.to_a.join(" ")
default += " " unless default.empty?
# here I would prefer to give more control and allow all_labels instea... | [
"def",
"ask_for_labels",
"domain",
",",
"question",
",",
"default_labels",
",",
"forbidden_labels",
"=",
"[",
"]",
"default_labels",
"=",
"default_labels",
"-",
"forbidden_labels",
"-",
"LabelManager",
"::",
"RESERVED_LABELS",
"default",
"=",
"default_labels",
".",
... | returns an array of labels | [
"returns",
"an",
"array",
"of",
"labels"
] | 36f95462e3014c354c577d63a78ba030c4b84474 | https://github.com/sup-heliotrope/sup/blob/36f95462e3014c354c577d63a78ba030c4b84474/lib/sup/buffer.rb#L485-L506 |
15,277 | sup-heliotrope/sup | lib/sup/buffer.rb | Redwood.BufferManager.ask | def ask domain, question, default=nil, &block
raise "impossible!" if @asking
raise "Question too long" if Ncurses.cols <= question.length
@asking = true
@textfields[domain] ||= TextField.new
tf = @textfields[domain]
completion_buf = nil
status, title = get_status_and_title @focus_buf
... | ruby | def ask domain, question, default=nil, &block
raise "impossible!" if @asking
raise "Question too long" if Ncurses.cols <= question.length
@asking = true
@textfields[domain] ||= TextField.new
tf = @textfields[domain]
completion_buf = nil
status, title = get_status_and_title @focus_buf
... | [
"def",
"ask",
"domain",
",",
"question",
",",
"default",
"=",
"nil",
",",
"&",
"block",
"raise",
"\"impossible!\"",
"if",
"@asking",
"raise",
"\"Question too long\"",
"if",
"Ncurses",
".",
"cols",
"<=",
"question",
".",
"length",
"@asking",
"=",
"true",
"@te... | for simplicitly, we always place the question at the very bottom of the
screen | [
"for",
"simplicitly",
"we",
"always",
"place",
"the",
"question",
"at",
"the",
"very",
"bottom",
"of",
"the",
"screen"
] | 36f95462e3014c354c577d63a78ba030c4b84474 | https://github.com/sup-heliotrope/sup/blob/36f95462e3014c354c577d63a78ba030c4b84474/lib/sup/buffer.rb#L534-L587 |
15,278 | sup-heliotrope/sup | lib/sup/contact.rb | Redwood.ContactManager.drop_contact | def drop_contact person
aalias = @p2a[person]
@p2a.delete person
@e2p.delete person.email
@a2p.delete aalias if aalias
end | ruby | def drop_contact person
aalias = @p2a[person]
@p2a.delete person
@e2p.delete person.email
@a2p.delete aalias if aalias
end | [
"def",
"drop_contact",
"person",
"aalias",
"=",
"@p2a",
"[",
"person",
"]",
"@p2a",
".",
"delete",
"person",
"@e2p",
".",
"delete",
"person",
".",
"email",
"@a2p",
".",
"delete",
"aalias",
"if",
"aalias",
"end"
] | this may not actually be called anywhere, since we still keep contacts
around without aliases to override any fullname changes. | [
"this",
"may",
"not",
"actually",
"be",
"called",
"anywhere",
"since",
"we",
"still",
"keep",
"contacts",
"around",
"without",
"aliases",
"to",
"override",
"any",
"fullname",
"changes",
"."
] | 36f95462e3014c354c577d63a78ba030c4b84474 | https://github.com/sup-heliotrope/sup/blob/36f95462e3014c354c577d63a78ba030c4b84474/lib/sup/contact.rb#L48-L53 |
15,279 | sup-heliotrope/sup | lib/sup/modes/thread_view_mode.rb | Redwood.ThreadViewMode.regen_text | def regen_text
@text = []
@chunk_lines = []
@message_lines = []
@person_lines = []
prevm = nil
@thread.each do |m, depth, parent|
unless m.is_a? Message # handle nil and :fake_root
@text += chunk_to_lines m, nil, @text.length, depth, parent
next
end
l = @layout... | ruby | def regen_text
@text = []
@chunk_lines = []
@message_lines = []
@person_lines = []
prevm = nil
@thread.each do |m, depth, parent|
unless m.is_a? Message # handle nil and :fake_root
@text += chunk_to_lines m, nil, @text.length, depth, parent
next
end
l = @layout... | [
"def",
"regen_text",
"@text",
"=",
"[",
"]",
"@chunk_lines",
"=",
"[",
"]",
"@message_lines",
"=",
"[",
"]",
"@person_lines",
"=",
"[",
"]",
"prevm",
"=",
"nil",
"@thread",
".",
"each",
"do",
"|",
"m",
",",
"depth",
",",
"parent",
"|",
"unless",
"m",... | here we generate the actual content lines. we accumulate
everything into @text, and we set @chunk_lines and
@message_lines, and we update @layout. | [
"here",
"we",
"generate",
"the",
"actual",
"content",
"lines",
".",
"we",
"accumulate",
"everything",
"into"
] | 36f95462e3014c354c577d63a78ba030c4b84474 | https://github.com/sup-heliotrope/sup/blob/36f95462e3014c354c577d63a78ba030c4b84474/lib/sup/modes/thread_view_mode.rb#L840-L901 |
15,280 | sup-heliotrope/sup | lib/sup/index.rb | Redwood.Index.num_results_for | def num_results_for query={}
xapian_query = build_xapian_query query
matchset = run_query xapian_query, 0, 0, 100
matchset.matches_estimated
end | ruby | def num_results_for query={}
xapian_query = build_xapian_query query
matchset = run_query xapian_query, 0, 0, 100
matchset.matches_estimated
end | [
"def",
"num_results_for",
"query",
"=",
"{",
"}",
"xapian_query",
"=",
"build_xapian_query",
"query",
"matchset",
"=",
"run_query",
"xapian_query",
",",
"0",
",",
"0",
",",
"100",
"matchset",
".",
"matches_estimated",
"end"
] | Return the number of matches for query in the index | [
"Return",
"the",
"number",
"of",
"matches",
"for",
"query",
"in",
"the",
"index"
] | 36f95462e3014c354c577d63a78ba030c4b84474 | https://github.com/sup-heliotrope/sup/blob/36f95462e3014c354c577d63a78ba030c4b84474/lib/sup/index.rb#L169-L173 |
15,281 | sup-heliotrope/sup | lib/sup/index.rb | Redwood.Index.build_message | def build_message id
entry = synchronize { get_entry id }
return unless entry
locations = entry[:locations].map do |source_id,source_info|
source = SourceManager[source_id]
raise "invalid source #{source_id}" unless source
Location.new source, source_info
end
m = Message.new :loc... | ruby | def build_message id
entry = synchronize { get_entry id }
return unless entry
locations = entry[:locations].map do |source_id,source_info|
source = SourceManager[source_id]
raise "invalid source #{source_id}" unless source
Location.new source, source_info
end
m = Message.new :loc... | [
"def",
"build_message",
"id",
"entry",
"=",
"synchronize",
"{",
"get_entry",
"id",
"}",
"return",
"unless",
"entry",
"locations",
"=",
"entry",
"[",
":locations",
"]",
".",
"map",
"do",
"|",
"source_id",
",",
"source_info",
"|",
"source",
"=",
"SourceManager... | Load message with the given message-id from the index | [
"Load",
"message",
"with",
"the",
"given",
"message",
"-",
"id",
"from",
"the",
"index"
] | 36f95462e3014c354c577d63a78ba030c4b84474 | https://github.com/sup-heliotrope/sup/blob/36f95462e3014c354c577d63a78ba030c4b84474/lib/sup/index.rb#L235-L259 |
15,282 | sup-heliotrope/sup | lib/sup/index.rb | Redwood.Index.load_contacts | def load_contacts email_addresses, opts={}
contacts = Set.new
num = opts[:num] || 20
each_id_by_date :participants => email_addresses do |id,b|
break if contacts.size >= num
m = b.call
([m.from]+m.to+m.cc+m.bcc).compact.each { |p| contacts << [p.name, p.email] }
end
contacts.to_a.c... | ruby | def load_contacts email_addresses, opts={}
contacts = Set.new
num = opts[:num] || 20
each_id_by_date :participants => email_addresses do |id,b|
break if contacts.size >= num
m = b.call
([m.from]+m.to+m.cc+m.bcc).compact.each { |p| contacts << [p.name, p.email] }
end
contacts.to_a.c... | [
"def",
"load_contacts",
"email_addresses",
",",
"opts",
"=",
"{",
"}",
"contacts",
"=",
"Set",
".",
"new",
"num",
"=",
"opts",
"[",
":num",
"]",
"||",
"20",
"each_id_by_date",
":participants",
"=>",
"email_addresses",
"do",
"|",
"id",
",",
"b",
"|",
"bre... | Given an array of email addresses, return an array of Person objects that
have sent mail to or received mail from any of the given addresses. | [
"Given",
"an",
"array",
"of",
"email",
"addresses",
"return",
"an",
"array",
"of",
"Person",
"objects",
"that",
"have",
"sent",
"mail",
"to",
"or",
"received",
"mail",
"from",
"any",
"of",
"the",
"given",
"addresses",
"."
] | 36f95462e3014c354c577d63a78ba030c4b84474 | https://github.com/sup-heliotrope/sup/blob/36f95462e3014c354c577d63a78ba030c4b84474/lib/sup/index.rb#L268-L277 |
15,283 | sup-heliotrope/sup | lib/sup/index.rb | Redwood.Index.index_message_static | def index_message_static m, doc, entry
# Person names are indexed with several prefixes
person_termer = lambda do |d|
lambda do |p|
doc.index_text p.name, PREFIX["#{d}_name"][:prefix] if p.name
doc.index_text p.email, PREFIX['email_text'][:prefix]
doc.add_term mkterm(:email, d, p.e... | ruby | def index_message_static m, doc, entry
# Person names are indexed with several prefixes
person_termer = lambda do |d|
lambda do |p|
doc.index_text p.name, PREFIX["#{d}_name"][:prefix] if p.name
doc.index_text p.email, PREFIX['email_text'][:prefix]
doc.add_term mkterm(:email, d, p.e... | [
"def",
"index_message_static",
"m",
",",
"doc",
",",
"entry",
"# Person names are indexed with several prefixes",
"person_termer",
"=",
"lambda",
"do",
"|",
"d",
"|",
"lambda",
"do",
"|",
"p",
"|",
"doc",
".",
"index_text",
"p",
".",
"name",
",",
"PREFIX",
"["... | Index content that can't be changed by the user | [
"Index",
"content",
"that",
"can",
"t",
"be",
"changed",
"by",
"the",
"user"
] | 36f95462e3014c354c577d63a78ba030c4b84474 | https://github.com/sup-heliotrope/sup/blob/36f95462e3014c354c577d63a78ba030c4b84474/lib/sup/index.rb#L748-L786 |
15,284 | sup-heliotrope/sup | lib/sup/index.rb | Redwood.Index.mkterm | def mkterm type, *args
case type
when :label
PREFIX['label'][:prefix] + args[0].to_s.downcase
when :type
PREFIX['type'][:prefix] + args[0].to_s.downcase
when :date
PREFIX['date'][:prefix] + args[0].getutc.strftime("%Y%m%d%H%M%S")
when :email
case args[0]
when :from then... | ruby | def mkterm type, *args
case type
when :label
PREFIX['label'][:prefix] + args[0].to_s.downcase
when :type
PREFIX['type'][:prefix] + args[0].to_s.downcase
when :date
PREFIX['date'][:prefix] + args[0].getutc.strftime("%Y%m%d%H%M%S")
when :email
case args[0]
when :from then... | [
"def",
"mkterm",
"type",
",",
"*",
"args",
"case",
"type",
"when",
":label",
"PREFIX",
"[",
"'label'",
"]",
"[",
":prefix",
"]",
"+",
"args",
"[",
"0",
"]",
".",
"to_s",
".",
"downcase",
"when",
":type",
"PREFIX",
"[",
"'type'",
"]",
"[",
":prefix",
... | Construct a Xapian term | [
"Construct",
"a",
"Xapian",
"term"
] | 36f95462e3014c354c577d63a78ba030c4b84474 | https://github.com/sup-heliotrope/sup/blob/36f95462e3014c354c577d63a78ba030c4b84474/lib/sup/index.rb#L841-L866 |
15,285 | sup-heliotrope/sup | lib/sup/thread.rb | Redwood.ThreadSet.link | def link p, c, overwrite=false
if p == c || p.descendant_of?(c) || c.descendant_of?(p) # would create a loop
#puts "*** linking parent #{p.id} and child #{c.id} would create a loop"
return
end
#puts "in link for #{p.id} to #{c.id}, perform? #{c.parent.nil?} || #{overwrite}"
return unless c... | ruby | def link p, c, overwrite=false
if p == c || p.descendant_of?(c) || c.descendant_of?(p) # would create a loop
#puts "*** linking parent #{p.id} and child #{c.id} would create a loop"
return
end
#puts "in link for #{p.id} to #{c.id}, perform? #{c.parent.nil?} || #{overwrite}"
return unless c... | [
"def",
"link",
"p",
",",
"c",
",",
"overwrite",
"=",
"false",
"if",
"p",
"==",
"c",
"||",
"p",
".",
"descendant_of?",
"(",
"c",
")",
"||",
"c",
".",
"descendant_of?",
"(",
"p",
")",
"# would create a loop",
"#puts \"*** linking parent #{p.id} and child #{c.id}... | link two containers | [
"link",
"two",
"containers"
] | 36f95462e3014c354c577d63a78ba030c4b84474 | https://github.com/sup-heliotrope/sup/blob/36f95462e3014c354c577d63a78ba030c4b84474/lib/sup/thread.rb#L292-L308 |
15,286 | sup-heliotrope/sup | lib/sup/thread.rb | Redwood.ThreadSet.load_thread_for_message | def load_thread_for_message m, opts={}
good = @index.each_message_in_thread_for m, opts do |mid, builder|
next if contains_id? mid
add_message builder.call
end
add_message m if good
end | ruby | def load_thread_for_message m, opts={}
good = @index.each_message_in_thread_for m, opts do |mid, builder|
next if contains_id? mid
add_message builder.call
end
add_message m if good
end | [
"def",
"load_thread_for_message",
"m",
",",
"opts",
"=",
"{",
"}",
"good",
"=",
"@index",
".",
"each_message_in_thread_for",
"m",
",",
"opts",
"do",
"|",
"mid",
",",
"builder",
"|",
"next",
"if",
"contains_id?",
"mid",
"add_message",
"builder",
".",
"call",
... | loads in all messages needed to thread m
may do nothing if m's thread is killed | [
"loads",
"in",
"all",
"messages",
"needed",
"to",
"thread",
"m",
"may",
"do",
"nothing",
"if",
"m",
"s",
"thread",
"is",
"killed"
] | 36f95462e3014c354c577d63a78ba030c4b84474 | https://github.com/sup-heliotrope/sup/blob/36f95462e3014c354c577d63a78ba030c4b84474/lib/sup/thread.rb#L352-L358 |
15,287 | sup-heliotrope/sup | lib/sup/thread.rb | Redwood.ThreadSet.add_thread | def add_thread t
raise "duplicate" if @threads.values.member? t
t.each { |m, *o| add_message m }
end | ruby | def add_thread t
raise "duplicate" if @threads.values.member? t
t.each { |m, *o| add_message m }
end | [
"def",
"add_thread",
"t",
"raise",
"\"duplicate\"",
"if",
"@threads",
".",
"values",
".",
"member?",
"t",
"t",
".",
"each",
"{",
"|",
"m",
",",
"*",
"o",
"|",
"add_message",
"m",
"}",
"end"
] | merges in a pre-loaded thread | [
"merges",
"in",
"a",
"pre",
"-",
"loaded",
"thread"
] | 36f95462e3014c354c577d63a78ba030c4b84474 | https://github.com/sup-heliotrope/sup/blob/36f95462e3014c354c577d63a78ba030c4b84474/lib/sup/thread.rb#L361-L364 |
15,288 | sup-heliotrope/sup | lib/sup/thread.rb | Redwood.ThreadSet.join_threads | def join_threads threads
return if threads.size < 2
containers = threads.map do |t|
c = @messages.member?(t.first.id) ? @messages[t.first.id] : nil
raise "not in threadset: #{t.first.id}" unless c && c.message
c
end
## use subject headers heuristically
parent = containers.find { ... | ruby | def join_threads threads
return if threads.size < 2
containers = threads.map do |t|
c = @messages.member?(t.first.id) ? @messages[t.first.id] : nil
raise "not in threadset: #{t.first.id}" unless c && c.message
c
end
## use subject headers heuristically
parent = containers.find { ... | [
"def",
"join_threads",
"threads",
"return",
"if",
"threads",
".",
"size",
"<",
"2",
"containers",
"=",
"threads",
".",
"map",
"do",
"|",
"t",
"|",
"c",
"=",
"@messages",
".",
"member?",
"(",
"t",
".",
"first",
".",
"id",
")",
"?",
"@messages",
"[",
... | merges two threads together. both must be members of this threadset.
does its best, heuristically, to determine which is the parent. | [
"merges",
"two",
"threads",
"together",
".",
"both",
"must",
"be",
"members",
"of",
"this",
"threadset",
".",
"does",
"its",
"best",
"heuristically",
"to",
"determine",
"which",
"is",
"the",
"parent",
"."
] | 36f95462e3014c354c577d63a78ba030c4b84474 | https://github.com/sup-heliotrope/sup/blob/36f95462e3014c354c577d63a78ba030c4b84474/lib/sup/thread.rb#L368-L390 |
15,289 | sup-heliotrope/sup | lib/sup/thread.rb | Redwood.ThreadSet.add_message | def add_message message
el = @messages[message.id]
return if el.message # we've seen it before
#puts "adding: #{message.id}, refs #{message.refs.inspect}"
el.message = message
oldroot = el.root
## link via references:
(message.refs + [el.id]).inject(nil) do |prev, ref_id|
ref = @mes... | ruby | def add_message message
el = @messages[message.id]
return if el.message # we've seen it before
#puts "adding: #{message.id}, refs #{message.refs.inspect}"
el.message = message
oldroot = el.root
## link via references:
(message.refs + [el.id]).inject(nil) do |prev, ref_id|
ref = @mes... | [
"def",
"add_message",
"message",
"el",
"=",
"@messages",
"[",
"message",
".",
"id",
"]",
"return",
"if",
"el",
".",
"message",
"# we've seen it before",
"#puts \"adding: #{message.id}, refs #{message.refs.inspect}\"",
"el",
".",
"message",
"=",
"message",
"oldroot",
"... | the heart of the threading code | [
"the",
"heart",
"of",
"the",
"threading",
"code"
] | 36f95462e3014c354c577d63a78ba030c4b84474 | https://github.com/sup-heliotrope/sup/blob/36f95462e3014c354c577d63a78ba030c4b84474/lib/sup/thread.rb#L403-L449 |
15,290 | sup-heliotrope/sup | lib/sup/message.rb | Redwood.Message.load_from_source! | def load_from_source!
@chunks ||=
begin
## we need to re-read the header because it contains information
## that we don't store in the index. actually i think it's just
## the mailing list address (if any), so this is kinda overkill.
## i could just store that in the index, but... | ruby | def load_from_source!
@chunks ||=
begin
## we need to re-read the header because it contains information
## that we don't store in the index. actually i think it's just
## the mailing list address (if any), so this is kinda overkill.
## i could just store that in the index, but... | [
"def",
"load_from_source!",
"@chunks",
"||=",
"begin",
"## we need to re-read the header because it contains information",
"## that we don't store in the index. actually i think it's just",
"## the mailing list address (if any), so this is kinda overkill.",
"## i could just store that in the index, ... | this is called when the message body needs to actually be loaded. | [
"this",
"is",
"called",
"when",
"the",
"message",
"body",
"needs",
"to",
"actually",
"be",
"loaded",
"."
] | 36f95462e3014c354c577d63a78ba030c4b84474 | https://github.com/sup-heliotrope/sup/blob/36f95462e3014c354c577d63a78ba030c4b84474/lib/sup/message.rb#L252-L280 |
15,291 | sup-heliotrope/sup | lib/sup/message.rb | Redwood.Message.indexable_content | def indexable_content
load_from_source!
[
from && from.indexable_content,
to.map { |p| p.indexable_content },
cc.map { |p| p.indexable_content },
bcc.map { |p| p.indexable_content },
indexable_chunks.map { |c| c.lines.map { |l| l.fix_encoding! } },
indexable_subject,
].fl... | ruby | def indexable_content
load_from_source!
[
from && from.indexable_content,
to.map { |p| p.indexable_content },
cc.map { |p| p.indexable_content },
bcc.map { |p| p.indexable_content },
indexable_chunks.map { |c| c.lines.map { |l| l.fix_encoding! } },
indexable_subject,
].fl... | [
"def",
"indexable_content",
"load_from_source!",
"[",
"from",
"&&",
"from",
".",
"indexable_content",
",",
"to",
".",
"map",
"{",
"|",
"p",
"|",
"p",
".",
"indexable_content",
"}",
",",
"cc",
".",
"map",
"{",
"|",
"p",
"|",
"p",
".",
"indexable_content",... | returns all the content from a message that will be indexed | [
"returns",
"all",
"the",
"content",
"from",
"a",
"message",
"that",
"will",
"be",
"indexed"
] | 36f95462e3014c354c577d63a78ba030c4b84474 | https://github.com/sup-heliotrope/sup/blob/36f95462e3014c354c577d63a78ba030c4b84474/lib/sup/message.rb#L337-L347 |
15,292 | sup-heliotrope/sup | lib/sup/message.rb | Redwood.Message.multipart_signed_to_chunks | def multipart_signed_to_chunks m
if m.body.size != 2
warn_with_location "multipart/signed with #{m.body.size} parts (expecting 2)"
return
end
payload, signature = m.body
if signature.multipart?
warn_with_location "multipart/signed with payload multipart #{payload.multipart?} and signa... | ruby | def multipart_signed_to_chunks m
if m.body.size != 2
warn_with_location "multipart/signed with #{m.body.size} parts (expecting 2)"
return
end
payload, signature = m.body
if signature.multipart?
warn_with_location "multipart/signed with payload multipart #{payload.multipart?} and signa... | [
"def",
"multipart_signed_to_chunks",
"m",
"if",
"m",
".",
"body",
".",
"size",
"!=",
"2",
"warn_with_location",
"\"multipart/signed with #{m.body.size} parts (expecting 2)\"",
"return",
"end",
"payload",
",",
"signature",
"=",
"m",
".",
"body",
"if",
"signature",
".",... | here's where we handle decoding mime attachments. unfortunately
but unsurprisingly, the world of mime attachments is a bit of a
mess. as an empiricist, i'm basing the following behavior on
observed mail rather than on interpretations of rfcs, so probably
this will have to be tweaked.
the general behavior i want i... | [
"here",
"s",
"where",
"we",
"handle",
"decoding",
"mime",
"attachments",
".",
"unfortunately",
"but",
"unsurprisingly",
"the",
"world",
"of",
"mime",
"attachments",
"is",
"a",
"bit",
"of",
"a",
"mess",
".",
"as",
"an",
"empiricist",
"i",
"m",
"basing",
"th... | 36f95462e3014c354c577d63a78ba030c4b84474 | https://github.com/sup-heliotrope/sup/blob/36f95462e3014c354c577d63a78ba030c4b84474/lib/sup/message.rb#L405-L430 |
15,293 | sup-heliotrope/sup | lib/sup/label.rb | Redwood.LabelManager.string_for | def string_for l
if RESERVED_LABELS.include? l
l.to_s.capitalize
else
l.to_s
end
end | ruby | def string_for l
if RESERVED_LABELS.include? l
l.to_s.capitalize
else
l.to_s
end
end | [
"def",
"string_for",
"l",
"if",
"RESERVED_LABELS",
".",
"include?",
"l",
"l",
".",
"to_s",
".",
"capitalize",
"else",
"l",
".",
"to_s",
"end",
"end"
] | reverse the label->string mapping, for convenience! | [
"reverse",
"the",
"label",
"-",
">",
"string",
"mapping",
"for",
"convenience!"
] | 36f95462e3014c354c577d63a78ba030c4b84474 | https://github.com/sup-heliotrope/sup/blob/36f95462e3014c354c577d63a78ba030c4b84474/lib/sup/label.rb#L47-L53 |
15,294 | sup-heliotrope/sup | lib/sup/modes/scroll_mode.rb | Redwood.ScrollMode.search_goto_pos | def search_goto_pos line, leftcol, rightcol
search_goto_line line
if rightcol > self.rightcol # if it's occluded...
jump_to_col [rightcol - buffer.content_width + 1, 0].max # move right
end
end | ruby | def search_goto_pos line, leftcol, rightcol
search_goto_line line
if rightcol > self.rightcol # if it's occluded...
jump_to_col [rightcol - buffer.content_width + 1, 0].max # move right
end
end | [
"def",
"search_goto_pos",
"line",
",",
"leftcol",
",",
"rightcol",
"search_goto_line",
"line",
"if",
"rightcol",
">",
"self",
".",
"rightcol",
"# if it's occluded...",
"jump_to_col",
"[",
"rightcol",
"-",
"buffer",
".",
"content_width",
"+",
"1",
",",
"0",
"]",
... | subclasses can override these three! | [
"subclasses",
"can",
"override",
"these",
"three!"
] | 36f95462e3014c354c577d63a78ba030c4b84474 | https://github.com/sup-heliotrope/sup/blob/36f95462e3014c354c577d63a78ba030c4b84474/lib/sup/modes/scroll_mode.rb#L89-L95 |
15,295 | sup-heliotrope/sup | lib/sup/modes/scroll_mode.rb | Redwood.ScrollMode.jump_to_line | def jump_to_line l
l = l.clamp 0, lines - 1
return if @topline == l
@topline = l
@botline = [l + buffer.content_height, lines].min
buffer.mark_dirty
end | ruby | def jump_to_line l
l = l.clamp 0, lines - 1
return if @topline == l
@topline = l
@botline = [l + buffer.content_height, lines].min
buffer.mark_dirty
end | [
"def",
"jump_to_line",
"l",
"l",
"=",
"l",
".",
"clamp",
"0",
",",
"lines",
"-",
"1",
"return",
"if",
"@topline",
"==",
"l",
"@topline",
"=",
"l",
"@botline",
"=",
"[",
"l",
"+",
"buffer",
".",
"content_height",
",",
"lines",
"]",
".",
"min",
"buff... | set top line to l | [
"set",
"top",
"line",
"to",
"l"
] | 36f95462e3014c354c577d63a78ba030c4b84474 | https://github.com/sup-heliotrope/sup/blob/36f95462e3014c354c577d63a78ba030c4b84474/lib/sup/modes/scroll_mode.rb#L123-L129 |
15,296 | sup-heliotrope/sup | lib/sup/modes/line_cursor_mode.rb | Redwood.LineCursorMode.page_down | def page_down
## if we're on the last page, and it's not a full page, just move
## the cursor down to the bottom and assume we can't load anything
## else via the callbacks.
if topline > lines - buffer.content_height
set_cursor_pos(lines - 1)
## if we're on the last page, and it's a full page... | ruby | def page_down
## if we're on the last page, and it's not a full page, just move
## the cursor down to the bottom and assume we can't load anything
## else via the callbacks.
if topline > lines - buffer.content_height
set_cursor_pos(lines - 1)
## if we're on the last page, and it's a full page... | [
"def",
"page_down",
"## if we're on the last page, and it's not a full page, just move",
"## the cursor down to the bottom and assume we can't load anything",
"## else via the callbacks.",
"if",
"topline",
">",
"lines",
"-",
"buffer",
".",
"content_height",
"set_cursor_pos",
"(",
"line... | more complicated than one might think. three behaviors. | [
"more",
"complicated",
"than",
"one",
"might",
"think",
".",
"three",
"behaviors",
"."
] | 36f95462e3014c354c577d63a78ba030c4b84474 | https://github.com/sup-heliotrope/sup/blob/36f95462e3014c354c577d63a78ba030c4b84474/lib/sup/modes/line_cursor_mode.rb#L161-L180 |
15,297 | sup-heliotrope/sup | lib/sup/textfield.rb | Redwood.TextField.get_cursed_value | def get_cursed_value
return nil unless @field
x = Ncurses.curx
form_driver_key Ncurses::Form::REQ_VALIDATION
v = @field.field_buffer(0).gsub(/^\s+|\s+$/, "")
## cursor <= end of text
if x - @question.length - v.length <= 0
v
else # trailing spaces
v + (" " * (x - @question.leng... | ruby | def get_cursed_value
return nil unless @field
x = Ncurses.curx
form_driver_key Ncurses::Form::REQ_VALIDATION
v = @field.field_buffer(0).gsub(/^\s+|\s+$/, "")
## cursor <= end of text
if x - @question.length - v.length <= 0
v
else # trailing spaces
v + (" " * (x - @question.leng... | [
"def",
"get_cursed_value",
"return",
"nil",
"unless",
"@field",
"x",
"=",
"Ncurses",
".",
"curx",
"form_driver_key",
"Ncurses",
"::",
"Form",
"::",
"REQ_VALIDATION",
"v",
"=",
"@field",
".",
"field_buffer",
"(",
"0",
")",
".",
"gsub",
"(",
"/",
"\\s",
"\\s... | ncurses inanity wrapper
DO NOT READ THIS CODE. YOU WILL GO MAD. | [
"ncurses",
"inanity",
"wrapper"
] | 36f95462e3014c354c577d63a78ba030c4b84474 | https://github.com/sup-heliotrope/sup/blob/36f95462e3014c354c577d63a78ba030c4b84474/lib/sup/textfield.rb#L177-L200 |
15,298 | websocket-rails/websocket-rails | lib/websocket_rails/base_controller.rb | WebsocketRails.BaseController.trigger_success | def trigger_success(data=nil)
event.success = true
event.data = data
event.trigger
end | ruby | def trigger_success(data=nil)
event.success = true
event.data = data
event.trigger
end | [
"def",
"trigger_success",
"(",
"data",
"=",
"nil",
")",
"event",
".",
"success",
"=",
"true",
"event",
".",
"data",
"=",
"data",
"event",
".",
"trigger",
"end"
] | Trigger the success callback function attached to the client event that triggered
this action. The object passed to this method will be passed as an argument to
the callback function on the client. | [
"Trigger",
"the",
"success",
"callback",
"function",
"attached",
"to",
"the",
"client",
"event",
"that",
"triggered",
"this",
"action",
".",
"The",
"object",
"passed",
"to",
"this",
"method",
"will",
"be",
"passed",
"as",
"an",
"argument",
"to",
"the",
"call... | 0ee9e97b19e1f8250c18ded08c71647a51669122 | https://github.com/websocket-rails/websocket-rails/blob/0ee9e97b19e1f8250c18ded08c71647a51669122/lib/websocket_rails/base_controller.rb#L100-L104 |
15,299 | websocket-rails/websocket-rails | lib/websocket_rails/base_controller.rb | WebsocketRails.BaseController.trigger_failure | def trigger_failure(data=nil)
event.success = false
event.data = data
event.trigger
end | ruby | def trigger_failure(data=nil)
event.success = false
event.data = data
event.trigger
end | [
"def",
"trigger_failure",
"(",
"data",
"=",
"nil",
")",
"event",
".",
"success",
"=",
"false",
"event",
".",
"data",
"=",
"data",
"event",
".",
"trigger",
"end"
] | Trigger the failure callback function attached to the client event that triggered
this action. The object passed to this method will be passed as an argument to
the callback function on the client. | [
"Trigger",
"the",
"failure",
"callback",
"function",
"attached",
"to",
"the",
"client",
"event",
"that",
"triggered",
"this",
"action",
".",
"The",
"object",
"passed",
"to",
"this",
"method",
"will",
"be",
"passed",
"as",
"an",
"argument",
"to",
"the",
"call... | 0ee9e97b19e1f8250c18ded08c71647a51669122 | https://github.com/websocket-rails/websocket-rails/blob/0ee9e97b19e1f8250c18ded08c71647a51669122/lib/websocket_rails/base_controller.rb#L109-L113 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.