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 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
rightscale/right_amqp | lib/right_amqp/ha_client/ha_broker_client.rb | RightAMQP.HABrokerClient.each | def each(status, identities = nil)
choices = if identities && !identities.empty?
identities.inject([]) { |c, i| if b = @brokers_hash[i] then c << b else c end }
else
@brokers
end
choices.select do |b|
if b.send("#{status}?".to_sym)
yield(b) if block_given?
... | ruby | def each(status, identities = nil)
choices = if identities && !identities.empty?
identities.inject([]) { |c, i| if b = @brokers_hash[i] then c << b else c end }
else
@brokers
end
choices.select do |b|
if b.send("#{status}?".to_sym)
yield(b) if block_given?
... | [
"def",
"each",
"(",
"status",
",",
"identities",
"=",
"nil",
")",
"choices",
"=",
"if",
"identities",
"&&",
"!",
"identities",
".",
"empty?",
"identities",
".",
"inject",
"(",
"[",
"]",
")",
"{",
"|",
"c",
",",
"i",
"|",
"if",
"b",
"=",
"@brokers_h... | Iterate over clients that have the specified status
=== Parameters
status(String):: Status for selecting: :usable, :connected, :failed
identities(Array):: Identity of brokers to be considered, nil or empty array means all brokers
=== Block
Optional block with following parameters to be called for each broker cli... | [
"Iterate",
"over",
"clients",
"that",
"have",
"the",
"specified",
"status"
] | 248de38141b228bdb437757155d7fd7dd6e50733 | https://github.com/rightscale/right_amqp/blob/248de38141b228bdb437757155d7fd7dd6e50733/lib/right_amqp/ha_client/ha_broker_client.rb#L942-L954 | train |
rightscale/right_amqp | lib/right_amqp/ha_client/ha_broker_client.rb | RightAMQP.HABrokerClient.use | def use(options)
choices = []
select = options[:order]
if options[:brokers] && !options[:brokers].empty?
options[:brokers].each do |identity|
if choice = @brokers_hash[identity]
choices << choice
else
logger.exception("Invalid broker identity #{ident... | ruby | def use(options)
choices = []
select = options[:order]
if options[:brokers] && !options[:brokers].empty?
options[:brokers].each do |identity|
if choice = @brokers_hash[identity]
choices << choice
else
logger.exception("Invalid broker identity #{ident... | [
"def",
"use",
"(",
"options",
")",
"choices",
"=",
"[",
"]",
"select",
"=",
"options",
"[",
":order",
"]",
"if",
"options",
"[",
":brokers",
"]",
"&&",
"!",
"options",
"[",
":brokers",
"]",
".",
"empty?",
"options",
"[",
":brokers",
"]",
".",
"each",... | Select the broker clients to be used in the desired order
=== Parameters
options(Hash):: Selection options:
:brokers(Array):: Identity of brokers selected for use, defaults to all brokers if nil or empty
:order(Symbol):: Broker selection order: :random or :priority,
defaults to @select if :brokers is nil,... | [
"Select",
"the",
"broker",
"clients",
"to",
"be",
"used",
"in",
"the",
"desired",
"order"
] | 248de38141b228bdb437757155d7fd7dd6e50733 | https://github.com/rightscale/right_amqp/blob/248de38141b228bdb437757155d7fd7dd6e50733/lib/right_amqp/ha_client/ha_broker_client.rb#L966-L986 | train |
rightscale/right_amqp | lib/right_amqp/ha_client/ha_broker_client.rb | RightAMQP.HABrokerClient.handle_return | def handle_return(identity, to, reason, message)
@brokers_hash[identity].update_status(:stopping) if reason == "ACCESS_REFUSED"
if context = @published.fetch(message)
@return_stats.update("#{alias_(identity)} (#{reason.to_s.downcase})")
context.record_failure(identity)
name = contex... | ruby | def handle_return(identity, to, reason, message)
@brokers_hash[identity].update_status(:stopping) if reason == "ACCESS_REFUSED"
if context = @published.fetch(message)
@return_stats.update("#{alias_(identity)} (#{reason.to_s.downcase})")
context.record_failure(identity)
name = contex... | [
"def",
"handle_return",
"(",
"identity",
",",
"to",
",",
"reason",
",",
"message",
")",
"@brokers_hash",
"[",
"identity",
"]",
".",
"update_status",
"(",
":stopping",
")",
"if",
"reason",
"==",
"\"ACCESS_REFUSED\"",
"if",
"context",
"=",
"@published",
".",
"... | Handle message returned by broker because it could not deliver it
If agent still active, resend using another broker
If this is last usable broker and persistent is enabled, allow message to be queued
on next send even if the queue has no consumers so there is a chance of message
eventually being delivered
If pers... | [
"Handle",
"message",
"returned",
"by",
"broker",
"because",
"it",
"could",
"not",
"deliver",
"it",
"If",
"agent",
"still",
"active",
"resend",
"using",
"another",
"broker",
"If",
"this",
"is",
"last",
"usable",
"broker",
"and",
"persistent",
"is",
"enabled",
... | 248de38141b228bdb437757155d7fd7dd6e50733 | https://github.com/rightscale/right_amqp/blob/248de38141b228bdb437757155d7fd7dd6e50733/lib/right_amqp/ha_client/ha_broker_client.rb#L1066-L1113 | train |
KatanaCode/evvnt | lib/evvnt/attributes.rb | Evvnt.Attributes.method_missing | def method_missing(method_name, *args)
setter = method_name.to_s.ends_with?('=')
attr_name = method_name.to_s.gsub(/=$/, "")
if setter
attributes[attr_name] = args.first
else
attributes[attr_name]
end
end | ruby | def method_missing(method_name, *args)
setter = method_name.to_s.ends_with?('=')
attr_name = method_name.to_s.gsub(/=$/, "")
if setter
attributes[attr_name] = args.first
else
attributes[attr_name]
end
end | [
"def",
"method_missing",
"(",
"method_name",
",",
"*",
"args",
")",
"setter",
"=",
"method_name",
".",
"to_s",
".",
"ends_with?",
"(",
"'='",
")",
"attr_name",
"=",
"method_name",
".",
"to_s",
".",
"gsub",
"(",
"/",
"/",
",",
"\"\"",
")",
"if",
"setter... | Overrides method missing to catch undefined methods. If +method_name+ is one
of the keys on +attributes+, returns the value of that attribute. If +method_name+
is not one of +attributes+, passes up the chain to super.
method_name - Symbol of the name of the method we're testing for.
args - Array of argument... | [
"Overrides",
"method",
"missing",
"to",
"catch",
"undefined",
"methods",
".",
"If",
"+",
"method_name",
"+",
"is",
"one",
"of",
"the",
"keys",
"on",
"+",
"attributes",
"+",
"returns",
"the",
"value",
"of",
"that",
"attribute",
".",
"If",
"+",
"method_name"... | e13f6d84af09a71819356620fb25685a6cd159c9 | https://github.com/KatanaCode/evvnt/blob/e13f6d84af09a71819356620fb25685a6cd159c9/lib/evvnt/attributes.rb#L101-L109 | train |
jinx/core | lib/jinx/resource/match_visitor.rb | Jinx.MatchVisitor.visit | def visit(source, target, &block)
# clear the match hashes
@matches.clear
@id_mtchs.clear
# seed the matches with the top-level source => target
add_match(source, target)
# Visit the source reference.
super(source) { |src| visit_matched(src, &block) }
end | ruby | def visit(source, target, &block)
# clear the match hashes
@matches.clear
@id_mtchs.clear
# seed the matches with the top-level source => target
add_match(source, target)
# Visit the source reference.
super(source) { |src| visit_matched(src, &block) }
end | [
"def",
"visit",
"(",
"source",
",",
"target",
",",
"&",
"block",
")",
"# clear the match hashes",
"@matches",
".",
"clear",
"@id_mtchs",
".",
"clear",
"# seed the matches with the top-level source => target",
"add_match",
"(",
"source",
",",
"target",
")",
"# Visit th... | Creates a new visitor which matches source and target domain object references.
The domain attributes to visit are determined by calling the selector block given to
this initializer. The selector arguments consist of the match source and target.
@param (see ReferenceVisitor#initialize)
@option opts [Proc] :mergeab... | [
"Creates",
"a",
"new",
"visitor",
"which",
"matches",
"source",
"and",
"target",
"domain",
"object",
"references",
".",
"The",
"domain",
"attributes",
"to",
"visit",
"are",
"determined",
"by",
"calling",
"the",
"selector",
"block",
"given",
"to",
"this",
"init... | 964a274cc9d7ab74613910e8375e12ed210a434d | https://github.com/jinx/core/blob/964a274cc9d7ab74613910e8375e12ed210a434d/lib/jinx/resource/match_visitor.rb#L63-L71 | train |
jinx/core | lib/jinx/resource/match_visitor.rb | Jinx.MatchVisitor.visit_matched | def visit_matched(source)
tgt = @matches[source] || return
# Match the unvisited matchable references, if any.
if @matchable then
mas = @matchable.call(source) - attributes_to_visit(source)
mas.each { |ma| match_reference(source, tgt, ma) }
end
block_given? ? yield(source, ... | ruby | def visit_matched(source)
tgt = @matches[source] || return
# Match the unvisited matchable references, if any.
if @matchable then
mas = @matchable.call(source) - attributes_to_visit(source)
mas.each { |ma| match_reference(source, tgt, ma) }
end
block_given? ? yield(source, ... | [
"def",
"visit_matched",
"(",
"source",
")",
"tgt",
"=",
"@matches",
"[",
"source",
"]",
"||",
"return",
"# Match the unvisited matchable references, if any.",
"if",
"@matchable",
"then",
"mas",
"=",
"@matchable",
".",
"call",
"(",
"source",
")",
"-",
"attributes_t... | Visits the given source domain object.
@param [Resource] source the match visit source
@yield [target, source] the optional block to call on the matched source and target
@yieldparam [Resource] source the visited source domain object
@yieldparam [Resource] target the domain object which matches the visited source
... | [
"Visits",
"the",
"given",
"source",
"domain",
"object",
"."
] | 964a274cc9d7ab74613910e8375e12ed210a434d | https://github.com/jinx/core/blob/964a274cc9d7ab74613910e8375e12ed210a434d/lib/jinx/resource/match_visitor.rb#L92-L100 | train |
jinx/core | lib/jinx/resource/match_visitor.rb | Jinx.MatchVisitor.match_reference | def match_reference(source, target, attribute)
srcs = source.send(attribute).to_enum
tgts = target.send(attribute).to_enum
# the match targets
mtchd_tgts = Set.new
# capture the matched targets and the the unmatched sources
unmtchd_srcs = srcs.reject do |src|
# the pri... | ruby | def match_reference(source, target, attribute)
srcs = source.send(attribute).to_enum
tgts = target.send(attribute).to_enum
# the match targets
mtchd_tgts = Set.new
# capture the matched targets and the the unmatched sources
unmtchd_srcs = srcs.reject do |src|
# the pri... | [
"def",
"match_reference",
"(",
"source",
",",
"target",
",",
"attribute",
")",
"srcs",
"=",
"source",
".",
"send",
"(",
"attribute",
")",
".",
"to_enum",
"tgts",
"=",
"target",
".",
"send",
"(",
"attribute",
")",
".",
"to_enum",
"# the match targets",
"mtc... | Matches the given source and target attribute references.
The match is performed by this visitor's matcher.
@param source (see #visit)
@param target (see #visit)
@param [Symbol] attribute the parent reference attribute
@return [{Resource => Resource}] the referenced source => target matches | [
"Matches",
"the",
"given",
"source",
"and",
"target",
"attribute",
"references",
".",
"The",
"match",
"is",
"performed",
"by",
"this",
"visitor",
"s",
"matcher",
"."
] | 964a274cc9d7ab74613910e8375e12ed210a434d | https://github.com/jinx/core/blob/964a274cc9d7ab74613910e8375e12ed210a434d/lib/jinx/resource/match_visitor.rb#L131-L157 | train |
DigitPaint/html_mockup | lib/html_mockup/extractor.rb | HtmlMockup.Extractor.extract_source_from_file | def extract_source_from_file(file_path, env = {})
source = HtmlMockup::Template.open(file_path, :partials_path => self.project.partial_path, :layouts_path => self.project.layouts_path).render(env.dup)
if @options[:url_relativize]
source = relativize_urls(source, file_path)
end
so... | ruby | def extract_source_from_file(file_path, env = {})
source = HtmlMockup::Template.open(file_path, :partials_path => self.project.partial_path, :layouts_path => self.project.layouts_path).render(env.dup)
if @options[:url_relativize]
source = relativize_urls(source, file_path)
end
so... | [
"def",
"extract_source_from_file",
"(",
"file_path",
",",
"env",
"=",
"{",
"}",
")",
"source",
"=",
"HtmlMockup",
"::",
"Template",
".",
"open",
"(",
"file_path",
",",
":partials_path",
"=>",
"self",
".",
"project",
".",
"partial_path",
",",
":layouts_path",
... | Runs the extractor on a single file and return processed source. | [
"Runs",
"the",
"extractor",
"on",
"a",
"single",
"file",
"and",
"return",
"processed",
"source",
"."
] | 976edadc01216b82a8cea177f53fb32559eaf41e | https://github.com/DigitPaint/html_mockup/blob/976edadc01216b82a8cea177f53fb32559eaf41e/lib/html_mockup/extractor.rb#L63-L71 | train |
booqable/scoped_serializer | lib/action_controller/serialization.rb | ActionController.Serialization.build_json_serializer | def build_json_serializer(object, options={})
ScopedSerializer.for(object, { :scope => serializer_scope, :super => true }.merge(options.merge(default_serializer_options)))
end | ruby | def build_json_serializer(object, options={})
ScopedSerializer.for(object, { :scope => serializer_scope, :super => true }.merge(options.merge(default_serializer_options)))
end | [
"def",
"build_json_serializer",
"(",
"object",
",",
"options",
"=",
"{",
"}",
")",
"ScopedSerializer",
".",
"for",
"(",
"object",
",",
"{",
":scope",
"=>",
"serializer_scope",
",",
":super",
"=>",
"true",
"}",
".",
"merge",
"(",
"options",
".",
"merge",
... | JSON serializer to use. | [
"JSON",
"serializer",
"to",
"use",
"."
] | fb163bbf61f54a5e8684e4aba3908592bdd986ac | https://github.com/booqable/scoped_serializer/blob/fb163bbf61f54a5e8684e4aba3908592bdd986ac/lib/action_controller/serialization.rb#L30-L32 | train |
terlar/formatter-number | lib/formatter/number.rb | Formatter.Number.format | def format(number)
case number
when Float then format_float(number)
when Integer then format_integer(number)
else fail ArgumentError
end
end | ruby | def format(number)
case number
when Float then format_float(number)
when Integer then format_integer(number)
else fail ArgumentError
end
end | [
"def",
"format",
"(",
"number",
")",
"case",
"number",
"when",
"Float",
"then",
"format_float",
"(",
"number",
")",
"when",
"Integer",
"then",
"format_integer",
"(",
"number",
")",
"else",
"fail",
"ArgumentError",
"end",
"end"
] | Initialize a formatter with the desired options.
@param [Hash] options the options to create a formatter with
@option options [Integer] :decimals (2) Number of decimal places
@option options [Boolean] :fixed (false) Fixed decimal places
@option options [String] :separator ('.') Decimal mark
@option options [Integ... | [
"Initialize",
"a",
"formatter",
"with",
"the",
"desired",
"options",
"."
] | e206c92a6823f12d1019bd9ad5689d914d410ef3 | https://github.com/terlar/formatter-number/blob/e206c92a6823f12d1019bd9ad5689d914d410ef3/lib/formatter/number.rb#L26-L32 | train |
binford2k/arnold | gem/lib/arnold/node_manager.rb | Arnold.NodeManager.remove_stale_symlinks | def remove_stale_symlinks(path)
Dir.glob("#{path}/*").each { |f| File.unlink(f) if not File.exist?(f) }
end | ruby | def remove_stale_symlinks(path)
Dir.glob("#{path}/*").each { |f| File.unlink(f) if not File.exist?(f) }
end | [
"def",
"remove_stale_symlinks",
"(",
"path",
")",
"Dir",
".",
"glob",
"(",
"\"#{path}/*\"",
")",
".",
"each",
"{",
"|",
"f",
"|",
"File",
".",
"unlink",
"(",
"f",
")",
"if",
"not",
"File",
".",
"exist?",
"(",
"f",
")",
"}",
"end"
] | just loop through a directory and get rid of any stale symlinks | [
"just",
"loop",
"through",
"a",
"directory",
"and",
"get",
"rid",
"of",
"any",
"stale",
"symlinks"
] | 8bf1b3c1ae0e76cc97dff1a07b24c2fa9170b688 | https://github.com/binford2k/arnold/blob/8bf1b3c1ae0e76cc97dff1a07b24c2fa9170b688/gem/lib/arnold/node_manager.rb#L114-L116 | train |
bluevialabs/connfu-client | lib/connfu/listener.rb | Connfu.Listener.start | def start(queue = nil)
queue.nil? and queue = @queue
logger.debug "Listener starts..."
@thread = Thread.new {
# listen to connFu
@connfu_stream.start_listening
}
while continue do
logger.debug "Waiting for a message from connFu stream"
message = @connfu_st... | ruby | def start(queue = nil)
queue.nil? and queue = @queue
logger.debug "Listener starts..."
@thread = Thread.new {
# listen to connFu
@connfu_stream.start_listening
}
while continue do
logger.debug "Waiting for a message from connFu stream"
message = @connfu_st... | [
"def",
"start",
"(",
"queue",
"=",
"nil",
")",
"queue",
".",
"nil?",
"and",
"queue",
"=",
"@queue",
"logger",
".",
"debug",
"\"Listener starts...\"",
"@thread",
"=",
"Thread",
".",
"new",
"{",
"# listen to connFu",
"@connfu_stream",
".",
"start_listening",
"}"... | max amount of messages to receive
Listener initializer.
==== Parameters
* +queue+ Connfu::Events instance to forward incoming events to be processed by the Dispatcher class
* +app_stream+ valid HTTP stream url to connect and listen events
* +token+ valid token to get access to a connFu Stream
* +stream_endpoint... | [
"max",
"amount",
"of",
"messages",
"to",
"receive"
] | b62a0f5176afa203ba1eecccc7994d6bc61af3a7 | https://github.com/bluevialabs/connfu-client/blob/b62a0f5176afa203ba1eecccc7994d6bc61af3a7/lib/connfu/listener.rb#L40-L59 | train |
jinx/core | lib/jinx/resource.rb | Jinx.Resource.owner= | def owner=(obj)
if obj.nil? then
op, ov = effective_owner_property_value || return
else
op = self.class.owner_properties.detect { |prop| prop.type === obj }
end
if op.nil? then raise NoMethodError.new("#{self.class.qp} does not have an owner attribute for #{obj}") end
set_p... | ruby | def owner=(obj)
if obj.nil? then
op, ov = effective_owner_property_value || return
else
op = self.class.owner_properties.detect { |prop| prop.type === obj }
end
if op.nil? then raise NoMethodError.new("#{self.class.qp} does not have an owner attribute for #{obj}") end
set_p... | [
"def",
"owner",
"=",
"(",
"obj",
")",
"if",
"obj",
".",
"nil?",
"then",
"op",
",",
"ov",
"=",
"effective_owner_property_value",
"||",
"return",
"else",
"op",
"=",
"self",
".",
"class",
".",
"owner_properties",
".",
"detect",
"{",
"|",
"prop",
"|",
"pro... | Sets this dependent's owner attribute to the given domain object.
@param [Resource] obj the owner domain object
@raise [NoMethodError] if this Resource's class does not have an owner property
which accepts the given domain object | [
"Sets",
"this",
"dependent",
"s",
"owner",
"attribute",
"to",
"the",
"given",
"domain",
"object",
"."
] | 964a274cc9d7ab74613910e8375e12ed210a434d | https://github.com/jinx/core/blob/964a274cc9d7ab74613910e8375e12ed210a434d/lib/jinx/resource.rb#L226-L234 | train |
jinx/core | lib/jinx/resource.rb | Jinx.Resource.references | def references(attributes=nil)
attributes ||= self.class.domain_attributes
attributes.map { |pa| send(pa) }.flatten.compact
end | ruby | def references(attributes=nil)
attributes ||= self.class.domain_attributes
attributes.map { |pa| send(pa) }.flatten.compact
end | [
"def",
"references",
"(",
"attributes",
"=",
"nil",
")",
"attributes",
"||=",
"self",
".",
"class",
".",
"domain_attributes",
"attributes",
".",
"map",
"{",
"|",
"pa",
"|",
"send",
"(",
"pa",
")",
"}",
".",
"flatten",
".",
"compact",
"end"
] | Returns the domain object references for the given attributes.
@param [<Symbol>, nil] the domain attributes to include, or nil to include all domain attributes
@return [<Resource>] the referenced attribute domain object values | [
"Returns",
"the",
"domain",
"object",
"references",
"for",
"the",
"given",
"attributes",
"."
] | 964a274cc9d7ab74613910e8375e12ed210a434d | https://github.com/jinx/core/blob/964a274cc9d7ab74613910e8375e12ed210a434d/lib/jinx/resource.rb#L277-L280 | train |
jinx/core | lib/jinx/resource.rb | Jinx.Resource.direct_dependents | def direct_dependents(attribute)
deps = send(attribute)
case deps
when Enumerable then deps
when nil then Array::EMPTY_ARRAY
else [deps]
end
end | ruby | def direct_dependents(attribute)
deps = send(attribute)
case deps
when Enumerable then deps
when nil then Array::EMPTY_ARRAY
else [deps]
end
end | [
"def",
"direct_dependents",
"(",
"attribute",
")",
"deps",
"=",
"send",
"(",
"attribute",
")",
"case",
"deps",
"when",
"Enumerable",
"then",
"deps",
"when",
"nil",
"then",
"Array",
"::",
"EMPTY_ARRAY",
"else",
"[",
"deps",
"]",
"end",
"end"
] | Returns the attribute references which directly depend on this owner.
The default is the attribute value.
Returns an Enumerable. If the value is not already an Enumerable, then this method
returns an empty array if value is nil, or a singelton array with value otherwise.
If there is more than one owner of a depen... | [
"Returns",
"the",
"attribute",
"references",
"which",
"directly",
"depend",
"on",
"this",
"owner",
".",
"The",
"default",
"is",
"the",
"attribute",
"value",
"."
] | 964a274cc9d7ab74613910e8375e12ed210a434d | https://github.com/jinx/core/blob/964a274cc9d7ab74613910e8375e12ed210a434d/lib/jinx/resource.rb#L335-L342 | train |
jinx/core | lib/jinx/resource.rb | Jinx.Resource.match_in | def match_in(others)
# trivial case: self is in others
return self if others.include?(self)
# filter for the same type
unless others.all? { |other| self.class === other } then
others = others.filter { |other| self.class === other }
end
# match on primary, secondary or alterna... | ruby | def match_in(others)
# trivial case: self is in others
return self if others.include?(self)
# filter for the same type
unless others.all? { |other| self.class === other } then
others = others.filter { |other| self.class === other }
end
# match on primary, secondary or alterna... | [
"def",
"match_in",
"(",
"others",
")",
"# trivial case: self is in others",
"return",
"self",
"if",
"others",
".",
"include?",
"(",
"self",
")",
"# filter for the same type",
"unless",
"others",
".",
"all?",
"{",
"|",
"other",
"|",
"self",
".",
"class",
"===",
... | Matches this dependent domain object with the others on type and key attributes
in the scope of a parent object.
Returns the object in others which matches this domain object, or nil if none.
The match attributes are, in order:
* the primary key
* the secondary key
* the alternate key
This domain object is mat... | [
"Matches",
"this",
"dependent",
"domain",
"object",
"with",
"the",
"others",
"on",
"type",
"and",
"key",
"attributes",
"in",
"the",
"scope",
"of",
"a",
"parent",
"object",
".",
"Returns",
"the",
"object",
"in",
"others",
"which",
"matches",
"this",
"domain",... | 964a274cc9d7ab74613910e8375e12ed210a434d | https://github.com/jinx/core/blob/964a274cc9d7ab74613910e8375e12ed210a434d/lib/jinx/resource.rb#L393-L404 | train |
jinx/core | lib/jinx/resource.rb | Jinx.Resource.visit_path | def visit_path(*path, &operator)
visitor = ReferencePathVisitor.new(self.class, path)
visitor.visit(self, &operator)
end | ruby | def visit_path(*path, &operator)
visitor = ReferencePathVisitor.new(self.class, path)
visitor.visit(self, &operator)
end | [
"def",
"visit_path",
"(",
"*",
"path",
",",
"&",
"operator",
")",
"visitor",
"=",
"ReferencePathVisitor",
".",
"new",
"(",
"self",
".",
"class",
",",
"path",
")",
"visitor",
".",
"visit",
"(",
"self",
",",
"operator",
")",
"end"
] | Applies the operator block to this object and each domain object in the reference path.
This method visits the transitive closure of each recursive path attribute.
@param [<Symbol>] path the attributes to visit
@yieldparam [Symbol] attribute the attribute to visit
@return the visit result
@see ReferencePathVisito... | [
"Applies",
"the",
"operator",
"block",
"to",
"this",
"object",
"and",
"each",
"domain",
"object",
"in",
"the",
"reference",
"path",
".",
"This",
"method",
"visits",
"the",
"transitive",
"closure",
"of",
"each",
"recursive",
"path",
"attribute",
"."
] | 964a274cc9d7ab74613910e8375e12ed210a434d | https://github.com/jinx/core/blob/964a274cc9d7ab74613910e8375e12ed210a434d/lib/jinx/resource.rb#L494-L497 | train |
jinx/core | lib/jinx/resource.rb | Jinx.Resource.printable_content | def printable_content(attributes=nil, &reference_printer)
attributes ||= printworthy_attributes
vh = value_hash(attributes)
vh.transform_value { |value| printable_value(value, &reference_printer) }
end | ruby | def printable_content(attributes=nil, &reference_printer)
attributes ||= printworthy_attributes
vh = value_hash(attributes)
vh.transform_value { |value| printable_value(value, &reference_printer) }
end | [
"def",
"printable_content",
"(",
"attributes",
"=",
"nil",
",",
"&",
"reference_printer",
")",
"attributes",
"||=",
"printworthy_attributes",
"vh",
"=",
"value_hash",
"(",
"attributes",
")",
"vh",
".",
"transform_value",
"{",
"|",
"value",
"|",
"printable_value",
... | Returns this domain object's attributes content as an attribute => value hash
suitable for printing.
The default attributes are this object's saved attributes. The optional
reference_printer is used to print a referenced domain object.
@param [<Symbol>, nil] attributes the attributes to print
@yield [ref] the re... | [
"Returns",
"this",
"domain",
"object",
"s",
"attributes",
"content",
"as",
"an",
"attribute",
"=",
">",
"value",
"hash",
"suitable",
"for",
"printing",
"."
] | 964a274cc9d7ab74613910e8375e12ed210a434d | https://github.com/jinx/core/blob/964a274cc9d7ab74613910e8375e12ed210a434d/lib/jinx/resource.rb#L560-L564 | train |
jinx/core | lib/jinx/resource.rb | Jinx.Resource.validate_mandatory_attributes | def validate_mandatory_attributes
invalid = missing_mandatory_attributes
unless invalid.empty? then
logger.error("Validation of #{qp} unsuccessful - missing #{invalid.join(', ')}:\n#{dump}")
raise ValidationError.new("Required attribute value missing for #{self}: #{invalid.join(', ')}")
... | ruby | def validate_mandatory_attributes
invalid = missing_mandatory_attributes
unless invalid.empty? then
logger.error("Validation of #{qp} unsuccessful - missing #{invalid.join(', ')}:\n#{dump}")
raise ValidationError.new("Required attribute value missing for #{self}: #{invalid.join(', ')}")
... | [
"def",
"validate_mandatory_attributes",
"invalid",
"=",
"missing_mandatory_attributes",
"unless",
"invalid",
".",
"empty?",
"then",
"logger",
".",
"error",
"(",
"\"Validation of #{qp} unsuccessful - missing #{invalid.join(', ')}:\\n#{dump}\"",
")",
"raise",
"ValidationError",
"."... | Validates that this domain object contains a non-nil value for each mandatory attribute.
@raise [ValidationError] if a mandatory attribute value is missing | [
"Validates",
"that",
"this",
"domain",
"object",
"contains",
"a",
"non",
"-",
"nil",
"value",
"for",
"each",
"mandatory",
"attribute",
"."
] | 964a274cc9d7ab74613910e8375e12ed210a434d | https://github.com/jinx/core/blob/964a274cc9d7ab74613910e8375e12ed210a434d/lib/jinx/resource.rb#L703-L710 | train |
jinx/core | lib/jinx/resource.rb | Jinx.Resource.validate_owner | def validate_owner
# If there is an unambigous owner, then we are done.
return unless owner.nil?
# If there is more than one owner attribute, then check that there is at most one
# unambiguous owner reference. The owner method returns nil if the owner is ambiguous.
if self.class.owner_attr... | ruby | def validate_owner
# If there is an unambigous owner, then we are done.
return unless owner.nil?
# If there is more than one owner attribute, then check that there is at most one
# unambiguous owner reference. The owner method returns nil if the owner is ambiguous.
if self.class.owner_attr... | [
"def",
"validate_owner",
"# If there is an unambigous owner, then we are done.",
"return",
"unless",
"owner",
".",
"nil?",
"# If there is more than one owner attribute, then check that there is at most one",
"# unambiguous owner reference. The owner method returns nil if the owner is ambiguous.",
... | Validates that this domain object either doesn't have an owner attribute or has a unique
effective owner.
@raise [ValidationError] if there is an owner reference attribute that is not set
@raise [ValidationError] if there is more than effective owner | [
"Validates",
"that",
"this",
"domain",
"object",
"either",
"doesn",
"t",
"have",
"an",
"owner",
"attribute",
"or",
"has",
"a",
"unique",
"effective",
"owner",
"."
] | 964a274cc9d7ab74613910e8375e12ed210a434d | https://github.com/jinx/core/blob/964a274cc9d7ab74613910e8375e12ed210a434d/lib/jinx/resource.rb#L717-L732 | train |
jinx/core | lib/jinx/resource.rb | Jinx.Resource.printable_value | def printable_value(value, &reference_printer)
Jinx::Collector.on(value) do |item|
if Resource === item then
block_given? ? yield(item) : printable_value(item) { |ref| ReferencePrinter.new(ref) }
else
item
end
end
end | ruby | def printable_value(value, &reference_printer)
Jinx::Collector.on(value) do |item|
if Resource === item then
block_given? ? yield(item) : printable_value(item) { |ref| ReferencePrinter.new(ref) }
else
item
end
end
end | [
"def",
"printable_value",
"(",
"value",
",",
"&",
"reference_printer",
")",
"Jinx",
"::",
"Collector",
".",
"on",
"(",
"value",
")",
"do",
"|",
"item",
"|",
"if",
"Resource",
"===",
"item",
"then",
"block_given?",
"?",
"yield",
"(",
"item",
")",
":",
"... | Returns a value suitable for printing. If value is a domain object, then the block provided to this method is called.
The default block creates a new ReferencePrinter on the value. | [
"Returns",
"a",
"value",
"suitable",
"for",
"printing",
".",
"If",
"value",
"is",
"a",
"domain",
"object",
"then",
"the",
"block",
"provided",
"to",
"this",
"method",
"is",
"called",
".",
"The",
"default",
"block",
"creates",
"a",
"new",
"ReferencePrinter",
... | 964a274cc9d7ab74613910e8375e12ed210a434d | https://github.com/jinx/core/blob/964a274cc9d7ab74613910e8375e12ed210a434d/lib/jinx/resource.rb#L807-L815 | train |
jinx/core | lib/jinx/resource.rb | Jinx.Resource.printworthy_attributes | def printworthy_attributes
if self.class.primary_key_attributes.all? { |pa| !!send(pa) } then
self.class.primary_key_attributes
elsif not self.class.secondary_key_attributes.empty? then
self.class.secondary_key_attributes
elsif not self.class.nondomain_java_attributes.empty? then
... | ruby | def printworthy_attributes
if self.class.primary_key_attributes.all? { |pa| !!send(pa) } then
self.class.primary_key_attributes
elsif not self.class.secondary_key_attributes.empty? then
self.class.secondary_key_attributes
elsif not self.class.nondomain_java_attributes.empty? then
... | [
"def",
"printworthy_attributes",
"if",
"self",
".",
"class",
".",
"primary_key_attributes",
".",
"all?",
"{",
"|",
"pa",
"|",
"!",
"!",
"send",
"(",
"pa",
")",
"}",
"then",
"self",
".",
"class",
".",
"primary_key_attributes",
"elsif",
"not",
"self",
".",
... | Returns an attribute => value hash which identifies the object.
If this object has a complete primary key, than the primary key attributes are returned.
Otherwise, if there are secondary key attributes, then they are returned.
Otherwise, if there are nondomain attributes, then they are returned.
Otherwise, if there... | [
"Returns",
"an",
"attribute",
"=",
">",
"value",
"hash",
"which",
"identifies",
"the",
"object",
".",
"If",
"this",
"object",
"has",
"a",
"complete",
"primary",
"key",
"than",
"the",
"primary",
"key",
"attributes",
"are",
"returned",
".",
"Otherwise",
"if",
... | 964a274cc9d7ab74613910e8375e12ed210a434d | https://github.com/jinx/core/blob/964a274cc9d7ab74613910e8375e12ed210a434d/lib/jinx/resource.rb#L824-L834 | train |
jinx/core | lib/jinx/resource.rb | Jinx.Resource.empty_value | def empty_value(attribute)
type = java_type(attribute) || return
if type.primitive? then
type.name == 'boolean' ? false : 0
else
self.class.empty_value(attribute)
end
end | ruby | def empty_value(attribute)
type = java_type(attribute) || return
if type.primitive? then
type.name == 'boolean' ? false : 0
else
self.class.empty_value(attribute)
end
end | [
"def",
"empty_value",
"(",
"attribute",
")",
"type",
"=",
"java_type",
"(",
"attribute",
")",
"||",
"return",
"if",
"type",
".",
"primitive?",
"then",
"type",
".",
"name",
"==",
"'boolean'",
"?",
"false",
":",
"0",
"else",
"self",
".",
"class",
".",
"e... | Returns 0 if attribute is a Java primitive number,
+false+ if attribute is a Java primitive boolean,
an empty collectin if the Java attribute is a collection,
nil otherwise. | [
"Returns",
"0",
"if",
"attribute",
"is",
"a",
"Java",
"primitive",
"number",
"+",
"false",
"+",
"if",
"attribute",
"is",
"a",
"Java",
"primitive",
"boolean",
"an",
"empty",
"collectin",
"if",
"the",
"Java",
"attribute",
"is",
"a",
"collection",
"nil",
"oth... | 964a274cc9d7ab74613910e8375e12ed210a434d | https://github.com/jinx/core/blob/964a274cc9d7ab74613910e8375e12ed210a434d/lib/jinx/resource.rb#L872-L879 | train |
jinx/core | lib/jinx/resource.rb | Jinx.Resource.java_type | def java_type(attribute)
prop = self.class.property(attribute)
prop.property_descriptor.attribute_type if JavaProperty === prop
end | ruby | def java_type(attribute)
prop = self.class.property(attribute)
prop.property_descriptor.attribute_type if JavaProperty === prop
end | [
"def",
"java_type",
"(",
"attribute",
")",
"prop",
"=",
"self",
".",
"class",
".",
"property",
"(",
"attribute",
")",
"prop",
".",
"property_descriptor",
".",
"attribute_type",
"if",
"JavaProperty",
"===",
"prop",
"end"
] | Returns the Java type of the given attribute, or nil if attribute is not a Java property attribute. | [
"Returns",
"the",
"Java",
"type",
"of",
"the",
"given",
"attribute",
"or",
"nil",
"if",
"attribute",
"is",
"not",
"a",
"Java",
"property",
"attribute",
"."
] | 964a274cc9d7ab74613910e8375e12ed210a434d | https://github.com/jinx/core/blob/964a274cc9d7ab74613910e8375e12ed210a434d/lib/jinx/resource.rb#L882-L885 | train |
jinx/core | lib/jinx/resource.rb | Jinx.Resource.match_unique_object_with_attributes | def match_unique_object_with_attributes(others, attributes)
vh = value_hash(attributes)
return if vh.empty? or vh.size < attributes.size
matches = others.select do |other|
self.class == other.class and
vh.all? { |pa, v| other.matches_attribute_value?(pa, v) }
end
matches.... | ruby | def match_unique_object_with_attributes(others, attributes)
vh = value_hash(attributes)
return if vh.empty? or vh.size < attributes.size
matches = others.select do |other|
self.class == other.class and
vh.all? { |pa, v| other.matches_attribute_value?(pa, v) }
end
matches.... | [
"def",
"match_unique_object_with_attributes",
"(",
"others",
",",
"attributes",
")",
"vh",
"=",
"value_hash",
"(",
"attributes",
")",
"return",
"if",
"vh",
".",
"empty?",
"or",
"vh",
".",
"size",
"<",
"attributes",
".",
"size",
"matches",
"=",
"others",
".",... | Returns the object in others which uniquely matches this domain object on the given attributes,
or nil if there is no unique match. This method returns nil if any attributes value is nil. | [
"Returns",
"the",
"object",
"in",
"others",
"which",
"uniquely",
"matches",
"this",
"domain",
"object",
"on",
"the",
"given",
"attributes",
"or",
"nil",
"if",
"there",
"is",
"no",
"unique",
"match",
".",
"This",
"method",
"returns",
"nil",
"if",
"any",
"at... | 964a274cc9d7ab74613910e8375e12ed210a434d | https://github.com/jinx/core/blob/964a274cc9d7ab74613910e8375e12ed210a434d/lib/jinx/resource.rb#L930-L938 | train |
jinx/core | lib/jinx/resource.rb | Jinx.Resource.non_id_search_attribute_values | def non_id_search_attribute_values
# if there is a secondary key, then search on those attributes.
# otherwise, search on all attributes.
key_props = self.class.secondary_key_attributes
pas = key_props.empty? ? self.class.nondomain_java_attributes : key_props
# associate the values
a... | ruby | def non_id_search_attribute_values
# if there is a secondary key, then search on those attributes.
# otherwise, search on all attributes.
key_props = self.class.secondary_key_attributes
pas = key_props.empty? ? self.class.nondomain_java_attributes : key_props
# associate the values
a... | [
"def",
"non_id_search_attribute_values",
"# if there is a secondary key, then search on those attributes.",
"# otherwise, search on all attributes.",
"key_props",
"=",
"self",
".",
"class",
".",
"secondary_key_attributes",
"pas",
"=",
"key_props",
".",
"empty?",
"?",
"self",
".",... | Returns the attribute => value hash to use for matching this domain object.
@see #search_attribute_values the method specification | [
"Returns",
"the",
"attribute",
"=",
">",
"value",
"hash",
"to",
"use",
"for",
"matching",
"this",
"domain",
"object",
"."
] | 964a274cc9d7ab74613910e8375e12ed210a434d | https://github.com/jinx/core/blob/964a274cc9d7ab74613910e8375e12ed210a434d/lib/jinx/resource.rb#L953-L962 | train |
barkerest/incline | lib/incline/extensions/action_controller_base.rb | Incline::Extensions.ActionControllerBase.render_csv | def render_csv(filename = nil, view_name = nil)
filename ||= params[:action]
view_name ||= params[:action]
filename.downcase!
filename += '.csv' unless filename[-4..-1] == '.csv'
headers['Content-Type'] = 'text/csv'
headers['Content-Disposition'] = "attachment; filename=\"#{filenam... | ruby | def render_csv(filename = nil, view_name = nil)
filename ||= params[:action]
view_name ||= params[:action]
filename.downcase!
filename += '.csv' unless filename[-4..-1] == '.csv'
headers['Content-Type'] = 'text/csv'
headers['Content-Disposition'] = "attachment; filename=\"#{filenam... | [
"def",
"render_csv",
"(",
"filename",
"=",
"nil",
",",
"view_name",
"=",
"nil",
")",
"filename",
"||=",
"params",
"[",
":action",
"]",
"view_name",
"||=",
"params",
"[",
":action",
"]",
"filename",
".",
"downcase!",
"filename",
"+=",
"'.csv'",
"unless",
"f... | Renders the view as a CSV file.
Set the +filename+ you would like to provide to the client, or leave it nil to use the action name.
Set the +view_name+ you would like to render, or leave it nil to use the action name. | [
"Renders",
"the",
"view",
"as",
"a",
"CSV",
"file",
"."
] | 1ff08db7aa8ab7f86b223268b700bc67d15bb8aa | https://github.com/barkerest/incline/blob/1ff08db7aa8ab7f86b223268b700bc67d15bb8aa/lib/incline/extensions/action_controller_base.rb#L213-L224 | train |
barkerest/incline | lib/incline/extensions/action_controller_base.rb | Incline::Extensions.ActionControllerBase.authorize! | def authorize!(*accepted_groups) #:doc:
begin
# an authenticated user must exist.
unless logged_in?
store_location
if (auth_url = ::Incline::UserManager.begin_external_authentication(request))
::Incline::Log.debug 'Redirecting for external authentication.'
... | ruby | def authorize!(*accepted_groups) #:doc:
begin
# an authenticated user must exist.
unless logged_in?
store_location
if (auth_url = ::Incline::UserManager.begin_external_authentication(request))
::Incline::Log.debug 'Redirecting for external authentication.'
... | [
"def",
"authorize!",
"(",
"*",
"accepted_groups",
")",
"#:doc:",
"begin",
"# an authenticated user must exist.",
"unless",
"logged_in?",
"store_location",
"if",
"(",
"auth_url",
"=",
"::",
"Incline",
"::",
"UserManager",
".",
"begin_external_authentication",
"(",
"reque... | Authorizes access for the action.
* With no arguments, this will validate that a user is currently logged in, but does not check their permission.
* With an argument of true, this will validate that the user currently logged in is an administrator.
* With one or more strings, this will validate that the user curren... | [
"Authorizes",
"access",
"for",
"the",
"action",
"."
] | 1ff08db7aa8ab7f86b223268b700bc67d15bb8aa | https://github.com/barkerest/incline/blob/1ff08db7aa8ab7f86b223268b700bc67d15bb8aa/lib/incline/extensions/action_controller_base.rb#L282-L339 | train |
barkerest/incline | lib/incline/extensions/action_controller_base.rb | Incline::Extensions.ActionControllerBase.valid_user? | def valid_user? #:doc:
if require_admin_for_request?
authorize! true
elsif require_anon_for_request?
if logged_in?
flash[:warning] = 'The specified action cannot be performed while logged in.'
redirect_to incline.user_path(current_user)
end
elsif allow_anon_... | ruby | def valid_user? #:doc:
if require_admin_for_request?
authorize! true
elsif require_anon_for_request?
if logged_in?
flash[:warning] = 'The specified action cannot be performed while logged in.'
redirect_to incline.user_path(current_user)
end
elsif allow_anon_... | [
"def",
"valid_user?",
"#:doc:",
"if",
"require_admin_for_request?",
"authorize!",
"true",
"elsif",
"require_anon_for_request?",
"if",
"logged_in?",
"flash",
"[",
":warning",
"]",
"=",
"'The specified action cannot be performed while logged in.'",
"redirect_to",
"incline",
".",
... | Validates that the current user is authorized for the current request.
This method is called for every action except the :api action.
For the :api action, this method will not be called until the actual requested action is performed.
One of four scenarios are possible:
1. If the +require_admin+ method applies to... | [
"Validates",
"that",
"the",
"current",
"user",
"is",
"authorized",
"for",
"the",
"current",
"request",
"."
] | 1ff08db7aa8ab7f86b223268b700bc67d15bb8aa | https://github.com/barkerest/incline/blob/1ff08db7aa8ab7f86b223268b700bc67d15bb8aa/lib/incline/extensions/action_controller_base.rb#L426-L444 | train |
masaomoc/aws-profile_parser | lib/aws/profile_parser.rb | AWS.ProfileParser.get | def get(profile='default')
raise 'Config File does not exist' unless File.exists?(@file)
@credentials = parse if @credentials.nil?
raise 'The profile is not specified in the config file' unless @credentials.has_key?(profile)
@credentials[profile]
end | ruby | def get(profile='default')
raise 'Config File does not exist' unless File.exists?(@file)
@credentials = parse if @credentials.nil?
raise 'The profile is not specified in the config file' unless @credentials.has_key?(profile)
@credentials[profile]
end | [
"def",
"get",
"(",
"profile",
"=",
"'default'",
")",
"raise",
"'Config File does not exist'",
"unless",
"File",
".",
"exists?",
"(",
"@file",
")",
"@credentials",
"=",
"parse",
"if",
"@credentials",
".",
"nil?",
"raise",
"'The profile is not specified in the config fi... | returns hash of AWS credential | [
"returns",
"hash",
"of",
"AWS",
"credential"
] | b45725b5497864e2f5de2457ae6b7ed0dabe94fa | https://github.com/masaomoc/aws-profile_parser/blob/b45725b5497864e2f5de2457ae6b7ed0dabe94fa/lib/aws/profile_parser.rb#L12-L19 | train |
detroit/detroit-gem | lib/detroit-gem.rb | Detroit.Gem.build | def build
trace "gem build #{gemspec}"
spec = load_gemspec
package = ::Gem::Package.build(spec)
mkdir_p(pkgdir) unless File.directory?(pkgdir)
mv(package, pkgdir)
end | ruby | def build
trace "gem build #{gemspec}"
spec = load_gemspec
package = ::Gem::Package.build(spec)
mkdir_p(pkgdir) unless File.directory?(pkgdir)
mv(package, pkgdir)
end | [
"def",
"build",
"trace",
"\"gem build #{gemspec}\"",
"spec",
"=",
"load_gemspec",
"package",
"=",
"::",
"Gem",
"::",
"Package",
".",
"build",
"(",
"spec",
")",
"mkdir_p",
"(",
"pkgdir",
")",
"unless",
"File",
".",
"directory?",
"(",
"pkgdir",
")",
"mv",
"(... | Create a gem package. | [
"Create",
"a",
"gem",
"package",
"."
] | 3a018942038c430f3fdc73ed5c40783c8f0a7c8b | https://github.com/detroit/detroit-gem/blob/3a018942038c430f3fdc73ed5c40783c8f0a7c8b/lib/detroit-gem.rb#L72-L78 | train |
detroit/detroit-gem | lib/detroit-gem.rb | Detroit.Gem.create_gemspec | def create_gemspec(file=nil)
file = gemspec if !file
#require 'gemdo/gemspec'
yaml = project.to_gemspec.to_yaml
File.open(file, 'w') do |f|
f << yaml
end
status File.basename(file) + " updated."
return file
end | ruby | def create_gemspec(file=nil)
file = gemspec if !file
#require 'gemdo/gemspec'
yaml = project.to_gemspec.to_yaml
File.open(file, 'w') do |f|
f << yaml
end
status File.basename(file) + " updated."
return file
end | [
"def",
"create_gemspec",
"(",
"file",
"=",
"nil",
")",
"file",
"=",
"gemspec",
"if",
"!",
"file",
"#require 'gemdo/gemspec'",
"yaml",
"=",
"project",
".",
"to_gemspec",
".",
"to_yaml",
"File",
".",
"open",
"(",
"file",
",",
"'w'",
")",
"do",
"|",
"f",
... | Create a gemspec file from project metadata. | [
"Create",
"a",
"gemspec",
"file",
"from",
"project",
"metadata",
"."
] | 3a018942038c430f3fdc73ed5c40783c8f0a7c8b | https://github.com/detroit/detroit-gem/blob/3a018942038c430f3fdc73ed5c40783c8f0a7c8b/lib/detroit-gem.rb#L171-L180 | train |
detroit/detroit-gem | lib/detroit-gem.rb | Detroit.Gem.lookup_gemspec | def lookup_gemspec
dot_gemspec = (project.root + '.gemspec').to_s
if File.exist?(dot_gemspec)
dot_gemspec.to_s
else
project.metadata.name + '.gemspec'
end
end | ruby | def lookup_gemspec
dot_gemspec = (project.root + '.gemspec').to_s
if File.exist?(dot_gemspec)
dot_gemspec.to_s
else
project.metadata.name + '.gemspec'
end
end | [
"def",
"lookup_gemspec",
"dot_gemspec",
"=",
"(",
"project",
".",
"root",
"+",
"'.gemspec'",
")",
".",
"to_s",
"if",
"File",
".",
"exist?",
"(",
"dot_gemspec",
")",
"dot_gemspec",
".",
"to_s",
"else",
"project",
".",
"metadata",
".",
"name",
"+",
"'.gemspe... | Lookup gemspec file. If not found returns default path.
Returns String of file path. | [
"Lookup",
"gemspec",
"file",
".",
"If",
"not",
"found",
"returns",
"default",
"path",
"."
] | 3a018942038c430f3fdc73ed5c40783c8f0a7c8b | https://github.com/detroit/detroit-gem/blob/3a018942038c430f3fdc73ed5c40783c8f0a7c8b/lib/detroit-gem.rb#L185-L192 | train |
detroit/detroit-gem | lib/detroit-gem.rb | Detroit.Gem.load_gemspec | def load_gemspec
file = gemspec
if yaml?(file)
::Gem::Specification.from_yaml(File.new(file))
else
::Gem::Specification.load(file)
end
end | ruby | def load_gemspec
file = gemspec
if yaml?(file)
::Gem::Specification.from_yaml(File.new(file))
else
::Gem::Specification.load(file)
end
end | [
"def",
"load_gemspec",
"file",
"=",
"gemspec",
"if",
"yaml?",
"(",
"file",
")",
"::",
"Gem",
"::",
"Specification",
".",
"from_yaml",
"(",
"File",
".",
"new",
"(",
"file",
")",
")",
"else",
"::",
"Gem",
"::",
"Specification",
".",
"load",
"(",
"file",
... | Load gemspec file.
Returns a ::Gem::Specification. | [
"Load",
"gemspec",
"file",
"."
] | 3a018942038c430f3fdc73ed5c40783c8f0a7c8b | https://github.com/detroit/detroit-gem/blob/3a018942038c430f3fdc73ed5c40783c8f0a7c8b/lib/detroit-gem.rb#L197-L204 | train |
detroit/detroit-gem | lib/detroit-gem.rb | Detroit.Gem.yaml? | def yaml?(file)
line = open(file) { |f| line = f.gets }
line.index "!ruby/object:Gem::Specification"
end | ruby | def yaml?(file)
line = open(file) { |f| line = f.gets }
line.index "!ruby/object:Gem::Specification"
end | [
"def",
"yaml?",
"(",
"file",
")",
"line",
"=",
"open",
"(",
"file",
")",
"{",
"|",
"f",
"|",
"line",
"=",
"f",
".",
"gets",
"}",
"line",
".",
"index",
"\"!ruby/object:Gem::Specification\"",
"end"
] | If the gemspec a YAML gemspec? | [
"If",
"the",
"gemspec",
"a",
"YAML",
"gemspec?"
] | 3a018942038c430f3fdc73ed5c40783c8f0a7c8b | https://github.com/detroit/detroit-gem/blob/3a018942038c430f3fdc73ed5c40783c8f0a7c8b/lib/detroit-gem.rb#L207-L210 | train |
Thermatix/ruta | lib/ruta/handler.rb | Ruta.Handlers.default | def default
handler_name = @handler_name
proc {
comp = @context.elements[handler_name][:content]
if comp.kind_of?(Proc)
comp.call
else
Context.wipe handler_name
Context.render comp, handler_name
end
}
end | ruby | def default
handler_name = @handler_name
proc {
comp = @context.elements[handler_name][:content]
if comp.kind_of?(Proc)
comp.call
else
Context.wipe handler_name
Context.render comp, handler_name
end
}
end | [
"def",
"default",
"handler_name",
"=",
"@handler_name",
"proc",
"{",
"comp",
"=",
"@context",
".",
"elements",
"[",
"handler_name",
"]",
"[",
":content",
"]",
"if",
"comp",
".",
"kind_of?",
"(",
"Proc",
")",
"comp",
".",
"call",
"else",
"Context",
".",
"... | Render the default content for this component as it is defined in the context. | [
"Render",
"the",
"default",
"content",
"for",
"this",
"component",
"as",
"it",
"is",
"defined",
"in",
"the",
"context",
"."
] | b4a6e3bc7c0c4b66c804023d638b173e3f61e157 | https://github.com/Thermatix/ruta/blob/b4a6e3bc7c0c4b66c804023d638b173e3f61e157/lib/ruta/handler.rb#L35-L46 | train |
lulibrary/aspire | lib/retry.rb | Retry.Engine.do | def do(delay: nil, exceptions: nil, handlers: nil, tries: nil, &block)
Retry.do(delay: delay || self.delay,
exceptions: exceptions || self.exceptions,
handlers: handlers || self.handlers,
tries: tries || self.tries,
&block)
end | ruby | def do(delay: nil, exceptions: nil, handlers: nil, tries: nil, &block)
Retry.do(delay: delay || self.delay,
exceptions: exceptions || self.exceptions,
handlers: handlers || self.handlers,
tries: tries || self.tries,
&block)
end | [
"def",
"do",
"(",
"delay",
":",
"nil",
",",
"exceptions",
":",
"nil",
",",
"handlers",
":",
"nil",
",",
"tries",
":",
"nil",
",",
"&",
"block",
")",
"Retry",
".",
"do",
"(",
"delay",
":",
"delay",
"||",
"self",
".",
"delay",
",",
"exceptions",
":... | Initialises a new Engine instance
@param delay [Float] the default delay before retrying
@param exceptions [Hash<Exception, Boolean>] the default retriable
exceptions
@param handlers [Hash<Exception|Symbol, Proc>] the default exception
handlers
@param tries [Integer, Proc] the default maximum number of tries ... | [
"Initialises",
"a",
"new",
"Engine",
"instance"
] | 623f481a2e79b9cb0b5feb923da438eb1ed2abfe | https://github.com/lulibrary/aspire/blob/623f481a2e79b9cb0b5feb923da438eb1ed2abfe/lib/retry.rb#L53-L59 | train |
wedesoft/multiarray | lib/multiarray/operations.rb | Hornetseye.Node.fmod_with_float | def fmod_with_float( other )
other = Node.match( other, typecode ).new other unless other.matched?
if typecode < FLOAT_ or other.typecode < FLOAT_
fmod other
else
fmod_without_float other
end
end | ruby | def fmod_with_float( other )
other = Node.match( other, typecode ).new other unless other.matched?
if typecode < FLOAT_ or other.typecode < FLOAT_
fmod other
else
fmod_without_float other
end
end | [
"def",
"fmod_with_float",
"(",
"other",
")",
"other",
"=",
"Node",
".",
"match",
"(",
"other",
",",
"typecode",
")",
".",
"new",
"other",
"unless",
"other",
".",
"matched?",
"if",
"typecode",
"<",
"FLOAT_",
"or",
"other",
".",
"typecode",
"<",
"FLOAT_",
... | Modulo operation for floating point numbers
This operation takes account of the problem that '%' does not work with
floating-point numbers in C.
@return [Node] Array with result of operation. | [
"Modulo",
"operation",
"for",
"floating",
"point",
"numbers"
] | 1ae1d98bacb4b941d6f406e44ccb184de12f83d9 | https://github.com/wedesoft/multiarray/blob/1ae1d98bacb4b941d6f406e44ccb184de12f83d9/lib/multiarray/operations.rb#L122-L129 | train |
wedesoft/multiarray | lib/multiarray/operations.rb | Hornetseye.Node.to_type | def to_type(dest)
if dimension == 0 and variables.empty?
target = typecode.to_type dest
target.new(simplify.get).simplify
else
key = "to_#{dest.to_s.downcase}"
Hornetseye::ElementWise( proc { |x| x.to_type dest }, key,
proc { |t| t.to_type des... | ruby | def to_type(dest)
if dimension == 0 and variables.empty?
target = typecode.to_type dest
target.new(simplify.get).simplify
else
key = "to_#{dest.to_s.downcase}"
Hornetseye::ElementWise( proc { |x| x.to_type dest }, key,
proc { |t| t.to_type des... | [
"def",
"to_type",
"(",
"dest",
")",
"if",
"dimension",
"==",
"0",
"and",
"variables",
".",
"empty?",
"target",
"=",
"typecode",
".",
"to_type",
"dest",
"target",
".",
"new",
"(",
"simplify",
".",
"get",
")",
".",
"simplify",
"else",
"key",
"=",
"\"to_#... | Convert array elements to different element type
@param [Class] dest Element type to convert to.
@return [Node] Array based on the different element type. | [
"Convert",
"array",
"elements",
"to",
"different",
"element",
"type"
] | 1ae1d98bacb4b941d6f406e44ccb184de12f83d9 | https://github.com/wedesoft/multiarray/blob/1ae1d98bacb4b941d6f406e44ccb184de12f83d9/lib/multiarray/operations.rb#L138-L147 | train |
wedesoft/multiarray | lib/multiarray/operations.rb | Hornetseye.Node.to_type_with_rgb | def to_type_with_rgb(dest)
if typecode < RGB_
if dest < FLOAT_
lazy { r * 0.299 + g * 0.587 + b * 0.114 }.to_type dest
elsif dest < INT_
lazy { (r * 0.299 + g * 0.587 + b * 0.114).round }.to_type dest
else
to_type_without_rgb dest
end
else
... | ruby | def to_type_with_rgb(dest)
if typecode < RGB_
if dest < FLOAT_
lazy { r * 0.299 + g * 0.587 + b * 0.114 }.to_type dest
elsif dest < INT_
lazy { (r * 0.299 + g * 0.587 + b * 0.114).round }.to_type dest
else
to_type_without_rgb dest
end
else
... | [
"def",
"to_type_with_rgb",
"(",
"dest",
")",
"if",
"typecode",
"<",
"RGB_",
"if",
"dest",
"<",
"FLOAT_",
"lazy",
"{",
"r",
"*",
"0.299",
"+",
"g",
"*",
"0.587",
"+",
"b",
"*",
"0.114",
"}",
".",
"to_type",
"dest",
"elsif",
"dest",
"<",
"INT_",
"laz... | Convert RGB array to scalar array
This operation is a special case handling colour to greyscale conversion.
@param [Class] dest Element type to convert to.
@return [Node] Array based on the different element type. | [
"Convert",
"RGB",
"array",
"to",
"scalar",
"array"
] | 1ae1d98bacb4b941d6f406e44ccb184de12f83d9 | https://github.com/wedesoft/multiarray/blob/1ae1d98bacb4b941d6f406e44ccb184de12f83d9/lib/multiarray/operations.rb#L156-L168 | train |
wedesoft/multiarray | lib/multiarray/operations.rb | Hornetseye.Node.reshape | def reshape(*ret_shape)
target_size = ret_shape.inject 1, :*
if target_size != size
raise "Target is of size #{target_size} but should be of size #{size}"
end
Hornetseye::MultiArray(typecode, ret_shape.size).
new *(ret_shape + [:memory => memorise.memory])
end | ruby | def reshape(*ret_shape)
target_size = ret_shape.inject 1, :*
if target_size != size
raise "Target is of size #{target_size} but should be of size #{size}"
end
Hornetseye::MultiArray(typecode, ret_shape.size).
new *(ret_shape + [:memory => memorise.memory])
end | [
"def",
"reshape",
"(",
"*",
"ret_shape",
")",
"target_size",
"=",
"ret_shape",
".",
"inject",
"1",
",",
":*",
"if",
"target_size",
"!=",
"size",
"raise",
"\"Target is of size #{target_size} but should be of size #{size}\"",
"end",
"Hornetseye",
"::",
"MultiArray",
"("... | Get array with same elements but different shape
The method returns an array with the same elements but with a different shape.
The desired shape must have the same number of elements.
@param [Array<Integer>] ret_shape Desired shape of return value
@return [Node] Array with desired shape. | [
"Get",
"array",
"with",
"same",
"elements",
"but",
"different",
"shape"
] | 1ae1d98bacb4b941d6f406e44ccb184de12f83d9 | https://github.com/wedesoft/multiarray/blob/1ae1d98bacb4b941d6f406e44ccb184de12f83d9/lib/multiarray/operations.rb#L197-L204 | train |
wedesoft/multiarray | lib/multiarray/operations.rb | Hornetseye.Node.conditional | def conditional(a, b)
a = Node.match(a, b.matched? ? b : nil).new a unless a.matched?
b = Node.match(b, a.matched? ? a : nil).new b unless b.matched?
if dimension == 0 and variables.empty? and
a.dimension == 0 and a.variables.empty? and
b.dimension == 0 and b.variables.empty?
t... | ruby | def conditional(a, b)
a = Node.match(a, b.matched? ? b : nil).new a unless a.matched?
b = Node.match(b, a.matched? ? a : nil).new b unless b.matched?
if dimension == 0 and variables.empty? and
a.dimension == 0 and a.variables.empty? and
b.dimension == 0 and b.variables.empty?
t... | [
"def",
"conditional",
"(",
"a",
",",
"b",
")",
"a",
"=",
"Node",
".",
"match",
"(",
"a",
",",
"b",
".",
"matched?",
"?",
"b",
":",
"nil",
")",
".",
"new",
"a",
"unless",
"a",
".",
"matched?",
"b",
"=",
"Node",
".",
"match",
"(",
"b",
",",
"... | Element-wise conditional selection of values
@param [Node] a First array of values.
@param [Node] b Second array of values.
@return [Node] Array with selected values. | [
"Element",
"-",
"wise",
"conditional",
"selection",
"of",
"values"
] | 1ae1d98bacb4b941d6f406e44ccb184de12f83d9 | https://github.com/wedesoft/multiarray/blob/1ae1d98bacb4b941d6f406e44ccb184de12f83d9/lib/multiarray/operations.rb#L212-L226 | train |
wedesoft/multiarray | lib/multiarray/operations.rb | Hornetseye.Node.transpose | def transpose(*order)
if (0 ... dimension).to_a != order.sort
raise 'Each array index must be specified exactly once!'
end
term = self
variables = shape.reverse.collect do |i|
var = Variable.new Hornetseye::INDEX( i )
term = term.element var
var
end.reverse
... | ruby | def transpose(*order)
if (0 ... dimension).to_a != order.sort
raise 'Each array index must be specified exactly once!'
end
term = self
variables = shape.reverse.collect do |i|
var = Variable.new Hornetseye::INDEX( i )
term = term.element var
var
end.reverse
... | [
"def",
"transpose",
"(",
"*",
"order",
")",
"if",
"(",
"0",
"...",
"dimension",
")",
".",
"to_a",
"!=",
"order",
".",
"sort",
"raise",
"'Each array index must be specified exactly once!'",
"end",
"term",
"=",
"self",
"variables",
"=",
"shape",
".",
"reverse",
... | Element-wise comparison of values
@param [Node] other Array with values to compare with.
@return [Node] Array with results.
Lazy transpose of array
Lazily compute transpose by swapping indices according to the specified
order.
@param [Array<Integer>] order New order of indices.
@return [Node] Returns the tr... | [
"Element",
"-",
"wise",
"comparison",
"of",
"values"
] | 1ae1d98bacb4b941d6f406e44ccb184de12f83d9 | https://github.com/wedesoft/multiarray/blob/1ae1d98bacb4b941d6f406e44ccb184de12f83d9/lib/multiarray/operations.rb#L275-L287 | train |
wedesoft/multiarray | lib/multiarray/operations.rb | Hornetseye.Node.unroll | def unroll( n = 1 )
if n < 0
roll -n
else
order = ( 0 ... dimension ).to_a
n.times { order = [ order.last ] + order[ 0 ... -1 ] }
transpose *order
end
end | ruby | def unroll( n = 1 )
if n < 0
roll -n
else
order = ( 0 ... dimension ).to_a
n.times { order = [ order.last ] + order[ 0 ... -1 ] }
transpose *order
end
end | [
"def",
"unroll",
"(",
"n",
"=",
"1",
")",
"if",
"n",
"<",
"0",
"roll",
"-",
"n",
"else",
"order",
"=",
"(",
"0",
"...",
"dimension",
")",
".",
"to_a",
"n",
".",
"times",
"{",
"order",
"=",
"[",
"order",
".",
"last",
"]",
"+",
"order",
"[",
... | Reverse-cycle indices of array
@param [Integer] n Number of times to cycle back indices of array.
@return [Node] Resulting array expression with different order of indices. | [
"Reverse",
"-",
"cycle",
"indices",
"of",
"array"
] | 1ae1d98bacb4b941d6f406e44ccb184de12f83d9 | https://github.com/wedesoft/multiarray/blob/1ae1d98bacb4b941d6f406e44ccb184de12f83d9/lib/multiarray/operations.rb#L309-L317 | train |
wedesoft/multiarray | lib/multiarray/operations.rb | Hornetseye.Node.collect | def collect(&action)
var = Variable.new typecode
block = action.call var
conversion = proc { |t| t.to_type action.call(Variable.new(t.typecode)).typecode }
Hornetseye::ElementWise( action, block.to_s, conversion ).new( self ).force
end | ruby | def collect(&action)
var = Variable.new typecode
block = action.call var
conversion = proc { |t| t.to_type action.call(Variable.new(t.typecode)).typecode }
Hornetseye::ElementWise( action, block.to_s, conversion ).new( self ).force
end | [
"def",
"collect",
"(",
"&",
"action",
")",
"var",
"=",
"Variable",
".",
"new",
"typecode",
"block",
"=",
"action",
".",
"call",
"var",
"conversion",
"=",
"proc",
"{",
"|",
"t",
"|",
"t",
".",
"to_type",
"action",
".",
"call",
"(",
"Variable",
".",
... | Perform element-wise operation on array
@param [Proc] action Operation(s) to perform on elements.
@return [Node] The resulting array. | [
"Perform",
"element",
"-",
"wise",
"operation",
"on",
"array"
] | 1ae1d98bacb4b941d6f406e44ccb184de12f83d9 | https://github.com/wedesoft/multiarray/blob/1ae1d98bacb4b941d6f406e44ccb184de12f83d9/lib/multiarray/operations.rb#L324-L329 | train |
wedesoft/multiarray | lib/multiarray/operations.rb | Hornetseye.Node.inject | def inject(*args, &action)
options = args.last.is_a?(Hash) ? args.pop : {}
unless action or options[:block]
unless [1, 2].member? args.size
raise "Inject expected 1 or 2 arguments but got #{args.size}"
end
initial, symbol = args[-2], args[-1]
action = proc { |a,b| ... | ruby | def inject(*args, &action)
options = args.last.is_a?(Hash) ? args.pop : {}
unless action or options[:block]
unless [1, 2].member? args.size
raise "Inject expected 1 or 2 arguments but got #{args.size}"
end
initial, symbol = args[-2], args[-1]
action = proc { |a,b| ... | [
"def",
"inject",
"(",
"*",
"args",
",",
"&",
"action",
")",
"options",
"=",
"args",
".",
"last",
".",
"is_a?",
"(",
"Hash",
")",
"?",
"args",
".",
"pop",
":",
"{",
"}",
"unless",
"action",
"or",
"options",
"[",
":block",
"]",
"unless",
"[",
"1",
... | Perform cummulative operation on array
@overload inject(initial = nil, options = {}, &action)
@param [Object] initial Initial value for cummulative operation.
@option options [Variable] :var1 First variable defining operation.
@option options [Variable] :var1 Second variable defining operation.
@option op... | [
"Perform",
"cummulative",
"operation",
"on",
"array"
] | 1ae1d98bacb4b941d6f406e44ccb184de12f83d9 | https://github.com/wedesoft/multiarray/blob/1ae1d98bacb4b941d6f406e44ccb184de12f83d9/lib/multiarray/operations.rb#L351-L388 | train |
wedesoft/multiarray | lib/multiarray/operations.rb | Hornetseye.Node.range | def range( initial = nil )
min( initial ? initial.min : nil ) .. max( initial ? initial.max : nil )
end | ruby | def range( initial = nil )
min( initial ? initial.min : nil ) .. max( initial ? initial.max : nil )
end | [
"def",
"range",
"(",
"initial",
"=",
"nil",
")",
"min",
"(",
"initial",
"?",
"initial",
".",
"min",
":",
"nil",
")",
"..",
"max",
"(",
"initial",
"?",
"initial",
".",
"max",
":",
"nil",
")",
"end"
] | Find range of values of array
@return [Object] Range of values of array. | [
"Find",
"range",
"of",
"values",
"of",
"array"
] | 1ae1d98bacb4b941d6f406e44ccb184de12f83d9 | https://github.com/wedesoft/multiarray/blob/1ae1d98bacb4b941d6f406e44ccb184de12f83d9/lib/multiarray/operations.rb#L461-L463 | train |
wedesoft/multiarray | lib/multiarray/operations.rb | Hornetseye.Node.normalise | def normalise( range = 0 .. 0xFF )
if range.exclude_end?
raise "Normalisation does not support ranges with end value " +
"excluded (such as #{range})"
end
lower, upper = min, max
if lower.is_a? RGB or upper.is_a? RGB
current = [ lower.r, lower.g, lower.b ].min ..
... | ruby | def normalise( range = 0 .. 0xFF )
if range.exclude_end?
raise "Normalisation does not support ranges with end value " +
"excluded (such as #{range})"
end
lower, upper = min, max
if lower.is_a? RGB or upper.is_a? RGB
current = [ lower.r, lower.g, lower.b ].min ..
... | [
"def",
"normalise",
"(",
"range",
"=",
"0",
"..",
"0xFF",
")",
"if",
"range",
".",
"exclude_end?",
"raise",
"\"Normalisation does not support ranges with end value \"",
"+",
"\"excluded (such as #{range})\"",
"end",
"lower",
",",
"upper",
"=",
"min",
",",
"max",
"if... | Check values against boundaries
@return [Node] Boolean array with result.
Normalise values of array
@param [Range] range Target range of normalisation.
@return [Node] Array with normalised values. | [
"Check",
"values",
"against",
"boundaries"
] | 1ae1d98bacb4b941d6f406e44ccb184de12f83d9 | https://github.com/wedesoft/multiarray/blob/1ae1d98bacb4b941d6f406e44ccb184de12f83d9/lib/multiarray/operations.rb#L477-L496 | train |
wedesoft/multiarray | lib/multiarray/operations.rb | Hornetseye.Node.clip | def clip( range = 0 .. 0xFF )
if range.exclude_end?
raise "Clipping does not support ranges with end value " +
"excluded (such as #{range})"
end
collect { |x| x.major( range.begin ).minor range.end }
end | ruby | def clip( range = 0 .. 0xFF )
if range.exclude_end?
raise "Clipping does not support ranges with end value " +
"excluded (such as #{range})"
end
collect { |x| x.major( range.begin ).minor range.end }
end | [
"def",
"clip",
"(",
"range",
"=",
"0",
"..",
"0xFF",
")",
"if",
"range",
".",
"exclude_end?",
"raise",
"\"Clipping does not support ranges with end value \"",
"+",
"\"excluded (such as #{range})\"",
"end",
"collect",
"{",
"|",
"x",
"|",
"x",
".",
"major",
"(",
"... | Clip values to specified range
@param [Range] range Allowed range of values.
@return [Node] Array with clipped values. | [
"Clip",
"values",
"to",
"specified",
"range"
] | 1ae1d98bacb4b941d6f406e44ccb184de12f83d9 | https://github.com/wedesoft/multiarray/blob/1ae1d98bacb4b941d6f406e44ccb184de12f83d9/lib/multiarray/operations.rb#L503-L509 | train |
wedesoft/multiarray | lib/multiarray/operations.rb | Hornetseye.Node.stretch | def stretch(from = 0 .. 0xFF, to = 0 .. 0xFF)
if from.exclude_end?
raise "Stretching does not support ranges with end value " +
"excluded (such as #{from})"
end
if to.exclude_end?
raise "Stretching does not support ranges with end value " +
"excluded (such a... | ruby | def stretch(from = 0 .. 0xFF, to = 0 .. 0xFF)
if from.exclude_end?
raise "Stretching does not support ranges with end value " +
"excluded (such as #{from})"
end
if to.exclude_end?
raise "Stretching does not support ranges with end value " +
"excluded (such a... | [
"def",
"stretch",
"(",
"from",
"=",
"0",
"..",
"0xFF",
",",
"to",
"=",
"0",
"..",
"0xFF",
")",
"if",
"from",
".",
"exclude_end?",
"raise",
"\"Stretching does not support ranges with end value \"",
"+",
"\"excluded (such as #{from})\"",
"end",
"if",
"to",
".",
"e... | Stretch values from one range to another
@param [Range] from Target range of values.
@param [Range] to Source range of values.
@return [Node] Array with stretched values. | [
"Stretch",
"values",
"from",
"one",
"range",
"to",
"another"
] | 1ae1d98bacb4b941d6f406e44ccb184de12f83d9 | https://github.com/wedesoft/multiarray/blob/1ae1d98bacb4b941d6f406e44ccb184de12f83d9/lib/multiarray/operations.rb#L517-L532 | train |
wedesoft/multiarray | lib/multiarray/operations.rb | Hornetseye.Node.diagonal | def diagonal( initial = nil, options = {} )
if dimension == 0
demand
else
if initial
initial = Node.match( initial ).new initial unless initial.matched?
initial_typecode = initial.typecode
else
initial_typecode = typecode
end
index0 = Var... | ruby | def diagonal( initial = nil, options = {} )
if dimension == 0
demand
else
if initial
initial = Node.match( initial ).new initial unless initial.matched?
initial_typecode = initial.typecode
else
initial_typecode = typecode
end
index0 = Var... | [
"def",
"diagonal",
"(",
"initial",
"=",
"nil",
",",
"options",
"=",
"{",
"}",
")",
"if",
"dimension",
"==",
"0",
"demand",
"else",
"if",
"initial",
"initial",
"=",
"Node",
".",
"match",
"(",
"initial",
")",
".",
"new",
"initial",
"unless",
"initial",
... | Apply accumulative operation over elements diagonally
This method is used internally to implement convolutions.
@param [Object,Node] initial Initial value.
@option options [Variable] :var1 First variable defining operation.
@option options [Variable] :var2 Second variable defining operation.
@option options [Var... | [
"Apply",
"accumulative",
"operation",
"over",
"elements",
"diagonally"
] | 1ae1d98bacb4b941d6f406e44ccb184de12f83d9 | https://github.com/wedesoft/multiarray/blob/1ae1d98bacb4b941d6f406e44ccb184de12f83d9/lib/multiarray/operations.rb#L560-L583 | train |
wedesoft/multiarray | lib/multiarray/operations.rb | Hornetseye.Node.table | def table( filter, &action )
filter = Node.match( filter, typecode ).new filter unless filter.matched?
if filter.dimension > dimension
raise "Filter has #{filter.dimension} dimension(s) but should " +
"not have more than #{dimension}"
end
filter = Hornetseye::lazy( 1 ) { fi... | ruby | def table( filter, &action )
filter = Node.match( filter, typecode ).new filter unless filter.matched?
if filter.dimension > dimension
raise "Filter has #{filter.dimension} dimension(s) but should " +
"not have more than #{dimension}"
end
filter = Hornetseye::lazy( 1 ) { fi... | [
"def",
"table",
"(",
"filter",
",",
"&",
"action",
")",
"filter",
"=",
"Node",
".",
"match",
"(",
"filter",
",",
"typecode",
")",
".",
"new",
"filter",
"unless",
"filter",
".",
"matched?",
"if",
"filter",
".",
"dimension",
">",
"dimension",
"raise",
"\... | Compute table from two arrays
Used internally to implement convolutions and other operations.
@param [Node] filter Filter to form table with.
@param [Proc] action Operation to make table for.
@return [Node] Result of operation.
@see #convolve
@private | [
"Compute",
"table",
"from",
"two",
"arrays"
] | 1ae1d98bacb4b941d6f406e44ccb184de12f83d9 | https://github.com/wedesoft/multiarray/blob/1ae1d98bacb4b941d6f406e44ccb184de12f83d9/lib/multiarray/operations.rb#L597-L609 | train |
wedesoft/multiarray | lib/multiarray/operations.rb | Hornetseye.Node.convolve | def convolve( filter )
filter = Node.match( filter, typecode ).new filter unless filter.matched?
array = self
(dimension - filter.dimension).times { array = array.roll }
array.table(filter) { |a,b| a * b }.diagonal { |s,x| s + x }
end | ruby | def convolve( filter )
filter = Node.match( filter, typecode ).new filter unless filter.matched?
array = self
(dimension - filter.dimension).times { array = array.roll }
array.table(filter) { |a,b| a * b }.diagonal { |s,x| s + x }
end | [
"def",
"convolve",
"(",
"filter",
")",
"filter",
"=",
"Node",
".",
"match",
"(",
"filter",
",",
"typecode",
")",
".",
"new",
"filter",
"unless",
"filter",
".",
"matched?",
"array",
"=",
"self",
"(",
"dimension",
"-",
"filter",
".",
"dimension",
")",
".... | Convolution with other array of same dimension
@param [Node] filter Filter to convolve with.
@return [Node] Result of convolution. | [
"Convolution",
"with",
"other",
"array",
"of",
"same",
"dimension"
] | 1ae1d98bacb4b941d6f406e44ccb184de12f83d9 | https://github.com/wedesoft/multiarray/blob/1ae1d98bacb4b941d6f406e44ccb184de12f83d9/lib/multiarray/operations.rb#L616-L621 | train |
wedesoft/multiarray | lib/multiarray/operations.rb | Hornetseye.Node.histogram | def histogram( *ret_shape )
options = ret_shape.last.is_a?( Hash ) ? ret_shape.pop : {}
options = { :weight => UINT.new( 1 ), :safe => true }.merge options
unless options[:weight].matched?
options[:weight] = Node.match(options[:weight]).maxint.new options[:weight]
end
if ( shape.fi... | ruby | def histogram( *ret_shape )
options = ret_shape.last.is_a?( Hash ) ? ret_shape.pop : {}
options = { :weight => UINT.new( 1 ), :safe => true }.merge options
unless options[:weight].matched?
options[:weight] = Node.match(options[:weight]).maxint.new options[:weight]
end
if ( shape.fi... | [
"def",
"histogram",
"(",
"*",
"ret_shape",
")",
"options",
"=",
"ret_shape",
".",
"last",
".",
"is_a?",
"(",
"Hash",
")",
"?",
"ret_shape",
".",
"pop",
":",
"{",
"}",
"options",
"=",
"{",
":weight",
"=>",
"UINT",
".",
"new",
"(",
"1",
")",
",",
"... | Compute histogram of this array
@overload histogram( *ret_shape, options = {} )
@param [Array<Integer>] ret_shape Dimensions of resulting histogram.
@option options [Node] :weight (UINT(1)) Weights for computing the histogram.
@option options [Boolean] :safe (true) Do a boundary check before creating the
... | [
"Compute",
"histogram",
"of",
"this",
"array"
] | 1ae1d98bacb4b941d6f406e44ccb184de12f83d9 | https://github.com/wedesoft/multiarray/blob/1ae1d98bacb4b941d6f406e44ccb184de12f83d9/lib/multiarray/operations.rb#L705-L717 | train |
wedesoft/multiarray | lib/multiarray/operations.rb | Hornetseye.Node.lut | def lut( table, options = {} )
if ( shape.first != 1 or dimension == 1 ) and table.dimension == 1
[ self ].lut table, options
else
( 0 ... shape.first ).collect { |i| unroll[i] }.lut table, options
end
end | ruby | def lut( table, options = {} )
if ( shape.first != 1 or dimension == 1 ) and table.dimension == 1
[ self ].lut table, options
else
( 0 ... shape.first ).collect { |i| unroll[i] }.lut table, options
end
end | [
"def",
"lut",
"(",
"table",
",",
"options",
"=",
"{",
"}",
")",
"if",
"(",
"shape",
".",
"first",
"!=",
"1",
"or",
"dimension",
"==",
"1",
")",
"and",
"table",
".",
"dimension",
"==",
"1",
"[",
"self",
"]",
".",
"lut",
"table",
",",
"options",
... | Perform element-wise lookup
@param [Node] table The lookup table (LUT).
@option options [Boolean] :safe (true) Do a boundary check before creating the
element-wise lookup.
@return [Node] The result of the lookup operation. | [
"Perform",
"element",
"-",
"wise",
"lookup"
] | 1ae1d98bacb4b941d6f406e44ccb184de12f83d9 | https://github.com/wedesoft/multiarray/blob/1ae1d98bacb4b941d6f406e44ccb184de12f83d9/lib/multiarray/operations.rb#L726-L732 | train |
wedesoft/multiarray | lib/multiarray/operations.rb | Hornetseye.Node.warp | def warp( *field )
options = field.last.is_a?( Hash ) ? field.pop : {}
options = { :safe => true, :default => typecode.default }.merge options
if options[ :safe ]
if field.size > dimension
raise "Number of arrays for warp (#{field.size}) is greater than the " +
"numbe... | ruby | def warp( *field )
options = field.last.is_a?( Hash ) ? field.pop : {}
options = { :safe => true, :default => typecode.default }.merge options
if options[ :safe ]
if field.size > dimension
raise "Number of arrays for warp (#{field.size}) is greater than the " +
"numbe... | [
"def",
"warp",
"(",
"*",
"field",
")",
"options",
"=",
"field",
".",
"last",
".",
"is_a?",
"(",
"Hash",
")",
"?",
"field",
".",
"pop",
":",
"{",
"}",
"options",
"=",
"{",
":safe",
"=>",
"true",
",",
":default",
"=>",
"typecode",
".",
"default",
"... | Warp an array
@overload warp( *field, options = {} )
@param [Array<Integer>] ret_shape Dimensions of resulting histogram.
@option options [Object] :default (typecode.default) Default value for out of
range warp vectors.
@option options [Boolean] :safe (true) Apply clip to warp vectors.
@return [... | [
"Warp",
"an",
"array"
] | 1ae1d98bacb4b941d6f406e44ccb184de12f83d9 | https://github.com/wedesoft/multiarray/blob/1ae1d98bacb4b941d6f406e44ccb184de12f83d9/lib/multiarray/operations.rb#L743-L759 | train |
wedesoft/multiarray | lib/multiarray/operations.rb | Hornetseye.Node.integral | def integral
left = allocate
block = Integral.new left, self
if block.compilable?
GCCFunction.run block
else
block.demand
end
left
end | ruby | def integral
left = allocate
block = Integral.new left, self
if block.compilable?
GCCFunction.run block
else
block.demand
end
left
end | [
"def",
"integral",
"left",
"=",
"allocate",
"block",
"=",
"Integral",
".",
"new",
"left",
",",
"self",
"if",
"block",
".",
"compilable?",
"GCCFunction",
".",
"run",
"block",
"else",
"block",
".",
"demand",
"end",
"left",
"end"
] | Compute integral image
@return [Node] The integral image of this array. | [
"Compute",
"integral",
"image"
] | 1ae1d98bacb4b941d6f406e44ccb184de12f83d9 | https://github.com/wedesoft/multiarray/blob/1ae1d98bacb4b941d6f406e44ccb184de12f83d9/lib/multiarray/operations.rb#L764-L773 | train |
wedesoft/multiarray | lib/multiarray/operations.rb | Hornetseye.Node.components | def components( options = {} )
if shape.any? { |x| x <= 1 }
raise "Every dimension must be greater than 1 (shape was #{shape})"
end
options = { :target => UINT, :default => typecode.default }.merge options
target = options[ :target ]
default = options[ :default ]
default = ty... | ruby | def components( options = {} )
if shape.any? { |x| x <= 1 }
raise "Every dimension must be greater than 1 (shape was #{shape})"
end
options = { :target => UINT, :default => typecode.default }.merge options
target = options[ :target ]
default = options[ :default ]
default = ty... | [
"def",
"components",
"(",
"options",
"=",
"{",
"}",
")",
"if",
"shape",
".",
"any?",
"{",
"|",
"x",
"|",
"x",
"<=",
"1",
"}",
"raise",
"\"Every dimension must be greater than 1 (shape was #{shape})\"",
"end",
"options",
"=",
"{",
":target",
"=>",
"UINT",
","... | Perform connected component labeling
@option options [Object] :default (typecode.default) Value of background elements.
@option options [Class] :target (UINT) Typecode of labels.
@return [Node] Array with labels of connected components. | [
"Perform",
"connected",
"component",
"labeling"
] | 1ae1d98bacb4b941d6f406e44ccb184de12f83d9 | https://github.com/wedesoft/multiarray/blob/1ae1d98bacb4b941d6f406e44ccb184de12f83d9/lib/multiarray/operations.rb#L781-L803 | train |
wedesoft/multiarray | lib/multiarray/operations.rb | Hornetseye.Node.mask | def mask( m )
check_shape m
left = MultiArray.new typecode, *( shape.first( dimension - m.dimension ) +
[ m.size ] )
index = Hornetseye::Pointer( INT ).new
index.store INT.new( 0 )
block = Mask.new left, self, m, index
if block.compilable?
... | ruby | def mask( m )
check_shape m
left = MultiArray.new typecode, *( shape.first( dimension - m.dimension ) +
[ m.size ] )
index = Hornetseye::Pointer( INT ).new
index.store INT.new( 0 )
block = Mask.new left, self, m, index
if block.compilable?
... | [
"def",
"mask",
"(",
"m",
")",
"check_shape",
"m",
"left",
"=",
"MultiArray",
".",
"new",
"typecode",
",",
"(",
"shape",
".",
"first",
"(",
"dimension",
"-",
"m",
".",
"dimension",
")",
"+",
"[",
"m",
".",
"size",
"]",
")",
"index",
"=",
"Hornetseye... | Select values from array using a mask
@param [Node] m Mask to apply to this array.
@return [Node] The masked array. | [
"Select",
"values",
"from",
"array",
"using",
"a",
"mask"
] | 1ae1d98bacb4b941d6f406e44ccb184de12f83d9 | https://github.com/wedesoft/multiarray/blob/1ae1d98bacb4b941d6f406e44ccb184de12f83d9/lib/multiarray/operations.rb#L810-L823 | train |
wedesoft/multiarray | lib/multiarray/operations.rb | Hornetseye.Node.unmask | def unmask( m, options = {} )
options = { :safe => true, :default => typecode.default }.merge options
default = options[:default]
default = typecode.new default unless default.matched?
m.check_shape default
if options[ :safe ]
if m.to_ubyte.sum > shape.last
raise "#{m.to_... | ruby | def unmask( m, options = {} )
options = { :safe => true, :default => typecode.default }.merge options
default = options[:default]
default = typecode.new default unless default.matched?
m.check_shape default
if options[ :safe ]
if m.to_ubyte.sum > shape.last
raise "#{m.to_... | [
"def",
"unmask",
"(",
"m",
",",
"options",
"=",
"{",
"}",
")",
"options",
"=",
"{",
":safe",
"=>",
"true",
",",
":default",
"=>",
"typecode",
".",
"default",
"}",
".",
"merge",
"options",
"default",
"=",
"options",
"[",
":default",
"]",
"default",
"=... | Distribute values in a new array using a mask
@param [Node] m Mask for inverse masking operation.
@option options [Object] :default (typecode.default) Default value for elements
where mask is +false+.
@option options [Boolean] :safe (true) Ensure that the size of this size is
sufficient.
@return... | [
"Distribute",
"values",
"in",
"a",
"new",
"array",
"using",
"a",
"mask"
] | 1ae1d98bacb4b941d6f406e44ccb184de12f83d9 | https://github.com/wedesoft/multiarray/blob/1ae1d98bacb4b941d6f406e44ccb184de12f83d9/lib/multiarray/operations.rb#L834-L856 | train |
wedesoft/multiarray | lib/multiarray/operations.rb | Hornetseye.Node.flip | def flip( *dimensions )
field = ( 0 ... dimension ).collect do |i|
if dimensions.member? i
Hornetseye::lazy( *shape ) { |*args| shape[i] - 1 - args[i] }
else
Hornetseye::lazy( *shape ) { |*args| args[i] }
end
end
warp *( field + [ :safe => false ] )
end | ruby | def flip( *dimensions )
field = ( 0 ... dimension ).collect do |i|
if dimensions.member? i
Hornetseye::lazy( *shape ) { |*args| shape[i] - 1 - args[i] }
else
Hornetseye::lazy( *shape ) { |*args| args[i] }
end
end
warp *( field + [ :safe => false ] )
end | [
"def",
"flip",
"(",
"*",
"dimensions",
")",
"field",
"=",
"(",
"0",
"...",
"dimension",
")",
".",
"collect",
"do",
"|",
"i",
"|",
"if",
"dimensions",
".",
"member?",
"i",
"Hornetseye",
"::",
"lazy",
"(",
"shape",
")",
"{",
"|",
"*",
"args",
"|",
... | Mirror the array
@param [Array<Integer>] dimensions The dimensions which should be flipped.
@return [Node] The result of flipping the dimensions. | [
"Mirror",
"the",
"array"
] | 1ae1d98bacb4b941d6f406e44ccb184de12f83d9 | https://github.com/wedesoft/multiarray/blob/1ae1d98bacb4b941d6f406e44ccb184de12f83d9/lib/multiarray/operations.rb#L863-L872 | train |
wedesoft/multiarray | lib/multiarray/operations.rb | Hornetseye.Node.shift | def shift( *offset )
if offset.size != dimension
raise "#{offset.size} offset(s) were given but array has " +
"#{dimension} dimension(s)"
end
retval = Hornetseye::MultiArray(typecode, dimension).new *shape
target, source, open, close = [], [], [], []
( shape.size - 1 ... | ruby | def shift( *offset )
if offset.size != dimension
raise "#{offset.size} offset(s) were given but array has " +
"#{dimension} dimension(s)"
end
retval = Hornetseye::MultiArray(typecode, dimension).new *shape
target, source, open, close = [], [], [], []
( shape.size - 1 ... | [
"def",
"shift",
"(",
"*",
"offset",
")",
"if",
"offset",
".",
"size",
"!=",
"dimension",
"raise",
"\"#{offset.size} offset(s) were given but array has \"",
"+",
"\"#{dimension} dimension(s)\"",
"end",
"retval",
"=",
"Hornetseye",
"::",
"MultiArray",
"(",
"typecode",
"... | Create array with shifted elements
@param [Array<Integer>] offset Array with amount of shift for each dimension.
@return [Node] The result of the shifting operation. | [
"Create",
"array",
"with",
"shifted",
"elements"
] | 1ae1d98bacb4b941d6f406e44ccb184de12f83d9 | https://github.com/wedesoft/multiarray/blob/1ae1d98bacb4b941d6f406e44ccb184de12f83d9/lib/multiarray/operations.rb#L879-L912 | train |
wedesoft/multiarray | lib/multiarray/operations.rb | Hornetseye.Node.downsample | def downsample( *rate )
options = rate.last.is_a?( Hash ) ? rate.pop : {}
options = { :offset => rate.collect { |r| r - 1 } }.merge options
offset = options[ :offset ]
if rate.size != dimension
raise "#{rate.size} sampling rate(s) given but array has " +
"#{dimension} dimen... | ruby | def downsample( *rate )
options = rate.last.is_a?( Hash ) ? rate.pop : {}
options = { :offset => rate.collect { |r| r - 1 } }.merge options
offset = options[ :offset ]
if rate.size != dimension
raise "#{rate.size} sampling rate(s) given but array has " +
"#{dimension} dimen... | [
"def",
"downsample",
"(",
"*",
"rate",
")",
"options",
"=",
"rate",
".",
"last",
".",
"is_a?",
"(",
"Hash",
")",
"?",
"rate",
".",
"pop",
":",
"{",
"}",
"options",
"=",
"{",
":offset",
"=>",
"rate",
".",
"collect",
"{",
"|",
"r",
"|",
"r",
"-",... | Downsampling of arrays
@overload downsample( *rate, options = {} )
@param [Array<Integer>] rate The sampling rates for each dimension.
@option options [Array<Integer>] :offset Sampling offsets for each dimension.
@return [Node] The downsampled data. | [
"Downsampling",
"of",
"arrays"
] | 1ae1d98bacb4b941d6f406e44ccb184de12f83d9 | https://github.com/wedesoft/multiarray/blob/1ae1d98bacb4b941d6f406e44ccb184de12f83d9/lib/multiarray/operations.rb#L921-L940 | train |
GemHQ/coin-op | lib/coin-op/bit/multi_wallet.rb | CoinOp::Bit.MultiWallet.signatures | def signatures(transaction, names: [:primary])
transaction.inputs.map do |input|
path = input.output.metadata[:wallet_path]
node = self.path(path)
sig_hash = transaction.sig_hash(input, node.script)
node.signatures(sig_hash, names: names)
end
end | ruby | def signatures(transaction, names: [:primary])
transaction.inputs.map do |input|
path = input.output.metadata[:wallet_path]
node = self.path(path)
sig_hash = transaction.sig_hash(input, node.script)
node.signatures(sig_hash, names: names)
end
end | [
"def",
"signatures",
"(",
"transaction",
",",
"names",
":",
"[",
":primary",
"]",
")",
"transaction",
".",
"inputs",
".",
"map",
"do",
"|",
"input",
"|",
"path",
"=",
"input",
".",
"output",
".",
"metadata",
"[",
":wallet_path",
"]",
"node",
"=",
"self... | Takes a Transaction ready to be signed.
Returns an Array of signature dictionaries. | [
"Takes",
"a",
"Transaction",
"ready",
"to",
"be",
"signed",
"."
] | 0b704b52d9826405cffb1606e914bf21b8dcc681 | https://github.com/GemHQ/coin-op/blob/0b704b52d9826405cffb1606e914bf21b8dcc681/lib/coin-op/bit/multi_wallet.rb#L157-L164 | train |
GemHQ/coin-op | lib/coin-op/bit/multi_wallet.rb | CoinOp::Bit.MultiWallet.authorize | def authorize(transaction, *signers)
transaction.set_script_sigs *signers do |input, *sig_dicts|
node = self.path(input.output.metadata[:wallet_path])
signatures = combine_signatures(*sig_dicts)
node.script_sig(signatures)
end
transaction
end | ruby | def authorize(transaction, *signers)
transaction.set_script_sigs *signers do |input, *sig_dicts|
node = self.path(input.output.metadata[:wallet_path])
signatures = combine_signatures(*sig_dicts)
node.script_sig(signatures)
end
transaction
end | [
"def",
"authorize",
"(",
"transaction",
",",
"*",
"signers",
")",
"transaction",
".",
"set_script_sigs",
"signers",
"do",
"|",
"input",
",",
"*",
"sig_dicts",
"|",
"node",
"=",
"self",
".",
"path",
"(",
"input",
".",
"output",
".",
"metadata",
"[",
":wal... | Takes a Transaction and any number of Arrays of signature dictionaries.
Each sig_dict in an Array corresponds to the Input with the same index.
Uses the combined signatures from all the signers to generate and set
the script_sig for each Input.
Returns the transaction. | [
"Takes",
"a",
"Transaction",
"and",
"any",
"number",
"of",
"Arrays",
"of",
"signature",
"dictionaries",
".",
"Each",
"sig_dict",
"in",
"an",
"Array",
"corresponds",
"to",
"the",
"Input",
"with",
"the",
"same",
"index",
"."
] | 0b704b52d9826405cffb1606e914bf21b8dcc681 | https://github.com/GemHQ/coin-op/blob/0b704b52d9826405cffb1606e914bf21b8dcc681/lib/coin-op/bit/multi_wallet.rb#L181-L188 | train |
GemHQ/coin-op | lib/coin-op/bit/multi_wallet.rb | CoinOp::Bit.MultiWallet.combine_signatures | def combine_signatures(*sig_dicts)
combined = {}
sig_dicts.each do |sig_dict|
sig_dict.each do |tree, signature|
decoded_sig = decode_base58(signature)
low_s_der_sig = Bitcoin::Script.is_low_der_signature?(decoded_sig) ?
decoded_sig : Bitcoin::OpenSSL_EC.signature_to_... | ruby | def combine_signatures(*sig_dicts)
combined = {}
sig_dicts.each do |sig_dict|
sig_dict.each do |tree, signature|
decoded_sig = decode_base58(signature)
low_s_der_sig = Bitcoin::Script.is_low_der_signature?(decoded_sig) ?
decoded_sig : Bitcoin::OpenSSL_EC.signature_to_... | [
"def",
"combine_signatures",
"(",
"*",
"sig_dicts",
")",
"combined",
"=",
"{",
"}",
"sig_dicts",
".",
"each",
"do",
"|",
"sig_dict",
"|",
"sig_dict",
".",
"each",
"do",
"|",
"tree",
",",
"signature",
"|",
"decoded_sig",
"=",
"decode_base58",
"(",
"signatur... | Takes any number of "signature dictionaries", which are Hashes where
the keys are tree names, and the values are base58-encoded signatures
for a single input.
Returns an Array of the signatures in binary, sorted by their tree names. | [
"Takes",
"any",
"number",
"of",
"signature",
"dictionaries",
"which",
"are",
"Hashes",
"where",
"the",
"keys",
"are",
"tree",
"names",
"and",
"the",
"values",
"are",
"base58",
"-",
"encoded",
"signatures",
"for",
"a",
"single",
"input",
"."
] | 0b704b52d9826405cffb1606e914bf21b8dcc681 | https://github.com/GemHQ/coin-op/blob/0b704b52d9826405cffb1606e914bf21b8dcc681/lib/coin-op/bit/multi_wallet.rb#L195-L210 | train |
RobertDober/Forwarder19 | lib/forwarder/arguments.rb | Forwarder.Arguments.evaluable? | def evaluable?
!lambda? &&
!aop? &&
( !args || args.all?{|a| Evaller.evaluable? a } ) &&
( !custom_target? || Evaller.evaluable?( custom_target? ) )
end | ruby | def evaluable?
!lambda? &&
!aop? &&
( !args || args.all?{|a| Evaller.evaluable? a } ) &&
( !custom_target? || Evaller.evaluable?( custom_target? ) )
end | [
"def",
"evaluable?",
"!",
"lambda?",
"&&",
"!",
"aop?",
"&&",
"(",
"!",
"args",
"||",
"args",
".",
"all?",
"{",
"|",
"a",
"|",
"Evaller",
".",
"evaluable?",
"a",
"}",
")",
"&&",
"(",
"!",
"custom_target?",
"||",
"Evaller",
".",
"evaluable?",
"(",
"... | def delegatable?
!aop? && !custom_target? && !all? && !chain? && !args && !lambda?
end | [
"def",
"delegatable?",
"!aop?",
"&&",
"!custom_target?",
"&&",
"!all?",
"&&",
"!chain?",
"&&",
"!args",
"&&",
"!lambda?",
"end"
] | b8d0a0b568f14b157fea078ed5b4102c55701c99 | https://github.com/RobertDober/Forwarder19/blob/b8d0a0b568f14b157fea078ed5b4102c55701c99/lib/forwarder/arguments.rb#L51-L56 | train |
rolandasb/gogcom | lib/gogcom/sale.rb | Gogcom.Sale.fetch | def fetch()
url = "http://www.gog.com/"
page = Net::HTTP.get(URI(url))
@data = JSON.parse(page[/(?<=var gogData = )(.*)(?=;)/,1])
end | ruby | def fetch()
url = "http://www.gog.com/"
page = Net::HTTP.get(URI(url))
@data = JSON.parse(page[/(?<=var gogData = )(.*)(?=;)/,1])
end | [
"def",
"fetch",
"(",
")",
"url",
"=",
"\"http://www.gog.com/\"",
"page",
"=",
"Net",
"::",
"HTTP",
".",
"get",
"(",
"URI",
"(",
"url",
")",
")",
"@data",
"=",
"JSON",
".",
"parse",
"(",
"page",
"[",
"/",
"/",
",",
"1",
"]",
")",
"end"
] | Fetches raw data from source.
@return [Object] | [
"Fetches",
"raw",
"data",
"from",
"source",
"."
] | 015de453bb214c9ccb51665ecadce1367e6d987d | https://github.com/rolandasb/gogcom/blob/015de453bb214c9ccb51665ecadce1367e6d987d/lib/gogcom/sale.rb#L19-L23 | train |
rolandasb/gogcom | lib/gogcom/sale.rb | Gogcom.Sale.parse | def parse(data)
items = []
data["on_sale"].each do |item|
sale_item = SaleItem.new(get_title(item), get_current_price(item),
get_original_price(item), get_discount_percentage(item),
get_discount_amount(item))
if @type.nil?
items.push(sale_item)
else
... | ruby | def parse(data)
items = []
data["on_sale"].each do |item|
sale_item = SaleItem.new(get_title(item), get_current_price(item),
get_original_price(item), get_discount_percentage(item),
get_discount_amount(item))
if @type.nil?
items.push(sale_item)
else
... | [
"def",
"parse",
"(",
"data",
")",
"items",
"=",
"[",
"]",
"data",
"[",
"\"on_sale\"",
"]",
".",
"each",
"do",
"|",
"item",
"|",
"sale_item",
"=",
"SaleItem",
".",
"new",
"(",
"get_title",
"(",
"item",
")",
",",
"get_current_price",
"(",
"item",
")",
... | Parses raw data and returns sale items.
@return [Array] | [
"Parses",
"raw",
"data",
"and",
"returns",
"sale",
"items",
"."
] | 015de453bb214c9ccb51665ecadce1367e6d987d | https://github.com/rolandasb/gogcom/blob/015de453bb214c9ccb51665ecadce1367e6d987d/lib/gogcom/sale.rb#L28-L54 | train |
schrodingersbox/split_cat | app/models/split_cat/experiment.rb | SplitCat.Experiment.choose_hypothesis | def choose_hypothesis
total = 0
roll = Kernel.rand( total_weight ) + 1
hypothesis = nil
hypotheses.each do |h|
if roll <= ( total += h.weight )
hypothesis ||= h
end
end
hypothesis ||= hypotheses.first
return hypothesis
end | ruby | def choose_hypothesis
total = 0
roll = Kernel.rand( total_weight ) + 1
hypothesis = nil
hypotheses.each do |h|
if roll <= ( total += h.weight )
hypothesis ||= h
end
end
hypothesis ||= hypotheses.first
return hypothesis
end | [
"def",
"choose_hypothesis",
"total",
"=",
"0",
"roll",
"=",
"Kernel",
".",
"rand",
"(",
"total_weight",
")",
"+",
"1",
"hypothesis",
"=",
"nil",
"hypotheses",
".",
"each",
"do",
"|",
"h",
"|",
"if",
"roll",
"<=",
"(",
"total",
"+=",
"h",
".",
"weight... | Returns a random hypothesis with weighted probability | [
"Returns",
"a",
"random",
"hypothesis",
"with",
"weighted",
"probability"
] | afe9c55e8d9be992ca601c0742b7512035e037a4 | https://github.com/schrodingersbox/split_cat/blob/afe9c55e8d9be992ca601c0742b7512035e037a4/app/models/split_cat/experiment.rb#L81-L92 | train |
schrodingersbox/split_cat | app/models/split_cat/experiment.rb | SplitCat.Experiment.same_structure? | def same_structure?( experiment )
return nil if name.to_sym != experiment.name.to_sym
return nil if goal_hash.keys != experiment.goal_hash.keys
return nil if hypothesis_hash.keys != experiment.hypothesis_hash.keys
return experiment
end | ruby | def same_structure?( experiment )
return nil if name.to_sym != experiment.name.to_sym
return nil if goal_hash.keys != experiment.goal_hash.keys
return nil if hypothesis_hash.keys != experiment.hypothesis_hash.keys
return experiment
end | [
"def",
"same_structure?",
"(",
"experiment",
")",
"return",
"nil",
"if",
"name",
".",
"to_sym",
"!=",
"experiment",
".",
"name",
".",
"to_sym",
"return",
"nil",
"if",
"goal_hash",
".",
"keys",
"!=",
"experiment",
".",
"goal_hash",
".",
"keys",
"return",
"n... | Returns true if the experiment has the same name, goals, and hypotheses as this one | [
"Returns",
"true",
"if",
"the",
"experiment",
"has",
"the",
"same",
"name",
"goals",
"and",
"hypotheses",
"as",
"this",
"one"
] | afe9c55e8d9be992ca601c0742b7512035e037a4 | https://github.com/schrodingersbox/split_cat/blob/afe9c55e8d9be992ca601c0742b7512035e037a4/app/models/split_cat/experiment.rb#L117-L122 | train |
detroit/detroit-dnote | lib/detroit-dnote.rb | Detroit.DNote.current? | def current?
output_mapping.each do |file, format|
return false if outofdate?(file, *dnote_session.files)
end
"DNotes are current (#{output})"
end | ruby | def current?
output_mapping.each do |file, format|
return false if outofdate?(file, *dnote_session.files)
end
"DNotes are current (#{output})"
end | [
"def",
"current?",
"output_mapping",
".",
"each",
"do",
"|",
"file",
",",
"format",
"|",
"return",
"false",
"if",
"outofdate?",
"(",
"file",
",",
"dnote_session",
".",
"files",
")",
"end",
"\"DNotes are current (#{output})\"",
"end"
] | Check the output file and see if they are older than
the input files.
@return [Boolean] whether output is up-to-date | [
"Check",
"the",
"output",
"file",
"and",
"see",
"if",
"they",
"are",
"older",
"than",
"the",
"input",
"files",
"."
] | 2f4dfd2deb31227b34d4bb7f9e8ce6937d6210ef | https://github.com/detroit/detroit-dnote/blob/2f4dfd2deb31227b34d4bb7f9e8ce6937d6210ef/lib/detroit-dnote.rb#L84-L89 | train |
detroit/detroit-dnote | lib/detroit-dnote.rb | Detroit.DNote.document | def document
session = dnote_session
output_mapping.each do |file, format|
#next unless verify_format(format)
dir = File.dirname(file)
mkdir_p(dir) unless File.directory?(dir)
session.output = file
session.format = format
session.run
report "Update... | ruby | def document
session = dnote_session
output_mapping.each do |file, format|
#next unless verify_format(format)
dir = File.dirname(file)
mkdir_p(dir) unless File.directory?(dir)
session.output = file
session.format = format
session.run
report "Update... | [
"def",
"document",
"session",
"=",
"dnote_session",
"output_mapping",
".",
"each",
"do",
"|",
"file",
",",
"format",
"|",
"#next unless verify_format(format)",
"dir",
"=",
"File",
".",
"dirname",
"(",
"file",
")",
"mkdir_p",
"(",
"dir",
")",
"unless",
"File",
... | Generate notes documents.
@return [void] | [
"Generate",
"notes",
"documents",
"."
] | 2f4dfd2deb31227b34d4bb7f9e8ce6937d6210ef | https://github.com/detroit/detroit-dnote/blob/2f4dfd2deb31227b34d4bb7f9e8ce6937d6210ef/lib/detroit-dnote.rb#L94-L109 | train |
detroit/detroit-dnote | lib/detroit-dnote.rb | Detroit.DNote.reset | def reset
output.each do |file, format|
if File.exist?(file)
utime(0,0,file)
report "Marked #{file} as out-of-date."
end
end
end | ruby | def reset
output.each do |file, format|
if File.exist?(file)
utime(0,0,file)
report "Marked #{file} as out-of-date."
end
end
end | [
"def",
"reset",
"output",
".",
"each",
"do",
"|",
"file",
",",
"format",
"|",
"if",
"File",
".",
"exist?",
"(",
"file",
")",
"utime",
"(",
"0",
",",
"0",
",",
"file",
")",
"report",
"\"Marked #{file} as out-of-date.\"",
"end",
"end",
"end"
] | Reset output files, marking them as out-of-date.
@return [void] | [
"Reset",
"output",
"files",
"marking",
"them",
"as",
"out",
"-",
"of",
"-",
"date",
"."
] | 2f4dfd2deb31227b34d4bb7f9e8ce6937d6210ef | https://github.com/detroit/detroit-dnote/blob/2f4dfd2deb31227b34d4bb7f9e8ce6937d6210ef/lib/detroit-dnote.rb#L114-L121 | train |
detroit/detroit-dnote | lib/detroit-dnote.rb | Detroit.DNote.purge | def purge
output.each do |file, format|
if File.exist?(file)
rm(file)
report "Removed #{file}"
end
end
end | ruby | def purge
output.each do |file, format|
if File.exist?(file)
rm(file)
report "Removed #{file}"
end
end
end | [
"def",
"purge",
"output",
".",
"each",
"do",
"|",
"file",
",",
"format",
"|",
"if",
"File",
".",
"exist?",
"(",
"file",
")",
"rm",
"(",
"file",
")",
"report",
"\"Removed #{file}\"",
"end",
"end",
"end"
] | Remove output files.
@return [void] | [
"Remove",
"output",
"files",
"."
] | 2f4dfd2deb31227b34d4bb7f9e8ce6937d6210ef | https://github.com/detroit/detroit-dnote/blob/2f4dfd2deb31227b34d4bb7f9e8ce6937d6210ef/lib/detroit-dnote.rb#L126-L133 | train |
detroit/detroit-dnote | lib/detroit-dnote.rb | Detroit.DNote.output_mapping | def output_mapping
@output_mapping ||= (
hash = {}
case output
when Array
output.each do |path|
hash[path] = format(path)
end
when String
hash[output] = format(output)
when Hash
hash = output
end
hash
... | ruby | def output_mapping
@output_mapping ||= (
hash = {}
case output
when Array
output.each do |path|
hash[path] = format(path)
end
when String
hash[output] = format(output)
when Hash
hash = output
end
hash
... | [
"def",
"output_mapping",
"@output_mapping",
"||=",
"(",
"hash",
"=",
"{",
"}",
"case",
"output",
"when",
"Array",
"output",
".",
"each",
"do",
"|",
"path",
"|",
"hash",
"[",
"path",
"]",
"=",
"format",
"(",
"path",
")",
"end",
"when",
"String",
"hash",... | Convert output into a hash of `file => format`.
@todo Should we use #apply_naming_policy ?
@return [Hash] | [
"Convert",
"output",
"into",
"a",
"hash",
"of",
"file",
"=",
">",
"format",
"."
] | 2f4dfd2deb31227b34d4bb7f9e8ce6937d6210ef | https://github.com/detroit/detroit-dnote/blob/2f4dfd2deb31227b34d4bb7f9e8ce6937d6210ef/lib/detroit-dnote.rb#L150-L165 | train |
detroit/detroit-dnote | lib/detroit-dnote.rb | Detroit.DNote.format | def format(file)
type = File.extname(file).sub('.','')
type = DEFAULT_FORMAT if type.empty?
type
end | ruby | def format(file)
type = File.extname(file).sub('.','')
type = DEFAULT_FORMAT if type.empty?
type
end | [
"def",
"format",
"(",
"file",
")",
"type",
"=",
"File",
".",
"extname",
"(",
"file",
")",
".",
"sub",
"(",
"'.'",
",",
"''",
")",
"type",
"=",
"DEFAULT_FORMAT",
"if",
"type",
".",
"empty?",
"type",
"end"
] | The format of the file based on the extension.
If the file has no extension then the value of
`DEFAULT_FORMAT` is returned.
@return [String] | [
"The",
"format",
"of",
"the",
"file",
"based",
"on",
"the",
"extension",
".",
"If",
"the",
"file",
"has",
"no",
"extension",
"then",
"the",
"value",
"of",
"DEFAULT_FORMAT",
"is",
"returned",
"."
] | 2f4dfd2deb31227b34d4bb7f9e8ce6937d6210ef | https://github.com/detroit/detroit-dnote/blob/2f4dfd2deb31227b34d4bb7f9e8ce6937d6210ef/lib/detroit-dnote.rb#L172-L176 | train |
detroit/detroit-dnote | lib/detroit-dnote.rb | Detroit.DNote.dnote_session | def dnote_session
::DNote::Session.new do |s|
s.paths = files
s.exclude = exclude
s.ignore = ignore
s.labels = labels
s.title = title
s.context = lines
s.dryrun = trial?
end
end | ruby | def dnote_session
::DNote::Session.new do |s|
s.paths = files
s.exclude = exclude
s.ignore = ignore
s.labels = labels
s.title = title
s.context = lines
s.dryrun = trial?
end
end | [
"def",
"dnote_session",
"::",
"DNote",
"::",
"Session",
".",
"new",
"do",
"|",
"s",
"|",
"s",
".",
"paths",
"=",
"files",
"s",
".",
"exclude",
"=",
"exclude",
"s",
".",
"ignore",
"=",
"ignore",
"s",
".",
"labels",
"=",
"labels",
"s",
".",
"title",
... | DNote Session instance.
@return [DNote::Session] | [
"DNote",
"Session",
"instance",
"."
] | 2f4dfd2deb31227b34d4bb7f9e8ce6937d6210ef | https://github.com/detroit/detroit-dnote/blob/2f4dfd2deb31227b34d4bb7f9e8ce6937d6210ef/lib/detroit-dnote.rb#L181-L191 | train |
aaronpk/jawbone-up-ruby | lib/jawbone-up/session.rb | JawboneUP.Session.get | def get(path, query=nil, headers={})
response = execute :get, path, query, headers
hash = JSON.parse response.body
end | ruby | def get(path, query=nil, headers={})
response = execute :get, path, query, headers
hash = JSON.parse response.body
end | [
"def",
"get",
"(",
"path",
",",
"query",
"=",
"nil",
",",
"headers",
"=",
"{",
"}",
")",
"response",
"=",
"execute",
":get",
",",
"path",
",",
"query",
",",
"headers",
"hash",
"=",
"JSON",
".",
"parse",
"response",
".",
"body",
"end"
] | Raw HTTP methods | [
"Raw",
"HTTP",
"methods"
] | 6fec67a72d7f3df5aa040fa4d5341d0c434f72ca | https://github.com/aaronpk/jawbone-up-ruby/blob/6fec67a72d7f3df5aa040fa4d5341d0c434f72ca/lib/jawbone-up/session.rb#L90-L93 | train |
seoaqua/baidumap | lib/baidumap/request.rb | Baidumap.Request.request | def request
http_segments = @segments.clone
@params.each do |key,value|
http_segments[key] = value
end
uri = URI::HTTP.build(
:host => HOST,
:path => @action_path,
:query => URI.encode_www_form(http_segments)
).to_s
result = JSON.parse(HTTParty.get(uri... | ruby | def request
http_segments = @segments.clone
@params.each do |key,value|
http_segments[key] = value
end
uri = URI::HTTP.build(
:host => HOST,
:path => @action_path,
:query => URI.encode_www_form(http_segments)
).to_s
result = JSON.parse(HTTParty.get(uri... | [
"def",
"request",
"http_segments",
"=",
"@segments",
".",
"clone",
"@params",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"http_segments",
"[",
"key",
"]",
"=",
"value",
"end",
"uri",
"=",
"URI",
"::",
"HTTP",
".",
"build",
"(",
":host",
"=>",
... | send http request | [
"send",
"http",
"request"
] | da6c0fd4ff61eb5b89ff8acea8389b2894a2661a | https://github.com/seoaqua/baidumap/blob/da6c0fd4ff61eb5b89ff8acea8389b2894a2661a/lib/baidumap/request.rb#L36-L48 | train |
midi-visualizer/vissen-parameterized | lib/vissen/parameterized.rb | Vissen.Parameterized.bind | def bind(param, target)
raise ScopeError unless scope.include? target
@_params.fetch(param).bind target
end | ruby | def bind(param, target)
raise ScopeError unless scope.include? target
@_params.fetch(param).bind target
end | [
"def",
"bind",
"(",
"param",
",",
"target",
")",
"raise",
"ScopeError",
"unless",
"scope",
".",
"include?",
"target",
"@_params",
".",
"fetch",
"(",
"param",
")",
".",
"bind",
"target",
"end"
] | Binds a parameter to a target value.
@see Parameter#bind
@raise [KeyError] if the parameter is not found.
@raise [ScopeError] if the parameter is out of scope.
@param param [Symbol] the parameter to bind.
@param target [#value] the value object to bind to.
@return [Parameter] the parameter that was bound... | [
"Binds",
"a",
"parameter",
"to",
"a",
"target",
"value",
"."
] | 20cfb1cbaf6c7af5f5907b41c5439c39eed06420 | https://github.com/midi-visualizer/vissen-parameterized/blob/20cfb1cbaf6c7af5f5907b41c5439c39eed06420/lib/vissen/parameterized.rb#L133-L136 | train |
midi-visualizer/vissen-parameterized | lib/vissen/parameterized.rb | Vissen.Parameterized.inspect | def inspect
format INSPECT_FORMAT, name: self.class.name,
object_id: object_id,
params: params_with_types,
type: Value.canonicalize(@_value.class)
end | ruby | def inspect
format INSPECT_FORMAT, name: self.class.name,
object_id: object_id,
params: params_with_types,
type: Value.canonicalize(@_value.class)
end | [
"def",
"inspect",
"format",
"INSPECT_FORMAT",
",",
"name",
":",
"self",
".",
"class",
".",
"name",
",",
"object_id",
":",
"object_id",
",",
"params",
":",
"params_with_types",
",",
"type",
":",
"Value",
".",
"canonicalize",
"(",
"@_value",
".",
"class",
")... | Produces a readable string representation of the parameterized object.
@return [String] a string representation. | [
"Produces",
"a",
"readable",
"string",
"representation",
"of",
"the",
"parameterized",
"object",
"."
] | 20cfb1cbaf6c7af5f5907b41c5439c39eed06420 | https://github.com/midi-visualizer/vissen-parameterized/blob/20cfb1cbaf6c7af5f5907b41c5439c39eed06420/lib/vissen/parameterized.rb#L166-L171 | train |
midi-visualizer/vissen-parameterized | lib/vissen/parameterized.rb | Vissen.Parameterized.each_parameterized | def each_parameterized
return to_enum(__callee__) unless block_given?
@_params.each do |_, param|
next if param.constant?
target = param.target
yield target if target.is_a? Parameterized
end
end | ruby | def each_parameterized
return to_enum(__callee__) unless block_given?
@_params.each do |_, param|
next if param.constant?
target = param.target
yield target if target.is_a? Parameterized
end
end | [
"def",
"each_parameterized",
"return",
"to_enum",
"(",
"__callee__",
")",
"unless",
"block_given?",
"@_params",
".",
"each",
"do",
"|",
"_",
",",
"param",
"|",
"next",
"if",
"param",
".",
"constant?",
"target",
"=",
"param",
".",
"target",
"yield",
"target",... | Iterates over the parameterized objects currently bound to the parameters.
@return [Enumerable] if no block is given. | [
"Iterates",
"over",
"the",
"parameterized",
"objects",
"currently",
"bound",
"to",
"the",
"parameters",
"."
] | 20cfb1cbaf6c7af5f5907b41c5439c39eed06420 | https://github.com/midi-visualizer/vissen-parameterized/blob/20cfb1cbaf6c7af5f5907b41c5439c39eed06420/lib/vissen/parameterized.rb#L176-L183 | train |
triglav-dataflow/triglav-client-ruby | lib/triglav_client/api/auth_api.rb | TriglavClient.AuthApi.create_token | def create_token(credential, opts = {})
data, _status_code, _headers = create_token_with_http_info(credential, opts)
return data
end | ruby | def create_token(credential, opts = {})
data, _status_code, _headers = create_token_with_http_info(credential, opts)
return data
end | [
"def",
"create_token",
"(",
"credential",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"create_token_with_http_info",
"(",
"credential",
",",
"opts",
")",
"return",
"data",
"end"
] | Creates a new token
@param credential
@param [Hash] opts the optional parameters
@return [TokenResponse] | [
"Creates",
"a",
"new",
"token"
] | b2f3781d65ee032ba96eb703fbd789c713a5e0bd | https://github.com/triglav-dataflow/triglav-client-ruby/blob/b2f3781d65ee032ba96eb703fbd789c713a5e0bd/lib/triglav_client/api/auth_api.rb#L39-L42 | train |
barkerest/barkest_core | app/models/barkest_core/auth_config.rb | BarkestCore.AuthConfig.to_h | def to_h
{
enable_db_auth: enable_db_auth?,
enable_ldap_auth: enable_ldap_auth?,
ldap_host: ldap_host.to_s,
ldap_port: ldap_port.to_s.to_i,
ldap_ssl: ldap_ssl?,
ldap_base_dn: ldap_base_dn.to_s,
ldap_browse_user: ldap_browse_user.to_s,
... | ruby | def to_h
{
enable_db_auth: enable_db_auth?,
enable_ldap_auth: enable_ldap_auth?,
ldap_host: ldap_host.to_s,
ldap_port: ldap_port.to_s.to_i,
ldap_ssl: ldap_ssl?,
ldap_base_dn: ldap_base_dn.to_s,
ldap_browse_user: ldap_browse_user.to_s,
... | [
"def",
"to_h",
"{",
"enable_db_auth",
":",
"enable_db_auth?",
",",
"enable_ldap_auth",
":",
"enable_ldap_auth?",
",",
"ldap_host",
":",
"ldap_host",
".",
"to_s",
",",
"ldap_port",
":",
"ldap_port",
".",
"to_s",
".",
"to_i",
",",
"ldap_ssl",
":",
"ldap_ssl?",
"... | Converts the configuration to a hash. | [
"Converts",
"the",
"configuration",
"to",
"a",
"hash",
"."
] | 3eeb025ec870888cacbc9bae252a39ebf9295f61 | https://github.com/barkerest/barkest_core/blob/3eeb025ec870888cacbc9bae252a39ebf9295f61/app/models/barkest_core/auth_config.rb#L67-L80 | train |
nrser/nrser.rb | lib/nrser/message.rb | NRSER.Message.send_to | def send_to receiver, publicly: true
if publicly
receiver.public_send symbol, *args, &block
else
receiver.send symbol, *args, &block
end
end | ruby | def send_to receiver, publicly: true
if publicly
receiver.public_send symbol, *args, &block
else
receiver.send symbol, *args, &block
end
end | [
"def",
"send_to",
"receiver",
",",
"publicly",
":",
"true",
"if",
"publicly",
"receiver",
".",
"public_send",
"symbol",
",",
"args",
",",
"block",
"else",
"receiver",
".",
"send",
"symbol",
",",
"args",
",",
"block",
"end",
"end"
] | Send this instance to a receiver object.
@example
msg.send_to obj
@param [Object] receiver
Object that the message will be sent to.
@param [Boolean] publicly
When `true`, the message will be sent via {Object#public_send}. This is
the default behavior.
When `false`, the message will be sent via {O... | [
"Send",
"this",
"instance",
"to",
"a",
"receiver",
"object",
"."
] | 7db9a729ec65894dfac13fd50851beae8b809738 | https://github.com/nrser/nrser.rb/blob/7db9a729ec65894dfac13fd50851beae8b809738/lib/nrser/message.rb#L159-L165 | train |
coralnexus/nucleon | lib/core/core.rb | Nucleon.Core.logger= | def logger=logger
Util::Logger.loggers.delete(self.logger.resource) if self.logger
if logger.is_a?(Util::Logger)
@logger = logger
else
@logger = Util::Logger.new(logger)
end
end | ruby | def logger=logger
Util::Logger.loggers.delete(self.logger.resource) if self.logger
if logger.is_a?(Util::Logger)
@logger = logger
else
@logger = Util::Logger.new(logger)
end
end | [
"def",
"logger",
"=",
"logger",
"Util",
"::",
"Logger",
".",
"loggers",
".",
"delete",
"(",
"self",
".",
"logger",
".",
"resource",
")",
"if",
"self",
".",
"logger",
"if",
"logger",
".",
"is_a?",
"(",
"Util",
"::",
"Logger",
")",
"@logger",
"=",
"log... | Set current object logger instance
* *Parameters*
- [String, Nucleon::Util::Logger] *logger* Logger instance or resource name for new logger
* *Returns*
- [Void] This method does not return a value
* *Errors*
See also:
- Nucleon::Util::Logger::loggers
- Nucleon::Util::Logger::new | [
"Set",
"current",
"object",
"logger",
"instance"
] | 3a3c489251139c184e0884feaa55269cf64cad44 | https://github.com/coralnexus/nucleon/blob/3a3c489251139c184e0884feaa55269cf64cad44/lib/core/core.rb#L153-L161 | train |
coralnexus/nucleon | lib/core/core.rb | Nucleon.Core.ui= | def ui=ui
if ui.is_a?(Util::Console)
@ui = ui
else
@ui = Util::Console.new(ui)
end
end | ruby | def ui=ui
if ui.is_a?(Util::Console)
@ui = ui
else
@ui = Util::Console.new(ui)
end
end | [
"def",
"ui",
"=",
"ui",
"if",
"ui",
".",
"is_a?",
"(",
"Util",
"::",
"Console",
")",
"@ui",
"=",
"ui",
"else",
"@ui",
"=",
"Util",
"::",
"Console",
".",
"new",
"(",
"ui",
")",
"end",
"end"
] | Set current object console instance
* *Parameters*
- [String, Nucleon::Util::Console] *ui* Console instance or resource name for new console
* *Returns*
- [Void] This method does not return a value
* *Errors*
See also:
- Nucleon::Util::Console::new | [
"Set",
"current",
"object",
"console",
"instance"
] | 3a3c489251139c184e0884feaa55269cf64cad44 | https://github.com/coralnexus/nucleon/blob/3a3c489251139c184e0884feaa55269cf64cad44/lib/core/core.rb#L192-L198 | train |
coralnexus/nucleon | lib/core/core.rb | Nucleon.Core.ui_group | def ui_group(resource, color = :cyan) # :yields: ui
ui_resource = ui.resource
ui.resource = Util::Console.colorize(resource, color)
yield(ui)
ensure
ui.resource = ui_resource
end | ruby | def ui_group(resource, color = :cyan) # :yields: ui
ui_resource = ui.resource
ui.resource = Util::Console.colorize(resource, color)
yield(ui)
ensure
ui.resource = ui_resource
end | [
"def",
"ui_group",
"(",
"resource",
",",
"color",
"=",
":cyan",
")",
"# :yields: ui",
"ui_resource",
"=",
"ui",
".",
"resource",
"ui",
".",
"resource",
"=",
"Util",
"::",
"Console",
".",
"colorize",
"(",
"resource",
",",
"color",
")",
"yield",
"(",
"ui",... | Contextualize console operations in a code block with a given resource name.
* *Parameters*
- [String, Symbol] *resource* Console resource identifier (prefix)
- [Symbol] *color* Color to use; *:black*, *:red*, *:green*, *:yellow*, *:blue*, *:purple*, *:cyan*, *:grey*
* *Returns*
- [Void] This method doe... | [
"Contextualize",
"console",
"operations",
"in",
"a",
"code",
"block",
"with",
"a",
"given",
"resource",
"name",
"."
] | 3a3c489251139c184e0884feaa55269cf64cad44 | https://github.com/coralnexus/nucleon/blob/3a3c489251139c184e0884feaa55269cf64cad44/lib/core/core.rb#L252-L259 | train |
DigitPaint/html_mockup | lib/html_mockup/release.rb | HtmlMockup.Release.log | def log(part, msg, verbose = false, &block)
if !verbose || verbose && self.project.options[:verbose]
self.project.shell.say "\033[37m#{part.class.to_s}\033[0m" + " : " + msg.to_s, nil, true
end
if block_given?
begin
self.project.shell.padding = self.project.shell.padding + 1
... | ruby | def log(part, msg, verbose = false, &block)
if !verbose || verbose && self.project.options[:verbose]
self.project.shell.say "\033[37m#{part.class.to_s}\033[0m" + " : " + msg.to_s, nil, true
end
if block_given?
begin
self.project.shell.padding = self.project.shell.padding + 1
... | [
"def",
"log",
"(",
"part",
",",
"msg",
",",
"verbose",
"=",
"false",
",",
"&",
"block",
")",
"if",
"!",
"verbose",
"||",
"verbose",
"&&",
"self",
".",
"project",
".",
"options",
"[",
":verbose",
"]",
"self",
".",
"project",
".",
"shell",
".",
"say"... | Write out a log message | [
"Write",
"out",
"a",
"log",
"message"
] | 976edadc01216b82a8cea177f53fb32559eaf41e | https://github.com/DigitPaint/html_mockup/blob/976edadc01216b82a8cea177f53fb32559eaf41e/lib/html_mockup/release.rb#L223-L235 | train |
DigitPaint/html_mockup | lib/html_mockup/release.rb | HtmlMockup.Release.validate_stack! | def validate_stack!
mockup_options = {}
relativizer_options = {}
run_relativizer = true
if @extractor_options
mockup_options = {:env => @extractor_options[:env]}
relativizer_options = {:url_attributes => @extractor_options[:url_attributes]}
run_relativizer = @extra... | ruby | def validate_stack!
mockup_options = {}
relativizer_options = {}
run_relativizer = true
if @extractor_options
mockup_options = {:env => @extractor_options[:env]}
relativizer_options = {:url_attributes => @extractor_options[:url_attributes]}
run_relativizer = @extra... | [
"def",
"validate_stack!",
"mockup_options",
"=",
"{",
"}",
"relativizer_options",
"=",
"{",
"}",
"run_relativizer",
"=",
"true",
"if",
"@extractor_options",
"mockup_options",
"=",
"{",
":env",
"=>",
"@extractor_options",
"[",
":env",
"]",
"}",
"relativizer_options",... | Checks if deprecated extractor options have been set
Checks if the mockup will be runned | [
"Checks",
"if",
"deprecated",
"extractor",
"options",
"have",
"been",
"set",
"Checks",
"if",
"the",
"mockup",
"will",
"be",
"runned"
] | 976edadc01216b82a8cea177f53fb32559eaf41e | https://github.com/DigitPaint/html_mockup/blob/976edadc01216b82a8cea177f53fb32559eaf41e/lib/html_mockup/release.rb#L280-L295 | train |
riddopic/garcun | lib/garcon/task/priority_queue.rb | Garcon.MutexPriorityQueue.delete | def delete(item)
original_length = @length
k = 1
while k <= @length
if @queue[k] == item
swap(k, @length)
@length -= 1
sink(k)
@queue.pop
else
k += 1
end
end
@length != original_length
end | ruby | def delete(item)
original_length = @length
k = 1
while k <= @length
if @queue[k] == item
swap(k, @length)
@length -= 1
sink(k)
@queue.pop
else
k += 1
end
end
@length != original_length
end | [
"def",
"delete",
"(",
"item",
")",
"original_length",
"=",
"@length",
"k",
"=",
"1",
"while",
"k",
"<=",
"@length",
"if",
"@queue",
"[",
"k",
"]",
"==",
"item",
"swap",
"(",
"k",
",",
"@length",
")",
"@length",
"-=",
"1",
"sink",
"(",
"k",
")",
"... | Deletes all items from `self` that are equal to `item`.
@param [Object] item
The item to be removed from the queue.
@return [Object]
True if the item is found else false. | [
"Deletes",
"all",
"items",
"from",
"self",
"that",
"are",
"equal",
"to",
"item",
"."
] | c2409bd8cf9c14b967a719810dab5269d69b42de | https://github.com/riddopic/garcun/blob/c2409bd8cf9c14b967a719810dab5269d69b42de/lib/garcon/task/priority_queue.rb#L63-L77 | train |
riddopic/garcun | lib/garcon/task/priority_queue.rb | Garcon.MutexPriorityQueue.sink | def sink(k)
while (j = (2 * k)) <= @length do
j += 1 if j < @length && ! ordered?(j, j+1)
break if ordered?(k, j)
swap(k, j)
k = j
end
end | ruby | def sink(k)
while (j = (2 * k)) <= @length do
j += 1 if j < @length && ! ordered?(j, j+1)
break if ordered?(k, j)
swap(k, j)
k = j
end
end | [
"def",
"sink",
"(",
"k",
")",
"while",
"(",
"j",
"=",
"(",
"2",
"*",
"k",
")",
")",
"<=",
"@length",
"do",
"j",
"+=",
"1",
"if",
"j",
"<",
"@length",
"&&",
"!",
"ordered?",
"(",
"j",
",",
"j",
"+",
"1",
")",
"break",
"if",
"ordered?",
"(",
... | Percolate down to maintain heap invariant.
@param [Integer] k
The index at which to start the percolation.
@!visibility private | [
"Percolate",
"down",
"to",
"maintain",
"heap",
"invariant",
"."
] | c2409bd8cf9c14b967a719810dab5269d69b42de | https://github.com/riddopic/garcun/blob/c2409bd8cf9c14b967a719810dab5269d69b42de/lib/garcon/task/priority_queue.rb#L210-L217 | train |
riddopic/garcun | lib/garcon/task/priority_queue.rb | Garcon.MutexPriorityQueue.swim | def swim(k)
while k > 1 && ! ordered?(k/2, k) do
swap(k, k/2)
k = k/2
end
end | ruby | def swim(k)
while k > 1 && ! ordered?(k/2, k) do
swap(k, k/2)
k = k/2
end
end | [
"def",
"swim",
"(",
"k",
")",
"while",
"k",
">",
"1",
"&&",
"!",
"ordered?",
"(",
"k",
"/",
"2",
",",
"k",
")",
"do",
"swap",
"(",
"k",
",",
"k",
"/",
"2",
")",
"k",
"=",
"k",
"/",
"2",
"end",
"end"
] | Percolate up to maintain heap invariant.
@param [Integer] k
The index at which to start the percolation.
@!visibility private | [
"Percolate",
"up",
"to",
"maintain",
"heap",
"invariant",
"."
] | c2409bd8cf9c14b967a719810dab5269d69b42de | https://github.com/riddopic/garcun/blob/c2409bd8cf9c14b967a719810dab5269d69b42de/lib/garcon/task/priority_queue.rb#L225-L230 | train |
devnull-tools/yummi | lib/yummi/text_box.rb | Yummi.TextBox.add | def add (obj, params = {})
text = obj.to_s
params = {
:width => style.width,
:align => style.align
}.merge! params
if params[:width]
width = params[:width]
words = text.gsub($/, ' ').split(' ') unless params[:raw]
words ||= [text]
buff = ''
... | ruby | def add (obj, params = {})
text = obj.to_s
params = {
:width => style.width,
:align => style.align
}.merge! params
if params[:width]
width = params[:width]
words = text.gsub($/, ' ').split(' ') unless params[:raw]
words ||= [text]
buff = ''
... | [
"def",
"add",
"(",
"obj",
",",
"params",
"=",
"{",
"}",
")",
"text",
"=",
"obj",
".",
"to_s",
"params",
"=",
"{",
":width",
"=>",
"style",
".",
"width",
",",
":align",
"=>",
"style",
".",
"align",
"}",
".",
"merge!",
"params",
"if",
"params",
"["... | Adds a line text to this box
=== Args
+obj+::
The obj to add (will be converted to string).
+params+::
A hash of parameters. Currently supported are:
color: the text color (see #Yummi#COLORS)
width: the text maximum width. Set this to break the lines automatically.
If the #width is set,... | [
"Adds",
"a",
"line",
"text",
"to",
"this",
"box"
] | b31cc1ef9a9f4ca1c22e0b77a84a1995bde5c2df | https://github.com/devnull-tools/yummi/blob/b31cc1ef9a9f4ca1c22e0b77a84a1995bde5c2df/lib/yummi/text_box.rb#L97-L125 | train |
devnull-tools/yummi | lib/yummi/text_box.rb | Yummi.TextBox.separator | def separator (params = {})
params = style.separator.merge params
params[:width] ||= style.width
raise Exception::new('Define a width for using separators') unless params[:width]
line = fill(params[:pattern], params[:width])
#replace the width with the box width to align the separator
... | ruby | def separator (params = {})
params = style.separator.merge params
params[:width] ||= style.width
raise Exception::new('Define a width for using separators') unless params[:width]
line = fill(params[:pattern], params[:width])
#replace the width with the box width to align the separator
... | [
"def",
"separator",
"(",
"params",
"=",
"{",
"}",
")",
"params",
"=",
"style",
".",
"separator",
".",
"merge",
"params",
"params",
"[",
":width",
"]",
"||=",
"style",
".",
"width",
"raise",
"Exception",
"::",
"new",
"(",
"'Define a width for using separators... | Adds a line separator.
=== Args
+params+::
A hash of parameters. Currently supported are:
pattern: the pattern to build the line
color: the separator color (see #Yummi#COLORS)
width: the separator width (#self#width will be used if unset)
align: the separator alignment (see #Yummi#Aligner) | [
"Adds",
"a",
"line",
"separator",
"."
] | b31cc1ef9a9f4ca1c22e0b77a84a1995bde5c2df | https://github.com/devnull-tools/yummi/blob/b31cc1ef9a9f4ca1c22e0b77a84a1995bde5c2df/lib/yummi/text_box.rb#L147-L155 | train |
kukushkin/aerogel-core | lib/aerogel/core/render/block_helper.rb | Aerogel::Render.BlockHelper.render | def render
content = output_capture(@block) do
instance_exec( *@args, &@block )
end
content_wrapped = output_capture() { wrap( content ) }
output_concat content_wrapped
end | ruby | def render
content = output_capture(@block) do
instance_exec( *@args, &@block )
end
content_wrapped = output_capture() { wrap( content ) }
output_concat content_wrapped
end | [
"def",
"render",
"content",
"=",
"output_capture",
"(",
"@block",
")",
"do",
"instance_exec",
"(",
"@args",
",",
"@block",
")",
"end",
"content_wrapped",
"=",
"output_capture",
"(",
")",
"{",
"wrap",
"(",
"content",
")",
"}",
"output_concat",
"content_wrapped"... | Renders output to the template or returns it as a string. | [
"Renders",
"output",
"to",
"the",
"template",
"or",
"returns",
"it",
"as",
"a",
"string",
"."
] | e156af6b237c410c1ee75e5cdf1b10075e7fbb8b | https://github.com/kukushkin/aerogel-core/blob/e156af6b237c410c1ee75e5cdf1b10075e7fbb8b/lib/aerogel/core/render/block_helper.rb#L32-L38 | train |
barkerest/incline | lib/incline/extensions/application.rb | Incline::Extensions.Application.app_instance_name | def app_instance_name
@app_instance_name ||=
begin
yaml = Rails.root.join('config','instance.yml')
if File.exist?(yaml)
yaml = (YAML.load(ERB.new(File.read(yaml)).result) || {}).symbolize_keys
yaml[:name].blank? ? 'default' : yaml[:name]
el... | ruby | def app_instance_name
@app_instance_name ||=
begin
yaml = Rails.root.join('config','instance.yml')
if File.exist?(yaml)
yaml = (YAML.load(ERB.new(File.read(yaml)).result) || {}).symbolize_keys
yaml[:name].blank? ? 'default' : yaml[:name]
el... | [
"def",
"app_instance_name",
"@app_instance_name",
"||=",
"begin",
"yaml",
"=",
"Rails",
".",
"root",
".",
"join",
"(",
"'config'",
",",
"'instance.yml'",
")",
"if",
"File",
".",
"exist?",
"(",
"yaml",
")",
"yaml",
"=",
"(",
"YAML",
".",
"load",
"(",
"ERB... | Gets the application instance name.
This can be set by creating a +config/instance.yml+ configuration file and setting the 'name' property.
The instance name is used to create unique cookies for each instance of an application.
The default instance name is 'default'. | [
"Gets",
"the",
"application",
"instance",
"name",
"."
] | 1ff08db7aa8ab7f86b223268b700bc67d15bb8aa | https://github.com/barkerest/incline/blob/1ff08db7aa8ab7f86b223268b700bc67d15bb8aa/lib/incline/extensions/application.rb#L46-L57 | train |
barkerest/incline | lib/incline/extensions/application.rb | Incline::Extensions.Application.restart_pending? | def restart_pending?
return false unless File.exist?(restart_file)
request_time = File.mtime(restart_file)
request_time > Incline.start_time
end | ruby | def restart_pending?
return false unless File.exist?(restart_file)
request_time = File.mtime(restart_file)
request_time > Incline.start_time
end | [
"def",
"restart_pending?",
"return",
"false",
"unless",
"File",
".",
"exist?",
"(",
"restart_file",
")",
"request_time",
"=",
"File",
".",
"mtime",
"(",
"restart_file",
")",
"request_time",
">",
"Incline",
".",
"start_time",
"end"
] | Is a restart currently pending. | [
"Is",
"a",
"restart",
"currently",
"pending",
"."
] | 1ff08db7aa8ab7f86b223268b700bc67d15bb8aa | https://github.com/barkerest/incline/blob/1ff08db7aa8ab7f86b223268b700bc67d15bb8aa/lib/incline/extensions/application.rb#L103-L107 | train |
barkerest/incline | lib/incline/extensions/application.rb | Incline::Extensions.Application.request_restart! | def request_restart!
Incline::Log::info 'Requesting an application restart.'
FileUtils.touch restart_file
File.mtime restart_file
end | ruby | def request_restart!
Incline::Log::info 'Requesting an application restart.'
FileUtils.touch restart_file
File.mtime restart_file
end | [
"def",
"request_restart!",
"Incline",
"::",
"Log",
"::",
"info",
"'Requesting an application restart.'",
"FileUtils",
".",
"touch",
"restart_file",
"File",
".",
"mtime",
"restart_file",
"end"
] | Updates the restart file to indicate we want to restart the web app. | [
"Updates",
"the",
"restart",
"file",
"to",
"indicate",
"we",
"want",
"to",
"restart",
"the",
"web",
"app",
"."
] | 1ff08db7aa8ab7f86b223268b700bc67d15bb8aa | https://github.com/barkerest/incline/blob/1ff08db7aa8ab7f86b223268b700bc67d15bb8aa/lib/incline/extensions/application.rb#L111-L115 | train |
Subsets and Splits
SQL Console for semeru/code-text-ruby
Retrieves 20,000 non-null code samples labeled as Ruby, providing a basic overview of the dataset but without deeper analysis.