repo stringlengths 5 58 | path stringlengths 9 168 | func_name stringlengths 9 130 | original_string stringlengths 66 10.5k | language stringclasses 1
value | code stringlengths 66 10.5k | code_tokens list | docstring stringlengths 8 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 94 266 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
Dev-Crea/swagger-docs-generator | lib/swagger_docs_generator/generator.rb | SwaggerDocsGenerator.Generator.generate_swagger_file | def generate_swagger_file
delete_file_before
File.open(@swagger_file, 'a+') do |file|
file.write(if SwaggerDocsGenerator.configure.compress
write_in_swagger_file.to_json
else
JSON.pretty_generate write_in_swagger_file
en... | ruby | def generate_swagger_file
delete_file_before
File.open(@swagger_file, 'a+') do |file|
file.write(if SwaggerDocsGenerator.configure.compress
write_in_swagger_file.to_json
else
JSON.pretty_generate write_in_swagger_file
en... | [
"def",
"generate_swagger_file",
"delete_file_before",
"File",
".",
"open",
"(",
"@swagger_file",
",",
"'a+'",
")",
"do",
"|",
"file",
"|",
"file",
".",
"write",
"(",
"if",
"SwaggerDocsGenerator",
".",
"configure",
".",
"compress",
"write_in_swagger_file",
".",
"... | Open or create a swagger.json file | [
"Open",
"or",
"create",
"a",
"swagger",
".",
"json",
"file"
] | 5d3de176aa1119cb38100b451bee028d66c0809d | https://github.com/Dev-Crea/swagger-docs-generator/blob/5d3de176aa1119cb38100b451bee028d66c0809d/lib/swagger_docs_generator/generator.rb#L26-L35 | train |
mharris717/ascension | lib/ascension/parse/card.rb | Parse.Card.mod_for_phrases | def mod_for_phrases(raw_cell, method_name_or_ability_class, card_to_setup)
return unless raw_cell
#puts [raw,cat,card_class,name].inspect
raw_cell.split(/[,;]/).each do |raw_cell_part|
p = make_parsed_phrase_obj(raw_cell_part,method_name_or_ability_class)
p.mod_card(card_to_setup) if p... | ruby | def mod_for_phrases(raw_cell, method_name_or_ability_class, card_to_setup)
return unless raw_cell
#puts [raw,cat,card_class,name].inspect
raw_cell.split(/[,;]/).each do |raw_cell_part|
p = make_parsed_phrase_obj(raw_cell_part,method_name_or_ability_class)
p.mod_card(card_to_setup) if p... | [
"def",
"mod_for_phrases",
"(",
"raw_cell",
",",
"method_name_or_ability_class",
",",
"card_to_setup",
")",
"return",
"unless",
"raw_cell",
"#puts [raw,cat,card_class,name].inspect",
"raw_cell",
".",
"split",
"(",
"/",
"/",
")",
".",
"each",
"do",
"|",
"raw_cell_part",... | Raw Cell is the text from the csv file for this column
method_name_or_ability_class is one of two things:
1. the symbol for the method to call for this column
2. The Class that represents this ability | [
"Raw",
"Cell",
"is",
"the",
"text",
"from",
"the",
"csv",
"file",
"for",
"this",
"column"
] | d4f4b9a603524d53b03436c370adf4756e5ca616 | https://github.com/mharris717/ascension/blob/d4f4b9a603524d53b03436c370adf4756e5ca616/lib/ascension/parse/card.rb#L25-L32 | train |
lyjia/zog | lib/zog/heart.rb | Zog.Heart.method_missing | def method_missing(meth, *args, &block)
if @categories.include?(meth)
if block_given?
args[0] = yield block
end
self::msg(meth, args[0])
else
super
end
end | ruby | def method_missing(meth, *args, &block)
if @categories.include?(meth)
if block_given?
args[0] = yield block
end
self::msg(meth, args[0])
else
super
end
end | [
"def",
"method_missing",
"(",
"meth",
",",
"*",
"args",
",",
"&",
"block",
")",
"if",
"@categories",
".",
"include?",
"(",
"meth",
")",
"if",
"block_given?",
"args",
"[",
"0",
"]",
"=",
"yield",
"block",
"end",
"self",
"::",
"msg",
"(",
"meth",
",",
... | This is what responds to Zog.info, Zog.error, etc | [
"This",
"is",
"what",
"responds",
"to",
"Zog",
".",
"info",
"Zog",
".",
"error",
"etc"
] | c7db39ee324f925e19ed8ed7b96b51ec734f6992 | https://github.com/lyjia/zog/blob/c7db39ee324f925e19ed8ed7b96b51ec734f6992/lib/zog/heart.rb#L100-L114 | train |
phildionne/associates | lib/associates.rb | Associates.ClassMethods.associate | def associate(model, options = {})
options[:only] = Array(options[:only])
options[:except] = Array(options[:except])
options[:depends_on] = Array(options[:depends_on])
options = {
delegate: true
}.merge(options)
associate = build_associate(model, options)
se... | ruby | def associate(model, options = {})
options[:only] = Array(options[:only])
options[:except] = Array(options[:except])
options[:depends_on] = Array(options[:depends_on])
options = {
delegate: true
}.merge(options)
associate = build_associate(model, options)
se... | [
"def",
"associate",
"(",
"model",
",",
"options",
"=",
"{",
"}",
")",
"options",
"[",
":only",
"]",
"=",
"Array",
"(",
"options",
"[",
":only",
"]",
")",
"options",
"[",
":except",
"]",
"=",
"Array",
"(",
"options",
"[",
":except",
"]",
")",
"optio... | Defines an associated model
@example
class User
include Associates
associate :user, only: :username
end
@param model [Symbol, Class]
@param [Hash] options
@option options [Symbol, Array] :only Only generate methods for the given attributes
@option options [Symbol, Array] :except Generate all th... | [
"Defines",
"an",
"associated",
"model"
] | 630edcc47340a73ad787feaf2cdf326b4487bb9f | https://github.com/phildionne/associates/blob/630edcc47340a73ad787feaf2cdf326b4487bb9f/lib/associates.rb#L64-L79 | train |
phildionne/associates | lib/associates.rb | Associates.ClassMethods.build_associate | def build_associate(model, options = {})
model_name = model.to_s.underscore
model_klass = (options[:class_name] || model).to_s.classify.constantize
dependent_associate_names = options[:depends_on].map(&:to_s)
attribute_names = extract_attribute_names(model_... | ruby | def build_associate(model, options = {})
model_name = model.to_s.underscore
model_klass = (options[:class_name] || model).to_s.classify.constantize
dependent_associate_names = options[:depends_on].map(&:to_s)
attribute_names = extract_attribute_names(model_... | [
"def",
"build_associate",
"(",
"model",
",",
"options",
"=",
"{",
"}",
")",
"model_name",
"=",
"model",
".",
"to_s",
".",
"underscore",
"model_klass",
"=",
"(",
"options",
"[",
":class_name",
"]",
"||",
"model",
")",
".",
"to_s",
".",
"classify",
".",
... | Builds an associate
@param model [Symbol, Class]
@param options [Hash]
@return [Item] | [
"Builds",
"an",
"associate"
] | 630edcc47340a73ad787feaf2cdf326b4487bb9f | https://github.com/phildionne/associates/blob/630edcc47340a73ad787feaf2cdf326b4487bb9f/lib/associates.rb#L89-L100 | train |
phildionne/associates | lib/associates.rb | Associates.ClassMethods.ensure_attribute_uniqueness | def ensure_attribute_uniqueness(associates_attribute_names, attribute_names)
attribute_names.each do |attribute_name|
if associates_attribute_names.include?(attribute_name)
raise NameError, "already defined attribute name '#{attribute_name}' for #{name}(#{object_id})"
end
end
e... | ruby | def ensure_attribute_uniqueness(associates_attribute_names, attribute_names)
attribute_names.each do |attribute_name|
if associates_attribute_names.include?(attribute_name)
raise NameError, "already defined attribute name '#{attribute_name}' for #{name}(#{object_id})"
end
end
e... | [
"def",
"ensure_attribute_uniqueness",
"(",
"associates_attribute_names",
",",
"attribute_names",
")",
"attribute_names",
".",
"each",
"do",
"|",
"attribute_name",
"|",
"if",
"associates_attribute_names",
".",
"include?",
"(",
"attribute_name",
")",
"raise",
"NameError",
... | Ensure associate attribute names don't clash with already declared ones
@param associates_attribute_names [Array]
@param attribute_names [Array] | [
"Ensure",
"associate",
"attribute",
"names",
"don",
"t",
"clash",
"with",
"already",
"declared",
"ones"
] | 630edcc47340a73ad787feaf2cdf326b4487bb9f | https://github.com/phildionne/associates/blob/630edcc47340a73ad787feaf2cdf326b4487bb9f/lib/associates.rb#L116-L122 | train |
phildionne/associates | lib/associates.rb | Associates.ClassMethods.ensure_dependent_names_existence | def ensure_dependent_names_existence(associates_names, dependent_associate_names)
dependent_associate_names.each do |dependent_name|
unless associates_names.include?(dependent_name)
raise NameError, "undefined associated model '#{dependent_name}' for #{name}(#{object_id})"
end
end
... | ruby | def ensure_dependent_names_existence(associates_names, dependent_associate_names)
dependent_associate_names.each do |dependent_name|
unless associates_names.include?(dependent_name)
raise NameError, "undefined associated model '#{dependent_name}' for #{name}(#{object_id})"
end
end
... | [
"def",
"ensure_dependent_names_existence",
"(",
"associates_names",
",",
"dependent_associate_names",
")",
"dependent_associate_names",
".",
"each",
"do",
"|",
"dependent_name",
"|",
"unless",
"associates_names",
".",
"include?",
"(",
"dependent_name",
")",
"raise",
"Name... | Ensure associate dependent names exists
@param associates_names [Array]
@param dependent_associate_names [Array] | [
"Ensure",
"associate",
"dependent",
"names",
"exists"
] | 630edcc47340a73ad787feaf2cdf326b4487bb9f | https://github.com/phildionne/associates/blob/630edcc47340a73ad787feaf2cdf326b4487bb9f/lib/associates.rb#L128-L134 | train |
phildionne/associates | lib/associates.rb | Associates.ClassMethods.define_associate_delegation | def define_associate_delegation(associate)
methods = [associate.attribute_names, associate.attribute_names.map { |attr| "#{attr}=" }].flatten
send(:delegate, *methods, to: associate.name)
end | ruby | def define_associate_delegation(associate)
methods = [associate.attribute_names, associate.attribute_names.map { |attr| "#{attr}=" }].flatten
send(:delegate, *methods, to: associate.name)
end | [
"def",
"define_associate_delegation",
"(",
"associate",
")",
"methods",
"=",
"[",
"associate",
".",
"attribute_names",
",",
"associate",
".",
"attribute_names",
".",
"map",
"{",
"|",
"attr",
"|",
"\"#{attr}=\"",
"}",
"]",
".",
"flatten",
"send",
"(",
":delegat... | Define associated model attribute methods delegation
@param associate [Item] | [
"Define",
"associated",
"model",
"attribute",
"methods",
"delegation"
] | 630edcc47340a73ad787feaf2cdf326b4487bb9f | https://github.com/phildionne/associates/blob/630edcc47340a73ad787feaf2cdf326b4487bb9f/lib/associates.rb#L156-L159 | train |
phildionne/associates | lib/associates.rb | Associates.ClassMethods.define_associate_instance_setter_method | def define_associate_instance_setter_method(associate)
define_method "#{associate.name}=" do |object|
unless object.is_a?(associate.klass)
raise ArgumentError, "#{associate.klass}(##{associate.klass.object_id}) expected, got #{object.class}(##{object.class.object_id})"
end
insta... | ruby | def define_associate_instance_setter_method(associate)
define_method "#{associate.name}=" do |object|
unless object.is_a?(associate.klass)
raise ArgumentError, "#{associate.klass}(##{associate.klass.object_id}) expected, got #{object.class}(##{object.class.object_id})"
end
insta... | [
"def",
"define_associate_instance_setter_method",
"(",
"associate",
")",
"define_method",
"\"#{associate.name}=\"",
"do",
"|",
"object",
"|",
"unless",
"object",
".",
"is_a?",
"(",
"associate",
".",
"klass",
")",
"raise",
"ArgumentError",
",",
"\"#{associate.klass}(##{a... | Define associated model instance setter method
@example
@association.user = User.new
@param associate [Item] | [
"Define",
"associated",
"model",
"instance",
"setter",
"method"
] | 630edcc47340a73ad787feaf2cdf326b4487bb9f | https://github.com/phildionne/associates/blob/630edcc47340a73ad787feaf2cdf326b4487bb9f/lib/associates.rb#L168-L183 | train |
phildionne/associates | lib/associates.rb | Associates.ClassMethods.define_associate_instance_getter_method | def define_associate_instance_getter_method(associate)
define_method associate.name do
instance = instance_variable_get("@#{associate.name}") || instance_variable_set("@#{associate.name}", associate.klass.new)
depending = associates.select { |_associate| _associate.dependent_names.include?(associ... | ruby | def define_associate_instance_getter_method(associate)
define_method associate.name do
instance = instance_variable_get("@#{associate.name}") || instance_variable_set("@#{associate.name}", associate.klass.new)
depending = associates.select { |_associate| _associate.dependent_names.include?(associ... | [
"def",
"define_associate_instance_getter_method",
"(",
"associate",
")",
"define_method",
"associate",
".",
"name",
"do",
"instance",
"=",
"instance_variable_get",
"(",
"\"@#{associate.name}\"",
")",
"||",
"instance_variable_set",
"(",
"\"@#{associate.name}\"",
",",
"associ... | Define associated model instance getter method
@example
@association.user
@param associate [Item] | [
"Define",
"associated",
"model",
"instance",
"getter",
"method"
] | 630edcc47340a73ad787feaf2cdf326b4487bb9f | https://github.com/phildionne/associates/blob/630edcc47340a73ad787feaf2cdf326b4487bb9f/lib/associates.rb#L192-L204 | train |
barkerest/incline | app/mailers/incline/user_mailer.rb | Incline.UserMailer.account_activation | def account_activation(data = {})
@data = {
user: nil,
client_ip: '0.0.0.0'
}.merge(data || {})
raise unless data[:user]
mail to: data[:user].email, subject: 'Account activation'
end | ruby | def account_activation(data = {})
@data = {
user: nil,
client_ip: '0.0.0.0'
}.merge(data || {})
raise unless data[:user]
mail to: data[:user].email, subject: 'Account activation'
end | [
"def",
"account_activation",
"(",
"data",
"=",
"{",
"}",
")",
"@data",
"=",
"{",
"user",
":",
"nil",
",",
"client_ip",
":",
"'0.0.0.0'",
"}",
".",
"merge",
"(",
"data",
"||",
"{",
"}",
")",
"raise",
"unless",
"data",
"[",
":user",
"]",
"mail",
"to"... | Sends the activation email to a new user. | [
"Sends",
"the",
"activation",
"email",
"to",
"a",
"new",
"user",
"."
] | 1ff08db7aa8ab7f86b223268b700bc67d15bb8aa | https://github.com/barkerest/incline/blob/1ff08db7aa8ab7f86b223268b700bc67d15bb8aa/app/mailers/incline/user_mailer.rb#L11-L18 | train |
barkerest/incline | app/mailers/incline/user_mailer.rb | Incline.UserMailer.invalid_password_reset | def invalid_password_reset(data = {})
@data = {
email: nil,
message: 'This email address is not associated with an existing account.',
client_ip: '0.0.0.0'
}.merge(data || {})
raise unless data[:email]
mail to: data[:email], subject: 'Password reset request'
end | ruby | def invalid_password_reset(data = {})
@data = {
email: nil,
message: 'This email address is not associated with an existing account.',
client_ip: '0.0.0.0'
}.merge(data || {})
raise unless data[:email]
mail to: data[:email], subject: 'Password reset request'
end | [
"def",
"invalid_password_reset",
"(",
"data",
"=",
"{",
"}",
")",
"@data",
"=",
"{",
"email",
":",
"nil",
",",
"message",
":",
"'This email address is not associated with an existing account.'",
",",
"client_ip",
":",
"'0.0.0.0'",
"}",
".",
"merge",
"(",
"data",
... | Sends an invalid password reset attempt message to a user whether they exist or not. | [
"Sends",
"an",
"invalid",
"password",
"reset",
"attempt",
"message",
"to",
"a",
"user",
"whether",
"they",
"exist",
"or",
"not",
"."
] | 1ff08db7aa8ab7f86b223268b700bc67d15bb8aa | https://github.com/barkerest/incline/blob/1ff08db7aa8ab7f86b223268b700bc67d15bb8aa/app/mailers/incline/user_mailer.rb#L33-L41 | train |
siefca/configuration-blocks | lib/configuration-blocks/core.rb | ConfigurationBlocks.ClassMethods.configuration_module | def configuration_module(base = self)
Module.new.tap do |cm|
delegators = get_configuration_methods
base = send(base) if base.is_a?(Symbol)
cm.extend Module.new {
delegators.each do |method|
module_eval do
define_method(method) do |*args|
... | ruby | def configuration_module(base = self)
Module.new.tap do |cm|
delegators = get_configuration_methods
base = send(base) if base.is_a?(Symbol)
cm.extend Module.new {
delegators.each do |method|
module_eval do
define_method(method) do |*args|
... | [
"def",
"configuration_module",
"(",
"base",
"=",
"self",
")",
"Module",
".",
"new",
".",
"tap",
"do",
"|",
"cm",
"|",
"delegators",
"=",
"get_configuration_methods",
"base",
"=",
"send",
"(",
"base",
")",
"if",
"base",
".",
"is_a?",
"(",
"Symbol",
")",
... | Creates and returns anonymous module containing
delegators that point to methods from a class this module is included in
or the given +base+.
@param base [Object,Symbol] base object which delegators will point to (defaults to object on which
this method has been called). If symbol is given, then it should contain... | [
"Creates",
"and",
"returns",
"anonymous",
"module",
"containing",
"delegators",
"that",
"point",
"to",
"methods",
"from",
"a",
"class",
"this",
"module",
"is",
"included",
"in",
"or",
"the",
"given",
"+",
"base",
"+",
"."
] | 1b04f5f3e97639b455a473c5f9c2200cf9f18c26 | https://github.com/siefca/configuration-blocks/blob/1b04f5f3e97639b455a473c5f9c2200cf9f18c26/lib/configuration-blocks/core.rb#L84-L98 | train |
siefca/configuration-blocks | lib/configuration-blocks/core.rb | ConfigurationBlocks.ClassMethods.get_configuration_methods | def get_configuration_methods(local_only = false)
all_delegators = singleton_class.send(:cf_block_delegators) + cf_block_delegators
return all_delegators if local_only
ancestors.each_with_object(all_delegators) do |ancestor, all|
all.merge(ancestor.send(__method__, true)) if ancestor.respond_t... | ruby | def get_configuration_methods(local_only = false)
all_delegators = singleton_class.send(:cf_block_delegators) + cf_block_delegators
return all_delegators if local_only
ancestors.each_with_object(all_delegators) do |ancestor, all|
all.merge(ancestor.send(__method__, true)) if ancestor.respond_t... | [
"def",
"get_configuration_methods",
"(",
"local_only",
"=",
"false",
")",
"all_delegators",
"=",
"singleton_class",
".",
"send",
"(",
":cf_block_delegators",
")",
"+",
"cf_block_delegators",
"return",
"all_delegators",
"if",
"local_only",
"ancestors",
".",
"each_with_ob... | Gets all method names known to configuration engine.
@param local_only [Boolean] optional flag that if set, causes only methods added
by current class or module to be listed.
@return [Array<Symbol>] delegated method names | [
"Gets",
"all",
"method",
"names",
"known",
"to",
"configuration",
"engine",
"."
] | 1b04f5f3e97639b455a473c5f9c2200cf9f18c26 | https://github.com/siefca/configuration-blocks/blob/1b04f5f3e97639b455a473c5f9c2200cf9f18c26/lib/configuration-blocks/core.rb#L106-L112 | train |
siefca/configuration-blocks | lib/configuration-blocks/core.rb | ConfigurationBlocks.ClassMethods.configuration_block_delegate | def configuration_block_delegate(*methods)
methods.flatten.each { |m| cf_block_delegators.add(m.to_sym) }
@cb_conf_module = nil if @cb_conf_module
nil
end | ruby | def configuration_block_delegate(*methods)
methods.flatten.each { |m| cf_block_delegators.add(m.to_sym) }
@cb_conf_module = nil if @cb_conf_module
nil
end | [
"def",
"configuration_block_delegate",
"(",
"*",
"methods",
")",
"methods",
".",
"flatten",
".",
"each",
"{",
"|",
"m",
"|",
"cf_block_delegators",
".",
"add",
"(",
"m",
".",
"to_sym",
")",
"}",
"@cb_conf_module",
"=",
"nil",
"if",
"@cb_conf_module",
"nil",
... | This DSL method is intended to be used in a class or module to indicate which methods
should be delegated.
@param methods [Array<Symbol,String>] list of method names
@return [nil] | [
"This",
"DSL",
"method",
"is",
"intended",
"to",
"be",
"used",
"in",
"a",
"class",
"or",
"module",
"to",
"indicate",
"which",
"methods",
"should",
"be",
"delegated",
"."
] | 1b04f5f3e97639b455a473c5f9c2200cf9f18c26 | https://github.com/siefca/configuration-blocks/blob/1b04f5f3e97639b455a473c5f9c2200cf9f18c26/lib/configuration-blocks/core.rb#L119-L123 | train |
siefca/configuration-blocks | lib/configuration-blocks/core.rb | ConfigurationBlocks.ClassMethods.configuration_block_core | def configuration_block_core(conf_module, &block)
return conf_module unless block_given?
return conf_module.tap(&block) unless block.arity == 0
conf_module.module_eval(&block)
conf_module
end | ruby | def configuration_block_core(conf_module, &block)
return conf_module unless block_given?
return conf_module.tap(&block) unless block.arity == 0
conf_module.module_eval(&block)
conf_module
end | [
"def",
"configuration_block_core",
"(",
"conf_module",
",",
"&",
"block",
")",
"return",
"conf_module",
"unless",
"block_given?",
"return",
"conf_module",
".",
"tap",
"(",
"block",
")",
"unless",
"block",
".",
"arity",
"==",
"0",
"conf_module",
".",
"module_eval... | Evaluates configuration block within a context of the given module. | [
"Evaluates",
"configuration",
"block",
"within",
"a",
"context",
"of",
"the",
"given",
"module",
"."
] | 1b04f5f3e97639b455a473c5f9c2200cf9f18c26 | https://github.com/siefca/configuration-blocks/blob/1b04f5f3e97639b455a473c5f9c2200cf9f18c26/lib/configuration-blocks/core.rb#L136-L141 | train |
barkerest/barkest_core | app/helpers/barkest_core/status_helper.rb | BarkestCore.StatusHelper.show_system_status | def show_system_status(options = {})
options = {
url_on_completion: nil,
completion_button: 'Continue',
main_status: 'System is busy'
}.merge(options || {})
if block_given?
clear_system_status
Spawnling.new do
status = BarkestCore::GlobalStatus.... | ruby | def show_system_status(options = {})
options = {
url_on_completion: nil,
completion_button: 'Continue',
main_status: 'System is busy'
}.merge(options || {})
if block_given?
clear_system_status
Spawnling.new do
status = BarkestCore::GlobalStatus.... | [
"def",
"show_system_status",
"(",
"options",
"=",
"{",
"}",
")",
"options",
"=",
"{",
"url_on_completion",
":",
"nil",
",",
"completion_button",
":",
"'Continue'",
",",
"main_status",
":",
"'System is busy'",
"}",
".",
"merge",
"(",
"options",
"||",
"{",
"}"... | Shows the system status while optionally performing a long running code block.
Accepted options:
url_on_completion::
This is the URL you want to redirect to when the long running code completes.
If not set, then the completion button will have an empty HREF which means it will simply reload the status pag... | [
"Shows",
"the",
"system",
"status",
"while",
"optionally",
"performing",
"a",
"long",
"running",
"code",
"block",
"."
] | 3eeb025ec870888cacbc9bae252a39ebf9295f61 | https://github.com/barkerest/barkest_core/blob/3eeb025ec870888cacbc9bae252a39ebf9295f61/app/helpers/barkest_core/status_helper.rb#L60-L88 | train |
barkerest/barkest_core | app/helpers/barkest_core/status_helper.rb | BarkestCore.StatusHelper.clear_system_status | def clear_system_status
unless BarkestCore::GlobalStatus.locked?
# open, truncate, and close.
File.open(BarkestCore::WorkPath.system_status_file,'w').close
end
end | ruby | def clear_system_status
unless BarkestCore::GlobalStatus.locked?
# open, truncate, and close.
File.open(BarkestCore::WorkPath.system_status_file,'w').close
end
end | [
"def",
"clear_system_status",
"unless",
"BarkestCore",
"::",
"GlobalStatus",
".",
"locked?",
"# open, truncate, and close.",
"File",
".",
"open",
"(",
"BarkestCore",
"::",
"WorkPath",
".",
"system_status_file",
",",
"'w'",
")",
".",
"close",
"end",
"end"
] | Clears the system status log file.
If the file does not exist, it is created as a zero byte file.
This is important for the status checking, since if there is no log file it will report an error. | [
"Clears",
"the",
"system",
"status",
"log",
"file",
"."
] | 3eeb025ec870888cacbc9bae252a39ebf9295f61 | https://github.com/barkerest/barkest_core/blob/3eeb025ec870888cacbc9bae252a39ebf9295f61/app/helpers/barkest_core/status_helper.rb#L96-L101 | train |
bblack16/bblib-ruby | lib/bblib/core/mixins/numeric_enhancements.rb | BBLib.NumericEnhancements.to_delimited_s | def to_delimited_s(delim = ',')
split = self.to_s.split('.')
split[0] = split.first.reverse.gsub(/(\d{3})/, "\\1#{delim}").reverse
split.join('.').uncapsulate(',')
end | ruby | def to_delimited_s(delim = ',')
split = self.to_s.split('.')
split[0] = split.first.reverse.gsub(/(\d{3})/, "\\1#{delim}").reverse
split.join('.').uncapsulate(',')
end | [
"def",
"to_delimited_s",
"(",
"delim",
"=",
"','",
")",
"split",
"=",
"self",
".",
"to_s",
".",
"split",
"(",
"'.'",
")",
"split",
"[",
"0",
"]",
"=",
"split",
".",
"first",
".",
"reverse",
".",
"gsub",
"(",
"/",
"\\d",
"/",
",",
"\"\\\\1#{delim}\"... | Convert this integer into a string with every three digits separated by a delimiter
on the left side of the decimal | [
"Convert",
"this",
"integer",
"into",
"a",
"string",
"with",
"every",
"three",
"digits",
"separated",
"by",
"a",
"delimiter",
"on",
"the",
"left",
"side",
"of",
"the",
"decimal"
] | 274eedeb583cc56243884fd041645488d5bd08a9 | https://github.com/bblack16/bblib-ruby/blob/274eedeb583cc56243884fd041645488d5bd08a9/lib/bblib/core/mixins/numeric_enhancements.rb#L24-L28 | train |
barkerest/incline | lib/incline/json_log_formatter.rb | Incline.JsonLogFormatter.call | def call(sev, time, _, msg) #:nodoc:
level = ({
Logger::DEBUG => 'DEBUG',
Logger::INFO => 'INFO',
Logger::WARN => 'WARN',
Logger::ERROR => 'ERROR',
Logger::FATAL => 'FATAL',
}[sev] || sev.to_s).upcase
if msg.present? && AUTO_DEBUG_PATTERNS... | ruby | def call(sev, time, _, msg) #:nodoc:
level = ({
Logger::DEBUG => 'DEBUG',
Logger::INFO => 'INFO',
Logger::WARN => 'WARN',
Logger::ERROR => 'ERROR',
Logger::FATAL => 'FATAL',
}[sev] || sev.to_s).upcase
if msg.present? && AUTO_DEBUG_PATTERNS... | [
"def",
"call",
"(",
"sev",
",",
"time",
",",
"_",
",",
"msg",
")",
"#:nodoc:",
"level",
"=",
"(",
"{",
"Logger",
"::",
"DEBUG",
"=>",
"'DEBUG'",
",",
"Logger",
"::",
"INFO",
"=>",
"'INFO'",
",",
"Logger",
"::",
"WARN",
"=>",
"'WARN'",
",",
"Logger"... | Overrides the default formatter behavior to log a JSON line. | [
"Overrides",
"the",
"default",
"formatter",
"behavior",
"to",
"log",
"a",
"JSON",
"line",
"."
] | 1ff08db7aa8ab7f86b223268b700bc67d15bb8aa | https://github.com/barkerest/incline/blob/1ff08db7aa8ab7f86b223268b700bc67d15bb8aa/lib/incline/json_log_formatter.rb#L17-L53 | train |
ffmike/shoehorn | lib/shoehorn/business_cards.rb | Shoehorn.BusinessCards.estimate_pdf_business_card_report | def estimate_pdf_business_card_report
xml = Builder::XmlMarkup.new
xml.instruct!
xml.Request(:xmlns => "urn:sbx:apis:SbxBaseComponents") do |xml|
connection.requester_credentials_block(xml)
xml.EstimatePdfBusinessCardReport
end
response = connection.post_xml(xml)
docu... | ruby | def estimate_pdf_business_card_report
xml = Builder::XmlMarkup.new
xml.instruct!
xml.Request(:xmlns => "urn:sbx:apis:SbxBaseComponents") do |xml|
connection.requester_credentials_block(xml)
xml.EstimatePdfBusinessCardReport
end
response = connection.post_xml(xml)
docu... | [
"def",
"estimate_pdf_business_card_report",
"xml",
"=",
"Builder",
"::",
"XmlMarkup",
".",
"new",
"xml",
".",
"instruct!",
"xml",
".",
"Request",
"(",
":xmlns",
"=>",
"\"urn:sbx:apis:SbxBaseComponents\"",
")",
"do",
"|",
"xml",
"|",
"connection",
".",
"requester_c... | Returns the estimated number of cards and number of pages for exporting Business Cards as PDF | [
"Returns",
"the",
"estimated",
"number",
"of",
"cards",
"and",
"number",
"of",
"pages",
"for",
"exporting",
"Business",
"Cards",
"as",
"PDF"
] | b3da6d2bc4bd49652ac76197d01077b14bafb70a | https://github.com/ffmike/shoehorn/blob/b3da6d2bc4bd49652ac76197d01077b14bafb70a/lib/shoehorn/business_cards.rb#L56-L68 | train |
ffmike/shoehorn | lib/shoehorn/business_cards.rb | Shoehorn.BusinessCards.generate_pdf_business_card_report | def generate_pdf_business_card_report
xml = Builder::XmlMarkup.new
xml.instruct!
xml.Request(:xmlns => "urn:sbx:apis:SbxBaseComponents") do |xml|
connection.requester_credentials_block(xml)
xml.GeneratePdfBusinessCardReport
end
response = connection.post_xml(xml)
docu... | ruby | def generate_pdf_business_card_report
xml = Builder::XmlMarkup.new
xml.instruct!
xml.Request(:xmlns => "urn:sbx:apis:SbxBaseComponents") do |xml|
connection.requester_credentials_block(xml)
xml.GeneratePdfBusinessCardReport
end
response = connection.post_xml(xml)
docu... | [
"def",
"generate_pdf_business_card_report",
"xml",
"=",
"Builder",
"::",
"XmlMarkup",
".",
"new",
"xml",
".",
"instruct!",
"xml",
".",
"Request",
"(",
":xmlns",
"=>",
"\"urn:sbx:apis:SbxBaseComponents\"",
")",
"do",
"|",
"xml",
"|",
"connection",
".",
"requester_c... | Returns a URL for one-time download of Business Cards as PDF | [
"Returns",
"a",
"URL",
"for",
"one",
"-",
"time",
"download",
"of",
"Business",
"Cards",
"as",
"PDF"
] | b3da6d2bc4bd49652ac76197d01077b14bafb70a | https://github.com/ffmike/shoehorn/blob/b3da6d2bc4bd49652ac76197d01077b14bafb70a/lib/shoehorn/business_cards.rb#L71-L81 | train |
ffmike/shoehorn | lib/shoehorn/business_cards.rb | Shoehorn.BusinessCards.notify_preference | def notify_preference
xml = Builder::XmlMarkup.new
xml.instruct!
xml.Request(:xmlns => "urn:sbx:apis:SbxBaseComponents") do |xml|
connection.requester_credentials_block(xml)
xml.GetBusinessCardNotifyPreferenceCall
end
response = connection.post_xml(xml)
document = REX... | ruby | def notify_preference
xml = Builder::XmlMarkup.new
xml.instruct!
xml.Request(:xmlns => "urn:sbx:apis:SbxBaseComponents") do |xml|
connection.requester_credentials_block(xml)
xml.GetBusinessCardNotifyPreferenceCall
end
response = connection.post_xml(xml)
document = REX... | [
"def",
"notify_preference",
"xml",
"=",
"Builder",
"::",
"XmlMarkup",
".",
"new",
"xml",
".",
"instruct!",
"xml",
".",
"Request",
"(",
":xmlns",
"=>",
"\"urn:sbx:apis:SbxBaseComponents\"",
")",
"do",
"|",
"xml",
"|",
"connection",
".",
"requester_credentials_block... | Does the user have business card auto-share mode turned on? | [
"Does",
"the",
"user",
"have",
"business",
"card",
"auto",
"-",
"share",
"mode",
"turned",
"on?"
] | b3da6d2bc4bd49652ac76197d01077b14bafb70a | https://github.com/ffmike/shoehorn/blob/b3da6d2bc4bd49652ac76197d01077b14bafb70a/lib/shoehorn/business_cards.rb#L106-L116 | train |
ffmike/shoehorn | lib/shoehorn/business_cards.rb | Shoehorn.BusinessCards.notify_preference= | def notify_preference=(value)
if value
translated_value = "1"
else
translated_value = "0"
end
xml = Builder::XmlMarkup.new
xml.instruct!
xml.Request(:xmlns => "urn:sbx:apis:SbxBaseComponents") do |xml|
connection.requester_credentials_block(xml)
xml.Se... | ruby | def notify_preference=(value)
if value
translated_value = "1"
else
translated_value = "0"
end
xml = Builder::XmlMarkup.new
xml.instruct!
xml.Request(:xmlns => "urn:sbx:apis:SbxBaseComponents") do |xml|
connection.requester_credentials_block(xml)
xml.Se... | [
"def",
"notify_preference",
"=",
"(",
"value",
")",
"if",
"value",
"translated_value",
"=",
"\"1\"",
"else",
"translated_value",
"=",
"\"0\"",
"end",
"xml",
"=",
"Builder",
"::",
"XmlMarkup",
".",
"new",
"xml",
".",
"instruct!",
"xml",
".",
"Request",
"(",
... | Turn auto-share mode on or off | [
"Turn",
"auto",
"-",
"share",
"mode",
"on",
"or",
"off"
] | b3da6d2bc4bd49652ac76197d01077b14bafb70a | https://github.com/ffmike/shoehorn/blob/b3da6d2bc4bd49652ac76197d01077b14bafb70a/lib/shoehorn/business_cards.rb#L119-L136 | train |
ffmike/shoehorn | lib/shoehorn/business_cards.rb | Shoehorn.BusinessCards.auto_share_contact_details | def auto_share_contact_details
xml = Builder::XmlMarkup.new
xml.instruct!
xml.Request(:xmlns => "urn:sbx:apis:SbxBaseComponents") do |xml|
connection.requester_credentials_block(xml)
xml.GetAutoShareContactDetailsCall
end
response = connection.post_xml(xml)
details = ... | ruby | def auto_share_contact_details
xml = Builder::XmlMarkup.new
xml.instruct!
xml.Request(:xmlns => "urn:sbx:apis:SbxBaseComponents") do |xml|
connection.requester_credentials_block(xml)
xml.GetAutoShareContactDetailsCall
end
response = connection.post_xml(xml)
details = ... | [
"def",
"auto_share_contact_details",
"xml",
"=",
"Builder",
"::",
"XmlMarkup",
".",
"new",
"xml",
".",
"instruct!",
"xml",
".",
"Request",
"(",
":xmlns",
"=>",
"\"urn:sbx:apis:SbxBaseComponents\"",
")",
"do",
"|",
"xml",
"|",
"connection",
".",
"requester_credenti... | Get user's contact information that is sent out with business cards | [
"Get",
"user",
"s",
"contact",
"information",
"that",
"is",
"sent",
"out",
"with",
"business",
"cards"
] | b3da6d2bc4bd49652ac76197d01077b14bafb70a | https://github.com/ffmike/shoehorn/blob/b3da6d2bc4bd49652ac76197d01077b14bafb70a/lib/shoehorn/business_cards.rb#L151-L167 | train |
devnull-tools/yummi | lib/yummi/colorizers.rb | Yummi.Colorizer.color_for | def color_for (arg)
arg = Yummi::Context::new(arg) unless arg.is_a? Context
call(arg)
end | ruby | def color_for (arg)
arg = Yummi::Context::new(arg) unless arg.is_a? Context
call(arg)
end | [
"def",
"color_for",
"(",
"arg",
")",
"arg",
"=",
"Yummi",
"::",
"Context",
"::",
"new",
"(",
"arg",
")",
"unless",
"arg",
".",
"is_a?",
"Context",
"call",
"(",
"arg",
")",
"end"
] | Returns the color for the given value
=== Args
A context or a value. | [
"Returns",
"the",
"color",
"for",
"the",
"given",
"value"
] | b31cc1ef9a9f4ca1c22e0b77a84a1995bde5c2df | https://github.com/devnull-tools/yummi/blob/b31cc1ef9a9f4ca1c22e0b77a84a1995bde5c2df/lib/yummi/colorizers.rb#L53-L56 | train |
inside-track/remi | lib/remi/data_subjects/csv_file.rb | Remi.Parser::CsvFile.parse | def parse(data)
# Assumes that each file has exactly the same structure
result_df = nil
Array(data).each_with_index do |filename, idx|
filename = filename.to_s
logger.info "Converting #{filename} to a dataframe"
processed_filename = preprocess(filename)
csv_df = Daru::... | ruby | def parse(data)
# Assumes that each file has exactly the same structure
result_df = nil
Array(data).each_with_index do |filename, idx|
filename = filename.to_s
logger.info "Converting #{filename} to a dataframe"
processed_filename = preprocess(filename)
csv_df = Daru::... | [
"def",
"parse",
"(",
"data",
")",
"# Assumes that each file has exactly the same structure",
"result_df",
"=",
"nil",
"Array",
"(",
"data",
")",
".",
"each_with_index",
"do",
"|",
"filename",
",",
"idx",
"|",
"filename",
"=",
"filename",
".",
"to_s",
"logger",
"... | Converts a list of filenames into a dataframe after parsing them
according ot the csv options that were set
@param data [Object] Extracted data that needs to be parsed
@return [Remi::DataFrame] The data converted into a dataframe | [
"Converts",
"a",
"list",
"of",
"filenames",
"into",
"a",
"dataframe",
"after",
"parsing",
"them",
"according",
"ot",
"the",
"csv",
"options",
"that",
"were",
"set"
] | f7e5f28f08f8c0403e04cd82d6fc14b6b2c362a7 | https://github.com/inside-track/remi/blob/f7e5f28f08f8c0403e04cd82d6fc14b6b2c362a7/lib/remi/data_subjects/csv_file.rb#L71-L96 | train |
inside-track/remi | lib/remi/data_subjects/csv_file.rb | Remi.Encoder::CsvFile.encode | def encode(dataframe)
logger.info "Writing CSV file to temporary location #{@working_file}"
label_columns = self.fields.reduce({}) { |h, (k, v)|
if v[:label]
h[k] = v[:label].to_sym
end
h
}
dataframe.rename_vectors label_columns
dataframe.write_csv @worki... | ruby | def encode(dataframe)
logger.info "Writing CSV file to temporary location #{@working_file}"
label_columns = self.fields.reduce({}) { |h, (k, v)|
if v[:label]
h[k] = v[:label].to_sym
end
h
}
dataframe.rename_vectors label_columns
dataframe.write_csv @worki... | [
"def",
"encode",
"(",
"dataframe",
")",
"logger",
".",
"info",
"\"Writing CSV file to temporary location #{@working_file}\"",
"label_columns",
"=",
"self",
".",
"fields",
".",
"reduce",
"(",
"{",
"}",
")",
"{",
"|",
"h",
",",
"(",
"k",
",",
"v",
")",
"|",
... | Converts the dataframe to a CSV file stored in the local work directory.
If labels are present write the CSV file with those headers but maintain
the structure of the original dataframe
@param dataframe [Remi::DataFrame] The dataframe to be encoded
@return [Object] The path to the file | [
"Converts",
"the",
"dataframe",
"to",
"a",
"CSV",
"file",
"stored",
"in",
"the",
"local",
"work",
"directory",
".",
"If",
"labels",
"are",
"present",
"write",
"the",
"CSV",
"file",
"with",
"those",
"headers",
"but",
"maintain",
"the",
"structure",
"of",
"t... | f7e5f28f08f8c0403e04cd82d6fc14b6b2c362a7 | https://github.com/inside-track/remi/blob/f7e5f28f08f8c0403e04cd82d6fc14b6b2c362a7/lib/remi/data_subjects/csv_file.rb#L167-L179 | train |
riddopic/garcun | lib/garcon/task/immediate_executor.rb | Garcon.ImmediateExecutor.post | def post(*args, &task)
raise ArgumentError, 'no block given' unless block_given?
return false unless running?
task.call(*args)
true
end | ruby | def post(*args, &task)
raise ArgumentError, 'no block given' unless block_given?
return false unless running?
task.call(*args)
true
end | [
"def",
"post",
"(",
"*",
"args",
",",
"&",
"task",
")",
"raise",
"ArgumentError",
",",
"'no block given'",
"unless",
"block_given?",
"return",
"false",
"unless",
"running?",
"task",
".",
"call",
"(",
"args",
")",
"true",
"end"
] | Creates a new executor
@!macro executor_method_post | [
"Creates",
"a",
"new",
"executor"
] | c2409bd8cf9c14b967a719810dab5269d69b42de | https://github.com/riddopic/garcun/blob/c2409bd8cf9c14b967a719810dab5269d69b42de/lib/garcon/task/immediate_executor.rb#L44-L49 | train |
DigitPaint/html_mockup | lib/html_mockup/template.rb | HtmlMockup.Template.target_extension | def target_extension
return @target_extension if @target_extension
if type = MIME::Types[self.target_mime_type].first
# Dirty little hack to enforce the use of .html instead of .htm
if type.sub_type == "html"
@target_extension = "html"
else
@target_extension = ty... | ruby | def target_extension
return @target_extension if @target_extension
if type = MIME::Types[self.target_mime_type].first
# Dirty little hack to enforce the use of .html instead of .htm
if type.sub_type == "html"
@target_extension = "html"
else
@target_extension = ty... | [
"def",
"target_extension",
"return",
"@target_extension",
"if",
"@target_extension",
"if",
"type",
"=",
"MIME",
"::",
"Types",
"[",
"self",
".",
"target_mime_type",
"]",
".",
"first",
"# Dirty little hack to enforce the use of .html instead of .htm",
"if",
"type",
".",
... | Try to infer the final extension of the output file. | [
"Try",
"to",
"infer",
"the",
"final",
"extension",
"of",
"the",
"output",
"file",
"."
] | 976edadc01216b82a8cea177f53fb32559eaf41e | https://github.com/DigitPaint/html_mockup/blob/976edadc01216b82a8cea177f53fb32559eaf41e/lib/html_mockup/template.rb#L79-L92 | train |
meloncargo/dragonfly-azure_data_store | lib/dragonfly/azure_data_store.rb | Dragonfly.AzureDataStore.update_metadata | def update_metadata(uid)
return false unless store_meta
path = full_path(uid)
meta = storage(:get_blob, container_name, path)[0].metadata
return false if meta.present?
meta = meta_from_file(path)
return false if meta.blank?
storage(:set_blob_metadata, container_name, path, meta... | ruby | def update_metadata(uid)
return false unless store_meta
path = full_path(uid)
meta = storage(:get_blob, container_name, path)[0].metadata
return false if meta.present?
meta = meta_from_file(path)
return false if meta.blank?
storage(:set_blob_metadata, container_name, path, meta... | [
"def",
"update_metadata",
"(",
"uid",
")",
"return",
"false",
"unless",
"store_meta",
"path",
"=",
"full_path",
"(",
"uid",
")",
"meta",
"=",
"storage",
"(",
":get_blob",
",",
"container_name",
",",
"path",
")",
"[",
"0",
"]",
".",
"metadata",
"return",
... | Updates metadata of file and deletes old meta file from legacy mode. | [
"Updates",
"metadata",
"of",
"file",
"and",
"deletes",
"old",
"meta",
"file",
"from",
"legacy",
"mode",
"."
] | fd7d1e7507660fc2f5bc7dae8d9dbb2bfc634dc4 | https://github.com/meloncargo/dragonfly-azure_data_store/blob/fd7d1e7507660fc2f5bc7dae8d9dbb2bfc634dc4/lib/dragonfly/azure_data_store.rb#L46-L58 | train |
Thermatix/ruta | lib/ruta/router.rb | Ruta.Router.map | def map ref,route, options={}
context = Context.collection[get_context]
context.routes[ref]= Route.new(route, context,options)
end | ruby | def map ref,route, options={}
context = Context.collection[get_context]
context.routes[ref]= Route.new(route, context,options)
end | [
"def",
"map",
"ref",
",",
"route",
",",
"options",
"=",
"{",
"}",
"context",
"=",
"Context",
".",
"collection",
"[",
"get_context",
"]",
"context",
".",
"routes",
"[",
"ref",
"]",
"=",
"Route",
".",
"new",
"(",
"route",
",",
"context",
",",
"options"... | map a route
@param [Symbol] ref to map route to for easy future reference | [
"map",
"a",
"route"
] | b4a6e3bc7c0c4b66c804023d638b173e3f61e157 | https://github.com/Thermatix/ruta/blob/b4a6e3bc7c0c4b66c804023d638b173e3f61e157/lib/ruta/router.rb#L32-L35 | train |
Thermatix/ruta | lib/ruta/router.rb | Ruta.Router.root_to | def root_to reference
Router.set_root_to reference
context = Context.collection[reference]
context.routes[:root]= Route.new('/', context,{ context: reference})
end | ruby | def root_to reference
Router.set_root_to reference
context = Context.collection[reference]
context.routes[:root]= Route.new('/', context,{ context: reference})
end | [
"def",
"root_to",
"reference",
"Router",
".",
"set_root_to",
"reference",
"context",
"=",
"Context",
".",
"collection",
"[",
"reference",
"]",
"context",
".",
"routes",
"[",
":root",
"]",
"=",
"Route",
".",
"new",
"(",
"'/'",
",",
"context",
",",
"{",
"c... | set the root context, this is the initial context that will be renered by the router
@note there is only ever one root, calling this multiple times will over right the original root
@param [Symbol] reference to context | [
"set",
"the",
"root",
"context",
"this",
"is",
"the",
"initial",
"context",
"that",
"will",
"be",
"renered",
"by",
"the",
"router"
] | b4a6e3bc7c0c4b66c804023d638b173e3f61e157 | https://github.com/Thermatix/ruta/blob/b4a6e3bc7c0c4b66c804023d638b173e3f61e157/lib/ruta/router.rb#L41-L45 | train |
maynard/kenna | lib/kenna.rb | Kenna.Api.fakeUser | def fakeUser
@roles = ['administrator', 'normal user', 'Linux Test Environment']
@role = @roles[rand(0..2)]
@fake_user = {
"user":
{
"firstname": Faker::Name.first_name,
"lastname": Faker::Name.last_name,... | ruby | def fakeUser
@roles = ['administrator', 'normal user', 'Linux Test Environment']
@role = @roles[rand(0..2)]
@fake_user = {
"user":
{
"firstname": Faker::Name.first_name,
"lastname": Faker::Name.last_name,... | [
"def",
"fakeUser",
"@roles",
"=",
"[",
"'administrator'",
",",
"'normal user'",
",",
"'Linux Test Environment'",
"]",
"@role",
"=",
"@roles",
"[",
"rand",
"(",
"0",
"..",
"2",
")",
"]",
"@fake_user",
"=",
"{",
"\"user\"",
":",
"{",
"\"firstname\"",
":",
"F... | Generate a unique fake user for testing | [
"Generate",
"a",
"unique",
"fake",
"user",
"for",
"testing"
] | 71eebceccf37ac571d1bd161c4cfaa0a276fe513 | https://github.com/maynard/kenna/blob/71eebceccf37ac571d1bd161c4cfaa0a276fe513/lib/kenna.rb#L106-L118 | train |
chrisjones-tripletri/action_command | lib/action_command/log_parser.rb | ActionCommand.LogMessage.populate | def populate(line, msg)
@line = line
@sequence = msg['sequence']
@depth = msg['depth']
@cmd = msg['cmd']
@kind = msg['kind']
@msg = msg['msg']
@key = msg['key']
end | ruby | def populate(line, msg)
@line = line
@sequence = msg['sequence']
@depth = msg['depth']
@cmd = msg['cmd']
@kind = msg['kind']
@msg = msg['msg']
@key = msg['key']
end | [
"def",
"populate",
"(",
"line",
",",
"msg",
")",
"@line",
"=",
"line",
"@sequence",
"=",
"msg",
"[",
"'sequence'",
"]",
"@depth",
"=",
"msg",
"[",
"'depth'",
"]",
"@cmd",
"=",
"msg",
"[",
"'cmd'",
"]",
"@kind",
"=",
"msg",
"[",
"'kind'",
"]",
"@msg... | Create a new log message | [
"Create",
"a",
"new",
"log",
"message"
] | 9b9a8ba30e407ca6d88a62a164d1dc22ba149874 | https://github.com/chrisjones-tripletri/action_command/blob/9b9a8ba30e407ca6d88a62a164d1dc22ba149874/lib/action_command/log_parser.rb#L11-L19 | train |
chrisjones-tripletri/action_command | lib/action_command/log_parser.rb | ActionCommand.LogParser.next | def next(msg)
# be tolerant of the fact that there might be other
# stuff in the log file.
next_line do |input, line|
if input.key?('sequence')
msg.populate(line, input) unless @sequence && @sequence != input['sequence']
return true
end
end
return false... | ruby | def next(msg)
# be tolerant of the fact that there might be other
# stuff in the log file.
next_line do |input, line|
if input.key?('sequence')
msg.populate(line, input) unless @sequence && @sequence != input['sequence']
return true
end
end
return false... | [
"def",
"next",
"(",
"msg",
")",
"# be tolerant of the fact that there might be other ",
"# stuff in the log file.",
"next_line",
"do",
"|",
"input",
",",
"line",
"|",
"if",
"input",
".",
"key?",
"(",
"'sequence'",
")",
"msg",
".",
"populate",
"(",
"line",
",",
"... | Populates a message from the next line in the | [
"Populates",
"a",
"message",
"from",
"the",
"next",
"line",
"in",
"the"
] | 9b9a8ba30e407ca6d88a62a164d1dc22ba149874 | https://github.com/chrisjones-tripletri/action_command/blob/9b9a8ba30e407ca6d88a62a164d1dc22ba149874/lib/action_command/log_parser.rb#L80-L90 | train |
codescrum/bebox | lib/bebox/project.rb | Bebox.Project.generate_ruby_version | def generate_ruby_version
ruby_version = (RUBY_PATCHLEVEL == 0) ? RUBY_VERSION : "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
File.open("#{self.path}/.ruby-version", 'w') do |f|
f.write ruby_version
end
end | ruby | def generate_ruby_version
ruby_version = (RUBY_PATCHLEVEL == 0) ? RUBY_VERSION : "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
File.open("#{self.path}/.ruby-version", 'w') do |f|
f.write ruby_version
end
end | [
"def",
"generate_ruby_version",
"ruby_version",
"=",
"(",
"RUBY_PATCHLEVEL",
"==",
"0",
")",
"?",
"RUBY_VERSION",
":",
"\"#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}\"",
"File",
".",
"open",
"(",
"\"#{self.path}/.ruby-version\"",
",",
"'w'",
")",
"do",
"|",
"f",
"|",
"f",
... | Create rbenv local | [
"Create",
"rbenv",
"local"
] | 0d19315847103341e599d32837ab0bd75524e5be | https://github.com/codescrum/bebox/blob/0d19315847103341e599d32837ab0bd75524e5be/lib/bebox/project.rb#L84-L89 | train |
codescrum/bebox | lib/bebox/project.rb | Bebox.Project.generate_steps_templates | def generate_steps_templates
Bebox::PROVISION_STEPS.each do |step|
ssh_key = ''
step_dir = Bebox::Provision.step_name(step)
templates_path = Bebox::Project::templates_path
# Generate site.pp template
generate_file_from_template("#{templates_path}/puppet/#{step}/manifests/si... | ruby | def generate_steps_templates
Bebox::PROVISION_STEPS.each do |step|
ssh_key = ''
step_dir = Bebox::Provision.step_name(step)
templates_path = Bebox::Project::templates_path
# Generate site.pp template
generate_file_from_template("#{templates_path}/puppet/#{step}/manifests/si... | [
"def",
"generate_steps_templates",
"Bebox",
"::",
"PROVISION_STEPS",
".",
"each",
"do",
"|",
"step",
"|",
"ssh_key",
"=",
"''",
"step_dir",
"=",
"Bebox",
"::",
"Provision",
".",
"step_name",
"(",
"step",
")",
"templates_path",
"=",
"Bebox",
"::",
"Project",
... | Generate steps templates for hiera and manifests files | [
"Generate",
"steps",
"templates",
"for",
"hiera",
"and",
"manifests",
"files"
] | 0d19315847103341e599d32837ab0bd75524e5be | https://github.com/codescrum/bebox/blob/0d19315847103341e599d32837ab0bd75524e5be/lib/bebox/project.rb#L165-L177 | train |
codescrum/bebox | lib/bebox/wizards/provision_wizard.rb | Bebox.ProvisionWizard.apply_step | def apply_step(project_root, environment, step)
# Check if environment has configured the ssh keys
(return warn _('wizard.provision.ssh_key_advice')%{environment: environment}) unless Bebox::Environment.check_environment_access(project_root, environment)
nodes_to_step = Bebox::Node.nodes_in_environmen... | ruby | def apply_step(project_root, environment, step)
# Check if environment has configured the ssh keys
(return warn _('wizard.provision.ssh_key_advice')%{environment: environment}) unless Bebox::Environment.check_environment_access(project_root, environment)
nodes_to_step = Bebox::Node.nodes_in_environmen... | [
"def",
"apply_step",
"(",
"project_root",
",",
"environment",
",",
"step",
")",
"# Check if environment has configured the ssh keys",
"(",
"return",
"warn",
"_",
"(",
"'wizard.provision.ssh_key_advice'",
")",
"%",
"{",
"environment",
":",
"environment",
"}",
")",
"unl... | Apply a step for the nodes in a environment | [
"Apply",
"a",
"step",
"for",
"the",
"nodes",
"in",
"a",
"environment"
] | 0d19315847103341e599d32837ab0bd75524e5be | https://github.com/codescrum/bebox/blob/0d19315847103341e599d32837ab0bd75524e5be/lib/bebox/wizards/provision_wizard.rb#L7-L22 | train |
GemHQ/coin-op | lib/coin-op/bit/fee.rb | CoinOp::Bit.Fee.estimate | def estimate(unspents, payees, network:, tx_size: nil, fee_per_kb: nil)
# https://en.bitcoin.it/wiki/Transaction_fees
# dupe because we'll need to add a change output
payees = payees.dup
unspent_total = unspents.inject(0) { |sum, output| sum += output.value }
payee_total = payees.inject(... | ruby | def estimate(unspents, payees, network:, tx_size: nil, fee_per_kb: nil)
# https://en.bitcoin.it/wiki/Transaction_fees
# dupe because we'll need to add a change output
payees = payees.dup
unspent_total = unspents.inject(0) { |sum, output| sum += output.value }
payee_total = payees.inject(... | [
"def",
"estimate",
"(",
"unspents",
",",
"payees",
",",
"network",
":",
",",
"tx_size",
":",
"nil",
",",
"fee_per_kb",
":",
"nil",
")",
"# https://en.bitcoin.it/wiki/Transaction_fees",
"# dupe because we'll need to add a change output",
"payees",
"=",
"payees",
".",
"... | Given an array of unspent Outputs and an array of Outputs for a
Transaction, estimate the fee required for the transaction to be
included in a block.
Optionally takes an Integer tx_size specifying the transaction size in bytes
This is useful if you have the scriptSigs for the unspents, because
you can get a m... | [
"Given",
"an",
"array",
"of",
"unspent",
"Outputs",
"and",
"an",
"array",
"of",
"Outputs",
"for",
"a",
"Transaction",
"estimate",
"the",
"fee",
"required",
"for",
"the",
"transaction",
"to",
"be",
"included",
"in",
"a",
"block",
"."
] | 0b704b52d9826405cffb1606e914bf21b8dcc681 | https://github.com/GemHQ/coin-op/blob/0b704b52d9826405cffb1606e914bf21b8dcc681/lib/coin-op/bit/fee.rb#L28-L57 | train |
Thoughtwright-LLC/httpmagic | lib/http_magic/api.rb | HttpMagic.Api.post | def post(data = {})
request = Request.new(@uri,
headers: @headers,
data: data,
)
request.post
end | ruby | def post(data = {})
request = Request.new(@uri,
headers: @headers,
data: data,
)
request.post
end | [
"def",
"post",
"(",
"data",
"=",
"{",
"}",
")",
"request",
"=",
"Request",
".",
"new",
"(",
"@uri",
",",
"headers",
":",
"@headers",
",",
"data",
":",
"data",
",",
")",
"request",
".",
"post",
"end"
] | POST's a resource from the URI and returns the result based on its content
type. JSON content will be parsed and returned as equivalent Ruby objects.
All other content types will be returned as text.
Assuming an api where each resource is namespaced with 'api/v1' and where
the url http://www.example.com/api/v1/foo... | [
"POST",
"s",
"a",
"resource",
"from",
"the",
"URI",
"and",
"returns",
"the",
"result",
"based",
"on",
"its",
"content",
"type",
".",
"JSON",
"content",
"will",
"be",
"parsed",
"and",
"returned",
"as",
"equivalent",
"Ruby",
"objects",
".",
"All",
"other",
... | e37dba9965eae7252a6f9e5c5a6641683a275a75 | https://github.com/Thoughtwright-LLC/httpmagic/blob/e37dba9965eae7252a6f9e5c5a6641683a275a75/lib/http_magic/api.rb#L220-L226 | train |
Thoughtwright-LLC/httpmagic | lib/http_magic/api.rb | HttpMagic.Api.put | def put(data = {})
request = Request.new(@uri,
headers: @headers,
data: data,
)
request.put
end | ruby | def put(data = {})
request = Request.new(@uri,
headers: @headers,
data: data,
)
request.put
end | [
"def",
"put",
"(",
"data",
"=",
"{",
"}",
")",
"request",
"=",
"Request",
".",
"new",
"(",
"@uri",
",",
"headers",
":",
"@headers",
",",
"data",
":",
"data",
",",
")",
"request",
".",
"put",
"end"
] | PUT's a resource to the URI and returns the result based on its content
type. JSON content will be parsed and returned as equivalent Ruby objects.
All other content types will be returned as text.
Assuming an api where each resource is namespaced with 'api/v1' and where
a GET to the url http://www.example.com/api/... | [
"PUT",
"s",
"a",
"resource",
"to",
"the",
"URI",
"and",
"returns",
"the",
"result",
"based",
"on",
"its",
"content",
"type",
".",
"JSON",
"content",
"will",
"be",
"parsed",
"and",
"returned",
"as",
"equivalent",
"Ruby",
"objects",
".",
"All",
"other",
"c... | e37dba9965eae7252a6f9e5c5a6641683a275a75 | https://github.com/Thoughtwright-LLC/httpmagic/blob/e37dba9965eae7252a6f9e5c5a6641683a275a75/lib/http_magic/api.rb#L255-L261 | train |
mayth/Chizuru | lib/chizuru/bot.rb | Chizuru.Bot.consumer | def consumer(cons, *init_args, &block)
if cons.instance_of? Class
cons = cons.new(*init_args)
end
ch = ConsumerHelper.new(cons, credential)
ch.instance_eval &block
provider.add_consumer(ch.consumer)
end | ruby | def consumer(cons, *init_args, &block)
if cons.instance_of? Class
cons = cons.new(*init_args)
end
ch = ConsumerHelper.new(cons, credential)
ch.instance_eval &block
provider.add_consumer(ch.consumer)
end | [
"def",
"consumer",
"(",
"cons",
",",
"*",
"init_args",
",",
"&",
"block",
")",
"if",
"cons",
".",
"instance_of?",
"Class",
"cons",
"=",
"cons",
".",
"new",
"(",
"init_args",
")",
"end",
"ch",
"=",
"ConsumerHelper",
".",
"new",
"(",
"cons",
",",
"cred... | Adds a consumer.
* If an instance of Consumer or its subclasses is given, it is used.
* If Class is given, initialize its instance, and use it. In this case, the rest arguments are passed to the constructor of the given class. | [
"Adds",
"a",
"consumer",
"."
] | 361bc595c2e4257313d134fe0f4f4cca65c88383 | https://github.com/mayth/Chizuru/blob/361bc595c2e4257313d134fe0f4f4cca65c88383/lib/chizuru/bot.rb#L46-L53 | train |
RISCfuture/has_metadata_column | lib/has_metadata_column.rb | HasMetadataColumn.Extensions.attribute | def attribute(attr)
return super unless self.class.metadata_column_fields.include?(attr.to_sym)
options = self.class.metadata_column_fields[attr.to_sym] || {}
default = options.include?(:default) ? options[:default] : nil
_metadata_hash.include?(attr) ? HasMetadataColumn.metadata_typecast(_meta... | ruby | def attribute(attr)
return super unless self.class.metadata_column_fields.include?(attr.to_sym)
options = self.class.metadata_column_fields[attr.to_sym] || {}
default = options.include?(:default) ? options[:default] : nil
_metadata_hash.include?(attr) ? HasMetadataColumn.metadata_typecast(_meta... | [
"def",
"attribute",
"(",
"attr",
")",
"return",
"super",
"unless",
"self",
".",
"class",
".",
"metadata_column_fields",
".",
"include?",
"(",
"attr",
".",
"to_sym",
")",
"options",
"=",
"self",
".",
"class",
".",
"metadata_column_fields",
"[",
"attr",
".",
... | ATTRIBUTE MATCHER METHODS | [
"ATTRIBUTE",
"MATCHER",
"METHODS"
] | cd9793dfd137fac0c8d5168f83623347157c6f98 | https://github.com/RISCfuture/has_metadata_column/blob/cd9793dfd137fac0c8d5168f83623347157c6f98/lib/has_metadata_column.rb#L251-L257 | train |
riddopic/hoodie | lib/hoodie/utils/ansi.rb | Hoodie.ANSI.build_ansi_methods | def build_ansi_methods(hash)
hash.each do |key, value|
define_method(key) do |string=nil, &block|
result = Array.new
result << %(\e[#{value}m)
if block_given?
result << block.call
elsif string.respond_to?(:to_str)
result << string.to_str
... | ruby | def build_ansi_methods(hash)
hash.each do |key, value|
define_method(key) do |string=nil, &block|
result = Array.new
result << %(\e[#{value}m)
if block_given?
result << block.call
elsif string.respond_to?(:to_str)
result << string.to_str
... | [
"def",
"build_ansi_methods",
"(",
"hash",
")",
"hash",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"define_method",
"(",
"key",
")",
"do",
"|",
"string",
"=",
"nil",
",",
"&",
"block",
"|",
"result",
"=",
"Array",
".",
"new",
"result",
"<<",
... | Dynamicly constructs ANSI methods for the color methods based on the ANSI
code hash passed in.
@param [Hash] hash
A hash where the keys represent the method names and the values are the
ANSI codes.
@return [Boolean]
True if successful. | [
"Dynamicly",
"constructs",
"ANSI",
"methods",
"for",
"the",
"color",
"methods",
"based",
"on",
"the",
"ANSI",
"code",
"hash",
"passed",
"in",
"."
] | 921601dd4849845d3f5d3765dafcf00178b2aa66 | https://github.com/riddopic/hoodie/blob/921601dd4849845d3f5d3765dafcf00178b2aa66/lib/hoodie/utils/ansi.rb#L127-L150 | train |
riddopic/hoodie | lib/hoodie/utils/ansi.rb | Hoodie.ANSI.uncolor | def uncolor(string = nil, &block)
if block_given?
block.call.to_str.gsub(ANSI_REGEX, '')
elsif string.respond_to?(:to_str)
string.to_str.gsub(ANSI_REGEX, '')
elsif respond_to?(:to_str)
to_str.gsub(ANSI_REGEX, '')
else
''
end
end | ruby | def uncolor(string = nil, &block)
if block_given?
block.call.to_str.gsub(ANSI_REGEX, '')
elsif string.respond_to?(:to_str)
string.to_str.gsub(ANSI_REGEX, '')
elsif respond_to?(:to_str)
to_str.gsub(ANSI_REGEX, '')
else
''
end
end | [
"def",
"uncolor",
"(",
"string",
"=",
"nil",
",",
"&",
"block",
")",
"if",
"block_given?",
"block",
".",
"call",
".",
"to_str",
".",
"gsub",
"(",
"ANSI_REGEX",
",",
"''",
")",
"elsif",
"string",
".",
"respond_to?",
"(",
":to_str",
")",
"string",
".",
... | Removes ANSI code sequences from a string.
@param [String] string
The string to operate on.
@yieldreturn [String]
The string to operate on.
@return [String]
The supplied string stripped of ANSI codes. | [
"Removes",
"ANSI",
"code",
"sequences",
"from",
"a",
"string",
"."
] | 921601dd4849845d3f5d3765dafcf00178b2aa66 | https://github.com/riddopic/hoodie/blob/921601dd4849845d3f5d3765dafcf00178b2aa66/lib/hoodie/utils/ansi.rb#L163-L173 | train |
barkerest/incline | lib/incline/validators/recaptcha_validator.rb | Incline.RecaptchaValidator.validate_each | def validate_each(record, attribute, value)
# Do NOT raise an error if nil.
return if value.blank?
# Make sure the response only gets processed once.
return if value == :verified
# Automatically skip validation if paused.
return if Incline::Recaptcha::paused?
# If the user f... | ruby | def validate_each(record, attribute, value)
# Do NOT raise an error if nil.
return if value.blank?
# Make sure the response only gets processed once.
return if value == :verified
# Automatically skip validation if paused.
return if Incline::Recaptcha::paused?
# If the user f... | [
"def",
"validate_each",
"(",
"record",
",",
"attribute",
",",
"value",
")",
"# Do NOT raise an error if nil.",
"return",
"if",
"value",
".",
"blank?",
"# Make sure the response only gets processed once.",
"return",
"if",
"value",
"==",
":verified",
"# Automatically skip val... | Validates a reCAPTCHA attribute.
The value of the attribute should be a hash with two keys: :response, :remote_ip | [
"Validates",
"a",
"reCAPTCHA",
"attribute",
"."
] | 1ff08db7aa8ab7f86b223268b700bc67d15bb8aa | https://github.com/barkerest/incline/blob/1ff08db7aa8ab7f86b223268b700bc67d15bb8aa/lib/incline/validators/recaptcha_validator.rb#L11-L34 | train |
djspinmonkey/classy | lib/classy/aliasable.rb | Aliasable.ControllingClassMethods.included | def included( klass )
klass.extend AliasingClassMethods
klass.extend UniversalClassMethods
# Hoo boy. We need to set the @@classy_aliases class variable in the
# including class to point to the same actual hash object that the
# @@classy_aliases variable on the controlling module points ... | ruby | def included( klass )
klass.extend AliasingClassMethods
klass.extend UniversalClassMethods
# Hoo boy. We need to set the @@classy_aliases class variable in the
# including class to point to the same actual hash object that the
# @@classy_aliases variable on the controlling module points ... | [
"def",
"included",
"(",
"klass",
")",
"klass",
".",
"extend",
"AliasingClassMethods",
"klass",
".",
"extend",
"UniversalClassMethods",
"# Hoo boy. We need to set the @@classy_aliases class variable in the",
"# including class to point to the same actual hash object that the",
"# @@cla... | Handle a class including a module that has included Aliasable. Since the
contolling module has extended this module, this method ends up being
called when the controlling module is included.
As a minor side effect, an instance method named #included ends up on any
class that directly includes Aliasable. If you k... | [
"Handle",
"a",
"class",
"including",
"a",
"module",
"that",
"has",
"included",
"Aliasable",
".",
"Since",
"the",
"contolling",
"module",
"has",
"extended",
"this",
"module",
"this",
"method",
"ends",
"up",
"being",
"called",
"when",
"the",
"controlling",
"modu... | 1589e2ae33c7fb7fc7ec88b0c24d7df18e2594b3 | https://github.com/djspinmonkey/classy/blob/1589e2ae33c7fb7fc7ec88b0c24d7df18e2594b3/lib/classy/aliasable.rb#L73-L86 | train |
rayko/da_face | lib/da_face/utilities.rb | DaFace.Utilities.symbolize_keys | def symbolize_keys keys, hash
new_hash = {}
keys.each do |key|
if hash[key].kind_of? Hash
new_hash[key.to_sym] = symbolize_keys(hash[key].keys, hash[key])
elsif hash[key].kind_of? Array
new_hash[key.to_sym] = []
hash[key].each do |item|
if item.kind_... | ruby | def symbolize_keys keys, hash
new_hash = {}
keys.each do |key|
if hash[key].kind_of? Hash
new_hash[key.to_sym] = symbolize_keys(hash[key].keys, hash[key])
elsif hash[key].kind_of? Array
new_hash[key.to_sym] = []
hash[key].each do |item|
if item.kind_... | [
"def",
"symbolize_keys",
"keys",
",",
"hash",
"new_hash",
"=",
"{",
"}",
"keys",
".",
"each",
"do",
"|",
"key",
"|",
"if",
"hash",
"[",
"key",
"]",
".",
"kind_of?",
"Hash",
"new_hash",
"[",
"key",
".",
"to_sym",
"]",
"=",
"symbolize_keys",
"(",
"hash... | Creates a new hash with all keys as symbols, can be
any level of depth | [
"Creates",
"a",
"new",
"hash",
"with",
"all",
"keys",
"as",
"symbols",
"can",
"be",
"any",
"level",
"of",
"depth"
] | 6260f4dc420fcc59a6985be0df248cb4773c4bf2 | https://github.com/rayko/da_face/blob/6260f4dc420fcc59a6985be0df248cb4773c4bf2/lib/da_face/utilities.rb#L6-L26 | train |
wedesoft/multiarray | lib/multiarray/shortcuts.rb | Hornetseye.MultiArrayConstructor.constructor_shortcut | def constructor_shortcut( target )
define_method target.to_s.downcase do |*args|
new target, *args
end
end | ruby | def constructor_shortcut( target )
define_method target.to_s.downcase do |*args|
new target, *args
end
end | [
"def",
"constructor_shortcut",
"(",
"target",
")",
"define_method",
"target",
".",
"to_s",
".",
"downcase",
"do",
"|",
"*",
"args",
"|",
"new",
"target",
",",
"args",
"end",
"end"
] | Meta-programming method for creating constructor shortcut methods
@param [Class] target Element-type to create constructor shortcut for.
@return [Proc] The new method.
@private | [
"Meta",
"-",
"programming",
"method",
"for",
"creating",
"constructor",
"shortcut",
"methods"
] | 1ae1d98bacb4b941d6f406e44ccb184de12f83d9 | https://github.com/wedesoft/multiarray/blob/1ae1d98bacb4b941d6f406e44ccb184de12f83d9/lib/multiarray/shortcuts.rb#L30-L34 | train |
anga/BetterRailsDebugger | lib/better_rails_debugger/analyzer.rb | BetterRailsDebugger.Analyzer.collect_information | def collect_information(identifier, group_id)
group = ::BetterRailsDebugger::AnalysisGroup.find group_id
if not group.present?
Rails.logger.error "[BetterRailsDebugger] Group '#{recorded[:group_id]}' not found. Skiping..."
return
end
# Load Mongo db if required
if not Mong... | ruby | def collect_information(identifier, group_id)
group = ::BetterRailsDebugger::AnalysisGroup.find group_id
if not group.present?
Rails.logger.error "[BetterRailsDebugger] Group '#{recorded[:group_id]}' not found. Skiping..."
return
end
# Load Mongo db if required
if not Mong... | [
"def",
"collect_information",
"(",
"identifier",
",",
"group_id",
")",
"group",
"=",
"::",
"BetterRailsDebugger",
"::",
"AnalysisGroup",
".",
"find",
"group_id",
"if",
"not",
"group",
".",
"present?",
"Rails",
".",
"logger",
".",
"error",
"\"[BetterRailsDebugger] ... | Record into db, information about object creation | [
"Record",
"into",
"db",
"information",
"about",
"object",
"creation"
] | 2ac7af13b8ee12483bd9a92680d8f43042f1f1d5 | https://github.com/anga/BetterRailsDebugger/blob/2ac7af13b8ee12483bd9a92680d8f43042f1f1d5/lib/better_rails_debugger/analyzer.rb#L63-L83 | train |
tclaus/keytechkit.gem | lib/keytechKit/elements/element_files/element_file_handler.rb | KeytechKit.ElementFileHandler.masterfile? | def masterfile?(element_key)
if Tools.class_type(element_key) == 'DO' # Only DO Types can have a file
file_list = load(element_key)
unless file_list.nil?
file_list.each do |file|
return true if file.fileStorageType.casecmp('master').zero?
end
end
end
... | ruby | def masterfile?(element_key)
if Tools.class_type(element_key) == 'DO' # Only DO Types can have a file
file_list = load(element_key)
unless file_list.nil?
file_list.each do |file|
return true if file.fileStorageType.casecmp('master').zero?
end
end
end
... | [
"def",
"masterfile?",
"(",
"element_key",
")",
"if",
"Tools",
".",
"class_type",
"(",
"element_key",
")",
"==",
"'DO'",
"# Only DO Types can have a file",
"file_list",
"=",
"load",
"(",
"element_key",
")",
"unless",
"file_list",
".",
"nil?",
"file_list",
".",
"e... | Returns true or false if a masterfile exist | [
"Returns",
"true",
"or",
"false",
"if",
"a",
"masterfile",
"exist"
] | caa7a6bee32b75ec18a4004179ae10cb69d148c2 | https://github.com/tclaus/keytechkit.gem/blob/caa7a6bee32b75ec18a4004179ae10cb69d148c2/lib/keytechKit/elements/element_files/element_file_handler.rb#L17-L27 | train |
tclaus/keytechkit.gem | lib/keytechKit/elements/element_files/element_file_handler.rb | KeytechKit.ElementFileHandler.masterfile_name | def masterfile_name(element_key)
file_list = load(element_key)
unless file_list.nil?
file_list.each do |file|
return file.fileName if file.fileStorageType.downcase! == 'master'
end
end
''
end | ruby | def masterfile_name(element_key)
file_list = load(element_key)
unless file_list.nil?
file_list.each do |file|
return file.fileName if file.fileStorageType.downcase! == 'master'
end
end
''
end | [
"def",
"masterfile_name",
"(",
"element_key",
")",
"file_list",
"=",
"load",
"(",
"element_key",
")",
"unless",
"file_list",
".",
"nil?",
"file_list",
".",
"each",
"do",
"|",
"file",
"|",
"return",
"file",
".",
"fileName",
"if",
"file",
".",
"fileStorageType... | Returns the name of a masterfile if present | [
"Returns",
"the",
"name",
"of",
"a",
"masterfile",
"if",
"present"
] | caa7a6bee32b75ec18a4004179ae10cb69d148c2 | https://github.com/tclaus/keytechkit.gem/blob/caa7a6bee32b75ec18a4004179ae10cb69d148c2/lib/keytechKit/elements/element_files/element_file_handler.rb#L43-L51 | train |
tclaus/keytechkit.gem | lib/keytechKit/elements/element_files/element_file_handler.rb | KeytechKit.ElementFileHandler.load | def load(element_key)
parameter = { basic_auth: @auth }
response = self.class.get("/elements/#{element_key}/files", parameter)
parse_files(response['FileInfos']) if response.success?
end | ruby | def load(element_key)
parameter = { basic_auth: @auth }
response = self.class.get("/elements/#{element_key}/files", parameter)
parse_files(response['FileInfos']) if response.success?
end | [
"def",
"load",
"(",
"element_key",
")",
"parameter",
"=",
"{",
"basic_auth",
":",
"@auth",
"}",
"response",
"=",
"self",
".",
"class",
".",
"get",
"(",
"\"/elements/#{element_key}/files\"",
",",
"parameter",
")",
"parse_files",
"(",
"response",
"[",
"'FileInfo... | Loads the filelist
Returns a full list of file data | [
"Loads",
"the",
"filelist",
"Returns",
"a",
"full",
"list",
"of",
"file",
"data"
] | caa7a6bee32b75ec18a4004179ae10cb69d148c2 | https://github.com/tclaus/keytechkit.gem/blob/caa7a6bee32b75ec18a4004179ae10cb69d148c2/lib/keytechKit/elements/element_files/element_file_handler.rb#L55-L59 | train |
tclaus/keytechkit.gem | lib/keytechKit/elements/element_files/element_file_handler.rb | KeytechKit.ElementFileHandler.load_masterfile | def load_masterfile(element_key)
parameter = { basic_auth: @auth }
response = self.class.get("/elements/#{element_key}/files/masterfile", parameter)
return response if response.success?
end | ruby | def load_masterfile(element_key)
parameter = { basic_auth: @auth }
response = self.class.get("/elements/#{element_key}/files/masterfile", parameter)
return response if response.success?
end | [
"def",
"load_masterfile",
"(",
"element_key",
")",
"parameter",
"=",
"{",
"basic_auth",
":",
"@auth",
"}",
"response",
"=",
"self",
".",
"class",
".",
"get",
"(",
"\"/elements/#{element_key}/files/masterfile\"",
",",
"parameter",
")",
"return",
"response",
"if",
... | Loads the masterfile directly | [
"Loads",
"the",
"masterfile",
"directly"
] | caa7a6bee32b75ec18a4004179ae10cb69d148c2 | https://github.com/tclaus/keytechkit.gem/blob/caa7a6bee32b75ec18a4004179ae10cb69d148c2/lib/keytechKit/elements/element_files/element_file_handler.rb#L62-L66 | train |
tclaus/keytechkit.gem | lib/keytechKit/elements/element_files/element_file_handler.rb | KeytechKit.ElementFileHandler.upload_masterfile | def upload_masterfile(element_key, file, original_filename)
# file, elementkey , name??
content_length = file.size
content_type = 'application/octet-stream; charset=utf-8'
parameter = { basic_auth: @auth,
headers: { 'Content-Type' => content_type,
... | ruby | def upload_masterfile(element_key, file, original_filename)
# file, elementkey , name??
content_length = file.size
content_type = 'application/octet-stream; charset=utf-8'
parameter = { basic_auth: @auth,
headers: { 'Content-Type' => content_type,
... | [
"def",
"upload_masterfile",
"(",
"element_key",
",",
"file",
",",
"original_filename",
")",
"# file, elementkey , name??",
"content_length",
"=",
"file",
".",
"size",
"content_type",
"=",
"'application/octet-stream; charset=utf-8'",
"parameter",
"=",
"{",
"basic_auth",
":... | Masterfile is the main file attached to a document | [
"Masterfile",
"is",
"the",
"main",
"file",
"attached",
"to",
"a",
"document"
] | caa7a6bee32b75ec18a4004179ae10cb69d148c2 | https://github.com/tclaus/keytechkit.gem/blob/caa7a6bee32b75ec18a4004179ae10cb69d148c2/lib/keytechKit/elements/element_files/element_file_handler.rb#L70-L81 | train |
barkerest/shells | lib/shells/shell_base/options.rb | Shells.ShellBase.change_quit | def change_quit(quit_command)
raise Shells::NotRunning unless running?
self.options = options.dup.merge( quit: quit_command ).freeze
self
end | ruby | def change_quit(quit_command)
raise Shells::NotRunning unless running?
self.options = options.dup.merge( quit: quit_command ).freeze
self
end | [
"def",
"change_quit",
"(",
"quit_command",
")",
"raise",
"Shells",
"::",
"NotRunning",
"unless",
"running?",
"self",
".",
"options",
"=",
"options",
".",
"dup",
".",
"merge",
"(",
"quit",
":",
"quit_command",
")",
".",
"freeze",
"self",
"end"
] | Initializes the shell with the supplied options.
These options are common to all shells.
+prompt+::
Defaults to "~~#". Most special characters will be stripped.
+retrieve_exit_code+::
Defaults to false. Can also be true.
+on_non_zero_exit_code+::
Defaults to :ignore. Can also be :raise.
+sil... | [
"Initializes",
"the",
"shell",
"with",
"the",
"supplied",
"options",
"."
] | 674a0254f48cea01b0ae8979933f13892e398506 | https://github.com/barkerest/shells/blob/674a0254f48cea01b0ae8979933f13892e398506/lib/shells/shell_base/options.rb#L103-L107 | train |
BUEZE/taaze | lib/taaze/comments.rb | Taaze.TaazeComments.url_get_html | def url_get_html(url_str)
url = URI.parse(URI.encode(url_str)) # first get total size
req = Net::HTTP::Get.new(url.to_s)
res = Net::HTTP.start(url.host, url.port) { |http| http.request(req) }
res.body
end | ruby | def url_get_html(url_str)
url = URI.parse(URI.encode(url_str)) # first get total size
req = Net::HTTP::Get.new(url.to_s)
res = Net::HTTP.start(url.host, url.port) { |http| http.request(req) }
res.body
end | [
"def",
"url_get_html",
"(",
"url_str",
")",
"url",
"=",
"URI",
".",
"parse",
"(",
"URI",
".",
"encode",
"(",
"url_str",
")",
")",
"# first get total size",
"req",
"=",
"Net",
"::",
"HTTP",
"::",
"Get",
".",
"new",
"(",
"url",
".",
"to_s",
")",
"res",... | Send url to get response | [
"Send",
"url",
"to",
"get",
"response"
] | ef95e1ad71140a7eaf9e2c65830d900f651bc184 | https://github.com/BUEZE/taaze/blob/ef95e1ad71140a7eaf9e2c65830d900f651bc184/lib/taaze/comments.rb#L74-L79 | train |
BUEZE/taaze | lib/taaze/comments.rb | Taaze.TaazeComments.extract_comments | def extract_comments(content, user_id)
# Json format~
# "content":"勇氣就是熱誠,來自於我們對自己工作的自信心;.....",
# "title":"",
# "status":"C",
# "stars":"5",
# "prodId":"11100597685",
# "titleMain":"行銷之神原一平全集(精裝版)",
# "orgProdId":"11100597685",
# "pkNo":"1000243977",
# "mdf_t... | ruby | def extract_comments(content, user_id)
# Json format~
# "content":"勇氣就是熱誠,來自於我們對自己工作的自信心;.....",
# "title":"",
# "status":"C",
# "stars":"5",
# "prodId":"11100597685",
# "titleMain":"行銷之神原一平全集(精裝版)",
# "orgProdId":"11100597685",
# "pkNo":"1000243977",
# "mdf_t... | [
"def",
"extract_comments",
"(",
"content",
",",
"user_id",
")",
"# Json format~",
"# \"content\":\"勇氣就是熱誠,來自於我們對自己工作的自信心;.....\",",
"# \"title\":\"\",",
"# \"status\":\"C\",",
"# \"stars\":\"5\",",
"# \"prodId\":\"11100597685\",",
"# \"titleMain\":\"行銷之神原一平全集(精裝版)\",",
"# \"orgProdId\":\... | Return the comments in the format specified in spec. | [
"Return",
"the",
"comments",
"in",
"the",
"format",
"specified",
"in",
"spec",
"."
] | ef95e1ad71140a7eaf9e2c65830d900f651bc184 | https://github.com/BUEZE/taaze/blob/ef95e1ad71140a7eaf9e2c65830d900f651bc184/lib/taaze/comments.rb#L82-L119 | train |
kukushkin/aerogel-core | lib/aerogel/core/db/model.rb | Model.ClassMethods.find! | def find!( *args )
raise_not_found_error_was = Mongoid.raise_not_found_error
begin
Mongoid.raise_not_found_error = true
self.find( *args )
ensure
Mongoid.raise_not_found_error = raise_not_found_error_was
end
end | ruby | def find!( *args )
raise_not_found_error_was = Mongoid.raise_not_found_error
begin
Mongoid.raise_not_found_error = true
self.find( *args )
ensure
Mongoid.raise_not_found_error = raise_not_found_error_was
end
end | [
"def",
"find!",
"(",
"*",
"args",
")",
"raise_not_found_error_was",
"=",
"Mongoid",
".",
"raise_not_found_error",
"begin",
"Mongoid",
".",
"raise_not_found_error",
"=",
"true",
"self",
".",
"find",
"(",
"args",
")",
"ensure",
"Mongoid",
".",
"raise_not_found_error... | Finds document by id.
Raises error if document is not found. | [
"Finds",
"document",
"by",
"id",
".",
"Raises",
"error",
"if",
"document",
"is",
"not",
"found",
"."
] | e156af6b237c410c1ee75e5cdf1b10075e7fbb8b | https://github.com/kukushkin/aerogel-core/blob/e156af6b237c410c1ee75e5cdf1b10075e7fbb8b/lib/aerogel/core/db/model.rb#L19-L27 | train |
NU-CBITS/think_feel_do_dashboard | app/helpers/think_feel_do_dashboard/application_helper.rb | ThinkFeelDoDashboard.ApplicationHelper.breadcrumbs | def breadcrumbs
return unless show_breadcrumbs?
content_for(
:breadcrumbs,
content_tag(:ol, class: "breadcrumb") do
concat(content_tag(:li, link_to("Home", root_path)))
if can_view_resource_index?
concat(
content_tag(
:li, contr... | ruby | def breadcrumbs
return unless show_breadcrumbs?
content_for(
:breadcrumbs,
content_tag(:ol, class: "breadcrumb") do
concat(content_tag(:li, link_to("Home", root_path)))
if can_view_resource_index?
concat(
content_tag(
:li, contr... | [
"def",
"breadcrumbs",
"return",
"unless",
"show_breadcrumbs?",
"content_for",
"(",
":breadcrumbs",
",",
"content_tag",
"(",
":ol",
",",
"class",
":",
"\"breadcrumb\"",
")",
"do",
"concat",
"(",
"content_tag",
"(",
":li",
",",
"link_to",
"(",
"\"Home\"",
",",
"... | Render navigational information in the form of breadcrumbs | [
"Render",
"navigational",
"information",
"in",
"the",
"form",
"of",
"breadcrumbs"
] | ff88b539d18a41b71fb93187607d74039f87215a | https://github.com/NU-CBITS/think_feel_do_dashboard/blob/ff88b539d18a41b71fb93187607d74039f87215a/app/helpers/think_feel_do_dashboard/application_helper.rb#L8-L25 | train |
grandcloud/sndacs-ruby | lib/sndacs/bucket.rb | Sndacs.Bucket.put_bucket_policy | def put_bucket_policy(bucket_policy)
if bucket_policy && bucket_policy.is_a?(String) && bucket_policy.strip != ''
bucket_request(:put,:body => bucket_policy,:subresource=>"policy")
true
else
false
end
end | ruby | def put_bucket_policy(bucket_policy)
if bucket_policy && bucket_policy.is_a?(String) && bucket_policy.strip != ''
bucket_request(:put,:body => bucket_policy,:subresource=>"policy")
true
else
false
end
end | [
"def",
"put_bucket_policy",
"(",
"bucket_policy",
")",
"if",
"bucket_policy",
"&&",
"bucket_policy",
".",
"is_a?",
"(",
"String",
")",
"&&",
"bucket_policy",
".",
"strip",
"!=",
"''",
"bucket_request",
"(",
":put",
",",
":body",
"=>",
"bucket_policy",
",",
":s... | Set bucket policy for the given bucket | [
"Set",
"bucket",
"policy",
"for",
"the",
"given",
"bucket"
] | 4565e926473e3af9df2ae17f728c423662ca750a | https://github.com/grandcloud/sndacs-ruby/blob/4565e926473e3af9df2ae17f728c423662ca750a/lib/sndacs/bucket.rb#L66-L73 | train |
codescrum/bebox | lib/bebox/wizards/profile_wizard.rb | Bebox.ProfileWizard.create_new_profile | def create_new_profile(project_root, profile_name, profile_base_path)
# Clean the profile_path to make it a valid path
profile_base_path = Bebox::Profile.cleanpath(profile_base_path)
# Check if the profile name is valid
return unless name_valid?(profile_name, profile_base_path)
# Check if ... | ruby | def create_new_profile(project_root, profile_name, profile_base_path)
# Clean the profile_path to make it a valid path
profile_base_path = Bebox::Profile.cleanpath(profile_base_path)
# Check if the profile name is valid
return unless name_valid?(profile_name, profile_base_path)
# Check if ... | [
"def",
"create_new_profile",
"(",
"project_root",
",",
"profile_name",
",",
"profile_base_path",
")",
"# Clean the profile_path to make it a valid path",
"profile_base_path",
"=",
"Bebox",
"::",
"Profile",
".",
"cleanpath",
"(",
"profile_base_path",
")",
"# Check if the profi... | Create a new profile | [
"Create",
"a",
"new",
"profile"
] | 0d19315847103341e599d32837ab0bd75524e5be | https://github.com/codescrum/bebox/blob/0d19315847103341e599d32837ab0bd75524e5be/lib/bebox/wizards/profile_wizard.rb#L8-L21 | train |
codescrum/bebox | lib/bebox/wizards/profile_wizard.rb | Bebox.ProfileWizard.name_valid? | def name_valid?(profile_name, profile_base_path)
unless valid_puppet_class_name?(profile_name)
error _('wizard.profile.invalid_name')%{words: Bebox::RESERVED_WORDS.join(', ')}
return false
end
return true if profile_base_path.empty?
# Check if the path name is valid
unless ... | ruby | def name_valid?(profile_name, profile_base_path)
unless valid_puppet_class_name?(profile_name)
error _('wizard.profile.invalid_name')%{words: Bebox::RESERVED_WORDS.join(', ')}
return false
end
return true if profile_base_path.empty?
# Check if the path name is valid
unless ... | [
"def",
"name_valid?",
"(",
"profile_name",
",",
"profile_base_path",
")",
"unless",
"valid_puppet_class_name?",
"(",
"profile_name",
")",
"error",
"_",
"(",
"'wizard.profile.invalid_name'",
")",
"%",
"{",
"words",
":",
"Bebox",
"::",
"RESERVED_WORDS",
".",
"join",
... | Check if the profile name is valid | [
"Check",
"if",
"the",
"profile",
"name",
"is",
"valid"
] | 0d19315847103341e599d32837ab0bd75524e5be | https://github.com/codescrum/bebox/blob/0d19315847103341e599d32837ab0bd75524e5be/lib/bebox/wizards/profile_wizard.rb#L24-L36 | train |
codescrum/bebox | lib/bebox/wizards/profile_wizard.rb | Bebox.ProfileWizard.remove_profile | def remove_profile(project_root)
# Choose a profile from the availables
profiles = Bebox::Profile.list(project_root)
# Get a profile if exist
if profiles.count > 0
profile = choose_option(profiles, _('wizard.choose_remove_profile'))
else
return error _('wizard.profile.no_de... | ruby | def remove_profile(project_root)
# Choose a profile from the availables
profiles = Bebox::Profile.list(project_root)
# Get a profile if exist
if profiles.count > 0
profile = choose_option(profiles, _('wizard.choose_remove_profile'))
else
return error _('wizard.profile.no_de... | [
"def",
"remove_profile",
"(",
"project_root",
")",
"# Choose a profile from the availables",
"profiles",
"=",
"Bebox",
"::",
"Profile",
".",
"list",
"(",
"project_root",
")",
"# Get a profile if exist",
"if",
"profiles",
".",
"count",
">",
"0",
"profile",
"=",
"choo... | Removes an existing profile | [
"Removes",
"an",
"existing",
"profile"
] | 0d19315847103341e599d32837ab0bd75524e5be | https://github.com/codescrum/bebox/blob/0d19315847103341e599d32837ab0bd75524e5be/lib/bebox/wizards/profile_wizard.rb#L39-L57 | train |
inside-track/remi | lib/remi/data_subject.rb | Remi.DataSubject.field_symbolizer | def field_symbolizer(arg = nil)
return @field_symbolizer unless arg
@field_symbolizer = if arg.is_a? Symbol
Remi::FieldSymbolizers[arg]
else
arg
end
end | ruby | def field_symbolizer(arg = nil)
return @field_symbolizer unless arg
@field_symbolizer = if arg.is_a? Symbol
Remi::FieldSymbolizers[arg]
else
arg
end
end | [
"def",
"field_symbolizer",
"(",
"arg",
"=",
"nil",
")",
"return",
"@field_symbolizer",
"unless",
"arg",
"@field_symbolizer",
"=",
"if",
"arg",
".",
"is_a?",
"Symbol",
"Remi",
"::",
"FieldSymbolizers",
"[",
"arg",
"]",
"else",
"arg",
"end",
"end"
] | Field symbolizer used to convert field names into symbols. This method sets
the symbolizer for the data subject and also sets the symbolizers for
any associated parser and encoders.
@return [Proc] the method for symbolizing field names | [
"Field",
"symbolizer",
"used",
"to",
"convert",
"field",
"names",
"into",
"symbols",
".",
"This",
"method",
"sets",
"the",
"symbolizer",
"for",
"the",
"data",
"subject",
"and",
"also",
"sets",
"the",
"symbolizers",
"for",
"any",
"associated",
"parser",
"and",
... | f7e5f28f08f8c0403e04cd82d6fc14b6b2c362a7 | https://github.com/inside-track/remi/blob/f7e5f28f08f8c0403e04cd82d6fc14b6b2c362a7/lib/remi/data_subject.rb#L56-L63 | train |
inside-track/remi | lib/remi/data_subject.rb | Remi.DataSubject.df= | def df=(new_dataframe)
dsl_eval
if new_dataframe.respond_to? :df_type
@dataframe = new_dataframe
else
@dataframe = Remi::DataFrame.create(df_type, new_dataframe)
end
end | ruby | def df=(new_dataframe)
dsl_eval
if new_dataframe.respond_to? :df_type
@dataframe = new_dataframe
else
@dataframe = Remi::DataFrame.create(df_type, new_dataframe)
end
end | [
"def",
"df",
"=",
"(",
"new_dataframe",
")",
"dsl_eval",
"if",
"new_dataframe",
".",
"respond_to?",
":df_type",
"@dataframe",
"=",
"new_dataframe",
"else",
"@dataframe",
"=",
"Remi",
"::",
"DataFrame",
".",
"create",
"(",
"df_type",
",",
"new_dataframe",
")",
... | Reassigns the dataframe associated with this DataSubject.
@param new_dataframe [Object] The new dataframe object to be associated.
@return [Remi::DataFrame] the associated dataframe | [
"Reassigns",
"the",
"dataframe",
"associated",
"with",
"this",
"DataSubject",
"."
] | f7e5f28f08f8c0403e04cd82d6fc14b6b2c362a7 | https://github.com/inside-track/remi/blob/f7e5f28f08f8c0403e04cd82d6fc14b6b2c362a7/lib/remi/data_subject.rb#L74-L81 | train |
jinx/core | lib/jinx/helpers/multi_enumerator.rb | Jinx.MultiEnumerator.method_missing | def method_missing(symbol, *args)
self.class.new(@components.map { |enum|enum.send(symbol, *args) })
end | ruby | def method_missing(symbol, *args)
self.class.new(@components.map { |enum|enum.send(symbol, *args) })
end | [
"def",
"method_missing",
"(",
"symbol",
",",
"*",
"args",
")",
"self",
".",
"class",
".",
"new",
"(",
"@components",
".",
"map",
"{",
"|",
"enum",
"|",
"enum",
".",
"send",
"(",
"symbol",
",",
"args",
")",
"}",
")",
"end"
] | Returns the union of the results of calling the given method symbol on each component. | [
"Returns",
"the",
"union",
"of",
"the",
"results",
"of",
"calling",
"the",
"given",
"method",
"symbol",
"on",
"each",
"component",
"."
] | 964a274cc9d7ab74613910e8375e12ed210a434d | https://github.com/jinx/core/blob/964a274cc9d7ab74613910e8375e12ed210a434d/lib/jinx/helpers/multi_enumerator.rb#L43-L45 | train |
itisnotdone/gogetit | lib/providers/lxd.rb | Gogetit.GogetLXD.generate_user_data | def generate_user_data(lxd_params, options)
logger.info("Calling <#{__method__.to_s}>")
lxd_params[:config] = {}
if options[:'no-maas']
lxd_params[:config][:"user.user-data"] = {}
else
sshkeys = maas.get_sshkeys
pkg_repos = maas.get_package_repos
lxd_params[:co... | ruby | def generate_user_data(lxd_params, options)
logger.info("Calling <#{__method__.to_s}>")
lxd_params[:config] = {}
if options[:'no-maas']
lxd_params[:config][:"user.user-data"] = {}
else
sshkeys = maas.get_sshkeys
pkg_repos = maas.get_package_repos
lxd_params[:co... | [
"def",
"generate_user_data",
"(",
"lxd_params",
",",
"options",
")",
"logger",
".",
"info",
"(",
"\"Calling <#{__method__.to_s}>\"",
")",
"lxd_params",
"[",
":config",
"]",
"=",
"{",
"}",
"if",
"options",
"[",
":'",
"'",
"]",
"lxd_params",
"[",
":config",
"]... | to generate 'user.user-data' | [
"to",
"generate",
"user",
".",
"user",
"-",
"data"
] | 62628c04c0310567178c4738aa5b64645ed5c4bd | https://github.com/itisnotdone/gogetit/blob/62628c04c0310567178c4738aa5b64645ed5c4bd/lib/providers/lxd.rb#L49-L107 | train |
mintdigital/pyrite | lib/pyrite/dsl.rb | Pyrite.Dsl.fill_in | def fill_in(element, value)
if element.match /date/ # Try to guess at date selects
select_date(element, value)
else
browser.type("jquery=#{element}", value)
end
end | ruby | def fill_in(element, value)
if element.match /date/ # Try to guess at date selects
select_date(element, value)
else
browser.type("jquery=#{element}", value)
end
end | [
"def",
"fill_in",
"(",
"element",
",",
"value",
")",
"if",
"element",
".",
"match",
"/",
"/",
"# Try to guess at date selects",
"select_date",
"(",
"element",
",",
"value",
")",
"else",
"browser",
".",
"type",
"(",
"\"jquery=#{element}\"",
",",
"value",
")",
... | Fill in a form field | [
"Fill",
"in",
"a",
"form",
"field"
] | acba5d6b460e4262b29be522a0bde0c29ef14cb1 | https://github.com/mintdigital/pyrite/blob/acba5d6b460e4262b29be522a0bde0c29ef14cb1/lib/pyrite/dsl.rb#L5-L11 | train |
mintdigital/pyrite | lib/pyrite/dsl.rb | Pyrite.Dsl.select_date | def select_date(element, value)
suffixes = {
:year => '1i',
:month => '2i',
:day => '3i',
:hour => '4i',
:minute => '5i'
}
date = value.respond_to?(:year) ? value : Date.parse(value)
browser.select "jquery=#{element}_#{suffixes[:year]}", date.year
... | ruby | def select_date(element, value)
suffixes = {
:year => '1i',
:month => '2i',
:day => '3i',
:hour => '4i',
:minute => '5i'
}
date = value.respond_to?(:year) ? value : Date.parse(value)
browser.select "jquery=#{element}_#{suffixes[:year]}", date.year
... | [
"def",
"select_date",
"(",
"element",
",",
"value",
")",
"suffixes",
"=",
"{",
":year",
"=>",
"'1i'",
",",
":month",
"=>",
"'2i'",
",",
":day",
"=>",
"'3i'",
",",
":hour",
"=>",
"'4i'",
",",
":minute",
"=>",
"'5i'",
"}",
"date",
"=",
"value",
".",
... | Fill in a Rails-ish set of date_select fields | [
"Fill",
"in",
"a",
"Rails",
"-",
"ish",
"set",
"of",
"date_select",
"fields"
] | acba5d6b460e4262b29be522a0bde0c29ef14cb1 | https://github.com/mintdigital/pyrite/blob/acba5d6b460e4262b29be522a0bde0c29ef14cb1/lib/pyrite/dsl.rb#L14-L26 | train |
mintdigital/pyrite | lib/pyrite/dsl.rb | Pyrite.Dsl.wait_for | def wait_for(element)
case element
when :page_load
browser.wait_for(:wait_for => :page)
when :ajax
browser.wait_for(:wait_for => :ajax, :javascript_framework => Pyrite.js_framework)
else
browser.wait_for(:element => "jquery=#{element}")
end
end | ruby | def wait_for(element)
case element
when :page_load
browser.wait_for(:wait_for => :page)
when :ajax
browser.wait_for(:wait_for => :ajax, :javascript_framework => Pyrite.js_framework)
else
browser.wait_for(:element => "jquery=#{element}")
end
end | [
"def",
"wait_for",
"(",
"element",
")",
"case",
"element",
"when",
":page_load",
"browser",
".",
"wait_for",
"(",
":wait_for",
"=>",
":page",
")",
"when",
":ajax",
"browser",
".",
"wait_for",
"(",
":wait_for",
"=>",
":ajax",
",",
":javascript_framework",
"=>",... | Wait for a specific element, the page to load
or an AJAX request to return | [
"Wait",
"for",
"a",
"specific",
"element",
"the",
"page",
"to",
"load",
"or",
"an",
"AJAX",
"request",
"to",
"return"
] | acba5d6b460e4262b29be522a0bde0c29ef14cb1 | https://github.com/mintdigital/pyrite/blob/acba5d6b460e4262b29be522a0bde0c29ef14cb1/lib/pyrite/dsl.rb#L61-L70 | train |
Bottega8/maguro | lib/maguro/features.rb | Maguro.Features.create_database_files | def create_database_files
username = builder.options['database-username']
password = builder.options['database-password']
builder.remove_file "config/database.yml"
create_database_yml_file("config/database.sample.yml", "username", "pass")
create_database_yml_file("config/database.yml", us... | ruby | def create_database_files
username = builder.options['database-username']
password = builder.options['database-password']
builder.remove_file "config/database.yml"
create_database_yml_file("config/database.sample.yml", "username", "pass")
create_database_yml_file("config/database.yml", us... | [
"def",
"create_database_files",
"username",
"=",
"builder",
".",
"options",
"[",
"'database-username'",
"]",
"password",
"=",
"builder",
".",
"options",
"[",
"'database-password'",
"]",
"builder",
".",
"remove_file",
"\"config/database.yml\"",
"create_database_yml_file",
... | create a new database.yml that works with PG. | [
"create",
"a",
"new",
"database",
".",
"yml",
"that",
"works",
"with",
"PG",
"."
] | 9bfff4e3a9e823d57d55f86394dcb9353fd8205e | https://github.com/Bottega8/maguro/blob/9bfff4e3a9e823d57d55f86394dcb9353fd8205e/lib/maguro/features.rb#L165-L172 | train |
SwagDevOps/kamaze-project | lib/kamaze/project/concern/observable.rb | Kamaze::Project::Concern::Observable.ClassMethods.add_observer | def add_observer(observer_class, func = :handle_event)
func = func.to_sym
unless observer_class.instance_methods.include?(func)
m = "#<#{observer_class}> does not respond to `#{func}'"
raise NoMethodError, m
end
observer_peers[observer_class] = func
self
end | ruby | def add_observer(observer_class, func = :handle_event)
func = func.to_sym
unless observer_class.instance_methods.include?(func)
m = "#<#{observer_class}> does not respond to `#{func}'"
raise NoMethodError, m
end
observer_peers[observer_class] = func
self
end | [
"def",
"add_observer",
"(",
"observer_class",
",",
"func",
"=",
":handle_event",
")",
"func",
"=",
"func",
".",
"to_sym",
"unless",
"observer_class",
".",
"instance_methods",
".",
"include?",
"(",
"func",
")",
"m",
"=",
"\"#<#{observer_class}> does not respond to `#... | Add observer.
@param [Class] observer_class
@return [self] | [
"Add",
"observer",
"."
] | a0451ff204ed3072c1d6ae980811a32b3eb50345 | https://github.com/SwagDevOps/kamaze-project/blob/a0451ff204ed3072c1d6ae980811a32b3eb50345/lib/kamaze/project/concern/observable.rb#L58-L69 | train |
tatemae/muck-engine | lib/muck-engine/controllers/ssl_requirement.rb | MuckEngine.SslRequirement.ssl_required? | def ssl_required?
return ENV['SSL'] == 'on' ? true : false if defined? ENV['SSL']
return false if local_request?
return false if RAILS_ENV == 'test'
((self.class.read_inheritable_attribute(:ssl_required_actions) || []).include?(action_name.to_sym)) && (::Rails.env == 'production' || ::Ra... | ruby | def ssl_required?
return ENV['SSL'] == 'on' ? true : false if defined? ENV['SSL']
return false if local_request?
return false if RAILS_ENV == 'test'
((self.class.read_inheritable_attribute(:ssl_required_actions) || []).include?(action_name.to_sym)) && (::Rails.env == 'production' || ::Ra... | [
"def",
"ssl_required?",
"return",
"ENV",
"[",
"'SSL'",
"]",
"==",
"'on'",
"?",
"true",
":",
"false",
"if",
"defined?",
"ENV",
"[",
"'SSL'",
"]",
"return",
"false",
"if",
"local_request?",
"return",
"false",
"if",
"RAILS_ENV",
"==",
"'test'",
"(",
"(",
"s... | Only require ssl if we are in production | [
"Only",
"require",
"ssl",
"if",
"we",
"are",
"in",
"production"
] | 41fc072dce3a365b3ce4a73d4f60a4ff24026d51 | https://github.com/tatemae/muck-engine/blob/41fc072dce3a365b3ce4a73d4f60a4ff24026d51/lib/muck-engine/controllers/ssl_requirement.rb#L24-L29 | train |
seblindberg/ruby-rooted_tree | lib/rooted_tree/node.rb | RootedTree.Node.ancestors | def ancestors
return to_enum(__callee__) unless block_given?
node = self
loop do
node = node.parent
yield node
end
end | ruby | def ancestors
return to_enum(__callee__) unless block_given?
node = self
loop do
node = node.parent
yield node
end
end | [
"def",
"ancestors",
"return",
"to_enum",
"(",
"__callee__",
")",
"unless",
"block_given?",
"node",
"=",
"self",
"loop",
"do",
"node",
"=",
"node",
".",
"parent",
"yield",
"node",
"end",
"end"
] | Iterates over the nodes above this in the tree hierarchy and yields them
to a block. If no block is given an enumerator is returned.
@yield [Node] each parent node.
@return [Enumerator] if no block is given. | [
"Iterates",
"over",
"the",
"nodes",
"above",
"this",
"in",
"the",
"tree",
"hierarchy",
"and",
"yields",
"them",
"to",
"a",
"block",
".",
"If",
"no",
"block",
"is",
"given",
"an",
"enumerator",
"is",
"returned",
"."
] | 59013fc0fd59f137b5e40d86c49afe08ea678941 | https://github.com/seblindberg/ruby-rooted_tree/blob/59013fc0fd59f137b5e40d86c49afe08ea678941/lib/rooted_tree/node.rb#L109-L116 | train |
seblindberg/ruby-rooted_tree | lib/rooted_tree/node.rb | RootedTree.Node.child | def child(index = nil)
unless index
raise ArgumentError, 'No index for node with degree != 1' if degree != 1
return first
end
rtl, index = wrap_index index
raise RangeError, 'Child index out of range' if index >= degree
children(rtl: rtl).each do |c|
break c if i... | ruby | def child(index = nil)
unless index
raise ArgumentError, 'No index for node with degree != 1' if degree != 1
return first
end
rtl, index = wrap_index index
raise RangeError, 'Child index out of range' if index >= degree
children(rtl: rtl).each do |c|
break c if i... | [
"def",
"child",
"(",
"index",
"=",
"nil",
")",
"unless",
"index",
"raise",
"ArgumentError",
",",
"'No index for node with degree != 1'",
"if",
"degree",
"!=",
"1",
"return",
"first",
"end",
"rtl",
",",
"index",
"=",
"wrap_index",
"index",
"raise",
"RangeError",
... | Accessor method for any of the n children under this node. If called
without an argument and the node has anything but exactly one child an
exception will be raised.
@param index [Integer] the n:th child to be returned. If the index is
negative the indexing will be reversed and the children counted from the
l... | [
"Accessor",
"method",
"for",
"any",
"of",
"the",
"n",
"children",
"under",
"this",
"node",
".",
"If",
"called",
"without",
"an",
"argument",
"and",
"the",
"node",
"has",
"anything",
"but",
"exactly",
"one",
"child",
"an",
"exception",
"will",
"be",
"raised... | 59013fc0fd59f137b5e40d86c49afe08ea678941 | https://github.com/seblindberg/ruby-rooted_tree/blob/59013fc0fd59f137b5e40d86c49afe08ea678941/lib/rooted_tree/node.rb#L139-L153 | train |
seblindberg/ruby-rooted_tree | lib/rooted_tree/node.rb | RootedTree.Node.edges | def edges(&block)
return to_enum(__callee__) unless block_given?
children do |v|
yield self, v
v.edges(&block)
end
end | ruby | def edges(&block)
return to_enum(__callee__) unless block_given?
children do |v|
yield self, v
v.edges(&block)
end
end | [
"def",
"edges",
"(",
"&",
"block",
")",
"return",
"to_enum",
"(",
"__callee__",
")",
"unless",
"block_given?",
"children",
"do",
"|",
"v",
"|",
"yield",
"self",
",",
"v",
"v",
".",
"edges",
"(",
"block",
")",
"end",
"end"
] | Iterates over each edge in the tree.
@yield [Array<Node>] each connected node pair.
@return [Enumerator] if no block is given. | [
"Iterates",
"over",
"each",
"edge",
"in",
"the",
"tree",
"."
] | 59013fc0fd59f137b5e40d86c49afe08ea678941 | https://github.com/seblindberg/ruby-rooted_tree/blob/59013fc0fd59f137b5e40d86c49afe08ea678941/lib/rooted_tree/node.rb#L200-L207 | train |
seblindberg/ruby-rooted_tree | lib/rooted_tree/node.rb | RootedTree.Node.+ | def +(other)
unless root? && other.root?
raise StructureException, 'Only roots can be added'
end
a = frozen? ? dup : self
b = other.frozen? ? other.dup : other
ab = self.class.new
ab << a << b
end | ruby | def +(other)
unless root? && other.root?
raise StructureException, 'Only roots can be added'
end
a = frozen? ? dup : self
b = other.frozen? ? other.dup : other
ab = self.class.new
ab << a << b
end | [
"def",
"+",
"(",
"other",
")",
"unless",
"root?",
"&&",
"other",
".",
"root?",
"raise",
"StructureException",
",",
"'Only roots can be added'",
"end",
"a",
"=",
"frozen?",
"?",
"dup",
":",
"self",
"b",
"=",
"other",
".",
"frozen?",
"?",
"other",
".",
"du... | Add two roots together to create a larger tree. A new common root will be
created and returned. Note that if the any of the root nodes are not
frozen they will be modified, and as a result seize to be roots.
@param other [Node] a Node-like object that responds true to #root?
@return [Node] a new root with the two... | [
"Add",
"two",
"roots",
"together",
"to",
"create",
"a",
"larger",
"tree",
".",
"A",
"new",
"common",
"root",
"will",
"be",
"created",
"and",
"returned",
".",
"Note",
"that",
"if",
"the",
"any",
"of",
"the",
"root",
"nodes",
"are",
"not",
"frozen",
"the... | 59013fc0fd59f137b5e40d86c49afe08ea678941 | https://github.com/seblindberg/ruby-rooted_tree/blob/59013fc0fd59f137b5e40d86c49afe08ea678941/lib/rooted_tree/node.rb#L215-L225 | train |
Dev-Crea/swagger-docs-generator | lib/swagger_docs_generator/methods.rb | SwaggerDocsGenerator.Methods.swagger_doc | def swagger_doc(action, &block)
parse = ParserAction.new(action, &block)
parse.adding_path
end | ruby | def swagger_doc(action, &block)
parse = ParserAction.new(action, &block)
parse.adding_path
end | [
"def",
"swagger_doc",
"(",
"action",
",",
"&",
"block",
")",
"parse",
"=",
"ParserAction",
".",
"new",
"(",
"action",
",",
"block",
")",
"parse",
".",
"adding_path",
"end"
] | Complete json file with datas to method and controller. Each action to
controller is writing in temporary file. | [
"Complete",
"json",
"file",
"with",
"datas",
"to",
"method",
"and",
"controller",
".",
"Each",
"action",
"to",
"controller",
"is",
"writing",
"in",
"temporary",
"file",
"."
] | 5d3de176aa1119cb38100b451bee028d66c0809d | https://github.com/Dev-Crea/swagger-docs-generator/blob/5d3de176aa1119cb38100b451bee028d66c0809d/lib/swagger_docs_generator/methods.rb#L18-L21 | train |
Dev-Crea/swagger-docs-generator | lib/swagger_docs_generator/methods.rb | SwaggerDocsGenerator.Methods.swagger_definition | def swagger_definition(name, &block)
parse = ParserDefinition.new(name, &block)
parse.adding_definition
end | ruby | def swagger_definition(name, &block)
parse = ParserDefinition.new(name, &block)
parse.adding_definition
end | [
"def",
"swagger_definition",
"(",
"name",
",",
"&",
"block",
")",
"parse",
"=",
"ParserDefinition",
".",
"new",
"(",
"name",
",",
"block",
")",
"parse",
".",
"adding_definition",
"end"
] | Complete definitions objects for each controller. | [
"Complete",
"definitions",
"objects",
"for",
"each",
"controller",
"."
] | 5d3de176aa1119cb38100b451bee028d66c0809d | https://github.com/Dev-Crea/swagger-docs-generator/blob/5d3de176aa1119cb38100b451bee028d66c0809d/lib/swagger_docs_generator/methods.rb#L24-L27 | train |
avdgaag/whenner | lib/whenner/conversions.rb | Whenner.Conversions.Promise | def Promise(obj)
return obj.to_promise if obj.respond_to?(:to_promise)
Deferred.new.fulfill(obj)
end | ruby | def Promise(obj)
return obj.to_promise if obj.respond_to?(:to_promise)
Deferred.new.fulfill(obj)
end | [
"def",
"Promise",
"(",
"obj",
")",
"return",
"obj",
".",
"to_promise",
"if",
"obj",
".",
"respond_to?",
"(",
":to_promise",
")",
"Deferred",
".",
"new",
".",
"fulfill",
"(",
"obj",
")",
"end"
] | Convert any object to a promise. When the object in question responds to
`to_promise`, the result of that method will be returned. If not, a new
deferred object is created and immediately fulfilled with the given
object.
@param [Object] obj
@return [Promise] | [
"Convert",
"any",
"object",
"to",
"a",
"promise",
".",
"When",
"the",
"object",
"in",
"question",
"responds",
"to",
"to_promise",
"the",
"result",
"of",
"that",
"method",
"will",
"be",
"returned",
".",
"If",
"not",
"a",
"new",
"deferred",
"object",
"is",
... | f27331435402648d02377bef9fce9ff8ae84845a | https://github.com/avdgaag/whenner/blob/f27331435402648d02377bef9fce9ff8ae84845a/lib/whenner/conversions.rb#L12-L15 | train |
DigitPaint/roger_eslint | lib/roger_eslint/lint.rb | RogerEslint.Lint.normalize_path | def normalize_path(test, path)
Pathname.new(path).relative_path_from(test.project.path.realpath).to_s
end | ruby | def normalize_path(test, path)
Pathname.new(path).relative_path_from(test.project.path.realpath).to_s
end | [
"def",
"normalize_path",
"(",
"test",
",",
"path",
")",
"Pathname",
".",
"new",
"(",
"path",
")",
".",
"relative_path_from",
"(",
"test",
".",
"project",
".",
"path",
".",
"realpath",
")",
".",
"to_s",
"end"
] | Will make path relative to project dir
@return [String] relative path | [
"Will",
"make",
"path",
"relative",
"to",
"project",
"dir"
] | 8d14a44b12fba27c6df9fc5f71920fc6cdecbf3d | https://github.com/DigitPaint/roger_eslint/blob/8d14a44b12fba27c6df9fc5f71920fc6cdecbf3d/lib/roger_eslint/lint.rb#L156-L158 | train |
syborg/mme_tools | lib/mme_tools/args_proc.rb | MMETools.ArgsProc.assert_valid_keys | def assert_valid_keys(options, valid_options)
unknown_keys = options.keys - valid_options.keys
raise(ArgumentError, "Unknown options(s): #{unknown_keys.join(", ")}") unless unknown_keys.empty?
end | ruby | def assert_valid_keys(options, valid_options)
unknown_keys = options.keys - valid_options.keys
raise(ArgumentError, "Unknown options(s): #{unknown_keys.join(", ")}") unless unknown_keys.empty?
end | [
"def",
"assert_valid_keys",
"(",
"options",
",",
"valid_options",
")",
"unknown_keys",
"=",
"options",
".",
"keys",
"-",
"valid_options",
".",
"keys",
"raise",
"(",
"ArgumentError",
",",
"\"Unknown options(s): #{unknown_keys.join(\", \")}\"",
")",
"unless",
"unknown_key... | Tests if +options+ includes only valid keys. Raises an error if
any key is not included within +valid_options+.
+valid_options+ is a Hash that must include all accepted keys. values
aren't taken into account. | [
"Tests",
"if",
"+",
"options",
"+",
"includes",
"only",
"valid",
"keys",
".",
"Raises",
"an",
"error",
"if",
"any",
"key",
"is",
"not",
"included",
"within",
"+",
"valid_options",
"+",
".",
"+",
"valid_options",
"+",
"is",
"a",
"Hash",
"that",
"must",
... | e93919f7fcfb408b941d6144290991a7feabaa7d | https://github.com/syborg/mme_tools/blob/e93919f7fcfb408b941d6144290991a7feabaa7d/lib/mme_tools/args_proc.rb#L18-L21 | train |
mrackwitz/CLIntegracon | lib/CLIntegracon/formatter.rb | CLIntegracon.Formatter.describe_file_diff | def describe_file_diff(diff, max_width=80)
description = []
description << "File comparison error `#{diff.relative_path}` for #{spec.spec_folder}:"
description << "--- DIFF ".ljust(max_width, '-')
description += diff.map do |line|
case line
when /^\+/ then line.green
... | ruby | def describe_file_diff(diff, max_width=80)
description = []
description << "File comparison error `#{diff.relative_path}` for #{spec.spec_folder}:"
description << "--- DIFF ".ljust(max_width, '-')
description += diff.map do |line|
case line
when /^\+/ then line.green
... | [
"def",
"describe_file_diff",
"(",
"diff",
",",
"max_width",
"=",
"80",
")",
"description",
"=",
"[",
"]",
"description",
"<<",
"\"File comparison error `#{diff.relative_path}` for #{spec.spec_folder}:\"",
"description",
"<<",
"\"--- DIFF \"",
".",
"ljust",
"(",
"max_width... | Return a description text for an expectation that two files were
expected to be the same, but are not.
@param [Diff] diff
the diff which holds the difference
@param [Integer] max_width
the max width of the terminal to print matching separators
@return [String] | [
"Return",
"a",
"description",
"text",
"for",
"an",
"expectation",
"that",
"two",
"files",
"were",
"expected",
"to",
"be",
"the",
"same",
"but",
"are",
"not",
"."
] | b675f23762d10e527487aa5576d6a77f9c623485 | https://github.com/mrackwitz/CLIntegracon/blob/b675f23762d10e527487aa5576d6a77f9c623485/lib/CLIntegracon/formatter.rb#L145-L159 | train |
mohan/gitkite | app/controllers/gitkite/gitkit_controller.rb | Gitkite.GitkitController.sign_in_success | def sign_in_success
g_user = signed_in?
if g_user
user = {
:email => g_user.email,
:user_id => g_user.user_id,
:name => g_user.name,
:photo_url => g_user.photo_url,
:provider_id => g_user.provider_id
}
@user = User.find_by(user_id: ... | ruby | def sign_in_success
g_user = signed_in?
if g_user
user = {
:email => g_user.email,
:user_id => g_user.user_id,
:name => g_user.name,
:photo_url => g_user.photo_url,
:provider_id => g_user.provider_id
}
@user = User.find_by(user_id: ... | [
"def",
"sign_in_success",
"g_user",
"=",
"signed_in?",
"if",
"g_user",
"user",
"=",
"{",
":email",
"=>",
"g_user",
".",
"email",
",",
":user_id",
"=>",
"g_user",
".",
"user_id",
",",
":name",
"=>",
"g_user",
".",
"name",
",",
":photo_url",
"=>",
"g_user",
... | This will be called after successfull signin | [
"This",
"will",
"be",
"called",
"after",
"successfull",
"signin"
] | c6ebefecdd44d1dfd30a41190e7661da877c091d | https://github.com/mohan/gitkite/blob/c6ebefecdd44d1dfd30a41190e7661da877c091d/app/controllers/gitkite/gitkit_controller.rb#L18-L54 | train |
codescrum/bebox | lib/bebox/files_helper.rb | Bebox.FilesHelper.render_erb_template | def render_erb_template(template_path, options)
require 'tilt'
Tilt::ERBTemplate.new(template_path).render(nil, options)
end | ruby | def render_erb_template(template_path, options)
require 'tilt'
Tilt::ERBTemplate.new(template_path).render(nil, options)
end | [
"def",
"render_erb_template",
"(",
"template_path",
",",
"options",
")",
"require",
"'tilt'",
"Tilt",
"::",
"ERBTemplate",
".",
"new",
"(",
"template_path",
")",
".",
"render",
"(",
"nil",
",",
"options",
")",
"end"
] | Render a template for file content | [
"Render",
"a",
"template",
"for",
"file",
"content"
] | 0d19315847103341e599d32837ab0bd75524e5be | https://github.com/codescrum/bebox/blob/0d19315847103341e599d32837ab0bd75524e5be/lib/bebox/files_helper.rb#L15-L18 | train |
codescrum/bebox | lib/bebox/files_helper.rb | Bebox.FilesHelper.write_content_to_file | def write_content_to_file(file_path, content)
File.open(file_path, 'w') do |f|
f.write content
end
end | ruby | def write_content_to_file(file_path, content)
File.open(file_path, 'w') do |f|
f.write content
end
end | [
"def",
"write_content_to_file",
"(",
"file_path",
",",
"content",
")",
"File",
".",
"open",
"(",
"file_path",
",",
"'w'",
")",
"do",
"|",
"f",
"|",
"f",
".",
"write",
"content",
"end",
"end"
] | Write content to a file | [
"Write",
"content",
"to",
"a",
"file"
] | 0d19315847103341e599d32837ab0bd75524e5be | https://github.com/codescrum/bebox/blob/0d19315847103341e599d32837ab0bd75524e5be/lib/bebox/files_helper.rb#L21-L25 | train |
triglav-dataflow/triglav-client-ruby | lib/triglav_client/api/resources_api.rb | TriglavClient.ResourcesApi.create_resource | def create_resource(resource, opts = {})
data, _status_code, _headers = create_resource_with_http_info(resource, opts)
return data
end | ruby | def create_resource(resource, opts = {})
data, _status_code, _headers = create_resource_with_http_info(resource, opts)
return data
end | [
"def",
"create_resource",
"(",
"resource",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"create_resource_with_http_info",
"(",
"resource",
",",
"opts",
")",
"return",
"data",
"end"
] | Creates a new resource
@param resource Resource to add
@param [Hash] opts the optional parameters
@return [ResourceResponse] | [
"Creates",
"a",
"new",
"resource"
] | b2f3781d65ee032ba96eb703fbd789c713a5e0bd | https://github.com/triglav-dataflow/triglav-client-ruby/blob/b2f3781d65ee032ba96eb703fbd789c713a5e0bd/lib/triglav_client/api/resources_api.rb#L39-L42 | train |
triglav-dataflow/triglav-client-ruby | lib/triglav_client/api/resources_api.rb | TriglavClient.ResourcesApi.get_resource | def get_resource(id_or_uri, opts = {})
data, _status_code, _headers = get_resource_with_http_info(id_or_uri, opts)
return data
end | ruby | def get_resource(id_or_uri, opts = {})
data, _status_code, _headers = get_resource_with_http_info(id_or_uri, opts)
return data
end | [
"def",
"get_resource",
"(",
"id_or_uri",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"get_resource_with_http_info",
"(",
"id_or_uri",
",",
"opts",
")",
"return",
"data",
"end"
] | Returns a single resource
@param id_or_uri ID or URI of resource to fetch
@param [Hash] opts the optional parameters
@return [ResourceResponse] | [
"Returns",
"a",
"single",
"resource"
] | b2f3781d65ee032ba96eb703fbd789c713a5e0bd | https://github.com/triglav-dataflow/triglav-client-ruby/blob/b2f3781d65ee032ba96eb703fbd789c713a5e0bd/lib/triglav_client/api/resources_api.rb#L152-L155 | train |
triglav-dataflow/triglav-client-ruby | lib/triglav_client/api/resources_api.rb | TriglavClient.ResourcesApi.list_aggregated_resources | def list_aggregated_resources(uri_prefix, opts = {})
data, _status_code, _headers = list_aggregated_resources_with_http_info(uri_prefix, opts)
return data
end | ruby | def list_aggregated_resources(uri_prefix, opts = {})
data, _status_code, _headers = list_aggregated_resources_with_http_info(uri_prefix, opts)
return data
end | [
"def",
"list_aggregated_resources",
"(",
"uri_prefix",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"list_aggregated_resources_with_http_info",
"(",
"uri_prefix",
",",
"opts",
")",
"return",
"data",
"end"
] | Returns aggregated resources to be monitored
@param uri_prefix Prefix of Resource URI
@param [Hash] opts the optional parameters
@return [Array<AggregatedResourceEachResponse>] | [
"Returns",
"aggregated",
"resources",
"to",
"be",
"monitored"
] | b2f3781d65ee032ba96eb703fbd789c713a5e0bd | https://github.com/triglav-dataflow/triglav-client-ruby/blob/b2f3781d65ee032ba96eb703fbd789c713a5e0bd/lib/triglav_client/api/resources_api.rb#L209-L212 | train |
triglav-dataflow/triglav-client-ruby | lib/triglav_client/api/resources_api.rb | TriglavClient.ResourcesApi.update_resource | def update_resource(id_or_uri, resource, opts = {})
data, _status_code, _headers = update_resource_with_http_info(id_or_uri, resource, opts)
return data
end | ruby | def update_resource(id_or_uri, resource, opts = {})
data, _status_code, _headers = update_resource_with_http_info(id_or_uri, resource, opts)
return data
end | [
"def",
"update_resource",
"(",
"id_or_uri",
",",
"resource",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"update_resource_with_http_info",
"(",
"id_or_uri",
",",
"resource",
",",
"opts",
")",
"return",
"data",
"end"
] | Updates a single resource
@param id_or_uri ID or URI of resource to fetch
@param resource Resource parameters to update
@param [Hash] opts the optional parameters
@return [ResourceResponse] | [
"Updates",
"a",
"single",
"resource"
] | b2f3781d65ee032ba96eb703fbd789c713a5e0bd | https://github.com/triglav-dataflow/triglav-client-ruby/blob/b2f3781d65ee032ba96eb703fbd789c713a5e0bd/lib/triglav_client/api/resources_api.rb#L324-L327 | train |
tnorthb/coinstack | lib/coinstack/list.rb | Coinstack.UserPair.add_list_data | def add_list_data(data)
raise symbol.to_s if data.nil?
self.exchange_rate = data['price_usd'].to_f
self.perchant_change_week = data['percent_change_7d'].to_f
self.perchant_change_day = data['percent_change_24h'].to_f
end | ruby | def add_list_data(data)
raise symbol.to_s if data.nil?
self.exchange_rate = data['price_usd'].to_f
self.perchant_change_week = data['percent_change_7d'].to_f
self.perchant_change_day = data['percent_change_24h'].to_f
end | [
"def",
"add_list_data",
"(",
"data",
")",
"raise",
"symbol",
".",
"to_s",
"if",
"data",
".",
"nil?",
"self",
".",
"exchange_rate",
"=",
"data",
"[",
"'price_usd'",
"]",
".",
"to_f",
"self",
".",
"perchant_change_week",
"=",
"data",
"[",
"'percent_change_7d'"... | Builds a UserPair given the related CMC data | [
"Builds",
"a",
"UserPair",
"given",
"the",
"related",
"CMC",
"data"
] | 1316fd069f502fa04fe15bc6ab7e63302aa29fd8 | https://github.com/tnorthb/coinstack/blob/1316fd069f502fa04fe15bc6ab7e63302aa29fd8/lib/coinstack/list.rb#L87-L92 | train |
arvicco/poster | lib/poster/forum.rb | Poster.Forum.new_topic | def new_topic board: 92, subj: 'test', msg: 'msg', icon: "exclamation"
board = board.instance_of?(Symbol) ? @opts[:boards][board] : board
# Check board posting page first (to get sequence numbers)
get "/index.php?action=post;board=#{board}.0"
raise "Not logged, cannot post!" unless logged?
... | ruby | def new_topic board: 92, subj: 'test', msg: 'msg', icon: "exclamation"
board = board.instance_of?(Symbol) ? @opts[:boards][board] : board
# Check board posting page first (to get sequence numbers)
get "/index.php?action=post;board=#{board}.0"
raise "Not logged, cannot post!" unless logged?
... | [
"def",
"new_topic",
"board",
":",
"92",
",",
"subj",
":",
"'test'",
",",
"msg",
":",
"'msg'",
",",
"icon",
":",
"\"exclamation\"",
"board",
"=",
"board",
".",
"instance_of?",
"(",
"Symbol",
")",
"?",
"@opts",
"[",
":boards",
"]",
"[",
"board",
"]",
"... | Post new topic | [
"Post",
"new",
"topic"
] | a5f22f7cb02116ab4dc5b7f2bdb672306b3dac63 | https://github.com/arvicco/poster/blob/a5f22f7cb02116ab4dc5b7f2bdb672306b3dac63/lib/poster/forum.rb#L21-L46 | train |
notCalle/ruby-tangle | lib/tangle/base_graph_private.rb | Tangle.BaseGraphPrivate.each_vertex_breadth_first | def each_vertex_breadth_first(start_vertex, walk_method)
remaining = [start_vertex]
remaining.each_with_object([]) do |vertex, history|
history << vertex
yield vertex
send(walk_method, vertex).each do |other|
remaining << other unless history.include?(other)
end
... | ruby | def each_vertex_breadth_first(start_vertex, walk_method)
remaining = [start_vertex]
remaining.each_with_object([]) do |vertex, history|
history << vertex
yield vertex
send(walk_method, vertex).each do |other|
remaining << other unless history.include?(other)
end
... | [
"def",
"each_vertex_breadth_first",
"(",
"start_vertex",
",",
"walk_method",
")",
"remaining",
"=",
"[",
"start_vertex",
"]",
"remaining",
".",
"each_with_object",
"(",
"[",
"]",
")",
"do",
"|",
"vertex",
",",
"history",
"|",
"history",
"<<",
"vertex",
"yield"... | Yield each reachable vertex to a block, breadth first | [
"Yield",
"each",
"reachable",
"vertex",
"to",
"a",
"block",
"breadth",
"first"
] | ccafab96835a0644b05ae749066d7ec7ecada260 | https://github.com/notCalle/ruby-tangle/blob/ccafab96835a0644b05ae749066d7ec7ecada260/lib/tangle/base_graph_private.rb#L25-L34 | train |
LifebookerInc/requires_approval | lib/requires_approval.rb | RequiresApproval.ClassMethods.create_versions_class | def create_versions_class
versions_table_name = self.versions_table_name
self.const_set self.versions_class_name, Class.new(ActiveRecord::Base)
self.versions_class.class_eval do
self.table_name = versions_table_name
# Whitelist public attributes
# Everything since this class... | ruby | def create_versions_class
versions_table_name = self.versions_table_name
self.const_set self.versions_class_name, Class.new(ActiveRecord::Base)
self.versions_class.class_eval do
self.table_name = versions_table_name
# Whitelist public attributes
# Everything since this class... | [
"def",
"create_versions_class",
"versions_table_name",
"=",
"self",
".",
"versions_table_name",
"self",
".",
"const_set",
"self",
".",
"versions_class_name",
",",
"Class",
".",
"new",
"(",
"ActiveRecord",
"::",
"Base",
")",
"self",
".",
"versions_class",
".",
"cla... | create a class | [
"create",
"a",
"class"
] | 83b18b4693143777108b5e066b252ebff9263cbc | https://github.com/LifebookerInc/requires_approval/blob/83b18b4693143777108b5e066b252ebff9263cbc/lib/requires_approval.rb#L294-L307 | train |
jns/Aims | lib/aims/geometry.rb | Aims.Geometry.make_bonds | def make_bonds(bond_length = 3.0)
# initialize an empty array
@bonds = Array.new
# Make bonds between all atoms
# stack = atoms.dup
atoms_extended = atoms.dup
if periodic?
v1 = lattice_vectors[0]
v2 = lattice_vectors[1]
atoms.each{|a|
[-1, 0, 1].each{|n1|
... | ruby | def make_bonds(bond_length = 3.0)
# initialize an empty array
@bonds = Array.new
# Make bonds between all atoms
# stack = atoms.dup
atoms_extended = atoms.dup
if periodic?
v1 = lattice_vectors[0]
v2 = lattice_vectors[1]
atoms.each{|a|
[-1, 0, 1].each{|n1|
... | [
"def",
"make_bonds",
"(",
"bond_length",
"=",
"3.0",
")",
"# initialize an empty array",
"@bonds",
"=",
"Array",
".",
"new",
"# Make bonds between all atoms",
"# stack = atoms.dup",
"atoms_extended",
"=",
"atoms",
".",
"dup",
"if",
"periodic?",
"v1",
"=",
"lattice_vec... | Generate and cache bonds for this geometry.
A bond will be generated for every pair of atoms closer than +bond_length+ | [
"Generate",
"and",
"cache",
"bonds",
"for",
"this",
"geometry",
".",
"A",
"bond",
"will",
"be",
"generated",
"for",
"every",
"pair",
"of",
"atoms",
"closer",
"than",
"+",
"bond_length",
"+"
] | 2dcb6c02cd05b2d0c8ab72be4e85d60375df296c | https://github.com/jns/Aims/blob/2dcb6c02cd05b2d0c8ab72be4e85d60375df296c/lib/aims/geometry.rb#L128-L175 | train |
jns/Aims | lib/aims/geometry.rb | Aims.Geometry.recache_visible_atoms | def recache_visible_atoms(makeBonds = false)
plane_count = (@clip_planes ? @clip_planes.length : 0)
return if plane_count == 0
if @visibleAtoms
@visibleAtoms.clear
else
@visibleAtoms = []
end
@atoms.each{|a|
i = plane_count
@clip_planes.each{|p|
... | ruby | def recache_visible_atoms(makeBonds = false)
plane_count = (@clip_planes ? @clip_planes.length : 0)
return if plane_count == 0
if @visibleAtoms
@visibleAtoms.clear
else
@visibleAtoms = []
end
@atoms.each{|a|
i = plane_count
@clip_planes.each{|p|
... | [
"def",
"recache_visible_atoms",
"(",
"makeBonds",
"=",
"false",
")",
"plane_count",
"=",
"(",
"@clip_planes",
"?",
"@clip_planes",
".",
"length",
":",
"0",
")",
"return",
"if",
"plane_count",
"==",
"0",
"if",
"@visibleAtoms",
"@visibleAtoms",
".",
"clear",
"el... | Recompute the atoms that are behind all the clip planes
Atoms that are in front of any clip-plane are considered invisible. | [
"Recompute",
"the",
"atoms",
"that",
"are",
"behind",
"all",
"the",
"clip",
"planes",
"Atoms",
"that",
"are",
"in",
"front",
"of",
"any",
"clip",
"-",
"plane",
"are",
"considered",
"invisible",
"."
] | 2dcb6c02cd05b2d0c8ab72be4e85d60375df296c | https://github.com/jns/Aims/blob/2dcb6c02cd05b2d0c8ab72be4e85d60375df296c/lib/aims/geometry.rb#L299-L337 | train |
jns/Aims | lib/aims/geometry.rb | Aims.Geometry.center | def center(visible_only = true)
if atoms.empty?
return Atom.new(0,0,0)
else
bounds = bounding_box(visible_only)
x = (bounds[0].x + bounds[1].x)/2.0
y = (bounds[0].y + bounds[1].y)/2.0
z = (bounds[0].z + bounds[1].z)/2.0
return Atom.new(x,y,z)
end
end | ruby | def center(visible_only = true)
if atoms.empty?
return Atom.new(0,0,0)
else
bounds = bounding_box(visible_only)
x = (bounds[0].x + bounds[1].x)/2.0
y = (bounds[0].y + bounds[1].y)/2.0
z = (bounds[0].z + bounds[1].z)/2.0
return Atom.new(x,y,z)
end
end | [
"def",
"center",
"(",
"visible_only",
"=",
"true",
")",
"if",
"atoms",
".",
"empty?",
"return",
"Atom",
".",
"new",
"(",
"0",
",",
"0",
",",
"0",
")",
"else",
"bounds",
"=",
"bounding_box",
"(",
"visible_only",
")",
"x",
"=",
"(",
"bounds",
"[",
"0... | Return an Atom whose coordinates are the center of the unit-cell. | [
"Return",
"an",
"Atom",
"whose",
"coordinates",
"are",
"the",
"center",
"of",
"the",
"unit",
"-",
"cell",
"."
] | 2dcb6c02cd05b2d0c8ab72be4e85d60375df296c | https://github.com/jns/Aims/blob/2dcb6c02cd05b2d0c8ab72be4e85d60375df296c/lib/aims/geometry.rb#L429-L439 | train |
jns/Aims | lib/aims/geometry.rb | Aims.Geometry.displace | def displace(x,y,z)
Geometry.new(atoms(:all).collect{|a|
a.displace(x,y,z)
}, self.lattice_vectors)
#TODO copy miller indices
end | ruby | def displace(x,y,z)
Geometry.new(atoms(:all).collect{|a|
a.displace(x,y,z)
}, self.lattice_vectors)
#TODO copy miller indices
end | [
"def",
"displace",
"(",
"x",
",",
"y",
",",
"z",
")",
"Geometry",
".",
"new",
"(",
"atoms",
"(",
":all",
")",
".",
"collect",
"{",
"|",
"a",
"|",
"a",
".",
"displace",
"(",
"x",
",",
"y",
",",
"z",
")",
"}",
",",
"self",
".",
"lattice_vectors... | Return a new unit cell with all the atoms displaced by the amount x,y,z | [
"Return",
"a",
"new",
"unit",
"cell",
"with",
"all",
"the",
"atoms",
"displaced",
"by",
"the",
"amount",
"x",
"y",
"z"
] | 2dcb6c02cd05b2d0c8ab72be4e85d60375df296c | https://github.com/jns/Aims/blob/2dcb6c02cd05b2d0c8ab72be4e85d60375df296c/lib/aims/geometry.rb#L463-L468 | train |
Subsets and Splits
SQL Console for semeru/code-text-ruby
Retrieves 20,000 non-null code samples labeled as Ruby, providing a basic overview of the dataset but without deeper analysis.