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
gnumarcelo/campaigning
lib/campaigning/list.rb
Campaigning.List.get_all_active_subscribers
def get_all_active_subscribers find_active_subscribers(DateTime.new(y=1911,m=1,d=01, h=01,min=00,s=00)) end
ruby
def get_all_active_subscribers find_active_subscribers(DateTime.new(y=1911,m=1,d=01, h=01,min=00,s=00)) end
[ "def", "get_all_active_subscribers", "find_active_subscribers", "(", "DateTime", ".", "new", "(", "y", "=", "1911", ",", "m", "=", "1", ",", "d", "=", "01", ",", "h", "=", "01", ",", "min", "=", "00", ",", "s", "=", "00", ")", ")", "end" ]
Gets a list of all active subscribers for a list. *Return*: *Success*: Upon a successful call, this method will return a collection of Campaigning::Subscriber objects. *Error*: An Exception containing the cause of the error will be raised.
[ "Gets", "a", "list", "of", "all", "active", "subscribers", "for", "a", "list", "." ]
f3d7da053b65cfa376269533183919dc890964fd
https://github.com/gnumarcelo/campaigning/blob/f3d7da053b65cfa376269533183919dc890964fd/lib/campaigning/list.rb#L180-L182
train
r7kamura/plz
lib/plz/command_builder.rb
Plz.CommandBuilder.base_url_from_schema
def base_url_from_schema json_schema.links.find do |link| if link.href && link.rel == "self" return link.href end end end
ruby
def base_url_from_schema json_schema.links.find do |link| if link.href && link.rel == "self" return link.href end end end
[ "def", "base_url_from_schema", "json_schema", ".", "links", ".", "find", "do", "|", "link", "|", "if", "link", ".", "href", "&&", "link", ".", "rel", "==", "\"self\"", "return", "link", ".", "href", "end", "end", "end" ]
Extracts the base url of the API from JSON Schema @return [String, nil] @example base_url_from_schema #=> "https://api.example.com/"
[ "Extracts", "the", "base", "url", "of", "the", "API", "from", "JSON", "Schema" ]
66aca9f864da21b561d558841ce4c17704eebbfc
https://github.com/r7kamura/plz/blob/66aca9f864da21b561d558841ce4c17704eebbfc/lib/plz/command_builder.rb#L206-L212
train
ViaQ/Relp
lib/relp/relp_protocol.rb
Relp.RelpProtocol.frame_read
def frame_read(socket) begin socket_content = socket.read_nonblock(4096) frame = Hash.new if match = socket_content.match(/(^[0-9]+) ([\S]*) (\d+)([\s\S]*)/) frame[:txnr], frame[:command], frame[:data_length], frame[:message] = match.captures # check_message_length(fram...
ruby
def frame_read(socket) begin socket_content = socket.read_nonblock(4096) frame = Hash.new if match = socket_content.match(/(^[0-9]+) ([\S]*) (\d+)([\s\S]*)/) frame[:txnr], frame[:command], frame[:data_length], frame[:message] = match.captures # check_message_length(fram...
[ "def", "frame_read", "(", "socket", ")", "begin", "socket_content", "=", "socket", ".", "read_nonblock", "(", "4096", ")", "frame", "=", "Hash", ".", "new", "if", "match", "=", "socket_content", ".", "match", "(", "/", "\\S", "\\d", "\\s", "\\S", "/", ...
Read socket and return Relp frame information in hash
[ "Read", "socket", "and", "return", "Relp", "frame", "information", "in", "hash" ]
979bbb757274d84f84c3d00bc459f2b30146c4fe
https://github.com/ViaQ/Relp/blob/979bbb757274d84f84c3d00bc459f2b30146c4fe/lib/relp/relp_protocol.rb#L33-L55
train
ViaQ/Relp
lib/relp/relp_protocol.rb
Relp.RelpProtocol.is_valid_command
def is_valid_command(command) valid_commands = ["open", "close", "rsp", "syslog"] if !valid_commands.include?(command) @logger.error 'Invalid RELP command' raise Relp::InvalidCommand.new('Invalid command') end end
ruby
def is_valid_command(command) valid_commands = ["open", "close", "rsp", "syslog"] if !valid_commands.include?(command) @logger.error 'Invalid RELP command' raise Relp::InvalidCommand.new('Invalid command') end end
[ "def", "is_valid_command", "(", "command", ")", "valid_commands", "=", "[", "\"open\"", ",", "\"close\"", ",", "\"rsp\"", ",", "\"syslog\"", "]", "if", "!", "valid_commands", ".", "include?", "(", "command", ")", "@logger", ".", "error", "'Invalid RELP command'"...
Check if command is one of valid commands if not raise exception
[ "Check", "if", "command", "is", "one", "of", "valid", "commands", "if", "not", "raise", "exception" ]
979bbb757274d84f84c3d00bc459f2b30146c4fe
https://github.com/ViaQ/Relp/blob/979bbb757274d84f84c3d00bc459f2b30146c4fe/lib/relp/relp_protocol.rb#L59-L65
train
benbalter/squad_goals
lib/squad_goals/helpers.rb
SquadGoals.Helpers.client_call
def client_call(method, *args) key = cache_key(method, args) cached = dalli.get(key) return cached if cached response = client.send(method, *args) dalli.set(key, response) response end
ruby
def client_call(method, *args) key = cache_key(method, args) cached = dalli.get(key) return cached if cached response = client.send(method, *args) dalli.set(key, response) response end
[ "def", "client_call", "(", "method", ",", "*", "args", ")", "key", "=", "cache_key", "(", "method", ",", "args", ")", "cached", "=", "dalli", ".", "get", "(", "key", ")", "return", "cached", "if", "cached", "response", "=", "client", ".", "send", "("...
Call octokit, using memcached response, when available
[ "Call", "octokit", "using", "memcached", "response", "when", "available" ]
f3c06e7e45980833ebccacd6b7aaca25c8a216cc
https://github.com/benbalter/squad_goals/blob/f3c06e7e45980833ebccacd6b7aaca25c8a216cc/lib/squad_goals/helpers.rb#L4-L11
train
xijo/helmsman
lib/helmsman/view_helper.rb
Helmsman.ViewHelper.current_state_by_controller
def current_state_by_controller(*given_controller_names, actions: []) if given_controller_names.any? { |name| name == controller_name.to_sym } if actions.present? Array(actions).include?(action_name.to_sym) else true end end end
ruby
def current_state_by_controller(*given_controller_names, actions: []) if given_controller_names.any? { |name| name == controller_name.to_sym } if actions.present? Array(actions).include?(action_name.to_sym) else true end end end
[ "def", "current_state_by_controller", "(", "*", "given_controller_names", ",", "actions", ":", "[", "]", ")", "if", "given_controller_names", ".", "any?", "{", "|", "name", "|", "name", "==", "controller_name", ".", "to_sym", "}", "if", "actions", ".", "presen...
Returns true if one of the given controllers match the actual one. If actions are set they are taken into account.
[ "Returns", "true", "if", "one", "of", "the", "given", "controllers", "match", "the", "actual", "one", ".", "If", "actions", "are", "set", "they", "are", "taken", "into", "account", "." ]
0cf50f298e8fc3c2d90344bf27c007ae2227fa9c
https://github.com/xijo/helmsman/blob/0cf50f298e8fc3c2d90344bf27c007ae2227fa9c/lib/helmsman/view_helper.rb#L5-L13
train
mru2/salesforce_adapter
lib/salesforce_adapter.rb
SalesforceAdapter.Base.call_webservice
def call_webservice(method_name, arguments, schema_url, service_path) # Perform the call to the webservice and returns the result Operations::WebserviceCall.new(@rforce_binding, method_name, arguments, schema_url, service_path).run() end
ruby
def call_webservice(method_name, arguments, schema_url, service_path) # Perform the call to the webservice and returns the result Operations::WebserviceCall.new(@rforce_binding, method_name, arguments, schema_url, service_path).run() end
[ "def", "call_webservice", "(", "method_name", ",", "arguments", ",", "schema_url", ",", "service_path", ")", "# Perform the call to the webservice and returns the result", "Operations", "::", "WebserviceCall", ".", "new", "(", "@rforce_binding", ",", "method_name", ",", "...
Queries a salesforce webservice
[ "Queries", "a", "salesforce", "webservice" ]
5f7ddd0cce6ee5bce5cd60482e5415a11d5593a4
https://github.com/mru2/salesforce_adapter/blob/5f7ddd0cce6ee5bce5cd60482e5415a11d5593a4/lib/salesforce_adapter.rb#L66-L71
train
michaelachrisco/nasa-api-client
lib/nasa/client.rb
NASA.Client.neo_feed
def neo_feed(start_date = Time.now.strftime('%Y-%m-%d'), end_date = (Time.now + 604800).strftime('%Y-%m-%d')) request .neo .rest .v1('feed') .get(:params => { :api_key => @application_id.dup, :start_date => start_date, ...
ruby
def neo_feed(start_date = Time.now.strftime('%Y-%m-%d'), end_date = (Time.now + 604800).strftime('%Y-%m-%d')) request .neo .rest .v1('feed') .get(:params => { :api_key => @application_id.dup, :start_date => start_date, ...
[ "def", "neo_feed", "(", "start_date", "=", "Time", ".", "now", ".", "strftime", "(", "'%Y-%m-%d'", ")", ",", "end_date", "=", "(", "Time", ".", "now", "+", "604800", ")", ".", "strftime", "(", "'%Y-%m-%d'", ")", ")", "request", ".", "neo", ".", "rest...
end_date is 1 week in seconds
[ "end_date", "is", "1", "week", "in", "seconds" ]
768be8a6006207050deca1bc9b039b7349fc969e
https://github.com/michaelachrisco/nasa-api-client/blob/768be8a6006207050deca1bc9b039b7349fc969e/lib/nasa/client.rb#L27-L37
train
blackwinter/nuggets
lib/nuggets/ruby_mixin.rb
Nuggets.RubyMixin.ruby_executable
def ruby_executable @ruby_executable ||= begin dir, name, ext = CONFIG.values_at(*%w[bindir RUBY_INSTALL_NAME EXEEXT]) ::File.join(dir, name + ext).sub(/.*\s.*/m, '"\&"') end end
ruby
def ruby_executable @ruby_executable ||= begin dir, name, ext = CONFIG.values_at(*%w[bindir RUBY_INSTALL_NAME EXEEXT]) ::File.join(dir, name + ext).sub(/.*\s.*/m, '"\&"') end end
[ "def", "ruby_executable", "@ruby_executable", "||=", "begin", "dir", ",", "name", ",", "ext", "=", "CONFIG", ".", "values_at", "(", "%w[", "bindir", "RUBY_INSTALL_NAME", "EXEEXT", "]", ")", "::", "File", ".", "join", "(", "dir", ",", "name", "+", "ext", ...
Returns the full path to the current Ruby interpreter's executable file. This might not be the actual correct command to use for invoking the Ruby interpreter; use ruby_command instead.
[ "Returns", "the", "full", "path", "to", "the", "current", "Ruby", "interpreter", "s", "executable", "file", ".", "This", "might", "not", "be", "the", "actual", "correct", "command", "to", "use", "for", "invoking", "the", "Ruby", "interpreter", ";", "use", ...
2a1d0beb015077b2820851ab190e886d1ad588b8
https://github.com/blackwinter/nuggets/blob/2a1d0beb015077b2820851ab190e886d1ad588b8/lib/nuggets/ruby_mixin.rb#L81-L86
train
blackwinter/nuggets
lib/nuggets/ruby_mixin.rb
Nuggets.RubyMixin.command_for_ruby_tool
def command_for_ruby_tool(name) filename = respond_to?(name) ? send(name) : locate_ruby_tool(name) shebang_command(filename) =~ /ruby/ ? "#{ruby_command} #{filename}" : filename end
ruby
def command_for_ruby_tool(name) filename = respond_to?(name) ? send(name) : locate_ruby_tool(name) shebang_command(filename) =~ /ruby/ ? "#{ruby_command} #{filename}" : filename end
[ "def", "command_for_ruby_tool", "(", "name", ")", "filename", "=", "respond_to?", "(", "name", ")", "?", "send", "(", "name", ")", ":", "locate_ruby_tool", "(", "name", ")", "shebang_command", "(", "filename", ")", "=~", "/", "/", "?", "\"#{ruby_command} #{f...
Returns the correct command string for invoking the +name+ executable that belongs to the current Ruby interpreter. Returns +nil+ if the command is not found. If the command executable is a Ruby program, then we need to run it in the correct Ruby interpreter just in case the command doesn't have the correct sheba...
[ "Returns", "the", "correct", "command", "string", "for", "invoking", "the", "+", "name", "+", "executable", "that", "belongs", "to", "the", "current", "Ruby", "interpreter", ".", "Returns", "+", "nil", "+", "if", "the", "command", "is", "not", "found", "."...
2a1d0beb015077b2820851ab190e886d1ad588b8
https://github.com/blackwinter/nuggets/blob/2a1d0beb015077b2820851ab190e886d1ad588b8/lib/nuggets/ruby_mixin.rb#L122-L125
train
rightscale/right_develop
lib/right_develop/ci/util.rb
RightDevelop::CI.Util.pseudo_java_class_name
def pseudo_java_class_name(name) result = '' name.each_char do |chr| if chr =~ JAVA_CLASS_NAME result << chr elsif chr == JAVA_PACKAGE_SEPARATOR result << JAVE_PACKAGE_SEPARATOR_HOMOGLYPH else chr = chr.unpack('U')[0].to_s(16) result << "&#x#{...
ruby
def pseudo_java_class_name(name) result = '' name.each_char do |chr| if chr =~ JAVA_CLASS_NAME result << chr elsif chr == JAVA_PACKAGE_SEPARATOR result << JAVE_PACKAGE_SEPARATOR_HOMOGLYPH else chr = chr.unpack('U')[0].to_s(16) result << "&#x#{...
[ "def", "pseudo_java_class_name", "(", "name", ")", "result", "=", "''", "name", ".", "each_char", "do", "|", "chr", "|", "if", "chr", "=~", "JAVA_CLASS_NAME", "result", "<<", "chr", "elsif", "chr", "==", "JAVA_PACKAGE_SEPARATOR", "result", "<<", "JAVE_PACKAGE_...
Ruby 1.8-2.1 compatible Make a string suitable for parsing by Jenkins JUnit display plugin by escaping any non-valid Java class name characters as an XML entity. This prevents Jenkins from interpreting "hi1.2" as a package-and-class name. @param [String] name @return [String] string with all non-alphanumerics rep...
[ "Ruby", "1", ".", "8", "-", "2", ".", "1", "compatible", "Make", "a", "string", "suitable", "for", "parsing", "by", "Jenkins", "JUnit", "display", "plugin", "by", "escaping", "any", "non", "-", "valid", "Java", "class", "name", "characters", "as", "an", ...
52527b3c32200b542ed590f6f9a275c76758df0e
https://github.com/rightscale/right_develop/blob/52527b3c32200b542ed590f6f9a275c76758df0e/lib/right_develop/ci/util.rb#L32-L47
train
rightscale/right_develop
lib/right_develop/ci/util.rb
RightDevelop::CI.Util.purify
def purify(untrusted) # First pass: strip bad UTF-8 characters if RUBY_VERSION =~ /^1\.8/ iconv = Iconv.new('UTF-8//IGNORE', 'UTF-8') result = iconv.iconv(untrusted) else result = untrusted.force_encoding(Encoding::BINARY).encode('UTF-8', :undef=>:replace, :replace=>'') e...
ruby
def purify(untrusted) # First pass: strip bad UTF-8 characters if RUBY_VERSION =~ /^1\.8/ iconv = Iconv.new('UTF-8//IGNORE', 'UTF-8') result = iconv.iconv(untrusted) else result = untrusted.force_encoding(Encoding::BINARY).encode('UTF-8', :undef=>:replace, :replace=>'') e...
[ "def", "purify", "(", "untrusted", ")", "# First pass: strip bad UTF-8 characters", "if", "RUBY_VERSION", "=~", "/", "\\.", "/", "iconv", "=", "Iconv", ".", "new", "(", "'UTF-8//IGNORE'", ",", "'UTF-8'", ")", "result", "=", "iconv", ".", "iconv", "(", "untrust...
Strip invalid UTF-8 sequences from a string and entity-escape any character that can't legally appear inside XML CDATA. If test output contains weird data, we could end up generating invalid JUnit XML which will choke Java. Preserve the purity of essence of our precious XML fluids! @return [String] the input with ...
[ "Strip", "invalid", "UTF", "-", "8", "sequences", "from", "a", "string", "and", "entity", "-", "escape", "any", "character", "that", "can", "t", "legally", "appear", "inside", "XML", "CDATA", ".", "If", "test", "output", "contains", "weird", "data", "we", ...
52527b3c32200b542ed590f6f9a275c76758df0e
https://github.com/rightscale/right_develop/blob/52527b3c32200b542ed590f6f9a275c76758df0e/lib/right_develop/ci/util.rb#L56-L69
train
agoragames/oembedr
lib/oembedr/providers.rb
Oembedr.Providers.service_endpoint
def service_endpoint url endpoint = LIST.find do |(pattern, endpoint)| url =~ pattern end endpoint ? endpoint.last : false end
ruby
def service_endpoint url endpoint = LIST.find do |(pattern, endpoint)| url =~ pattern end endpoint ? endpoint.last : false end
[ "def", "service_endpoint", "url", "endpoint", "=", "LIST", ".", "find", "do", "|", "(", "pattern", ",", "endpoint", ")", "|", "url", "=~", "pattern", "end", "endpoint", "?", "endpoint", ".", "last", ":", "false", "end" ]
Locate the correct service endpoint for the given resource URL. @param url [String] a fully-qualified URL to an oembeddable resource @return the url, or false if no known endpoint.
[ "Locate", "the", "correct", "service", "endpoint", "for", "the", "given", "resource", "URL", "." ]
9e453adceaa01c5b07db466e6429a4ebb8bcda03
https://github.com/agoragames/oembedr/blob/9e453adceaa01c5b07db466e6429a4ebb8bcda03/lib/oembedr/providers.rb#L75-L80
train
af83/desi
lib/desi/index_manager.rb
Desi.IndexManager.delete!
def delete!(pattern) warn "You must provide a pattern" and exit if pattern.nil? @outputter.puts "The following indices from host #{@host} are now deleted" if @verbose indices(Regexp.new(pattern)).each do |index| @client.delete("/#{index}") @outputter.puts " * #{index.inspect}" if @ve...
ruby
def delete!(pattern) warn "You must provide a pattern" and exit if pattern.nil? @outputter.puts "The following indices from host #{@host} are now deleted" if @verbose indices(Regexp.new(pattern)).each do |index| @client.delete("/#{index}") @outputter.puts " * #{index.inspect}" if @ve...
[ "def", "delete!", "(", "pattern", ")", "warn", "\"You must provide a pattern\"", "and", "exit", "if", "pattern", ".", "nil?", "@outputter", ".", "puts", "\"The following indices from host #{@host} are now deleted\"", "if", "@verbose", "indices", "(", "Regexp", ".", "new...
Delete all indices matching the specified pattern @param [#to_s] pattern Regexp pattern used to restrict the selection @return [void] @note No confirmation is needed, so beware! @note This method will also output its result on STDOUT if +@verbose+ is true @example Delete all indices whose n...
[ "Delete", "all", "indices", "matching", "the", "specified", "pattern" ]
30c51ce3b484765bd8911baf2fb83a85809cc81c
https://github.com/af83/desi/blob/30c51ce3b484765bd8911baf2fb83a85809cc81c/lib/desi/index_manager.rb#L124-L133
train
af83/desi
lib/desi/index_manager.rb
Desi.IndexManager.close!
def close!(pattern) warn "You must provide a pattern" and exit if pattern.nil? @outputter.puts "The following indices from host #{@host} are now closed" if @verbose indices(Regexp.new(pattern)).each do |index| @client.post("/#{index}/_close") @outputter.puts " * #{index.inspect}" if ...
ruby
def close!(pattern) warn "You must provide a pattern" and exit if pattern.nil? @outputter.puts "The following indices from host #{@host} are now closed" if @verbose indices(Regexp.new(pattern)).each do |index| @client.post("/#{index}/_close") @outputter.puts " * #{index.inspect}" if ...
[ "def", "close!", "(", "pattern", ")", "warn", "\"You must provide a pattern\"", "and", "exit", "if", "pattern", ".", "nil?", "@outputter", ".", "puts", "\"The following indices from host #{@host} are now closed\"", "if", "@verbose", "indices", "(", "Regexp", ".", "new",...
Close all indices matching the specified pattern @param [#to_s] pattern Regexp pattern used to restrict the selection @return [void] @note No confirmation is needed, so beware! @note This method will also output its result on STDOUT if +@verbose+ is true @example Close all indices whose nam...
[ "Close", "all", "indices", "matching", "the", "specified", "pattern" ]
30c51ce3b484765bd8911baf2fb83a85809cc81c
https://github.com/af83/desi/blob/30c51ce3b484765bd8911baf2fb83a85809cc81c/lib/desi/index_manager.rb#L149-L158
train
datacite/toccatore
lib/toccatore/usage_update.rb
Toccatore.UsageUpdate.push_data
def push_data(items, options={}) if items.empty? puts "No works found in the Queue." 0 elsif options[:access_token].blank? puts "An error occured: Access token missing." options[:total] else error_total = 0 Array(items).each do |item| puts item...
ruby
def push_data(items, options={}) if items.empty? puts "No works found in the Queue." 0 elsif options[:access_token].blank? puts "An error occured: Access token missing." options[:total] else error_total = 0 Array(items).each do |item| puts item...
[ "def", "push_data", "(", "items", ",", "options", "=", "{", "}", ")", "if", "items", ".", "empty?", "puts", "\"No works found in the Queue.\"", "0", "elsif", "options", "[", ":access_token", "]", ".", "blank?", "puts", "\"An error occured: Access token missing.\"", ...
method returns number of errors
[ "method", "returns", "number", "of", "errors" ]
2fe36304776d599700c568544982d83c6ad44eac
https://github.com/datacite/toccatore/blob/2fe36304776d599700c568544982d83c6ad44eac/lib/toccatore/usage_update.rb#L70-L86
train
rschultheis/hatt
lib/hatt/configuration.rb
Hatt.Configuration.init_config
def init_config unless instance_variable_defined? :@hatt_configuration @hatt_configuration = TCFG::Base.new # build up some default configuration @hatt_configuration.tcfg_set 'hatt_services', {} @hatt_configuration.tcfg_set 'hatt_globs', DEFAULT_HATT_GLOBS @hatt_configura...
ruby
def init_config unless instance_variable_defined? :@hatt_configuration @hatt_configuration = TCFG::Base.new # build up some default configuration @hatt_configuration.tcfg_set 'hatt_services', {} @hatt_configuration.tcfg_set 'hatt_globs', DEFAULT_HATT_GLOBS @hatt_configura...
[ "def", "init_config", "unless", "instance_variable_defined?", ":@hatt_configuration", "@hatt_configuration", "=", "TCFG", "::", "Base", ".", "new", "# build up some default configuration", "@hatt_configuration", ".", "tcfg_set", "'hatt_services'", ",", "{", "}", "@hatt_config...
ensure the configuration is resolved and ready to use
[ "ensure", "the", "configuration", "is", "resolved", "and", "ready", "to", "use" ]
b1b5cddf2b52d8952e5607a2987d2efb648babaf
https://github.com/rschultheis/hatt/blob/b1b5cddf2b52d8952e5607a2987d2efb648babaf/lib/hatt/configuration.rb#L35-L57
train
birarda/logan
lib/logan/client.rb
Logan.Client.auth=
def auth=(auth_hash) # symbolize the keys new_auth_hash = {} auth_hash.each {|k, v| new_auth_hash[k.to_sym] = v} auth_hash = new_auth_hash if auth_hash.has_key? :access_token # clear the basic_auth, if it's set self.class.default_options.reject!{ |k| k == :basic_auth } ...
ruby
def auth=(auth_hash) # symbolize the keys new_auth_hash = {} auth_hash.each {|k, v| new_auth_hash[k.to_sym] = v} auth_hash = new_auth_hash if auth_hash.has_key? :access_token # clear the basic_auth, if it's set self.class.default_options.reject!{ |k| k == :basic_auth } ...
[ "def", "auth", "=", "(", "auth_hash", ")", "# symbolize the keys", "new_auth_hash", "=", "{", "}", "auth_hash", ".", "each", "{", "|", "k", ",", "v", "|", "new_auth_hash", "[", "k", ".", "to_sym", "]", "=", "v", "}", "auth_hash", "=", "new_auth_hash", ...
Initializes the Logan shared client with information required to communicate with Basecamp @param basecamp_id [String] the Basecamp company ID @param auth_hash [Hash] authorization hash consisting of a username and password combination (:username, :password) or an access_token (:access_token) @param user_agent [Str...
[ "Initializes", "the", "Logan", "shared", "client", "with", "information", "required", "to", "communicate", "with", "Basecamp" ]
c007081c7dbb5b98ef5312db78f84867c6075ab0
https://github.com/birarda/logan/blob/c007081c7dbb5b98ef5312db78f84867c6075ab0/lib/logan/client.rb#L22-L45
train
birarda/logan
lib/logan/client.rb
Logan.Client.project_templates
def project_templates response = self.class.get '/project_templates.json' handle_response(response, Proc.new {|h| Logan::ProjectTemplate.new(h) }) end
ruby
def project_templates response = self.class.get '/project_templates.json' handle_response(response, Proc.new {|h| Logan::ProjectTemplate.new(h) }) end
[ "def", "project_templates", "response", "=", "self", ".", "class", ".", "get", "'/project_templates.json'", "handle_response", "(", "response", ",", "Proc", ".", "new", "{", "|", "h", "|", "Logan", "::", "ProjectTemplate", ".", "new", "(", "h", ")", "}", "...
get project templates from Basecamp API @return [Array<Logan::ProjectTemplate>] array of {Logan::ProjectTemplate} instances
[ "get", "project", "templates", "from", "Basecamp", "API" ]
c007081c7dbb5b98ef5312db78f84867c6075ab0
https://github.com/birarda/logan/blob/c007081c7dbb5b98ef5312db78f84867c6075ab0/lib/logan/client.rb#L61-L64
train
birarda/logan
lib/logan/client.rb
Logan.Client.todolists
def todolists response = self.class.get '/todolists.json' handle_response(response, Proc.new { |h| list = Logan::TodoList.new(h) # grab the project ID for this list from the url list.project_id = list.url.scan( /projects\/(\d+)/).last.first # return the list...
ruby
def todolists response = self.class.get '/todolists.json' handle_response(response, Proc.new { |h| list = Logan::TodoList.new(h) # grab the project ID for this list from the url list.project_id = list.url.scan( /projects\/(\d+)/).last.first # return the list...
[ "def", "todolists", "response", "=", "self", ".", "class", ".", "get", "'/todolists.json'", "handle_response", "(", "response", ",", "Proc", ".", "new", "{", "|", "h", "|", "list", "=", "Logan", "::", "TodoList", ".", "new", "(", "h", ")", "# grab the pr...
get active Todo lists for all projects from Basecamp API @return [Array<Logan::TodoList>] array of {Logan::TodoList} instances
[ "get", "active", "Todo", "lists", "for", "all", "projects", "from", "Basecamp", "API" ]
c007081c7dbb5b98ef5312db78f84867c6075ab0
https://github.com/birarda/logan/blob/c007081c7dbb5b98ef5312db78f84867c6075ab0/lib/logan/client.rb#L69-L82
train
nyk/catflap
lib/catflap/netfilter/writer.rb
NetfilterWriter.Rules.chain
def chain(cmd, chain, p = {}) cmds = { new: '-N', rename: '-E', delete: '-X', flush: '-F', list_rules: '-S', list: '-L', zero: '-Z', policy: '-P' } @buffer << [ 'iptables', option('-t', @table), cmds[cmd], option('-n', p[:numeric]), chain, option(false, p[:rule...
ruby
def chain(cmd, chain, p = {}) cmds = { new: '-N', rename: '-E', delete: '-X', flush: '-F', list_rules: '-S', list: '-L', zero: '-Z', policy: '-P' } @buffer << [ 'iptables', option('-t', @table), cmds[cmd], option('-n', p[:numeric]), chain, option(false, p[:rule...
[ "def", "chain", "(", "cmd", ",", "chain", ",", "p", "=", "{", "}", ")", "cmds", "=", "{", "new", ":", "'-N'", ",", "rename", ":", "'-E'", ",", "delete", ":", "'-X'", ",", "flush", ":", "'-F'", ",", "list_rules", ":", "'-S'", ",", "list", ":", ...
Create, flush and delete chains and other iptable chain operations. @param [Symbol] cmd the operation to perform (:new, :delete, :flush) @param [String] chain name of the chain (e.g. INPUT, CATFLAP-DENY, etc.) @param [Hash] p parameters for specific iptables features. @return self @example Rules.new('nat').chai...
[ "Create", "flush", "and", "delete", "chains", "and", "other", "iptable", "chain", "operations", "." ]
e146e5df6d8d0085c127bf3ab77bfecfa9af78d9
https://github.com/nyk/catflap/blob/e146e5df6d8d0085c127bf3ab77bfecfa9af78d9/lib/catflap/netfilter/writer.rb#L44-L57
train
bilus/akasha
lib/akasha/changeset.rb
Akasha.Changeset.append
def append(event_name, **data) id = SecureRandom.uuid event = Akasha::Event.new(event_name, id, { aggregate_id: aggregate_id }, **data) @aggregate.apply_events([event]) @events << event end
ruby
def append(event_name, **data) id = SecureRandom.uuid event = Akasha::Event.new(event_name, id, { aggregate_id: aggregate_id }, **data) @aggregate.apply_events([event]) @events << event end
[ "def", "append", "(", "event_name", ",", "**", "data", ")", "id", "=", "SecureRandom", ".", "uuid", "event", "=", "Akasha", "::", "Event", ".", "new", "(", "event_name", ",", "id", ",", "{", "aggregate_id", ":", "aggregate_id", "}", ",", "**", "data", ...
Adds an event to the changeset.
[ "Adds", "an", "event", "to", "the", "changeset", "." ]
5fadefc249f520ae909b762956ac23a6f916b021
https://github.com/bilus/akasha/blob/5fadefc249f520ae909b762956ac23a6f916b021/lib/akasha/changeset.rb#L17-L22
train
chetan/bixby-client
lib/bixby-client/client.rb
Bixby.Client.exec_api
def exec_api(json_req) begin req = sign_request(json_req) return HttpChannel.new(api_uri).execute(req) rescue Curl::Err::CurlError => ex return JsonResponse.new("fail", ex.message) end end
ruby
def exec_api(json_req) begin req = sign_request(json_req) return HttpChannel.new(api_uri).execute(req) rescue Curl::Err::CurlError => ex return JsonResponse.new("fail", ex.message) end end
[ "def", "exec_api", "(", "json_req", ")", "begin", "req", "=", "sign_request", "(", "json_req", ")", "return", "HttpChannel", ".", "new", "(", "api_uri", ")", ".", "execute", "(", "req", ")", "rescue", "Curl", "::", "Err", "::", "CurlError", "=>", "ex", ...
Execute the given API request on the manager @param [JsonRequest] json_req @return [JsonResponse]
[ "Execute", "the", "given", "API", "request", "on", "the", "manager" ]
5444c2fb154fddef53459dd5cebe08b3f091d252
https://github.com/chetan/bixby-client/blob/5444c2fb154fddef53459dd5cebe08b3f091d252/lib/bixby-client/client.rb#L46-L53
train
asaaki/sjekksum
lib/sjekksum/luhn.rb
Sjekksum.Luhn.of
def of number raise_on_type_mismatch number digits = convert_number_to_digits(number) sum = digits.reverse.map.with_index do |digit, idx| idx.even? ? (digit * 2).divmod(10).reduce(&:+) : digit end.reduce(&:+) (10 - sum % 10) % 10 end
ruby
def of number raise_on_type_mismatch number digits = convert_number_to_digits(number) sum = digits.reverse.map.with_index do |digit, idx| idx.even? ? (digit * 2).divmod(10).reduce(&:+) : digit end.reduce(&:+) (10 - sum % 10) % 10 end
[ "def", "of", "number", "raise_on_type_mismatch", "number", "digits", "=", "convert_number_to_digits", "(", "number", ")", "sum", "=", "digits", ".", "reverse", ".", "map", ".", "with_index", "do", "|", "digit", ",", "idx", "|", "idx", ".", "even?", "?", "(...
Calculates Luhn checksum @example Sjekksum::Luhn.of(7992739871) #=> 3 @param number [Integer, String] number for which the checksum should be calculated @return [Integer] calculated checksum
[ "Calculates", "Luhn", "checksum" ]
47a21c19dcffc67a3bef11d4f2de7c167fd20087
https://github.com/asaaki/sjekksum/blob/47a21c19dcffc67a3bef11d4f2de7c167fd20087/lib/sjekksum/luhn.rb#L20-L29
train
sgillesp/taxonomite
lib/taxonomite/taxonomy.rb
Taxonomite.Taxonomy.valid_parent_types
def valid_parent_types(child) # could be a node object, or maybe a string str = child.respond_to?(:entity_type) ? child.entity_type : child self.up_taxonomy[str] end
ruby
def valid_parent_types(child) # could be a node object, or maybe a string str = child.respond_to?(:entity_type) ? child.entity_type : child self.up_taxonomy[str] end
[ "def", "valid_parent_types", "(", "child", ")", "# could be a node object, or maybe a string", "str", "=", "child", ".", "respond_to?", "(", ":entity_type", ")", "?", "child", ".", "entity_type", ":", "child", "self", ".", "up_taxonomy", "[", "str", "]", "end" ]
access the appropriate parent entity_types for a particular child or child entity_type @param [Taxonomy::Node, String] child the child object or entity_type string @return [Array] an array of strings which are the valid parent types for the child
[ "access", "the", "appropriate", "parent", "entity_types", "for", "a", "particular", "child", "or", "child", "entity_type" ]
731b42d0dfa1f52b39d050026f49b2d205407ff8
https://github.com/sgillesp/taxonomite/blob/731b42d0dfa1f52b39d050026f49b2d205407ff8/lib/taxonomite/taxonomy.rb#L56-L60
train
sgillesp/taxonomite
lib/taxonomite/taxonomy.rb
Taxonomite.Taxonomy.valid_child_types
def valid_child_types(parent) # could be a node object, or maybe a string str = parent.respond_to?(:entity_type) ? parent.entity_type : child self.down_taxonomy[str] end
ruby
def valid_child_types(parent) # could be a node object, or maybe a string str = parent.respond_to?(:entity_type) ? parent.entity_type : child self.down_taxonomy[str] end
[ "def", "valid_child_types", "(", "parent", ")", "# could be a node object, or maybe a string", "str", "=", "parent", ".", "respond_to?", "(", ":entity_type", ")", "?", "parent", ".", "entity_type", ":", "child", "self", ".", "down_taxonomy", "[", "str", "]", "end"...
access the appropriate child entity_types for a particular parent or parent entity_type @param [Taxonomy::Node, String] parent the parent object or entity_type string @return [Array] an array of strings which are the valid child types for the child
[ "access", "the", "appropriate", "child", "entity_types", "for", "a", "particular", "parent", "or", "parent", "entity_type" ]
731b42d0dfa1f52b39d050026f49b2d205407ff8
https://github.com/sgillesp/taxonomite/blob/731b42d0dfa1f52b39d050026f49b2d205407ff8/lib/taxonomite/taxonomy.rb#L66-L70
train
thumblemonks/riot-rails
lib/riot/action_controller/context_middleware.rb
RiotRails.ActionControllerMiddleware.nested_handle?
def nested_handle?(context) (handle?(context.description) || nested_handle?(context.parent)) if context.respond_to?(:description) end
ruby
def nested_handle?(context) (handle?(context.description) || nested_handle?(context.parent)) if context.respond_to?(:description) end
[ "def", "nested_handle?", "(", "context", ")", "(", "handle?", "(", "context", ".", "description", ")", "||", "nested_handle?", "(", "context", ".", "parent", ")", ")", "if", "context", ".", "respond_to?", "(", ":description", ")", "end" ]
Walking the description chain looking to see if any of them are serviceable TODO: see if we can't define a method on the context to observe instead of calling action_controller_description? each time
[ "Walking", "the", "description", "chain", "looking", "to", "see", "if", "any", "of", "them", "are", "serviceable" ]
8bb2555d04f7fb67407f7224536e8b32349cede1
https://github.com/thumblemonks/riot-rails/blob/8bb2555d04f7fb67407f7224536e8b32349cede1/lib/riot/action_controller/context_middleware.rb#L19-L21
train
dlangevin/gxapi_rails
lib/gxapi/base.rb
Gxapi.Base.get_variant
def get_variant(identifier, override = nil) # identifier object to handle finding and caching the # experiment identifier = GxApi::ExperimentIdentifier.new(identifier) Celluloid::Future.new do # allows us to override and get back a variant # easily that conforms to the api ...
ruby
def get_variant(identifier, override = nil) # identifier object to handle finding and caching the # experiment identifier = GxApi::ExperimentIdentifier.new(identifier) Celluloid::Future.new do # allows us to override and get back a variant # easily that conforms to the api ...
[ "def", "get_variant", "(", "identifier", ",", "override", "=", "nil", ")", "# identifier object to handle finding and caching the", "# experiment", "identifier", "=", "GxApi", "::", "ExperimentIdentifier", ".", "new", "(", "identifier", ")", "Celluloid", "::", "Future",...
return a variant value by name or id @param identifier [String, Hash] The name of the experiment or a hash with the id of the experiment @param override [String] Override value returned from the experiment @example variant = @gxapi.get_variant("my_experiment") variant.value => # Ostruct.new(experiment_...
[ "return", "a", "variant", "value", "by", "name", "or", "id" ]
21361227f0c70118b38f7fa372a18c0ae7aab810
https://github.com/dlangevin/gxapi_rails/blob/21361227f0c70118b38f7fa372a18c0ae7aab810/lib/gxapi/base.rb#L55-L69
train
dlangevin/gxapi_rails
lib/gxapi/base.rb
Gxapi.Base.get_variant_value
def get_variant_value(identifier) data = Gxapi.with_error_handling do Timeout::timeout(2.0) do Gxapi.cache.fetch(self.cache_key(identifier)) do @interface.get_variant(identifier).to_hash end end end Ostruct.new( data.is_a?(Hash) ? data : self.def...
ruby
def get_variant_value(identifier) data = Gxapi.with_error_handling do Timeout::timeout(2.0) do Gxapi.cache.fetch(self.cache_key(identifier)) do @interface.get_variant(identifier).to_hash end end end Ostruct.new( data.is_a?(Hash) ? data : self.def...
[ "def", "get_variant_value", "(", "identifier", ")", "data", "=", "Gxapi", ".", "with_error_handling", "do", "Timeout", "::", "timeout", "(", "2.0", ")", "do", "Gxapi", ".", "cache", ".", "fetch", "(", "self", ".", "cache_key", "(", "identifier", ")", ")", ...
protected method to make the actual calls to get values from the cache or from Google @param identifier [ExperimentIdentifier] Experiment to look for @return [Gxapi::Ostruct] Experiment data
[ "protected", "method", "to", "make", "the", "actual", "calls", "to", "get", "values", "from", "the", "cache", "or", "from", "Google" ]
21361227f0c70118b38f7fa372a18c0ae7aab810
https://github.com/dlangevin/gxapi_rails/blob/21361227f0c70118b38f7fa372a18c0ae7aab810/lib/gxapi/base.rb#L108-L119
train
thumblemonks/riot-rails
lib/riot/active_record/transactional_middleware.rb
RiotRails.TransactionalMiddleware.hijack_local_run
def hijack_local_run(context) (class << context; self; end).class_eval do alias_method :transactionless_local_run, :local_run def local_run(*args) ::ActiveRecord::Base.transaction do transactionless_local_run(*args) raise ::ActiveRecord::Rollback end ...
ruby
def hijack_local_run(context) (class << context; self; end).class_eval do alias_method :transactionless_local_run, :local_run def local_run(*args) ::ActiveRecord::Base.transaction do transactionless_local_run(*args) raise ::ActiveRecord::Rollback end ...
[ "def", "hijack_local_run", "(", "context", ")", "(", "class", "<<", "context", ";", "self", ";", "end", ")", ".", "class_eval", "do", "alias_method", ":transactionless_local_run", ",", ":local_run", "def", "local_run", "(", "*", "args", ")", "::", "ActiveRecor...
Don't you just love mr. metaclass?
[ "Don", "t", "you", "just", "love", "mr", ".", "metaclass?" ]
8bb2555d04f7fb67407f7224536e8b32349cede1
https://github.com/thumblemonks/riot-rails/blob/8bb2555d04f7fb67407f7224536e8b32349cede1/lib/riot/active_record/transactional_middleware.rb#L15-L25
train
medcat/packed_struct
lib/packed_struct/directive.rb
PackedStruct.Directive.[]
def [](new_size) if new_size.is_a? Directive tags.merge! new_size.tags_for_sized_directive else tags[:size] = new_size end self end
ruby
def [](new_size) if new_size.is_a? Directive tags.merge! new_size.tags_for_sized_directive else tags[:size] = new_size end self end
[ "def", "[]", "(", "new_size", ")", "if", "new_size", ".", "is_a?", "Directive", "tags", ".", "merge!", "new_size", ".", "tags_for_sized_directive", "else", "tags", "[", ":size", "]", "=", "new_size", "end", "self", "end" ]
Changes the size of the directive to the given size. It is possible for the given value to the a directive; if it is, it just uses the name of the directive. @param new_size [Numeric, Directive] @return [self]
[ "Changes", "the", "size", "of", "the", "directive", "to", "the", "given", "size", ".", "It", "is", "possible", "for", "the", "given", "value", "to", "the", "a", "directive", ";", "if", "it", "is", "it", "just", "uses", "the", "name", "of", "the", "di...
4c32c17acbfbe8c1a1a27daafb04d2f6bee0347f
https://github.com/medcat/packed_struct/blob/4c32c17acbfbe8c1a1a27daafb04d2f6bee0347f/lib/packed_struct/directive.rb#L69-L77
train
medcat/packed_struct
lib/packed_struct/directive.rb
PackedStruct.Directive.finalize!
def finalize! return if finalized? modifiers.each do |modifier| modifier.type.each_with_index do |type, i| case type when :endian, :signedness, :precision, :type, :string_type tags[type] = modifier.value[i] when :size tags[:size] = modifier.valu...
ruby
def finalize! return if finalized? modifiers.each do |modifier| modifier.type.each_with_index do |type, i| case type when :endian, :signedness, :precision, :type, :string_type tags[type] = modifier.value[i] when :size tags[:size] = modifier.valu...
[ "def", "finalize!", "return", "if", "finalized?", "modifiers", ".", "each", "do", "|", "modifier", "|", "modifier", ".", "type", ".", "each_with_index", "do", "|", "type", ",", "i", "|", "case", "type", "when", ":endian", ",", ":signedness", ",", ":precisi...
Finalizes the directive. @return [void]
[ "Finalizes", "the", "directive", "." ]
4c32c17acbfbe8c1a1a27daafb04d2f6bee0347f
https://github.com/medcat/packed_struct/blob/4c32c17acbfbe8c1a1a27daafb04d2f6bee0347f/lib/packed_struct/directive.rb#L144-L163
train
medcat/packed_struct
lib/packed_struct/directive.rb
PackedStruct.Directive.bytesize
def bytesize(data = {}) case tags[:type] when nil (size(data) || 8) / 8 when :short, :int, :long BYTES_IN_STRING.fetch tags[:type] when :float if tags[:precision] == :double BYTES_IN_STRING[:float_double] else BYTES_IN_STRING[:float_single] ...
ruby
def bytesize(data = {}) case tags[:type] when nil (size(data) || 8) / 8 when :short, :int, :long BYTES_IN_STRING.fetch tags[:type] when :float if tags[:precision] == :double BYTES_IN_STRING[:float_double] else BYTES_IN_STRING[:float_single] ...
[ "def", "bytesize", "(", "data", "=", "{", "}", ")", "case", "tags", "[", ":type", "]", "when", "nil", "(", "size", "(", "data", ")", "||", "8", ")", "/", "8", "when", ":short", ",", ":int", ",", ":long", "BYTES_IN_STRING", ".", "fetch", "tags", "...
The number of bytes this takes up in the resulting packed string. @param (see #to_s) @return [Numeric]
[ "The", "number", "of", "bytes", "this", "takes", "up", "in", "the", "resulting", "packed", "string", "." ]
4c32c17acbfbe8c1a1a27daafb04d2f6bee0347f
https://github.com/medcat/packed_struct/blob/4c32c17acbfbe8c1a1a27daafb04d2f6bee0347f/lib/packed_struct/directive.rb#L223-L242
train
medcat/packed_struct
lib/packed_struct/directive.rb
PackedStruct.Directive.modify_if_needed
def modify_if_needed(str, include_endian = true) base = if @tags[:signedness] == :signed str.swapcase else str end if include_endian modify_for_endianness(base) else base end end
ruby
def modify_if_needed(str, include_endian = true) base = if @tags[:signedness] == :signed str.swapcase else str end if include_endian modify_for_endianness(base) else base end end
[ "def", "modify_if_needed", "(", "str", ",", "include_endian", "=", "true", ")", "base", "=", "if", "@tags", "[", ":signedness", "]", "==", ":signed", "str", ".", "swapcase", "else", "str", "end", "if", "include_endian", "modify_for_endianness", "(", "base", ...
Modifies the given string if it's needed, according to signness and endianness. This assumes that a signed directive should be in lowercase. @param str [String] the string to modify. @param include_endian [Boolean] whether or not to include the endianness. @return [String]
[ "Modifies", "the", "given", "string", "if", "it", "s", "needed", "according", "to", "signness", "and", "endianness", ".", "This", "assumes", "that", "a", "signed", "directive", "should", "be", "in", "lowercase", "." ]
4c32c17acbfbe8c1a1a27daafb04d2f6bee0347f
https://github.com/medcat/packed_struct/blob/4c32c17acbfbe8c1a1a27daafb04d2f6bee0347f/lib/packed_struct/directive.rb#L339-L350
train
medcat/packed_struct
lib/packed_struct/directive.rb
PackedStruct.Directive.modify_for_endianness
def modify_for_endianness(str, use_case = false) case [tags[:endian], use_case] when [:little, true] str.swapcase when [:little, false] str + "<" when [:big, true] str when [:big, false] str + ">" else str end end
ruby
def modify_for_endianness(str, use_case = false) case [tags[:endian], use_case] when [:little, true] str.swapcase when [:little, false] str + "<" when [:big, true] str when [:big, false] str + ">" else str end end
[ "def", "modify_for_endianness", "(", "str", ",", "use_case", "=", "false", ")", "case", "[", "tags", "[", ":endian", "]", ",", "use_case", "]", "when", "[", ":little", ",", "true", "]", "str", ".", "swapcase", "when", "[", ":little", ",", "false", "]",...
Modifies the given string to account for endianness. If +use_case+ is true, it modifies the case of the given string to represent endianness; otherwise, it appends data to the string to represent endianness. @param str [String] the string to modify. @param use_case [Boolean] @return [String]
[ "Modifies", "the", "given", "string", "to", "account", "for", "endianness", ".", "If", "+", "use_case", "+", "is", "true", "it", "modifies", "the", "case", "of", "the", "given", "string", "to", "represent", "endianness", ";", "otherwise", "it", "appends", ...
4c32c17acbfbe8c1a1a27daafb04d2f6bee0347f
https://github.com/medcat/packed_struct/blob/4c32c17acbfbe8c1a1a27daafb04d2f6bee0347f/lib/packed_struct/directive.rb#L360-L373
train
bdurand/acts_as_trashable
lib/acts_as_trashable/trash_record.rb
ActsAsTrashable.TrashRecord.restore
def restore restore_class = self.trashable_type.constantize sti_type = self.trashable_attributes[restore_class.inheritance_column] if sti_type begin if !restore_class.store_full_sti_class && !sti_type.start_with?("::") sti_type = "#{restore_class.parent.name}::#{sti_...
ruby
def restore restore_class = self.trashable_type.constantize sti_type = self.trashable_attributes[restore_class.inheritance_column] if sti_type begin if !restore_class.store_full_sti_class && !sti_type.start_with?("::") sti_type = "#{restore_class.parent.name}::#{sti_...
[ "def", "restore", "restore_class", "=", "self", ".", "trashable_type", ".", "constantize", "sti_type", "=", "self", ".", "trashable_attributes", "[", "restore_class", ".", "inheritance_column", "]", "if", "sti_type", "begin", "if", "!", "restore_class", ".", "stor...
Create a new trash record for the provided record. Restore a trashed record into an object. The record will not be saved.
[ "Create", "a", "new", "trash", "record", "for", "the", "provided", "record", ".", "Restore", "a", "trashed", "record", "into", "an", "object", ".", "The", "record", "will", "not", "be", "saved", "." ]
8bb0e40d6b30dda9c5175a0deb28da1b067fff03
https://github.com/bdurand/acts_as_trashable/blob/8bb0e40d6b30dda9c5175a0deb28da1b067fff03/lib/acts_as_trashable/trash_record.rb#L56-L84
train
bdurand/acts_as_trashable
lib/acts_as_trashable/trash_record.rb
ActsAsTrashable.TrashRecord.trashable_attributes
def trashable_attributes return nil unless self.data uncompressed = Zlib::Inflate.inflate(self.data) rescue uncompressed = self.data # backward compatibility with uncompressed data Marshal.load(uncompressed) end
ruby
def trashable_attributes return nil unless self.data uncompressed = Zlib::Inflate.inflate(self.data) rescue uncompressed = self.data # backward compatibility with uncompressed data Marshal.load(uncompressed) end
[ "def", "trashable_attributes", "return", "nil", "unless", "self", ".", "data", "uncompressed", "=", "Zlib", "::", "Inflate", ".", "inflate", "(", "self", ".", "data", ")", "rescue", "uncompressed", "=", "self", ".", "data", "# backward compatibility with uncompres...
Attributes of the trashed record as a hash.
[ "Attributes", "of", "the", "trashed", "record", "as", "a", "hash", "." ]
8bb0e40d6b30dda9c5175a0deb28da1b067fff03
https://github.com/bdurand/acts_as_trashable/blob/8bb0e40d6b30dda9c5175a0deb28da1b067fff03/lib/acts_as_trashable/trash_record.rb#L95-L99
train
emancu/ork
lib/ork/model/document.rb
Ork.Document.save
def save __robject.content_type = model.content_type __robject.data = __persist_attributes __check_unique_indices __update_indices __robject.store @id = __robject.key self end
ruby
def save __robject.content_type = model.content_type __robject.data = __persist_attributes __check_unique_indices __update_indices __robject.store @id = __robject.key self end
[ "def", "save", "__robject", ".", "content_type", "=", "model", ".", "content_type", "__robject", ".", "data", "=", "__persist_attributes", "__check_unique_indices", "__update_indices", "__robject", ".", "store", "@id", "=", "__robject", ".", "key", "self", "end" ]
Persist the model attributes and update indices and unique indices. Example: class User include Ork::Document attribute :name end u = User.new(:name => "John").save # => #<User:6kS5VHNbaed9h7gFLnVg5lmO4U7 {:name=>"John"}>
[ "Persist", "the", "model", "attributes", "and", "update", "indices", "and", "unique", "indices", "." ]
83b2deaef0e790d90f98c031f254b5f438b19edf
https://github.com/emancu/ork/blob/83b2deaef0e790d90f98c031f254b5f438b19edf/lib/ork/model/document.rb#L72-L83
train
emancu/ork
lib/ork/model/document.rb
Ork.Document.load!
def load!(id) self.__robject.key = id __load_robject! id, @__robject.reload(force: true) end
ruby
def load!(id) self.__robject.key = id __load_robject! id, @__robject.reload(force: true) end
[ "def", "load!", "(", "id", ")", "self", ".", "__robject", ".", "key", "=", "id", "__load_robject!", "id", ",", "@__robject", ".", "reload", "(", "force", ":", "true", ")", "end" ]
Overwrite attributes with the persisted attributes in Riak.
[ "Overwrite", "attributes", "with", "the", "persisted", "attributes", "in", "Riak", "." ]
83b2deaef0e790d90f98c031f254b5f438b19edf
https://github.com/emancu/ork/blob/83b2deaef0e790d90f98c031f254b5f438b19edf/lib/ork/model/document.rb#L102-L105
train
emancu/ork
lib/ork/model/document.rb
Ork.Document.__update_indices
def __update_indices model.indices.values.each do |index| __robject.indexes[index.riak_name] = index.value_from(attributes) end end
ruby
def __update_indices model.indices.values.each do |index| __robject.indexes[index.riak_name] = index.value_from(attributes) end end
[ "def", "__update_indices", "model", ".", "indices", ".", "values", ".", "each", "do", "|", "index", "|", "__robject", ".", "indexes", "[", "index", ".", "riak_name", "]", "=", "index", ".", "value_from", "(", "attributes", ")", "end", "end" ]
Build the secondary indices of this object
[ "Build", "the", "secondary", "indices", "of", "this", "object" ]
83b2deaef0e790d90f98c031f254b5f438b19edf
https://github.com/emancu/ork/blob/83b2deaef0e790d90f98c031f254b5f438b19edf/lib/ork/model/document.rb#L132-L136
train
emancu/ork
lib/ork/model/document.rb
Ork.Document.__check_unique_indices
def __check_unique_indices model.uniques.each do |uniq| if value = attributes[uniq] index = model.indices[uniq] records = model.bucket.get_index(index.riak_name, value) unless records.empty? || records == [self.id] raise Ork::UniqueIndexViolation, "#{uniq} is not ...
ruby
def __check_unique_indices model.uniques.each do |uniq| if value = attributes[uniq] index = model.indices[uniq] records = model.bucket.get_index(index.riak_name, value) unless records.empty? || records == [self.id] raise Ork::UniqueIndexViolation, "#{uniq} is not ...
[ "def", "__check_unique_indices", "model", ".", "uniques", ".", "each", "do", "|", "uniq", "|", "if", "value", "=", "attributes", "[", "uniq", "]", "index", "=", "model", ".", "indices", "[", "uniq", "]", "records", "=", "model", ".", "bucket", ".", "ge...
Look up into Riak for repeated values on unique attributes
[ "Look", "up", "into", "Riak", "for", "repeated", "values", "on", "unique", "attributes" ]
83b2deaef0e790d90f98c031f254b5f438b19edf
https://github.com/emancu/ork/blob/83b2deaef0e790d90f98c031f254b5f438b19edf/lib/ork/model/document.rb#L139-L149
train
roja/words
lib/wordnet_connectors/tokyo_wordnet_connection.rb
Words.TokyoWordnetConnection.open!
def open! unless connected? if @data_path.exist? @connection = Rufus::Tokyo::Table.new(@data_path.to_s, :mode => 'r') @connected = true else @connected = false raise BadWordnetDataset, "Failed to locate the tokyo words dataset at #{@data_path}. Please insure you have created it using t...
ruby
def open! unless connected? if @data_path.exist? @connection = Rufus::Tokyo::Table.new(@data_path.to_s, :mode => 'r') @connected = true else @connected = false raise BadWordnetDataset, "Failed to locate the tokyo words dataset at #{@data_path}. Please insure you have created it using t...
[ "def", "open!", "unless", "connected?", "if", "@data_path", ".", "exist?", "@connection", "=", "Rufus", "::", "Tokyo", "::", "Table", ".", "new", "(", "@data_path", ".", "to_s", ",", ":mode", "=>", "'r'", ")", "@connected", "=", "true", "else", "@connected...
Constructs a new tokyo ruby connector for use with the words wordnet class. @param [Pathname] data_path Specifies the directory within which constructed datasets can be found (tokyo index, evocations etc...) @param [Pathname] wordnet_path Specifies the directory within which the wordnet dictionary can be found. @re...
[ "Constructs", "a", "new", "tokyo", "ruby", "connector", "for", "use", "with", "the", "words", "wordnet", "class", "." ]
4d6302e7218533fcc2afb4cd993686dd56fe2cde
https://github.com/roja/words/blob/4d6302e7218533fcc2afb4cd993686dd56fe2cde/lib/wordnet_connectors/tokyo_wordnet_connection.rb#L57-L70
train
locks/halibut
lib/halibut/core/resource.rb
Halibut::Core.Resource.set_property
def set_property(property, value) if property == '_links' || property == '_embedded' raise ArgumentError, "Argument #{property} is a reserved property" end tap { @properties[property] = value } end
ruby
def set_property(property, value) if property == '_links' || property == '_embedded' raise ArgumentError, "Argument #{property} is a reserved property" end tap { @properties[property] = value } end
[ "def", "set_property", "(", "property", ",", "value", ")", "if", "property", "==", "'_links'", "||", "property", "==", "'_embedded'", "raise", "ArgumentError", ",", "\"Argument #{property} is a reserved property\"", "end", "tap", "{", "@properties", "[", "property", ...
Sets a property in the resource. @example resource = Halibut::Core::Resource.new resource.set_property :name, 'FooBar' resource.property :name # => "FooBar" @param [Object] property the key @param [Object] value the value
[ "Sets", "a", "property", "in", "the", "resource", "." ]
b8da6aa0796c9db317b9cd3d377915499a52383c
https://github.com/locks/halibut/blob/b8da6aa0796c9db317b9cd3d377915499a52383c/lib/halibut/core/resource.rb#L84-L90
train
locks/halibut
lib/halibut/core/resource.rb
Halibut::Core.Resource.add_link
def add_link(relation, href, opts={}) @links.add relation, Link.new(href, opts) end
ruby
def add_link(relation, href, opts={}) @links.add relation, Link.new(href, opts) end
[ "def", "add_link", "(", "relation", ",", "href", ",", "opts", "=", "{", "}", ")", "@links", ".", "add", "relation", ",", "Link", ".", "new", "(", "href", ",", "opts", ")", "end" ]
Adds link to relation. @example resource = Halibut::Core::Resource.new resource.add_link 'next', '/resource/2', name: 'Foo' link = resource.links['next'].first link.href # => "/resource/2" link.name # => "Foo" @param [String] relation relation @param [String] href ...
[ "Adds", "link", "to", "relation", "." ]
b8da6aa0796c9db317b9cd3d377915499a52383c
https://github.com/locks/halibut/blob/b8da6aa0796c9db317b9cd3d377915499a52383c/lib/halibut/core/resource.rb#L132-L134
train
locks/halibut
lib/halibut/core/resource.rb
Halibut::Core.Resource.to_hash
def to_hash {}.merge(@properties).tap do |h| h['_links'] = {}.merge @links unless @links.empty? combined_embedded = {} combined_embedded.merge! @embedded unless @embedded.empty? combined_embedded.merge! @embedded_arrays unless @embedded_arrays.empty? h['_embedded'] = co...
ruby
def to_hash {}.merge(@properties).tap do |h| h['_links'] = {}.merge @links unless @links.empty? combined_embedded = {} combined_embedded.merge! @embedded unless @embedded.empty? combined_embedded.merge! @embedded_arrays unless @embedded_arrays.empty? h['_embedded'] = co...
[ "def", "to_hash", "{", "}", ".", "merge", "(", "@properties", ")", ".", "tap", "do", "|", "h", "|", "h", "[", "'_links'", "]", "=", "{", "}", ".", "merge", "@links", "unless", "@links", ".", "empty?", "combined_embedded", "=", "{", "}", "combined_emb...
Hash representation of the resource. Will ommit links and embedded keys if they're empty @return [Hash] hash representation of the resource
[ "Hash", "representation", "of", "the", "resource", ".", "Will", "ommit", "links", "and", "embedded", "keys", "if", "they", "re", "empty" ]
b8da6aa0796c9db317b9cd3d377915499a52383c
https://github.com/locks/halibut/blob/b8da6aa0796c9db317b9cd3d377915499a52383c/lib/halibut/core/resource.rb#L161-L170
train
ombulabs/bitpagos
lib/bitpagos/client.rb
Bitpagos.Client.get_transaction_type_from_symbol
def get_transaction_type_from_symbol(transaction_type) begin target_type = transaction_type.to_s.upcase return if target_type.empty? self.class.const_get(target_type) rescue NameError => error raise Bitpagos::Errors::InvalidTransactionType.new(error.message) end end
ruby
def get_transaction_type_from_symbol(transaction_type) begin target_type = transaction_type.to_s.upcase return if target_type.empty? self.class.const_get(target_type) rescue NameError => error raise Bitpagos::Errors::InvalidTransactionType.new(error.message) end end
[ "def", "get_transaction_type_from_symbol", "(", "transaction_type", ")", "begin", "target_type", "=", "transaction_type", ".", "to_s", ".", "upcase", "return", "if", "target_type", ".", "empty?", "self", ".", "class", ".", "const_get", "(", "target_type", ")", "re...
Takes a symbol and returns the proper transaction type. @param [Symbol] Can be :pending, :waiting, :completed or :partially_paid @return [String,nil] Returns the corresponding "PE", "WA", "CO" or "PP"
[ "Takes", "a", "symbol", "and", "returns", "the", "proper", "transaction", "type", "." ]
007fca57437f1e3fc3eff72f3d84f56f49cf64fc
https://github.com/ombulabs/bitpagos/blob/007fca57437f1e3fc3eff72f3d84f56f49cf64fc/lib/bitpagos/client.rb#L69-L77
train
ombulabs/bitpagos
lib/bitpagos/client.rb
Bitpagos.Client.retrieve_transactions
def retrieve_transactions(query = nil, transaction_id = nil) headers.merge!(params: query) if query url = "#{API_BASE}/transaction/#{transaction_id}" begin response = RestClient.get(url, headers) JSON.parse(response) rescue RestClient::Unauthorized => error raise Bitpagos...
ruby
def retrieve_transactions(query = nil, transaction_id = nil) headers.merge!(params: query) if query url = "#{API_BASE}/transaction/#{transaction_id}" begin response = RestClient.get(url, headers) JSON.parse(response) rescue RestClient::Unauthorized => error raise Bitpagos...
[ "def", "retrieve_transactions", "(", "query", "=", "nil", ",", "transaction_id", "=", "nil", ")", "headers", ".", "merge!", "(", "params", ":", "query", ")", "if", "query", "url", "=", "\"#{API_BASE}/transaction/#{transaction_id}\"", "begin", "response", "=", "R...
Hits the Bitpagos transaction API, returns a hash with results @param [String] State (Pending, Waiting, Completed, Partially Paid) @param [String] Transaction ID @return [Hash]
[ "Hits", "the", "Bitpagos", "transaction", "API", "returns", "a", "hash", "with", "results" ]
007fca57437f1e3fc3eff72f3d84f56f49cf64fc
https://github.com/ombulabs/bitpagos/blob/007fca57437f1e3fc3eff72f3d84f56f49cf64fc/lib/bitpagos/client.rb#L84-L93
train
nwops/retrospec
lib/retrospec/plugins.rb
Retrospec.Plugins.discover_plugin
def discover_plugin(module_path) plugin = plugin_classes.find {|c| c.send(:valid_module_dir?, module_path) } raise NoSuitablePluginFoundException unless plugin plugin end
ruby
def discover_plugin(module_path) plugin = plugin_classes.find {|c| c.send(:valid_module_dir?, module_path) } raise NoSuitablePluginFoundException unless plugin plugin end
[ "def", "discover_plugin", "(", "module_path", ")", "plugin", "=", "plugin_classes", ".", "find", "{", "|", "c", "|", "c", ".", "send", "(", ":valid_module_dir?", ",", "module_path", ")", "}", "raise", "NoSuitablePluginFoundException", "unless", "plugin", "plugin...
returns the first plugin class that supports this module directory not sure what to do when we find multiple plugins would need additional criteria
[ "returns", "the", "first", "plugin", "class", "that", "supports", "this", "module", "directory", "not", "sure", "what", "to", "do", "when", "we", "find", "multiple", "plugins", "would", "need", "additional", "criteria" ]
e61a8e8b86384c64a3ce9340d1342fa416740522
https://github.com/nwops/retrospec/blob/e61a8e8b86384c64a3ce9340d1342fa416740522/lib/retrospec/plugins.rb#L38-L42
train
wilson/revenant
lib/revenant/task.rb
Revenant.Task.run
def run(&block) unless @work = block raise ArgumentError, "Usage: run { while_we_have_the_lock }" end @shutdown = false @restart = false install_plugins startup # typically daemonizes the process, can have various implementations on_load.call(self) if on_load run_...
ruby
def run(&block) unless @work = block raise ArgumentError, "Usage: run { while_we_have_the_lock }" end @shutdown = false @restart = false install_plugins startup # typically daemonizes the process, can have various implementations on_load.call(self) if on_load run_...
[ "def", "run", "(", "&", "block", ")", "unless", "@work", "=", "block", "raise", "ArgumentError", ",", "\"Usage: run { while_we_have_the_lock }\"", "end", "@shutdown", "=", "false", "@restart", "=", "false", "install_plugins", "startup", "# typically daemonizes the proce...
Takes actual block of code that is to be guarded by the lock. The +run_loop+ method does the actual work. If 'daemon?' is true, your code (including +on_load+) will execute after a fork. Make sure you don't open files and sockets in the exiting parent process by mistake. Open them in code that is called via +on...
[ "Takes", "actual", "block", "of", "code", "that", "is", "to", "be", "guarded", "by", "the", "lock", ".", "The", "+", "run_loop", "+", "method", "does", "the", "actual", "work", "." ]
80fe65742de54ce0c5a8e6c56cea7003fe286746
https://github.com/wilson/revenant/blob/80fe65742de54ce0c5a8e6c56cea7003fe286746/lib/revenant/task.rb#L48-L60
train
cloudspace/ruby-fleetctl
lib/fleet/cluster.rb
Fleet.Cluster.build_from
def build_from(*ip_addrs) ip_addrs = [*ip_addrs].flatten.compact begin Fleetctl.logger.info 'building from hosts: ' + ip_addrs.inspect built_from = ip_addrs.detect { |ip_addr| fetch_machines(ip_addr) } Fleetctl.logger.info 'built successfully from host: ' + built_from.inspect if buil...
ruby
def build_from(*ip_addrs) ip_addrs = [*ip_addrs].flatten.compact begin Fleetctl.logger.info 'building from hosts: ' + ip_addrs.inspect built_from = ip_addrs.detect { |ip_addr| fetch_machines(ip_addr) } Fleetctl.logger.info 'built successfully from host: ' + built_from.inspect if buil...
[ "def", "build_from", "(", "*", "ip_addrs", ")", "ip_addrs", "=", "[", "ip_addrs", "]", ".", "flatten", ".", "compact", "begin", "Fleetctl", ".", "logger", ".", "info", "'building from hosts: '", "+", "ip_addrs", ".", "inspect", "built_from", "=", "ip_addrs", ...
attempts to rebuild the cluster from any of the hosts passed as arguments returns the first ip that worked, else nil
[ "attempts", "to", "rebuild", "the", "cluster", "from", "any", "of", "the", "hosts", "passed", "as", "arguments", "returns", "the", "first", "ip", "that", "worked", "else", "nil" ]
23c9a71f733d43275fbfaf35c568d4b284f715ab
https://github.com/cloudspace/ruby-fleetctl/blob/23c9a71f733d43275fbfaf35c568d4b284f715ab/lib/fleet/cluster.rb#L25-L38
train
cloudspace/ruby-fleetctl
lib/fleet/cluster.rb
Fleet.Cluster.fetch_machines
def fetch_machines(host) Fleetctl.logger.info 'Fetching machines from host: '+host.inspect clear Fleetctl::Command.new('list-machines', '-l') do |runner| runner.run(host: host) new_machines = parse_machines(runner.output) if runner.exit_code == 0 return true e...
ruby
def fetch_machines(host) Fleetctl.logger.info 'Fetching machines from host: '+host.inspect clear Fleetctl::Command.new('list-machines', '-l') do |runner| runner.run(host: host) new_machines = parse_machines(runner.output) if runner.exit_code == 0 return true e...
[ "def", "fetch_machines", "(", "host", ")", "Fleetctl", ".", "logger", ".", "info", "'Fetching machines from host: '", "+", "host", ".", "inspect", "clear", "Fleetctl", "::", "Command", ".", "new", "(", "'list-machines'", ",", "'-l'", ")", "do", "|", "runner", ...
attempts a list-machines action on the given host. returns true if successful, else false
[ "attempts", "a", "list", "-", "machines", "action", "on", "the", "given", "host", ".", "returns", "true", "if", "successful", "else", "false" ]
23c9a71f733d43275fbfaf35c568d4b284f715ab
https://github.com/cloudspace/ruby-fleetctl/blob/23c9a71f733d43275fbfaf35c568d4b284f715ab/lib/fleet/cluster.rb#L42-L54
train
cloudspace/ruby-fleetctl
lib/fleet/cluster.rb
Fleet.Cluster.discover!
def discover! known_hosts = [Fleetctl.options.fleet_host] | fleet_hosts.to_a clear success_host = build_from(known_hosts) || build_from(Fleet::Discovery.hosts) if success_host Fleetctl.logger.info 'Successfully recovered from host: ' + success_host.inspect else Fleetctl.log...
ruby
def discover! known_hosts = [Fleetctl.options.fleet_host] | fleet_hosts.to_a clear success_host = build_from(known_hosts) || build_from(Fleet::Discovery.hosts) if success_host Fleetctl.logger.info 'Successfully recovered from host: ' + success_host.inspect else Fleetctl.log...
[ "def", "discover!", "known_hosts", "=", "[", "Fleetctl", ".", "options", ".", "fleet_host", "]", "|", "fleet_hosts", ".", "to_a", "clear", "success_host", "=", "build_from", "(", "known_hosts", ")", "||", "build_from", "(", "Fleet", "::", "Discovery", ".", "...
attempts to rebuild the cluster by the specified fleet host, then hosts that it has built previously, and finally by using the discovery url
[ "attempts", "to", "rebuild", "the", "cluster", "by", "the", "specified", "fleet", "host", "then", "hosts", "that", "it", "has", "built", "previously", "and", "finally", "by", "using", "the", "discovery", "url" ]
23c9a71f733d43275fbfaf35c568d4b284f715ab
https://github.com/cloudspace/ruby-fleetctl/blob/23c9a71f733d43275fbfaf35c568d4b284f715ab/lib/fleet/cluster.rb#L67-L76
train
jarhart/rattler
lib/rattler/parsers/token.rb
Rattler::Parsers.Token.parse
def parse(scanner, rules, scope = ParserScope.empty) p = scanner.pos child.parse(scanner, rules, scope) && scanner.string[p...(scanner.pos)] end
ruby
def parse(scanner, rules, scope = ParserScope.empty) p = scanner.pos child.parse(scanner, rules, scope) && scanner.string[p...(scanner.pos)] end
[ "def", "parse", "(", "scanner", ",", "rules", ",", "scope", "=", "ParserScope", ".", "empty", ")", "p", "=", "scanner", ".", "pos", "child", ".", "parse", "(", "scanner", ",", "rules", ",", "scope", ")", "&&", "scanner", ".", "string", "[", "p", "....
If the decorated parser matches return the entire matched string, otherwise return a false value. @param (see Match#parse) @return (see Match#parse)
[ "If", "the", "decorated", "parser", "matches", "return", "the", "entire", "matched", "string", "otherwise", "return", "a", "false", "value", "." ]
8b4efde2a05e9e790955bb635d4a1a9615893719
https://github.com/jarhart/rattler/blob/8b4efde2a05e9e790955bb635d4a1a9615893719/lib/rattler/parsers/token.rb#L15-L18
train
postmodern/rprogram
lib/rprogram/option_list.rb
RProgram.OptionList.method_missing
def method_missing(sym,*args,&block) name = sym.to_s unless block if (name =~ /=$/ && args.length == 1) return self[name.chop.to_sym] = args.first elsif args.empty? return self[sym] end end return super(sym,*args,&block) end
ruby
def method_missing(sym,*args,&block) name = sym.to_s unless block if (name =~ /=$/ && args.length == 1) return self[name.chop.to_sym] = args.first elsif args.empty? return self[sym] end end return super(sym,*args,&block) end
[ "def", "method_missing", "(", "sym", ",", "*", "args", ",", "&", "block", ")", "name", "=", "sym", ".", "to_s", "unless", "block", "if", "(", "name", "=~", "/", "/", "&&", "args", ".", "length", "==", "1", ")", "return", "self", "[", "name", ".",...
Provides transparent access to the options within the option list. @example opt_list = OptionList.new(:name => 'test') opt_list.name # => "test"
[ "Provides", "transparent", "access", "to", "the", "options", "within", "the", "option", "list", "." ]
94c32a72c98c7310d6e6b767b55ea8b8fbf0c0be
https://github.com/postmodern/rprogram/blob/94c32a72c98c7310d6e6b767b55ea8b8fbf0c0be/lib/rprogram/option_list.rb#L24-L36
train
alihuber/http_archive
lib/http_archive/archive.rb
HttpArchive.Archive.get_total_data
def get_total_data size = calc_total_size.to_s load_time = (@pages.first.on_load / 1000.0).to_s [@pages.first.title, @entries.size.to_s, size, load_time] end
ruby
def get_total_data size = calc_total_size.to_s load_time = (@pages.first.on_load / 1000.0).to_s [@pages.first.title, @entries.size.to_s, size, load_time] end
[ "def", "get_total_data", "size", "=", "calc_total_size", ".", "to_s", "load_time", "=", "(", "@pages", ".", "first", ".", "on_load", "/", "1000.0", ")", ".", "to_s", "[", "@pages", ".", "first", ".", "title", ",", "@entries", ".", "size", ".", "to_s", ...
Gets the common data for a page. Convenience method that can be used for bulk reading of page data. @return [Array<page_title, ressource_count, total_download_size, overall_load_time>] An array with page data @example Example of returned Array ["Software is hard", "26", "0.36", "6.745"]
[ "Gets", "the", "common", "data", "for", "a", "page", ".", "Convenience", "method", "that", "can", "be", "used", "for", "bulk", "reading", "of", "page", "data", "." ]
3fc1e1f4e206ea6b4a68b75199bdda662a4e153a
https://github.com/alihuber/http_archive/blob/3fc1e1f4e206ea6b4a68b75199bdda662a4e153a/lib/http_archive/archive.rb#L70-L75
train
alihuber/http_archive
lib/http_archive/archive.rb
HttpArchive.Archive.get_row_data
def get_row_data rows = [] @entries.each do |entry| method = entry.request.http_method # get part after .com/ if any url = entry.request.url if url.end_with?("/") ressource = entry.request.url else r = url.rindex("/") ressource = url[r..-...
ruby
def get_row_data rows = [] @entries.each do |entry| method = entry.request.http_method # get part after .com/ if any url = entry.request.url if url.end_with?("/") ressource = entry.request.url else r = url.rindex("/") ressource = url[r..-...
[ "def", "get_row_data", "rows", "=", "[", "]", "@entries", ".", "each", "do", "|", "entry", "|", "method", "=", "entry", ".", "request", ".", "http_method", "# get part after .com/ if any", "url", "=", "entry", ".", "request", ".", "url", "if", "url", ".", ...
Gets the data for a row for all entries. Convenience method that can be used for bulk reading of entry data. @return [Array<Array<html_method, ressource_name, status_name, status_code, ressource_size, load_duration>>] An array with row data @example Example of returned Array [["GET", "/prototype.js?ver=1.6.1", ...
[ "Gets", "the", "data", "for", "a", "row", "for", "all", "entries", ".", "Convenience", "method", "that", "can", "be", "used", "for", "bulk", "reading", "of", "entry", "data", "." ]
3fc1e1f4e206ea6b4a68b75199bdda662a4e153a
https://github.com/alihuber/http_archive/blob/3fc1e1f4e206ea6b4a68b75199bdda662a4e153a/lib/http_archive/archive.rb#L83-L105
train
jemmyw/bisques
lib/bisques/aws_request.rb
Bisques.AwsRequest.make_request
def make_request create_authorization options = {} options[:header] = authorization.headers.merge( 'Authorization' => authorization.authorization_header ) options[:query] = query if query.any? options[:body] = form_body if body http_response = @httpclient.request(meth...
ruby
def make_request create_authorization options = {} options[:header] = authorization.headers.merge( 'Authorization' => authorization.authorization_header ) options[:query] = query if query.any? options[:body] = form_body if body http_response = @httpclient.request(meth...
[ "def", "make_request", "create_authorization", "options", "=", "{", "}", "options", "[", ":header", "]", "=", "authorization", ".", "headers", ".", "merge", "(", "'Authorization'", "=>", "authorization", ".", "authorization_header", ")", "options", "[", ":query", ...
Send the HTTP request and get a response. Returns an AwsResponse object. The instance is frozen once this method is called and cannot be used again.
[ "Send", "the", "HTTP", "request", "and", "get", "a", "response", ".", "Returns", "an", "AwsResponse", "object", ".", "The", "instance", "is", "frozen", "once", "this", "method", "is", "called", "and", "cannot", "be", "used", "again", "." ]
c48ab555f07664752bcbf9e8deb99bd75cbdc41b
https://github.com/jemmyw/bisques/blob/c48ab555f07664752bcbf9e8deb99bd75cbdc41b/lib/bisques/aws_request.rb#L77-L93
train
jemmyw/bisques
lib/bisques/aws_request.rb
Bisques.AwsRequest.form_body
def form_body if body.is_a?(Hash) body.map do |k,v| [AwsRequest.aws_encode(k), AwsRequest.aws_encode(v)].join("=") end.join("&") else body end end
ruby
def form_body if body.is_a?(Hash) body.map do |k,v| [AwsRequest.aws_encode(k), AwsRequest.aws_encode(v)].join("=") end.join("&") else body end end
[ "def", "form_body", "if", "body", ".", "is_a?", "(", "Hash", ")", "body", ".", "map", "do", "|", "k", ",", "v", "|", "[", "AwsRequest", ".", "aws_encode", "(", "k", ")", ",", "AwsRequest", ".", "aws_encode", "(", "v", ")", "]", ".", "join", "(", ...
Encode the form params if the body is given as a Hash.
[ "Encode", "the", "form", "params", "if", "the", "body", "is", "given", "as", "a", "Hash", "." ]
c48ab555f07664752bcbf9e8deb99bd75cbdc41b
https://github.com/jemmyw/bisques/blob/c48ab555f07664752bcbf9e8deb99bd75cbdc41b/lib/bisques/aws_request.rb#L98-L106
train
jemmyw/bisques
lib/bisques/aws_request.rb
Bisques.AwsRequest.create_authorization
def create_authorization @authorization = AwsRequestAuthorization.new.tap do |authorization| authorization.url = url authorization.method = method authorization.query = query authorization.body = form_body authorization.region = region authorization.service = servic...
ruby
def create_authorization @authorization = AwsRequestAuthorization.new.tap do |authorization| authorization.url = url authorization.method = method authorization.query = query authorization.body = form_body authorization.region = region authorization.service = servic...
[ "def", "create_authorization", "@authorization", "=", "AwsRequestAuthorization", ".", "new", ".", "tap", "do", "|", "authorization", "|", "authorization", ".", "url", "=", "url", "authorization", ".", "method", "=", "method", "authorization", ".", "query", "=", ...
Create the AwsRequestAuthorization object for the request.
[ "Create", "the", "AwsRequestAuthorization", "object", "for", "the", "request", "." ]
c48ab555f07664752bcbf9e8deb99bd75cbdc41b
https://github.com/jemmyw/bisques/blob/c48ab555f07664752bcbf9e8deb99bd75cbdc41b/lib/bisques/aws_request.rb#L109-L120
train
jemmyw/bisques
lib/bisques/queue.rb
Bisques.Queue.retrieve
def retrieve(poll_time = 1) response = client.receive_message(url, {"WaitTimeSeconds" => poll_time, "MaxNumberOfMessages" => 1}) raise QueueNotFound.new(self, "not found at #{url}") if response.http_response.status == 404 response.doc.xpath("//Message").map do |element| attributes = Hash[*ele...
ruby
def retrieve(poll_time = 1) response = client.receive_message(url, {"WaitTimeSeconds" => poll_time, "MaxNumberOfMessages" => 1}) raise QueueNotFound.new(self, "not found at #{url}") if response.http_response.status == 404 response.doc.xpath("//Message").map do |element| attributes = Hash[*ele...
[ "def", "retrieve", "(", "poll_time", "=", "1", ")", "response", "=", "client", ".", "receive_message", "(", "url", ",", "{", "\"WaitTimeSeconds\"", "=>", "poll_time", ",", "\"MaxNumberOfMessages\"", "=>", "1", "}", ")", "raise", "QueueNotFound", ".", "new", ...
Retrieve a message from the queue. Returns nil if no message is waiting in the given poll time. Otherwise it returns a Message. @param [Fixnum] poll_time @return [Message,nil] @raise [AwsActionError]
[ "Retrieve", "a", "message", "from", "the", "queue", ".", "Returns", "nil", "if", "no", "message", "is", "waiting", "in", "the", "given", "poll", "time", ".", "Otherwise", "it", "returns", "a", "Message", "." ]
c48ab555f07664752bcbf9e8deb99bd75cbdc41b
https://github.com/jemmyw/bisques/blob/c48ab555f07664752bcbf9e8deb99bd75cbdc41b/lib/bisques/queue.rb#L142-L157
train
NullVoxPopuli/authorizable
lib/authorizable/proxy.rb
Authorizable.Proxy.process_permission
def process_permission(permission, *args) cached = value_from_cache(permission, *args) if cached.nil? evaluate_permission(permission, *args) else cached end end
ruby
def process_permission(permission, *args) cached = value_from_cache(permission, *args) if cached.nil? evaluate_permission(permission, *args) else cached end end
[ "def", "process_permission", "(", "permission", ",", "*", "args", ")", "cached", "=", "value_from_cache", "(", "permission", ",", "args", ")", "if", "cached", ".", "nil?", "evaluate_permission", "(", "permission", ",", "args", ")", "else", "cached", "end", "...
checks if the permission has already been calculated otherwise the permission needs to be evaluated
[ "checks", "if", "the", "permission", "has", "already", "been", "calculated", "otherwise", "the", "permission", "needs", "to", "be", "evaluated" ]
6a4ef94848861bb79b0ab1454264366aed4e2db8
https://github.com/NullVoxPopuli/authorizable/blob/6a4ef94848861bb79b0ab1454264366aed4e2db8/lib/authorizable/proxy.rb#L55-L63
train
NullVoxPopuli/authorizable
lib/authorizable/proxy.rb
Authorizable.Proxy.value_from_cache
def value_from_cache(permission, *args) # object; Event, Discount, etc o = args[0] role = get_role_of(o) # don't perform the permission evaluation, if we have already computed it cache.get_for_role(permission, role) end
ruby
def value_from_cache(permission, *args) # object; Event, Discount, etc o = args[0] role = get_role_of(o) # don't perform the permission evaluation, if we have already computed it cache.get_for_role(permission, role) end
[ "def", "value_from_cache", "(", "permission", ",", "*", "args", ")", "# object; Event, Discount, etc", "o", "=", "args", "[", "0", "]", "role", "=", "get_role_of", "(", "o", ")", "# don't perform the permission evaluation, if we have already computed it", "cache", ".", ...
checks the cache if we have calculated this permission before @return [Boolean|NilClass]
[ "checks", "the", "cache", "if", "we", "have", "calculated", "this", "permission", "before" ]
6a4ef94848861bb79b0ab1454264366aed4e2db8
https://github.com/NullVoxPopuli/authorizable/blob/6a4ef94848861bb79b0ab1454264366aed4e2db8/lib/authorizable/proxy.rb#L67-L74
train
NullVoxPopuli/authorizable
lib/authorizable/proxy.rb
Authorizable.Proxy.evaluate_permission
def evaluate_permission(permission, *args) # object; Event, Discount, etc o = args[0] # default to allow result = true role = get_role_of(o) # evaluate procs if (proc = PermissionUtilities.has_procs?(permission)) result &= proc.call(o, self) end # Here is...
ruby
def evaluate_permission(permission, *args) # object; Event, Discount, etc o = args[0] # default to allow result = true role = get_role_of(o) # evaluate procs if (proc = PermissionUtilities.has_procs?(permission)) result &= proc.call(o, self) end # Here is...
[ "def", "evaluate_permission", "(", "permission", ",", "*", "args", ")", "# object; Event, Discount, etc", "o", "=", "args", "[", "0", "]", "# default to allow", "result", "=", "true", "role", "=", "get_role_of", "(", "o", ")", "# evaluate procs", "if", "(", "p...
performs a full evaluation of the permission @return [Boolean]
[ "performs", "a", "full", "evaluation", "of", "the", "permission" ]
6a4ef94848861bb79b0ab1454264366aed4e2db8
https://github.com/NullVoxPopuli/authorizable/blob/6a4ef94848861bb79b0ab1454264366aed4e2db8/lib/authorizable/proxy.rb#L78-L104
train
NullVoxPopuli/authorizable
lib/authorizable/proxy.rb
Authorizable.Proxy.has_role_with
def has_role_with(object) if object.respond_to?(:user_id) if object.user_id == actor.id return IS_OWNER else return IS_UNRELATED end end # hopefully the object passed always responds to user_id IS_UNRELATED end
ruby
def has_role_with(object) if object.respond_to?(:user_id) if object.user_id == actor.id return IS_OWNER else return IS_UNRELATED end end # hopefully the object passed always responds to user_id IS_UNRELATED end
[ "def", "has_role_with", "(", "object", ")", "if", "object", ".", "respond_to?", "(", ":user_id", ")", "if", "object", ".", "user_id", "==", "actor", ".", "id", "return", "IS_OWNER", "else", "return", "IS_UNRELATED", "end", "end", "# hopefully the object passed a...
This method can also be overridden if one desires to have multiple types of ownership, such as a collaborator-type relationship @param [ActiveRecord::Base] object should be the object that is being tested if the user can perform the action on @return [Number] true if self owns object
[ "This", "method", "can", "also", "be", "overridden", "if", "one", "desires", "to", "have", "multiple", "types", "of", "ownership", "such", "as", "a", "collaborator", "-", "type", "relationship" ]
6a4ef94848861bb79b0ab1454264366aed4e2db8
https://github.com/NullVoxPopuli/authorizable/blob/6a4ef94848861bb79b0ab1454264366aed4e2db8/lib/authorizable/proxy.rb#L144-L154
train
nanodeath/threadz
lib/threadz/thread_pool.rb
Threadz.ThreadPool.spawn_thread
def spawn_thread Thread.new do while true x = @queue.shift if x == Directive::SUICIDE_PILL @worker_threads_count.decrement Thread.current.terminate end Thread.pass begin x.job.call(x) rescue StandardError => e ...
ruby
def spawn_thread Thread.new do while true x = @queue.shift if x == Directive::SUICIDE_PILL @worker_threads_count.decrement Thread.current.terminate end Thread.pass begin x.job.call(x) rescue StandardError => e ...
[ "def", "spawn_thread", "Thread", ".", "new", "do", "while", "true", "x", "=", "@queue", ".", "shift", "if", "x", "==", "Directive", "::", "SUICIDE_PILL", "@worker_threads_count", ".", "decrement", "Thread", ".", "current", ".", "terminate", "end", "Thread", ...
Spin up a new thread
[ "Spin", "up", "a", "new", "thread" ]
5d96e052567076d5e86690f3d3703f1082330dd5
https://github.com/nanodeath/threadz/blob/5d96e052567076d5e86690f3d3703f1082330dd5/lib/threadz/thread_pool.rb#L77-L94
train
nanodeath/threadz
lib/threadz/thread_pool.rb
Threadz.ThreadPool.spawn_watch_thread
def spawn_watch_thread @watch_thread = Thread.new do while true # If there are idle threads and we're above minimum if @queue.num_waiting > 0 && @worker_threads_count.value > @min_size # documented @killscore += THREADS_IDLE_SCORE * @queue.num_waiting #...
ruby
def spawn_watch_thread @watch_thread = Thread.new do while true # If there are idle threads and we're above minimum if @queue.num_waiting > 0 && @worker_threads_count.value > @min_size # documented @killscore += THREADS_IDLE_SCORE * @queue.num_waiting #...
[ "def", "spawn_watch_thread", "@watch_thread", "=", "Thread", ".", "new", "do", "while", "true", "# If there are idle threads and we're above minimum", "if", "@queue", ".", "num_waiting", ">", "0", "&&", "@worker_threads_count", ".", "value", ">", "@min_size", "# documen...
This thread watches over the pool and allocated and deallocates threads as necessary
[ "This", "thread", "watches", "over", "the", "pool", "and", "allocated", "and", "deallocates", "threads", "as", "necessary" ]
5d96e052567076d5e86690f3d3703f1082330dd5
https://github.com/nanodeath/threadz/blob/5d96e052567076d5e86690f3d3703f1082330dd5/lib/threadz/thread_pool.rb#L106-L134
train
jduckett/duck_map
lib/duck_map/array_helper.rb
DuckMap.ArrayHelper.convert_to
def convert_to(values, type) buffer = [] if values.kind_of?(Array) values.each do |value| begin if type == :string buffer.push(value.to_s) elsif type == :symbol buffer.push(value.to_sym) end rescue Exception =...
ruby
def convert_to(values, type) buffer = [] if values.kind_of?(Array) values.each do |value| begin if type == :string buffer.push(value.to_s) elsif type == :symbol buffer.push(value.to_sym) end rescue Exception =...
[ "def", "convert_to", "(", "values", ",", "type", ")", "buffer", "=", "[", "]", "if", "values", ".", "kind_of?", "(", "Array", ")", "values", ".", "each", "do", "|", "value", "|", "begin", "if", "type", "==", ":string", "buffer", ".", "push", "(", "...
Ensures all values in an Array are of a certain type. This is meant to be used internally by DuckMap modules and classes. values = ["new_book", "edit_book", "create_book", "destroy_book"] values = obj.convert_to(values, :symbol) puts values #=> [:new_book, :edit_book, :create_book, :destroy_book] @p...
[ "Ensures", "all", "values", "in", "an", "Array", "are", "of", "a", "certain", "type", ".", "This", "is", "meant", "to", "be", "used", "internally", "by", "DuckMap", "modules", "and", "classes", "." ]
c510acfa95e8ad4afb1501366058ae88a73704df
https://github.com/jduckett/duck_map/blob/c510acfa95e8ad4afb1501366058ae88a73704df/lib/duck_map/array_helper.rb#L19-L46
train
kwatch/baby_erubis
lib/baby_erubis.rb
BabyErubis.Template.from_file
def from_file(filename, encoding='utf-8') mode = "rb:#{encoding}" mode = "rb" if RUBY_VERSION < '1.9' input = File.open(filename, mode) {|f| f.read() } compile(parse(input), filename, 1) return self end
ruby
def from_file(filename, encoding='utf-8') mode = "rb:#{encoding}" mode = "rb" if RUBY_VERSION < '1.9' input = File.open(filename, mode) {|f| f.read() } compile(parse(input), filename, 1) return self end
[ "def", "from_file", "(", "filename", ",", "encoding", "=", "'utf-8'", ")", "mode", "=", "\"rb:#{encoding}\"", "mode", "=", "\"rb\"", "if", "RUBY_VERSION", "<", "'1.9'", "input", "=", "File", ".", "open", "(", "filename", ",", "mode", ")", "{", "|", "f", ...
Ruby 2.1 feature
[ "Ruby", "2", ".", "1", "feature" ]
247e105643094942572bb20f517423122fcb5eab
https://github.com/kwatch/baby_erubis/blob/247e105643094942572bb20f517423122fcb5eab/lib/baby_erubis.rb#L46-L52
train
kostyantyn/school_friend
lib/school_friend/session.rb
SchoolFriend.Session.additional_params
def additional_params @additional_params ||= if session_scope? if oauth2_session? {application_key: application_key} else {application_key: application_key, session_key: options[:session_key]} end else {application_key: application_key} end end
ruby
def additional_params @additional_params ||= if session_scope? if oauth2_session? {application_key: application_key} else {application_key: application_key, session_key: options[:session_key]} end else {application_key: application_key} end end
[ "def", "additional_params", "@additional_params", "||=", "if", "session_scope?", "if", "oauth2_session?", "{", "application_key", ":", "application_key", "}", "else", "{", "application_key", ":", "application_key", ",", "session_key", ":", "options", "[", ":session_key"...
Returns additional params which are required for all requests. Depends on request scope. @return [Hash]
[ "Returns", "additional", "params", "which", "are", "required", "for", "all", "requests", ".", "Depends", "on", "request", "scope", "." ]
4cfd829bc6ba4b6a9148e6565e5328d5f2ba91e9
https://github.com/kostyantyn/school_friend/blob/4cfd829bc6ba4b6a9148e6565e5328d5f2ba91e9/lib/school_friend/session.rb#L164-L174
train
kostyantyn/school_friend
lib/school_friend/session.rb
SchoolFriend.Session.api_call
def api_call(method, params = {}, force_session_call = false) raise RequireSessionScopeError.new('This API call requires session scope') if force_session_call and application_scope? uri = build_uri(method, params) Net::HTTP.get_response(uri) end
ruby
def api_call(method, params = {}, force_session_call = false) raise RequireSessionScopeError.new('This API call requires session scope') if force_session_call and application_scope? uri = build_uri(method, params) Net::HTTP.get_response(uri) end
[ "def", "api_call", "(", "method", ",", "params", "=", "{", "}", ",", "force_session_call", "=", "false", ")", "raise", "RequireSessionScopeError", ".", "new", "(", "'This API call requires session scope'", ")", "if", "force_session_call", "and", "application_scope?", ...
Performs API call to Odnoklassniki @example Performs API call in current scope school_friend = SchoolFriend::Session.new school_friend.api_call('widget.getWidgets', wids: 'mobile-header,mobile-footer') # Net::HTTPResponse @example Force performs API call in session scope school_friend = SchoolFriend::Sessi...
[ "Performs", "API", "call", "to", "Odnoklassniki" ]
4cfd829bc6ba4b6a9148e6565e5328d5f2ba91e9
https://github.com/kostyantyn/school_friend/blob/4cfd829bc6ba4b6a9148e6565e5328d5f2ba91e9/lib/school_friend/session.rb#L191-L196
train
kostyantyn/school_friend
lib/school_friend/session.rb
SchoolFriend.Session.build_uri
def build_uri(method, params = {}) uri = URI(api_server) uri.path = '/api/' + method.sub('.', '/') uri.query = URI.encode_www_form(sign(params)) SchoolFriend.logger.debug "API Request: #{uri}" uri end
ruby
def build_uri(method, params = {}) uri = URI(api_server) uri.path = '/api/' + method.sub('.', '/') uri.query = URI.encode_www_form(sign(params)) SchoolFriend.logger.debug "API Request: #{uri}" uri end
[ "def", "build_uri", "(", "method", ",", "params", "=", "{", "}", ")", "uri", "=", "URI", "(", "api_server", ")", "uri", ".", "path", "=", "'/api/'", "+", "method", ".", "sub", "(", "'.'", ",", "'/'", ")", "uri", ".", "query", "=", "URI", ".", "...
Builds URI object @param [String] method request method @param [Hash] params request params @return [URI::HTTP]
[ "Builds", "URI", "object" ]
4cfd829bc6ba4b6a9148e6565e5328d5f2ba91e9
https://github.com/kostyantyn/school_friend/blob/4cfd829bc6ba4b6a9148e6565e5328d5f2ba91e9/lib/school_friend/session.rb#L203-L211
train
NullVoxPopuli/lazy_crud
lib/lazy_crud/instance_methods.rb
LazyCrud.InstanceMethods.undestroy
def undestroy @resource = resource_proxy(true).find(params[:id]) set_resource_instance @resource.deleted_at = nil @resource.save respond_with(@resource, location: { action: :index }) # flash[:notice] = "#{resource_name} has been undeleted" # redirect_to action: :index en...
ruby
def undestroy @resource = resource_proxy(true).find(params[:id]) set_resource_instance @resource.deleted_at = nil @resource.save respond_with(@resource, location: { action: :index }) # flash[:notice] = "#{resource_name} has been undeleted" # redirect_to action: :index en...
[ "def", "undestroy", "@resource", "=", "resource_proxy", "(", "true", ")", ".", "find", "(", "params", "[", ":id", "]", ")", "set_resource_instance", "@resource", ".", "deleted_at", "=", "nil", "@resource", ".", "save", "respond_with", "(", "@resource", ",", ...
only works if deleting of resources occurs by setting the deleted_at field
[ "only", "works", "if", "deleting", "of", "resources", "occurs", "by", "setting", "the", "deleted_at", "field" ]
80997de5de9eba4f96121c2bdb11fc4e4b8b754a
https://github.com/NullVoxPopuli/lazy_crud/blob/80997de5de9eba4f96121c2bdb11fc4e4b8b754a/lib/lazy_crud/instance_methods.rb#L64-L75
train
NullVoxPopuli/lazy_crud
lib/lazy_crud/instance_methods.rb
LazyCrud.InstanceMethods.resource_proxy
def resource_proxy(with_deleted = false) proxy = if parent_instance.present? parent_instance.send(resource_plural_name) else self.class.resource_class end if with_deleted and proxy.respond_to?(:with_deleted) proxy = proxy.with_deleted end proxy end
ruby
def resource_proxy(with_deleted = false) proxy = if parent_instance.present? parent_instance.send(resource_plural_name) else self.class.resource_class end if with_deleted and proxy.respond_to?(:with_deleted) proxy = proxy.with_deleted end proxy end
[ "def", "resource_proxy", "(", "with_deleted", "=", "false", ")", "proxy", "=", "if", "parent_instance", ".", "present?", "parent_instance", ".", "send", "(", "resource_plural_name", ")", "else", "self", ".", "class", ".", "resource_class", "end", "if", "with_del...
determines if we want to use the parent class if available or if we just use the resource class
[ "determines", "if", "we", "want", "to", "use", "the", "parent", "class", "if", "available", "or", "if", "we", "just", "use", "the", "resource", "class" ]
80997de5de9eba4f96121c2bdb11fc4e4b8b754a
https://github.com/NullVoxPopuli/lazy_crud/blob/80997de5de9eba4f96121c2bdb11fc4e4b8b754a/lib/lazy_crud/instance_methods.rb#L95-L107
train
m-31/puppetdb_query
lib/puppetdb_query/parser.rb
PuppetDBQuery.Parser.read_maximal_term
def read_maximal_term(priority) return nil if empty? logger.debug "read maximal term (#{priority})" first = read_minimal_term term = add_next_infix_terms(priority, first) logger.debug "read maximal term: #{term}" term end
ruby
def read_maximal_term(priority) return nil if empty? logger.debug "read maximal term (#{priority})" first = read_minimal_term term = add_next_infix_terms(priority, first) logger.debug "read maximal term: #{term}" term end
[ "def", "read_maximal_term", "(", "priority", ")", "return", "nil", "if", "empty?", "logger", ".", "debug", "\"read maximal term (#{priority})\"", "first", "=", "read_minimal_term", "term", "=", "add_next_infix_terms", "(", "priority", ",", "first", ")", "logger", "....
Reads next maximal term. The following input doesn't make the term more complete. Respects the priority of operators by comparing it to the given value.
[ "Reads", "next", "maximal", "term", ".", "The", "following", "input", "doesn", "t", "make", "the", "term", "more", "complete", ".", "Respects", "the", "priority", "of", "operators", "by", "comparing", "it", "to", "the", "given", "value", "." ]
58103c91f291de8ce28d679256e50ae391b93ecb
https://github.com/m-31/puppetdb_query/blob/58103c91f291de8ce28d679256e50ae391b93ecb/lib/puppetdb_query/parser.rb#L63-L70
train
innku/kublog
app/helpers/kublog/application_helper.rb
Kublog.ApplicationHelper.error_messages_for
def error_messages_for(*objects) options = objects.extract_options! options[:header_message] ||= I18n.t(:"activerecord.errors.header", :default => "Invalid Fields") options[:message] ||= I18n.t(:"activerecord.errors.message", :default => "Correct the following errors and try again.") messages = ...
ruby
def error_messages_for(*objects) options = objects.extract_options! options[:header_message] ||= I18n.t(:"activerecord.errors.header", :default => "Invalid Fields") options[:message] ||= I18n.t(:"activerecord.errors.message", :default => "Correct the following errors and try again.") messages = ...
[ "def", "error_messages_for", "(", "*", "objects", ")", "options", "=", "objects", ".", "extract_options!", "options", "[", ":header_message", "]", "||=", "I18n", ".", "t", "(", ":\"", "\"", ",", ":default", "=>", "\"Invalid Fields\"", ")", "options", "[", ":...
Nifty generators errors helper code
[ "Nifty", "generators", "errors", "helper", "code" ]
51b53cc3e1dd742053aed0b13bab915016d9a768
https://github.com/innku/kublog/blob/51b53cc3e1dd742053aed0b13bab915016d9a768/app/helpers/kublog/application_helper.rb#L5-L16
train
rob-lane/shiny_themes
lib/shiny_themes/renders_theme.rb
ShinyThemes.RendersTheme.update_current_theme
def update_current_theme(name, options = {}) self.class.renders_theme(name, options) Rails.application.config.theme.name = current_theme_name Rails.application.config.theme.layout = current_theme_layout ShinyThemes::Engine.theme_config.save unless options[:dont_save] self.class.theme # ret...
ruby
def update_current_theme(name, options = {}) self.class.renders_theme(name, options) Rails.application.config.theme.name = current_theme_name Rails.application.config.theme.layout = current_theme_layout ShinyThemes::Engine.theme_config.save unless options[:dont_save] self.class.theme # ret...
[ "def", "update_current_theme", "(", "name", ",", "options", "=", "{", "}", ")", "self", ".", "class", ".", "renders_theme", "(", "name", ",", "options", ")", "Rails", ".", "application", ".", "config", ".", "theme", ".", "name", "=", "current_theme_name", ...
Update the current theme for the controller and optionally save @param name [String] The name of the new theme @param options [Hash] Options hash @option options [String] :layout ('application') Default layout for theme @option options [Boolean] :dont_save (false) Dont save the update to the theme.yml config @retu...
[ "Update", "the", "current", "theme", "for", "the", "controller", "and", "optionally", "save" ]
8c9e9d6bab1db4c63ddcbeb52b6f4577f4680699
https://github.com/rob-lane/shiny_themes/blob/8c9e9d6bab1db4c63ddcbeb52b6f4577f4680699/lib/shiny_themes/renders_theme.rb#L34-L40
train
wilson/revenant
lib/locks/mysql.rb
Revenant.MySQL.acquire_lock
def acquire_lock(lock_name) begin acquired = false sql = lock_query(lock_name) connection.query(sql) do |result| acquired = result.fetch_row.first == "1" end acquired rescue ::Exception false end end
ruby
def acquire_lock(lock_name) begin acquired = false sql = lock_query(lock_name) connection.query(sql) do |result| acquired = result.fetch_row.first == "1" end acquired rescue ::Exception false end end
[ "def", "acquire_lock", "(", "lock_name", ")", "begin", "acquired", "=", "false", "sql", "=", "lock_query", "(", "lock_name", ")", "connection", ".", "query", "(", "sql", ")", "do", "|", "result", "|", "acquired", "=", "result", ".", "fetch_row", ".", "fi...
Expects the connection to behave like an instance of +Mysql+ If you need something else, replace +acquire_lock+ with your own code. Or define your own lock_function while configuring a new Revenant task.
[ "Expects", "the", "connection", "to", "behave", "like", "an", "instance", "of", "+", "Mysql", "+", "If", "you", "need", "something", "else", "replace", "+", "acquire_lock", "+", "with", "your", "own", "code", ".", "Or", "define", "your", "own", "lock_funct...
80fe65742de54ce0c5a8e6c56cea7003fe286746
https://github.com/wilson/revenant/blob/80fe65742de54ce0c5a8e6c56cea7003fe286746/lib/locks/mysql.rb#L21-L32
train
rob-lane/shiny_themes
lib/shiny_themes/theme_config.rb
ShinyThemes.ThemeConfig.load
def load new_config = full_config[Rails.env].try(:deep_symbolize_keys!) || {} # Honor values in config file over defaults @defaults.reject! { |k, _| new_config.keys.include?(k) } Rails.application.config.theme.merge!(@defaults.merge(new_config)) end
ruby
def load new_config = full_config[Rails.env].try(:deep_symbolize_keys!) || {} # Honor values in config file over defaults @defaults.reject! { |k, _| new_config.keys.include?(k) } Rails.application.config.theme.merge!(@defaults.merge(new_config)) end
[ "def", "load", "new_config", "=", "full_config", "[", "Rails", ".", "env", "]", ".", "try", "(", ":deep_symbolize_keys!", ")", "||", "{", "}", "# Honor values in config file over defaults", "@defaults", ".", "reject!", "{", "|", "k", ",", "_", "|", "new_config...
Create the ordered options, populate with provided hash and load YAML file options. @param default_options [Hash] (Hash.new) - Options to populate the theme config with. @options default_options [String] :path The path relative to the rails root where templates are installed @options default_options [Array(St...
[ "Create", "the", "ordered", "options", "populate", "with", "provided", "hash", "and", "load", "YAML", "file", "options", "." ]
8c9e9d6bab1db4c63ddcbeb52b6f4577f4680699
https://github.com/rob-lane/shiny_themes/blob/8c9e9d6bab1db4c63ddcbeb52b6f4577f4680699/lib/shiny_themes/theme_config.rb#L21-L26
train
rob-lane/shiny_themes
lib/shiny_themes/theme_config.rb
ShinyThemes.ThemeConfig.save
def save # Don't save default values save_config = Rails.application.config.theme.reject { |k, _| @defaults.keys.include?(k) } full_config[Rails.env].merge!(save_config) File.open(config_pathname, 'w') { |f| f << full_config.to_yaml } end
ruby
def save # Don't save default values save_config = Rails.application.config.theme.reject { |k, _| @defaults.keys.include?(k) } full_config[Rails.env].merge!(save_config) File.open(config_pathname, 'w') { |f| f << full_config.to_yaml } end
[ "def", "save", "# Don't save default values", "save_config", "=", "Rails", ".", "application", ".", "config", ".", "theme", ".", "reject", "{", "|", "k", ",", "_", "|", "@defaults", ".", "keys", ".", "include?", "(", "k", ")", "}", "full_config", "[", "R...
Save the current state of the theme config to the theme.yml file
[ "Save", "the", "current", "state", "of", "the", "theme", "config", "to", "the", "theme", ".", "yml", "file" ]
8c9e9d6bab1db4c63ddcbeb52b6f4577f4680699
https://github.com/rob-lane/shiny_themes/blob/8c9e9d6bab1db4c63ddcbeb52b6f4577f4680699/lib/shiny_themes/theme_config.rb#L29-L34
train
jarhart/rattler
lib/rattler/parsers/super.rb
Rattler::Parsers.Super.parse
def parse(scanner, rules, scope = ParserScope.empty) rules.inherited_rule(rule_name).parse(scanner, rules, scope) end
ruby
def parse(scanner, rules, scope = ParserScope.empty) rules.inherited_rule(rule_name).parse(scanner, rules, scope) end
[ "def", "parse", "(", "scanner", ",", "rules", ",", "scope", "=", "ParserScope", ".", "empty", ")", "rules", ".", "inherited_rule", "(", "rule_name", ")", ".", "parse", "(", "scanner", ",", "rules", ",", "scope", ")", "end" ]
Apply the parse rule of the same name inherited from a super-grammar. @param (see Match#parse) @return the result of applying parse rule of the same name inherited from a super-grammar
[ "Apply", "the", "parse", "rule", "of", "the", "same", "name", "inherited", "from", "a", "super", "-", "grammar", "." ]
8b4efde2a05e9e790955bb635d4a1a9615893719
https://github.com/jarhart/rattler/blob/8b4efde2a05e9e790955bb635d4a1a9615893719/lib/rattler/parsers/super.rb#L23-L25
train
jrochkind/borrow_direct
lib/borrow_direct/find_item.rb
BorrowDirect.FindItem.exact_search_request_hash
def exact_search_request_hash(type, value) # turn it into an array if it's not one already values = Array(value) hash = { "PartnershipId" => Defaults.partnership_id, "ExactSearch" => [] } values.each do |value| hash["ExactSearch"] << { "Type" => ty...
ruby
def exact_search_request_hash(type, value) # turn it into an array if it's not one already values = Array(value) hash = { "PartnershipId" => Defaults.partnership_id, "ExactSearch" => [] } values.each do |value| hash["ExactSearch"] << { "Type" => ty...
[ "def", "exact_search_request_hash", "(", "type", ",", "value", ")", "# turn it into an array if it's not one already", "values", "=", "Array", "(", "value", ")", "hash", "=", "{", "\"PartnershipId\"", "=>", "Defaults", ".", "partnership_id", ",", "\"ExactSearch\"", "=...
Produce BD request hash for exact search of type eg "ISBN" value can be a singel value, or an array of values. For array, BD will "OR" them.
[ "Produce", "BD", "request", "hash", "for", "exact", "search", "of", "type", "eg", "ISBN", "value", "can", "be", "a", "singel", "value", "or", "an", "array", "of", "values", ".", "For", "array", "BD", "will", "OR", "them", "." ]
f2f53760e15d742a5c5584dd641f20dea315f99f
https://github.com/jrochkind/borrow_direct/blob/f2f53760e15d742a5c5584dd641f20dea315f99f/lib/borrow_direct/find_item.rb#L78-L95
train
atomicobject/hardmock
lib/hardmock/expectation.rb
Hardmock.Expectation.raises
def raises(err=nil) case err when Exception @options[:raises] = err when String @options[:raises] = RuntimeError.new(err) else @options[:raises] = RuntimeError.new("An Error") end self end
ruby
def raises(err=nil) case err when Exception @options[:raises] = err when String @options[:raises] = RuntimeError.new(err) else @options[:raises] = RuntimeError.new("An Error") end self end
[ "def", "raises", "(", "err", "=", "nil", ")", "case", "err", "when", "Exception", "@options", "[", ":raises", "]", "=", "err", "when", "String", "@options", "[", ":raises", "]", "=", "RuntimeError", ".", "new", "(", "err", ")", "else", "@options", "[",...
Rig an expected method to raise an exception when the mock is invoked. Eg, @cash_machine.expects.withdraw(20,:dollars).raises "Insufficient funds" The argument can be: * an Exception -- will be used directly * a String -- will be used as the message for a RuntimeError * nothing -- RuntimeError.new("An Error")...
[ "Rig", "an", "expected", "method", "to", "raise", "an", "exception", "when", "the", "mock", "is", "invoked", "." ]
a2c01c2cbd28f56a71cc824f04b40ea1d14be367
https://github.com/atomicobject/hardmock/blob/a2c01c2cbd28f56a71cc824f04b40ea1d14be367/lib/hardmock/expectation.rb#L86-L96
train
atomicobject/hardmock
lib/hardmock/expectation.rb
Hardmock.Expectation.yields
def yields(*items) @options[:suppress_arguments_to_block] = true if items.empty? # Yield once @options[:block] = lambda do |block| if block.arity != 0 and block.arity != -1 raise ExpectationError.new("The given block was expected to have no parameter count; instead, got...
ruby
def yields(*items) @options[:suppress_arguments_to_block] = true if items.empty? # Yield once @options[:block] = lambda do |block| if block.arity != 0 and block.arity != -1 raise ExpectationError.new("The given block was expected to have no parameter count; instead, got...
[ "def", "yields", "(", "*", "items", ")", "@options", "[", ":suppress_arguments_to_block", "]", "=", "true", "if", "items", ".", "empty?", "# Yield once", "@options", "[", ":block", "]", "=", "lambda", "do", "|", "block", "|", "if", "block", ".", "arity", ...
Used when an expected method accepts a block at runtime. When the expected method is invoked, the block passed to that method will be invoked as well. NOTE: ExpectationError will be thrown upon running the expected method if the arguments you set up in +yields+ do not properly match up with the actual block that ...
[ "Used", "when", "an", "expected", "method", "accepts", "a", "block", "at", "runtime", ".", "When", "the", "expected", "method", "is", "invoked", "the", "block", "passed", "to", "that", "method", "will", "be", "invoked", "as", "well", "." ]
a2c01c2cbd28f56a71cc824f04b40ea1d14be367
https://github.com/atomicobject/hardmock/blob/a2c01c2cbd28f56a71cc824f04b40ea1d14be367/lib/hardmock/expectation.rb#L182-L218
train
roja/words
lib/words.rb
Words.Wordnet.find
def find(term) raise NoWordnetConnection, "There is presently no connection to wordnet. To attempt to reistablish a connection you should use the 'open!' command on the Wordnet object." unless connected? homographs = @wordnet_connection.homographs(term) Homographs.new(homographs, @wordnet_connection) un...
ruby
def find(term) raise NoWordnetConnection, "There is presently no connection to wordnet. To attempt to reistablish a connection you should use the 'open!' command on the Wordnet object." unless connected? homographs = @wordnet_connection.homographs(term) Homographs.new(homographs, @wordnet_connection) un...
[ "def", "find", "(", "term", ")", "raise", "NoWordnetConnection", ",", "\"There is presently no connection to wordnet. To attempt to reistablish a connection you should use the 'open!' command on the Wordnet object.\"", "unless", "connected?", "homographs", "=", "@wordnet_connection", "."...
Constructs a new wordnet connection object. @param [Symbol] connector_type Specifies the connector type or mode desired. Current supported connectors are :pure and :tokyo. @param [String, Symbol] wordnet_path Specifies the directory within which the wordnet dictionary can be found. It can be set to :search to attemp...
[ "Constructs", "a", "new", "wordnet", "connection", "object", "." ]
4d6302e7218533fcc2afb4cd993686dd56fe2cde
https://github.com/roja/words/blob/4d6302e7218533fcc2afb4cd993686dd56fe2cde/lib/words.rb#L65-L71
train
bjh/griddle
lib/griddle/point.rb
Griddle.Point.to_rectangle
def to_rectangle(point) d = delta(point) Rectangle.new( row, col, d.col + 1, d.row + 1 ) end
ruby
def to_rectangle(point) d = delta(point) Rectangle.new( row, col, d.col + 1, d.row + 1 ) end
[ "def", "to_rectangle", "(", "point", ")", "d", "=", "delta", "(", "point", ")", "Rectangle", ".", "new", "(", "row", ",", "col", ",", "d", ".", "col", "+", "1", ",", "d", ".", "row", "+", "1", ")", "end" ]
`point` is used to calculate the width and height of the new rectangle
[ "point", "is", "used", "to", "calculate", "the", "width", "and", "height", "of", "the", "new", "rectangle" ]
c924bcb56172c282cfa246560d8b2051d48e8884
https://github.com/bjh/griddle/blob/c924bcb56172c282cfa246560d8b2051d48e8884/lib/griddle/point.rb#L34-L43
train
medihack/make_voteable
lib/make_voteable/voter.rb
MakeVoteable.Voter.up_vote
def up_vote(voteable) check_voteable(voteable) voting = fetch_voting(voteable) if voting if voting.up_vote raise Exceptions::AlreadyVotedError.new(true) else voting.up_vote = true voteable.down_votes -= 1 self.down_votes -= 1 if has_attribute?(...
ruby
def up_vote(voteable) check_voteable(voteable) voting = fetch_voting(voteable) if voting if voting.up_vote raise Exceptions::AlreadyVotedError.new(true) else voting.up_vote = true voteable.down_votes -= 1 self.down_votes -= 1 if has_attribute?(...
[ "def", "up_vote", "(", "voteable", ")", "check_voteable", "(", "voteable", ")", "voting", "=", "fetch_voting", "(", "voteable", ")", "if", "voting", "if", "voting", ".", "up_vote", "raise", "Exceptions", "::", "AlreadyVotedError", ".", "new", "(", "true", ")...
Up vote a +voteable+. Raises an AlreadyVotedError if the voter already up voted the voteable. Changes a down vote to an up vote if the the voter already down voted the voteable.
[ "Up", "vote", "a", "+", "voteable", "+", ".", "Raises", "an", "AlreadyVotedError", "if", "the", "voter", "already", "up", "voted", "the", "voteable", ".", "Changes", "a", "down", "vote", "to", "an", "up", "vote", "if", "the", "the", "voter", "already", ...
3cf3f7ca1c8db075a6a51e101c1b38ef724facd2
https://github.com/medihack/make_voteable/blob/3cf3f7ca1c8db075a6a51e101c1b38ef724facd2/lib/make_voteable/voter.rb#L18-L45
train
medihack/make_voteable
lib/make_voteable/voter.rb
MakeVoteable.Voter.up_vote!
def up_vote!(voteable) begin up_vote(voteable) success = true rescue Exceptions::AlreadyVotedError success = false end success end
ruby
def up_vote!(voteable) begin up_vote(voteable) success = true rescue Exceptions::AlreadyVotedError success = false end success end
[ "def", "up_vote!", "(", "voteable", ")", "begin", "up_vote", "(", "voteable", ")", "success", "=", "true", "rescue", "Exceptions", "::", "AlreadyVotedError", "success", "=", "false", "end", "success", "end" ]
Up votes the +voteable+, but doesn't raise an error if the votelable was already up voted. The vote is simply ignored then.
[ "Up", "votes", "the", "+", "voteable", "+", "but", "doesn", "t", "raise", "an", "error", "if", "the", "votelable", "was", "already", "up", "voted", ".", "The", "vote", "is", "simply", "ignored", "then", "." ]
3cf3f7ca1c8db075a6a51e101c1b38ef724facd2
https://github.com/medihack/make_voteable/blob/3cf3f7ca1c8db075a6a51e101c1b38ef724facd2/lib/make_voteable/voter.rb#L49-L57
train
medihack/make_voteable
lib/make_voteable/voter.rb
MakeVoteable.Voter.down_vote!
def down_vote!(voteable) begin down_vote(voteable) success = true rescue Exceptions::AlreadyVotedError success = false end success end
ruby
def down_vote!(voteable) begin down_vote(voteable) success = true rescue Exceptions::AlreadyVotedError success = false end success end
[ "def", "down_vote!", "(", "voteable", ")", "begin", "down_vote", "(", "voteable", ")", "success", "=", "true", "rescue", "Exceptions", "::", "AlreadyVotedError", "success", "=", "false", "end", "success", "end" ]
Down votes the +voteable+, but doesn't raise an error if the votelable was already down voted. The vote is simply ignored then.
[ "Down", "votes", "the", "+", "voteable", "+", "but", "doesn", "t", "raise", "an", "error", "if", "the", "votelable", "was", "already", "down", "voted", ".", "The", "vote", "is", "simply", "ignored", "then", "." ]
3cf3f7ca1c8db075a6a51e101c1b38ef724facd2
https://github.com/medihack/make_voteable/blob/3cf3f7ca1c8db075a6a51e101c1b38ef724facd2/lib/make_voteable/voter.rb#L93-L101
train
medihack/make_voteable
lib/make_voteable/voter.rb
MakeVoteable.Voter.unvote
def unvote(voteable) check_voteable(voteable) voting = fetch_voting(voteable) raise Exceptions::NotVotedError unless voting if voting.up_vote voteable.up_votes -= 1 self.up_votes -= 1 if has_attribute?(:up_votes) else voteable.down_votes -= 1 self.down_vo...
ruby
def unvote(voteable) check_voteable(voteable) voting = fetch_voting(voteable) raise Exceptions::NotVotedError unless voting if voting.up_vote voteable.up_votes -= 1 self.up_votes -= 1 if has_attribute?(:up_votes) else voteable.down_votes -= 1 self.down_vo...
[ "def", "unvote", "(", "voteable", ")", "check_voteable", "(", "voteable", ")", "voting", "=", "fetch_voting", "(", "voteable", ")", "raise", "Exceptions", "::", "NotVotedError", "unless", "voting", "if", "voting", ".", "up_vote", "voteable", ".", "up_votes", "...
Clears an already done vote on a +voteable+. Raises a NotVotedError if the voter didn't voted for the voteable.
[ "Clears", "an", "already", "done", "vote", "on", "a", "+", "voteable", "+", ".", "Raises", "a", "NotVotedError", "if", "the", "voter", "didn", "t", "voted", "for", "the", "voteable", "." ]
3cf3f7ca1c8db075a6a51e101c1b38ef724facd2
https://github.com/medihack/make_voteable/blob/3cf3f7ca1c8db075a6a51e101c1b38ef724facd2/lib/make_voteable/voter.rb#L105-L127
train
medihack/make_voteable
lib/make_voteable/voter.rb
MakeVoteable.Voter.unvote!
def unvote!(voteable) begin unvote(voteable) success = true rescue Exceptions::NotVotedError success = false end success end
ruby
def unvote!(voteable) begin unvote(voteable) success = true rescue Exceptions::NotVotedError success = false end success end
[ "def", "unvote!", "(", "voteable", ")", "begin", "unvote", "(", "voteable", ")", "success", "=", "true", "rescue", "Exceptions", "::", "NotVotedError", "success", "=", "false", "end", "success", "end" ]
Clears an already done vote on a +voteable+, but doesn't raise an error if the voteable was not voted. It ignores the unvote then.
[ "Clears", "an", "already", "done", "vote", "on", "a", "+", "voteable", "+", "but", "doesn", "t", "raise", "an", "error", "if", "the", "voteable", "was", "not", "voted", ".", "It", "ignores", "the", "unvote", "then", "." ]
3cf3f7ca1c8db075a6a51e101c1b38ef724facd2
https://github.com/medihack/make_voteable/blob/3cf3f7ca1c8db075a6a51e101c1b38ef724facd2/lib/make_voteable/voter.rb#L131-L139
train
medihack/make_voteable
lib/make_voteable/voter.rb
MakeVoteable.Voter.down_voted?
def down_voted?(voteable) check_voteable(voteable) voting = fetch_voting(voteable) return false if voting.nil? return true if voting.has_attribute?(:up_vote) && !voting.up_vote false end
ruby
def down_voted?(voteable) check_voteable(voteable) voting = fetch_voting(voteable) return false if voting.nil? return true if voting.has_attribute?(:up_vote) && !voting.up_vote false end
[ "def", "down_voted?", "(", "voteable", ")", "check_voteable", "(", "voteable", ")", "voting", "=", "fetch_voting", "(", "voteable", ")", "return", "false", "if", "voting", ".", "nil?", "return", "true", "if", "voting", ".", "has_attribute?", "(", ":up_vote", ...
Returns true if the voter down voted the +voteable+.
[ "Returns", "true", "if", "the", "voter", "down", "voted", "the", "+", "voteable", "+", "." ]
3cf3f7ca1c8db075a6a51e101c1b38ef724facd2
https://github.com/medihack/make_voteable/blob/3cf3f7ca1c8db075a6a51e101c1b38ef724facd2/lib/make_voteable/voter.rb#L158-L164
train
mkfs/mindset
lib/mindset/connection.rb
Mindset.LoopbackConnection.read_packet_buffer
def read_packet_buffer packets = @data[:wave][@wave_idx, 64].map { |val| Packet.factory(:wave, val) } @wave_idx += 64 @wave_idx = 0 if @wave_idx >= @data[:wave].count if @counter == 7 packets << Packet.factory(:delta, @data[:delta][@esense_idx]) packets << Pack...
ruby
def read_packet_buffer packets = @data[:wave][@wave_idx, 64].map { |val| Packet.factory(:wave, val) } @wave_idx += 64 @wave_idx = 0 if @wave_idx >= @data[:wave].count if @counter == 7 packets << Packet.factory(:delta, @data[:delta][@esense_idx]) packets << Pack...
[ "def", "read_packet_buffer", "packets", "=", "@data", "[", ":wave", "]", "[", "@wave_idx", ",", "64", "]", ".", "map", "{", "|", "val", "|", "Packet", ".", "factory", "(", ":wave", ",", "val", ")", "}", "@wave_idx", "+=", "64", "@wave_idx", "=", "0",...
=begin rdoc Simulate a read of the Mindset device by returning an Array of Packet objects. This assumes it will be called 8 times a second. According to the MDT, Mindset packets are sent at the following intervals: 1 packet per second: eSense, ASIC EEG, POOR_SIGNAL 512 packets per second: RAW Each read will there...
[ "=", "begin", "rdoc", "Simulate", "a", "read", "of", "the", "Mindset", "device", "by", "returning", "an", "Array", "of", "Packet", "objects", ".", "This", "assumes", "it", "will", "be", "called", "8", "times", "a", "second", "." ]
1b8a6b9c1773290828ba126065c1327ffdffabf1
https://github.com/mkfs/mindset/blob/1b8a6b9c1773290828ba126065c1327ffdffabf1/lib/mindset/connection.rb#L193-L219
train
notjosh/danger-package_json_lockdown
lib/package_json_lockdown/plugin.rb
Danger.DangerPackageJsonLockdown.verify
def verify(package_json) inspect(package_json).each do |suspicious| warn( "`#{suspicious[:package]}` doesn't specify fixed version number", file: package_json, line: suspicious[:line] ) end end
ruby
def verify(package_json) inspect(package_json).each do |suspicious| warn( "`#{suspicious[:package]}` doesn't specify fixed version number", file: package_json, line: suspicious[:line] ) end end
[ "def", "verify", "(", "package_json", ")", "inspect", "(", "package_json", ")", ".", "each", "do", "|", "suspicious", "|", "warn", "(", "\"`#{suspicious[:package]}` doesn't specify fixed version number\"", ",", "file", ":", "package_json", ",", "line", ":", "suspici...
Verifies the supplied `package.json` file @param [string] package_json Path to `package.json`, relative to current directory @return [void]
[ "Verifies", "the", "supplied", "package", ".", "json", "file" ]
7cdd25864da877fe90bc33350db22324f394cbfc
https://github.com/notjosh/danger-package_json_lockdown/blob/7cdd25864da877fe90bc33350db22324f394cbfc/lib/package_json_lockdown/plugin.rb#L64-L72
train
notjosh/danger-package_json_lockdown
lib/package_json_lockdown/plugin.rb
Danger.DangerPackageJsonLockdown.inspect
def inspect(package_json) json = JSON.parse(File.read(package_json)) suspicious_packages = [] dependency_keys.each do |dependency_key| next unless json.key?(dependency_key) results = find_something_suspicious(json[dependency_key], package_json) suspicious_packages.push(*resu...
ruby
def inspect(package_json) json = JSON.parse(File.read(package_json)) suspicious_packages = [] dependency_keys.each do |dependency_key| next unless json.key?(dependency_key) results = find_something_suspicious(json[dependency_key], package_json) suspicious_packages.push(*resu...
[ "def", "inspect", "(", "package_json", ")", "json", "=", "JSON", ".", "parse", "(", "File", ".", "read", "(", "package_json", ")", ")", "suspicious_packages", "=", "[", "]", "dependency_keys", ".", "each", "do", "|", "dependency_key", "|", "next", "unless"...
Inspects the supplied `package.json` file and returns problems @param [string] package_json Path to `package.json`, relative to current directory @return [Array<{Symbol => String}>] - `:package`: the offending package name - `:version`: the version as written in `package.json` ...
[ "Inspects", "the", "supplied", "package", ".", "json", "file", "and", "returns", "problems" ]
7cdd25864da877fe90bc33350db22324f394cbfc
https://github.com/notjosh/danger-package_json_lockdown/blob/7cdd25864da877fe90bc33350db22324f394cbfc/lib/package_json_lockdown/plugin.rb#L81-L94
train
jemmyw/bisques
lib/bisques/queue_listener.rb
Bisques.QueueListener.listen
def listen(&block) return if @listening @listening = true @thread = Thread.new do while @listening message = @queue.retrieve(@poll_time) block.call(message) if message.present? end end end
ruby
def listen(&block) return if @listening @listening = true @thread = Thread.new do while @listening message = @queue.retrieve(@poll_time) block.call(message) if message.present? end end end
[ "def", "listen", "(", "&", "block", ")", "return", "if", "@listening", "@listening", "=", "true", "@thread", "=", "Thread", ".", "new", "do", "while", "@listening", "message", "=", "@queue", ".", "retrieve", "(", "@poll_time", ")", "block", ".", "call", ...
Listen for messages. This is asynchronous and returns immediately. @example queue = bisques.find_or_create_queue("my queue") listener = QueuedListener.new(queue) listener.listen do |message| puts "Received #{message.object}" message.delete end while true; sleep 1; end # Process messages for...
[ "Listen", "for", "messages", ".", "This", "is", "asynchronous", "and", "returns", "immediately", "." ]
c48ab555f07664752bcbf9e8deb99bd75cbdc41b
https://github.com/jemmyw/bisques/blob/c48ab555f07664752bcbf9e8deb99bd75cbdc41b/lib/bisques/queue_listener.rb#L34-L44
train
mirrec/token_field
lib/token_field/form_builder.rb
TokenField.FormBuilder.token_field
def token_field(attribute_name, options = {}) association_type = @object.send(attribute_name).respond_to?(:each) ? :many : :one model_name = options.fetch(:model) { attribute_name.to_s.gsub(/_ids?/, "") }.to_s association = attribute_name.to_s.gsub(/_ids?/, "").to_sym token_url = options.fetch(:...
ruby
def token_field(attribute_name, options = {}) association_type = @object.send(attribute_name).respond_to?(:each) ? :many : :one model_name = options.fetch(:model) { attribute_name.to_s.gsub(/_ids?/, "") }.to_s association = attribute_name.to_s.gsub(/_ids?/, "").to_sym token_url = options.fetch(:...
[ "def", "token_field", "(", "attribute_name", ",", "options", "=", "{", "}", ")", "association_type", "=", "@object", ".", "send", "(", "attribute_name", ")", ".", "respond_to?", "(", ":each", ")", "?", ":many", ":", ":one", "model_name", "=", "options", "....
form_for helper for token input with jquery token input plugin for has_many and belongs_to association http://railscasts.com/episodes/258-token-fields http://loopj.com/jquery-tokeninput/ helper will render standard text field input with javascript. javascript will change standard input to token field input EXA...
[ "form_for", "helper", "for", "token", "input", "with", "jquery", "token", "input", "plugin", "for", "has_many", "and", "belongs_to", "association" ]
a4abed90ef18890afeac5363b4f791e66f3fe62e
https://github.com/mirrec/token_field/blob/a4abed90ef18890afeac5363b4f791e66f3fe62e/lib/token_field/form_builder.rb#L94-L151
train
26fe/tree.rb
lib/tree_rb/input_plugins/html_page/dom_walker.rb
TreeRb.DomWalker.process_node
def process_node(node, level=1) entries = node.children @visitor.enter_node(node) entries.each do |entry| unless is_leaf?(entry) process_node(entry, level+1) else @visitor.visit_leaf(entry) end end @visitor.exit_node(node) end
ruby
def process_node(node, level=1) entries = node.children @visitor.enter_node(node) entries.each do |entry| unless is_leaf?(entry) process_node(entry, level+1) else @visitor.visit_leaf(entry) end end @visitor.exit_node(node) end
[ "def", "process_node", "(", "node", ",", "level", "=", "1", ")", "entries", "=", "node", ".", "children", "@visitor", ".", "enter_node", "(", "node", ")", "entries", ".", "each", "do", "|", "entry", "|", "unless", "is_leaf?", "(", "entry", ")", "proces...
recurse on nodes
[ "recurse", "on", "nodes" ]
5ecf0cfbbc439e27c72b9676d6a1ccee8e6bb02b
https://github.com/26fe/tree.rb/blob/5ecf0cfbbc439e27c72b9676d6a1ccee8e6bb02b/lib/tree_rb/input_plugins/html_page/dom_walker.rb#L18-L29
train
marcmo/cxxproject
lib/cxxproject/buildingblocks/linkable.rb
Cxxproject.Linkable.handle_whole_archive
def handle_whole_archive(building_block, res, linker, flag) if is_whole_archive(building_block) res.push(flag) if flag and !flag.empty? end end
ruby
def handle_whole_archive(building_block, res, linker, flag) if is_whole_archive(building_block) res.push(flag) if flag and !flag.empty? end end
[ "def", "handle_whole_archive", "(", "building_block", ",", "res", ",", "linker", ",", "flag", ")", "if", "is_whole_archive", "(", "building_block", ")", "res", ".", "push", "(", "flag", ")", "if", "flag", "and", "!", "flag", ".", "empty?", "end", "end" ]
res the array with command line arguments that is used as result linker the linker hash sym the symbol that is used to fish out a value from the linker
[ "res", "the", "array", "with", "command", "line", "arguments", "that", "is", "used", "as", "result", "linker", "the", "linker", "hash", "sym", "the", "symbol", "that", "is", "used", "to", "fish", "out", "a", "value", "from", "the", "linker" ]
3740a09d6a143acd96bde3d2ff79055a6b810da4
https://github.com/marcmo/cxxproject/blob/3740a09d6a143acd96bde3d2ff79055a6b810da4/lib/cxxproject/buildingblocks/linkable.rb#L152-L156
train
marcmo/cxxproject
lib/cxxproject/buildingblocks/linkable.rb
Cxxproject.Linkable.convert_to_rake
def convert_to_rake() object_multitask = prepare_tasks_for_objects() res = typed_file_task get_rake_task_type(), get_task_name => object_multitask do cmd = calc_command_line Dir.chdir(@project_dir) do mapfileStr = @mapfile ? " >#{@mapfile}" : "" rd, wr = IO.pipe ...
ruby
def convert_to_rake() object_multitask = prepare_tasks_for_objects() res = typed_file_task get_rake_task_type(), get_task_name => object_multitask do cmd = calc_command_line Dir.chdir(@project_dir) do mapfileStr = @mapfile ? " >#{@mapfile}" : "" rd, wr = IO.pipe ...
[ "def", "convert_to_rake", "(", ")", "object_multitask", "=", "prepare_tasks_for_objects", "(", ")", "res", "=", "typed_file_task", "get_rake_task_type", "(", ")", ",", "get_task_name", "=>", "object_multitask", "do", "cmd", "=", "calc_command_line", "Dir", ".", "chd...
create a task that will link an executable from a set of object files
[ "create", "a", "task", "that", "will", "link", "an", "executable", "from", "a", "set", "of", "object", "files" ]
3740a09d6a143acd96bde3d2ff79055a6b810da4
https://github.com/marcmo/cxxproject/blob/3740a09d6a143acd96bde3d2ff79055a6b810da4/lib/cxxproject/buildingblocks/linkable.rb#L181-L241
train
marcmo/cxxproject
lib/cxxproject/buildingblocks/linkable.rb
Cxxproject.SharedLibrary.post_link_hook
def post_link_hook(linker) basic_name = get_basic_name(linker) soname = get_soname(linker) symlink_lib_to basic_name symlink_lib_to soname end
ruby
def post_link_hook(linker) basic_name = get_basic_name(linker) soname = get_soname(linker) symlink_lib_to basic_name symlink_lib_to soname end
[ "def", "post_link_hook", "(", "linker", ")", "basic_name", "=", "get_basic_name", "(", "linker", ")", "soname", "=", "get_soname", "(", "linker", ")", "symlink_lib_to", "basic_name", "symlink_lib_to", "soname", "end" ]
Some symbolic links ln -s libfoo.so libfoo.1.2.so ln -s libfoo.1.so libfoo.1.2.so
[ "Some", "symbolic", "links", "ln", "-", "s", "libfoo", ".", "so", "libfoo", ".", "1", ".", "2", ".", "so", "ln", "-", "s", "libfoo", ".", "1", ".", "so", "libfoo", ".", "1", ".", "2", ".", "so" ]
3740a09d6a143acd96bde3d2ff79055a6b810da4
https://github.com/marcmo/cxxproject/blob/3740a09d6a143acd96bde3d2ff79055a6b810da4/lib/cxxproject/buildingblocks/linkable.rb#L355-L360
train