id int32 0 24.9k | repo stringlengths 5 58 | path stringlengths 9 168 | func_name stringlengths 9 130 | original_string stringlengths 66 10.5k | language stringclasses 1
value | code stringlengths 66 10.5k | code_tokens list | docstring stringlengths 8 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 94 266 |
|---|---|---|---|---|---|---|---|---|---|---|---|
2,900 | Yellowen/Faalis | app/models/faalis/user.rb | Faalis.User.join_guests | def join_guests
#::Faalis::Group.find_by(role: 'guest')
if groups.empty?
guest_group = ::Faalis::Group.find_or_create_by(name: 'Guest',
role: 'guest')
self.groups << guest_group
end
end | ruby | def join_guests
#::Faalis::Group.find_by(role: 'guest')
if groups.empty?
guest_group = ::Faalis::Group.find_or_create_by(name: 'Guest',
role: 'guest')
self.groups << guest_group
end
end | [
"def",
"join_guests",
"#::Faalis::Group.find_by(role: 'guest')",
"if",
"groups",
".",
"empty?",
"guest_group",
"=",
"::",
"Faalis",
"::",
"Group",
".",
"find_or_create_by",
"(",
"name",
":",
"'Guest'",
",",
"role",
":",
"'guest'",
")",
"self",
".",
"groups",
"<<... | It's totally obviuse. Join the guest group if no group provided | [
"It",
"s",
"totally",
"obviuse",
".",
"Join",
"the",
"guest",
"group",
"if",
"no",
"group",
"provided"
] | d12abdb8559dabbf6b2044e3ba437038527039b2 | https://github.com/Yellowen/Faalis/blob/d12abdb8559dabbf6b2044e3ba437038527039b2/app/models/faalis/user.rb#L67-L74 |
2,901 | Yellowen/Faalis | lib/faalis/dashboard/dsl/base.rb | Faalis::Dashboard::DSL.Base.attributes | def attributes(*fields_name, **options, &block)
if options.include? :except
@fields = resolve_model_reflections.reject do |field|
options[:except].include? field.to_sym
end
elsif options.include? :append
@fields += options[:append]
else
# Check for valid fie... | ruby | def attributes(*fields_name, **options, &block)
if options.include? :except
@fields = resolve_model_reflections.reject do |field|
options[:except].include? field.to_sym
end
elsif options.include? :append
@fields += options[:append]
else
# Check for valid fie... | [
"def",
"attributes",
"(",
"*",
"fields_name",
",",
"**",
"options",
",",
"&",
"block",
")",
"if",
"options",
".",
"include?",
":except",
"@fields",
"=",
"resolve_model_reflections",
".",
"reject",
"do",
"|",
"field",
"|",
"options",
"[",
":except",
"]",
".... | Base class for all the DSL property classes to be
used as the yielded object inside each section DSL
scope.
For example the below code will yield an instance of
one of this class children.
in_index do
# This will yield an instance of this class child
end
The most important note in this class is that all... | [
"Base",
"class",
"for",
"all",
"the",
"DSL",
"property",
"classes",
"to",
"be",
"used",
"as",
"the",
"yielded",
"object",
"inside",
"each",
"section",
"DSL",
"scope",
"."
] | d12abdb8559dabbf6b2044e3ba437038527039b2 | https://github.com/Yellowen/Faalis/blob/d12abdb8559dabbf6b2044e3ba437038527039b2/lib/faalis/dashboard/dsl/base.rb#L32-L53 |
2,902 | Yellowen/Faalis | lib/faalis/dashboard/dsl/base.rb | Faalis::Dashboard::DSL.Base.resolve_model_reflections | def resolve_model_reflections
# TODO: cach the result using and instance_var or something
reflections = model.reflections
columns = Set.new model.column_names
new_fields = Set.new
fields_to_remove = Set.new
reflections.each do |name, column|
has_many = ActiveRecord::Ref... | ruby | def resolve_model_reflections
# TODO: cach the result using and instance_var or something
reflections = model.reflections
columns = Set.new model.column_names
new_fields = Set.new
fields_to_remove = Set.new
reflections.each do |name, column|
has_many = ActiveRecord::Ref... | [
"def",
"resolve_model_reflections",
"# TODO: cach the result using and instance_var or something",
"reflections",
"=",
"model",
".",
"reflections",
"columns",
"=",
"Set",
".",
"new",
"model",
".",
"column_names",
"new_fields",
"=",
"Set",
".",
"new",
"fields_to_remove",
"... | Replace foreign key names with their reflection names
and create an array of model fields | [
"Replace",
"foreign",
"key",
"names",
"with",
"their",
"reflection",
"names",
"and",
"create",
"an",
"array",
"of",
"model",
"fields"
] | d12abdb8559dabbf6b2044e3ba437038527039b2 | https://github.com/Yellowen/Faalis/blob/d12abdb8559dabbf6b2044e3ba437038527039b2/lib/faalis/dashboard/dsl/base.rb#L103-L131 |
2,903 | kjvarga/ajax | lib/ajax/application.rb | Ajax.Application.rails? | def rails?(*args)
version, comparator = args.pop, (args.pop || :==)
result =
if version.nil?
defined?(::Rails)
elsif defined?(::Rails)
if ::Rails.respond_to?(:version)
rails_version = Rails.version.to_f
rails_version = rails_version.floor if versio... | ruby | def rails?(*args)
version, comparator = args.pop, (args.pop || :==)
result =
if version.nil?
defined?(::Rails)
elsif defined?(::Rails)
if ::Rails.respond_to?(:version)
rails_version = Rails.version.to_f
rails_version = rails_version.floor if versio... | [
"def",
"rails?",
"(",
"*",
"args",
")",
"version",
",",
"comparator",
"=",
"args",
".",
"pop",
",",
"(",
"args",
".",
"pop",
"||",
":==",
")",
"result",
"=",
"if",
"version",
".",
"nil?",
"defined?",
"(",
"::",
"Rails",
")",
"elsif",
"defined?",
"(... | Return a boolean indicating whether the Rails constant is defined.
It cannot identify Rails < 2.1
Example:
rails?(3) => true if Rails major version is 3
rails?(3.0) => true if Rails major.minor version is 3.0
rails?(:>=, 3) => true if Rails major version is >= 3
rails?(:>=, 3.1) => true if Rails major.minor vers... | [
"Return",
"a",
"boolean",
"indicating",
"whether",
"the",
"Rails",
"constant",
"is",
"defined",
".",
"It",
"cannot",
"identify",
"Rails",
"<",
"2",
".",
"1"
] | e60acbc51855cd85b4907d509ea41fe0965ce72e | https://github.com/kjvarga/ajax/blob/e60acbc51855cd85b4907d509ea41fe0965ce72e/lib/ajax/application.rb#L15-L32 |
2,904 | kjvarga/ajax | lib/ajax/application.rb | Ajax.Application.init | def init
return unless rails?
if rails?(:>=, 3)
require 'ajax/railtie'
else
require 'ajax/action_controller'
require 'ajax/action_view'
Ajax.logger = ::Rails.logger
# Customize rendering. Include custom headers and don't render the layout for AJAX.
::... | ruby | def init
return unless rails?
if rails?(:>=, 3)
require 'ajax/railtie'
else
require 'ajax/action_controller'
require 'ajax/action_view'
Ajax.logger = ::Rails.logger
# Customize rendering. Include custom headers and don't render the layout for AJAX.
::... | [
"def",
"init",
"return",
"unless",
"rails?",
"if",
"rails?",
"(",
":>=",
",",
"3",
")",
"require",
"'ajax/railtie'",
"else",
"require",
"'ajax/action_controller'",
"require",
"'ajax/action_view'",
"Ajax",
".",
"logger",
"=",
"::",
"Rails",
".",
"logger",
"# Cust... | Include framework hooks for Rails
This method is called by <tt>init.rb</tt>, which is run by Rails on startup.
Customize rendering. Include custom headers and don't render the layout for AJAX.
Insert the Rack::Ajax middleware to rewrite and handle requests.
Add custom attributes to outgoing links.
Hooks for Ra... | [
"Include",
"framework",
"hooks",
"for",
"Rails"
] | e60acbc51855cd85b4907d509ea41fe0965ce72e | https://github.com/kjvarga/ajax/blob/e60acbc51855cd85b4907d509ea41fe0965ce72e/lib/ajax/application.rb#L47-L66 |
2,905 | opulent/opulent | lib/opulent/compiler/eval.rb | Opulent.Compiler.evaluate | def evaluate(node, indent)
# Check if this is a substructure of a control block and remove the last
# end evaluation if it is
if node[@value] =~ Settings::END_REMOVAL
@template.pop if @template[-1] == [:eval, 'end']
end
# Check for explicit end node
if node[@value] =~ Settin... | ruby | def evaluate(node, indent)
# Check if this is a substructure of a control block and remove the last
# end evaluation if it is
if node[@value] =~ Settings::END_REMOVAL
@template.pop if @template[-1] == [:eval, 'end']
end
# Check for explicit end node
if node[@value] =~ Settin... | [
"def",
"evaluate",
"(",
"node",
",",
"indent",
")",
"# Check if this is a substructure of a control block and remove the last",
"# end evaluation if it is",
"if",
"node",
"[",
"@value",
"]",
"=~",
"Settings",
"::",
"END_REMOVAL",
"@template",
".",
"pop",
"if",
"@template"... | Evaluate the embedded ruby code using the current context
@param node [Array] Node code generation data
@param indent [Fixnum] Size of the indentation to be added | [
"Evaluate",
"the",
"embedded",
"ruby",
"code",
"using",
"the",
"current",
"context"
] | 7b219bd4f54b404e8f43955b8e70925a01814b59 | https://github.com/opulent/opulent/blob/7b219bd4f54b404e8f43955b8e70925a01814b59/lib/opulent/compiler/eval.rb#L10-L32 |
2,906 | Yellowen/Faalis | lib/faalis/routes.rb | Faalis.RouteHelpers.localized_scope | def localized_scope
langs = ::I18n.available_locales.join('|')
scope '(:locale)', locale: Regexp.new(langs) do
yield
end
end | ruby | def localized_scope
langs = ::I18n.available_locales.join('|')
scope '(:locale)', locale: Regexp.new(langs) do
yield
end
end | [
"def",
"localized_scope",
"langs",
"=",
"::",
"I18n",
".",
"available_locales",
".",
"join",
"(",
"'|'",
")",
"scope",
"'(:locale)'",
",",
"locale",
":",
"Regexp",
".",
"new",
"(",
"langs",
")",
"do",
"yield",
"end",
"end"
] | Allow localized scope | [
"Allow",
"localized",
"scope"
] | d12abdb8559dabbf6b2044e3ba437038527039b2 | https://github.com/Yellowen/Faalis/blob/d12abdb8559dabbf6b2044e3ba437038527039b2/lib/faalis/routes.rb#L12-L17 |
2,907 | Yellowen/Faalis | lib/faalis/routes.rb | Faalis.RouteHelpers.api_routes | def api_routes(version: :v1)
# TODO: Add a dynamic solution for formats
namespace :api, defaults: { format: :json } do
namespace version do
# Call user given block to define user routes
# inside this namespace
yield if block_given?
end
end
scope 'mo... | ruby | def api_routes(version: :v1)
# TODO: Add a dynamic solution for formats
namespace :api, defaults: { format: :json } do
namespace version do
# Call user given block to define user routes
# inside this namespace
yield if block_given?
end
end
scope 'mo... | [
"def",
"api_routes",
"(",
"version",
":",
":v1",
")",
"# TODO: Add a dynamic solution for formats",
"namespace",
":api",
",",
"defaults",
":",
"{",
"format",
":",
":json",
"}",
"do",
"namespace",
"version",
"do",
"# Call user given block to define user routes",
"# insid... | This method allow user to define his routes in api
namespace | [
"This",
"method",
"allow",
"user",
"to",
"define",
"his",
"routes",
"in",
"api",
"namespace"
] | d12abdb8559dabbf6b2044e3ba437038527039b2 | https://github.com/Yellowen/Faalis/blob/d12abdb8559dabbf6b2044e3ba437038527039b2/lib/faalis/routes.rb#L21-L50 |
2,908 | beatrichartz/configurations | lib/configurations/configuration.rb | Configurations.Configuration.to_h | def to_h
@data.reduce({}) do |h, (k, v)|
h[k] = v.is_a?(__class__) ? v.to_h : v
h
end
end | ruby | def to_h
@data.reduce({}) do |h, (k, v)|
h[k] = v.is_a?(__class__) ? v.to_h : v
h
end
end | [
"def",
"to_h",
"@data",
".",
"reduce",
"(",
"{",
"}",
")",
"do",
"|",
"h",
",",
"(",
"k",
",",
"v",
")",
"|",
"h",
"[",
"k",
"]",
"=",
"v",
".",
"is_a?",
"(",
"__class__",
")",
"?",
"v",
".",
"to_h",
":",
"v",
"h",
"end",
"end"
] | A convenience accessor to get a hash representation of the
current state of the configuration
@return [Hash] the configuration in hash form | [
"A",
"convenience",
"accessor",
"to",
"get",
"a",
"hash",
"representation",
"of",
"the",
"current",
"state",
"of",
"the",
"configuration"
] | bd8ef480ca831e29b821ffc9ebeaed4ef46a9db2 | https://github.com/beatrichartz/configurations/blob/bd8ef480ca831e29b821ffc9ebeaed4ef46a9db2/lib/configurations/configuration.rb#L59-L65 |
2,909 | beatrichartz/configurations | lib/configurations/configuration.rb | Configurations.Configuration.from_h | def from_h(h)
@key_ambiguity_validator.validate!(h)
h.each do |property, value|
p = property.to_sym
if value.is_a?(::Hash) && __nested?(p)
@data[p].from_h(value)
elsif __configurable?(p)
__assign!(p, value)
end
end
self
end | ruby | def from_h(h)
@key_ambiguity_validator.validate!(h)
h.each do |property, value|
p = property.to_sym
if value.is_a?(::Hash) && __nested?(p)
@data[p].from_h(value)
elsif __configurable?(p)
__assign!(p, value)
end
end
self
end | [
"def",
"from_h",
"(",
"h",
")",
"@key_ambiguity_validator",
".",
"validate!",
"(",
"h",
")",
"h",
".",
"each",
"do",
"|",
"property",
",",
"value",
"|",
"p",
"=",
"property",
".",
"to_sym",
"if",
"value",
".",
"is_a?",
"(",
"::",
"Hash",
")",
"&&",
... | A convenience accessor to instantiate a configuration from a hash
@param [Hash] h the hash to read into the configuration
@return [Configuration] the configuration with values assigned
@raise [ConfigurationError] if the given hash ambiguous values
- string and symbol keys with the same string value pointing to
... | [
"A",
"convenience",
"accessor",
"to",
"instantiate",
"a",
"configuration",
"from",
"a",
"hash"
] | bd8ef480ca831e29b821ffc9ebeaed4ef46a9db2 | https://github.com/beatrichartz/configurations/blob/bd8ef480ca831e29b821ffc9ebeaed4ef46a9db2/lib/configurations/configuration.rb#L74-L87 |
2,910 | opulent/opulent | lib/opulent/compiler/control.rb | Opulent.Compiler.if_node | def if_node(node, indent)
# Check if we have any condition met, or an else branch
node[@value].each_with_index do |value, index|
# If we have a branch that meets the condition, generate code for the
# children related to that specific branch
case value
when node[@value].first... | ruby | def if_node(node, indent)
# Check if we have any condition met, or an else branch
node[@value].each_with_index do |value, index|
# If we have a branch that meets the condition, generate code for the
# children related to that specific branch
case value
when node[@value].first... | [
"def",
"if_node",
"(",
"node",
",",
"indent",
")",
"# Check if we have any condition met, or an else branch",
"node",
"[",
"@value",
"]",
".",
"each_with_index",
"do",
"|",
"value",
",",
"index",
"|",
"# If we have a branch that meets the condition, generate code for the",
... | Generate the code for a if-elsif-else control structure
@param node [Array] Node code generation data
@param indent [Fixnum] Size of the indentation to be added | [
"Generate",
"the",
"code",
"for",
"a",
"if",
"-",
"elsif",
"-",
"else",
"control",
"structure"
] | 7b219bd4f54b404e8f43955b8e70925a01814b59 | https://github.com/opulent/opulent/blob/7b219bd4f54b404e8f43955b8e70925a01814b59/lib/opulent/compiler/control.rb#L10-L29 |
2,911 | opulent/opulent | lib/opulent/compiler/control.rb | Opulent.Compiler.unless_node | def unless_node(node, indent)
# Check if we have any condition met, or an else branch
node[@value].each_with_index do |value, index|
# If we have a branch that meets the condition, generate code for the
# children related to that specific branch
case value
when node[@value].f... | ruby | def unless_node(node, indent)
# Check if we have any condition met, or an else branch
node[@value].each_with_index do |value, index|
# If we have a branch that meets the condition, generate code for the
# children related to that specific branch
case value
when node[@value].f... | [
"def",
"unless_node",
"(",
"node",
",",
"indent",
")",
"# Check if we have any condition met, or an else branch",
"node",
"[",
"@value",
"]",
".",
"each_with_index",
"do",
"|",
"value",
",",
"index",
"|",
"# If we have a branch that meets the condition, generate code for the"... | Generate the code for a unless-else control structure
@param node [Array] Node code generation data
@param indent [Fixnum] Size of the indentation to be added | [
"Generate",
"the",
"code",
"for",
"a",
"unless",
"-",
"else",
"control",
"structure"
] | 7b219bd4f54b404e8f43955b8e70925a01814b59 | https://github.com/opulent/opulent/blob/7b219bd4f54b404e8f43955b8e70925a01814b59/lib/opulent/compiler/control.rb#L36-L54 |
2,912 | opulent/opulent | lib/opulent/compiler/control.rb | Opulent.Compiler.case_node | def case_node(node, indent)
# Evaluate the switching condition
buffer_eval "case #{node[@options][:condition]}"
# Check if we have any condition met, or an else branch
node[@value].each_with_index do |value, index|
# If we have a branch that meets the condition, generate code for the
... | ruby | def case_node(node, indent)
# Evaluate the switching condition
buffer_eval "case #{node[@options][:condition]}"
# Check if we have any condition met, or an else branch
node[@value].each_with_index do |value, index|
# If we have a branch that meets the condition, generate code for the
... | [
"def",
"case_node",
"(",
"node",
",",
"indent",
")",
"# Evaluate the switching condition",
"buffer_eval",
"\"case #{node[@options][:condition]}\"",
"# Check if we have any condition met, or an else branch",
"node",
"[",
"@value",
"]",
".",
"each_with_index",
"do",
"|",
"value",... | Generate the code for a case-when-else control structure
@param node [Array] Node code generation data
@param indent [Fixnum] Size of the indentation to be added | [
"Generate",
"the",
"code",
"for",
"a",
"case",
"-",
"when",
"-",
"else",
"control",
"structure"
] | 7b219bd4f54b404e8f43955b8e70925a01814b59 | https://github.com/opulent/opulent/blob/7b219bd4f54b404e8f43955b8e70925a01814b59/lib/opulent/compiler/control.rb#L61-L82 |
2,913 | mdub/representative | lib/representative/nokogiri.rb | Representative.Nokogiri.comment | def comment(text)
comment_node = ::Nokogiri::XML::Comment.new(doc, " #{text} ")
current_element.add_child(comment_node)
end | ruby | def comment(text)
comment_node = ::Nokogiri::XML::Comment.new(doc, " #{text} ")
current_element.add_child(comment_node)
end | [
"def",
"comment",
"(",
"text",
")",
"comment_node",
"=",
"::",
"Nokogiri",
"::",
"XML",
"::",
"Comment",
".",
"new",
"(",
"doc",
",",
"\" #{text} \"",
")",
"current_element",
".",
"add_child",
"(",
"comment_node",
")",
"end"
] | Generate a comment | [
"Generate",
"a",
"comment"
] | c60214e79d51581a1744ae2891094468416b88f9 | https://github.com/mdub/representative/blob/c60214e79d51581a1744ae2891094468416b88f9/lib/representative/nokogiri.rb#L33-L36 |
2,914 | opulent/opulent | lib/opulent/parser/node.rb | Opulent.Parser.node | def node(parent, indent = nil)
return unless (name = lookahead(:node_lookahead) ||
lookahead(:shorthand_lookahead))
# Skip node if it's a reserved keyword
return nil if KEYWORDS.include? name[0].to_sym
# Accept either explicit node_name or implicit :div node_name
... | ruby | def node(parent, indent = nil)
return unless (name = lookahead(:node_lookahead) ||
lookahead(:shorthand_lookahead))
# Skip node if it's a reserved keyword
return nil if KEYWORDS.include? name[0].to_sym
# Accept either explicit node_name or implicit :div node_name
... | [
"def",
"node",
"(",
"parent",
",",
"indent",
"=",
"nil",
")",
"return",
"unless",
"(",
"name",
"=",
"lookahead",
"(",
":node_lookahead",
")",
"||",
"lookahead",
"(",
":shorthand_lookahead",
")",
")",
"# Skip node if it's a reserved keyword",
"return",
"nil",
"if... | Check if we match an node node with its attributes and possibly
inline text
node [ attributes ] Inline text
@param parent [Node] Parent node to which we append the node | [
"Check",
"if",
"we",
"match",
"an",
"node",
"node",
"with",
"its",
"attributes",
"and",
"possibly",
"inline",
"text"
] | 7b219bd4f54b404e8f43955b8e70925a01814b59 | https://github.com/opulent/opulent/blob/7b219bd4f54b404e8f43955b8e70925a01814b59/lib/opulent/parser/node.rb#L12-L87 |
2,915 | opulent/opulent | lib/opulent/parser/node.rb | Opulent.Parser.shorthand_attributes | def shorthand_attributes(atts = {})
while (key = accept :shorthand)
key = Settings::SHORTHAND[key.to_sym]
# Check whether the value is escaped or unescaped
escaped = accept(:unescaped_value) ? false : true
# Get the attribute value and process it
if (value = accept(:short... | ruby | def shorthand_attributes(atts = {})
while (key = accept :shorthand)
key = Settings::SHORTHAND[key.to_sym]
# Check whether the value is escaped or unescaped
escaped = accept(:unescaped_value) ? false : true
# Get the attribute value and process it
if (value = accept(:short... | [
"def",
"shorthand_attributes",
"(",
"atts",
"=",
"{",
"}",
")",
"while",
"(",
"key",
"=",
"accept",
":shorthand",
")",
"key",
"=",
"Settings",
"::",
"SHORTHAND",
"[",
"key",
".",
"to_sym",
"]",
"# Check whether the value is escaped or unescaped",
"escaped",
"=",... | Accept node shorthand attributes. Each shorthand attribute is directly
mapped to an attribute key
@param atts [Hash] Node attributes | [
"Accept",
"node",
"shorthand",
"attributes",
".",
"Each",
"shorthand",
"attribute",
"is",
"directly",
"mapped",
"to",
"an",
"attribute",
"key"
] | 7b219bd4f54b404e8f43955b8e70925a01814b59 | https://github.com/opulent/opulent/blob/7b219bd4f54b404e8f43955b8e70925a01814b59/lib/opulent/parser/node.rb#L164-L188 |
2,916 | opulent/opulent | lib/opulent/parser/node.rb | Opulent.Parser.attributes | def attributes(atts = {}, for_definition = false)
wrapped_attributes atts, for_definition
attributes_assignments atts, false, for_definition
atts
end | ruby | def attributes(atts = {}, for_definition = false)
wrapped_attributes atts, for_definition
attributes_assignments atts, false, for_definition
atts
end | [
"def",
"attributes",
"(",
"atts",
"=",
"{",
"}",
",",
"for_definition",
"=",
"false",
")",
"wrapped_attributes",
"atts",
",",
"for_definition",
"attributes_assignments",
"atts",
",",
"false",
",",
"for_definition",
"atts",
"end"
] | Get element attributes
@param atts [Hash] Accumulator for node attributes
@param for_definition [Boolean] Set default value in wrapped to nil | [
"Get",
"element",
"attributes"
] | 7b219bd4f54b404e8f43955b8e70925a01814b59 | https://github.com/opulent/opulent/blob/7b219bd4f54b404e8f43955b8e70925a01814b59/lib/opulent/parser/node.rb#L195-L199 |
2,917 | opulent/opulent | lib/opulent/parser/node.rb | Opulent.Parser.wrapped_attributes | def wrapped_attributes(list = {}, for_definition = false)
return unless (bracket = accept :brackets)
accept_newline
attributes_assignments list, true, for_definition
accept_newline
accept_stripped bracket.to_sym, :*
list
end | ruby | def wrapped_attributes(list = {}, for_definition = false)
return unless (bracket = accept :brackets)
accept_newline
attributes_assignments list, true, for_definition
accept_newline
accept_stripped bracket.to_sym, :*
list
end | [
"def",
"wrapped_attributes",
"(",
"list",
"=",
"{",
"}",
",",
"for_definition",
"=",
"false",
")",
"return",
"unless",
"(",
"bracket",
"=",
"accept",
":brackets",
")",
"accept_newline",
"attributes_assignments",
"list",
",",
"true",
",",
"for_definition",
"accep... | Check if we match node attributes
[ assignments ]
@param as_parameters [Boolean] Accept or reject identifier nodes | [
"Check",
"if",
"we",
"match",
"node",
"attributes"
] | 7b219bd4f54b404e8f43955b8e70925a01814b59 | https://github.com/opulent/opulent/blob/7b219bd4f54b404e8f43955b8e70925a01814b59/lib/opulent/parser/node.rb#L207-L217 |
2,918 | opulent/opulent | lib/opulent/parser/node.rb | Opulent.Parser.attributes_assignments | def attributes_assignments(list, wrapped = true, for_definition = false)
if wrapped && lookahead(:exp_identifier_stripped_lookahead).nil? ||
!wrapped && lookahead(:assignment_lookahead).nil?
return list
end
return unless (argument = accept_stripped :node)
argument = argument.t... | ruby | def attributes_assignments(list, wrapped = true, for_definition = false)
if wrapped && lookahead(:exp_identifier_stripped_lookahead).nil? ||
!wrapped && lookahead(:assignment_lookahead).nil?
return list
end
return unless (argument = accept_stripped :node)
argument = argument.t... | [
"def",
"attributes_assignments",
"(",
"list",
",",
"wrapped",
"=",
"true",
",",
"for_definition",
"=",
"false",
")",
"if",
"wrapped",
"&&",
"lookahead",
"(",
":exp_identifier_stripped_lookahead",
")",
".",
"nil?",
"||",
"!",
"wrapped",
"&&",
"lookahead",
"(",
... | Get all attribute assignments as key=value pairs or standalone keys
[ assignments ]
@param list [Hash] Parent to which we append nodes
@param as_parameters [Boolean] Accept or reject identifier nodes | [
"Get",
"all",
"attribute",
"assignments",
"as",
"key",
"=",
"value",
"pairs",
"or",
"standalone",
"keys"
] | 7b219bd4f54b404e8f43955b8e70925a01814b59 | https://github.com/opulent/opulent/blob/7b219bd4f54b404e8f43955b8e70925a01814b59/lib/opulent/parser/node.rb#L226-L281 |
2,919 | opulent/opulent | lib/opulent/parser/node.rb | Opulent.Parser.extend_attributes | def extend_attributes
return unless accept :extend_attributes
unescaped = accept :unescaped_value
extension = expression(false, false, false)
extension[@options][:escaped] = !unescaped
extension
end | ruby | def extend_attributes
return unless accept :extend_attributes
unescaped = accept :unescaped_value
extension = expression(false, false, false)
extension[@options][:escaped] = !unescaped
extension
end | [
"def",
"extend_attributes",
"return",
"unless",
"accept",
":extend_attributes",
"unescaped",
"=",
"accept",
":unescaped_value",
"extension",
"=",
"expression",
"(",
"false",
",",
"false",
",",
"false",
")",
"extension",
"[",
"@options",
"]",
"[",
":escaped",
"]",
... | Extend node attributes with hash from
+value
+{hash: "value"}
+(paranthesis) | [
"Extend",
"node",
"attributes",
"with",
"hash",
"from"
] | 7b219bd4f54b404e8f43955b8e70925a01814b59 | https://github.com/opulent/opulent/blob/7b219bd4f54b404e8f43955b8e70925a01814b59/lib/opulent/parser/node.rb#L289-L297 |
2,920 | opulent/opulent | lib/opulent/parser/root.rb | Opulent.Parser.root | def root(parent = @root, min_indent = -1)
while (@line = @code[(@i += 1)])
# Reset character position cursor
@j = 0
# Skip to next iteration if we have a blank line
next if @line =~ /\A\s*\Z/
# Reset the line offset
@offset = 0
# Parse the current line by... | ruby | def root(parent = @root, min_indent = -1)
while (@line = @code[(@i += 1)])
# Reset character position cursor
@j = 0
# Skip to next iteration if we have a blank line
next if @line =~ /\A\s*\Z/
# Reset the line offset
@offset = 0
# Parse the current line by... | [
"def",
"root",
"(",
"parent",
"=",
"@root",
",",
"min_indent",
"=",
"-",
"1",
")",
"while",
"(",
"@line",
"=",
"@code",
"[",
"(",
"@i",
"+=",
"1",
")",
"]",
")",
"# Reset character position cursor",
"@j",
"=",
"0",
"# Skip to next iteration if we have a blan... | Analyze the input code and check for matching tokens.
In case no match was found, throw an exception.
In special cases, modify the token hash.
@param parent [Array] Parent node to which we append to | [
"Analyze",
"the",
"input",
"code",
"and",
"check",
"for",
"matching",
"tokens",
".",
"In",
"case",
"no",
"match",
"was",
"found",
"throw",
"an",
"exception",
".",
"In",
"special",
"cases",
"modify",
"the",
"token",
"hash",
"."
] | 7b219bd4f54b404e8f43955b8e70925a01814b59 | https://github.com/opulent/opulent/blob/7b219bd4f54b404e8f43955b8e70925a01814b59/lib/opulent/parser/root.rb#L11-L57 |
2,921 | opulent/opulent | lib/opulent/compiler/define.rb | Opulent.Compiler.define | def define(node)
# Write out def method_name
definition = "def _opulent_definition_#{node[@value].to_s.tr '-', '_'}"
# Node attributes
parameters = []
node[@options][:parameters].each do |key, value|
parameters << "#{key} = #{value[@value]}"
end
parameters << 'attribut... | ruby | def define(node)
# Write out def method_name
definition = "def _opulent_definition_#{node[@value].to_s.tr '-', '_'}"
# Node attributes
parameters = []
node[@options][:parameters].each do |key, value|
parameters << "#{key} = #{value[@value]}"
end
parameters << 'attribut... | [
"def",
"define",
"(",
"node",
")",
"# Write out def method_name",
"definition",
"=",
"\"def _opulent_definition_#{node[@value].to_s.tr '-', '_'}\"",
"# Node attributes",
"parameters",
"=",
"[",
"]",
"node",
"[",
"@options",
"]",
"[",
":parameters",
"]",
".",
"each",
"do... | Write out definition node using ruby def
@param node [Node] Current node data with options | [
"Write",
"out",
"definition",
"node",
"using",
"ruby",
"def"
] | 7b219bd4f54b404e8f43955b8e70925a01814b59 | https://github.com/opulent/opulent/blob/7b219bd4f54b404e8f43955b8e70925a01814b59/lib/opulent/compiler/define.rb#L9-L34 |
2,922 | beatrichartz/configurations | lib/configurations/arbitrary.rb | Configurations.Arbitrary.respond_to_missing? | def respond_to_missing?(method, include_private = false)
__respond_to_writer?(method) ||
__respond_to_method_for_read?(method, *args, &block) ||
__respond_to_method_for_write?(method) ||
super
end | ruby | def respond_to_missing?(method, include_private = false)
__respond_to_writer?(method) ||
__respond_to_method_for_read?(method, *args, &block) ||
__respond_to_method_for_write?(method) ||
super
end | [
"def",
"respond_to_missing?",
"(",
"method",
",",
"include_private",
"=",
"false",
")",
"__respond_to_writer?",
"(",
"method",
")",
"||",
"__respond_to_method_for_read?",
"(",
"method",
",",
"args",
",",
"block",
")",
"||",
"__respond_to_method_for_write?",
"(",
"me... | Respond to missing according to the method_missing implementation | [
"Respond",
"to",
"missing",
"according",
"to",
"the",
"method_missing",
"implementation"
] | bd8ef480ca831e29b821ffc9ebeaed4ef46a9db2 | https://github.com/beatrichartz/configurations/blob/bd8ef480ca831e29b821ffc9ebeaed4ef46a9db2/lib/configurations/arbitrary.rb#L43-L48 |
2,923 | opulent/opulent | lib/opulent/parser.rb | Opulent.Parser.apply_definitions | def apply_definitions(node)
# Apply definition check to all of the node's children
process_definitions = proc do |children|
children.each do |child|
# Check if we have a definition
is_definition = if child[@value] == @current_def
child[@options][:recur... | ruby | def apply_definitions(node)
# Apply definition check to all of the node's children
process_definitions = proc do |children|
children.each do |child|
# Check if we have a definition
is_definition = if child[@value] == @current_def
child[@options][:recur... | [
"def",
"apply_definitions",
"(",
"node",
")",
"# Apply definition check to all of the node's children",
"process_definitions",
"=",
"proc",
"do",
"|",
"children",
"|",
"children",
".",
"each",
"do",
"|",
"child",
"|",
"# Check if we have a definition",
"is_definition",
"=... | Set each node as a defined node if a definition exists with the given
node name, unless we're inside a definition with the same name as the node
because we want to avoid recursion.
@param node [Node] Input Node to checked for existence of definitions | [
"Set",
"each",
"node",
"as",
"a",
"defined",
"node",
"if",
"a",
"definition",
"exists",
"with",
"the",
"given",
"node",
"name",
"unless",
"we",
"re",
"inside",
"a",
"definition",
"with",
"the",
"same",
"name",
"as",
"the",
"node",
"because",
"we",
"want"... | 7b219bd4f54b404e8f43955b8e70925a01814b59 | https://github.com/opulent/opulent/blob/7b219bd4f54b404e8f43955b8e70925a01814b59/lib/opulent/parser.rb#L93-L121 |
2,924 | opulent/opulent | lib/opulent/parser.rb | Opulent.Parser.accept | def accept(token, required = false, strip = false)
# Consume leading whitespace if we want to ignore it
accept :whitespace if strip
# We reached the end of the parsing process and there are no more lines
# left to parse
return nil unless @line
# Match the token to the current line.... | ruby | def accept(token, required = false, strip = false)
# Consume leading whitespace if we want to ignore it
accept :whitespace if strip
# We reached the end of the parsing process and there are no more lines
# left to parse
return nil unless @line
# Match the token to the current line.... | [
"def",
"accept",
"(",
"token",
",",
"required",
"=",
"false",
",",
"strip",
"=",
"false",
")",
"# Consume leading whitespace if we want to ignore it",
"accept",
":whitespace",
"if",
"strip",
"# We reached the end of the parsing process and there are no more lines",
"# left to p... | Check and accept or reject a given token as long as we have tokens
remaining. Shift the code with the match length plus any extra character
count around the capture group
@param token [RegEx] Token to be accepted by the parser
@param required [Boolean] Expect the given token syntax
@param strip [Boolean] Left str... | [
"Check",
"and",
"accept",
"or",
"reject",
"a",
"given",
"token",
"as",
"long",
"as",
"we",
"have",
"tokens",
"remaining",
".",
"Shift",
"the",
"code",
"with",
"the",
"match",
"length",
"plus",
"any",
"extra",
"character",
"count",
"around",
"the",
"capture... | 7b219bd4f54b404e8f43955b8e70925a01814b59 | https://github.com/opulent/opulent/blob/7b219bd4f54b404e8f43955b8e70925a01814b59/lib/opulent/parser.rb#L131-L150 |
2,925 | opulent/opulent | lib/opulent/parser.rb | Opulent.Parser.indent_lines | def indent_lines(text, indent)
text ||= ''
text.lines.map { |line| indent + line }.join
end | ruby | def indent_lines(text, indent)
text ||= ''
text.lines.map { |line| indent + line }.join
end | [
"def",
"indent_lines",
"(",
"text",
",",
"indent",
")",
"text",
"||=",
"''",
"text",
".",
"lines",
".",
"map",
"{",
"|",
"line",
"|",
"indent",
"+",
"line",
"}",
".",
"join",
"end"
] | Indent all lines of the input text using give indentation
@param text [String] Input text to be indented
@param indent [String] Indentation string to be appended | [
"Indent",
"all",
"lines",
"of",
"the",
"input",
"text",
"using",
"give",
"indentation"
] | 7b219bd4f54b404e8f43955b8e70925a01814b59 | https://github.com/opulent/opulent/blob/7b219bd4f54b404e8f43955b8e70925a01814b59/lib/opulent/parser.rb#L210-L213 |
2,926 | redbooth/redbooth-ruby | lib/redbooth-ruby/client.rb | RedboothRuby.Client.perform! | def perform!(resource_name, action, options = {})
ClientOperations::Perform.new(resource_name, action, session, options).perform!
end | ruby | def perform!(resource_name, action, options = {})
ClientOperations::Perform.new(resource_name, action, session, options).perform!
end | [
"def",
"perform!",
"(",
"resource_name",
",",
"action",
",",
"options",
"=",
"{",
"}",
")",
"ClientOperations",
"::",
"Perform",
".",
"new",
"(",
"resource_name",
",",
"action",
",",
"session",
",",
"options",
")",
".",
"perform!",
"end"
] | Executes block with the access token
@param [String||Symbol] resource_name name of the resource to execute over
@param [String||Symbol] action name of the action to execute over
@param [Hash] options for the execution
@return the execution return or nil | [
"Executes",
"block",
"with",
"the",
"access",
"token"
] | fb6bc228a9346d4db476032f0df16c9588fdfbe1 | https://github.com/redbooth/redbooth-ruby/blob/fb6bc228a9346d4db476032f0df16c9588fdfbe1/lib/redbooth-ruby/client.rb#L55-L57 |
2,927 | Yellowen/Faalis | app/models/faalis/concerns/user/auth_definitions.rb | Faalis.Concerns::User::AuthDefinitions.password_required? | def password_required?
# TODO: nil? is not suitable for here we should use empty? or blink?
if Devise.omniauth_configs.any?
return (provider.nil? || password.nil?) && super
else
password.nil? && super
end
end | ruby | def password_required?
# TODO: nil? is not suitable for here we should use empty? or blink?
if Devise.omniauth_configs.any?
return (provider.nil? || password.nil?) && super
else
password.nil? && super
end
end | [
"def",
"password_required?",
"# TODO: nil? is not suitable for here we should use empty? or blink?",
"if",
"Devise",
".",
"omniauth_configs",
".",
"any?",
"return",
"(",
"provider",
".",
"nil?",
"||",
"password",
".",
"nil?",
")",
"&&",
"super",
"else",
"password",
".",... | Omniauth users does not need password | [
"Omniauth",
"users",
"does",
"not",
"need",
"password"
] | d12abdb8559dabbf6b2044e3ba437038527039b2 | https://github.com/Yellowen/Faalis/blob/d12abdb8559dabbf6b2044e3ba437038527039b2/app/models/faalis/concerns/user/auth_definitions.rb#L51-L58 |
2,928 | redbooth/redbooth-ruby | lib/redbooth-ruby/file.rb | RedboothRuby.File.download | def download(style='original', path=nil)
options = { session: session }
options[:download_path] = path unless path.nil?
request = RedboothRuby.request(:download, nil, "files/#{id}/download/#{style}/#{name}", {}, options)
request.body
end | ruby | def download(style='original', path=nil)
options = { session: session }
options[:download_path] = path unless path.nil?
request = RedboothRuby.request(:download, nil, "files/#{id}/download/#{style}/#{name}", {}, options)
request.body
end | [
"def",
"download",
"(",
"style",
"=",
"'original'",
",",
"path",
"=",
"nil",
")",
"options",
"=",
"{",
"session",
":",
"session",
"}",
"options",
"[",
":download_path",
"]",
"=",
"path",
"unless",
"path",
".",
"nil?",
"request",
"=",
"RedboothRuby",
".",... | Returns a blop with the file data
@param [String] style The style to use
@param [String] path The path to save the file to
@return [String] the object metadata | [
"Returns",
"a",
"blop",
"with",
"the",
"file",
"data"
] | fb6bc228a9346d4db476032f0df16c9588fdfbe1 | https://github.com/redbooth/redbooth-ruby/blob/fb6bc228a9346d4db476032f0df16c9588fdfbe1/lib/redbooth-ruby/file.rb#L32-L37 |
2,929 | opulent/opulent | lib/opulent/engine.rb | Opulent.Engine.render | def render(scope = Object.new, locals = {}, &block)
# Get opulent buffer value
if scope.instance_variable_defined?(:@_opulent_buffer)
initial_buffer = scope.instance_variable_get(:@_opulent_buffer)
else
initial_buffer = []
end
# If a layout is set, get the specific layout,... | ruby | def render(scope = Object.new, locals = {}, &block)
# Get opulent buffer value
if scope.instance_variable_defined?(:@_opulent_buffer)
initial_buffer = scope.instance_variable_get(:@_opulent_buffer)
else
initial_buffer = []
end
# If a layout is set, get the specific layout,... | [
"def",
"render",
"(",
"scope",
"=",
"Object",
".",
"new",
",",
"locals",
"=",
"{",
"}",
",",
"&",
"block",
")",
"# Get opulent buffer value",
"if",
"scope",
".",
"instance_variable_defined?",
"(",
":@_opulent_buffer",
")",
"initial_buffer",
"=",
"scope",
".",
... | Update render settings
@param input [Symbol/String] Input code or file
@param settings [Hash] Opulent settings override
Avoid code duplication when layouting is set. When we have a layout, look
in layouts/application by default.
@param scope [Object] Template evaluation context
@param locals [Hash] Render call... | [
"Update",
"render",
"settings"
] | 7b219bd4f54b404e8f43955b8e70925a01814b59 | https://github.com/opulent/opulent/blob/7b219bd4f54b404e8f43955b8e70925a01814b59/lib/opulent/engine.rb#L50-L88 |
2,930 | opulent/opulent | lib/opulent/engine.rb | Opulent.Engine.read | def read(input)
if input.is_a? Symbol
@file = File.expand_path get_eval_file input
File.read @file
else
@file = File.expand_path __FILE__
input
end
end | ruby | def read(input)
if input.is_a? Symbol
@file = File.expand_path get_eval_file input
File.read @file
else
@file = File.expand_path __FILE__
input
end
end | [
"def",
"read",
"(",
"input",
")",
"if",
"input",
".",
"is_a?",
"Symbol",
"@file",
"=",
"File",
".",
"expand_path",
"get_eval_file",
"input",
"File",
".",
"read",
"@file",
"else",
"@file",
"=",
"File",
".",
"expand_path",
"__FILE__",
"input",
"end",
"end"
] | Read input as file or string input
@param input [Object] | [
"Read",
"input",
"as",
"file",
"or",
"string",
"input"
] | 7b219bd4f54b404e8f43955b8e70925a01814b59 | https://github.com/opulent/opulent/blob/7b219bd4f54b404e8f43955b8e70925a01814b59/lib/opulent/engine.rb#L96-L104 |
2,931 | opulent/opulent | lib/opulent/engine.rb | Opulent.Engine.get_eval_file | def get_eval_file(input)
input = input.to_s
unless File.extname(input) == Settings::FILE_EXTENSION
input += Settings::FILE_EXTENSION
end
input
end | ruby | def get_eval_file(input)
input = input.to_s
unless File.extname(input) == Settings::FILE_EXTENSION
input += Settings::FILE_EXTENSION
end
input
end | [
"def",
"get_eval_file",
"(",
"input",
")",
"input",
"=",
"input",
".",
"to_s",
"unless",
"File",
".",
"extname",
"(",
"input",
")",
"==",
"Settings",
"::",
"FILE_EXTENSION",
"input",
"+=",
"Settings",
"::",
"FILE_EXTENSION",
"end",
"input",
"end"
] | Add .op extension to input file if it isn't already set.
@param input [Symbol] Input file | [
"Add",
".",
"op",
"extension",
"to",
"input",
"file",
"if",
"it",
"isn",
"t",
"already",
"set",
"."
] | 7b219bd4f54b404e8f43955b8e70925a01814b59 | https://github.com/opulent/opulent/blob/7b219bd4f54b404e8f43955b8e70925a01814b59/lib/opulent/engine.rb#L110-L116 |
2,932 | opulent/opulent | lib/opulent/compiler/buffer.rb | Opulent.Compiler.buffer_attributes_to_hash | def buffer_attributes_to_hash(attributes)
'{' + attributes.inject([]) do |extend_map, (key, attribute)|
extend_map << (
":\"#{key}\" => " + if key == :class
'[' + attribute.map do |exp|
exp[@value]
... | ruby | def buffer_attributes_to_hash(attributes)
'{' + attributes.inject([]) do |extend_map, (key, attribute)|
extend_map << (
":\"#{key}\" => " + if key == :class
'[' + attribute.map do |exp|
exp[@value]
... | [
"def",
"buffer_attributes_to_hash",
"(",
"attributes",
")",
"'{'",
"+",
"attributes",
".",
"inject",
"(",
"[",
"]",
")",
"do",
"|",
"extend_map",
",",
"(",
"key",
",",
"attribute",
")",
"|",
"extend_map",
"<<",
"(",
"\":\\\"#{key}\\\" => \"",
"+",
"if",
"k... | Turn call node attributes into a hash string
@param attributes [Array] Array of node attributes | [
"Turn",
"call",
"node",
"attributes",
"into",
"a",
"hash",
"string"
] | 7b219bd4f54b404e8f43955b8e70925a01814b59 | https://github.com/opulent/opulent/blob/7b219bd4f54b404e8f43955b8e70925a01814b59/lib/opulent/compiler/buffer.rb#L88-L100 |
2,933 | opulent/opulent | lib/opulent/compiler/buffer.rb | Opulent.Compiler.buffer_attributes | def buffer_attributes(attributes, extension)
# Proc for setting class attribute extension, used as DRY closure
#
buffer_class_attribute_type_check = proc do |variable, escape = true|
class_variable = buffer_set_variable :local, variable
# Check if we need to add the class attribute
... | ruby | def buffer_attributes(attributes, extension)
# Proc for setting class attribute extension, used as DRY closure
#
buffer_class_attribute_type_check = proc do |variable, escape = true|
class_variable = buffer_set_variable :local, variable
# Check if we need to add the class attribute
... | [
"def",
"buffer_attributes",
"(",
"attributes",
",",
"extension",
")",
"# Proc for setting class attribute extension, used as DRY closure",
"#",
"buffer_class_attribute_type_check",
"=",
"proc",
"do",
"|",
"variable",
",",
"escape",
"=",
"true",
"|",
"class_variable",
"=",
... | Go through the node attributes and apply extension where needed
@param attributes [Array] Array of node attributes, from parser
@param extension [String] Extension identifier | [
"Go",
"through",
"the",
"node",
"attributes",
"and",
"apply",
"extension",
"where",
"needed"
] | 7b219bd4f54b404e8f43955b8e70925a01814b59 | https://github.com/opulent/opulent/blob/7b219bd4f54b404e8f43955b8e70925a01814b59/lib/opulent/compiler/buffer.rb#L107-L307 |
2,934 | opulent/opulent | lib/opulent/compiler/buffer.rb | Opulent.Compiler.buffer_split_by_interpolation | def buffer_split_by_interpolation(string, escape = true)
# Interpolate variables in text (#{variable}).
# Split the text into multiple dynamic and static parts.
begin
case string
when /\A\\\#\{/
# Escaped interpolation
buffer_freeze '#{'
string = $'
... | ruby | def buffer_split_by_interpolation(string, escape = true)
# Interpolate variables in text (#{variable}).
# Split the text into multiple dynamic and static parts.
begin
case string
when /\A\\\#\{/
# Escaped interpolation
buffer_freeze '#{'
string = $'
... | [
"def",
"buffer_split_by_interpolation",
"(",
"string",
",",
"escape",
"=",
"true",
")",
"# Interpolate variables in text (#{variable}).",
"# Split the text into multiple dynamic and static parts.",
"begin",
"case",
"string",
"when",
"/",
"\\A",
"\\\\",
"\\#",
"\\{",
"/",
"#... | Split a string by its interpolation, then check if it really needs to be
escaped or not. Huge performance boost!
@param string [String] Input string
@param escape [Boolean] Escape string
@ref slim-lang Thank you for the interpolation code | [
"Split",
"a",
"string",
"by",
"its",
"interpolation",
"then",
"check",
"if",
"it",
"really",
"needs",
"to",
"be",
"escaped",
"or",
"not",
".",
"Huge",
"performance",
"boost!"
] | 7b219bd4f54b404e8f43955b8e70925a01814b59 | https://github.com/opulent/opulent/blob/7b219bd4f54b404e8f43955b8e70925a01814b59/lib/opulent/compiler/buffer.rb#L339-L373 |
2,935 | beatrichartz/configurations | lib/configurations/strict.rb | Configurations.Strict.__evaluate_configurable! | def __evaluate_configurable!
entries = @properties.entries_at(@path)
entries.each do |property, value|
if value.is_a?(Maps::Properties::Entry)
__install_property__(property)
else
__install_nested_getter__(property)
end
end
end | ruby | def __evaluate_configurable!
entries = @properties.entries_at(@path)
entries.each do |property, value|
if value.is_a?(Maps::Properties::Entry)
__install_property__(property)
else
__install_nested_getter__(property)
end
end
end | [
"def",
"__evaluate_configurable!",
"entries",
"=",
"@properties",
".",
"entries_at",
"(",
"@path",
")",
"entries",
".",
"each",
"do",
"|",
"property",
",",
"value",
"|",
"if",
"value",
".",
"is_a?",
"(",
"Maps",
"::",
"Properties",
"::",
"Entry",
")",
"__i... | Evaluates configurable properties and passes eventual hashes
down to subconfigurations | [
"Evaluates",
"configurable",
"properties",
"and",
"passes",
"eventual",
"hashes",
"down",
"to",
"subconfigurations"
] | bd8ef480ca831e29b821ffc9ebeaed4ef46a9db2 | https://github.com/beatrichartz/configurations/blob/bd8ef480ca831e29b821ffc9ebeaed4ef46a9db2/lib/configurations/strict.rb#L36-L45 |
2,936 | beatrichartz/configurations | lib/configurations/strict.rb | Configurations.Strict.__assign! | def __assign!(property, value)
@types.test!(@path.add(property), value)
v = @blocks.evaluate!(@path.add(property), value)
value = v unless v.nil?
super(property, value)
end | ruby | def __assign!(property, value)
@types.test!(@path.add(property), value)
v = @blocks.evaluate!(@path.add(property), value)
value = v unless v.nil?
super(property, value)
end | [
"def",
"__assign!",
"(",
"property",
",",
"value",
")",
"@types",
".",
"test!",
"(",
"@path",
".",
"add",
"(",
"property",
")",
",",
"value",
")",
"v",
"=",
"@blocks",
".",
"evaluate!",
"(",
"@path",
".",
"add",
"(",
"property",
")",
",",
"value",
... | Assigns a value after running the assertions
@param [Symbol] property the property to type test
@param [Any] value the given value | [
"Assigns",
"a",
"value",
"after",
"running",
"the",
"assertions"
] | bd8ef480ca831e29b821ffc9ebeaed4ef46a9db2 | https://github.com/beatrichartz/configurations/blob/bd8ef480ca831e29b821ffc9ebeaed4ef46a9db2/lib/configurations/strict.rb#L109-L115 |
2,937 | mdub/representative | lib/representative/abstract_xml.rb | Representative.AbstractXml.element | def element(name, *args, &block)
metadata = @inspector.get_metadata(current_subject, name)
attributes = args.extract_options!.merge(metadata)
subject_of_element = if args.empty?
@inspector.get_value(current_subject, name)
else
args.shift
end
raise ArgumentError, "t... | ruby | def element(name, *args, &block)
metadata = @inspector.get_metadata(current_subject, name)
attributes = args.extract_options!.merge(metadata)
subject_of_element = if args.empty?
@inspector.get_value(current_subject, name)
else
args.shift
end
raise ArgumentError, "t... | [
"def",
"element",
"(",
"name",
",",
"*",
"args",
",",
"&",
"block",
")",
"metadata",
"=",
"@inspector",
".",
"get_metadata",
"(",
"current_subject",
",",
"name",
")",
"attributes",
"=",
"args",
".",
"extract_options!",
".",
"merge",
"(",
"metadata",
")",
... | Generate an element.
With two arguments, it generates an element with the specified text content.
r.element :size, 42
# => <size>42</size>
More commonly, though, the second argument is omitted, in which case the
element content is assumed to be the named property of the current #subject.
r.representing ... | [
"Generate",
"an",
"element",
"."
] | c60214e79d51581a1744ae2891094468416b88f9 | https://github.com/mdub/representative/blob/c60214e79d51581a1744ae2891094468416b88f9/lib/representative/abstract_xml.rb#L45-L77 |
2,938 | mdub/representative | lib/representative/abstract_xml.rb | Representative.AbstractXml.list_of | def list_of(name, *args, &block)
options = args.extract_options!
list_subject = args.empty? ? name : args.shift
raise ArgumentError, "too many arguments" unless args.empty?
list_attributes = options[:list_attributes] || {}
item_name = options[:item_name] || name.to_s.singularize
it... | ruby | def list_of(name, *args, &block)
options = args.extract_options!
list_subject = args.empty? ? name : args.shift
raise ArgumentError, "too many arguments" unless args.empty?
list_attributes = options[:list_attributes] || {}
item_name = options[:item_name] || name.to_s.singularize
it... | [
"def",
"list_of",
"(",
"name",
",",
"*",
"args",
",",
"&",
"block",
")",
"options",
"=",
"args",
".",
"extract_options!",
"list_subject",
"=",
"args",
".",
"empty?",
"?",
"name",
":",
"args",
".",
"shift",
"raise",
"ArgumentError",
",",
"\"too many argumen... | Generate a list of elements from Enumerable data.
r.list_of :books, my_books do
r.element :title
end
# => <books type="array">
# <book><title>Sailing for old dogs</title></book>
# <book><title>On the horizon</title></book>
# <book><title>The Little Blue Book of VHS Programming</ti... | [
"Generate",
"a",
"list",
"of",
"elements",
"from",
"Enumerable",
"data",
"."
] | c60214e79d51581a1744ae2891094468416b88f9 | https://github.com/mdub/representative/blob/c60214e79d51581a1744ae2891094468416b88f9/lib/representative/abstract_xml.rb#L93-L110 |
2,939 | opulent/opulent | lib/opulent/parser/expression.rb | Opulent.Parser.expression | def expression(allow_assignments = true, wrapped = true, whitespace = true)
buffer = ''
# Build a ruby expression out of accepted literals
while (term = (whitespace ? accept(:whitespace) : nil) ||
modifier ||
identifier ||
method_call ||
... | ruby | def expression(allow_assignments = true, wrapped = true, whitespace = true)
buffer = ''
# Build a ruby expression out of accepted literals
while (term = (whitespace ? accept(:whitespace) : nil) ||
modifier ||
identifier ||
method_call ||
... | [
"def",
"expression",
"(",
"allow_assignments",
"=",
"true",
",",
"wrapped",
"=",
"true",
",",
"whitespace",
"=",
"true",
")",
"buffer",
"=",
"''",
"# Build a ruby expression out of accepted literals",
"while",
"(",
"term",
"=",
"(",
"whitespace",
"?",
"accept",
... | Check if the parser matches an expression node | [
"Check",
"if",
"the",
"parser",
"matches",
"an",
"expression",
"node"
] | 7b219bd4f54b404e8f43955b8e70925a01814b59 | https://github.com/opulent/opulent/blob/7b219bd4f54b404e8f43955b8e70925a01814b59/lib/opulent/parser/expression.rb#L7-L51 |
2,940 | opulent/opulent | lib/opulent/parser/expression.rb | Opulent.Parser.array_elements | def array_elements(buffer = '')
if (term = expression)
buffer += term[@value]
# If there is an array_terminator ",", recursively gather the next
# array element into the buffer
if (terminator = accept_stripped :comma)
accept_newline
buffer += array_elements term... | ruby | def array_elements(buffer = '')
if (term = expression)
buffer += term[@value]
# If there is an array_terminator ",", recursively gather the next
# array element into the buffer
if (terminator = accept_stripped :comma)
accept_newline
buffer += array_elements term... | [
"def",
"array_elements",
"(",
"buffer",
"=",
"''",
")",
"if",
"(",
"term",
"=",
"expression",
")",
"buffer",
"+=",
"term",
"[",
"@value",
"]",
"# If there is an array_terminator \",\", recursively gather the next",
"# array element into the buffer",
"if",
"(",
"terminat... | Recursively gather expressions separated by a comma and add them to the
expression buffer
experssion1, experssion2, experssion3
@param buffer [String] Accumulator for the array elements | [
"Recursively",
"gather",
"expressions",
"separated",
"by",
"a",
"comma",
"and",
"add",
"them",
"to",
"the",
"expression",
"buffer"
] | 7b219bd4f54b404e8f43955b8e70925a01814b59 | https://github.com/opulent/opulent/blob/7b219bd4f54b404e8f43955b8e70925a01814b59/lib/opulent/parser/expression.rb#L81-L97 |
2,941 | opulent/opulent | lib/opulent/parser/expression.rb | Opulent.Parser.method_call | def method_call
method_code = ''
while (method_start = accept(:exp_method_call))
method_code += method_start
argument = call
method_code += argument if argument
end
method_code == '' ? nil : method_code
end | ruby | def method_call
method_code = ''
while (method_start = accept(:exp_method_call))
method_code += method_start
argument = call
method_code += argument if argument
end
method_code == '' ? nil : method_code
end | [
"def",
"method_call",
"method_code",
"=",
"''",
"while",
"(",
"method_start",
"=",
"accept",
"(",
":exp_method_call",
")",
")",
"method_code",
"+=",
"method_start",
"argument",
"=",
"call",
"method_code",
"+=",
"argument",
"if",
"argument",
"end",
"method_code",
... | Accept a ruby method call modifier | [
"Accept",
"a",
"ruby",
"method",
"call",
"modifier"
] | 7b219bd4f54b404e8f43955b8e70925a01814b59 | https://github.com/opulent/opulent/blob/7b219bd4f54b404e8f43955b8e70925a01814b59/lib/opulent/parser/expression.rb#L185-L195 |
2,942 | opulent/opulent | lib/opulent/parser/expression.rb | Opulent.Parser.call_elements | def call_elements(buffer = '')
# Accept both shorthand and default ruby hash style. Following DRY
# principles, a Proc is used to assign the value to the current key
#
# key: value
# :key => value
# value
if (symbol = accept_stripped :hash_symbol)
buffer += symbol
... | ruby | def call_elements(buffer = '')
# Accept both shorthand and default ruby hash style. Following DRY
# principles, a Proc is used to assign the value to the current key
#
# key: value
# :key => value
# value
if (symbol = accept_stripped :hash_symbol)
buffer += symbol
... | [
"def",
"call_elements",
"(",
"buffer",
"=",
"''",
")",
"# Accept both shorthand and default ruby hash style. Following DRY",
"# principles, a Proc is used to assign the value to the current key",
"#",
"# key: value",
"# :key => value",
"# value",
"if",
"(",
"symbol",
"=",
"accept_s... | Recursively gather expression attributes separated by a comma and add
them to the expression buffer
expression1, a: expression2, expression3
@param buffer [String] Accumulator for the call elements | [
"Recursively",
"gather",
"expression",
"attributes",
"separated",
"by",
"a",
"comma",
"and",
"add",
"them",
"to",
"the",
"expression",
"buffer"
] | 7b219bd4f54b404e8f43955b8e70925a01814b59 | https://github.com/opulent/opulent/blob/7b219bd4f54b404e8f43955b8e70925a01814b59/lib/opulent/parser/expression.rb#L218-L262 |
2,943 | opulent/opulent | lib/opulent/parser/expression.rb | Opulent.Parser.symbol | def symbol
return unless (colon = accept :colon)
return undo colon if lookahead(:whitespace)
if (exp = expression).nil?
error :symbol
else
colon + exp[@value]
end
end | ruby | def symbol
return unless (colon = accept :colon)
return undo colon if lookahead(:whitespace)
if (exp = expression).nil?
error :symbol
else
colon + exp[@value]
end
end | [
"def",
"symbol",
"return",
"unless",
"(",
"colon",
"=",
"accept",
":colon",
")",
"return",
"undo",
"colon",
"if",
"lookahead",
"(",
":whitespace",
")",
"if",
"(",
"exp",
"=",
"expression",
")",
".",
"nil?",
"error",
":symbol",
"else",
"colon",
"+",
"exp"... | Accept a ruby symbol defined through a colon and a trailing expression
:'symbol'
:symbol | [
"Accept",
"a",
"ruby",
"symbol",
"defined",
"through",
"a",
"colon",
"and",
"a",
"trailing",
"expression"
] | 7b219bd4f54b404e8f43955b8e70925a01814b59 | https://github.com/opulent/opulent/blob/7b219bd4f54b404e8f43955b8e70925a01814b59/lib/opulent/parser/expression.rb#L269-L278 |
2,944 | opulent/opulent | lib/opulent/parser/expression.rb | Opulent.Parser.ternary_operator | def ternary_operator(allow_assignments, wrapped)
if (buffer = accept :exp_ternary)
buffer += expression(allow_assignments, wrapped)[@value]
if (else_branch = accept :exp_ternary_else)
buffer += else_branch
buffer += expression(allow_assignments, wrapped)[@value]
end
... | ruby | def ternary_operator(allow_assignments, wrapped)
if (buffer = accept :exp_ternary)
buffer += expression(allow_assignments, wrapped)[@value]
if (else_branch = accept :exp_ternary_else)
buffer += else_branch
buffer += expression(allow_assignments, wrapped)[@value]
end
... | [
"def",
"ternary_operator",
"(",
"allow_assignments",
",",
"wrapped",
")",
"if",
"(",
"buffer",
"=",
"accept",
":exp_ternary",
")",
"buffer",
"+=",
"expression",
"(",
"allow_assignments",
",",
"wrapped",
")",
"[",
"@value",
"]",
"if",
"(",
"else_branch",
"=",
... | Accept ternary operator syntax
condition ? expression1 : expression2 | [
"Accept",
"ternary",
"operator",
"syntax"
] | 7b219bd4f54b404e8f43955b8e70925a01814b59 | https://github.com/opulent/opulent/blob/7b219bd4f54b404e8f43955b8e70925a01814b59/lib/opulent/parser/expression.rb#L344-L353 |
2,945 | kjvarga/ajax | lib/ajax/action_controller.rb | Ajax.ActionController.serialize_ajax_info | def serialize_ajax_info
layout_name =
if Ajax.app.rails?(3)
if @_rendered_layout.is_a?(String)
@_rendered_layout =~ /.*\/([^\/]*)/ ? $1 : @_rendered_layout
elsif @_rendered_layout
@_rendered_layout.variable_name
end
else
active_layout... | ruby | def serialize_ajax_info
layout_name =
if Ajax.app.rails?(3)
if @_rendered_layout.is_a?(String)
@_rendered_layout =~ /.*\/([^\/]*)/ ? $1 : @_rendered_layout
elsif @_rendered_layout
@_rendered_layout.variable_name
end
else
active_layout... | [
"def",
"serialize_ajax_info",
"layout_name",
"=",
"if",
"Ajax",
".",
"app",
".",
"rails?",
"(",
"3",
")",
"if",
"@_rendered_layout",
".",
"is_a?",
"(",
"String",
")",
"@_rendered_layout",
"=~",
"/",
"\\/",
"\\/",
"/",
"?",
"$1",
":",
"@_rendered_layout",
"... | Convert the Ajax-Info hash to JSON before the request is sent.
Invoked as an after filter.
Adds the current +layout+ and +controller+ to the hash.
These values will be sent in future requests using the Ajax-Info header.
+controller+ is the result of calling ActionController#controller_name, so
if your controller... | [
"Convert",
"the",
"Ajax",
"-",
"Info",
"hash",
"to",
"JSON",
"before",
"the",
"request",
"is",
"sent",
".",
"Invoked",
"as",
"an",
"after",
"filter",
"."
] | e60acbc51855cd85b4907d509ea41fe0965ce72e | https://github.com/kjvarga/ajax/blob/e60acbc51855cd85b4907d509ea41fe0965ce72e/lib/ajax/action_controller.rb#L152-L165 |
2,946 | kjvarga/ajax | lib/ajax/action_controller.rb | Ajax.ActionController._layout_for_ajax | def _layout_for_ajax(default) #:nodoc:
ajax_layout = self.class.read_inheritable_attribute(:ajax_layout)
ajax_layout = if ajax_layout.nil? && default.nil?
nil
elsif ajax_layout.nil? && !default.nil? # look for one with the default name in layouts/ajax
if default =~ /^layouts\/aja... | ruby | def _layout_for_ajax(default) #:nodoc:
ajax_layout = self.class.read_inheritable_attribute(:ajax_layout)
ajax_layout = if ajax_layout.nil? && default.nil?
nil
elsif ajax_layout.nil? && !default.nil? # look for one with the default name in layouts/ajax
if default =~ /^layouts\/aja... | [
"def",
"_layout_for_ajax",
"(",
"default",
")",
"#:nodoc:",
"ajax_layout",
"=",
"self",
".",
"class",
".",
"read_inheritable_attribute",
"(",
":ajax_layout",
")",
"ajax_layout",
"=",
"if",
"ajax_layout",
".",
"nil?",
"&&",
"default",
".",
"nil?",
"nil",
"elsif",... | Return the layout to use for an AJAX request, or nil if the default should be used.
If no ajax_layout is set, look for the default layout in <tt>layouts/ajax</tt>.
If the layout cannot be found, use the default. | [
"Return",
"the",
"layout",
"to",
"use",
"for",
"an",
"AJAX",
"request",
"or",
"nil",
"if",
"the",
"default",
"should",
"be",
"used",
"."
] | e60acbc51855cd85b4907d509ea41fe0965ce72e | https://github.com/kjvarga/ajax/blob/e60acbc51855cd85b4907d509ea41fe0965ce72e/lib/ajax/action_controller.rb#L258-L277 |
2,947 | opulent/opulent | lib/opulent/parser/filter.rb | Opulent.Parser.filter | def filter(parent, indent)
return unless (filter_name = accept :filter)
# Get element attributes
atts = attributes(shorthand_attributes) || {}
# Accept inline text or multiline text feed as first child
error :fiter unless accept(:line_feed).strip.empty?
# Get everything under the ... | ruby | def filter(parent, indent)
return unless (filter_name = accept :filter)
# Get element attributes
atts = attributes(shorthand_attributes) || {}
# Accept inline text or multiline text feed as first child
error :fiter unless accept(:line_feed).strip.empty?
# Get everything under the ... | [
"def",
"filter",
"(",
"parent",
",",
"indent",
")",
"return",
"unless",
"(",
"filter_name",
"=",
"accept",
":filter",
")",
"# Get element attributes",
"atts",
"=",
"attributes",
"(",
"shorthand_attributes",
")",
"||",
"{",
"}",
"# Accept inline text or multiline tex... | Check if we match an compile time filter
:filter
@param parent [Node] Parent node to which we append the element | [
"Check",
"if",
"we",
"match",
"an",
"compile",
"time",
"filter"
] | 7b219bd4f54b404e8f43955b8e70925a01814b59 | https://github.com/opulent/opulent/blob/7b219bd4f54b404e8f43955b8e70925a01814b59/lib/opulent/parser/filter.rb#L11-L29 |
2,948 | opulent/opulent | lib/opulent/compiler/text.rb | Opulent.Compiler.plain | def plain(node, indent)
# Text value
value = node[@options][:value]
# Pretty print
if @settings[:pretty]
indentation = ' ' * indent
inline = @sibling_stack[-1][-1] &&
@sibling_stack[-1][-1][0] == :node &&
Settings::INLINE_NODE.include?(@sibling... | ruby | def plain(node, indent)
# Text value
value = node[@options][:value]
# Pretty print
if @settings[:pretty]
indentation = ' ' * indent
inline = @sibling_stack[-1][-1] &&
@sibling_stack[-1][-1][0] == :node &&
Settings::INLINE_NODE.include?(@sibling... | [
"def",
"plain",
"(",
"node",
",",
"indent",
")",
"# Text value",
"value",
"=",
"node",
"[",
"@options",
"]",
"[",
":value",
"]",
"# Pretty print",
"if",
"@settings",
"[",
":pretty",
"]",
"indentation",
"=",
"' '",
"*",
"indent",
"inline",
"=",
"@sibling_st... | Generate the code for a standard text node
@param node [Array] Node code generation data
@param indent [Fixnum] Size of the indentation to be added | [
"Generate",
"the",
"code",
"for",
"a",
"standard",
"text",
"node"
] | 7b219bd4f54b404e8f43955b8e70925a01814b59 | https://github.com/opulent/opulent/blob/7b219bd4f54b404e8f43955b8e70925a01814b59/lib/opulent/compiler/text.rb#L10-L57 |
2,949 | opulent/opulent | lib/opulent/parser/include.rb | Opulent.Parser.include_file | def include_file(_parent, indent)
return unless accept :include
# Process data
name = accept :line_feed || ''
name.strip!
# Check if there is any string after the include input
Logger.error :parse, @code, @i, @j, :include_end if name.empty?
# Get the complete file path based... | ruby | def include_file(_parent, indent)
return unless accept :include
# Process data
name = accept :line_feed || ''
name.strip!
# Check if there is any string after the include input
Logger.error :parse, @code, @i, @j, :include_end if name.empty?
# Get the complete file path based... | [
"def",
"include_file",
"(",
"_parent",
",",
"indent",
")",
"return",
"unless",
"accept",
":include",
"# Process data",
"name",
"=",
"accept",
":line_feed",
"||",
"''",
"name",
".",
"strip!",
"# Check if there is any string after the include input",
"Logger",
".",
"err... | Check if we have an include node, which will include a new file inside
of the current one to be parsed
@param parent [Array] Parent node to which we append to | [
"Check",
"if",
"we",
"have",
"an",
"include",
"node",
"which",
"will",
"include",
"a",
"new",
"file",
"inside",
"of",
"the",
"current",
"one",
"to",
"be",
"parsed"
] | 7b219bd4f54b404e8f43955b8e70925a01814b59 | https://github.com/opulent/opulent/blob/7b219bd4f54b404e8f43955b8e70925a01814b59/lib/opulent/parser/include.rb#L10-L57 |
2,950 | redbooth/redbooth-ruby | lib/redbooth-ruby/base.rb | RedboothRuby.Base.parse_timestamps | def parse_timestamps
@created_time = created_time.to_i if created_time.is_a? String
@created_time = Time.at(created_time) if created_time
end | ruby | def parse_timestamps
@created_time = created_time.to_i if created_time.is_a? String
@created_time = Time.at(created_time) if created_time
end | [
"def",
"parse_timestamps",
"@created_time",
"=",
"created_time",
".",
"to_i",
"if",
"created_time",
".",
"is_a?",
"String",
"@created_time",
"=",
"Time",
".",
"at",
"(",
"created_time",
")",
"if",
"created_time",
"end"
] | Parses UNIX timestamps and creates Time objects. | [
"Parses",
"UNIX",
"timestamps",
"and",
"creates",
"Time",
"objects",
"."
] | fb6bc228a9346d4db476032f0df16c9588fdfbe1 | https://github.com/redbooth/redbooth-ruby/blob/fb6bc228a9346d4db476032f0df16c9588fdfbe1/lib/redbooth-ruby/base.rb#L38-L41 |
2,951 | opulent/opulent | lib/opulent/compiler/node.rb | Opulent.Compiler.node | def node(node, indent)
# Pretty print
if @settings[:pretty]
indentation = ' ' * indent
inline = Settings::INLINE_NODE.include? node[@value]
indentate = proc do
if @in_definition
buffer "' ' * (indent + #{indent})"
else
buffer_freeze indent... | ruby | def node(node, indent)
# Pretty print
if @settings[:pretty]
indentation = ' ' * indent
inline = Settings::INLINE_NODE.include? node[@value]
indentate = proc do
if @in_definition
buffer "' ' * (indent + #{indent})"
else
buffer_freeze indent... | [
"def",
"node",
"(",
"node",
",",
"indent",
")",
"# Pretty print",
"if",
"@settings",
"[",
":pretty",
"]",
"indentation",
"=",
"' '",
"*",
"indent",
"inline",
"=",
"Settings",
"::",
"INLINE_NODE",
".",
"include?",
"node",
"[",
"@value",
"]",
"indentate",
"=... | Generate the code for a standard node element, with closing tags or
self enclosing elements
@param node [Array] Node code generation data
@param indent [Fixnum] Size of the indentation to be added | [
"Generate",
"the",
"code",
"for",
"a",
"standard",
"node",
"element",
"with",
"closing",
"tags",
"or",
"self",
"enclosing",
"elements"
] | 7b219bd4f54b404e8f43955b8e70925a01814b59 | https://github.com/opulent/opulent/blob/7b219bd4f54b404e8f43955b8e70925a01814b59/lib/opulent/compiler/node.rb#L11-L123 |
2,952 | ageweke/flex_columns | lib/flex_columns/has_flex_columns.rb | FlexColumns.HasFlexColumns._flex_columns_before_save! | def _flex_columns_before_save!
self.class._all_flex_column_names.each do |flex_column_name|
klass = self.class._flex_column_class_for(flex_column_name)
if klass.requires_serialization_on_save?(self)
_flex_column_object_for(flex_column_name).before_save!
end
end
end | ruby | def _flex_columns_before_save!
self.class._all_flex_column_names.each do |flex_column_name|
klass = self.class._flex_column_class_for(flex_column_name)
if klass.requires_serialization_on_save?(self)
_flex_column_object_for(flex_column_name).before_save!
end
end
end | [
"def",
"_flex_columns_before_save!",
"self",
".",
"class",
".",
"_all_flex_column_names",
".",
"each",
"do",
"|",
"flex_column_name",
"|",
"klass",
"=",
"self",
".",
"class",
".",
"_flex_column_class_for",
"(",
"flex_column_name",
")",
"if",
"klass",
".",
"require... | Before we save this model, make sure each flex column has a chance to serialize itself up and assign itself
properly to this model object. Note that we only need to call through to flex-column objects that have actually
been instantiated, since, by definition, there's no way the contents of any other flex columns cou... | [
"Before",
"we",
"save",
"this",
"model",
"make",
"sure",
"each",
"flex",
"column",
"has",
"a",
"chance",
"to",
"serialize",
"itself",
"up",
"and",
"assign",
"itself",
"properly",
"to",
"this",
"model",
"object",
".",
"Note",
"that",
"we",
"only",
"need",
... | 3870086352ac1a0342e96e86c403c4870fea9d6f | https://github.com/ageweke/flex_columns/blob/3870086352ac1a0342e96e86c403c4870fea9d6f/lib/flex_columns/has_flex_columns.rb#L30-L37 |
2,953 | ageweke/flex_columns | lib/flex_columns/has_flex_columns.rb | FlexColumns.HasFlexColumns._flex_column_owned_object_for | def _flex_column_owned_object_for(column_name, create_if_needed = true)
column_name = self.class._flex_column_normalize_name(column_name)
out = _flex_column_objects[column_name]
if (! out) && create_if_needed
out = _flex_column_objects[column_name] = self.class._flex_column_class_for(column_n... | ruby | def _flex_column_owned_object_for(column_name, create_if_needed = true)
column_name = self.class._flex_column_normalize_name(column_name)
out = _flex_column_objects[column_name]
if (! out) && create_if_needed
out = _flex_column_objects[column_name] = self.class._flex_column_class_for(column_n... | [
"def",
"_flex_column_owned_object_for",
"(",
"column_name",
",",
"create_if_needed",
"=",
"true",
")",
"column_name",
"=",
"self",
".",
"class",
".",
"_flex_column_normalize_name",
"(",
"column_name",
")",
"out",
"=",
"_flex_column_objects",
"[",
"column_name",
"]",
... | Returns the correct flex-column object for the given column name. This simply creates an instance of the
appropriate flex-column class, and saves it away so it will be returned again if someone requests the object for
the same column later.
This method almost never gets invoked directly; instead, everything calls i... | [
"Returns",
"the",
"correct",
"flex",
"-",
"column",
"object",
"for",
"the",
"given",
"column",
"name",
".",
"This",
"simply",
"creates",
"an",
"instance",
"of",
"the",
"appropriate",
"flex",
"-",
"column",
"class",
"and",
"saves",
"it",
"away",
"so",
"it",... | 3870086352ac1a0342e96e86c403c4870fea9d6f | https://github.com/ageweke/flex_columns/blob/3870086352ac1a0342e96e86c403c4870fea9d6f/lib/flex_columns/has_flex_columns.rb#L55-L63 |
2,954 | opulent/opulent | lib/opulent/parser/define.rb | Opulent.Parser.define | def define(parent, indent)
return unless accept(:def)
# Definition parent check
Logger.error :parse, @code, @i, @j, :definition if parent[@type] != :root
# Process data
name = accept(:node, :*).to_sym
# Create node
definition = [
:def,
name,
{ paramet... | ruby | def define(parent, indent)
return unless accept(:def)
# Definition parent check
Logger.error :parse, @code, @i, @j, :definition if parent[@type] != :root
# Process data
name = accept(:node, :*).to_sym
# Create node
definition = [
:def,
name,
{ paramet... | [
"def",
"define",
"(",
"parent",
",",
"indent",
")",
"return",
"unless",
"accept",
"(",
":def",
")",
"# Definition parent check",
"Logger",
".",
"error",
":parse",
",",
"@code",
",",
"@i",
",",
"@j",
",",
":definition",
"if",
"parent",
"[",
"@type",
"]",
... | Check if we match a new node definition to use within our page.
Definitions will not be recursive because, by the time we parse
the definition children, the definition itself is not in the
knowledgebase yet.
However, we may use previously defined nodes inside new definitions,
due to the fact that they are known ... | [
"Check",
"if",
"we",
"match",
"a",
"new",
"node",
"definition",
"to",
"use",
"within",
"our",
"page",
"."
] | 7b219bd4f54b404e8f43955b8e70925a01814b59 | https://github.com/opulent/opulent/blob/7b219bd4f54b404e8f43955b8e70925a01814b59/lib/opulent/parser/define.rb#L16-L41 |
2,955 | kjvarga/ajax | lib/rack-ajax.rb | Rack.Ajax.encode_env | def encode_env(env)
env = env.dup
env.keep_if { |k, v| k =~ /[A-Z]/ }
env.to_yaml(:Encoding => :Utf8)
end | ruby | def encode_env(env)
env = env.dup
env.keep_if { |k, v| k =~ /[A-Z]/ }
env.to_yaml(:Encoding => :Utf8)
end | [
"def",
"encode_env",
"(",
"env",
")",
"env",
"=",
"env",
".",
"dup",
"env",
".",
"keep_if",
"{",
"|",
"k",
",",
"v",
"|",
"k",
"=~",
"/",
"/",
"}",
"env",
".",
"to_yaml",
"(",
":Encoding",
"=>",
":Utf8",
")",
"end"
] | Convert the environment hash to yaml so it can be unserialized later | [
"Convert",
"the",
"environment",
"hash",
"to",
"yaml",
"so",
"it",
"can",
"be",
"unserialized",
"later"
] | e60acbc51855cd85b4907d509ea41fe0965ce72e | https://github.com/kjvarga/ajax/blob/e60acbc51855cd85b4907d509ea41fe0965ce72e/lib/rack-ajax.rb#L63-L67 |
2,956 | cottonwoodcoding/repack | lib/repack/helper.rb | Repack.Helper.webpack_asset_paths | def webpack_asset_paths(source, extension: nil)
return "" unless source.present?
paths = Repack::Manifest.asset_paths(source)
paths = paths.select {|p| p.ends_with? ".#{extension}" } if extension
host = ::Rails.configuration.repack.dev_server.host
port = ::Rails.configuration.repack.dev_... | ruby | def webpack_asset_paths(source, extension: nil)
return "" unless source.present?
paths = Repack::Manifest.asset_paths(source)
paths = paths.select {|p| p.ends_with? ".#{extension}" } if extension
host = ::Rails.configuration.repack.dev_server.host
port = ::Rails.configuration.repack.dev_... | [
"def",
"webpack_asset_paths",
"(",
"source",
",",
"extension",
":",
"nil",
")",
"return",
"\"\"",
"unless",
"source",
".",
"present?",
"paths",
"=",
"Repack",
"::",
"Manifest",
".",
"asset_paths",
"(",
"source",
")",
"paths",
"=",
"paths",
".",
"select",
"... | Return asset paths for a particular webpack entry point.
Response may either be full URLs (eg http://localhost/...) if the dev server
is in use or a host-relative URl (eg /webpack/...) if assets are precompiled.
Will raise an error if our manifest can't be found or the entry point does
not exist. | [
"Return",
"asset",
"paths",
"for",
"a",
"particular",
"webpack",
"entry",
"point",
"."
] | a1d05799502779afdc97970cc6e79a2b2e8695fd | https://github.com/cottonwoodcoding/repack/blob/a1d05799502779afdc97970cc6e79a2b2e8695fd/lib/repack/helper.rb#L14-L30 |
2,957 | 3ofcoins/chef-helpers | lib/chef-helpers/has_source.rb | ChefHelpers.HasSource.has_source? | def has_source?(source, segment, cookbook=nil)
cookbook ||= cookbook_name
begin
run_context.cookbook_collection[cookbook].
send(:find_preferred_manifest_record, run_context.node, segment, source)
rescue Chef::Exceptions::FileNotFound
nil
end
end | ruby | def has_source?(source, segment, cookbook=nil)
cookbook ||= cookbook_name
begin
run_context.cookbook_collection[cookbook].
send(:find_preferred_manifest_record, run_context.node, segment, source)
rescue Chef::Exceptions::FileNotFound
nil
end
end | [
"def",
"has_source?",
"(",
"source",
",",
"segment",
",",
"cookbook",
"=",
"nil",
")",
"cookbook",
"||=",
"cookbook_name",
"begin",
"run_context",
".",
"cookbook_collection",
"[",
"cookbook",
"]",
".",
"send",
"(",
":find_preferred_manifest_record",
",",
"run_cont... | Checks for existence of a cookbook file or template source in a cookbook.
@param [String] source name of the desired template or cookbook file source
@param [Symbol] segment `:files` or `:templates`
@param [String, nil] cookbook to look in, defaults to current cookbook
@return [String, nil] full path to the source ... | [
"Checks",
"for",
"existence",
"of",
"a",
"cookbook",
"file",
"or",
"template",
"source",
"in",
"a",
"cookbook",
"."
] | 6d784d53751528c28b8c6e5c69c206740d22ada0 | https://github.com/3ofcoins/chef-helpers/blob/6d784d53751528c28b8c6e5c69c206740d22ada0/lib/chef-helpers/has_source.rb#L16-L24 |
2,958 | chadrem/tribe | lib/tribe/actable.rb | Tribe.Actable.process_events | def process_events
while (event = @_actable.mailbox.obtain_and_shift)
event_handler(event)
end
rescue Exception => exception
cleanup_handler(exception)
exception_handler(exception)
ensure
@_actable.mailbox.release do
process_events
end
nil
end | ruby | def process_events
while (event = @_actable.mailbox.obtain_and_shift)
event_handler(event)
end
rescue Exception => exception
cleanup_handler(exception)
exception_handler(exception)
ensure
@_actable.mailbox.release do
process_events
end
nil
end | [
"def",
"process_events",
"while",
"(",
"event",
"=",
"@_actable",
".",
"mailbox",
".",
"obtain_and_shift",
")",
"event_handler",
"(",
"event",
")",
"end",
"rescue",
"Exception",
"=>",
"exception",
"cleanup_handler",
"(",
"exception",
")",
"exception_handler",
"(",... | All system commands are prefixed with an underscore. | [
"All",
"system",
"commands",
"are",
"prefixed",
"with",
"an",
"underscore",
"."
] | 7cca0c3f66c710b4f361f8a371b6d126b22d7f6a | https://github.com/chadrem/tribe/blob/7cca0c3f66c710b4f361f8a371b6d126b22d7f6a/lib/tribe/actable.rb#L157-L171 |
2,959 | opulent/opulent | lib/opulent/context.rb | Opulent.Context.evaluate | def evaluate(code, &block)
begin
eval code, @binding, &block
rescue NameError => variable
Compiler.error :binding, variable, code
end
end | ruby | def evaluate(code, &block)
begin
eval code, @binding, &block
rescue NameError => variable
Compiler.error :binding, variable, code
end
end | [
"def",
"evaluate",
"(",
"code",
",",
"&",
"block",
")",
"begin",
"eval",
"code",
",",
"@binding",
",",
"block",
"rescue",
"NameError",
"=>",
"variable",
"Compiler",
".",
"error",
":binding",
",",
"variable",
",",
"code",
"end",
"end"
] | Create a context from the environment binding, extended with the locals
given as arguments
@param locals [Hash] Binding extension
@param block [Binding] Call environment block
@param content [Binding] Content yielding
Evaluate ruby code in current context
@param code [String] Code to be evaluated | [
"Create",
"a",
"context",
"from",
"the",
"environment",
"binding",
"extended",
"with",
"the",
"locals",
"given",
"as",
"arguments"
] | 7b219bd4f54b404e8f43955b8e70925a01814b59 | https://github.com/opulent/opulent/blob/7b219bd4f54b404e8f43955b8e70925a01814b59/lib/opulent/context.rb#L36-L42 |
2,960 | opulent/opulent | lib/opulent/context.rb | Opulent.Context.extend_locals | def extend_locals(locals)
# Create new local variables from the input hash
locals.each do |key, value|
begin
@binding.local_variable_set key.to_sym, value
rescue NameError => variable
Compiler.error :variable_name, variable, key
end
end
end | ruby | def extend_locals(locals)
# Create new local variables from the input hash
locals.each do |key, value|
begin
@binding.local_variable_set key.to_sym, value
rescue NameError => variable
Compiler.error :variable_name, variable, key
end
end
end | [
"def",
"extend_locals",
"(",
"locals",
")",
"# Create new local variables from the input hash",
"locals",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"begin",
"@binding",
".",
"local_variable_set",
"key",
".",
"to_sym",
",",
"value",
"rescue",
"NameError",
"... | Extend the call context with a Hash, String or other Object
@param context [Object] Extension object | [
"Extend",
"the",
"call",
"context",
"with",
"a",
"Hash",
"String",
"or",
"other",
"Object"
] | 7b219bd4f54b404e8f43955b8e70925a01814b59 | https://github.com/opulent/opulent/blob/7b219bd4f54b404e8f43955b8e70925a01814b59/lib/opulent/context.rb#L54-L63 |
2,961 | opulent/opulent | lib/opulent/context.rb | Opulent.Context.extend_nonlocals | def extend_nonlocals(bind)
bind.eval('instance_variables').each do |var|
@binding.eval('self').instance_variable_set var, bind.eval(var.to_s)
end
bind.eval('self.class.class_variables').each do |var|
@binding.eval('self').class_variable_set var, bind.eval(var.to_s)
end
end | ruby | def extend_nonlocals(bind)
bind.eval('instance_variables').each do |var|
@binding.eval('self').instance_variable_set var, bind.eval(var.to_s)
end
bind.eval('self.class.class_variables').each do |var|
@binding.eval('self').class_variable_set var, bind.eval(var.to_s)
end
end | [
"def",
"extend_nonlocals",
"(",
"bind",
")",
"bind",
".",
"eval",
"(",
"'instance_variables'",
")",
".",
"each",
"do",
"|",
"var",
"|",
"@binding",
".",
"eval",
"(",
"'self'",
")",
".",
"instance_variable_set",
"var",
",",
"bind",
".",
"eval",
"(",
"var"... | Extend instance, class and global variables for use in definitions
@param bind [Binding] Binding to extend current context binding | [
"Extend",
"instance",
"class",
"and",
"global",
"variables",
"for",
"use",
"in",
"definitions"
] | 7b219bd4f54b404e8f43955b8e70925a01814b59 | https://github.com/opulent/opulent/blob/7b219bd4f54b404e8f43955b8e70925a01814b59/lib/opulent/context.rb#L69-L77 |
2,962 | Yellowen/Faalis | lib/faalis/dashboard/dsl/index.rb | Faalis::Dashboard::DSL.Index.attributes | def attributes(*fields_name, **options, &block)
if options.include? :except
@fields = resolve_model_reflections.reject do |field|
options[:except].include? field.to_sym
end
elsif options.include? :append
@fields += options[:append]
else
# set new value for fi... | ruby | def attributes(*fields_name, **options, &block)
if options.include? :except
@fields = resolve_model_reflections.reject do |field|
options[:except].include? field.to_sym
end
elsif options.include? :append
@fields += options[:append]
else
# set new value for fi... | [
"def",
"attributes",
"(",
"*",
"fields_name",
",",
"**",
"options",
",",
"&",
"block",
")",
"if",
"options",
".",
"include?",
":except",
"@fields",
"=",
"resolve_model_reflections",
".",
"reject",
"do",
"|",
"field",
"|",
"options",
"[",
":except",
"]",
".... | Allow user to specify an array of model attributes to be used
in respected section. For example attributes to show as header
columns in index section | [
"Allow",
"user",
"to",
"specify",
"an",
"array",
"of",
"model",
"attributes",
"to",
"be",
"used",
"in",
"respected",
"section",
".",
"For",
"example",
"attributes",
"to",
"show",
"as",
"header",
"columns",
"in",
"index",
"section"
] | d12abdb8559dabbf6b2044e3ba437038527039b2 | https://github.com/Yellowen/Faalis/blob/d12abdb8559dabbf6b2044e3ba437038527039b2/lib/faalis/dashboard/dsl/index.rb#L10-L23 |
2,963 | Yellowen/Faalis | lib/faalis/dashboard/sections/resources_index.rb | Faalis::Dashboard::Sections.ResourcesIndex.fetch_index_objects | def fetch_index_objects
scope = index_properties.default_scope
puts "<<<<<<<" * 100, scope
if !scope.nil?
# If user provided an scope for `index` section.
if scope.respond_to? :call
# If scope provided by a block
scope = scope.call
else
... | ruby | def fetch_index_objects
scope = index_properties.default_scope
puts "<<<<<<<" * 100, scope
if !scope.nil?
# If user provided an scope for `index` section.
if scope.respond_to? :call
# If scope provided by a block
scope = scope.call
else
... | [
"def",
"fetch_index_objects",
"scope",
"=",
"index_properties",
".",
"default_scope",
"puts",
"\"<<<<<<<\"",
"*",
"100",
",",
"scope",
"if",
"!",
"scope",
".",
"nil?",
"# If user provided an scope for `index` section.",
"if",
"scope",
".",
"respond_to?",
":call",
"# I... | Fetch all or part of the corresponding resource
from data base with respect to `scope` DSL.
The important thing here is that by using `scope`
DSL this method will chain the resulted scope
with other scopes like `page` and `policy_scope` | [
"Fetch",
"all",
"or",
"part",
"of",
"the",
"corresponding",
"resource",
"from",
"data",
"base",
"with",
"respect",
"to",
"scope",
"DSL",
"."
] | d12abdb8559dabbf6b2044e3ba437038527039b2 | https://github.com/Yellowen/Faalis/blob/d12abdb8559dabbf6b2044e3ba437038527039b2/lib/faalis/dashboard/sections/resources_index.rb#L29-L53 |
2,964 | vjt/sanitize-rails | lib/sanitize/rails/matchers.rb | Sanitize::Rails::Matchers.SanitizeFieldsMatcher.matches? | def matches?(instance)
self.instance = instance
# assign invalid value to each field
fields.each { |field| instance.send("#{field}=", invalid_value) }
# sanitize the object calling the method
instance.send(sanitizer) rescue nil
# check expectation on results
fields.all? { |fiel... | ruby | def matches?(instance)
self.instance = instance
# assign invalid value to each field
fields.each { |field| instance.send("#{field}=", invalid_value) }
# sanitize the object calling the method
instance.send(sanitizer) rescue nil
# check expectation on results
fields.all? { |fiel... | [
"def",
"matches?",
"(",
"instance",
")",
"self",
".",
"instance",
"=",
"instance",
"# assign invalid value to each field",
"fields",
".",
"each",
"{",
"|",
"field",
"|",
"instance",
".",
"send",
"(",
"\"#{field}=\"",
",",
"invalid_value",
")",
"}",
"# sanitize t... | Actual match code | [
"Actual",
"match",
"code"
] | 85541b447427347b59f1c3b584cffcecbc884476 | https://github.com/vjt/sanitize-rails/blob/85541b447427347b59f1c3b584cffcecbc884476/lib/sanitize/rails/matchers.rb#L84-L92 |
2,965 | opulent/opulent | lib/opulent/parser/control.rb | Opulent.Parser.control | def control(parent, indent)
# Accept eval or multiline eval syntax and return a new node,
return unless (structure = accept(:control))
structure = structure.to_sym
# Handle each and the other control structures
condition = accept(:line_feed).strip
# Process each control structure c... | ruby | def control(parent, indent)
# Accept eval or multiline eval syntax and return a new node,
return unless (structure = accept(:control))
structure = structure.to_sym
# Handle each and the other control structures
condition = accept(:line_feed).strip
# Process each control structure c... | [
"def",
"control",
"(",
"parent",
",",
"indent",
")",
"# Accept eval or multiline eval syntax and return a new node,",
"return",
"unless",
"(",
"structure",
"=",
"accept",
"(",
":control",
")",
")",
"structure",
"=",
"structure",
".",
"to_sym",
"# Handle each and the oth... | Match an if-else control structure | [
"Match",
"an",
"if",
"-",
"else",
"control",
"structure"
] | 7b219bd4f54b404e8f43955b8e70925a01814b59 | https://github.com/opulent/opulent/blob/7b219bd4f54b404e8f43955b8e70925a01814b59/lib/opulent/parser/control.rb#L7-L112 |
2,966 | taganaka/polipus | lib/polipus/robotex.rb | Polipus.Robotex.delay! | def delay!(uri)
delay = delay(uri)
sleep delay - (Time.now - @last_accessed) if delay
@last_accessed = Time.now
end | ruby | def delay!(uri)
delay = delay(uri)
sleep delay - (Time.now - @last_accessed) if delay
@last_accessed = Time.now
end | [
"def",
"delay!",
"(",
"uri",
")",
"delay",
"=",
"delay",
"(",
"uri",
")",
"sleep",
"delay",
"-",
"(",
"Time",
".",
"now",
"-",
"@last_accessed",
")",
"if",
"delay",
"@last_accessed",
"=",
"Time",
".",
"now",
"end"
] | Sleep for the amount of time necessary to obey the Crawl-Delay specified by the server | [
"Sleep",
"for",
"the",
"amount",
"of",
"time",
"necessary",
"to",
"obey",
"the",
"Crawl",
"-",
"Delay",
"specified",
"by",
"the",
"server"
] | 8917a37c151a8e36fcc49fb5461aaeaf97f1f5a6 | https://github.com/taganaka/polipus/blob/8917a37c151a8e36fcc49fb5461aaeaf97f1f5a6/lib/polipus/robotex.rb#L139-L143 |
2,967 | Yellowen/Faalis | app/helpers/faalis/dashboard_helper.rb | Faalis.DashboardHelper.get_url | def get_url(route_name, id = nil, engine = Rails.application)
return route_name.call if id.nil?
return route_name.call(id) unless id.nil?
end | ruby | def get_url(route_name, id = nil, engine = Rails.application)
return route_name.call if id.nil?
return route_name.call(id) unless id.nil?
end | [
"def",
"get_url",
"(",
"route_name",
",",
"id",
"=",
"nil",
",",
"engine",
"=",
"Rails",
".",
"application",
")",
"return",
"route_name",
".",
"call",
"if",
"id",
".",
"nil?",
"return",
"route_name",
".",
"call",
"(",
"id",
")",
"unless",
"id",
".",
... | Translate route name to url dynamically | [
"Translate",
"route",
"name",
"to",
"url",
"dynamically"
] | d12abdb8559dabbf6b2044e3ba437038527039b2 | https://github.com/Yellowen/Faalis/blob/d12abdb8559dabbf6b2044e3ba437038527039b2/app/helpers/faalis/dashboard_helper.rb#L59-L62 |
2,968 | hassox/warden_strategies | lib/warden_strategies/simple.rb | WardenStrategies.Simple.authenticate! | def authenticate!
if u = user_class.send(config[:authenticate_method], *required_param_values)
success!(u)
else
fail!(config[:error_message])
end
end | ruby | def authenticate!
if u = user_class.send(config[:authenticate_method], *required_param_values)
success!(u)
else
fail!(config[:error_message])
end
end | [
"def",
"authenticate!",
"if",
"u",
"=",
"user_class",
".",
"send",
"(",
"config",
"[",
":authenticate_method",
"]",
",",
"required_param_values",
")",
"success!",
"(",
"u",
")",
"else",
"fail!",
"(",
"config",
"[",
":error_message",
"]",
")",
"end",
"end"
] | The workhorse. Will pass all requred_param_values to the configured authenticate_method
@see WardenStrategies::Simple.config
@see Warden::Strategy::Base#authenticate!
@api private | [
"The",
"workhorse",
".",
"Will",
"pass",
"all",
"requred_param_values",
"to",
"the",
"configured",
"authenticate_method"
] | 8d249132c56d519c19adc92fbac0553456375cc9 | https://github.com/hassox/warden_strategies/blob/8d249132c56d519c19adc92fbac0553456375cc9/lib/warden_strategies/simple.rb#L101-L107 |
2,969 | myfreecomm/charging-client-ruby | lib/charging/invoice.rb | Charging.Invoice.create! | def create!
super do
raise 'can not create without a domain' if invalid_domain?
raise 'can not create wihtout a charge account' if invalid_charge_account?
Invoice.post_charge_accounts_invoices(domain, charge_account, attributes)
end
reload_attributes!(Helpers.ex... | ruby | def create!
super do
raise 'can not create without a domain' if invalid_domain?
raise 'can not create wihtout a charge account' if invalid_charge_account?
Invoice.post_charge_accounts_invoices(domain, charge_account, attributes)
end
reload_attributes!(Helpers.ex... | [
"def",
"create!",
"super",
"do",
"raise",
"'can not create without a domain'",
"if",
"invalid_domain?",
"raise",
"'can not create wihtout a charge account'",
"if",
"invalid_charge_account?",
"Invoice",
".",
"post_charge_accounts_invoices",
"(",
"domain",
",",
"charge_account",
... | Creates current invoice at API.
API method: <tt>POST /charge-accounts/:uuid/invoices/</tt>
API documentation: https://charging.financeconnect.com.br/static/docs/charges.html#post-charge-accounts-uuid-invoices | [
"Creates",
"current",
"invoice",
"at",
"API",
"."
] | d2b164a3536a8c5faa8656c8477b399b22181e7f | https://github.com/myfreecomm/charging-client-ruby/blob/d2b164a3536a8c5faa8656c8477b399b22181e7f/lib/charging/invoice.rb#L28-L37 |
2,970 | myfreecomm/charging-client-ruby | lib/charging/invoice.rb | Charging.Invoice.payments | def payments
reset_errors!
response = Http.get("/invoices/#{uuid}/payments/", domain.token)
return [] if response.code != 200
MultiJson.decode(response.body)
end | ruby | def payments
reset_errors!
response = Http.get("/invoices/#{uuid}/payments/", domain.token)
return [] if response.code != 200
MultiJson.decode(response.body)
end | [
"def",
"payments",
"reset_errors!",
"response",
"=",
"Http",
".",
"get",
"(",
"\"/invoices/#{uuid}/payments/\"",
",",
"domain",
".",
"token",
")",
"return",
"[",
"]",
"if",
"response",
".",
"code",
"!=",
"200",
"MultiJson",
".",
"decode",
"(",
"response",
".... | List all payments for an invoice
API method: <tt>GET /invoices/:uuid/payments/</tt>
API documentation: https://charging.financeconnect.com.br/static/docs/charges.html#get-invoices-uuid-payments | [
"List",
"all",
"payments",
"for",
"an",
"invoice"
] | d2b164a3536a8c5faa8656c8477b399b22181e7f | https://github.com/myfreecomm/charging-client-ruby/blob/d2b164a3536a8c5faa8656c8477b399b22181e7f/lib/charging/invoice.rb#L84-L92 |
2,971 | myfreecomm/charging-client-ruby | lib/charging/invoice.rb | Charging.Invoice.billet_url | def billet_url
return if unpersisted?
response = Http.get("/invoices/#{uuid}/billet/", domain.token)
return if response.code != 200
MultiJson.decode(response.body)["billet"]
rescue
nil
end | ruby | def billet_url
return if unpersisted?
response = Http.get("/invoices/#{uuid}/billet/", domain.token)
return if response.code != 200
MultiJson.decode(response.body)["billet"]
rescue
nil
end | [
"def",
"billet_url",
"return",
"if",
"unpersisted?",
"response",
"=",
"Http",
".",
"get",
"(",
"\"/invoices/#{uuid}/billet/\"",
",",
"domain",
".",
"token",
")",
"return",
"if",
"response",
".",
"code",
"!=",
"200",
"MultiJson",
".",
"decode",
"(",
"response",... | Returns a String with the temporary URL for print current invoice.
API method: <tt>GET /invoices/:uuid/billet/</tt>
API documentation: https://charging.financeconnect.com.br/static/docs/charges.html#get-invoices-uuid-billet | [
"Returns",
"a",
"String",
"with",
"the",
"temporary",
"URL",
"for",
"print",
"current",
"invoice",
"."
] | d2b164a3536a8c5faa8656c8477b399b22181e7f | https://github.com/myfreecomm/charging-client-ruby/blob/d2b164a3536a8c5faa8656c8477b399b22181e7f/lib/charging/invoice.rb#L99-L109 |
2,972 | myfreecomm/rexpense-client-ruby | lib/rexpense/resources/nested_endpoints/participant.rb | Rexpense::Resources.Participant.participants | def participants(resource_id)
http.get(participants_endpoint(resource_id)) do |response|
Rexpense::Entities::UserCollection.build response
end
end | ruby | def participants(resource_id)
http.get(participants_endpoint(resource_id)) do |response|
Rexpense::Entities::UserCollection.build response
end
end | [
"def",
"participants",
"(",
"resource_id",
")",
"http",
".",
"get",
"(",
"participants_endpoint",
"(",
"resource_id",
")",
")",
"do",
"|",
"response",
"|",
"Rexpense",
"::",
"Entities",
"::",
"UserCollection",
".",
"build",
"response",
"end",
"end"
] | Get resource participants tags
[API]
Method: <tt>GET /api/v1/reimbursements/:id/participants</tt>
Method: <tt>GET /api/v1/expenses/:id/participants</tt>
Method: <tt>GET /api/v1/advancements/:id/participants</tt>
Documentation: http://developers.rexpense.com/api/participants#index
Documentation: http:/... | [
"Get",
"resource",
"participants",
"tags"
] | c3a36440876dda29e0747d45807e70b246e99945 | https://github.com/myfreecomm/rexpense-client-ruby/blob/c3a36440876dda29e0747d45807e70b246e99945/lib/rexpense/resources/nested_endpoints/participant.rb#L14-L18 |
2,973 | myfreecomm/charging-client-ruby | lib/charging/charge_account.rb | Charging.ChargeAccount.update_attribute! | def update_attribute!(attribute, value, should_reload_attributes = true)
execute_and_capture_raises_at_errors(204) do
@last_response = Http.patch("/charge-accounts/#{uuid}/", domain.token, etag, attribute => value)
end
reload_attributes! if should_reload_attributes
end | ruby | def update_attribute!(attribute, value, should_reload_attributes = true)
execute_and_capture_raises_at_errors(204) do
@last_response = Http.patch("/charge-accounts/#{uuid}/", domain.token, etag, attribute => value)
end
reload_attributes! if should_reload_attributes
end | [
"def",
"update_attribute!",
"(",
"attribute",
",",
"value",
",",
"should_reload_attributes",
"=",
"true",
")",
"execute_and_capture_raises_at_errors",
"(",
"204",
")",
"do",
"@last_response",
"=",
"Http",
".",
"patch",
"(",
"\"/charge-accounts/#{uuid}/\"",
",",
"domai... | Update an attribute on charge account at API.
API method: <tt>PATCH /charge-accounts/:uuid/</tt>
API documentation: https://charging.financeconnect.com.br/static/docs/charges.html#patch-charge-accounts-uuid | [
"Update",
"an",
"attribute",
"on",
"charge",
"account",
"at",
"API",
"."
] | d2b164a3536a8c5faa8656c8477b399b22181e7f | https://github.com/myfreecomm/charging-client-ruby/blob/d2b164a3536a8c5faa8656c8477b399b22181e7f/lib/charging/charge_account.rb#L56-L62 |
2,974 | myfreecomm/rexpense-client-ruby | lib/rexpense/resources/nested_endpoints/membership.rb | Rexpense::Resources.Membership.memberships | def memberships(organization_id)
http.get(membership_endpoint(organization_id)) do |response|
Rexpense::Entities::MembershipCollection.build response
end
end | ruby | def memberships(organization_id)
http.get(membership_endpoint(organization_id)) do |response|
Rexpense::Entities::MembershipCollection.build response
end
end | [
"def",
"memberships",
"(",
"organization_id",
")",
"http",
".",
"get",
"(",
"membership_endpoint",
"(",
"organization_id",
")",
")",
"do",
"|",
"response",
"|",
"Rexpense",
"::",
"Entities",
"::",
"MembershipCollection",
".",
"build",
"response",
"end",
"end"
] | Get organization memberships
[API]
Method: <tt>GET /api/v1/organizations/:id/memberships</tt>
Documentation: http://developers.rexpense.com/api/memberships#index | [
"Get",
"organization",
"memberships"
] | c3a36440876dda29e0747d45807e70b246e99945 | https://github.com/myfreecomm/rexpense-client-ruby/blob/c3a36440876dda29e0747d45807e70b246e99945/lib/rexpense/resources/nested_endpoints/membership.rb#L10-L14 |
2,975 | myfreecomm/rexpense-client-ruby | lib/rexpense/resources/nested_endpoints/membership.rb | Rexpense::Resources.Membership.create_membership | def create_membership(organization_id, params)
http.post(membership_endpoint(organization_id), body: params) do |response|
response.parsed_body
end
end | ruby | def create_membership(organization_id, params)
http.post(membership_endpoint(organization_id), body: params) do |response|
response.parsed_body
end
end | [
"def",
"create_membership",
"(",
"organization_id",
",",
"params",
")",
"http",
".",
"post",
"(",
"membership_endpoint",
"(",
"organization_id",
")",
",",
"body",
":",
"params",
")",
"do",
"|",
"response",
"|",
"response",
".",
"parsed_body",
"end",
"end"
] | Create organization membership
[API]
Method: <tt>POST /api/v1/organizations/:id/memberships</tt>
Documentation: http://developers.rexpense.com/api/memberships#create | [
"Create",
"organization",
"membership"
] | c3a36440876dda29e0747d45807e70b246e99945 | https://github.com/myfreecomm/rexpense-client-ruby/blob/c3a36440876dda29e0747d45807e70b246e99945/lib/rexpense/resources/nested_endpoints/membership.rb#L36-L40 |
2,976 | myfreecomm/rexpense-client-ruby | lib/rexpense/resources/nested_endpoints/membership.rb | Rexpense::Resources.Membership.update_membership | def update_membership(organization_id, membership_id, params)
http.put("#{membership_endpoint(organization_id)}/#{membership_id}", body: params) do |response|
Rexpense::Entities::Membership.new response.parsed_body
end
end | ruby | def update_membership(organization_id, membership_id, params)
http.put("#{membership_endpoint(organization_id)}/#{membership_id}", body: params) do |response|
Rexpense::Entities::Membership.new response.parsed_body
end
end | [
"def",
"update_membership",
"(",
"organization_id",
",",
"membership_id",
",",
"params",
")",
"http",
".",
"put",
"(",
"\"#{membership_endpoint(organization_id)}/#{membership_id}\"",
",",
"body",
":",
"params",
")",
"do",
"|",
"response",
"|",
"Rexpense",
"::",
"Ent... | Update organization membership
[API]
Method: <tt>PUT /api/v1/organizations/:id/memberships/:membership_id</tt>
Documentation: http://developers.rexpense.com/api/memberships#update | [
"Update",
"organization",
"membership"
] | c3a36440876dda29e0747d45807e70b246e99945 | https://github.com/myfreecomm/rexpense-client-ruby/blob/c3a36440876dda29e0747d45807e70b246e99945/lib/rexpense/resources/nested_endpoints/membership.rb#L49-L53 |
2,977 | myfreecomm/rexpense-client-ruby | lib/rexpense/resources/nested_endpoints/attachment.rb | Rexpense::Resources.Attachment.attachments | def attachments(resource_id)
http.get(attachment_endpoint(resource_id)) do |response|
Rexpense::Entities::AttachmentCollection.build response
end
end | ruby | def attachments(resource_id)
http.get(attachment_endpoint(resource_id)) do |response|
Rexpense::Entities::AttachmentCollection.build response
end
end | [
"def",
"attachments",
"(",
"resource_id",
")",
"http",
".",
"get",
"(",
"attachment_endpoint",
"(",
"resource_id",
")",
")",
"do",
"|",
"response",
"|",
"Rexpense",
"::",
"Entities",
"::",
"AttachmentCollection",
".",
"build",
"response",
"end",
"end"
] | Get resource attachments
[API]
Method: <tt>GET /api/v1/expenses/:id/attachments</tt>
Documentation: http://developers.rexpense.com/api/attachments#index | [
"Get",
"resource",
"attachments"
] | c3a36440876dda29e0747d45807e70b246e99945 | https://github.com/myfreecomm/rexpense-client-ruby/blob/c3a36440876dda29e0747d45807e70b246e99945/lib/rexpense/resources/nested_endpoints/attachment.rb#L10-L14 |
2,978 | myfreecomm/rexpense-client-ruby | lib/rexpense/resources/nested_endpoints/attachment.rb | Rexpense::Resources.Attachment.find_attachment | def find_attachment(resource_id, attachment_id)
http.get("#{attachment_endpoint(resource_id)}/#{attachment_id}") do |response|
Rexpense::Entities::Attachment.new response.parsed_body
end
end | ruby | def find_attachment(resource_id, attachment_id)
http.get("#{attachment_endpoint(resource_id)}/#{attachment_id}") do |response|
Rexpense::Entities::Attachment.new response.parsed_body
end
end | [
"def",
"find_attachment",
"(",
"resource_id",
",",
"attachment_id",
")",
"http",
".",
"get",
"(",
"\"#{attachment_endpoint(resource_id)}/#{attachment_id}\"",
")",
"do",
"|",
"response",
"|",
"Rexpense",
"::",
"Entities",
"::",
"Attachment",
".",
"new",
"response",
"... | Get resource attachment
[API]
Method: <tt>GET /api/v1/expenses/:id/attachments/:id</tt>
Documentation: http://developers.rexpense.com/api/attachments#show | [
"Get",
"resource",
"attachment"
] | c3a36440876dda29e0747d45807e70b246e99945 | https://github.com/myfreecomm/rexpense-client-ruby/blob/c3a36440876dda29e0747d45807e70b246e99945/lib/rexpense/resources/nested_endpoints/attachment.rb#L23-L27 |
2,979 | myfreecomm/rexpense-client-ruby | lib/rexpense/resources/nested_endpoints/comment.rb | Rexpense::Resources.Comment.comments | def comments(resource_id)
http.get(comment_endpoint(resource_id)) do |response|
Rexpense::Entities::CommentCollection.build response
end
end | ruby | def comments(resource_id)
http.get(comment_endpoint(resource_id)) do |response|
Rexpense::Entities::CommentCollection.build response
end
end | [
"def",
"comments",
"(",
"resource_id",
")",
"http",
".",
"get",
"(",
"comment_endpoint",
"(",
"resource_id",
")",
")",
"do",
"|",
"response",
"|",
"Rexpense",
"::",
"Entities",
"::",
"CommentCollection",
".",
"build",
"response",
"end",
"end"
] | Get resource comments
[API]
Method: <tt>GET /api/v1/reimbursements/:id/comments</tt>
Method: <tt>GET /api/v1/expenses/:id/comments</tt>
Method: <tt>GET /api/v1/advancements/:id/comments</tt>
Documentation: http://developers.rexpense.com/api/comments#index | [
"Get",
"resource",
"comments"
] | c3a36440876dda29e0747d45807e70b246e99945 | https://github.com/myfreecomm/rexpense-client-ruby/blob/c3a36440876dda29e0747d45807e70b246e99945/lib/rexpense/resources/nested_endpoints/comment.rb#L12-L16 |
2,980 | myfreecomm/rexpense-client-ruby | lib/rexpense/resources/nested_endpoints/comment.rb | Rexpense::Resources.Comment.find_comment | def find_comment(resource_id, comment_id)
http.get("#{comment_endpoint(resource_id)}/#{comment_id}") do |response|
Rexpense::Entities::Comment.new response.parsed_body
end
end | ruby | def find_comment(resource_id, comment_id)
http.get("#{comment_endpoint(resource_id)}/#{comment_id}") do |response|
Rexpense::Entities::Comment.new response.parsed_body
end
end | [
"def",
"find_comment",
"(",
"resource_id",
",",
"comment_id",
")",
"http",
".",
"get",
"(",
"\"#{comment_endpoint(resource_id)}/#{comment_id}\"",
")",
"do",
"|",
"response",
"|",
"Rexpense",
"::",
"Entities",
"::",
"Comment",
".",
"new",
"response",
".",
"parsed_b... | Get resource comment
[API]
Method: <tt>GET /api/v1/reimbursements/:id/comments/:comment_id</tt>
Method: <tt>GET /api/v1/expenses/:id/comments/:comment_id</tt>
Method: <tt>GET /api/v1/advancements/:id/comments/:comment_id</tt>
Documentation: http://developers.rexpense.com/api/comments#show | [
"Get",
"resource",
"comment"
] | c3a36440876dda29e0747d45807e70b246e99945 | https://github.com/myfreecomm/rexpense-client-ruby/blob/c3a36440876dda29e0747d45807e70b246e99945/lib/rexpense/resources/nested_endpoints/comment.rb#L27-L31 |
2,981 | myfreecomm/rexpense-client-ruby | lib/rexpense/resources/nested_endpoints/comment.rb | Rexpense::Resources.Comment.create_comment | def create_comment(resource_id, params)
http.post(comment_endpoint(resource_id), body: params) do |response|
Rexpense::Entities::Comment.new response.parsed_body
end
end | ruby | def create_comment(resource_id, params)
http.post(comment_endpoint(resource_id), body: params) do |response|
Rexpense::Entities::Comment.new response.parsed_body
end
end | [
"def",
"create_comment",
"(",
"resource_id",
",",
"params",
")",
"http",
".",
"post",
"(",
"comment_endpoint",
"(",
"resource_id",
")",
",",
"body",
":",
"params",
")",
"do",
"|",
"response",
"|",
"Rexpense",
"::",
"Entities",
"::",
"Comment",
".",
"new",
... | Create resource comment
[API]
Method: <tt>POST /api/v1/reimbursements/:id/comments</tt>
Method: <tt>POST /api/v1/expenses/:id/comments</tt>
Method: <tt>POST /api/v1/advancements/:id/comments</tt>
Documentation: http://developers.rexpense.com/api/comments#create | [
"Create",
"resource",
"comment"
] | c3a36440876dda29e0747d45807e70b246e99945 | https://github.com/myfreecomm/rexpense-client-ruby/blob/c3a36440876dda29e0747d45807e70b246e99945/lib/rexpense/resources/nested_endpoints/comment.rb#L42-L46 |
2,982 | myfreecomm/rexpense-client-ruby | lib/rexpense/resources/nested_endpoints/comment.rb | Rexpense::Resources.Comment.update_comment | def update_comment(resource_id, comment_id, params)
http.put("#{comment_endpoint(resource_id)}/#{comment_id}", body: params) do |response|
Rexpense::Entities::Comment.new response.parsed_body
end
end | ruby | def update_comment(resource_id, comment_id, params)
http.put("#{comment_endpoint(resource_id)}/#{comment_id}", body: params) do |response|
Rexpense::Entities::Comment.new response.parsed_body
end
end | [
"def",
"update_comment",
"(",
"resource_id",
",",
"comment_id",
",",
"params",
")",
"http",
".",
"put",
"(",
"\"#{comment_endpoint(resource_id)}/#{comment_id}\"",
",",
"body",
":",
"params",
")",
"do",
"|",
"response",
"|",
"Rexpense",
"::",
"Entities",
"::",
"C... | Update resource comment
[API]
Method: <tt>PUT /api/v1/reimbursements/:id/comments/:comment_id</tt>
Method: <tt>PUT /api/v1/expenses/:id/comments/:comment_id</tt>
Method: <tt>PUT /api/v1/advancements/:id/comments/:comment_id</tt>
Documentation: http://developers.rexpense.com/api/comments#update | [
"Update",
"resource",
"comment"
] | c3a36440876dda29e0747d45807e70b246e99945 | https://github.com/myfreecomm/rexpense-client-ruby/blob/c3a36440876dda29e0747d45807e70b246e99945/lib/rexpense/resources/nested_endpoints/comment.rb#L57-L61 |
2,983 | bensie/enom | lib/enom/domain.rb | Enom.Domain.sync_auth_info | def sync_auth_info(options = {})
opts = {
"RunSynchAutoInfo" => 'True',
"EmailEPP" => 'True'
}
opts["EmailEPP"] = 'True' if options[:email]
Client.request({"Command" => "SynchAuthInfo", "SLD" => sld, "TLD" => tld}.merge(opts))
return self
end | ruby | def sync_auth_info(options = {})
opts = {
"RunSynchAutoInfo" => 'True',
"EmailEPP" => 'True'
}
opts["EmailEPP"] = 'True' if options[:email]
Client.request({"Command" => "SynchAuthInfo", "SLD" => sld, "TLD" => tld}.merge(opts))
return self
end | [
"def",
"sync_auth_info",
"(",
"options",
"=",
"{",
"}",
")",
"opts",
"=",
"{",
"\"RunSynchAutoInfo\"",
"=>",
"'True'",
",",
"\"EmailEPP\"",
"=>",
"'True'",
"}",
"opts",
"[",
"\"EmailEPP\"",
"]",
"=",
"'True'",
"if",
"options",
"[",
":email",
"]",
"Client",... | synchronize EPP key with Registry, and optionally email it to owner | [
"synchronize",
"EPP",
"key",
"with",
"Registry",
"and",
"optionally",
"email",
"it",
"to",
"owner"
] | a5f493a61422ea8da5d327d541c300c8756aed1e | https://github.com/bensie/enom/blob/a5f493a61422ea8da5d327d541c300c8756aed1e/lib/enom/domain.rb#L212-L222 |
2,984 | bensie/enom | lib/enom/domain.rb | Enom.Domain.get_extended_domain_attributes | def get_extended_domain_attributes
sld, tld = name.split(".")
attributes = Client.request("Command" => "GetDomainInfo", "SLD" => sld, "TLD" => tld)["interface_response"]["GetDomainInfo"]
set_extended_domain_attributes(attributes)
end | ruby | def get_extended_domain_attributes
sld, tld = name.split(".")
attributes = Client.request("Command" => "GetDomainInfo", "SLD" => sld, "TLD" => tld)["interface_response"]["GetDomainInfo"]
set_extended_domain_attributes(attributes)
end | [
"def",
"get_extended_domain_attributes",
"sld",
",",
"tld",
"=",
"name",
".",
"split",
"(",
"\".\"",
")",
"attributes",
"=",
"Client",
".",
"request",
"(",
"\"Command\"",
"=>",
"\"GetDomainInfo\"",
",",
"\"SLD\"",
"=>",
"sld",
",",
"\"TLD\"",
"=>",
"tld",
")... | Make another API call to get all domain info. Often necessary when domains are
found using Domain.all instead of Domain.find. | [
"Make",
"another",
"API",
"call",
"to",
"get",
"all",
"domain",
"info",
".",
"Often",
"necessary",
"when",
"domains",
"are",
"found",
"using",
"Domain",
".",
"all",
"instead",
"of",
"Domain",
".",
"find",
"."
] | a5f493a61422ea8da5d327d541c300c8756aed1e | https://github.com/bensie/enom/blob/a5f493a61422ea8da5d327d541c300c8756aed1e/lib/enom/domain.rb#L292-L296 |
2,985 | bdurand/acts_as_revisionable | lib/acts_as_revisionable/revision_record.rb | ActsAsRevisionable.RevisionRecord.restore | def restore
restore_class = self.revisionable_type.constantize
# Check if we have a type field, if yes, assume single table inheritance and restore the actual class instead of the stored base class
sti_type = self.revision_attributes[restore_class.inheritance_column]
if sti_type
begin
... | ruby | def restore
restore_class = self.revisionable_type.constantize
# Check if we have a type field, if yes, assume single table inheritance and restore the actual class instead of the stored base class
sti_type = self.revision_attributes[restore_class.inheritance_column]
if sti_type
begin
... | [
"def",
"restore",
"restore_class",
"=",
"self",
".",
"revisionable_type",
".",
"constantize",
"# Check if we have a type field, if yes, assume single table inheritance and restore the actual class instead of the stored base class",
"sti_type",
"=",
"self",
".",
"revision_attributes",
"... | Restore the revision to the original record. If any errors are encountered restoring attributes, they
will be added to the errors object of the restored record. | [
"Restore",
"the",
"revision",
"to",
"the",
"original",
"record",
".",
"If",
"any",
"errors",
"are",
"encountered",
"restoring",
"attributes",
"they",
"will",
"be",
"added",
"to",
"the",
"errors",
"object",
"of",
"the",
"restored",
"record",
"."
] | cabc9b9e35b58463d2a942f6cd2b4ab3d4fe64fc | https://github.com/bdurand/acts_as_revisionable/blob/cabc9b9e35b58463d2a942f6cd2b4ab3d4fe64fc/lib/acts_as_revisionable/revision_record.rb#L95-L115 |
2,986 | bdurand/acts_as_revisionable | lib/acts_as_revisionable/revision_record.rb | ActsAsRevisionable.RevisionRecord.restore_record | def restore_record(record, attributes)
primary_key = record.class.primary_key
primary_key = [primary_key].compact unless primary_key.is_a?(Array)
primary_key.each do |key|
record.send("#{key.to_s}=", attributes[key.to_s])
end
attrs, association_attrs = attributes_and_associations(... | ruby | def restore_record(record, attributes)
primary_key = record.class.primary_key
primary_key = [primary_key].compact unless primary_key.is_a?(Array)
primary_key.each do |key|
record.send("#{key.to_s}=", attributes[key.to_s])
end
attrs, association_attrs = attributes_and_associations(... | [
"def",
"restore_record",
"(",
"record",
",",
"attributes",
")",
"primary_key",
"=",
"record",
".",
"class",
".",
"primary_key",
"primary_key",
"=",
"[",
"primary_key",
"]",
".",
"compact",
"unless",
"primary_key",
".",
"is_a?",
"(",
"Array",
")",
"primary_key"... | Restore a record and all its associations. | [
"Restore",
"a",
"record",
"and",
"all",
"its",
"associations",
"."
] | cabc9b9e35b58463d2a942f6cd2b4ab3d4fe64fc | https://github.com/bdurand/acts_as_revisionable/blob/cabc9b9e35b58463d2a942f6cd2b4ab3d4fe64fc/lib/acts_as_revisionable/revision_record.rb#L237-L266 |
2,987 | ShipCompliant/ship_compliant-ruby | lib/ship_compliant/search_sales_orders_result.rb | ShipCompliant.SearchSalesOrdersResult.parse! | def parse!
unless raw.has_key?(:sales_orders)
raw[:sales_orders] = {}
end
# force orders to be an array
orders = raw[:sales_orders].fetch(:sales_order_summary, {})
unless orders.kind_of?(Array)
raw[:sales_orders][:sales_order_summary] = [orders]
end
# typecast... | ruby | def parse!
unless raw.has_key?(:sales_orders)
raw[:sales_orders] = {}
end
# force orders to be an array
orders = raw[:sales_orders].fetch(:sales_order_summary, {})
unless orders.kind_of?(Array)
raw[:sales_orders][:sales_order_summary] = [orders]
end
# typecast... | [
"def",
"parse!",
"unless",
"raw",
".",
"has_key?",
"(",
":sales_orders",
")",
"raw",
"[",
":sales_orders",
"]",
"=",
"{",
"}",
"end",
"# force orders to be an array",
"orders",
"=",
"raw",
"[",
":sales_orders",
"]",
".",
"fetch",
"(",
":sales_order_summary",
"... | Standardizes the XML response by converting fields to integers
and forcing the order summaries into an array. | [
"Standardizes",
"the",
"XML",
"response",
"by",
"converting",
"fields",
"to",
"integers",
"and",
"forcing",
"the",
"order",
"summaries",
"into",
"an",
"array",
"."
] | aa12852a58cd6cb7939eb9fbb7fdc03e46e18197 | https://github.com/ShipCompliant/ship_compliant-ruby/blob/aa12852a58cd6cb7939eb9fbb7fdc03e46e18197/lib/ship_compliant/search_sales_orders_result.rb#L64-L97 |
2,988 | ShipCompliant/ship_compliant-ruby | lib/ship_compliant/client.rb | ShipCompliant.Client.call | def call(operation, locals = {})
locals['Security'] = ShipCompliant.configuration.credentials
response = savon_call(operation, message: {
'Request' => locals
})
get_result_from_response(operation, response)
end | ruby | def call(operation, locals = {})
locals['Security'] = ShipCompliant.configuration.credentials
response = savon_call(operation, message: {
'Request' => locals
})
get_result_from_response(operation, response)
end | [
"def",
"call",
"(",
"operation",
",",
"locals",
"=",
"{",
"}",
")",
"locals",
"[",
"'Security'",
"]",
"=",
"ShipCompliant",
".",
"configuration",
".",
"credentials",
"response",
"=",
"savon_call",
"(",
"operation",
",",
"message",
":",
"{",
"'Request'",
"=... | Adds the required security credentials and formats
the message to match the ShipCompliant structure.
ShipCompliant.client.call(:some_operation, {
'SomeKey' => 'SomeValue'
}) | [
"Adds",
"the",
"required",
"security",
"credentials",
"and",
"formats",
"the",
"message",
"to",
"match",
"the",
"ShipCompliant",
"structure",
"."
] | aa12852a58cd6cb7939eb9fbb7fdc03e46e18197 | https://github.com/ShipCompliant/ship_compliant-ruby/blob/aa12852a58cd6cb7939eb9fbb7fdc03e46e18197/lib/ship_compliant/client.rb#L35-L43 |
2,989 | rossf7/elasticrawl | lib/elasticrawl/job.rb | Elasticrawl.Job.confirm_message | def confirm_message
cluster = Cluster.new
case self.type
when 'Elasticrawl::ParseJob'
message = segment_list
else
message = []
end
message.push('Job configuration')
message.push(self.job_desc)
message.push('')
message.push(cluster.cluster_desc)
... | ruby | def confirm_message
cluster = Cluster.new
case self.type
when 'Elasticrawl::ParseJob'
message = segment_list
else
message = []
end
message.push('Job configuration')
message.push(self.job_desc)
message.push('')
message.push(cluster.cluster_desc)
... | [
"def",
"confirm_message",
"cluster",
"=",
"Cluster",
".",
"new",
"case",
"self",
".",
"type",
"when",
"'Elasticrawl::ParseJob'",
"message",
"=",
"segment_list",
"else",
"message",
"=",
"[",
"]",
"end",
"message",
".",
"push",
"(",
"'Job configuration'",
")",
"... | Displays a confirmation message showing the configuration of the
Elastic MapReduce job flow and cluster. | [
"Displays",
"a",
"confirmation",
"message",
"showing",
"the",
"configuration",
"of",
"the",
"Elastic",
"MapReduce",
"job",
"flow",
"and",
"cluster",
"."
] | db70bb6819c86805869f389daf1920f3acc87cef | https://github.com/rossf7/elasticrawl/blob/db70bb6819c86805869f389daf1920f3acc87cef/lib/elasticrawl/job.rb#L8-L24 |
2,990 | rossf7/elasticrawl | lib/elasticrawl/job.rb | Elasticrawl.Job.run_job_flow | def run_job_flow(emr_config)
cluster = Cluster.new
job_flow = cluster.create_job_flow(self, emr_config)
job_steps.each do |step|
job_flow.add_step(step.job_flow_step(job_config))
end
begin
job_flow.run
rescue StandardError => e
raise ElasticMapReduceAccessE... | ruby | def run_job_flow(emr_config)
cluster = Cluster.new
job_flow = cluster.create_job_flow(self, emr_config)
job_steps.each do |step|
job_flow.add_step(step.job_flow_step(job_config))
end
begin
job_flow.run
rescue StandardError => e
raise ElasticMapReduceAccessE... | [
"def",
"run_job_flow",
"(",
"emr_config",
")",
"cluster",
"=",
"Cluster",
".",
"new",
"job_flow",
"=",
"cluster",
".",
"create_job_flow",
"(",
"self",
",",
"emr_config",
")",
"job_steps",
".",
"each",
"do",
"|",
"step",
"|",
"job_flow",
".",
"add_step",
"(... | Calls the Elastic MapReduce API to create a Job Flow. Returns the Job Flow ID. | [
"Calls",
"the",
"Elastic",
"MapReduce",
"API",
"to",
"create",
"a",
"Job",
"Flow",
".",
"Returns",
"the",
"Job",
"Flow",
"ID",
"."
] | db70bb6819c86805869f389daf1920f3acc87cef | https://github.com/rossf7/elasticrawl/blob/db70bb6819c86805869f389daf1920f3acc87cef/lib/elasticrawl/job.rb#L40-L54 |
2,991 | brasten/scruffy | lib/scruffy/layers/scatter.rb | Scruffy::Layers.Scatter.draw | def draw(svg, coords, options={})
options.merge!(@options)
if options[:shadow]
svg.g(:class => 'shadow', :transform => "translate(#{relative(0.5)}, #{relative(0.5)})") {
coords.each { |coord| svg.circle( :cx => coord.first, :cy => coord.last + relative(0.9), :r => relative(2)... | ruby | def draw(svg, coords, options={})
options.merge!(@options)
if options[:shadow]
svg.g(:class => 'shadow', :transform => "translate(#{relative(0.5)}, #{relative(0.5)})") {
coords.each { |coord| svg.circle( :cx => coord.first, :cy => coord.last + relative(0.9), :r => relative(2)... | [
"def",
"draw",
"(",
"svg",
",",
"coords",
",",
"options",
"=",
"{",
"}",
")",
"options",
".",
"merge!",
"(",
"@options",
")",
"if",
"options",
"[",
":shadow",
"]",
"svg",
".",
"g",
"(",
":class",
"=>",
"'shadow'",
",",
":transform",
"=>",
"\"translat... | Renders scatter graph. | [
"Renders",
"scatter",
"graph",
"."
] | 4aad4f9ab2b946ba0f6e6251dc7eb3b9747a4e9e | https://github.com/brasten/scruffy/blob/4aad4f9ab2b946ba0f6e6251dc7eb3b9747a4e9e/lib/scruffy/layers/scatter.rb#L13-L26 |
2,992 | brasten/scruffy | lib/scruffy/layers/area.rb | Scruffy::Layers.Area.draw | def draw(svg, coords, options={})
# svg.polygon wants a long string of coords.
points_value = "0,#{height} #{stringify_coords(coords).join(' ')} #{width},#{height}"
# Experimental, for later user.
# This was supposed to add some fun filters, 3d effects and whatnot.
# Neither ImageMagick ... | ruby | def draw(svg, coords, options={})
# svg.polygon wants a long string of coords.
points_value = "0,#{height} #{stringify_coords(coords).join(' ')} #{width},#{height}"
# Experimental, for later user.
# This was supposed to add some fun filters, 3d effects and whatnot.
# Neither ImageMagick ... | [
"def",
"draw",
"(",
"svg",
",",
"coords",
",",
"options",
"=",
"{",
"}",
")",
"# svg.polygon wants a long string of coords. ",
"points_value",
"=",
"\"0,#{height} #{stringify_coords(coords).join(' ')} #{width},#{height}\"",
"# Experimental, for later user.",
"# This was supposed to... | Render area graph. | [
"Render",
"area",
"graph",
"."
] | 4aad4f9ab2b946ba0f6e6251dc7eb3b9747a4e9e | https://github.com/brasten/scruffy/blob/4aad4f9ab2b946ba0f6e6251dc7eb3b9747a4e9e/lib/scruffy/layers/area.rb#L11-L44 |
2,993 | waiting-for-dev/landing_page | app/controllers/landing_page/users_controller.rb | LandingPage.UsersController.create | def create
params.require(:user).permit!
user = User.new(params[:user])
if user.valid?
user.save
flash.now[:success] = t('landing_page.subscribed')
render :create
else
@user = user
render :new
end
end | ruby | def create
params.require(:user).permit!
user = User.new(params[:user])
if user.valid?
user.save
flash.now[:success] = t('landing_page.subscribed')
render :create
else
@user = user
render :new
end
end | [
"def",
"create",
"params",
".",
"require",
"(",
":user",
")",
".",
"permit!",
"user",
"=",
"User",
".",
"new",
"(",
"params",
"[",
":user",
"]",
")",
"if",
"user",
".",
"valid?",
"user",
".",
"save",
"flash",
".",
"now",
"[",
":success",
"]",
"=",
... | Register a new user or show errors | [
"Register",
"a",
"new",
"user",
"or",
"show",
"errors"
] | be564fc12fd838f8845d42b5c8ade54e3c3c7c1a | https://github.com/waiting-for-dev/landing_page/blob/be564fc12fd838f8845d42b5c8ade54e3c3c7c1a/app/controllers/landing_page/users_controller.rb#L10-L21 |
2,994 | orta/travish | lib/environment_parser.rb | Travish.EnvironmentParser.build_environment_hash | def build_environment_hash
parsed_variables = {}
@env.each do |env_row|
# Each row can potentially contain multiple environment
# variables
variables = extract_variables(env_row)
variables.each do |variables_with_values|
variables_with_values.each do |key, value|
... | ruby | def build_environment_hash
parsed_variables = {}
@env.each do |env_row|
# Each row can potentially contain multiple environment
# variables
variables = extract_variables(env_row)
variables.each do |variables_with_values|
variables_with_values.each do |key, value|
... | [
"def",
"build_environment_hash",
"parsed_variables",
"=",
"{",
"}",
"@env",
".",
"each",
"do",
"|",
"env_row",
"|",
"# Each row can potentially contain multiple environment",
"# variables",
"variables",
"=",
"extract_variables",
"(",
"env_row",
")",
"variables",
".",
"e... | Build the environment hash by extracting the environment
variables from the provided travis environment and merging
with any provided overrides | [
"Build",
"the",
"environment",
"hash",
"by",
"extracting",
"the",
"environment",
"variables",
"from",
"the",
"provided",
"travis",
"environment",
"and",
"merging",
"with",
"any",
"provided",
"overrides"
] | fe71115690c8cef69979cea0dca8176eba304ab1 | https://github.com/orta/travish/blob/fe71115690c8cef69979cea0dca8176eba304ab1/lib/environment_parser.rb#L31-L50 |
2,995 | orta/travish | lib/environment_parser.rb | Travish.EnvironmentParser.extract_variables | def extract_variables(variable)
return [variable] if variable.is_a? Hash
return extract_variables_from_string(variable) if variable.is_a? String
[]
end | ruby | def extract_variables(variable)
return [variable] if variable.is_a? Hash
return extract_variables_from_string(variable) if variable.is_a? String
[]
end | [
"def",
"extract_variables",
"(",
"variable",
")",
"return",
"[",
"variable",
"]",
"if",
"variable",
".",
"is_a?",
"Hash",
"return",
"extract_variables_from_string",
"(",
"variable",
")",
"if",
"variable",
".",
"is_a?",
"String",
"[",
"]",
"end"
] | Extract environment variables from a value
The value is expected to be either a hash or a string with
one or more key value pairs on the form
KEY=VALUE | [
"Extract",
"environment",
"variables",
"from",
"a",
"value",
"The",
"value",
"is",
"expected",
"to",
"be",
"either",
"a",
"hash",
"or",
"a",
"string",
"with",
"one",
"or",
"more",
"key",
"value",
"pairs",
"on",
"the",
"form",
"KEY",
"=",
"VALUE"
] | fe71115690c8cef69979cea0dca8176eba304ab1 | https://github.com/orta/travish/blob/fe71115690c8cef69979cea0dca8176eba304ab1/lib/environment_parser.rb#L56-L61 |
2,996 | orta/travish | lib/environment_parser.rb | Travish.EnvironmentParser.extract_variables_from_string | def extract_variables_from_string(string)
string.split(/ /).map do |defintion|
match = defintion.match STRING_REG_EX
next nil unless match
{ match[1] => match[2] }
end.reject(&:nil?)
end | ruby | def extract_variables_from_string(string)
string.split(/ /).map do |defintion|
match = defintion.match STRING_REG_EX
next nil unless match
{ match[1] => match[2] }
end.reject(&:nil?)
end | [
"def",
"extract_variables_from_string",
"(",
"string",
")",
"string",
".",
"split",
"(",
"/",
"/",
")",
".",
"map",
"do",
"|",
"defintion",
"|",
"match",
"=",
"defintion",
".",
"match",
"STRING_REG_EX",
"next",
"nil",
"unless",
"match",
"{",
"match",
"[",
... | Extract variables from a string on the form
KEY1=VALUE1 KEY2="VALUE2"
Optional quoting around the value is allowed | [
"Extract",
"variables",
"from",
"a",
"string",
"on",
"the",
"form",
"KEY1",
"=",
"VALUE1",
"KEY2",
"=",
"VALUE2",
"Optional",
"quoting",
"around",
"the",
"value",
"is",
"allowed"
] | fe71115690c8cef69979cea0dca8176eba304ab1 | https://github.com/orta/travish/blob/fe71115690c8cef69979cea0dca8176eba304ab1/lib/environment_parser.rb#L66-L73 |
2,997 | poise/poise-profiler | lib/poise_profiler/base.rb | PoiseProfiler.Base._monkey_patch_old_chef! | def _monkey_patch_old_chef!
require 'chef/event_dispatch/dispatcher'
instance = self
orig_method = Chef::EventDispatch::Dispatcher.instance_method(:library_file_loaded)
Chef::EventDispatch::Dispatcher.send(:define_method, :library_file_loaded) do |filename|
instance.events = self
... | ruby | def _monkey_patch_old_chef!
require 'chef/event_dispatch/dispatcher'
instance = self
orig_method = Chef::EventDispatch::Dispatcher.instance_method(:library_file_loaded)
Chef::EventDispatch::Dispatcher.send(:define_method, :library_file_loaded) do |filename|
instance.events = self
... | [
"def",
"_monkey_patch_old_chef!",
"require",
"'chef/event_dispatch/dispatcher'",
"instance",
"=",
"self",
"orig_method",
"=",
"Chef",
"::",
"EventDispatch",
"::",
"Dispatcher",
".",
"instance_method",
"(",
":library_file_loaded",
")",
"Chef",
"::",
"EventDispatch",
"::",
... | Inject this instance for Chef < 12.3. Don't call this on newer Chef.
@api private
@see Base.install
@return [void] | [
"Inject",
"this",
"instance",
"for",
"Chef",
"<",
"12",
".",
"3",
".",
"Don",
"t",
"call",
"this",
"on",
"newer",
"Chef",
"."
] | a190acc6bdd4fcdac34ef43bbe4f59dddb9c0f67 | https://github.com/poise/poise-profiler/blob/a190acc6bdd4fcdac34ef43bbe4f59dddb9c0f67/lib/poise_profiler/base.rb#L76-L87 |
2,998 | botanicus/rango | lib/rango/controller.rb | Rango.Controller.rescue_http_error | def rescue_http_error(exception)
# we need to call it before we assign the variables
body = self.render_http_error(exception)
[exception.status, exception.headers, body]
end | ruby | def rescue_http_error(exception)
# we need to call it before we assign the variables
body = self.render_http_error(exception)
[exception.status, exception.headers, body]
end | [
"def",
"rescue_http_error",
"(",
"exception",
")",
"# we need to call it before we assign the variables",
"body",
"=",
"self",
".",
"render_http_error",
"(",
"exception",
")",
"[",
"exception",
".",
"status",
",",
"exception",
".",
"headers",
",",
"body",
"]",
"end"... | redefine this method for your controller if you want to provide custom error pages
returns response array for rack
if you need to change just body of error message, define render_http_error method
@api plugin | [
"redefine",
"this",
"method",
"for",
"your",
"controller",
"if",
"you",
"want",
"to",
"provide",
"custom",
"error",
"pages",
"returns",
"response",
"array",
"for",
"rack",
"if",
"you",
"need",
"to",
"change",
"just",
"body",
"of",
"error",
"message",
"define... | b8904453f3b7d3cd65e2bcc5236bfe645aa78e8e | https://github.com/botanicus/rango/blob/b8904453f3b7d3cd65e2bcc5236bfe645aa78e8e/lib/rango/controller.rb#L139-L143 |
2,999 | mezis/tsuga | lib/tsuga/service/clusterer.rb | Tsuga::Service.Clusterer._build_clusters | def _build_clusters(tile)
used_ids = []
clusters = []
_adapter.in_tile(*tile.children).find_each do |child|
cluster = _adapter.build_from(tile.depth, child)
clusters << cluster
used_ids << child.id
end
return [used_ids, clusters]
end | ruby | def _build_clusters(tile)
used_ids = []
clusters = []
_adapter.in_tile(*tile.children).find_each do |child|
cluster = _adapter.build_from(tile.depth, child)
clusters << cluster
used_ids << child.id
end
return [used_ids, clusters]
end | [
"def",
"_build_clusters",
"(",
"tile",
")",
"used_ids",
"=",
"[",
"]",
"clusters",
"=",
"[",
"]",
"_adapter",
".",
"in_tile",
"(",
"tile",
".",
"children",
")",
".",
"find_each",
"do",
"|",
"child",
"|",
"cluster",
"=",
"_adapter",
".",
"build_from",
"... | return the record IDs used | [
"return",
"the",
"record",
"IDs",
"used"
] | 418a1dac7af068fb388883c47f39eb52113af096 | https://github.com/mezis/tsuga/blob/418a1dac7af068fb388883c47f39eb52113af096/lib/tsuga/service/clusterer.rb#L245-L256 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.