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
cldwalker/boson
lib/boson/scientist.rb
Boson.Scientist.redefine_command
def redefine_command(obj, command) cmd_block = redefine_command_block(obj, command) @no_option_commands << command if command.options.nil? [command.name, command.alias].compact.each {|e| obj.singleton_class.send(:define_method, e, cmd_block) } rescue Error warn "Error: #{$!.mes...
ruby
def redefine_command(obj, command) cmd_block = redefine_command_block(obj, command) @no_option_commands << command if command.options.nil? [command.name, command.alias].compact.each {|e| obj.singleton_class.send(:define_method, e, cmd_block) } rescue Error warn "Error: #{$!.mes...
[ "def", "redefine_command", "(", "obj", ",", "command", ")", "cmd_block", "=", "redefine_command_block", "(", "obj", ",", "command", ")", "@no_option_commands", "<<", "command", "if", "command", ".", "options", ".", "nil?", "[", "command", ".", "name", ",", "...
Redefines an object's method with a Command of the same name.
[ "Redefines", "an", "object", "s", "method", "with", "a", "Command", "of", "the", "same", "name", "." ]
17fe830fefd3dc41d90af01d191f074306591f32
https://github.com/cldwalker/boson/blob/17fe830fefd3dc41d90af01d191f074306591f32/lib/boson/scientist.rb#L44-L52
train
cldwalker/boson
lib/boson/scientist.rb
Boson.Scientist.redefine_command_block
def redefine_command_block(obj, command) object_methods(obj)[command.name] ||= begin obj.method(command.name) rescue NameError raise Error, "No method exists to redefine command '#{command.name}'." end lambda {|*args| Scientist.analyze(obj, command, args) {|args| ...
ruby
def redefine_command_block(obj, command) object_methods(obj)[command.name] ||= begin obj.method(command.name) rescue NameError raise Error, "No method exists to redefine command '#{command.name}'." end lambda {|*args| Scientist.analyze(obj, command, args) {|args| ...
[ "def", "redefine_command_block", "(", "obj", ",", "command", ")", "object_methods", "(", "obj", ")", "[", "command", ".", "name", "]", "||=", "begin", "obj", ".", "method", "(", "command", ".", "name", ")", "rescue", "NameError", "raise", "Error", ",", "...
The actual method which redefines a command's original method
[ "The", "actual", "method", "which", "redefines", "a", "command", "s", "original", "method" ]
17fe830fefd3dc41d90af01d191f074306591f32
https://github.com/cldwalker/boson/blob/17fe830fefd3dc41d90af01d191f074306591f32/lib/boson/scientist.rb#L79-L90
train
cldwalker/boson
lib/boson/scientist.rb
Boson.Scientist.analyze
def analyze(obj, command, args, &block) @global_options, @command, @original_args = {}, command, args.dup @args = translate_args(obj, args) return run_help_option(@command) if @global_options[:help] during_analyze(&block) rescue OptionParser::Error, Error raise if Boson.in_shell ...
ruby
def analyze(obj, command, args, &block) @global_options, @command, @original_args = {}, command, args.dup @args = translate_args(obj, args) return run_help_option(@command) if @global_options[:help] during_analyze(&block) rescue OptionParser::Error, Error raise if Boson.in_shell ...
[ "def", "analyze", "(", "obj", ",", "command", ",", "args", ",", "&", "block", ")", "@global_options", ",", "@command", ",", "@original_args", "=", "{", "}", ",", "command", ",", "args", ".", "dup", "@args", "=", "translate_args", "(", "obj", ",", "args...
Runs a command given its object and arguments
[ "Runs", "a", "command", "given", "its", "object", "and", "arguments" ]
17fe830fefd3dc41d90af01d191f074306591f32
https://github.com/cldwalker/boson/blob/17fe830fefd3dc41d90af01d191f074306591f32/lib/boson/scientist.rb#L103-L111
train
cldwalker/boson
lib/boson/option_parser.rb
Boson.OptionParser.formatted_usage
def formatted_usage return "" if @opt_types.empty? @opt_types.map do |opt, type| val = respond_to?("usage_for_#{type}", true) ? send("usage_for_#{type}", opt) : "#{opt}=:#{type}" "[" + val + "]" end.join(" ") end
ruby
def formatted_usage return "" if @opt_types.empty? @opt_types.map do |opt, type| val = respond_to?("usage_for_#{type}", true) ? send("usage_for_#{type}", opt) : "#{opt}=:#{type}" "[" + val + "]" end.join(" ") end
[ "def", "formatted_usage", "return", "\"\"", "if", "@opt_types", ".", "empty?", "@opt_types", ".", "map", "do", "|", "opt", ",", "type", "|", "val", "=", "respond_to?", "(", "\"usage_for_#{type}\"", ",", "true", ")", "?", "send", "(", "\"usage_for_#{type}\"", ...
Generates one-line usage of all options.
[ "Generates", "one", "-", "line", "usage", "of", "all", "options", "." ]
17fe830fefd3dc41d90af01d191f074306591f32
https://github.com/cldwalker/boson/blob/17fe830fefd3dc41d90af01d191f074306591f32/lib/boson/option_parser.rb#L257-L264
train
cldwalker/boson
lib/boson/option_parser.rb
Boson.OptionParser.print_usage_table
def print_usage_table(options={}) fields = get_usage_fields options[:fields] fields, opts = get_fields_and_options(fields, options) render_table(fields, opts, options) end
ruby
def print_usage_table(options={}) fields = get_usage_fields options[:fields] fields, opts = get_fields_and_options(fields, options) render_table(fields, opts, options) end
[ "def", "print_usage_table", "(", "options", "=", "{", "}", ")", "fields", "=", "get_usage_fields", "options", "[", ":fields", "]", "fields", ",", "opts", "=", "get_fields_and_options", "(", "fields", ",", "options", ")", "render_table", "(", "fields", ",", "...
More verbose option help in the form of a table.
[ "More", "verbose", "option", "help", "in", "the", "form", "of", "a", "table", "." ]
17fe830fefd3dc41d90af01d191f074306591f32
https://github.com/cldwalker/boson/blob/17fe830fefd3dc41d90af01d191f074306591f32/lib/boson/option_parser.rb#L269-L273
train
cldwalker/boson
lib/boson/option_parser.rb
Boson.OptionParser.indifferent_hash
def indifferent_hash Hash.new {|hash,key| hash[key.to_sym] if String === key } end
ruby
def indifferent_hash Hash.new {|hash,key| hash[key.to_sym] if String === key } end
[ "def", "indifferent_hash", "Hash", ".", "new", "{", "|", "hash", ",", "key", "|", "hash", "[", "key", ".", "to_sym", "]", "if", "String", "===", "key", "}", "end" ]
Creates a Hash with indifferent access
[ "Creates", "a", "Hash", "with", "indifferent", "access" ]
17fe830fefd3dc41d90af01d191f074306591f32
https://github.com/cldwalker/boson/blob/17fe830fefd3dc41d90af01d191f074306591f32/lib/boson/option_parser.rb#L330-L332
train
cldwalker/boson
lib/boson/loader.rb
Boson.Loader.load
def load load_source_and_set_module module_callbacks if @module yield if block_given? # load dependencies detect_additions { load_commands } if load_commands? set_library_commands loaded_correctly? && (@loaded = true) end
ruby
def load load_source_and_set_module module_callbacks if @module yield if block_given? # load dependencies detect_additions { load_commands } if load_commands? set_library_commands loaded_correctly? && (@loaded = true) end
[ "def", "load", "load_source_and_set_module", "module_callbacks", "if", "@module", "yield", "if", "block_given?", "detect_additions", "{", "load_commands", "}", "if", "load_commands?", "set_library_commands", "loaded_correctly?", "&&", "(", "@loaded", "=", "true", ")", "...
Loads a library and its dependencies and returns true if library loads correctly.
[ "Loads", "a", "library", "and", "its", "dependencies", "and", "returns", "true", "if", "library", "loads", "correctly", "." ]
17fe830fefd3dc41d90af01d191f074306591f32
https://github.com/cldwalker/boson/blob/17fe830fefd3dc41d90af01d191f074306591f32/lib/boson/loader.rb#L16-L23
train
cldwalker/boson
lib/boson/loader.rb
Boson.Loader.detect_additions
def detect_additions(options={}, &block) Util.detect(options, &block).tap do |detected| @commands.concat detected[:methods].map(&:to_s) end end
ruby
def detect_additions(options={}, &block) Util.detect(options, &block).tap do |detected| @commands.concat detected[:methods].map(&:to_s) end end
[ "def", "detect_additions", "(", "options", "=", "{", "}", ",", "&", "block", ")", "Util", ".", "detect", "(", "options", ",", "&", "block", ")", ".", "tap", "do", "|", "detected", "|", "@commands", ".", "concat", "detected", "[", ":methods", "]", "."...
Wraps around module loading for unexpected additions
[ "Wraps", "around", "module", "loading", "for", "unexpected", "additions" ]
17fe830fefd3dc41d90af01d191f074306591f32
https://github.com/cldwalker/boson/blob/17fe830fefd3dc41d90af01d191f074306591f32/lib/boson/loader.rb#L38-L42
train
cldwalker/boson
lib/boson/loader.rb
Boson.Loader.load_commands
def load_commands @module = @module ? Util.constantize(@module) : Util.create_module(Boson::Commands, clean_name) before_load_commands check_for_method_conflicts unless @force actual_load_commands rescue MethodConflictError => err handle_method_conflict_error err end
ruby
def load_commands @module = @module ? Util.constantize(@module) : Util.create_module(Boson::Commands, clean_name) before_load_commands check_for_method_conflicts unless @force actual_load_commands rescue MethodConflictError => err handle_method_conflict_error err end
[ "def", "load_commands", "@module", "=", "@module", "?", "Util", ".", "constantize", "(", "@module", ")", ":", "Util", ".", "create_module", "(", "Boson", "::", "Commands", ",", "clean_name", ")", "before_load_commands", "check_for_method_conflicts", "unless", "@fo...
Prepares for command loading, loads commands and rescues certain errors.
[ "Prepares", "for", "command", "loading", "loads", "commands", "and", "rescues", "certain", "errors", "." ]
17fe830fefd3dc41d90af01d191f074306591f32
https://github.com/cldwalker/boson/blob/17fe830fefd3dc41d90af01d191f074306591f32/lib/boson/loader.rb#L45-L53
train
apiaryio/redsnow
lib/redsnow/object.rb
RedSnow.Object.deep_symbolize_keys
def deep_symbolize_keys return each_with_object({}) { |memo, (k, v)| memo[k.to_sym] = v.deep_symbolize_keys } if self.is_a?(Hash) return each_with_object([]) { |memo, v| memo << v.deep_symbolize_keys } if self.is_a?(Array) self end
ruby
def deep_symbolize_keys return each_with_object({}) { |memo, (k, v)| memo[k.to_sym] = v.deep_symbolize_keys } if self.is_a?(Hash) return each_with_object([]) { |memo, v| memo << v.deep_symbolize_keys } if self.is_a?(Array) self end
[ "def", "deep_symbolize_keys", "return", "each_with_object", "(", "{", "}", ")", "{", "|", "memo", ",", "(", "k", ",", "v", ")", "|", "memo", "[", "k", ".", "to_sym", "]", "=", "v", ".", "deep_symbolize_keys", "}", "if", "self", ".", "is_a?", "(", "...
Symbolizes keys of a hash
[ "Symbolizes", "keys", "of", "a", "hash" ]
5a05b704218dfee6a73e066ca1e6924733b10bdc
https://github.com/apiaryio/redsnow/blob/5a05b704218dfee6a73e066ca1e6924733b10bdc/lib/redsnow/object.rb#L6-L10
train
apiaryio/redsnow
lib/redsnow/blueprint.rb
RedSnow.NamedBlueprintNode.ensure_description_newlines
def ensure_description_newlines(buffer) return if description.empty? if description[-1, 1] != '\n' buffer << '\n\n' elsif description.length > 1 && description[-2, 1] != '\n' buffer << '\n' end end
ruby
def ensure_description_newlines(buffer) return if description.empty? if description[-1, 1] != '\n' buffer << '\n\n' elsif description.length > 1 && description[-2, 1] != '\n' buffer << '\n' end end
[ "def", "ensure_description_newlines", "(", "buffer", ")", "return", "if", "description", ".", "empty?", "if", "description", "[", "-", "1", ",", "1", "]", "!=", "'\\n'", "buffer", "<<", "'\\n\\n'", "elsif", "description", ".", "length", ">", "1", "&&", "de...
Ensure the input string buffer ends with two newlines. @param buffer [String] a buffer to check If the buffer does not ends with two newlines the newlines are added.
[ "Ensure", "the", "input", "string", "buffer", "ends", "with", "two", "newlines", "." ]
5a05b704218dfee6a73e066ca1e6924733b10bdc
https://github.com/apiaryio/redsnow/blob/5a05b704218dfee6a73e066ca1e6924733b10bdc/lib/redsnow/blueprint.rb#L40-L48
train
apiaryio/redsnow
lib/redsnow/blueprint.rb
RedSnow.KeyValueCollection.filter_collection
def filter_collection(ignore_keys) return @collection if ignore_keys.blank? @collection.select { |kv_item| !ignore_keys.include?(kv_item.keys.first) } end
ruby
def filter_collection(ignore_keys) return @collection if ignore_keys.blank? @collection.select { |kv_item| !ignore_keys.include?(kv_item.keys.first) } end
[ "def", "filter_collection", "(", "ignore_keys", ")", "return", "@collection", "if", "ignore_keys", ".", "blank?", "@collection", ".", "select", "{", "|", "kv_item", "|", "!", "ignore_keys", ".", "include?", "(", "kv_item", ".", "keys", ".", "first", ")", "}"...
Filter collection keys @return [Array<Hash>] collection without ignored keys
[ "Filter", "collection", "keys" ]
5a05b704218dfee6a73e066ca1e6924733b10bdc
https://github.com/apiaryio/redsnow/blob/5a05b704218dfee6a73e066ca1e6924733b10bdc/lib/redsnow/blueprint.rb#L70-L73
train
cldwalker/boson
lib/boson/library.rb
Boson.Library.command_objects
def command_objects(names=self.commands, command_array=Boson.commands) command_array.select {|e| names.include?(e.name) && e.lib == self.name } end
ruby
def command_objects(names=self.commands, command_array=Boson.commands) command_array.select {|e| names.include?(e.name) && e.lib == self.name } end
[ "def", "command_objects", "(", "names", "=", "self", ".", "commands", ",", "command_array", "=", "Boson", ".", "commands", ")", "command_array", ".", "select", "{", "|", "e", "|", "names", ".", "include?", "(", "e", ".", "name", ")", "&&", "e", ".", ...
Command objects of library's commands
[ "Command", "objects", "of", "library", "s", "commands" ]
17fe830fefd3dc41d90af01d191f074306591f32
https://github.com/cldwalker/boson/blob/17fe830fefd3dc41d90af01d191f074306591f32/lib/boson/library.rb#L91-L93
train
cldwalker/boson
lib/boson/util.rb
Boson.Util.create_module
def create_module(base_module, name) desired_class = camelize(name) possible_suffixes = [''] + %w{1 2 3 4 5 6 7 8 9 10} if suffix = possible_suffixes.find {|e| !base_module.const_defined?(desired_class+e) } base_module.const_set(desired_class+suffix, Module.new) end end
ruby
def create_module(base_module, name) desired_class = camelize(name) possible_suffixes = [''] + %w{1 2 3 4 5 6 7 8 9 10} if suffix = possible_suffixes.find {|e| !base_module.const_defined?(desired_class+e) } base_module.const_set(desired_class+suffix, Module.new) end end
[ "def", "create_module", "(", "base_module", ",", "name", ")", "desired_class", "=", "camelize", "(", "name", ")", "possible_suffixes", "=", "[", "''", "]", "+", "%w{", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "}", "if", "suffix", "=", "po...
Creates a module under a given base module and possible name. If the module already exists, it attempts to create one with a number appended to the name.
[ "Creates", "a", "module", "under", "a", "given", "base", "module", "and", "possible", "name", ".", "If", "the", "module", "already", "exists", "it", "attempts", "to", "create", "one", "with", "a", "number", "appended", "to", "the", "name", "." ]
17fe830fefd3dc41d90af01d191f074306591f32
https://github.com/cldwalker/boson/blob/17fe830fefd3dc41d90af01d191f074306591f32/lib/boson/util.rb#L75-L82
train
sunny/handle_invalid_percent_encoding_requests
lib/handle_invalid_percent_encoding_requests/middleware.rb
HandleInvalidPercentEncodingRequests.Middleware.call
def call(env) # calling env.dup here prevents bad things from happening request = Rack::Request.new(env.dup) # calling request.params is sufficient to trigger the error see # https://github.com/rack/rack/issues/337#issuecomment-46453404 request.params @app.call(env) # Rescue fr...
ruby
def call(env) # calling env.dup here prevents bad things from happening request = Rack::Request.new(env.dup) # calling request.params is sufficient to trigger the error see # https://github.com/rack/rack/issues/337#issuecomment-46453404 request.params @app.call(env) # Rescue fr...
[ "def", "call", "(", "env", ")", "request", "=", "Rack", "::", "Request", ".", "new", "(", "env", ".", "dup", ")", "request", ".", "params", "@app", ".", "call", "(", "env", ")", "rescue", "ArgumentError", "=>", "e", "raise", "unless", "e", ".", "me...
Called by Rack when a request comes through
[ "Called", "by", "Rack", "when", "a", "request", "comes", "through" ]
eafa7d0c867a015f865b1242af3940dc7536e575
https://github.com/sunny/handle_invalid_percent_encoding_requests/blob/eafa7d0c867a015f865b1242af3940dc7536e575/lib/handle_invalid_percent_encoding_requests/middleware.rb#L13-L29
train
monkbroc/particlerb
lib/particle/connection.rb
Particle.Connection.connection
def connection @connection ||= Faraday.new(conn_opts) do |http| http.url_prefix = endpoint if @access_token http.authorization :Bearer, @access_token end end end
ruby
def connection @connection ||= Faraday.new(conn_opts) do |http| http.url_prefix = endpoint if @access_token http.authorization :Bearer, @access_token end end end
[ "def", "connection", "@connection", "||=", "Faraday", ".", "new", "(", "conn_opts", ")", "do", "|", "http", "|", "http", ".", "url_prefix", "=", "endpoint", "if", "@access_token", "http", ".", "authorization", ":Bearer", ",", "@access_token", "end", "end", "...
HTTP connection for the Particle API @return [Faraday::Connection]
[ "HTTP", "connection", "for", "the", "Particle", "API" ]
a76ef290fd60cf216352f70fc47cb6109ce70742
https://github.com/monkbroc/particlerb/blob/a76ef290fd60cf216352f70fc47cb6109ce70742/lib/particle/connection.rb#L70-L77
train
cldwalker/boson
lib/boson/method_inspector.rb
Boson.MethodInspector.new_method_added
def new_method_added(mod, meth) self.current_module = mod store[:temp] ||= {} METHODS.each do |e| store[e][meth.to_s] = store[:temp][e] if store[:temp][e] end if store[:temp][:option] (store[:options][meth.to_s] ||= {}).merge! store[:temp][:option] end during_n...
ruby
def new_method_added(mod, meth) self.current_module = mod store[:temp] ||= {} METHODS.each do |e| store[e][meth.to_s] = store[:temp][e] if store[:temp][e] end if store[:temp][:option] (store[:options][meth.to_s] ||= {}).merge! store[:temp][:option] end during_n...
[ "def", "new_method_added", "(", "mod", ",", "meth", ")", "self", ".", "current_module", "=", "mod", "store", "[", ":temp", "]", "||=", "{", "}", "METHODS", ".", "each", "do", "|", "e", "|", "store", "[", "e", "]", "[", "meth", ".", "to_s", "]", "...
The method_added used while scraping method attributes.
[ "The", "method_added", "used", "while", "scraping", "method", "attributes", "." ]
17fe830fefd3dc41d90af01d191f074306591f32
https://github.com/cldwalker/boson/blob/17fe830fefd3dc41d90af01d191f074306591f32/lib/boson/method_inspector.rb#L37-L53
train
cldwalker/boson
lib/boson/option_command.rb
Boson.OptionCommand.parse
def parse(args) if args.size == 1 && args[0].is_a?(String) args = Shellwords.shellwords(args[0]) if !Boson.in_shell global_opt, parsed_options, args = parse_options args # last string argument interpreted as args + options elsif args.size > 1 && args[-1].is_a?(String) temp_args...
ruby
def parse(args) if args.size == 1 && args[0].is_a?(String) args = Shellwords.shellwords(args[0]) if !Boson.in_shell global_opt, parsed_options, args = parse_options args # last string argument interpreted as args + options elsif args.size > 1 && args[-1].is_a?(String) temp_args...
[ "def", "parse", "(", "args", ")", "if", "args", ".", "size", "==", "1", "&&", "args", "[", "0", "]", ".", "is_a?", "(", "String", ")", "args", "=", "Shellwords", ".", "shellwords", "(", "args", "[", "0", "]", ")", "if", "!", "Boson", ".", "in_s...
Parses arguments and returns global options, local options and leftover arguments.
[ "Parses", "arguments", "and", "returns", "global", "options", "local", "options", "and", "leftover", "arguments", "." ]
17fe830fefd3dc41d90af01d191f074306591f32
https://github.com/cldwalker/boson/blob/17fe830fefd3dc41d90af01d191f074306591f32/lib/boson/option_command.rb#L43-L64
train
cldwalker/boson
lib/boson/option_command.rb
Boson.OptionCommand.modify_args
def modify_args(args) if @command.default_option && @command.numerical_arg_size? && @command.arg_size <= 1 && !args[0].is_a?(Hash) && args[0].to_s[/./] != '-' && !args.join.empty? args[0] = "--#{@command.default_option}=#{args[0]}" end end
ruby
def modify_args(args) if @command.default_option && @command.numerical_arg_size? && @command.arg_size <= 1 && !args[0].is_a?(Hash) && args[0].to_s[/./] != '-' && !args.join.empty? args[0] = "--#{@command.default_option}=#{args[0]}" end end
[ "def", "modify_args", "(", "args", ")", "if", "@command", ".", "default_option", "&&", "@command", ".", "numerical_arg_size?", "&&", "@command", ".", "arg_size", "<=", "1", "&&", "!", "args", "[", "0", "]", ".", "is_a?", "(", "Hash", ")", "&&", "args", ...
modifies args for edge cases
[ "modifies", "args", "for", "edge", "cases" ]
17fe830fefd3dc41d90af01d191f074306591f32
https://github.com/cldwalker/boson/blob/17fe830fefd3dc41d90af01d191f074306591f32/lib/boson/option_command.rb#L79-L85
train
cldwalker/boson
lib/boson/option_command.rb
Boson.OptionCommand.check_argument_size
def check_argument_size(args) if @command.numerical_arg_size? && args.size != @command.arg_size command_size, args_size = args.size > @command.arg_size ? [@command.arg_size, args.size] : [@command.arg_size - 1, args.size - 1] raise CommandArgumentError, "wrong number ...
ruby
def check_argument_size(args) if @command.numerical_arg_size? && args.size != @command.arg_size command_size, args_size = args.size > @command.arg_size ? [@command.arg_size, args.size] : [@command.arg_size - 1, args.size - 1] raise CommandArgumentError, "wrong number ...
[ "def", "check_argument_size", "(", "args", ")", "if", "@command", ".", "numerical_arg_size?", "&&", "args", ".", "size", "!=", "@command", ".", "arg_size", "command_size", ",", "args_size", "=", "args", ".", "size", ">", "@command", ".", "arg_size", "?", "["...
raises CommandArgumentError if argument size is incorrect for given args
[ "raises", "CommandArgumentError", "if", "argument", "size", "is", "incorrect", "for", "given", "args" ]
17fe830fefd3dc41d90af01d191f074306591f32
https://github.com/cldwalker/boson/blob/17fe830fefd3dc41d90af01d191f074306591f32/lib/boson/option_command.rb#L88-L96
train
cldwalker/boson
lib/boson/option_command.rb
Boson.OptionCommand.add_default_args
def add_default_args(args, obj) if @command.args && args.size < @command.arg_size - 1 # leave off last arg since its an option @command.args.slice(0..-2).each_with_index {|arr,i| next if args.size >= i + 1 # only fill in once args run out break if arr.size != 2 # a default arg ...
ruby
def add_default_args(args, obj) if @command.args && args.size < @command.arg_size - 1 # leave off last arg since its an option @command.args.slice(0..-2).each_with_index {|arr,i| next if args.size >= i + 1 # only fill in once args run out break if arr.size != 2 # a default arg ...
[ "def", "add_default_args", "(", "args", ",", "obj", ")", "if", "@command", ".", "args", "&&", "args", ".", "size", "<", "@command", ".", "arg_size", "-", "1", "@command", ".", "args", ".", "slice", "(", "0", "..", "-", "2", ")", ".", "each_with_index...
Adds default args as original method would
[ "Adds", "default", "args", "as", "original", "method", "would" ]
17fe830fefd3dc41d90af01d191f074306591f32
https://github.com/cldwalker/boson/blob/17fe830fefd3dc41d90af01d191f074306591f32/lib/boson/option_command.rb#L99-L113
train
alfa-jpn/kakurenbo
lib/kakurenbo/core.rb
Kakurenbo.Core.delete
def delete(options = {:hard => false}) if options[:hard] self.class.delete(self.id, options) else return if new_record? or destroyed? update_column kakurenbo_column, current_time_from_proper_timezone end end
ruby
def delete(options = {:hard => false}) if options[:hard] self.class.delete(self.id, options) else return if new_record? or destroyed? update_column kakurenbo_column, current_time_from_proper_timezone end end
[ "def", "delete", "(", "options", "=", "{", ":hard", "=>", "false", "}", ")", "if", "options", "[", ":hard", "]", "self", ".", "class", ".", "delete", "(", "self", ".", "id", ",", "options", ")", "else", "return", "if", "new_record?", "or", "destroyed...
delete record. @param options [Hash] options. @option options [Boolean] hard (false) if hard-delete.
[ "delete", "record", "." ]
d577f885134f8229c926a60af8dbe7adabd810d8
https://github.com/alfa-jpn/kakurenbo/blob/d577f885134f8229c926a60af8dbe7adabd810d8/lib/kakurenbo/core.rb#L57-L64
train
alfa-jpn/kakurenbo
lib/kakurenbo/core.rb
Kakurenbo.Core.destroy
def destroy(options = {:hard => false}) if options[:hard] with_transaction_returning_status do hard_destroy_associated_records self.reload.hard_destroy end else return true if destroyed? with_transaction_returning_status do destroy_at = Time.now ...
ruby
def destroy(options = {:hard => false}) if options[:hard] with_transaction_returning_status do hard_destroy_associated_records self.reload.hard_destroy end else return true if destroyed? with_transaction_returning_status do destroy_at = Time.now ...
[ "def", "destroy", "(", "options", "=", "{", ":hard", "=>", "false", "}", ")", "if", "options", "[", ":hard", "]", "with_transaction_returning_status", "do", "hard_destroy_associated_records", "self", ".", "reload", ".", "hard_destroy", "end", "else", "return", "...
destroy record and run callbacks. @param options [Hash] options. @option options [Boolean] hard (false) if hard-delete. @return [Boolean, self] if action is cancelled, return false.
[ "destroy", "record", "and", "run", "callbacks", "." ]
d577f885134f8229c926a60af8dbe7adabd810d8
https://github.com/alfa-jpn/kakurenbo/blob/d577f885134f8229c926a60af8dbe7adabd810d8/lib/kakurenbo/core.rb#L72-L85
train
alfa-jpn/kakurenbo
lib/kakurenbo/core.rb
Kakurenbo.Core.restore
def restore(options = {:recursive => true}) return false unless destroyed? with_transaction_returning_status do run_callbacks(:restore) do restore_associated_records if options[:recursive] update_column kakurenbo_column, nil self end end end
ruby
def restore(options = {:recursive => true}) return false unless destroyed? with_transaction_returning_status do run_callbacks(:restore) do restore_associated_records if options[:recursive] update_column kakurenbo_column, nil self end end end
[ "def", "restore", "(", "options", "=", "{", ":recursive", "=>", "true", "}", ")", "return", "false", "unless", "destroyed?", "with_transaction_returning_status", "do", "run_callbacks", "(", ":restore", ")", "do", "restore_associated_records", "if", "options", "[", ...
restore record. @param options [Hash] options. @option options [Boolean] recursive (true) if restore recursive. @return [Boolean, self] if action is cancelled, return false.
[ "restore", "record", "." ]
d577f885134f8229c926a60af8dbe7adabd810d8
https://github.com/alfa-jpn/kakurenbo/blob/d577f885134f8229c926a60af8dbe7adabd810d8/lib/kakurenbo/core.rb#L119-L129
train
alfa-jpn/kakurenbo
lib/kakurenbo/core.rb
Kakurenbo.Core.dependent_association_scopes
def dependent_association_scopes self.class.reflect_on_all_associations.select { |reflection| reflection.options[:dependent] == :destroy and reflection.klass.paranoid? }.map { |reflection| self.association(reflection.name).tap {|assoc| assoc.reset_scope }.scope } end
ruby
def dependent_association_scopes self.class.reflect_on_all_associations.select { |reflection| reflection.options[:dependent] == :destroy and reflection.klass.paranoid? }.map { |reflection| self.association(reflection.name).tap {|assoc| assoc.reset_scope }.scope } end
[ "def", "dependent_association_scopes", "self", ".", "class", ".", "reflect_on_all_associations", ".", "select", "{", "|", "reflection", "|", "reflection", ".", "options", "[", ":dependent", "]", "==", ":destroy", "and", "reflection", ".", "klass", ".", "paranoid?"...
All Scope of dependent association. @return [Array<ActiveRecord::Relation>] array of dependent association.
[ "All", "Scope", "of", "dependent", "association", "." ]
d577f885134f8229c926a60af8dbe7adabd810d8
https://github.com/alfa-jpn/kakurenbo/blob/d577f885134f8229c926a60af8dbe7adabd810d8/lib/kakurenbo/core.rb#L145-L151
train
schleyfox/ruby_kml
lib/kml/geometry.rb
KML.Geometry.altitude_mode=
def altitude_mode=(mode) allowed_modes = %w(clampToGround relativeToGround absolute) if allowed_modes.include?(mode) @altitude_mode = mode else raise ArgumentError, "Must be one of the allowed altitude modes: #{allowed_modes.join(',')}" end end
ruby
def altitude_mode=(mode) allowed_modes = %w(clampToGround relativeToGround absolute) if allowed_modes.include?(mode) @altitude_mode = mode else raise ArgumentError, "Must be one of the allowed altitude modes: #{allowed_modes.join(',')}" end end
[ "def", "altitude_mode", "=", "(", "mode", ")", "allowed_modes", "=", "%w(", "clampToGround", "relativeToGround", "absolute", ")", "if", "allowed_modes", ".", "include?", "(", "mode", ")", "@altitude_mode", "=", "mode", "else", "raise", "ArgumentError", ",", "\"M...
Set the altitude mode
[ "Set", "the", "altitude", "mode" ]
0d6b4d076e1ee155893f7d8e82b7055644e024b8
https://github.com/schleyfox/ruby_kml/blob/0d6b4d076e1ee155893f7d8e82b7055644e024b8/lib/kml/geometry.rb#L63-L70
train
schleyfox/ruby_kml
lib/kml/feature.rb
KML.Feature.render
def render(xm=Builder::XmlMarkup.new(:indent => 2)) [:name, :visibility, :address].each do |a| xm.__send__(a, self.__send__(a)) unless self.__send__(a).nil? end xm.description { xm.cdata!(description) } unless description.nil? xm.open(self.open) unless open.nil? xm.ph...
ruby
def render(xm=Builder::XmlMarkup.new(:indent => 2)) [:name, :visibility, :address].each do |a| xm.__send__(a, self.__send__(a)) unless self.__send__(a).nil? end xm.description { xm.cdata!(description) } unless description.nil? xm.open(self.open) unless open.nil? xm.ph...
[ "def", "render", "(", "xm", "=", "Builder", "::", "XmlMarkup", ".", "new", "(", ":indent", "=>", "2", ")", ")", "[", ":name", ",", ":visibility", ",", ":address", "]", ".", "each", "do", "|", "a", "|", "xm", ".", "__send__", "(", "a", ",", "self"...
Render the object and all of its sub-elements.
[ "Render", "the", "object", "and", "all", "of", "its", "sub", "-", "elements", "." ]
0d6b4d076e1ee155893f7d8e82b7055644e024b8
https://github.com/schleyfox/ruby_kml/blob/0d6b4d076e1ee155893f7d8e82b7055644e024b8/lib/kml/feature.rb#L133-L153
train
taxweb/ransack_advanced_search
app/controllers/concerns/ransack_advanced_search/saved_search_utils.rb
RansackAdvancedSearch.SavedSearchUtils.perform_saved_searches_actions
def perform_saved_searches_actions(context, params={}) get_saved_searches(context) save_or_update_saved_search(params.merge(context: context)) get_params_to_search(context) end
ruby
def perform_saved_searches_actions(context, params={}) get_saved_searches(context) save_or_update_saved_search(params.merge(context: context)) get_params_to_search(context) end
[ "def", "perform_saved_searches_actions", "(", "context", ",", "params", "=", "{", "}", ")", "get_saved_searches", "(", "context", ")", "save_or_update_saved_search", "(", "params", ".", "merge", "(", "context", ":", "context", ")", ")", "get_params_to_search", "("...
Perform saved searches actions to provide full functionality with one method
[ "Perform", "saved", "searches", "actions", "to", "provide", "full", "functionality", "with", "one", "method" ]
1e757ad118aa02bd9064fa02fca48d32163fcd87
https://github.com/taxweb/ransack_advanced_search/blob/1e757ad118aa02bd9064fa02fca48d32163fcd87/app/controllers/concerns/ransack_advanced_search/saved_search_utils.rb#L6-L10
train
taxweb/ransack_advanced_search
app/controllers/concerns/ransack_advanced_search/saved_search_utils.rb
RansackAdvancedSearch.SavedSearchUtils.get_params_to_search
def get_params_to_search(context) if params[:saved_search].present? @saved_search = SavedSearch.find_by(id: params[:saved_search], context: context) end return params[:q] if params[:use_search_params].present? params[:q] = @saved_search.try(:search_params) || params[:q] end
ruby
def get_params_to_search(context) if params[:saved_search].present? @saved_search = SavedSearch.find_by(id: params[:saved_search], context: context) end return params[:q] if params[:use_search_params].present? params[:q] = @saved_search.try(:search_params) || params[:q] end
[ "def", "get_params_to_search", "(", "context", ")", "if", "params", "[", ":saved_search", "]", ".", "present?", "@saved_search", "=", "SavedSearch", ".", "find_by", "(", "id", ":", "params", "[", ":saved_search", "]", ",", "context", ":", "context", ")", "en...
Return params of Saved Search or search form params
[ "Return", "params", "of", "Saved", "Search", "or", "search", "form", "params" ]
1e757ad118aa02bd9064fa02fca48d32163fcd87
https://github.com/taxweb/ransack_advanced_search/blob/1e757ad118aa02bd9064fa02fca48d32163fcd87/app/controllers/concerns/ransack_advanced_search/saved_search_utils.rb#L18-L24
train
taxweb/ransack_advanced_search
app/controllers/concerns/ransack_advanced_search/saved_search_utils.rb
RansackAdvancedSearch.SavedSearchUtils.save_or_update_saved_search
def save_or_update_saved_search(params) if params[:save_new_search].present? || params[:save_search].present? if params[:save_new_search].present? @saved_search = new_saved_search(params) elsif params[:save_search].present? && params[:saved_search].present? @saved_search = upda...
ruby
def save_or_update_saved_search(params) if params[:save_new_search].present? || params[:save_search].present? if params[:save_new_search].present? @saved_search = new_saved_search(params) elsif params[:save_search].present? && params[:saved_search].present? @saved_search = upda...
[ "def", "save_or_update_saved_search", "(", "params", ")", "if", "params", "[", ":save_new_search", "]", ".", "present?", "||", "params", "[", ":save_search", "]", ".", "present?", "if", "params", "[", ":save_new_search", "]", ".", "present?", "@saved_search", "=...
Save or update Saved Search
[ "Save", "or", "update", "Saved", "Search" ]
1e757ad118aa02bd9064fa02fca48d32163fcd87
https://github.com/taxweb/ransack_advanced_search/blob/1e757ad118aa02bd9064fa02fca48d32163fcd87/app/controllers/concerns/ransack_advanced_search/saved_search_utils.rb#L27-L43
train
gderosa/rubysu
lib/sudo/wrapper.rb
Sudo.Wrapper.start!
def start! Sudo::System.check @sudo_pid = spawn( "#{SUDO_CMD} -E #{RUBY_CMD} -I#{LIBDIR} #{@ruby_opts} #{SERVER_SCRIPT} #{@socket} #{Process.uid}" ) Process.detach(@sudo_pid) if @sudo_pid # avoid zombies finalizer = Finalizer.new(pid: @sudo_pid, socket: @socket) ObjectSpace.define_f...
ruby
def start! Sudo::System.check @sudo_pid = spawn( "#{SUDO_CMD} -E #{RUBY_CMD} -I#{LIBDIR} #{@ruby_opts} #{SERVER_SCRIPT} #{@socket} #{Process.uid}" ) Process.detach(@sudo_pid) if @sudo_pid # avoid zombies finalizer = Finalizer.new(pid: @sudo_pid, socket: @socket) ObjectSpace.define_f...
[ "def", "start!", "Sudo", "::", "System", ".", "check", "@sudo_pid", "=", "spawn", "(", "\"#{SUDO_CMD} -E #{RUBY_CMD} -I#{LIBDIR} #{@ruby_opts} #{SERVER_SCRIPT} #{@socket} #{Process.uid}\"", ")", "Process", ".", "detach", "(", "@sudo_pid", ")", "if", "@sudo_pid", "finalizer"...
Start the sudo-ed Ruby process.
[ "Start", "the", "sudo", "-", "ed", "Ruby", "process", "." ]
8a2905c659b3bb0ec408c6f5283596bc622d2d19
https://github.com/gderosa/rubysu/blob/8a2905c659b3bb0ec408c6f5283596bc622d2d19/lib/sudo/wrapper.rb#L62-L81
train
gderosa/rubysu
lib/sudo/wrapper.rb
Sudo.Wrapper.load_gems
def load_gems load_paths prospective_gems.each do |prospect| gem_name = prospect.dup begin loaded = @proxy.proxy(Kernel, :require, gem_name) # puts "Loading Gem: #{gem_name} => #{loaded}" rescue LoadError, NameError => e old_gem_name = gem_name.dup ...
ruby
def load_gems load_paths prospective_gems.each do |prospect| gem_name = prospect.dup begin loaded = @proxy.proxy(Kernel, :require, gem_name) # puts "Loading Gem: #{gem_name} => #{loaded}" rescue LoadError, NameError => e old_gem_name = gem_name.dup ...
[ "def", "load_gems", "load_paths", "prospective_gems", ".", "each", "do", "|", "prospect", "|", "gem_name", "=", "prospect", ".", "dup", "begin", "loaded", "=", "@proxy", ".", "proxy", "(", "Kernel", ",", ":require", ",", "gem_name", ")", "rescue", "LoadError...
Load needed libraries in the DRb server. Usually you don't need
[ "Load", "needed", "libraries", "in", "the", "DRb", "server", ".", "Usually", "you", "don", "t", "need" ]
8a2905c659b3bb0ec408c6f5283596bc622d2d19
https://github.com/gderosa/rubysu/blob/8a2905c659b3bb0ec408c6f5283596bc622d2d19/lib/sudo/wrapper.rb#L137-L150
train
bdwyertech/chef-rundeck2
lib/chef-rundeck/config.rb
ChefRunDeck.Config.add
def add(config = {}) config.each do |key, value| define_setting key.to_sym, value end end
ruby
def add(config = {}) config.each do |key, value| define_setting key.to_sym, value end end
[ "def", "add", "(", "config", "=", "{", "}", ")", "config", ".", "each", "do", "|", "key", ",", "value", "|", "define_setting", "key", ".", "to_sym", ",", "value", "end", "end" ]
=> Facilitate Dynamic Addition of Configuration Values => @return [class_variable]
[ "=", ">", "Facilitate", "Dynamic", "Addition", "of", "Configuration", "Values" ]
5c67fa2a2f4cd01716a0859dd4b900e740dfc8f7
https://github.com/bdwyertech/chef-rundeck2/blob/5c67fa2a2f4cd01716a0859dd4b900e740dfc8f7/lib/chef-rundeck/config.rb#L71-L75
train
bdwyertech/chef-rundeck2
lib/chef-rundeck/chef.rb
ChefRunDeck.Chef.delete
def delete(node) # => Make sure the Node Exists return 'Node not found on Chef Server' unless Node.exists?(node) # => Initialize the Admin API Client Settings admin_api_client # => Delete the Client & Node Object Client.delete(node) Node.delete(node) 'Client/Node Delete...
ruby
def delete(node) # => Make sure the Node Exists return 'Node not found on Chef Server' unless Node.exists?(node) # => Initialize the Admin API Client Settings admin_api_client # => Delete the Client & Node Object Client.delete(node) Node.delete(node) 'Client/Node Delete...
[ "def", "delete", "(", "node", ")", "return", "'Node not found on Chef Server'", "unless", "Node", ".", "exists?", "(", "node", ")", "admin_api_client", "Client", ".", "delete", "(", "node", ")", "Node", ".", "delete", "(", "node", ")", "'Client/Node Deleted from...
=> Delete a Node Object
[ "=", ">", "Delete", "a", "Node", "Object" ]
5c67fa2a2f4cd01716a0859dd4b900e740dfc8f7
https://github.com/bdwyertech/chef-rundeck2/blob/5c67fa2a2f4cd01716a0859dd4b900e740dfc8f7/lib/chef-rundeck/chef.rb#L66-L77
train
github/octofacts
lib/octofacts_updater/cli.rb
OctofactsUpdater.CLI.run
def run unless opts[:action] usage exit 255 end @config = {} if opts[:config] @config = YAML.load_file(opts[:config]) substitute_relative_paths!(@config, File.dirname(opts[:config])) load_plugins(@config["plugins"]) if @config.key?("plugins") end ...
ruby
def run unless opts[:action] usage exit 255 end @config = {} if opts[:config] @config = YAML.load_file(opts[:config]) substitute_relative_paths!(@config, File.dirname(opts[:config])) load_plugins(@config["plugins"]) if @config.key?("plugins") end ...
[ "def", "run", "unless", "opts", "[", ":action", "]", "usage", "exit", "255", "end", "@config", "=", "{", "}", "if", "opts", "[", ":config", "]", "@config", "=", "YAML", ".", "load_file", "(", "opts", "[", ":config", "]", ")", "substitute_relative_paths!"...
Run method. Call this to run the octofacts updater with the object that was previously construcuted.
[ "Run", "method", ".", "Call", "this", "to", "run", "the", "octofacts", "updater", "with", "the", "object", "that", "was", "previously", "construcuted", "." ]
0fe4f4bc1de16f41f6ef2eb45eb1d2d687617ce7
https://github.com/github/octofacts/blob/0fe4f4bc1de16f41f6ef2eb45eb1d2d687617ce7/lib/octofacts_updater/cli.rb#L81-L114
train
github/octofacts
lib/octofacts_updater/cli.rb
OctofactsUpdater.CLI.index_file
def index_file @index_file ||= begin if config.fetch("index", {})["file"] return config["index"]["file"] if File.file?(config["index"]["file"]) raise Errno::ENOENT, "Index file (#{config['index']['file'].inspect}) does not exist" end raise ArgumentError, "No index file ...
ruby
def index_file @index_file ||= begin if config.fetch("index", {})["file"] return config["index"]["file"] if File.file?(config["index"]["file"]) raise Errno::ENOENT, "Index file (#{config['index']['file'].inspect}) does not exist" end raise ArgumentError, "No index file ...
[ "def", "index_file", "@index_file", "||=", "begin", "if", "config", ".", "fetch", "(", "\"index\"", ",", "{", "}", ")", "[", "\"file\"", "]", "return", "config", "[", "\"index\"", "]", "[", "\"file\"", "]", "if", "File", ".", "file?", "(", "config", "[...
Get the index file from the options or configuration file. Raise error if it does not exist or was not specified.
[ "Get", "the", "index", "file", "from", "the", "options", "or", "configuration", "file", ".", "Raise", "error", "if", "it", "does", "not", "exist", "or", "was", "not", "specified", "." ]
0fe4f4bc1de16f41f6ef2eb45eb1d2d687617ce7
https://github.com/github/octofacts/blob/0fe4f4bc1de16f41f6ef2eb45eb1d2d687617ce7/lib/octofacts_updater/cli.rb#L214-L222
train
github/octofacts
lib/octofacts_updater/cli.rb
OctofactsUpdater.CLI.print_or_write
def print_or_write(data) if opts[:output_file] File.open(opts[:output_file], "w") { |f| f.write(data) } else puts data end end
ruby
def print_or_write(data) if opts[:output_file] File.open(opts[:output_file], "w") { |f| f.write(data) } else puts data end end
[ "def", "print_or_write", "(", "data", ")", "if", "opts", "[", ":output_file", "]", "File", ".", "open", "(", "opts", "[", ":output_file", "]", ",", "\"w\"", ")", "{", "|", "f", "|", "f", ".", "write", "(", "data", ")", "}", "else", "puts", "data", ...
Print or write to file depending on whether or not the output file was set. data - Data to print or write.
[ "Print", "or", "write", "to", "file", "depending", "on", "whether", "or", "not", "the", "output", "file", "was", "set", "." ]
0fe4f4bc1de16f41f6ef2eb45eb1d2d687617ce7
https://github.com/github/octofacts/blob/0fe4f4bc1de16f41f6ef2eb45eb1d2d687617ce7/lib/octofacts_updater/cli.rb#L245-L251
train
joeyates/rake-builder
lib/rake/builder.rb
Rake.Builder.ensure_headers
def ensure_headers missing = missing_headers return if missing.size == 0 message = "Compilation cannot proceed as the following header files are missing:\n" + missing.join("\n") raise Error.new(message) end
ruby
def ensure_headers missing = missing_headers return if missing.size == 0 message = "Compilation cannot proceed as the following header files are missing:\n" + missing.join("\n") raise Error.new(message) end
[ "def", "ensure_headers", "missing", "=", "missing_headers", "return", "if", "missing", ".", "size", "==", "0", "message", "=", "\"Compilation cannot proceed as the following header files are missing:\\n\"", "+", "missing", ".", "join", "(", "\"\\n\"", ")", "raise", "Err...
Raises an error if there are missing headers
[ "Raises", "an", "error", "if", "there", "are", "missing", "headers" ]
38e840fc8575fb7c05b631afa1cddab7914234ea
https://github.com/joeyates/rake-builder/blob/38e840fc8575fb7c05b631afa1cddab7914234ea/lib/rake/builder.rb#L301-L307
train
joeyates/rake-builder
lib/rake/builder.rb
Rake.Builder.source_files
def source_files return @source_files if @source_files old_dir = Dir.pwd Dir.chdir @rakefile_path @source_files = Rake::Path.find_files(@source_search_paths, source_file_extension).uniq.sort Dir.chdir old_dir @source_files end
ruby
def source_files return @source_files if @source_files old_dir = Dir.pwd Dir.chdir @rakefile_path @source_files = Rake::Path.find_files(@source_search_paths, source_file_extension).uniq.sort Dir.chdir old_dir @source_files end
[ "def", "source_files", "return", "@source_files", "if", "@source_files", "old_dir", "=", "Dir", ".", "pwd", "Dir", ".", "chdir", "@rakefile_path", "@source_files", "=", "Rake", "::", "Path", ".", "find_files", "(", "@source_search_paths", ",", "source_file_extension...
Source files found in source_search_paths
[ "Source", "files", "found", "in", "source_search_paths" ]
38e840fc8575fb7c05b631afa1cddab7914234ea
https://github.com/joeyates/rake-builder/blob/38e840fc8575fb7c05b631afa1cddab7914234ea/lib/rake/builder.rb#L351-L359
train
Aerlinger/attr_deprecated
lib/attr_deprecated.rb
AttrDeprecated.ClassMethods._set_attribute_as_deprecated
def _set_attribute_as_deprecated(attribute) original_attribute_method = instance_method(attribute.to_sym) klass = self define_method attribute.to_sym do |*args| backtrace_cleaner = ActiveSupport::BacktraceCleaner.new backtrace = backtrace_cleaner.clean(caller) klass._notify_...
ruby
def _set_attribute_as_deprecated(attribute) original_attribute_method = instance_method(attribute.to_sym) klass = self define_method attribute.to_sym do |*args| backtrace_cleaner = ActiveSupport::BacktraceCleaner.new backtrace = backtrace_cleaner.clean(caller) klass._notify_...
[ "def", "_set_attribute_as_deprecated", "(", "attribute", ")", "original_attribute_method", "=", "instance_method", "(", "attribute", ".", "to_sym", ")", "klass", "=", "self", "define_method", "attribute", ".", "to_sym", "do", "|", "*", "args", "|", "backtrace_cleane...
Wrap the original attribute method with appropriate notification while leaving the functionality of the original method unchanged.
[ "Wrap", "the", "original", "attribute", "method", "with", "appropriate", "notification", "while", "leaving", "the", "functionality", "of", "the", "original", "method", "unchanged", "." ]
ead9483a7e220ffd987d8f06f0c0ccabc713500e
https://github.com/Aerlinger/attr_deprecated/blob/ead9483a7e220ffd987d8f06f0c0ccabc713500e/lib/attr_deprecated.rb#L77-L91
train
github/octofacts
lib/octofacts_updater/fact_index.rb
OctofactsUpdater.FactIndex.reindex
def reindex(facts_to_index, fixtures) @index_data = {} facts_to_index.each { |fact| add(fact, fixtures) } set_top_level_nodes_fact(fixtures) end
ruby
def reindex(facts_to_index, fixtures) @index_data = {} facts_to_index.each { |fact| add(fact, fixtures) } set_top_level_nodes_fact(fixtures) end
[ "def", "reindex", "(", "facts_to_index", ",", "fixtures", ")", "@index_data", "=", "{", "}", "facts_to_index", ".", "each", "{", "|", "fact", "|", "add", "(", "fact", ",", "fixtures", ")", "}", "set_top_level_nodes_fact", "(", "fixtures", ")", "end" ]
Rebuild an index with a specified list of facts. This will remove any indexed facts that are not on the list of facts to use. facts_to_index - An Array of Strings with facts to index fixtures - An Array with fact fixtures (must respond to .facts and .hostname)
[ "Rebuild", "an", "index", "with", "a", "specified", "list", "of", "facts", ".", "This", "will", "remove", "any", "indexed", "facts", "that", "are", "not", "on", "the", "list", "of", "facts", "to", "use", "." ]
0fe4f4bc1de16f41f6ef2eb45eb1d2d687617ce7
https://github.com/github/octofacts/blob/0fe4f4bc1de16f41f6ef2eb45eb1d2d687617ce7/lib/octofacts_updater/fact_index.rb#L92-L96
train
github/octofacts
lib/octofacts_updater/fact_index.rb
OctofactsUpdater.FactIndex.write_file
def write_file(filename = nil) filename ||= @filename unless filename.is_a?(String) raise ArgumentError, "Called write_file() for fact_index without a filename" end File.open(filename, "w") { |f| f.write(to_yaml) } end
ruby
def write_file(filename = nil) filename ||= @filename unless filename.is_a?(String) raise ArgumentError, "Called write_file() for fact_index without a filename" end File.open(filename, "w") { |f| f.write(to_yaml) } end
[ "def", "write_file", "(", "filename", "=", "nil", ")", "filename", "||=", "@filename", "unless", "filename", ".", "is_a?", "(", "String", ")", "raise", "ArgumentError", ",", "\"Called write_file() for fact_index without a filename\"", "end", "File", ".", "open", "("...
Write the fact index out to a YAML file. filename - A String with the file to write (defaults to filename from constructor if available)
[ "Write", "the", "fact", "index", "out", "to", "a", "YAML", "file", "." ]
0fe4f4bc1de16f41f6ef2eb45eb1d2d687617ce7
https://github.com/github/octofacts/blob/0fe4f4bc1de16f41f6ef2eb45eb1d2d687617ce7/lib/octofacts_updater/fact_index.rb#L126-L132
train
Tapjoy/chore
lib/chore/job.rb
Chore.Job.perform_async
def perform_async(*args) self.class.run_hooks_for(:before_publish,*args) @chore_publisher ||= self.class.options[:publisher] @chore_publisher.publish(self.class.prefixed_queue_name,self.class.job_hash(args)) self.class.run_hooks_for(:after_publish,*args) end
ruby
def perform_async(*args) self.class.run_hooks_for(:before_publish,*args) @chore_publisher ||= self.class.options[:publisher] @chore_publisher.publish(self.class.prefixed_queue_name,self.class.job_hash(args)) self.class.run_hooks_for(:after_publish,*args) end
[ "def", "perform_async", "(", "*", "args", ")", "self", ".", "class", ".", "run_hooks_for", "(", ":before_publish", ",", "*", "args", ")", "@chore_publisher", "||=", "self", ".", "class", ".", "options", "[", ":publisher", "]", "@chore_publisher", ".", "publi...
Use the current configured publisher to send this job into a queue.
[ "Use", "the", "current", "configured", "publisher", "to", "send", "this", "job", "into", "a", "queue", "." ]
f3d978cb6e5f20aa2a163f2c80f3c1c2efa93ef1
https://github.com/Tapjoy/chore/blob/f3d978cb6e5f20aa2a163f2c80f3c1c2efa93ef1/lib/chore/job.rb#L125-L130
train
unboxed/be_valid_asset
lib/be_valid_asset/be_valid_feed.rb
BeValidAsset.BeValidFeed.response_indicates_valid?
def response_indicates_valid?(response) REXML::Document.new(response.body).root.get_elements('//m:validity').first.text == 'true' end
ruby
def response_indicates_valid?(response) REXML::Document.new(response.body).root.get_elements('//m:validity').first.text == 'true' end
[ "def", "response_indicates_valid?", "(", "response", ")", "REXML", "::", "Document", ".", "new", "(", "response", ".", "body", ")", ".", "root", ".", "get_elements", "(", "'//m:validity'", ")", ".", "first", ".", "text", "==", "'true'", "end" ]
The feed validator uses a different response type, so we have to override these here.
[ "The", "feed", "validator", "uses", "a", "different", "response", "type", "so", "we", "have", "to", "override", "these", "here", "." ]
a4d2096d2b6f108c9fb06e0431bc854479a9cd1f
https://github.com/unboxed/be_valid_asset/blob/a4d2096d2b6f108c9fb06e0431bc854479a9cd1f/lib/be_valid_asset/be_valid_feed.rb#L47-L49
train
github/octofacts
lib/octofacts/facts.rb
Octofacts.Facts.method_missing
def method_missing(name, *args, &block) if Octofacts::Manipulators.run(self, name, *args, &block) @facts_manipulated = true return self end if facts.respond_to?(name, false) if args[0].is_a?(String) || args[0].is_a?(Symbol) args[0] = string_or_symbolized_key(args[0])...
ruby
def method_missing(name, *args, &block) if Octofacts::Manipulators.run(self, name, *args, &block) @facts_manipulated = true return self end if facts.respond_to?(name, false) if args[0].is_a?(String) || args[0].is_a?(Symbol) args[0] = string_or_symbolized_key(args[0])...
[ "def", "method_missing", "(", "name", ",", "*", "args", ",", "&", "block", ")", "if", "Octofacts", "::", "Manipulators", ".", "run", "(", "self", ",", "name", ",", "*", "args", ",", "&", "block", ")", "@facts_manipulated", "=", "true", "return", "self"...
Missing method - this is used to dispatch to manipulators or to call a Hash method in the facts. Try calling a Manipulator method, delegate to the facts hash or else error out. Returns this object (so that calls to manipulators can be chained).
[ "Missing", "method", "-", "this", "is", "used", "to", "dispatch", "to", "manipulators", "or", "to", "call", "a", "Hash", "method", "in", "the", "facts", "." ]
0fe4f4bc1de16f41f6ef2eb45eb1d2d687617ce7
https://github.com/github/octofacts/blob/0fe4f4bc1de16f41f6ef2eb45eb1d2d687617ce7/lib/octofacts/facts.rb#L78-L92
train
bdwyertech/chef-rundeck2
lib/chef-rundeck/cli.rb
ChefRunDeck.CLI.run
def run(argv = ARGV) # => Parse CLI Configuration cli = Options.new cli.parse_options(argv) # => Grab the Default Values default = Config.options # => Parse JSON Config File (If Specified and Exists) json_config = Util.parse_json_config(cli.config[:config_file] || Config.conf...
ruby
def run(argv = ARGV) # => Parse CLI Configuration cli = Options.new cli.parse_options(argv) # => Grab the Default Values default = Config.options # => Parse JSON Config File (If Specified and Exists) json_config = Util.parse_json_config(cli.config[:config_file] || Config.conf...
[ "def", "run", "(", "argv", "=", "ARGV", ")", "cli", "=", "Options", ".", "new", "cli", ".", "parse_options", "(", "argv", ")", "default", "=", "Config", ".", "options", "json_config", "=", "Util", ".", "parse_json_config", "(", "cli", ".", "config", "[...
=> Launch the Application
[ "=", ">", "Launch", "the", "Application" ]
5c67fa2a2f4cd01716a0859dd4b900e740dfc8f7
https://github.com/bdwyertech/chef-rundeck2/blob/5c67fa2a2f4cd01716a0859dd4b900e740dfc8f7/lib/chef-rundeck/cli.rb#L97-L130
train
soracom/soracom-sdk-ruby
lib/soracom/client.rb
Soracom.Client.auth_by_user
def auth_by_user(operator_id, user_name, password, endpoint) endpoint = API_BASE_URL if endpoint.nil? res = RestClient.post endpoint + '/auth', { operatorId: operator_id, userName: user_name, password: password }, 'Content-Type' => 'application/json', ...
ruby
def auth_by_user(operator_id, user_name, password, endpoint) endpoint = API_BASE_URL if endpoint.nil? res = RestClient.post endpoint + '/auth', { operatorId: operator_id, userName: user_name, password: password }, 'Content-Type' => 'application/json', ...
[ "def", "auth_by_user", "(", "operator_id", ",", "user_name", ",", "password", ",", "endpoint", ")", "endpoint", "=", "API_BASE_URL", "if", "endpoint", ".", "nil?", "res", "=", "RestClient", ".", "post", "endpoint", "+", "'/auth'", ",", "{", "operatorId", ":"...
authenticate by operator_id and user_name and password
[ "authenticate", "by", "operator_id", "and", "user_name", "and", "password" ]
7e8e2158a7818ffc62191fb15b948f633b1d49d1
https://github.com/soracom/soracom-sdk-ruby/blob/7e8e2158a7818ffc62191fb15b948f633b1d49d1/lib/soracom/client.rb#L538-L547
train
github/octofacts
lib/octofacts_updater/fact.rb
OctofactsUpdater.Fact.set_value
def set_value(new_value, name_in = nil) if name_in.nil? if new_value.is_a?(Proc) return @value = new_value.call(@value) end return @value = new_value end parts = if name_in.is_a?(String) name_in.split("::") elsif name_in.is_a?(Array) name_in.ma...
ruby
def set_value(new_value, name_in = nil) if name_in.nil? if new_value.is_a?(Proc) return @value = new_value.call(@value) end return @value = new_value end parts = if name_in.is_a?(String) name_in.split("::") elsif name_in.is_a?(Array) name_in.ma...
[ "def", "set_value", "(", "new_value", ",", "name_in", "=", "nil", ")", "if", "name_in", ".", "nil?", "if", "new_value", ".", "is_a?", "(", "Proc", ")", "return", "@value", "=", "new_value", ".", "call", "(", "@value", ")", "end", "return", "@value", "=...
Set the value of the fact. If the name is specified, this will dig into a structured fact to set the value within the structure. new_value - An object with the new value for the fact name_in - An optional String to dig into the structure (formatted with :: indicating hash delimiters)
[ "Set", "the", "value", "of", "the", "fact", ".", "If", "the", "name", "is", "specified", "this", "will", "dig", "into", "a", "structured", "fact", "to", "set", "the", "value", "within", "the", "structure", "." ]
0fe4f4bc1de16f41f6ef2eb45eb1d2d687617ce7
https://github.com/github/octofacts/blob/0fe4f4bc1de16f41f6ef2eb45eb1d2d687617ce7/lib/octofacts_updater/fact.rb#L58-L84
train
github/octofacts
lib/octofacts_updater/fact.rb
OctofactsUpdater.Fact.set_structured_value
def set_structured_value(subhash, parts, value) return if subhash.nil? raise ArgumentError, "Cannot set structured value at #{parts.first.inspect}" unless subhash.is_a?(Hash) raise ArgumentError, "parts must be an Array, got #{parts.inspect}" unless parts.is_a?(Array) # At the top level, find a...
ruby
def set_structured_value(subhash, parts, value) return if subhash.nil? raise ArgumentError, "Cannot set structured value at #{parts.first.inspect}" unless subhash.is_a?(Hash) raise ArgumentError, "parts must be an Array, got #{parts.inspect}" unless parts.is_a?(Array) # At the top level, find a...
[ "def", "set_structured_value", "(", "subhash", ",", "parts", ",", "value", ")", "return", "if", "subhash", ".", "nil?", "raise", "ArgumentError", ",", "\"Cannot set structured value at #{parts.first.inspect}\"", "unless", "subhash", ".", "is_a?", "(", "Hash", ")", "...
Set a value in the data structure of a structured fact. This is intended to be called recursively. subhash - The Hash, part of the fact, being operated upon parts - The Array to dig in to the hash value - The value to set the ultimate last part to Does not return anything, but modifies 'subhash'
[ "Set", "a", "value", "in", "the", "data", "structure", "of", "a", "structured", "fact", ".", "This", "is", "intended", "to", "be", "called", "recursively", "." ]
0fe4f4bc1de16f41f6ef2eb45eb1d2d687617ce7
https://github.com/github/octofacts/blob/0fe4f4bc1de16f41f6ef2eb45eb1d2d687617ce7/lib/octofacts_updater/fact.rb#L96-L143
train
imathis/clash
lib/clash/diff.rb
Clash.Diff.diff_dirs
def diff_dirs(dir1, dir2) mattching_dir_files(dir1, dir2).each do |file| a = File.join(dir1, file) b = File.join(dir2, file) diff_files(a,b) end end
ruby
def diff_dirs(dir1, dir2) mattching_dir_files(dir1, dir2).each do |file| a = File.join(dir1, file) b = File.join(dir2, file) diff_files(a,b) end end
[ "def", "diff_dirs", "(", "dir1", ",", "dir2", ")", "mattching_dir_files", "(", "dir1", ",", "dir2", ")", ".", "each", "do", "|", "file", "|", "a", "=", "File", ".", "join", "(", "dir1", ",", "file", ")", "b", "=", "File", ".", "join", "(", "dir2"...
Recursively diff common files between dir1 and dir2
[ "Recursively", "diff", "common", "files", "between", "dir1", "and", "dir2" ]
961fe5d7719789afc47486ac2f3b84e9cdcce769
https://github.com/imathis/clash/blob/961fe5d7719789afc47486ac2f3b84e9cdcce769/lib/clash/diff.rb#L39-L45
train
imathis/clash
lib/clash/diff.rb
Clash.Diff.dir_files
def dir_files(dir) Find.find(dir).to_a.reject!{|f| File.directory?(f) } end
ruby
def dir_files(dir) Find.find(dir).to_a.reject!{|f| File.directory?(f) } end
[ "def", "dir_files", "(", "dir", ")", "Find", ".", "find", "(", "dir", ")", ".", "to_a", ".", "reject!", "{", "|", "f", "|", "File", ".", "directory?", "(", "f", ")", "}", "end" ]
Find all files in a given directory
[ "Find", "all", "files", "in", "a", "given", "directory" ]
961fe5d7719789afc47486ac2f3b84e9cdcce769
https://github.com/imathis/clash/blob/961fe5d7719789afc47486ac2f3b84e9cdcce769/lib/clash/diff.rb#L63-L65
train
imathis/clash
lib/clash/diff.rb
Clash.Diff.unique_files
def unique_files(dir, dir_files, common_files) unique = dir_files - common_files if !unique.empty? @test_failures << yellowit("\nMissing from directory #{dir}:\n") unique.each do |f| failure = " - #{f}" failure << "\n" if unique.last == f @test_failures << fai...
ruby
def unique_files(dir, dir_files, common_files) unique = dir_files - common_files if !unique.empty? @test_failures << yellowit("\nMissing from directory #{dir}:\n") unique.each do |f| failure = " - #{f}" failure << "\n" if unique.last == f @test_failures << fai...
[ "def", "unique_files", "(", "dir", ",", "dir_files", ",", "common_files", ")", "unique", "=", "dir_files", "-", "common_files", "if", "!", "unique", ".", "empty?", "@test_failures", "<<", "yellowit", "(", "\"\\nMissing from directory #{dir}:\\n\"", ")", "unique", ...
Find files which aren't common to both directories
[ "Find", "files", "which", "aren", "t", "common", "to", "both", "directories" ]
961fe5d7719789afc47486ac2f3b84e9cdcce769
https://github.com/imathis/clash/blob/961fe5d7719789afc47486ac2f3b84e9cdcce769/lib/clash/diff.rb#L69-L79
train
github/octofacts
lib/octofacts_updater/fixture.rb
OctofactsUpdater.Fixture.to_yaml
def to_yaml sorted_facts = @facts.sort.to_h facts_hash_with_expanded_values = Hash[sorted_facts.collect { |k, v| [k, v.value] }] YAML.dump(facts_hash_with_expanded_values) end
ruby
def to_yaml sorted_facts = @facts.sort.to_h facts_hash_with_expanded_values = Hash[sorted_facts.collect { |k, v| [k, v.value] }] YAML.dump(facts_hash_with_expanded_values) end
[ "def", "to_yaml", "sorted_facts", "=", "@facts", ".", "sort", ".", "to_h", "facts_hash_with_expanded_values", "=", "Hash", "[", "sorted_facts", ".", "collect", "{", "|", "k", ",", "v", "|", "[", "k", ",", "v", ".", "value", "]", "}", "]", "YAML", ".", ...
YAML representation of the fact fixture. Returns a String containing the YAML representation of the fact fixture.
[ "YAML", "representation", "of", "the", "fact", "fixture", "." ]
0fe4f4bc1de16f41f6ef2eb45eb1d2d687617ce7
https://github.com/github/octofacts/blob/0fe4f4bc1de16f41f6ef2eb45eb1d2d687617ce7/lib/octofacts_updater/fixture.rb#L130-L134
train
slon1024/linear-regression
lib/linear-regression/base.rb
Regression.Base.covariance2
def covariance2(xs, ys) raise "Length xs and ys must be equal" unless xs.length == ys.length ev_x, ev_y = mean(xs), mean(ys) xs.zip(ys) .map{|x,y| (x-ev_x) * (y-ev_y)} .inject(0) {|sum, x| sum += x} / xs.length end
ruby
def covariance2(xs, ys) raise "Length xs and ys must be equal" unless xs.length == ys.length ev_x, ev_y = mean(xs), mean(ys) xs.zip(ys) .map{|x,y| (x-ev_x) * (y-ev_y)} .inject(0) {|sum, x| sum += x} / xs.length end
[ "def", "covariance2", "(", "xs", ",", "ys", ")", "raise", "\"Length xs and ys must be equal\"", "unless", "xs", ".", "length", "==", "ys", ".", "length", "ev_x", ",", "ev_y", "=", "mean", "(", "xs", ")", ",", "mean", "(", "ys", ")", "xs", ".", "zip", ...
Another way to implement covariance
[ "Another", "way", "to", "implement", "covariance" ]
cc6cb1adf36bf7fc66286c1c6de1b850737bdd03
https://github.com/slon1024/linear-regression/blob/cc6cb1adf36bf7fc66286c1c6de1b850737bdd03/lib/linear-regression/base.rb#L21-L28
train
tkrajina/geoelevations
lib/geoelevation.rb
GeoElevation.Srtm.get_file_name
def get_file_name(latitude, longitude) north_south = latitude >= 0 ? 'N' : 'S' east_west = longitude >= 0 ? 'E' : 'W' lat = latitude.floor.to_i.abs.to_s.rjust(2, '0') lon = longitude.floor.to_i.abs.to_s.rjust(3, '0') "#{north_south}#{lat}#{east_west}#{lon}.h...
ruby
def get_file_name(latitude, longitude) north_south = latitude >= 0 ? 'N' : 'S' east_west = longitude >= 0 ? 'E' : 'W' lat = latitude.floor.to_i.abs.to_s.rjust(2, '0') lon = longitude.floor.to_i.abs.to_s.rjust(3, '0') "#{north_south}#{lat}#{east_west}#{lon}.h...
[ "def", "get_file_name", "(", "latitude", ",", "longitude", ")", "north_south", "=", "latitude", ">=", "0", "?", "'N'", ":", "'S'", "east_west", "=", "longitude", ">=", "0", "?", "'E'", ":", "'W'", "lat", "=", "latitude", ".", "floor", ".", "to_i", ".",...
Return the file name no matter if the actual SRTM file exists.
[ "Return", "the", "file", "name", "no", "matter", "if", "the", "actual", "SRTM", "file", "exists", "." ]
2225da9108e651bfd9857ba010cb5c401b56b22a
https://github.com/tkrajina/geoelevations/blob/2225da9108e651bfd9857ba010cb5c401b56b22a/lib/geoelevation.rb#L81-L89
train
tkrajina/geoelevations
lib/geoelevation.rb
GeoElevation.SrtmFile.get_elevation
def get_elevation(latitude, longitude) if ! (@latitude <= latitude && latitude < @latitude + 1) raise "Invalid latitude #{latitude} for file #{@file_name}" end if ! (@longitude <= longitude && longitude < @longitude + 1) raise "Invalid longitude #{long...
ruby
def get_elevation(latitude, longitude) if ! (@latitude <= latitude && latitude < @latitude + 1) raise "Invalid latitude #{latitude} for file #{@file_name}" end if ! (@longitude <= longitude && longitude < @longitude + 1) raise "Invalid longitude #{long...
[ "def", "get_elevation", "(", "latitude", ",", "longitude", ")", "if", "!", "(", "@latitude", "<=", "latitude", "&&", "latitude", "<", "@latitude", "+", "1", ")", "raise", "\"Invalid latitude #{latitude} for file #{@file_name}\"", "end", "if", "!", "(", "@longitude...
If approximate is True then only the points from SRTM grid will be used, otherwise a basic aproximation of nearby points will be calculated.
[ "If", "approximate", "is", "True", "then", "only", "the", "points", "from", "SRTM", "grid", "will", "be", "used", "otherwise", "a", "basic", "aproximation", "of", "nearby", "points", "will", "be", "calculated", "." ]
2225da9108e651bfd9857ba010cb5c401b56b22a
https://github.com/tkrajina/geoelevations/blob/2225da9108e651bfd9857ba010cb5c401b56b22a/lib/geoelevation.rb#L128-L141
train
tkrajina/geoelevations
lib/geoelevation.rb
GeoElevation.Undulations.get_value_at_file_position
def get_value_at_file_position(position) @file.seek(4 + position * 4) bytes = @file.read(4) begin value = bytes[0].ord * 256**0 + bytes[1].ord * 256**1 + bytes[2].ord * 256**2 + bytes[3].ord * 256**3 result = unpack(value) rescue ...
ruby
def get_value_at_file_position(position) @file.seek(4 + position * 4) bytes = @file.read(4) begin value = bytes[0].ord * 256**0 + bytes[1].ord * 256**1 + bytes[2].ord * 256**2 + bytes[3].ord * 256**3 result = unpack(value) rescue ...
[ "def", "get_value_at_file_position", "(", "position", ")", "@file", ".", "seek", "(", "4", "+", "position", "*", "4", ")", "bytes", "=", "@file", ".", "read", "(", "4", ")", "begin", "value", "=", "bytes", "[", "0", "]", ".", "ord", "*", "256", "**...
Loads a value from the n-th position in the EGM file. Every position is a 4-byte real number.
[ "Loads", "a", "value", "from", "the", "n", "-", "th", "position", "in", "the", "EGM", "file", ".", "Every", "position", "is", "a", "4", "-", "byte", "real", "number", "." ]
2225da9108e651bfd9857ba010cb5c401b56b22a
https://github.com/tkrajina/geoelevations/blob/2225da9108e651bfd9857ba010cb5c401b56b22a/lib/geoelevation.rb#L214-L226
train
tkrajina/geoelevations
lib/geoelevation.rb
GeoElevation.Undulations.unpack
def unpack(n) sign = n >> 31 exponent = (n >> (32 - 9)) & 0b11111111 value = n & 0b11111111111111111111111 resul = nil if 1 <= exponent and exponent <= 254 result = (-1)**sign * (1 + value * 2**(-23)) * 2**(exponent - 127) elsif ex...
ruby
def unpack(n) sign = n >> 31 exponent = (n >> (32 - 9)) & 0b11111111 value = n & 0b11111111111111111111111 resul = nil if 1 <= exponent and exponent <= 254 result = (-1)**sign * (1 + value * 2**(-23)) * 2**(exponent - 127) elsif ex...
[ "def", "unpack", "(", "n", ")", "sign", "=", "n", ">>", "31", "exponent", "=", "(", "n", ">>", "(", "32", "-", "9", ")", ")", "&", "0b11111111", "value", "=", "n", "&", "0b11111111111111111111111", "resul", "=", "nil", "if", "1", "<=", "exponent", ...
Unpacks a number from the EGM file
[ "Unpacks", "a", "number", "from", "the", "EGM", "file" ]
2225da9108e651bfd9857ba010cb5c401b56b22a
https://github.com/tkrajina/geoelevations/blob/2225da9108e651bfd9857ba010cb5c401b56b22a/lib/geoelevation.rb#L229-L245
train
bdwyertech/chef-rundeck2
lib/chef-rundeck/state.rb
ChefRunDeck.State.add_state
def add_state(node, user, params) # => Create a Node-State Object (n = {}) && (n[:name] = node) n[:created] = DateTime.now n[:creator] = user n[:type] = params['type'] if params['type'] # => Build the Updated State update_state(n) # => Return the Added Node find_sta...
ruby
def add_state(node, user, params) # => Create a Node-State Object (n = {}) && (n[:name] = node) n[:created] = DateTime.now n[:creator] = user n[:type] = params['type'] if params['type'] # => Build the Updated State update_state(n) # => Return the Added Node find_sta...
[ "def", "add_state", "(", "node", ",", "user", ",", "params", ")", "(", "n", "=", "{", "}", ")", "&&", "(", "n", "[", ":name", "]", "=", "node", ")", "n", "[", ":created", "]", "=", "DateTime", ".", "now", "n", "[", ":creator", "]", "=", "user...
=> Add Node to the State
[ "=", ">", "Add", "Node", "to", "the", "State" ]
5c67fa2a2f4cd01716a0859dd4b900e740dfc8f7
https://github.com/bdwyertech/chef-rundeck2/blob/5c67fa2a2f4cd01716a0859dd4b900e740dfc8f7/lib/chef-rundeck/state.rb#L52-L62
train
bdwyertech/chef-rundeck2
lib/chef-rundeck/state.rb
ChefRunDeck.State.delete_state
def delete_state(node) # => Find the Node existing = find_state(node) return 'Node not present in state' unless existing # => Delete the Node from State state.delete(existing) # => Write Out the Updated State write_state # => Return the Deleted Node existing end
ruby
def delete_state(node) # => Find the Node existing = find_state(node) return 'Node not present in state' unless existing # => Delete the Node from State state.delete(existing) # => Write Out the Updated State write_state # => Return the Deleted Node existing end
[ "def", "delete_state", "(", "node", ")", "existing", "=", "find_state", "(", "node", ")", "return", "'Node not present in state'", "unless", "existing", "state", ".", "delete", "(", "existing", ")", "write_state", "existing", "end" ]
=> Remove Node from the State
[ "=", ">", "Remove", "Node", "from", "the", "State" ]
5c67fa2a2f4cd01716a0859dd4b900e740dfc8f7
https://github.com/bdwyertech/chef-rundeck2/blob/5c67fa2a2f4cd01716a0859dd4b900e740dfc8f7/lib/chef-rundeck/state.rb#L65-L75
train
r7kamura/somemoji
lib/somemoji/emoji_collection.rb
Somemoji.EmojiCollection.replace_character
def replace_character(string, &block) string.gsub(character_pattern) do |character| block.call(find_by_character(character), character) end end
ruby
def replace_character(string, &block) string.gsub(character_pattern) do |character| block.call(find_by_character(character), character) end end
[ "def", "replace_character", "(", "string", ",", "&", "block", ")", "string", ".", "gsub", "(", "character_pattern", ")", "do", "|", "character", "|", "block", ".", "call", "(", "find_by_character", "(", "character", ")", ",", "character", ")", "end", "end"...
Replaces emoji characters in a given string with a given block result @param string [String] a string that to be replaced @return [String] a replaced result @example Somemoji.emoji_collection.replace_character("I ❤ Emoji") do |emoji| %(<img alt="#{emoji.character}" class="emoji" src="/images/emoji/#{emoji.ba...
[ "Replaces", "emoji", "characters", "in", "a", "given", "string", "with", "a", "given", "block", "result" ]
43563493df49e92a2c6d59671d04d1fc20849cc9
https://github.com/r7kamura/somemoji/blob/43563493df49e92a2c6d59671d04d1fc20849cc9/lib/somemoji/emoji_collection.rb#L109-L113
train
r7kamura/somemoji
lib/somemoji/emoji_collection.rb
Somemoji.EmojiCollection.replace_code
def replace_code(string, &block) string.gsub(code_pattern) do |matched_string| block.call(find_by_code(::Regexp.last_match(1)), matched_string) end end
ruby
def replace_code(string, &block) string.gsub(code_pattern) do |matched_string| block.call(find_by_code(::Regexp.last_match(1)), matched_string) end end
[ "def", "replace_code", "(", "string", ",", "&", "block", ")", "string", ".", "gsub", "(", "code_pattern", ")", "do", "|", "matched_string", "|", "block", ".", "call", "(", "find_by_code", "(", "::", "Regexp", ".", "last_match", "(", "1", ")", ")", ",",...
Replaces emoji codes in a given string with a given block result @param string [String] a string that to be replaced @return [String] a replaced result @example Somemoji.emoji_collection.replace_code("I :heart: Emoji") do |emoji| %(<img alt="#{emoji.character}" class="emoji" src="/images/emoji/#{emoji.base_p...
[ "Replaces", "emoji", "codes", "in", "a", "given", "string", "with", "a", "given", "block", "result" ]
43563493df49e92a2c6d59671d04d1fc20849cc9
https://github.com/r7kamura/somemoji/blob/43563493df49e92a2c6d59671d04d1fc20849cc9/lib/somemoji/emoji_collection.rb#L123-L127
train
r7kamura/somemoji
lib/somemoji/emoji_collection.rb
Somemoji.EmojiCollection.search_by_code
def search_by_code(pattern) self.class.new( select do |emoji| pattern === emoji.code || emoji.aliases.any? do |alias_code| pattern === alias_code end end ) end
ruby
def search_by_code(pattern) self.class.new( select do |emoji| pattern === emoji.code || emoji.aliases.any? do |alias_code| pattern === alias_code end end ) end
[ "def", "search_by_code", "(", "pattern", ")", "self", ".", "class", ".", "new", "(", "select", "do", "|", "emoji", "|", "pattern", "===", "emoji", ".", "code", "||", "emoji", ".", "aliases", ".", "any?", "do", "|", "alias_code", "|", "pattern", "===", ...
Searches emojis that match with given pattern @param pattern [Object] @return [Somemoji::EmojiCollection] @example Somemoji.emoji_collection.search_by_code(/^cus/).map(&:code) #=> ["custard", "customs"]
[ "Searches", "emojis", "that", "match", "with", "given", "pattern" ]
43563493df49e92a2c6d59671d04d1fc20849cc9
https://github.com/r7kamura/somemoji/blob/43563493df49e92a2c6d59671d04d1fc20849cc9/lib/somemoji/emoji_collection.rb#L135-L143
train
phallguy/scorpion
lib/scorpion/hunt.rb
Scorpion.Hunt.inject
def inject( object ) trip.object = object object.send :scorpion_hunt=, self object.injected_attributes.each do |attr| next if object.send "#{ attr.name }?" next if attr.lazy? object.send :inject_dependency, attr, fetch( attr.contract ) end object.send :on_injecte...
ruby
def inject( object ) trip.object = object object.send :scorpion_hunt=, self object.injected_attributes.each do |attr| next if object.send "#{ attr.name }?" next if attr.lazy? object.send :inject_dependency, attr, fetch( attr.contract ) end object.send :on_injecte...
[ "def", "inject", "(", "object", ")", "trip", ".", "object", "=", "object", "object", ".", "send", ":scorpion_hunt=", ",", "self", "object", ".", "injected_attributes", ".", "each", "do", "|", "attr", "|", "next", "if", "object", ".", "send", "\"#{ attr.nam...
Inject given `object` with its expected dependencies. @param [Scorpion::Object] object to be injected. @return [Scorpion::Object] the injected object.
[ "Inject", "given", "object", "with", "its", "expected", "dependencies", "." ]
0bc9c1111a37e35991d48543dec88a36f16d7aee
https://github.com/phallguy/scorpion/blob/0bc9c1111a37e35991d48543dec88a36f16d7aee/lib/scorpion/hunt.rb#L80-L94
train
phallguy/scorpion
lib/scorpion/attribute_set.rb
Scorpion.AttributeSet.define_attribute
def define_attribute( name, contract, **options ) attributes[name.to_sym] = Attribute.new name, contract, options end
ruby
def define_attribute( name, contract, **options ) attributes[name.to_sym] = Attribute.new name, contract, options end
[ "def", "define_attribute", "(", "name", ",", "contract", ",", "**", "options", ")", "attributes", "[", "name", ".", "to_sym", "]", "=", "Attribute", ".", "new", "name", ",", "contract", ",", "options", "end" ]
Define a single attribute with the given name that expects food that will satisfy the contract. @param [String] name of the attribute. @param [Class,Module,Symbol] contract that describes the desired behavior of the injected object. @return [Attribute] the attribute that was created.
[ "Define", "a", "single", "attribute", "with", "the", "given", "name", "that", "expects", "food", "that", "will", "satisfy", "the", "contract", "." ]
0bc9c1111a37e35991d48543dec88a36f16d7aee
https://github.com/phallguy/scorpion/blob/0bc9c1111a37e35991d48543dec88a36f16d7aee/lib/scorpion/attribute_set.rb#L78-L80
train
rvm/pluginator
lib/plugins/pluginator/extensions/plugins_map.rb
Pluginator::Extensions.PluginsMap.plugins_map
def plugins_map(type) @plugins_map ||= {} type = type.to_s @plugins_map[type] ||= Hash[ @plugins[type].map do |plugin| [class2name(plugin), plugin] end ] end
ruby
def plugins_map(type) @plugins_map ||= {} type = type.to_s @plugins_map[type] ||= Hash[ @plugins[type].map do |plugin| [class2name(plugin), plugin] end ] end
[ "def", "plugins_map", "(", "type", ")", "@plugins_map", "||=", "{", "}", "type", "=", "type", ".", "to_s", "@plugins_map", "[", "type", "]", "||=", "Hash", "[", "@plugins", "[", "type", "]", ".", "map", "do", "|", "plugin", "|", "[", "class2name", "(...
provide extra map of plugins with symbolized names as keys @param type [String] name of type to generate the map for @return [Hash] map of the names and plugin classes
[ "provide", "extra", "map", "of", "plugins", "with", "symbolized", "names", "as", "keys" ]
e205d0e69334e3789f48f20c6c4d4f9b3fdaaf2f
https://github.com/rvm/pluginator/blob/e205d0e69334e3789f48f20c6c4d4f9b3fdaaf2f/lib/plugins/pluginator/extensions/plugins_map.rb#L32-L40
train
grossvogel/websocket-gui
lib/websocket-gui/base.rb
WebsocketGui.Base.run!
def run!(runtime_config = {}) @websocket_config.merge! runtime_config EM.run do if @websocket_config[:tick_interval] EM.add_periodic_timer(@websocket_config[:tick_interval]) do socket_trigger(:on_tick, @socket_connected) end end EventMachine::WebSocket.run(host: @websocket_config[:so...
ruby
def run!(runtime_config = {}) @websocket_config.merge! runtime_config EM.run do if @websocket_config[:tick_interval] EM.add_periodic_timer(@websocket_config[:tick_interval]) do socket_trigger(:on_tick, @socket_connected) end end EventMachine::WebSocket.run(host: @websocket_config[:so...
[ "def", "run!", "(", "runtime_config", "=", "{", "}", ")", "@websocket_config", ".", "merge!", "runtime_config", "EM", ".", "run", "do", "if", "@websocket_config", "[", ":tick_interval", "]", "EM", ".", "add_periodic_timer", "(", "@websocket_config", "[", ":tick_...
start the socket server and the web server, and launch a browser to fetch the view from the web server
[ "start", "the", "socket", "server", "and", "the", "web", "server", "and", "launch", "a", "browser", "to", "fetch", "the", "view", "from", "the", "web", "server" ]
20f4f3f95312ea357c4afafbd1af4509d6fac1a1
https://github.com/grossvogel/websocket-gui/blob/20f4f3f95312ea357c4afafbd1af4509d6fac1a1/lib/websocket-gui/base.rb#L30-L63
train
rvm/pluginator
lib/plugins/pluginator/extensions/first_class.rb
Pluginator::Extensions.FirstClass.first_class!
def first_class!(type, klass) @plugins[type] or raise Pluginator::MissingType.new(type, @plugins.keys) klass = string2class(klass) plugins_map(type)[klass] or raise Pluginator::MissingPlugin.new(type, klass, plugins_map(type).keys) end
ruby
def first_class!(type, klass) @plugins[type] or raise Pluginator::MissingType.new(type, @plugins.keys) klass = string2class(klass) plugins_map(type)[klass] or raise Pluginator::MissingPlugin.new(type, klass, plugins_map(type).keys) end
[ "def", "first_class!", "(", "type", ",", "klass", ")", "@plugins", "[", "type", "]", "or", "raise", "Pluginator", "::", "MissingType", ".", "new", "(", "type", ",", "@plugins", ".", "keys", ")", "klass", "=", "string2class", "(", "klass", ")", "plugins_m...
Find first plugin whose class matches the given name. Behaves like `first_class` but throws exceptions if can not find anything. @param type [String] name of type to search for plugins @param klass [Symbol|String] name of the searched class @return [Class] The first plugin that matches the klass @raise [Plug...
[ "Find", "first", "plugin", "whose", "class", "matches", "the", "given", "name", ".", "Behaves", "like", "first_class", "but", "throws", "exceptions", "if", "can", "not", "find", "anything", "." ]
e205d0e69334e3789f48f20c6c4d4f9b3fdaaf2f
https://github.com/rvm/pluginator/blob/e205d0e69334e3789f48f20c6c4d4f9b3fdaaf2f/lib/plugins/pluginator/extensions/first_class.rb#L45-L50
train
8x8Cloud/zerigodns
lib/zerigodns/resource.rb
ZerigoDNS::Resource.ClassMethods.process_response
def process_response response without_root = response.body.values.first case when without_root.is_a?(Array) then process_array(response, without_root) when without_root.is_a?(Hash) then from_response(response, without_root) else without_root end end
ruby
def process_response response without_root = response.body.values.first case when without_root.is_a?(Array) then process_array(response, without_root) when without_root.is_a?(Hash) then from_response(response, without_root) else without_root end end
[ "def", "process_response", "response", "without_root", "=", "response", ".", "body", ".", "values", ".", "first", "case", "when", "without_root", ".", "is_a?", "(", "Array", ")", "then", "process_array", "(", "response", ",", "without_root", ")", "when", "with...
Removes the root from the response and hands it off to the class to process it Processes an array response by delegating to the includer's self.from_response @param [Faraday::Response] response The response @return [Object] The result of the parsed response.
[ "Removes", "the", "root", "from", "the", "response", "and", "hands", "it", "off", "to", "the", "class", "to", "process", "it", "Processes", "an", "array", "response", "by", "delegating", "to", "the", "includer", "s", "self", ".", "from_response" ]
cd6085851d8fbf9abaf0cc71345f01a30c85d661
https://github.com/8x8Cloud/zerigodns/blob/cd6085851d8fbf9abaf0cc71345f01a30c85d661/lib/zerigodns/resource.rb#L10-L17
train
phallguy/scorpion
lib/scorpion/object.rb
Scorpion.Object.inject_from
def inject_from( dependencies, overwrite = false ) injected_attributes.each do |attr| next unless dependencies.key? attr.name if overwrite || !send( "#{ attr.name }?" ) send( "#{ attr.name }=", dependencies[ attr.name ] ) end end dependencies end
ruby
def inject_from( dependencies, overwrite = false ) injected_attributes.each do |attr| next unless dependencies.key? attr.name if overwrite || !send( "#{ attr.name }?" ) send( "#{ attr.name }=", dependencies[ attr.name ] ) end end dependencies end
[ "def", "inject_from", "(", "dependencies", ",", "overwrite", "=", "false", ")", "injected_attributes", ".", "each", "do", "|", "attr", "|", "next", "unless", "dependencies", ".", "key?", "attr", ".", "name", "if", "overwrite", "||", "!", "send", "(", "\"#{...
Feed dependencies from a hash into their associated attributes. @param [Hash] dependencies hash describing attributes to inject. @param [Boolean] overwrite existing attributes with values in in the hash.
[ "Feed", "dependencies", "from", "a", "hash", "into", "their", "associated", "attributes", "." ]
0bc9c1111a37e35991d48543dec88a36f16d7aee
https://github.com/phallguy/scorpion/blob/0bc9c1111a37e35991d48543dec88a36f16d7aee/lib/scorpion/object.rb#L84-L94
train
phallguy/scorpion
lib/scorpion/object.rb
Scorpion.Object.inject_from!
def inject_from!( dependencies, overwrite = false ) injected_attributes.each do |attr| next unless dependencies.key? attr.name val = dependencies.delete( attr.name ) if overwrite || !send( "#{ attr.name }?" ) send( "#{ attr.name }=", val ) end end ...
ruby
def inject_from!( dependencies, overwrite = false ) injected_attributes.each do |attr| next unless dependencies.key? attr.name val = dependencies.delete( attr.name ) if overwrite || !send( "#{ attr.name }?" ) send( "#{ attr.name }=", val ) end end ...
[ "def", "inject_from!", "(", "dependencies", ",", "overwrite", "=", "false", ")", "injected_attributes", ".", "each", "do", "|", "attr", "|", "next", "unless", "dependencies", ".", "key?", "attr", ".", "name", "val", "=", "dependencies", ".", "delete", "(", ...
Injects dependenices from the hash and removes them from the hash. @see #inject_from
[ "Injects", "dependenices", "from", "the", "hash", "and", "removes", "them", "from", "the", "hash", "." ]
0bc9c1111a37e35991d48543dec88a36f16d7aee
https://github.com/phallguy/scorpion/blob/0bc9c1111a37e35991d48543dec88a36f16d7aee/lib/scorpion/object.rb#L98-L109
train
8x8Cloud/zerigodns
lib/zerigodns/resource/attributes.rb
ZerigoDNS::Resource::Attributes.InstanceMethods.method_missing
def method_missing mtd, *args if mtd.to_s.chars.to_a.last == '=' raise ArgumentError, "Invalid number of arguments (#{args.length} for 1)" if args.length != 1 attributes[mtd.to_s.slice(0,mtd.to_s.length-1)] = args.first else raise ArgumentError, "Invalid number of arguments (#{args.l...
ruby
def method_missing mtd, *args if mtd.to_s.chars.to_a.last == '=' raise ArgumentError, "Invalid number of arguments (#{args.length} for 1)" if args.length != 1 attributes[mtd.to_s.slice(0,mtd.to_s.length-1)] = args.first else raise ArgumentError, "Invalid number of arguments (#{args.l...
[ "def", "method_missing", "mtd", ",", "*", "args", "if", "mtd", ".", "to_s", ".", "chars", ".", "to_a", ".", "last", "==", "'='", "raise", "ArgumentError", ",", "\"Invalid number of arguments (#{args.length} for 1)\"", "if", "args", ".", "length", "!=", "1", "a...
Allows method-style access to the attributes.
[ "Allows", "method", "-", "style", "access", "to", "the", "attributes", "." ]
cd6085851d8fbf9abaf0cc71345f01a30c85d661
https://github.com/8x8Cloud/zerigodns/blob/cd6085851d8fbf9abaf0cc71345f01a30c85d661/lib/zerigodns/resource/attributes.rb#L10-L18
train
notnyt/beaglebone
lib/beaglebone/ain.rb
Beaglebone.AINPin.run_on_change
def run_on_change(callback, mv_change=10, interval=0.01, repeats=nil) AIN::run_on_change(callback, @pin, mv_change, interval, repeats) end
ruby
def run_on_change(callback, mv_change=10, interval=0.01, repeats=nil) AIN::run_on_change(callback, @pin, mv_change, interval, repeats) end
[ "def", "run_on_change", "(", "callback", ",", "mv_change", "=", "10", ",", "interval", "=", "0.01", ",", "repeats", "=", "nil", ")", "AIN", "::", "run_on_change", "(", "callback", ",", "@pin", ",", "mv_change", ",", "interval", ",", "repeats", ")", "end"...
Runs a callback after voltage changes by specified amount. This creates a new thread that runs in the background and polls at specified interval. @param callback A method to call when the change is detected This method should take 4 arguments: the pin, the previous voltage, the current voltage, and the counter @pa...
[ "Runs", "a", "callback", "after", "voltage", "changes", "by", "specified", "amount", ".", "This", "creates", "a", "new", "thread", "that", "runs", "in", "the", "background", "and", "polls", "at", "specified", "interval", "." ]
7caa8f19f017e4a3d489ce8a2e8526c2e36905d5
https://github.com/notnyt/beaglebone/blob/7caa8f19f017e4a3d489ce8a2e8526c2e36905d5/lib/beaglebone/ain.rb#L391-L393
train
notnyt/beaglebone
lib/beaglebone/ain.rb
Beaglebone.AINPin.run_on_threshold
def run_on_threshold(callback, mv_lower, mv_upper, mv_reset=10, interval=0.01, repeats=nil) AIN::run_on_threshold(callback, @pin, mv_lower, mv_upper, mv_reset, interval, repeats) end
ruby
def run_on_threshold(callback, mv_lower, mv_upper, mv_reset=10, interval=0.01, repeats=nil) AIN::run_on_threshold(callback, @pin, mv_lower, mv_upper, mv_reset, interval, repeats) end
[ "def", "run_on_threshold", "(", "callback", ",", "mv_lower", ",", "mv_upper", ",", "mv_reset", "=", "10", ",", "interval", "=", "0.01", ",", "repeats", "=", "nil", ")", "AIN", "::", "run_on_threshold", "(", "callback", ",", "@pin", ",", "mv_lower", ",", ...
Runs a callback after voltage changes beyond a certain threshold. This creates a new thread that runs in the background and polls at specified interval. When the voltage crosses the specified thresholds the callback is run. @param callback A method to call when the change is detected. This method should take 6 argu...
[ "Runs", "a", "callback", "after", "voltage", "changes", "beyond", "a", "certain", "threshold", ".", "This", "creates", "a", "new", "thread", "that", "runs", "in", "the", "background", "and", "polls", "at", "specified", "interval", ".", "When", "the", "voltag...
7caa8f19f017e4a3d489ce8a2e8526c2e36905d5
https://github.com/notnyt/beaglebone/blob/7caa8f19f017e4a3d489ce8a2e8526c2e36905d5/lib/beaglebone/ain.rb#L421-L423
train
notnyt/beaglebone
lib/beaglebone/ain.rb
Beaglebone.AINPin.run_once_on_threshold
def run_once_on_threshold(callback, mv_lower, mv_upper, mv_reset=10, interval=0.01) AIN::run_once_on_threshold(callback, @pin, mv_lower, mv_upper, mv_reset, interval) end
ruby
def run_once_on_threshold(callback, mv_lower, mv_upper, mv_reset=10, interval=0.01) AIN::run_once_on_threshold(callback, @pin, mv_lower, mv_upper, mv_reset, interval) end
[ "def", "run_once_on_threshold", "(", "callback", ",", "mv_lower", ",", "mv_upper", ",", "mv_reset", "=", "10", ",", "interval", "=", "0.01", ")", "AIN", "::", "run_once_on_threshold", "(", "callback", ",", "@pin", ",", "mv_lower", ",", "mv_upper", ",", "mv_r...
Runs a callback once after voltage crosses a specified threshold. Convenience method for run_on_threshold
[ "Runs", "a", "callback", "once", "after", "voltage", "crosses", "a", "specified", "threshold", ".", "Convenience", "method", "for", "run_on_threshold" ]
7caa8f19f017e4a3d489ce8a2e8526c2e36905d5
https://github.com/notnyt/beaglebone/blob/7caa8f19f017e4a3d489ce8a2e8526c2e36905d5/lib/beaglebone/ain.rb#L428-L430
train
datamapper/dm-validations
lib/data_mapper/validation.rb
DataMapper.Validation.validate
def validate(context_name = default_validation_context) errors.clear validation_violations(context_name).each { |v| errors.add(v) } self end
ruby
def validate(context_name = default_validation_context) errors.clear validation_violations(context_name).each { |v| errors.add(v) } self end
[ "def", "validate", "(", "context_name", "=", "default_validation_context", ")", "errors", ".", "clear", "validation_violations", "(", "context_name", ")", ".", "each", "{", "|", "v", "|", "errors", ".", "add", "(", "v", ")", "}", "self", "end" ]
Command a resource to populate its ViolationSet with any violations of its validation Rules in +context_name+ @api public
[ "Command", "a", "resource", "to", "populate", "its", "ViolationSet", "with", "any", "violations", "of", "its", "validation", "Rules", "in", "+", "context_name", "+" ]
21c8ebde52f70c404c2fc8e10242f8cd92b761fc
https://github.com/datamapper/dm-validations/blob/21c8ebde52f70c404c2fc8e10242f8cd92b761fc/lib/data_mapper/validation.rb#L23-L28
train
rvm/pluginator
lib/pluginator/group.rb
Pluginator.Group.register_plugin
def register_plugin(type, klass) type = type.to_s @plugins[type] ||= [] @plugins[type].push(klass) unless @plugins[type].include?(klass) end
ruby
def register_plugin(type, klass) type = type.to_s @plugins[type] ||= [] @plugins[type].push(klass) unless @plugins[type].include?(klass) end
[ "def", "register_plugin", "(", "type", ",", "klass", ")", "type", "=", "type", ".", "to_s", "@plugins", "[", "type", "]", "||=", "[", "]", "@plugins", "[", "type", "]", ".", "push", "(", "klass", ")", "unless", "@plugins", "[", "type", "]", ".", "i...
Register a new plugin, can be used to load custom plugins @param type [String] type for the klass @param klass [Class] klass of the plugin to add
[ "Register", "a", "new", "plugin", "can", "be", "used", "to", "load", "custom", "plugins" ]
e205d0e69334e3789f48f20c6c4d4f9b3fdaaf2f
https://github.com/rvm/pluginator/blob/e205d0e69334e3789f48f20c6c4d4f9b3fdaaf2f/lib/pluginator/group.rb#L47-L51
train
phallguy/scorpion
lib/scorpion/hunter.rb
Scorpion.Hunter.find_dependency
def find_dependency( hunt ) dependency = dependency_map.find( hunt.contract ) dependency ||= parent.find_dependency( hunt ) if parent dependency end
ruby
def find_dependency( hunt ) dependency = dependency_map.find( hunt.contract ) dependency ||= parent.find_dependency( hunt ) if parent dependency end
[ "def", "find_dependency", "(", "hunt", ")", "dependency", "=", "dependency_map", ".", "find", "(", "hunt", ".", "contract", ")", "dependency", "||=", "parent", ".", "find_dependency", "(", "hunt", ")", "if", "parent", "dependency", "end" ]
Find any explicitly defined dependencies that can satisfy the hunt. @param [Hunt] hunt being resolved. @return [Dependency] the matching dependency if found
[ "Find", "any", "explicitly", "defined", "dependencies", "that", "can", "satisfy", "the", "hunt", "." ]
0bc9c1111a37e35991d48543dec88a36f16d7aee
https://github.com/phallguy/scorpion/blob/0bc9c1111a37e35991d48543dec88a36f16d7aee/lib/scorpion/hunter.rb#L64-L69
train
rvm/pluginator
lib/plugins/pluginator/extensions/first_ask.rb
Pluginator::Extensions.FirstAsk.first_ask!
def first_ask!(type, method_name, *params) @plugins[type] or raise Pluginator::MissingType.new(type, @plugins.keys) try_to_find(type, method_name, params) or raise Pluginator::MissingPlugin.new(type, "first_ask: #{method_name}", plugins_map(type).keys) end
ruby
def first_ask!(type, method_name, *params) @plugins[type] or raise Pluginator::MissingType.new(type, @plugins.keys) try_to_find(type, method_name, params) or raise Pluginator::MissingPlugin.new(type, "first_ask: #{method_name}", plugins_map(type).keys) end
[ "def", "first_ask!", "(", "type", ",", "method_name", ",", "*", "params", ")", "@plugins", "[", "type", "]", "or", "raise", "Pluginator", "::", "MissingType", ".", "new", "(", "type", ",", "@plugins", ".", "keys", ")", "try_to_find", "(", "type", ",", ...
Call a method on plugin and return first one that returns `true`. Behaves like `first_ask` but throws exceptions if can not find anything. @param type [String] name of type to search for plugins @param method_name [Symbol] name of the method to execute @param params [Array] params to pass to the called method @ret...
[ "Call", "a", "method", "on", "plugin", "and", "return", "first", "one", "that", "returns", "true", ".", "Behaves", "like", "first_ask", "but", "throws", "exceptions", "if", "can", "not", "find", "anything", "." ]
e205d0e69334e3789f48f20c6c4d4f9b3fdaaf2f
https://github.com/rvm/pluginator/blob/e205d0e69334e3789f48f20c6c4d4f9b3fdaaf2f/lib/plugins/pluginator/extensions/first_ask.rb#L46-L50
train
notnyt/beaglebone
lib/beaglebone/gpio.rb
Beaglebone.GPIOPin.run_on_edge
def run_on_edge(callback, edge, timeout=nil, repeats=nil) GPIO::run_on_edge(callback, @pin, edge, timeout, repeats) end
ruby
def run_on_edge(callback, edge, timeout=nil, repeats=nil) GPIO::run_on_edge(callback, @pin, edge, timeout, repeats) end
[ "def", "run_on_edge", "(", "callback", ",", "edge", ",", "timeout", "=", "nil", ",", "repeats", "=", "nil", ")", "GPIO", "::", "run_on_edge", "(", "callback", ",", "@pin", ",", "edge", ",", "timeout", ",", "repeats", ")", "end" ]
Runs a callback on an edge trigger event. This creates a new thread that runs in the background @param callback A method to call when the edge trigger is detected. This method should take 3 arguments, the pin, the edge, and the counter @param edge should be a symbol representing the trigger type, e.g. :RISING, :FA...
[ "Runs", "a", "callback", "on", "an", "edge", "trigger", "event", ".", "This", "creates", "a", "new", "thread", "that", "runs", "in", "the", "background" ]
7caa8f19f017e4a3d489ce8a2e8526c2e36905d5
https://github.com/notnyt/beaglebone/blob/7caa8f19f017e4a3d489ce8a2e8526c2e36905d5/lib/beaglebone/gpio.rb#L652-L654
train
8x8Cloud/zerigodns
lib/zerigodns/resource/naming.rb
ZerigoDNS::Resource::Naming.ClassMethods.default_resource_name
def default_resource_name result = self.to_s.split("::").last.gsub(/([A-Z])/, '_\1').downcase result.slice 1, result.length end
ruby
def default_resource_name result = self.to_s.split("::").last.gsub(/([A-Z])/, '_\1').downcase result.slice 1, result.length end
[ "def", "default_resource_name", "result", "=", "self", ".", "to_s", ".", "split", "(", "\"::\"", ")", ".", "last", ".", "gsub", "(", "/", "/", ",", "'_\\1'", ")", ".", "downcase", "result", ".", "slice", "1", ",", "result", ".", "length", "end" ]
Default Resource Name @return [String] generated resource name from class name "e.g. ZerigoDNS::ZoneTemplate -> zone_template"
[ "Default", "Resource", "Name" ]
cd6085851d8fbf9abaf0cc71345f01a30c85d661
https://github.com/8x8Cloud/zerigodns/blob/cd6085851d8fbf9abaf0cc71345f01a30c85d661/lib/zerigodns/resource/naming.rb#L9-L12
train
edmundhighcock/hdf5
lib/hdf5.rb
Hdf5.H5Dataspace.offset_simple
def offset_simple(offsets) raise ArgumentError.new("offsets should have ndims elements") unless offsets.size == ndims basic_offset_simple(@id, offsets.ffi_mem_pointer_hsize_t) end
ruby
def offset_simple(offsets) raise ArgumentError.new("offsets should have ndims elements") unless offsets.size == ndims basic_offset_simple(@id, offsets.ffi_mem_pointer_hsize_t) end
[ "def", "offset_simple", "(", "offsets", ")", "raise", "ArgumentError", ".", "new", "(", "\"offsets should have ndims elements\"", ")", "unless", "offsets", ".", "size", "==", "ndims", "basic_offset_simple", "(", "@id", ",", "offsets", ".", "ffi_mem_pointer_hsize_t", ...
Set the offset of the dataspace. offsets should be an ndims-sized array of zero-based integer offsets.
[ "Set", "the", "offset", "of", "the", "dataspace", ".", "offsets", "should", "be", "an", "ndims", "-", "sized", "array", "of", "zero", "-", "based", "integer", "offsets", "." ]
908e90c249501f1583b1995bf20151a7f9e5fe03
https://github.com/edmundhighcock/hdf5/blob/908e90c249501f1583b1995bf20151a7f9e5fe03/lib/hdf5.rb#L294-L297
train
dblessing/rundeck-ruby
lib/rundeck/request.rb
Rundeck.Request.api_token_header
def api_token_header(options, path = nil) return nil if path == '/j_security_check' unless @api_token fail Error::MissingCredentials, 'Please set a api_token for user' end options[:headers] = {} if options[:headers].nil? options[:headers].merge!('X-Rundeck-Auth-Token' => @api_token...
ruby
def api_token_header(options, path = nil) return nil if path == '/j_security_check' unless @api_token fail Error::MissingCredentials, 'Please set a api_token for user' end options[:headers] = {} if options[:headers].nil? options[:headers].merge!('X-Rundeck-Auth-Token' => @api_token...
[ "def", "api_token_header", "(", "options", ",", "path", "=", "nil", ")", "return", "nil", "if", "path", "==", "'/j_security_check'", "unless", "@api_token", "fail", "Error", "::", "MissingCredentials", ",", "'Please set a api_token for user'", "end", "options", "[",...
Sets a PRIVATE-TOKEN header for requests. @raise [Error::MissingCredentials] if api_token not set.
[ "Sets", "a", "PRIVATE", "-", "TOKEN", "header", "for", "requests", "." ]
4faa9c7ebe59408ed92e91d68bd05cd9e8706dd2
https://github.com/dblessing/rundeck-ruby/blob/4faa9c7ebe59408ed92e91d68bd05cd9e8706dd2/lib/rundeck/request.rb#L70-L77
train
rvm/pluginator
lib/pluginator/name_converter.rb
Pluginator.NameConverter.name2class
def name2class(name) klass = Kernel name.to_s.split(%r{/}).each do |part| klass = klass.const_get( part.capitalize.gsub(/[_-](.)/) { |match| match[1].upcase } ) end klass end
ruby
def name2class(name) klass = Kernel name.to_s.split(%r{/}).each do |part| klass = klass.const_get( part.capitalize.gsub(/[_-](.)/) { |match| match[1].upcase } ) end klass end
[ "def", "name2class", "(", "name", ")", "klass", "=", "Kernel", "name", ".", "to_s", ".", "split", "(", "%r{", "}", ")", ".", "each", "do", "|", "part", "|", "klass", "=", "klass", ".", "const_get", "(", "part", ".", "capitalize", ".", "gsub", "(", ...
full_name => class
[ "full_name", "=", ">", "class" ]
e205d0e69334e3789f48f20c6c4d4f9b3fdaaf2f
https://github.com/rvm/pluginator/blob/e205d0e69334e3789f48f20c6c4d4f9b3fdaaf2f/lib/pluginator/name_converter.rb#L26-L34
train
phallguy/scorpion
lib/scorpion/stinger.rb
Scorpion.Stinger.sting!
def sting!( object ) return object unless scorpion if object assign_scorpion object assign_scorpion_to_enumerable object end object end
ruby
def sting!( object ) return object unless scorpion if object assign_scorpion object assign_scorpion_to_enumerable object end object end
[ "def", "sting!", "(", "object", ")", "return", "object", "unless", "scorpion", "if", "object", "assign_scorpion", "object", "assign_scorpion_to_enumerable", "object", "end", "object", "end" ]
Sting an object so that it will be injected with the scorpion and use it to resolve all dependencies. @param [#scorpion] object to sting. @return [object] the object that was stung.
[ "Sting", "an", "object", "so", "that", "it", "will", "be", "injected", "with", "the", "scorpion", "and", "use", "it", "to", "resolve", "all", "dependencies", "." ]
0bc9c1111a37e35991d48543dec88a36f16d7aee
https://github.com/phallguy/scorpion/blob/0bc9c1111a37e35991d48543dec88a36f16d7aee/lib/scorpion/stinger.rb#L34-L43
train
rvm/pluginator
lib/plugins/pluginator/extensions/matching.rb
Pluginator::Extensions.Matching.matching
def matching(type, list) list.map do |plugin| (plugins_map(type) || {})[string2class(plugin)] end end
ruby
def matching(type, list) list.map do |plugin| (plugins_map(type) || {})[string2class(plugin)] end end
[ "def", "matching", "(", "type", ",", "list", ")", "list", ".", "map", "do", "|", "plugin", "|", "(", "plugins_map", "(", "type", ")", "||", "{", "}", ")", "[", "string2class", "(", "plugin", ")", "]", "end", "end" ]
Map array of names to available plugins. @param type [String] name of type to search for plugins @param list [Array] list of plugin names to load @return [Array] list of loaded plugins
[ "Map", "array", "of", "names", "to", "available", "plugins", "." ]
e205d0e69334e3789f48f20c6c4d4f9b3fdaaf2f
https://github.com/rvm/pluginator/blob/e205d0e69334e3789f48f20c6c4d4f9b3fdaaf2f/lib/plugins/pluginator/extensions/matching.rb#L34-L38
train
rvm/pluginator
lib/plugins/pluginator/extensions/matching.rb
Pluginator::Extensions.Matching.matching!
def matching!(type, list) @plugins[type] or raise Pluginator::MissingType.new(type, @plugins.keys) list.map do |plugin| plugin = string2class(plugin) plugins_map(type)[plugin] or raise Pluginator::MissingPlugin.new(type, plugin, plugins_map(type).keys) end end
ruby
def matching!(type, list) @plugins[type] or raise Pluginator::MissingType.new(type, @plugins.keys) list.map do |plugin| plugin = string2class(plugin) plugins_map(type)[plugin] or raise Pluginator::MissingPlugin.new(type, plugin, plugins_map(type).keys) end end
[ "def", "matching!", "(", "type", ",", "list", ")", "@plugins", "[", "type", "]", "or", "raise", "Pluginator", "::", "MissingType", ".", "new", "(", "type", ",", "@plugins", ".", "keys", ")", "list", ".", "map", "do", "|", "plugin", "|", "plugin", "="...
Map array of names to available plugins. Behaves like `matching` but throws exceptions if can not find anything. @param type [String] name of type to search for plugins @param list [Array] list of plugin names to load @return [Array] list of loaded plugins @raise [Pluginator::MissingPlugin] when can not find...
[ "Map", "array", "of", "names", "to", "available", "plugins", ".", "Behaves", "like", "matching", "but", "throws", "exceptions", "if", "can", "not", "find", "anything", "." ]
e205d0e69334e3789f48f20c6c4d4f9b3fdaaf2f
https://github.com/rvm/pluginator/blob/e205d0e69334e3789f48f20c6c4d4f9b3fdaaf2f/lib/plugins/pluginator/extensions/matching.rb#L46-L53
train
dblessing/rundeck-ruby
lib/rundeck/client.rb
Rundeck.Client.objectify
def objectify(result) if result.is_a?(Hash) ObjectifiedHash.new(result) elsif result.is_a?(Array) result.map { |e| ObjectifiedHash.new(e) } elsif result.nil? nil else fail Error::Parsing, "Couldn't parse a response body" end end
ruby
def objectify(result) if result.is_a?(Hash) ObjectifiedHash.new(result) elsif result.is_a?(Array) result.map { |e| ObjectifiedHash.new(e) } elsif result.nil? nil else fail Error::Parsing, "Couldn't parse a response body" end end
[ "def", "objectify", "(", "result", ")", "if", "result", ".", "is_a?", "(", "Hash", ")", "ObjectifiedHash", ".", "new", "(", "result", ")", "elsif", "result", ".", "is_a?", "(", "Array", ")", "result", ".", "map", "{", "|", "e", "|", "ObjectifiedHash", ...
Turn a hash into an object for easy accessibility. @note This method will objectify nested hashes/arrays. @param [Hash, Array] result An array or hash of results to turn into an object @return [Rundeck::ObjectifiedHash] if +result+ was a hash @return [Rundeck::ObjectifiedHash] if +result+ was an array @raise...
[ "Turn", "a", "hash", "into", "an", "object", "for", "easy", "accessibility", "." ]
4faa9c7ebe59408ed92e91d68bd05cd9e8706dd2
https://github.com/dblessing/rundeck-ruby/blob/4faa9c7ebe59408ed92e91d68bd05cd9e8706dd2/lib/rundeck/client.rb#L70-L80
train
8x8Cloud/zerigodns
lib/zerigodns/resource/rest.rb
ZerigoDNS::Resource::Rest.ClassMethods.convert
def convert object return {resource_name => object} if object.is_a? Hash {resource_name => object.to_hash} end
ruby
def convert object return {resource_name => object} if object.is_a? Hash {resource_name => object.to_hash} end
[ "def", "convert", "object", "return", "{", "resource_name", "=>", "object", "}", "if", "object", ".", "is_a?", "Hash", "{", "resource_name", "=>", "object", ".", "to_hash", "}", "end" ]
Converts a resource object to a hash. @param [Object] object to convert to a hash @raise [ArgumentError] if the object given does not respond to to_hash
[ "Converts", "a", "resource", "object", "to", "a", "hash", "." ]
cd6085851d8fbf9abaf0cc71345f01a30c85d661
https://github.com/8x8Cloud/zerigodns/blob/cd6085851d8fbf9abaf0cc71345f01a30c85d661/lib/zerigodns/resource/rest.rb#L68-L71
train
reqres-api/reqres_rspec
lib/reqres_rspec/collector.rb
ReqresRspec.Collector.sort
def sort self.records.sort! do |x,y| comp = x[:request][:symbolized_path] <=> y[:request][:symbolized_path] comp.zero? ? (x[:title] <=> y[:title]) : comp end end
ruby
def sort self.records.sort! do |x,y| comp = x[:request][:symbolized_path] <=> y[:request][:symbolized_path] comp.zero? ? (x[:title] <=> y[:title]) : comp end end
[ "def", "sort", "self", ".", "records", ".", "sort!", "do", "|", "x", ",", "y", "|", "comp", "=", "x", "[", ":request", "]", "[", ":symbolized_path", "]", "<=>", "y", "[", ":request", "]", "[", ":symbolized_path", "]", "comp", ".", "zero?", "?", "("...
sorts records alphabetically
[ "sorts", "records", "alphabetically" ]
149b67c01e37a2f0cd42c21fdc275ffe6bb9d579
https://github.com/reqres-api/reqres_rspec/blob/149b67c01e37a2f0cd42c21fdc275ffe6bb9d579/lib/reqres_rspec/collector.rb#L146-L151
train
reqres-api/reqres_rspec
lib/reqres_rspec/collector.rb
ReqresRspec.Collector.read_response_headers
def read_response_headers(response) raw_headers = response.headers headers = {} EXCLUDE_RESPONSE_HEADER_PATTERNS.each do |pattern| raw_headers = raw_headers.reject { |h| h if h.starts_with? pattern } end raw_headers.each do |key, val| headers.merge!(cleanup_header(key) => v...
ruby
def read_response_headers(response) raw_headers = response.headers headers = {} EXCLUDE_RESPONSE_HEADER_PATTERNS.each do |pattern| raw_headers = raw_headers.reject { |h| h if h.starts_with? pattern } end raw_headers.each do |key, val| headers.merge!(cleanup_header(key) => v...
[ "def", "read_response_headers", "(", "response", ")", "raw_headers", "=", "response", ".", "headers", "headers", "=", "{", "}", "EXCLUDE_RESPONSE_HEADER_PATTERNS", ".", "each", "do", "|", "pattern", "|", "raw_headers", "=", "raw_headers", ".", "reject", "{", "|"...
read and cleanup response headers returns Hash
[ "read", "and", "cleanup", "response", "headers", "returns", "Hash" ]
149b67c01e37a2f0cd42c21fdc275ffe6bb9d579
https://github.com/reqres-api/reqres_rspec/blob/149b67c01e37a2f0cd42c21fdc275ffe6bb9d579/lib/reqres_rspec/collector.rb#L168-L178
train
reqres-api/reqres_rspec
lib/reqres_rspec/collector.rb
ReqresRspec.Collector.get_symbolized_path
def get_symbolized_path(request) request_path = (request.env['REQUEST_URI'] || request.path).dup request_params = request.env['action_dispatch.request.parameters'] || request.env['rack.request.form_hash'] || request.env['rack.request.query_hash'] if request_params requ...
ruby
def get_symbolized_path(request) request_path = (request.env['REQUEST_URI'] || request.path).dup request_params = request.env['action_dispatch.request.parameters'] || request.env['rack.request.form_hash'] || request.env['rack.request.query_hash'] if request_params requ...
[ "def", "get_symbolized_path", "(", "request", ")", "request_path", "=", "(", "request", ".", "env", "[", "'REQUEST_URI'", "]", "||", "request", ".", "path", ")", ".", "dup", "request_params", "=", "request", ".", "env", "[", "'action_dispatch.request.parameters'...
replace each first occurrence of param's value in the request path Example: request path = /api/users/123 id = 123 symbolized path => /api/users/:id
[ "replace", "each", "first", "occurrence", "of", "param", "s", "value", "in", "the", "request", "path" ]
149b67c01e37a2f0cd42c21fdc275ffe6bb9d579
https://github.com/reqres-api/reqres_rspec/blob/149b67c01e37a2f0cd42c21fdc275ffe6bb9d579/lib/reqres_rspec/collector.rb#L210-L225
train
phallguy/scorpion
lib/scorpion/dependency_map.rb
Scorpion.DependencyMap.capture
def capture( contract, **options, &builder ) active_dependency_set.unshift Dependency::CapturedDependency.new( define_dependency( contract, options, &builder ) ) # rubocop:disable Metrics/LineLength end
ruby
def capture( contract, **options, &builder ) active_dependency_set.unshift Dependency::CapturedDependency.new( define_dependency( contract, options, &builder ) ) # rubocop:disable Metrics/LineLength end
[ "def", "capture", "(", "contract", ",", "**", "options", ",", "&", "builder", ")", "active_dependency_set", ".", "unshift", "Dependency", "::", "CapturedDependency", ".", "new", "(", "define_dependency", "(", "contract", ",", "options", ",", "&", "builder", ")...
Captures a single dependency and returns the same instance fore each request for the resource. @see #hunt_for @return [Dependency] the dependency to be hunted for.
[ "Captures", "a", "single", "dependency", "and", "returns", "the", "same", "instance", "fore", "each", "request", "for", "the", "resource", "." ]
0bc9c1111a37e35991d48543dec88a36f16d7aee
https://github.com/phallguy/scorpion/blob/0bc9c1111a37e35991d48543dec88a36f16d7aee/lib/scorpion/dependency_map.rb#L94-L96
train
phallguy/scorpion
lib/scorpion/dependency_map.rb
Scorpion.DependencyMap.replicate_from
def replicate_from( other_map ) other_map.each do |dependency| if replica = dependency.replicate dependency_set << replica end end self end
ruby
def replicate_from( other_map ) other_map.each do |dependency| if replica = dependency.replicate dependency_set << replica end end self end
[ "def", "replicate_from", "(", "other_map", ")", "other_map", ".", "each", "do", "|", "dependency", "|", "if", "replica", "=", "dependency", ".", "replicate", "dependency_set", "<<", "replica", "end", "end", "self", "end" ]
Replicates the dependency in `other_map` into this map. @param [Scorpion::DependencyMap] other_map to replicate from. @return [self]
[ "Replicates", "the", "dependency", "in", "other_map", "into", "this", "map", "." ]
0bc9c1111a37e35991d48543dec88a36f16d7aee
https://github.com/phallguy/scorpion/blob/0bc9c1111a37e35991d48543dec88a36f16d7aee/lib/scorpion/dependency_map.rb#L118-L126
train
notnyt/beaglebone
lib/beaglebone/spi.rb
Beaglebone.SPIDevice.xfer
def xfer(tx_data, readbytes=0, speed=nil, delay=nil, bpw=nil) SPI::xfer(@spi, tx_data, readbytes, speed, delay, bpw) end
ruby
def xfer(tx_data, readbytes=0, speed=nil, delay=nil, bpw=nil) SPI::xfer(@spi, tx_data, readbytes, speed, delay, bpw) end
[ "def", "xfer", "(", "tx_data", ",", "readbytes", "=", "0", ",", "speed", "=", "nil", ",", "delay", "=", "nil", ",", "bpw", "=", "nil", ")", "SPI", "::", "xfer", "(", "@spi", ",", "tx_data", ",", "readbytes", ",", "speed", ",", "delay", ",", "bpw"...
Initialize an SPI device. Returns an SPIDevice object @param spi should be a symbol representing the SPI device @param mode optional, default 0, specifies the SPI mode :SPI_MODE_0 through 3 @param speed optional, specifies the SPI communication speed @param bpw optional, specifies the bits per word @example ...
[ "Initialize", "an", "SPI", "device", ".", "Returns", "an", "SPIDevice", "object" ]
7caa8f19f017e4a3d489ce8a2e8526c2e36905d5
https://github.com/notnyt/beaglebone/blob/7caa8f19f017e4a3d489ce8a2e8526c2e36905d5/lib/beaglebone/spi.rb#L423-L425
train
dblessing/rundeck-ruby
lib/rundeck/configuration.rb
Rundeck.Configuration.options
def options VALID_OPTIONS_KEYS.reduce({}) do |option, key| option.merge!(key => send(key)) end end
ruby
def options VALID_OPTIONS_KEYS.reduce({}) do |option, key| option.merge!(key => send(key)) end end
[ "def", "options", "VALID_OPTIONS_KEYS", ".", "reduce", "(", "{", "}", ")", "do", "|", "option", ",", "key", "|", "option", ".", "merge!", "(", "key", "=>", "send", "(", "key", ")", ")", "end", "end" ]
Creates a hash of options and their values.
[ "Creates", "a", "hash", "of", "options", "and", "their", "values", "." ]
4faa9c7ebe59408ed92e91d68bd05cd9e8706dd2
https://github.com/dblessing/rundeck-ruby/blob/4faa9c7ebe59408ed92e91d68bd05cd9e8706dd2/lib/rundeck/configuration.rb#L25-L29
train
messagemedia/messages-ruby-sdk
lib/message_media_messages/controllers/replies_controller.rb
MessageMediaMessages.RepliesController.check_replies
def check_replies # Prepare query url. _path_url = '/v1/replies' _query_builder = Configuration.base_uri.dup _query_builder << _path_url _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json' } ...
ruby
def check_replies # Prepare query url. _path_url = '/v1/replies' _query_builder = Configuration.base_uri.dup _query_builder << _path_url _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json' } ...
[ "def", "check_replies", "_path_url", "=", "'/v1/replies'", "_query_builder", "=", "Configuration", ".", "base_uri", ".", "dup", "_query_builder", "<<", "_path_url", "_query_url", "=", "APIHelper", ".", "clean_url", "_query_builder", "_headers", "=", "{", "'accept'", ...
Check for any replies that have been received. Replies are messages that have been sent from a handset in response to a message sent by an application or messages that have been sent from a handset to a inbound number associated with an account, known as a dedicated inbound number (contact <support@messagemedia.c...
[ "Check", "for", "any", "replies", "that", "have", "been", "received", ".", "Replies", "are", "messages", "that", "have", "been", "sent", "from", "a", "handset", "in", "response", "to", "a", "message", "sent", "by", "an", "application", "or", "messages", "t...
073f1f7ca5e4ff3df51b8eeafeaae2167ec6f311
https://github.com/messagemedia/messages-ruby-sdk/blob/073f1f7ca5e4ff3df51b8eeafeaae2167ec6f311/lib/message_media_messages/controllers/replies_controller.rb#L102-L126
train
gupta-ankit/fitgem_oauth2
lib/fitgem_oauth2/heartrate.rb
FitgemOauth2.Client.heartrate_time_series
def heartrate_time_series(start_date: nil, end_date: nil, period: nil) warn '[DEPRECATION] `heartrate_time_series` is deprecated. Please use `hr_series_for_date_range` or `hr_series_for_period` instead.' regular_time_series_guard( start_date: start_date, end_date: end_date, period:...
ruby
def heartrate_time_series(start_date: nil, end_date: nil, period: nil) warn '[DEPRECATION] `heartrate_time_series` is deprecated. Please use `hr_series_for_date_range` or `hr_series_for_period` instead.' regular_time_series_guard( start_date: start_date, end_date: end_date, period:...
[ "def", "heartrate_time_series", "(", "start_date", ":", "nil", ",", "end_date", ":", "nil", ",", "period", ":", "nil", ")", "warn", "'[DEPRECATION] `heartrate_time_series` is deprecated. Please use `hr_series_for_date_range` or `hr_series_for_period` instead.'", "regular_time_seri...
retrieve heartrate time series
[ "retrieve", "heartrate", "time", "series" ]
10caf154d351dcef54442d9092c445cd388ad09e
https://github.com/gupta-ankit/fitgem_oauth2/blob/10caf154d351dcef54442d9092c445cd388ad09e/lib/fitgem_oauth2/heartrate.rb#L24-L38
train
gupta-ankit/fitgem_oauth2
lib/fitgem_oauth2/heartrate.rb
FitgemOauth2.Client.intraday_heartrate_time_series
def intraday_heartrate_time_series(start_date: nil, end_date: nil, detail_level: nil, start_time: nil, end_time: nil) intraday_series_guard( start_date: start_date, end_date: end_date, detail_level: detail_level, start_time: start_time, end_time: end_time ) end...
ruby
def intraday_heartrate_time_series(start_date: nil, end_date: nil, detail_level: nil, start_time: nil, end_time: nil) intraday_series_guard( start_date: start_date, end_date: end_date, detail_level: detail_level, start_time: start_time, end_time: end_time ) end...
[ "def", "intraday_heartrate_time_series", "(", "start_date", ":", "nil", ",", "end_date", ":", "nil", ",", "detail_level", ":", "nil", ",", "start_time", ":", "nil", ",", "end_time", ":", "nil", ")", "intraday_series_guard", "(", "start_date", ":", "start_date", ...
retrieve intraday series for heartrate
[ "retrieve", "intraday", "series", "for", "heartrate" ]
10caf154d351dcef54442d9092c445cd388ad09e
https://github.com/gupta-ankit/fitgem_oauth2/blob/10caf154d351dcef54442d9092c445cd388ad09e/lib/fitgem_oauth2/heartrate.rb#L41-L59
train
messagemedia/messages-ruby-sdk
lib/message_media_messages/http/faraday_client.rb
MessageMediaMessages.FaradayClient.execute_as_string
def execute_as_string(http_request) response = @connection.send( http_request.http_method.downcase, http_request.query_url ) do |request| request.headers = http_request.headers unless http_request.parameters.empty? request.body = http_request.parameters ...
ruby
def execute_as_string(http_request) response = @connection.send( http_request.http_method.downcase, http_request.query_url ) do |request| request.headers = http_request.headers unless http_request.parameters.empty? request.body = http_request.parameters ...
[ "def", "execute_as_string", "(", "http_request", ")", "response", "=", "@connection", ".", "send", "(", "http_request", ".", "http_method", ".", "downcase", ",", "http_request", ".", "query_url", ")", "do", "|", "request", "|", "request", ".", "headers", "=", ...
The constructor. Method overridden from HttpClient.
[ "The", "constructor", ".", "Method", "overridden", "from", "HttpClient", "." ]
073f1f7ca5e4ff3df51b8eeafeaae2167ec6f311
https://github.com/messagemedia/messages-ruby-sdk/blob/073f1f7ca5e4ff3df51b8eeafeaae2167ec6f311/lib/message_media_messages/http/faraday_client.rb#L30-L41
train