id
int32
0
24.9k
repo
stringlengths
5
58
path
stringlengths
9
168
func_name
stringlengths
9
130
original_string
stringlengths
66
10.5k
language
stringclasses
1 value
code
stringlengths
66
10.5k
code_tokens
list
docstring
stringlengths
8
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
94
266
4,200
scrapper/perobs
lib/perobs/FlatFileBlobHeader.rb
PEROBS.FlatFileBlobHeader.write
def write begin buf = [ @flags, @length, @id, @crc].pack(FORMAT) crc = Zlib.crc32(buf, 0) @file.seek(@addr) @file.write(buf + [ crc ].pack('L')) rescue IOError => e PEROBS.log.fatal "Cannot write blob header into flat file DB: " + e.message end end
ruby
def write begin buf = [ @flags, @length, @id, @crc].pack(FORMAT) crc = Zlib.crc32(buf, 0) @file.seek(@addr) @file.write(buf + [ crc ].pack('L')) rescue IOError => e PEROBS.log.fatal "Cannot write blob header into flat file DB: " + e.message end end
[ "def", "write", "begin", "buf", "=", "[", "@flags", ",", "@length", ",", "@id", ",", "@crc", "]", ".", "pack", "(", "FORMAT", ")", "crc", "=", "Zlib", ".", "crc32", "(", "buf", ",", "0", ")", "@file", ".", "seek", "(", "@addr", ")", "@file", "....
Write the header to a given File.
[ "Write", "the", "header", "to", "a", "given", "File", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/FlatFileBlobHeader.rb#L182-L192
4,201
jeffnyman/tapestry
lib/tapestry/extensions/dom_observer.rb
Watir.Element.dom_updated?
def dom_updated?(delay: 1.1) element_call do begin driver.manage.timeouts.script_timeout = delay + 1 driver.execute_async_script(DOM_OBSERVER, wd, delay) rescue Selenium::WebDriver::Error::StaleElementReferenceError # This situation can occur when the DOM changes betw...
ruby
def dom_updated?(delay: 1.1) element_call do begin driver.manage.timeouts.script_timeout = delay + 1 driver.execute_async_script(DOM_OBSERVER, wd, delay) rescue Selenium::WebDriver::Error::StaleElementReferenceError # This situation can occur when the DOM changes betw...
[ "def", "dom_updated?", "(", "delay", ":", "1.1", ")", "element_call", "do", "begin", "driver", ".", "manage", ".", "timeouts", ".", "script_timeout", "=", "delay", "+", "1", "driver", ".", "execute_async_script", "(", "DOM_OBSERVER", ",", "wd", ",", "delay",...
This method makes a call to `execute_async_script` which means that the DOM observer script must explicitly signal that it is finished by invoking a callback. In this case, the callback is nothing more than a delay. The delay is being used to allow the DOM to be updated before script actions continue. The method ...
[ "This", "method", "makes", "a", "call", "to", "execute_async_script", "which", "means", "that", "the", "DOM", "observer", "script", "must", "explicitly", "signal", "that", "it", "is", "finished", "by", "invoking", "a", "callback", ".", "In", "this", "case", ...
da28652dd6de71e415cd2c01afd89f641938a05b
https://github.com/jeffnyman/tapestry/blob/da28652dd6de71e415cd2c01afd89f641938a05b/lib/tapestry/extensions/dom_observer.rb#L46-L73
4,202
scrapper/perobs
lib/perobs/DataBase.rb
PEROBS.DataBase.serialize
def serialize(obj) begin case @serializer when :marshal Marshal.dump(obj) when :json obj.to_json when :yaml YAML.dump(obj) end rescue => e PEROBS.log.fatal "Cannot serialize object as #{@serializer}: " + e.message ...
ruby
def serialize(obj) begin case @serializer when :marshal Marshal.dump(obj) when :json obj.to_json when :yaml YAML.dump(obj) end rescue => e PEROBS.log.fatal "Cannot serialize object as #{@serializer}: " + e.message ...
[ "def", "serialize", "(", "obj", ")", "begin", "case", "@serializer", "when", ":marshal", "Marshal", ".", "dump", "(", "obj", ")", "when", ":json", "obj", ".", "to_json", "when", ":yaml", "YAML", ".", "dump", "(", "obj", ")", "end", "rescue", "=>", "e",...
Serialize the given object using the object serializer. @param obj [ObjectBase] Object to serialize @return [String] Serialized version
[ "Serialize", "the", "given", "object", "using", "the", "object", "serializer", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/DataBase.rb#L64-L78
4,203
scrapper/perobs
lib/perobs/DataBase.rb
PEROBS.DataBase.deserialize
def deserialize(raw) begin case @serializer when :marshal Marshal.load(raw) when :json JSON.parse(raw, :create_additions => true) when :yaml YAML.load(raw) end rescue => e PEROBS.log.fatal "Cannot de-serialize object with #{@seria...
ruby
def deserialize(raw) begin case @serializer when :marshal Marshal.load(raw) when :json JSON.parse(raw, :create_additions => true) when :yaml YAML.load(raw) end rescue => e PEROBS.log.fatal "Cannot de-serialize object with #{@seria...
[ "def", "deserialize", "(", "raw", ")", "begin", "case", "@serializer", "when", ":marshal", "Marshal", ".", "load", "(", "raw", ")", "when", ":json", "JSON", ".", "parse", "(", "raw", ",", ":create_additions", "=>", "true", ")", "when", ":yaml", "YAML", "...
De-serialize the given String into a Ruby object. @param raw [String] @return [Hash] Deserialized version
[ "De", "-", "serialize", "the", "given", "String", "into", "a", "Ruby", "object", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/DataBase.rb#L83-L97
4,204
scrapper/perobs
lib/perobs/DataBase.rb
PEROBS.DataBase.check_option
def check_option(name) value = instance_variable_get('@' + name) if @config.include?(name) # The database already existed and has a setting for this config # option. If it does not match the instance variable, adjust the # instance variable accordingly. unless @config[name] ...
ruby
def check_option(name) value = instance_variable_get('@' + name) if @config.include?(name) # The database already existed and has a setting for this config # option. If it does not match the instance variable, adjust the # instance variable accordingly. unless @config[name] ...
[ "def", "check_option", "(", "name", ")", "value", "=", "instance_variable_get", "(", "'@'", "+", "name", ")", "if", "@config", ".", "include?", "(", "name", ")", "# The database already existed and has a setting for this config", "# option. If it does not match the instance...
Check a config option and adjust it if needed. @param name [String] Name of the config option.
[ "Check", "a", "config", "option", "and", "adjust", "it", "if", "needed", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/DataBase.rb#L101-L116
4,205
scrapper/perobs
lib/perobs/DataBase.rb
PEROBS.DataBase.ensure_dir_exists
def ensure_dir_exists(dir) unless Dir.exist?(dir) begin Dir.mkdir(dir) rescue IOError => e PEROBS.log.fatal "Cannote create DB directory '#{dir}': #{e.message}" end end end
ruby
def ensure_dir_exists(dir) unless Dir.exist?(dir) begin Dir.mkdir(dir) rescue IOError => e PEROBS.log.fatal "Cannote create DB directory '#{dir}': #{e.message}" end end end
[ "def", "ensure_dir_exists", "(", "dir", ")", "unless", "Dir", ".", "exist?", "(", "dir", ")", "begin", "Dir", ".", "mkdir", "(", "dir", ")", "rescue", "IOError", "=>", "e", "PEROBS", ".", "log", ".", "fatal", "\"Cannote create DB directory '#{dir}': #{e.messag...
Ensure that we have a directory to store the DB items.
[ "Ensure", "that", "we", "have", "a", "directory", "to", "store", "the", "DB", "items", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/DataBase.rb#L121-L129
4,206
xinminlabs/synvert-core
lib/synvert/core/rewriter/gem_spec.rb
Synvert::Core.Rewriter::GemSpec.match?
def match? gemfile_lock_path = File.join(Configuration.instance.get(:path), 'Gemfile.lock') if File.exists? gemfile_lock_path parser = Bundler::LockfileParser.new(File.read(gemfile_lock_path)) if spec = parser.specs.find { |spec| spec.name == @name } Gem::Version.new(spec.version)....
ruby
def match? gemfile_lock_path = File.join(Configuration.instance.get(:path), 'Gemfile.lock') if File.exists? gemfile_lock_path parser = Bundler::LockfileParser.new(File.read(gemfile_lock_path)) if spec = parser.specs.find { |spec| spec.name == @name } Gem::Version.new(spec.version)....
[ "def", "match?", "gemfile_lock_path", "=", "File", ".", "join", "(", "Configuration", ".", "instance", ".", "get", "(", ":path", ")", ",", "'Gemfile.lock'", ")", "if", "File", ".", "exists?", "gemfile_lock_path", "parser", "=", "Bundler", "::", "LockfileParser...
Initialize a gem_spec. @param name [String] gem name @param comparator [Hash] comparator to gem version, e.g. {eq: '2.0.0'}, comparator key can be eq, lt, gt, lte, gte or ne. Check if the specified gem version in Gemfile.lock matches gem_spec comparator. @return [Boolean] true if matches, otherwise false. @ra...
[ "Initialize", "a", "gem_spec", "." ]
a490bfd30eaec81002d10f8fb61b49138708e46c
https://github.com/xinminlabs/synvert-core/blob/a490bfd30eaec81002d10f8fb61b49138708e46c/lib/synvert/core/rewriter/gem_spec.rb#L28-L40
4,207
sethvargo/community-zero
lib/community_zero/endpoints/cookbook_versions_version_endpoint.rb
CommunityZero.CookbookVersionsVersionEndpoint.response_hash_for
def response_hash_for(cookbook) { 'cookbook' => url_for(cookbook), 'average_rating' => cookbook.average_rating, 'version' => cookbook.version, 'license' => cookbook.license, 'file' => "http://s3.amazonaws.com/#{c...
ruby
def response_hash_for(cookbook) { 'cookbook' => url_for(cookbook), 'average_rating' => cookbook.average_rating, 'version' => cookbook.version, 'license' => cookbook.license, 'file' => "http://s3.amazonaws.com/#{c...
[ "def", "response_hash_for", "(", "cookbook", ")", "{", "'cookbook'", "=>", "url_for", "(", "cookbook", ")", ",", "'average_rating'", "=>", "cookbook", ".", "average_rating", ",", "'version'", "=>", "cookbook", ".", "version", ",", "'license'", "=>", "cookbook", ...
The response hash for this cookbook. @param [CommunityZero::Cookbook] cookbook the cookbook to generate a hash for
[ "The", "response", "hash", "for", "this", "cookbook", "." ]
08a22c47c865deb6a5f931cb4d9f747a2b9d3459
https://github.com/sethvargo/community-zero/blob/08a22c47c865deb6a5f931cb4d9f747a2b9d3459/lib/community_zero/endpoints/cookbook_versions_version_endpoint.rb#L45-L56
4,208
notonthehighstreet/chicago
lib/chicago/query.rb
Chicago.Query.order
def order(*ordering) @order = ordering.map do |c| if c.kind_of?(String) {:column => c, :ascending => true} else c.symbolize_keys! end end self end
ruby
def order(*ordering) @order = ordering.map do |c| if c.kind_of?(String) {:column => c, :ascending => true} else c.symbolize_keys! end end self end
[ "def", "order", "(", "*", "ordering", ")", "@order", "=", "ordering", ".", "map", "do", "|", "c", "|", "if", "c", ".", "kind_of?", "(", "String", ")", "{", ":column", "=>", "c", ",", ":ascending", "=>", "true", "}", "else", "c", ".", "symbolize_key...
Order the results by the specified columns. @param ordering an array of hashes, of the form {:column => "name", :ascending => true} @api public
[ "Order", "the", "results", "by", "the", "specified", "columns", "." ]
428e94f8089d2f36fdcff2e27ea2af572b816def
https://github.com/notonthehighstreet/chicago/blob/428e94f8089d2f36fdcff2e27ea2af572b816def/lib/chicago/query.rb#L79-L88
4,209
scrapper/perobs
lib/perobs/StackFile.rb
PEROBS.StackFile.close
def close begin @f.flush @f.flock(File::LOCK_UN) @f.close rescue IOError => e PEROBS.log.fatal "Cannot close stack file #{@file_name}: #{e.message}" end end
ruby
def close begin @f.flush @f.flock(File::LOCK_UN) @f.close rescue IOError => e PEROBS.log.fatal "Cannot close stack file #{@file_name}: #{e.message}" end end
[ "def", "close", "begin", "@f", ".", "flush", "@f", ".", "flock", "(", "File", "::", "LOCK_UN", ")", "@f", ".", "close", "rescue", "IOError", "=>", "e", "PEROBS", ".", "log", ".", "fatal", "\"Cannot close stack file #{@file_name}: #{e.message}\"", "end", "end" ...
Close the stack file. This method must be called before the program is terminated to avoid data loss.
[ "Close", "the", "stack", "file", ".", "This", "method", "must", "be", "called", "before", "the", "program", "is", "terminated", "to", "avoid", "data", "loss", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/StackFile.rb#L64-L72
4,210
scrapper/perobs
lib/perobs/StackFile.rb
PEROBS.StackFile.push
def push(bytes) if bytes.length != @entry_bytes PEROBS.log.fatal "All stack entries must be #{@entry_bytes} " + "long. This entry is #{bytes.length} bytes long." end begin @f.seek(0, IO::SEEK_END) @f.write(bytes) rescue => e PEROBS.log.fatal "Cannot push...
ruby
def push(bytes) if bytes.length != @entry_bytes PEROBS.log.fatal "All stack entries must be #{@entry_bytes} " + "long. This entry is #{bytes.length} bytes long." end begin @f.seek(0, IO::SEEK_END) @f.write(bytes) rescue => e PEROBS.log.fatal "Cannot push...
[ "def", "push", "(", "bytes", ")", "if", "bytes", ".", "length", "!=", "@entry_bytes", "PEROBS", ".", "log", ".", "fatal", "\"All stack entries must be #{@entry_bytes} \"", "+", "\"long. This entry is #{bytes.length} bytes long.\"", "end", "begin", "@f", ".", "seek", "...
Push the given bytes onto the stack file. @param bytes [String] Bytes to write.
[ "Push", "the", "given", "bytes", "onto", "the", "stack", "file", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/StackFile.rb#L85-L96
4,211
scrapper/perobs
lib/perobs/StackFile.rb
PEROBS.StackFile.pop
def pop begin return nil if @f.size == 0 @f.seek(-@entry_bytes, IO::SEEK_END) bytes = @f.read(@entry_bytes) @f.truncate(@f.size - @entry_bytes) @f.flush rescue => e PEROBS.log.fatal "Cannot pop from stack file #{@file_name}: " + e.message end ...
ruby
def pop begin return nil if @f.size == 0 @f.seek(-@entry_bytes, IO::SEEK_END) bytes = @f.read(@entry_bytes) @f.truncate(@f.size - @entry_bytes) @f.flush rescue => e PEROBS.log.fatal "Cannot pop from stack file #{@file_name}: " + e.message end ...
[ "def", "pop", "begin", "return", "nil", "if", "@f", ".", "size", "==", "0", "@f", ".", "seek", "(", "-", "@entry_bytes", ",", "IO", "::", "SEEK_END", ")", "bytes", "=", "@f", ".", "read", "(", "@entry_bytes", ")", "@f", ".", "truncate", "(", "@f", ...
Pop the last entry from the stack file. @return [String or nil] Popped entry or nil if stack is already empty.
[ "Pop", "the", "last", "entry", "from", "the", "stack", "file", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/StackFile.rb#L100-L114
4,212
tagoh/ruby-bugzilla
lib/bugzilla/bug.rb
Bugzilla.Bug.get_comments
def get_comments(bugs) params = {} if bugs.kind_of?(Array) then params['ids'] = bugs elsif bugs.kind_of?(Integer) || bugs.kind_of?(String) then params['ids'] = [bugs] else raise ArgumentError, sprintf("Unknown type of arguments: %s", bugs.class) end ...
ruby
def get_comments(bugs) params = {} if bugs.kind_of?(Array) then params['ids'] = bugs elsif bugs.kind_of?(Integer) || bugs.kind_of?(String) then params['ids'] = [bugs] else raise ArgumentError, sprintf("Unknown type of arguments: %s", bugs.class) end ...
[ "def", "get_comments", "(", "bugs", ")", "params", "=", "{", "}", "if", "bugs", ".", "kind_of?", "(", "Array", ")", "then", "params", "[", "'ids'", "]", "=", "bugs", "elsif", "bugs", ".", "kind_of?", "(", "Integer", ")", "||", "bugs", ".", "kind_of?"...
def get_bugs =begin rdoc ==== Bugzilla::Bug#get_comments(bugs) =end
[ "def", "get_bugs", "=", "begin", "rdoc" ]
5aabec1b045473bcd6e6ac7427b68adb3e3b4886
https://github.com/tagoh/ruby-bugzilla/blob/5aabec1b045473bcd6e6ac7427b68adb3e3b4886/lib/bugzilla/bug.rb#L107-L123
4,213
jeffnyman/tapestry
lib/tapestry/ready.rb
Tapestry.Ready.when_ready
def when_ready(simple_check = false, &_block) already_marked_ready = ready unless simple_check no_ready_check_possible unless block_given? end self.ready = ready? not_ready_validation(ready_error || 'NO REASON PROVIDED') unless ready yield self if block_given? ensure ...
ruby
def when_ready(simple_check = false, &_block) already_marked_ready = ready unless simple_check no_ready_check_possible unless block_given? end self.ready = ready? not_ready_validation(ready_error || 'NO REASON PROVIDED') unless ready yield self if block_given? ensure ...
[ "def", "when_ready", "(", "simple_check", "=", "false", ",", "&", "_block", ")", "already_marked_ready", "=", "ready", "unless", "simple_check", "no_ready_check_possible", "unless", "block_given?", "end", "self", ".", "ready", "=", "ready?", "not_ready_validation", ...
The `when_ready` method is called on an instance of an interface. This executes the provided validation block after the page has been loaded. The Ready object instance is yielded into the block. Calls to the `ready?` method use a poor-man's cache approach. The idea here being that when a page has confirmed that it...
[ "The", "when_ready", "method", "is", "called", "on", "an", "instance", "of", "an", "interface", ".", "This", "executes", "the", "provided", "validation", "block", "after", "the", "page", "has", "been", "loaded", ".", "The", "Ready", "object", "instance", "is...
da28652dd6de71e415cd2c01afd89f641938a05b
https://github.com/jeffnyman/tapestry/blob/da28652dd6de71e415cd2c01afd89f641938a05b/lib/tapestry/ready.rb#L55-L68
4,214
jeffnyman/tapestry
lib/tapestry/ready.rb
Tapestry.Ready.ready_validations_pass?
def ready_validations_pass? self.class.ready_validations.all? do |validation| passed, message = instance_eval(&validation) self.ready_error = message if message && !passed passed end end
ruby
def ready_validations_pass? self.class.ready_validations.all? do |validation| passed, message = instance_eval(&validation) self.ready_error = message if message && !passed passed end end
[ "def", "ready_validations_pass?", "self", ".", "class", ".", "ready_validations", ".", "all?", "do", "|", "validation", "|", "passed", ",", "message", "=", "instance_eval", "(", "validation", ")", "self", ".", "ready_error", "=", "message", "if", "message", "&...
This method checks if the ready validations that have been specified have passed. If any ready validation fails, no matter if others have succeeded, this method immediately returns false.
[ "This", "method", "checks", "if", "the", "ready", "validations", "that", "have", "been", "specified", "have", "passed", ".", "If", "any", "ready", "validation", "fails", "no", "matter", "if", "others", "have", "succeeded", "this", "method", "immediately", "ret...
da28652dd6de71e415cd2c01afd89f641938a05b
https://github.com/jeffnyman/tapestry/blob/da28652dd6de71e415cd2c01afd89f641938a05b/lib/tapestry/ready.rb#L92-L98
4,215
xinminlabs/synvert-core
lib/synvert/core/rewriter/condition/unless_exist_condition.rb
Synvert::Core.Rewriter::UnlessExistCondition.match?
def match? match = false @instance.current_node.recursive_children do |child_node| match = match || (child_node && child_node.match?(@rules)) end !match end
ruby
def match? match = false @instance.current_node.recursive_children do |child_node| match = match || (child_node && child_node.match?(@rules)) end !match end
[ "def", "match?", "match", "=", "false", "@instance", ".", "current_node", ".", "recursive_children", "do", "|", "child_node", "|", "match", "=", "match", "||", "(", "child_node", "&&", "child_node", ".", "match?", "(", "@rules", ")", ")", "end", "!", "matc...
check if none of child node matches the rules.
[ "check", "if", "none", "of", "child", "node", "matches", "the", "rules", "." ]
a490bfd30eaec81002d10f8fb61b49138708e46c
https://github.com/xinminlabs/synvert-core/blob/a490bfd30eaec81002d10f8fb61b49138708e46c/lib/synvert/core/rewriter/condition/unless_exist_condition.rb#L7-L13
4,216
pupeno/random_unique_id
lib/random_unique_id.rb
RandomUniqueId.ClassMethods.add_rid_related_validations
def add_rid_related_validations(options) validates(options[:field], presence: true) validates(options[:field], uniqueness: true) if options[:random_generation_method] != :uuid # If we're generating UUIDs, don't check for uniqueness end
ruby
def add_rid_related_validations(options) validates(options[:field], presence: true) validates(options[:field], uniqueness: true) if options[:random_generation_method] != :uuid # If we're generating UUIDs, don't check for uniqueness end
[ "def", "add_rid_related_validations", "(", "options", ")", "validates", "(", "options", "[", ":field", "]", ",", "presence", ":", "true", ")", "validates", "(", "options", "[", ":field", "]", ",", "uniqueness", ":", "true", ")", "if", "options", "[", ":ran...
Add the rid related validations to the model. @param options [Hash] same as in RandomUniqueID.config
[ "Add", "the", "rid", "related", "validations", "to", "the", "model", "." ]
bab61f23a17a3f6ba9f7bc255805d4f9d34b8bfc
https://github.com/pupeno/random_unique_id/blob/bab61f23a17a3f6ba9f7bc255805d4f9d34b8bfc/lib/random_unique_id.rb#L118-L121
4,217
pupeno/random_unique_id
lib/random_unique_id.rb
RandomUniqueId.ClassMethods.define_rid_accessors
def define_rid_accessors(related_class, relationship_name) define_method("#{relationship_name}_rid") do self.send(relationship_name).try(random_unique_id_options[:field]) end define_method("#{relationship_name}_rid=") do |rid| record = related_class.find_by_rid(rid) self.send(...
ruby
def define_rid_accessors(related_class, relationship_name) define_method("#{relationship_name}_rid") do self.send(relationship_name).try(random_unique_id_options[:field]) end define_method("#{relationship_name}_rid=") do |rid| record = related_class.find_by_rid(rid) self.send(...
[ "def", "define_rid_accessors", "(", "related_class", ",", "relationship_name", ")", "define_method", "(", "\"#{relationship_name}_rid\"", ")", "do", "self", ".", "send", "(", "relationship_name", ")", ".", "try", "(", "random_unique_id_options", "[", ":field", "]", ...
Defines the setter and getter for the RID of a relationship. @param related_class [Class] class in which the RID methods are going to be defined. @param relationship_name [String] name of the relationship for which the RID methods are going to be defined. @see RandomUniqueId::ClassMethods.belongs_to
[ "Defines", "the", "setter", "and", "getter", "for", "the", "RID", "of", "a", "relationship", "." ]
bab61f23a17a3f6ba9f7bc255805d4f9d34b8bfc
https://github.com/pupeno/random_unique_id/blob/bab61f23a17a3f6ba9f7bc255805d4f9d34b8bfc/lib/random_unique_id.rb#L128-L138
4,218
code-and-effect/effective_pages
app/models/effective/menu.rb
Effective.Menu.build
def build(&block) raise 'build must be called with a block' if !block_given? root = menu_items.build(title: 'Home', url: '/', lft: 1, rgt: 2) root.parent = true instance_exec(&block) # A call to dropdown or item root.rgt = menu_items.map(&:rgt).max self end
ruby
def build(&block) raise 'build must be called with a block' if !block_given? root = menu_items.build(title: 'Home', url: '/', lft: 1, rgt: 2) root.parent = true instance_exec(&block) # A call to dropdown or item root.rgt = menu_items.map(&:rgt).max self end
[ "def", "build", "(", "&", "block", ")", "raise", "'build must be called with a block'", "if", "!", "block_given?", "root", "=", "menu_items", ".", "build", "(", "title", ":", "'Home'", ",", "url", ":", "'/'", ",", "lft", ":", "1", ",", "rgt", ":", "2", ...
This is the entry point to the DSL method for creating menu items
[ "This", "is", "the", "entry", "point", "to", "the", "DSL", "method", "for", "creating", "menu", "items" ]
ff00e2d76055985ab65f570747bc9a5f2748f817
https://github.com/code-and-effect/effective_pages/blob/ff00e2d76055985ab65f570747bc9a5f2748f817/app/models/effective/menu.rb#L58-L66
4,219
scrapper/perobs
lib/perobs/BTreeNode.rb
PEROBS.BTreeNode.search_key_index
def search_key_index(key) # Handle special case for empty keys list. return 0 if @keys.empty? # Keys are unique and always sorted. Use a binary search to find the # index that fits the given key. li = pi = 0 ui = @keys.size - 1 while li <= ui # The pivot element is alw...
ruby
def search_key_index(key) # Handle special case for empty keys list. return 0 if @keys.empty? # Keys are unique and always sorted. Use a binary search to find the # index that fits the given key. li = pi = 0 ui = @keys.size - 1 while li <= ui # The pivot element is alw...
[ "def", "search_key_index", "(", "key", ")", "# Handle special case for empty keys list.", "return", "0", "if", "@keys", ".", "empty?", "# Keys are unique and always sorted. Use a binary search to find the", "# index that fits the given key.", "li", "=", "pi", "=", "0", "ui", ...
Search the keys of the node that fits the given key. The result is either the index of an exact match or the index of the position where the given key would have to be inserted. @param key [Integer] key to search for @return [Integer] Index of the matching key or the insert position.
[ "Search", "the", "keys", "of", "the", "node", "that", "fits", "the", "given", "key", ".", "The", "result", "is", "either", "the", "index", "of", "an", "exact", "match", "or", "the", "index", "of", "the", "position", "where", "the", "given", "key", "wou...
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/BTreeNode.rb#L563-L594
4,220
astro/ruby-sasl
lib/sasl/digest_md5.rb
SASL.DigestMD5.response_value
def response_value(nonce, nc, cnonce, qop, a2_prefix='AUTHENTICATE') a1_h = h("#{preferences.username}:#{preferences.realm}:#{preferences.password}") a1 = "#{a1_h}:#{nonce}:#{cnonce}" if preferences.authzid a1 += ":#{preferences.authzid}" end if qop && (qop.downcase == 'auth-int' |...
ruby
def response_value(nonce, nc, cnonce, qop, a2_prefix='AUTHENTICATE') a1_h = h("#{preferences.username}:#{preferences.realm}:#{preferences.password}") a1 = "#{a1_h}:#{nonce}:#{cnonce}" if preferences.authzid a1 += ":#{preferences.authzid}" end if qop && (qop.downcase == 'auth-int' |...
[ "def", "response_value", "(", "nonce", ",", "nc", ",", "cnonce", ",", "qop", ",", "a2_prefix", "=", "'AUTHENTICATE'", ")", "a1_h", "=", "h", "(", "\"#{preferences.username}:#{preferences.realm}:#{preferences.password}\"", ")", "a1", "=", "\"#{a1_h}:#{nonce}:#{cnonce}\""...
Calculate the value for the response field
[ "Calculate", "the", "value", "for", "the", "response", "field" ]
e54d8950c9cfb6a51066fcbbe3ada9f0121aa7f4
https://github.com/astro/ruby-sasl/blob/e54d8950c9cfb6a51066fcbbe3ada9f0121aa7f4/lib/sasl/digest_md5.rb#L139-L151
4,221
regru/reg_api2-ruby
lib/reg_api2/request_contract.rb
RegApi2.RequestContract.to_hash
def to_hash arr return {} if arr.nil? return arr if arr.kind_of?(Hash) arr = [ arr.to_sym ] unless arr.kind_of?(Array) ret = {} arr.each { |key| ret[key.to_sym] = {} } ret end
ruby
def to_hash arr return {} if arr.nil? return arr if arr.kind_of?(Hash) arr = [ arr.to_sym ] unless arr.kind_of?(Array) ret = {} arr.each { |key| ret[key.to_sym] = {} } ret end
[ "def", "to_hash", "arr", "return", "{", "}", "if", "arr", ".", "nil?", "return", "arr", "if", "arr", ".", "kind_of?", "(", "Hash", ")", "arr", "=", "[", "arr", ".", "to_sym", "]", "unless", "arr", ".", "kind_of?", "(", "Array", ")", "ret", "=", "...
Normalizes `required` and `optional` fields to the form of Hash with options. @param [NilClass,Hash,Array, etc.] arr Something to normalize.
[ "Normalizes", "required", "and", "optional", "fields", "to", "the", "form", "of", "Hash", "with", "options", "." ]
82fadffc9da6534761003b8a33edb77ab617df70
https://github.com/regru/reg_api2-ruby/blob/82fadffc9da6534761003b8a33edb77ab617df70/lib/reg_api2/request_contract.rb#L21-L28
4,222
regru/reg_api2-ruby
lib/reg_api2/request_contract.rb
RegApi2.RequestContract.fields_to_validate
def fields_to_validate required_fields = to_hash opts[:required] optional_fields = to_hash opts[:optional] required_fields.keys.each { |key| required_fields[key][:required] = true } optional_fields.merge(required_fields) end
ruby
def fields_to_validate required_fields = to_hash opts[:required] optional_fields = to_hash opts[:optional] required_fields.keys.each { |key| required_fields[key][:required] = true } optional_fields.merge(required_fields) end
[ "def", "fields_to_validate", "required_fields", "=", "to_hash", "opts", "[", ":required", "]", "optional_fields", "=", "to_hash", "opts", "[", ":optional", "]", "required_fields", ".", "keys", ".", "each", "{", "|", "key", "|", "required_fields", "[", "key", "...
Gets fields to validate @return [Hash] Fields to validate.
[ "Gets", "fields", "to", "validate" ]
82fadffc9da6534761003b8a33edb77ab617df70
https://github.com/regru/reg_api2-ruby/blob/82fadffc9da6534761003b8a33edb77ab617df70/lib/reg_api2/request_contract.rb#L32-L37
4,223
regru/reg_api2-ruby
lib/reg_api2/request_contract.rb
RegApi2.RequestContract.validate_ipaddr
def validate_ipaddr key, value, opts if opts[:ipaddr] == true && value.kind_of?(String) value = IPAddr.new(value) end value.to_s end
ruby
def validate_ipaddr key, value, opts if opts[:ipaddr] == true && value.kind_of?(String) value = IPAddr.new(value) end value.to_s end
[ "def", "validate_ipaddr", "key", ",", "value", ",", "opts", "if", "opts", "[", ":ipaddr", "]", "==", "true", "&&", "value", ".", "kind_of?", "(", "String", ")", "value", "=", "IPAddr", ".", "new", "(", "value", ")", "end", "value", ".", "to_s", "end"...
Validates specified `value` with `ipaddr` field. @param [Object] key Value to validate. @param [Object] value Value to validate. @param [Hash] opts opts with optional ipaddr field. @return [String] Updated `value`
[ "Validates", "specified", "value", "with", "ipaddr", "field", "." ]
82fadffc9da6534761003b8a33edb77ab617df70
https://github.com/regru/reg_api2-ruby/blob/82fadffc9da6534761003b8a33edb77ab617df70/lib/reg_api2/request_contract.rb#L73-L78
4,224
regru/reg_api2-ruby
lib/reg_api2/request_contract.rb
RegApi2.RequestContract.validate_presence_of_required_fields
def validate_presence_of_required_fields form, fields absent_fields = [] fields.each_pair do |key, opts| next unless opts[:required] if !form.has_key?(key) || form[key].nil? absent_fields << key end end unless absent_fields.empty? raise RegApi2::Contrac...
ruby
def validate_presence_of_required_fields form, fields absent_fields = [] fields.each_pair do |key, opts| next unless opts[:required] if !form.has_key?(key) || form[key].nil? absent_fields << key end end unless absent_fields.empty? raise RegApi2::Contrac...
[ "def", "validate_presence_of_required_fields", "form", ",", "fields", "absent_fields", "=", "[", "]", "fields", ".", "each_pair", "do", "|", "key", ",", "opts", "|", "next", "unless", "opts", "[", ":required", "]", "if", "!", "form", ".", "has_key?", "(", ...
Validates specified `form` for presence of all required fields. @param [Hash] form Form to validate. @param [Hash] fields Fields to test. return void @raise ContractError
[ "Validates", "specified", "form", "for", "presence", "of", "all", "required", "fields", "." ]
82fadffc9da6534761003b8a33edb77ab617df70
https://github.com/regru/reg_api2-ruby/blob/82fadffc9da6534761003b8a33edb77ab617df70/lib/reg_api2/request_contract.rb#L85-L100
4,225
regru/reg_api2-ruby
lib/reg_api2/request_contract.rb
RegApi2.RequestContract.validate
def validate(form) fields = fields_to_validate return form if fields.empty? validate_presence_of_required_fields form, fields fields.each_pair do |key, opts| next if !form.has_key?(key) || form[key].nil? form[key] = validate_re key, form[key], opts form[key] = valida...
ruby
def validate(form) fields = fields_to_validate return form if fields.empty? validate_presence_of_required_fields form, fields fields.each_pair do |key, opts| next if !form.has_key?(key) || form[key].nil? form[key] = validate_re key, form[key], opts form[key] = valida...
[ "def", "validate", "(", "form", ")", "fields", "=", "fields_to_validate", "return", "form", "if", "fields", ".", "empty?", "validate_presence_of_required_fields", "form", ",", "fields", "fields", ".", "each_pair", "do", "|", "key", ",", "opts", "|", "next", "i...
Validates specified `form` with `required` and `optional` fields. @param [Hash] form Form to validate. @return [Hash] Updated form. @raise ContractError
[ "Validates", "specified", "form", "with", "required", "and", "optional", "fields", "." ]
82fadffc9da6534761003b8a33edb77ab617df70
https://github.com/regru/reg_api2-ruby/blob/82fadffc9da6534761003b8a33edb77ab617df70/lib/reg_api2/request_contract.rb#L106-L121
4,226
scrapper/perobs
lib/perobs/BigTreeNode.rb
PEROBS.BigTreeNode.has_key?
def has_key?(key) node = self while node do # Find index of the entry that best fits the key. i = node.search_key_index(key) if node.is_leaf? # This is a leaf node. Check if there is an exact match for the # given key and return the corresponding value or nil. ...
ruby
def has_key?(key) node = self while node do # Find index of the entry that best fits the key. i = node.search_key_index(key) if node.is_leaf? # This is a leaf node. Check if there is an exact match for the # given key and return the corresponding value or nil. ...
[ "def", "has_key?", "(", "key", ")", "node", "=", "self", "while", "node", "do", "# Find index of the entry that best fits the key.", "i", "=", "node", ".", "search_key_index", "(", "key", ")", "if", "node", ".", "is_leaf?", "# This is a leaf node. Check if there is an...
Return if given key is stored in the node. @param key [Integer] key to search for @return [Boolean] True if key was found, false otherwise
[ "Return", "if", "given", "key", "is", "stored", "in", "the", "node", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/BigTreeNode.rb#L169-L187
4,227
scrapper/perobs
lib/perobs/BigTreeNode.rb
PEROBS.BigTreeNode.remove_element
def remove_element(index) # Delete the key at the specified index. unless (key = @keys.delete_at(index)) PEROBS.log.fatal "Could not remove element #{index} from BigTreeNode " + "@#{@_id}" end update_branch_key(key) if index == 0 # Delete the corresponding value. r...
ruby
def remove_element(index) # Delete the key at the specified index. unless (key = @keys.delete_at(index)) PEROBS.log.fatal "Could not remove element #{index} from BigTreeNode " + "@#{@_id}" end update_branch_key(key) if index == 0 # Delete the corresponding value. r...
[ "def", "remove_element", "(", "index", ")", "# Delete the key at the specified index.", "unless", "(", "key", "=", "@keys", ".", "delete_at", "(", "index", ")", ")", "PEROBS", ".", "log", ".", "fatal", "\"Could not remove element #{index} from BigTreeNode \"", "+", "\...
Remove the element from a leaf node at the given index. @param index [Integer] The index of the entry to be removed @return [Object] The removed value
[ "Remove", "the", "element", "from", "a", "leaf", "node", "at", "the", "given", "index", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/BigTreeNode.rb#L518-L543
4,228
scrapper/perobs
lib/perobs/BigTreeNode.rb
PEROBS.BigTreeNode.remove_child
def remove_child(node) unless (index = search_node_index(node)) PEROBS.log.fatal "Cannot remove child #{node._id} from node #{@_id}" end if index == 0 # Removing the first child is a bit more complicated as the # corresponding branch key is in a parent node. key = @key...
ruby
def remove_child(node) unless (index = search_node_index(node)) PEROBS.log.fatal "Cannot remove child #{node._id} from node #{@_id}" end if index == 0 # Removing the first child is a bit more complicated as the # corresponding branch key is in a parent node. key = @key...
[ "def", "remove_child", "(", "node", ")", "unless", "(", "index", "=", "search_node_index", "(", "node", ")", ")", "PEROBS", ".", "log", ".", "fatal", "\"Cannot remove child #{node._id} from node #{@_id}\"", "end", "if", "index", "==", "0", "# Removing the first chil...
Remove the specified node from this branch node. @param node [BigTreeNode] The child to remove
[ "Remove", "the", "specified", "node", "from", "this", "branch", "node", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/BigTreeNode.rb#L547-L591
4,229
scrapper/perobs
lib/perobs/BigTreeNode.rb
PEROBS.BigTreeNode.statistics
def statistics(stats) traverse do |node, position, stack| if position == 0 if node.is_leaf? stats.leaf_nodes += 1 depth = stack.size + 1 if stats.min_depth.nil? || stats.min_depth < depth stats.min_depth = depth end if sta...
ruby
def statistics(stats) traverse do |node, position, stack| if position == 0 if node.is_leaf? stats.leaf_nodes += 1 depth = stack.size + 1 if stats.min_depth.nil? || stats.min_depth < depth stats.min_depth = depth end if sta...
[ "def", "statistics", "(", "stats", ")", "traverse", "do", "|", "node", ",", "position", ",", "stack", "|", "if", "position", "==", "0", "if", "node", ".", "is_leaf?", "stats", ".", "leaf_nodes", "+=", "1", "depth", "=", "stack", ".", "size", "+", "1"...
Gather some statistics about the node and all sub nodes. @param stats [Stats] Data structure that stores the gathered data
[ "Gather", "some", "statistics", "about", "the", "node", "and", "all", "sub", "nodes", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/BigTreeNode.rb#L702-L719
4,230
scrapper/perobs
lib/perobs/BTreeDB.rb
PEROBS.BTreeDB.include?
def include?(id) !(blob = find_blob(id)).nil? && !blob.find(id).nil? end
ruby
def include?(id) !(blob = find_blob(id)).nil? && !blob.find(id).nil? end
[ "def", "include?", "(", "id", ")", "!", "(", "blob", "=", "find_blob", "(", "id", ")", ")", ".", "nil?", "&&", "!", "blob", ".", "find", "(", "id", ")", ".", "nil?", "end" ]
Return true if the object with given ID exists @param id [Integer]
[ "Return", "true", "if", "the", "object", "with", "given", "ID", "exists" ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/BTreeDB.rb#L107-L109
4,231
scrapper/perobs
lib/perobs/BTreeDB.rb
PEROBS.BTreeDB.get_object
def get_object(id) return nil unless (blob = find_blob(id)) && (obj = blob.read_object(id)) deserialize(obj) end
ruby
def get_object(id) return nil unless (blob = find_blob(id)) && (obj = blob.read_object(id)) deserialize(obj) end
[ "def", "get_object", "(", "id", ")", "return", "nil", "unless", "(", "blob", "=", "find_blob", "(", "id", ")", ")", "&&", "(", "obj", "=", "blob", ".", "read_object", "(", "id", ")", ")", "deserialize", "(", "obj", ")", "end" ]
Load the given object from the filesystem. @param id [Integer] object ID @return [Hash] Object as defined by PEROBS::ObjectBase or nil if ID does not exist
[ "Load", "the", "given", "object", "from", "the", "filesystem", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/BTreeDB.rb#L149-L152
4,232
scrapper/perobs
lib/perobs/BTreeDB.rb
PEROBS.BTreeDB.is_marked?
def is_marked?(id, ignore_errors = false) (blob = find_blob(id)) && blob.is_marked?(id, ignore_errors) end
ruby
def is_marked?(id, ignore_errors = false) (blob = find_blob(id)) && blob.is_marked?(id, ignore_errors) end
[ "def", "is_marked?", "(", "id", ",", "ignore_errors", "=", "false", ")", "(", "blob", "=", "find_blob", "(", "id", ")", ")", "&&", "blob", ".", "is_marked?", "(", "id", ",", "ignore_errors", ")", "end" ]
Check if the object is marked. @param id [Integer] ID of the object to check @param ignore_errors [Boolean] If set to true no errors will be raised for non-existing objects.
[ "Check", "if", "the", "object", "is", "marked", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/BTreeDB.rb#L178-L180
4,233
dalehamel/cloudshaper
lib/cloudshaper/command.rb
Cloudshaper.Command.env
def env vars = {} @stack.variables.each { |k, v| vars["TF_VAR_#{k}"] = v } SECRETS.each do |_provider, secrets| if secrets.is_a?(Hash) secrets.each do |k, v| vars[k.to_s] = v end end end vars end
ruby
def env vars = {} @stack.variables.each { |k, v| vars["TF_VAR_#{k}"] = v } SECRETS.each do |_provider, secrets| if secrets.is_a?(Hash) secrets.each do |k, v| vars[k.to_s] = v end end end vars end
[ "def", "env", "vars", "=", "{", "}", "@stack", ".", "variables", ".", "each", "{", "|", "k", ",", "v", "|", "vars", "[", "\"TF_VAR_#{k}\"", "]", "=", "v", "}", "SECRETS", ".", "each", "do", "|", "_provider", ",", "secrets", "|", "if", "secrets", ...
fixme - make these shell safe
[ "fixme", "-", "make", "these", "shell", "safe" ]
bcfeb18fd9853f782b7aa81ebe3f84d69e17e5b4
https://github.com/dalehamel/cloudshaper/blob/bcfeb18fd9853f782b7aa81ebe3f84d69e17e5b4/lib/cloudshaper/command.rb#L14-L25
4,234
sethvargo/community-zero
lib/community_zero/store.rb
CommunityZero.Store.search
def search(query) regex = Regexp.new(query, 'i') _cookbooks.collect do |_, v| v[v.keys.first] if regex.match(v[v.keys.first].name) end.compact end
ruby
def search(query) regex = Regexp.new(query, 'i') _cookbooks.collect do |_, v| v[v.keys.first] if regex.match(v[v.keys.first].name) end.compact end
[ "def", "search", "(", "query", ")", "regex", "=", "Regexp", ".", "new", "(", "query", ",", "'i'", ")", "_cookbooks", ".", "collect", "do", "|", "_", ",", "v", "|", "v", "[", "v", ".", "keys", ".", "first", "]", "if", "regex", ".", "match", "(",...
Query the installed cookbooks, returning those who's name matches the given query. @param [String] query the query parameter @return [Array<CommunityZero::Cookbook>] the list of cookbooks that match the given query
[ "Query", "the", "installed", "cookbooks", "returning", "those", "who", "s", "name", "matches", "the", "given", "query", "." ]
08a22c47c865deb6a5f931cb4d9f747a2b9d3459
https://github.com/sethvargo/community-zero/blob/08a22c47c865deb6a5f931cb4d9f747a2b9d3459/lib/community_zero/store.rb#L51-L56
4,235
sethvargo/community-zero
lib/community_zero/store.rb
CommunityZero.Store.add
def add(cookbook) cookbook = cookbook.dup cookbook.created_at = Time.now cookbook.updated_at = Time.now entry = _cookbooks[cookbook.name] ||= {} entry[cookbook.version] = cookbook end
ruby
def add(cookbook) cookbook = cookbook.dup cookbook.created_at = Time.now cookbook.updated_at = Time.now entry = _cookbooks[cookbook.name] ||= {} entry[cookbook.version] = cookbook end
[ "def", "add", "(", "cookbook", ")", "cookbook", "=", "cookbook", ".", "dup", "cookbook", ".", "created_at", "=", "Time", ".", "now", "cookbook", ".", "updated_at", "=", "Time", ".", "now", "entry", "=", "_cookbooks", "[", "cookbook", ".", "name", "]", ...
Add the given cookbook to the cookbook store. This method's implementation prohibits duplicate cookbooks from entering the store. @param [CommunityZero::Cookbook] cookbook the cookbook to add
[ "Add", "the", "given", "cookbook", "to", "the", "cookbook", "store", ".", "This", "method", "s", "implementation", "prohibits", "duplicate", "cookbooks", "from", "entering", "the", "store", "." ]
08a22c47c865deb6a5f931cb4d9f747a2b9d3459
https://github.com/sethvargo/community-zero/blob/08a22c47c865deb6a5f931cb4d9f747a2b9d3459/lib/community_zero/store.rb#L68-L75
4,236
sethvargo/community-zero
lib/community_zero/store.rb
CommunityZero.Store.remove
def remove(cookbook) return unless has_cookbook?(cookbook.name, cookbook.version) _cookbooks[cookbook.name].delete(cookbook.version) end
ruby
def remove(cookbook) return unless has_cookbook?(cookbook.name, cookbook.version) _cookbooks[cookbook.name].delete(cookbook.version) end
[ "def", "remove", "(", "cookbook", ")", "return", "unless", "has_cookbook?", "(", "cookbook", ".", "name", ",", "cookbook", ".", "version", ")", "_cookbooks", "[", "cookbook", ".", "name", "]", ".", "delete", "(", "cookbook", ".", "version", ")", "end" ]
Remove the cookbook from the store. @param [CommunityZero::Cookbook] cookbook the cookbook to remove
[ "Remove", "the", "cookbook", "from", "the", "store", "." ]
08a22c47c865deb6a5f931cb4d9f747a2b9d3459
https://github.com/sethvargo/community-zero/blob/08a22c47c865deb6a5f931cb4d9f747a2b9d3459/lib/community_zero/store.rb#L82-L85
4,237
sethvargo/community-zero
lib/community_zero/store.rb
CommunityZero.Store.find
def find(name, version = nil) possibles = _cookbooks[name] return nil if possibles.nil? version ||= possibles.keys.sort.last possibles[version] end
ruby
def find(name, version = nil) possibles = _cookbooks[name] return nil if possibles.nil? version ||= possibles.keys.sort.last possibles[version] end
[ "def", "find", "(", "name", ",", "version", "=", "nil", ")", "possibles", "=", "_cookbooks", "[", "name", "]", "return", "nil", "if", "possibles", ".", "nil?", "version", "||=", "possibles", ".", "keys", ".", "sort", ".", "last", "possibles", "[", "ver...
Determine if the cookbook store contains a cookbook. If the version attribute is nil, this method will return the latest cookbook version by that name that exists. If the version is specified, this method will only return that specific version, or nil if that cookbook at that version exists. @param [String] name ...
[ "Determine", "if", "the", "cookbook", "store", "contains", "a", "cookbook", ".", "If", "the", "version", "attribute", "is", "nil", "this", "method", "will", "return", "the", "latest", "cookbook", "version", "by", "that", "name", "that", "exists", ".", "If", ...
08a22c47c865deb6a5f931cb4d9f747a2b9d3459
https://github.com/sethvargo/community-zero/blob/08a22c47c865deb6a5f931cb4d9f747a2b9d3459/lib/community_zero/store.rb#L107-L113
4,238
sethvargo/community-zero
lib/community_zero/store.rb
CommunityZero.Store.versions
def versions(name) name = name.respond_to?(:name) ? name.name : name (_cookbooks[name] && _cookbooks[name].keys.sort) || [] end
ruby
def versions(name) name = name.respond_to?(:name) ? name.name : name (_cookbooks[name] && _cookbooks[name].keys.sort) || [] end
[ "def", "versions", "(", "name", ")", "name", "=", "name", ".", "respond_to?", "(", ":name", ")", "?", "name", ".", "name", ":", "name", "(", "_cookbooks", "[", "name", "]", "&&", "_cookbooks", "[", "name", "]", ".", "keys", ".", "sort", ")", "||", ...
Return a list of all versions for the given cookbook. @param [String, CommunityZero::Cookbook] name the cookbook or name of the cookbook to get versions for
[ "Return", "a", "list", "of", "all", "versions", "for", "the", "given", "cookbook", "." ]
08a22c47c865deb6a5f931cb4d9f747a2b9d3459
https://github.com/sethvargo/community-zero/blob/08a22c47c865deb6a5f931cb4d9f747a2b9d3459/lib/community_zero/store.rb#L119-L122
4,239
scrapper/perobs
lib/perobs/Hash.rb
PEROBS.Hash._referenced_object_ids
def _referenced_object_ids @data.each_value.select { |v| v && v.respond_to?(:is_poxreference?) }. map { |o| o.id } end
ruby
def _referenced_object_ids @data.each_value.select { |v| v && v.respond_to?(:is_poxreference?) }. map { |o| o.id } end
[ "def", "_referenced_object_ids", "@data", ".", "each_value", ".", "select", "{", "|", "v", "|", "v", "&&", "v", ".", "respond_to?", "(", ":is_poxreference?", ")", "}", ".", "map", "{", "|", "o", "|", "o", ".", "id", "}", "end" ]
Return a list of all object IDs of all persistend objects that this Hash is referencing. @return [Array of Integer] IDs of referenced objects
[ "Return", "a", "list", "of", "all", "object", "IDs", "of", "all", "persistend", "objects", "that", "this", "Hash", "is", "referencing", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/Hash.rb#L141-L144
4,240
scrapper/perobs
lib/perobs/Hash.rb
PEROBS.Hash._delete_reference_to_id
def _delete_reference_to_id(id) @data.delete_if do |k, v| v && v.respond_to?(:is_poxreference?) && v.id == id end @store.cache.cache_write(self) end
ruby
def _delete_reference_to_id(id) @data.delete_if do |k, v| v && v.respond_to?(:is_poxreference?) && v.id == id end @store.cache.cache_write(self) end
[ "def", "_delete_reference_to_id", "(", "id", ")", "@data", ".", "delete_if", "do", "|", "k", ",", "v", "|", "v", "&&", "v", ".", "respond_to?", "(", ":is_poxreference?", ")", "&&", "v", ".", "id", "==", "id", "end", "@store", ".", "cache", ".", "cach...
This method should only be used during store repair operations. It will delete all referenced to the given object ID. @param id [Integer] targeted object ID
[ "This", "method", "should", "only", "be", "used", "during", "store", "repair", "operations", ".", "It", "will", "delete", "all", "referenced", "to", "the", "given", "object", "ID", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/Hash.rb#L149-L154
4,241
scrapper/perobs
lib/perobs/IDListPageRecord.rb
PEROBS.IDListPageRecord.split
def split # Determine the new max_id for the old page. max_id = @min_id + (@max_id - @min_id) / 2 # Create a new page that stores the upper half of the ID range. Remove # all IDs from this page that now belong into the new page and transfer # them. new_page_record = IDListPageRecord....
ruby
def split # Determine the new max_id for the old page. max_id = @min_id + (@max_id - @min_id) / 2 # Create a new page that stores the upper half of the ID range. Remove # all IDs from this page that now belong into the new page and transfer # them. new_page_record = IDListPageRecord....
[ "def", "split", "# Determine the new max_id for the old page.", "max_id", "=", "@min_id", "+", "(", "@max_id", "-", "@min_id", ")", "/", "2", "# Create a new page that stores the upper half of the ID range. Remove", "# all IDs from this page that now belong into the new page and transf...
Split the current page. This split is done by splitting the ID range in half. This page will keep the first half, the newly created page will get the second half. This may not actually yield an empty page as all values could remain with one of the pages. In this case further splits need to be issued by the caller. ...
[ "Split", "the", "current", "page", ".", "This", "split", "is", "done", "by", "splitting", "the", "ID", "range", "in", "half", ".", "This", "page", "will", "keep", "the", "first", "half", "the", "newly", "created", "page", "will", "get", "the", "second", ...
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/IDListPageRecord.rb#L84-L96
4,242
notonthehighstreet/chicago
lib/chicago/schema/builders/shrunken_dimension_builder.rb
Chicago::Schema::Builders.ShrunkenDimensionBuilder.columns
def columns(*names) columns = @base.columns.select {|c| names.include?(c.name) } check_columns_subset_of_base_dimension names, columns @options[:columns] = columns end
ruby
def columns(*names) columns = @base.columns.select {|c| names.include?(c.name) } check_columns_subset_of_base_dimension names, columns @options[:columns] = columns end
[ "def", "columns", "(", "*", "names", ")", "columns", "=", "@base", ".", "columns", ".", "select", "{", "|", "c", "|", "names", ".", "include?", "(", "c", ".", "name", ")", "}", "check_columns_subset_of_base_dimension", "names", ",", "columns", "@options", ...
Defines which columns of the base dimension are present in the shrunken dimension. Takes an array of the column names as symbols. The columns must be a subset of the base dimension's columns; additional names will raise a Chicago::MissingDefinitionError.
[ "Defines", "which", "columns", "of", "the", "base", "dimension", "are", "present", "in", "the", "shrunken", "dimension", "." ]
428e94f8089d2f36fdcff2e27ea2af572b816def
https://github.com/notonthehighstreet/chicago/blob/428e94f8089d2f36fdcff2e27ea2af572b816def/lib/chicago/schema/builders/shrunken_dimension_builder.rb#L29-L33
4,243
xinminlabs/synvert-core
lib/synvert/core/rewriter/action/insert_action.rb
Synvert::Core.Rewriter::InsertAction.insert_position
def insert_position(node) case node.type when :block node.children[1].children.empty? ? node.children[0].loc.expression.end_pos + 3 : node.children[1].loc.expression.end_pos when :class node.children[1] ? node.children[1].loc.expression.end_pos : node.children[0].loc.expression.end_pos...
ruby
def insert_position(node) case node.type when :block node.children[1].children.empty? ? node.children[0].loc.expression.end_pos + 3 : node.children[1].loc.expression.end_pos when :class node.children[1] ? node.children[1].loc.expression.end_pos : node.children[0].loc.expression.end_pos...
[ "def", "insert_position", "(", "node", ")", "case", "node", ".", "type", "when", ":block", "node", ".", "children", "[", "1", "]", ".", "children", ".", "empty?", "?", "node", ".", "children", "[", "0", "]", ".", "loc", ".", "expression", ".", "end_p...
Insert position. @return [Integer] insert position.
[ "Insert", "position", "." ]
a490bfd30eaec81002d10f8fb61b49138708e46c
https://github.com/xinminlabs/synvert-core/blob/a490bfd30eaec81002d10f8fb61b49138708e46c/lib/synvert/core/rewriter/action/insert_action.rb#L25-L34
4,244
jeffnyman/tapestry
lib/tapestry/element.rb
Tapestry.Element.accessor_aspects
def accessor_aspects(element, *signature) identifier = signature.shift locator_args = {} qualifier_args = {} gather_aspects(identifier, element, locator_args, qualifier_args) [locator_args, qualifier_args] end
ruby
def accessor_aspects(element, *signature) identifier = signature.shift locator_args = {} qualifier_args = {} gather_aspects(identifier, element, locator_args, qualifier_args) [locator_args, qualifier_args] end
[ "def", "accessor_aspects", "(", "element", ",", "*", "signature", ")", "identifier", "=", "signature", ".", "shift", "locator_args", "=", "{", "}", "qualifier_args", "=", "{", "}", "gather_aspects", "(", "identifier", ",", "element", ",", "locator_args", ",", ...
This method provides the means to get the aspects of an accessor signature. The "aspects" refer to the locator information and any qualifier information that was provided along with the locator. This is important because the qualifier is not used to locate an element but rather to put conditions on how the state of...
[ "This", "method", "provides", "the", "means", "to", "get", "the", "aspects", "of", "an", "accessor", "signature", ".", "The", "aspects", "refer", "to", "the", "locator", "information", "and", "any", "qualifier", "information", "that", "was", "provided", "along...
da28652dd6de71e415cd2c01afd89f641938a05b
https://github.com/jeffnyman/tapestry/blob/da28652dd6de71e415cd2c01afd89f641938a05b/lib/tapestry/element.rb#L78-L84
4,245
scrapper/perobs
lib/perobs/DynamoDB.rb
PEROBS.DynamoDB.delete_database
def delete_database dynamodb = Aws::DynamoDB::Client.new dynamodb.delete_table(:table_name => @table_name) dynamodb.wait_until(:table_not_exists, table_name: @table_name) end
ruby
def delete_database dynamodb = Aws::DynamoDB::Client.new dynamodb.delete_table(:table_name => @table_name) dynamodb.wait_until(:table_not_exists, table_name: @table_name) end
[ "def", "delete_database", "dynamodb", "=", "Aws", "::", "DynamoDB", "::", "Client", ".", "new", "dynamodb", ".", "delete_table", "(", ":table_name", "=>", "@table_name", ")", "dynamodb", ".", "wait_until", "(", ":table_not_exists", ",", "table_name", ":", "@tabl...
Create a new DynamoDB object. @param db_name [String] name of the DB directory @param options [Hash] options to customize the behavior. Currently only the following options are supported: :serializer : Can be :json and :yaml :aws_id : AWS credentials ID :aws_key : AWS c...
[ "Create", "a", "new", "DynamoDB", "object", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/DynamoDB.rb#L93-L97
4,246
scrapper/perobs
lib/perobs/DynamoDB.rb
PEROBS.DynamoDB.delete_unmarked_objects
def delete_unmarked_objects deleted_objects_count = 0 each_item do |id| unless dynamo_is_marked?(id) dynamo_delete_item(id) deleted_objects_count += 1 @item_counter -= 1 end end dynamo_put_item('item_counter', @item_counter.to_s) deleted_objec...
ruby
def delete_unmarked_objects deleted_objects_count = 0 each_item do |id| unless dynamo_is_marked?(id) dynamo_delete_item(id) deleted_objects_count += 1 @item_counter -= 1 end end dynamo_put_item('item_counter', @item_counter.to_s) deleted_objec...
[ "def", "delete_unmarked_objects", "deleted_objects_count", "=", "0", "each_item", "do", "|", "id", "|", "unless", "dynamo_is_marked?", "(", "id", ")", "dynamo_delete_item", "(", "id", ")", "deleted_objects_count", "+=", "1", "@item_counter", "-=", "1", "end", "end...
Permanently delete all objects that have not been marked. Those are orphaned and are no longer referenced by any actively used object. @return [Integer] Count of the deleted objects.
[ "Permanently", "delete", "all", "objects", "that", "have", "not", "been", "marked", ".", "Those", "are", "orphaned", "and", "are", "no", "longer", "referenced", "by", "any", "actively", "used", "object", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/DynamoDB.rb#L161-L173
4,247
scrapper/perobs
lib/perobs/DynamoDB.rb
PEROBS.DynamoDB.check_db
def check_db(repair = false) unless (item_counter = dynamo_get_item('item_counter')) && item_counter == @item_counter PEROBS.log.error "@item_counter variable (#{@item_counter}) and " + "item_counter table entry (#{item_counter}) don't match" end item_counter = 0 e...
ruby
def check_db(repair = false) unless (item_counter = dynamo_get_item('item_counter')) && item_counter == @item_counter PEROBS.log.error "@item_counter variable (#{@item_counter}) and " + "item_counter table entry (#{item_counter}) don't match" end item_counter = 0 e...
[ "def", "check_db", "(", "repair", "=", "false", ")", "unless", "(", "item_counter", "=", "dynamo_get_item", "(", "'item_counter'", ")", ")", "&&", "item_counter", "==", "@item_counter", "PEROBS", ".", "log", ".", "error", "\"@item_counter variable (#{@item_counter})...
Basic consistency check. @param repair [TrueClass/FalseClass] True if found errors should be repaired.
[ "Basic", "consistency", "check", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/DynamoDB.rb#L190-L202
4,248
scrapper/perobs
lib/perobs/ObjectBase.rb
PEROBS.POXReference.method_missing
def method_missing(method_sym, *args, &block) unless (obj = _referenced_object) ::PEROBS.log.fatal "Internal consistency error. No object with ID " + "#{@id} found in the store." end if obj.respond_to?(:is_poxreference?) ::PEROBS.log.fatal "POXReference that references a POXR...
ruby
def method_missing(method_sym, *args, &block) unless (obj = _referenced_object) ::PEROBS.log.fatal "Internal consistency error. No object with ID " + "#{@id} found in the store." end if obj.respond_to?(:is_poxreference?) ::PEROBS.log.fatal "POXReference that references a POXR...
[ "def", "method_missing", "(", "method_sym", ",", "*", "args", ",", "&", "block", ")", "unless", "(", "obj", "=", "_referenced_object", ")", "::", "PEROBS", ".", "log", ".", "fatal", "\"Internal consistency error. No object with ID \"", "+", "\"#{@id} found in the st...
Proxy all calls to unknown methods to the referenced object.
[ "Proxy", "all", "calls", "to", "unknown", "methods", "to", "the", "referenced", "object", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/ObjectBase.rb#L49-L58
4,249
scrapper/perobs
lib/perobs/ObjectBase.rb
PEROBS.ObjectBase._transfer
def _transfer(store) @store = store # Remove the previously defined finalizer as it is attached to the old # store. ObjectSpace.undefine_finalizer(self) # Register the object as in-memory object with the new store. @store._register_in_memory(self, @_id) # Register the finalizer...
ruby
def _transfer(store) @store = store # Remove the previously defined finalizer as it is attached to the old # store. ObjectSpace.undefine_finalizer(self) # Register the object as in-memory object with the new store. @store._register_in_memory(self, @_id) # Register the finalizer...
[ "def", "_transfer", "(", "store", ")", "@store", "=", "store", "# Remove the previously defined finalizer as it is attached to the old", "# store.", "ObjectSpace", ".", "undefine_finalizer", "(", "self", ")", "# Register the object as in-memory object with the new store.", "@store"...
Library internal method to transfer the Object to a new store. @param store [Store] New store
[ "Library", "internal", "method", "to", "transfer", "the", "Object", "to", "a", "new", "store", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/ObjectBase.rb#L172-L183
4,250
scrapper/perobs
lib/perobs/ObjectBase.rb
PEROBS.ObjectBase._restore
def _restore(level) # Find the most recently stored state of this object. This could be on # any previous stash level or in the regular object DB. If the object # was created during the transaction, there is not previous state to # restore to. data = nil if @_stash_map (level...
ruby
def _restore(level) # Find the most recently stored state of this object. This could be on # any previous stash level or in the regular object DB. If the object # was created during the transaction, there is not previous state to # restore to. data = nil if @_stash_map (level...
[ "def", "_restore", "(", "level", ")", "# Find the most recently stored state of this object. This could be on", "# any previous stash level or in the regular object DB. If the object", "# was created during the transaction, there is not previous state to", "# restore to.", "data", "=", "nil", ...
Restore the object state from the storage back-end. @param level [Integer] the transaction nesting level
[ "Restore", "the", "object", "state", "from", "the", "storage", "back", "-", "end", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/ObjectBase.rb#L250-L269
4,251
Absolight/epp-client
lib/epp-client/domain.rb
EPPClient.Domain.domain_check
def domain_check(*domains) domains.flatten! response = send_request(domain_check_xml(*domains)) get_result(:xml => response, :callback => :domain_check_process) end
ruby
def domain_check(*domains) domains.flatten! response = send_request(domain_check_xml(*domains)) get_result(:xml => response, :callback => :domain_check_process) end
[ "def", "domain_check", "(", "*", "domains", ")", "domains", ".", "flatten!", "response", "=", "send_request", "(", "domain_check_xml", "(", "domains", ")", ")", "get_result", "(", ":xml", "=>", "response", ",", ":callback", "=>", ":domain_check_process", ")", ...
Check the availability of domains takes a list of domains as arguments returns an array of hashes containing three fields : [<tt>:name</tt>] The domain name [<tt>:avail</tt>] Wether the domain is available or not. [<tt>:reason</tt>] The reason for non availability, if given.
[ "Check", "the", "availability", "of", "domains" ]
c0025daee5e7087f60b654595a8e7d92e966c54e
https://github.com/Absolight/epp-client/blob/c0025daee5e7087f60b654595a8e7d92e966c54e/lib/epp-client/domain.rb#L29-L34
4,252
Absolight/epp-client
lib/epp-client/domain.rb
EPPClient.Domain.domain_info
def domain_info(args) args = { :name => args } if args.is_a?(String) response = send_request(domain_info_xml(args)) get_result(:xml => response, :callback => :domain_info_process) end
ruby
def domain_info(args) args = { :name => args } if args.is_a?(String) response = send_request(domain_info_xml(args)) get_result(:xml => response, :callback => :domain_info_process) end
[ "def", "domain_info", "(", "args", ")", "args", "=", "{", ":name", "=>", "args", "}", "if", "args", ".", "is_a?", "(", "String", ")", "response", "=", "send_request", "(", "domain_info_xml", "(", "args", ")", ")", "get_result", "(", ":xml", "=>", "resp...
Returns the informations about a domain Takes either a unique argument, a string, representing the domain, or a hash with : <tt>:name</tt> the domain name, and optionnaly <tt>:authInfo</tt> the authentication information and possibly <tt>:roid</tt> the contact the authInfo is about. Returned is a hash mapping as...
[ "Returns", "the", "informations", "about", "a", "domain" ]
c0025daee5e7087f60b654595a8e7d92e966c54e
https://github.com/Absolight/epp-client/blob/c0025daee5e7087f60b654595a8e7d92e966c54e/lib/epp-client/domain.rb#L118-L123
4,253
scrapper/perobs
lib/perobs/EquiBlobsFile.rb
PEROBS.EquiBlobsFile.set_custom_data
def set_custom_data(name, value) unless @custom_data_labels.include?(name) PEROBS.log.fatal "Unknown custom data field #{name}" end @custom_data_values[@custom_data_labels.index(name)] = value write_header if @f end
ruby
def set_custom_data(name, value) unless @custom_data_labels.include?(name) PEROBS.log.fatal "Unknown custom data field #{name}" end @custom_data_values[@custom_data_labels.index(name)] = value write_header if @f end
[ "def", "set_custom_data", "(", "name", ",", "value", ")", "unless", "@custom_data_labels", ".", "include?", "(", "name", ")", "PEROBS", ".", "log", ".", "fatal", "\"Unknown custom data field #{name}\"", "end", "@custom_data_values", "[", "@custom_data_labels", ".", ...
Set the registered custom data field to the given value. @param name [String] Label of the offset @param value [Integer] Value
[ "Set", "the", "registered", "custom", "data", "field", "to", "the", "given", "value", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/EquiBlobsFile.rb#L146-L153
4,254
scrapper/perobs
lib/perobs/EquiBlobsFile.rb
PEROBS.EquiBlobsFile.free_address
def free_address if @first_space == 0 # There is currently no free entry. Create a new reserved entry at the # end of the file. begin offset = @f.size @f.seek(offset) write_n_bytes([1] + ::Array.new(@entry_bytes, 0)) write_header return off...
ruby
def free_address if @first_space == 0 # There is currently no free entry. Create a new reserved entry at the # end of the file. begin offset = @f.size @f.seek(offset) write_n_bytes([1] + ::Array.new(@entry_bytes, 0)) write_header return off...
[ "def", "free_address", "if", "@first_space", "==", "0", "# There is currently no free entry. Create a new reserved entry at the", "# end of the file.", "begin", "offset", "=", "@f", ".", "size", "@f", ".", "seek", "(", "offset", ")", "write_n_bytes", "(", "[", "1", "]...
Return the address of a free blob storage space. Addresses start at 0 and increase linearly. @return [Integer] address of a free blob space
[ "Return", "the", "address", "of", "a", "free", "blob", "storage", "space", ".", "Addresses", "start", "at", "0", "and", "increase", "linearly", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/EquiBlobsFile.rb#L204-L242
4,255
scrapper/perobs
lib/perobs/EquiBlobsFile.rb
PEROBS.EquiBlobsFile.store_blob
def store_blob(address, bytes) unless address >= 0 PEROBS.log.fatal "Blob storage address must be larger than 0, " + "not #{address}" end if bytes.length != @entry_bytes PEROBS.log.fatal "All stack entries must be #{@entry_bytes} " + "long. This entry is #{bytes.len...
ruby
def store_blob(address, bytes) unless address >= 0 PEROBS.log.fatal "Blob storage address must be larger than 0, " + "not #{address}" end if bytes.length != @entry_bytes PEROBS.log.fatal "All stack entries must be #{@entry_bytes} " + "long. This entry is #{bytes.len...
[ "def", "store_blob", "(", "address", ",", "bytes", ")", "unless", "address", ">=", "0", "PEROBS", ".", "log", ".", "fatal", "\"Blob storage address must be larger than 0, \"", "+", "\"not #{address}\"", "end", "if", "bytes", ".", "length", "!=", "@entry_bytes", "P...
Store the given byte blob at the specified address. If the blob space is already in use the content will be overwritten. @param address [Integer] Address to store the blob @param bytes [String] bytes to store
[ "Store", "the", "given", "byte", "blob", "at", "the", "specified", "address", ".", "If", "the", "blob", "space", "is", "already", "in", "use", "the", "content", "will", "be", "overwritten", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/EquiBlobsFile.rb#L248-L290
4,256
scrapper/perobs
lib/perobs/EquiBlobsFile.rb
PEROBS.EquiBlobsFile.retrieve_blob
def retrieve_blob(address) unless address > 0 PEROBS.log.fatal "Blob retrieval address must be larger than 0, " + "not #{address}" end begin if (offset = address_to_offset(address)) >= @f.size PEROBS.log.fatal "Cannot retrieve blob at address #{address} " + ...
ruby
def retrieve_blob(address) unless address > 0 PEROBS.log.fatal "Blob retrieval address must be larger than 0, " + "not #{address}" end begin if (offset = address_to_offset(address)) >= @f.size PEROBS.log.fatal "Cannot retrieve blob at address #{address} " + ...
[ "def", "retrieve_blob", "(", "address", ")", "unless", "address", ">", "0", "PEROBS", ".", "log", ".", "fatal", "\"Blob retrieval address must be larger than 0, \"", "+", "\"not #{address}\"", "end", "begin", "if", "(", "offset", "=", "address_to_offset", "(", "addr...
Retrieve a blob from the given address. @param address [Integer] Address to store the blob @return [String] blob bytes
[ "Retrieve", "a", "blob", "from", "the", "given", "address", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/EquiBlobsFile.rb#L295-L321
4,257
scrapper/perobs
lib/perobs/EquiBlobsFile.rb
PEROBS.EquiBlobsFile.delete_blob
def delete_blob(address) unless address >= 0 PEROBS.log.fatal "Blob address must be larger than 0, " + "not #{address}" end offset = address_to_offset(address) begin @f.seek(offset) if (marker = read_char) != 1 && marker != 2 PEROBS.log.fatal "Cannot ...
ruby
def delete_blob(address) unless address >= 0 PEROBS.log.fatal "Blob address must be larger than 0, " + "not #{address}" end offset = address_to_offset(address) begin @f.seek(offset) if (marker = read_char) != 1 && marker != 2 PEROBS.log.fatal "Cannot ...
[ "def", "delete_blob", "(", "address", ")", "unless", "address", ">=", "0", "PEROBS", ".", "log", ".", "fatal", "\"Blob address must be larger than 0, \"", "+", "\"not #{address}\"", "end", "offset", "=", "address_to_offset", "(", "address", ")", "begin", "@f", "."...
Delete the blob at the given address. @param address [Integer] Address of blob to delete
[ "Delete", "the", "blob", "at", "the", "given", "address", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/EquiBlobsFile.rb#L325-L357
4,258
scrapper/perobs
lib/perobs/EquiBlobsFile.rb
PEROBS.EquiBlobsFile.check
def check sync return false unless check_spaces return false unless check_entries expected_size = address_to_offset(@total_entries + @total_spaces + 1) actual_size = @f.size if actual_size != expected_size PEROBS.log.error "Size mismatch in EquiBlobsFile #{@file_name}. " + ...
ruby
def check sync return false unless check_spaces return false unless check_entries expected_size = address_to_offset(@total_entries + @total_spaces + 1) actual_size = @f.size if actual_size != expected_size PEROBS.log.error "Size mismatch in EquiBlobsFile #{@file_name}. " + ...
[ "def", "check", "sync", "return", "false", "unless", "check_spaces", "return", "false", "unless", "check_entries", "expected_size", "=", "address_to_offset", "(", "@total_entries", "+", "@total_spaces", "+", "1", ")", "actual_size", "=", "@f", ".", "size", "if", ...
Check the file for logical errors. @return [Boolean] true of file has no errors, false otherwise.
[ "Check", "the", "file", "for", "logical", "errors", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/EquiBlobsFile.rb#L361-L376
4,259
scrapper/perobs
lib/perobs/Log.rb
PEROBS.ILogger.open
def open(io) begin @@logger = Logger.new(io, *@@options) rescue IOError => e @@logger = Logger.new($stderr) $stderr.puts "Cannot open log file: #{e.message}" end @@logger.level = @@level @@logger.formatter = @@formatter end
ruby
def open(io) begin @@logger = Logger.new(io, *@@options) rescue IOError => e @@logger = Logger.new($stderr) $stderr.puts "Cannot open log file: #{e.message}" end @@logger.level = @@level @@logger.formatter = @@formatter end
[ "def", "open", "(", "io", ")", "begin", "@@logger", "=", "Logger", ".", "new", "(", "io", ",", "@@options", ")", "rescue", "IOError", "=>", "e", "@@logger", "=", "Logger", ".", "new", "(", "$stderr", ")", "$stderr", ".", "puts", "\"Cannot open log file: ...
Redirect all log messages to the given IO. @param io [IO] Output file descriptor
[ "Redirect", "all", "log", "messages", "to", "the", "given", "IO", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/Log.rb#L81-L90
4,260
scrapper/perobs
lib/perobs/ClassMap.rb
PEROBS.ClassMap.rename
def rename(rename_map) @by_id.each.with_index do |klass, id| # Some entries can be nil. Ignore them. next unless klass if (new_name = rename_map[klass]) # We have a rename request. Update the current @by_id entry. @by_id[id] = new_name # Remove the old class ...
ruby
def rename(rename_map) @by_id.each.with_index do |klass, id| # Some entries can be nil. Ignore them. next unless klass if (new_name = rename_map[klass]) # We have a rename request. Update the current @by_id entry. @by_id[id] = new_name # Remove the old class ...
[ "def", "rename", "(", "rename_map", ")", "@by_id", ".", "each", ".", "with_index", "do", "|", "klass", ",", "id", "|", "# Some entries can be nil. Ignore them.", "next", "unless", "klass", "if", "(", "new_name", "=", "rename_map", "[", "klass", "]", ")", "# ...
Rename a set of classes to new names. @param rename_map [Hash] Hash that maps old names to new names
[ "Rename", "a", "set", "of", "classes", "to", "new", "names", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/ClassMap.rb#L65-L79
4,261
scrapper/perobs
lib/perobs/ClassMap.rb
PEROBS.ClassMap.keep
def keep(classes) @by_id.each.with_index do |klass, id| unless classes.include?(klass) # Delete the class from the @by_id list by setting the entry to nil. @by_id[id] = nil # Delete the corresponding @by_class entry as well. @by_class.delete(klass) end ...
ruby
def keep(classes) @by_id.each.with_index do |klass, id| unless classes.include?(klass) # Delete the class from the @by_id list by setting the entry to nil. @by_id[id] = nil # Delete the corresponding @by_class entry as well. @by_class.delete(klass) end ...
[ "def", "keep", "(", "classes", ")", "@by_id", ".", "each", ".", "with_index", "do", "|", "klass", ",", "id", "|", "unless", "classes", ".", "include?", "(", "klass", ")", "# Delete the class from the @by_id list by setting the entry to nil.", "@by_id", "[", "id", ...
Delete all classes unless they are contained in _classes_. @param classes [Array of String] List of the class names
[ "Delete", "all", "classes", "unless", "they", "are", "contained", "in", "_classes_", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/ClassMap.rb#L83-L92
4,262
mreq/wmctile
lib/wmctile/memory.rb
Wmctile.Memory.read_file
def read_file @file_path = '~/.local/share/wmctile' @file_name = 'memory.yml' @file_full = File.expand_path([@file_path, @file_name].join('/')) if File.exist? @file_full file_contents = File.read(@file_full) @memory = YAML.load(file_contents) else create_file ...
ruby
def read_file @file_path = '~/.local/share/wmctile' @file_name = 'memory.yml' @file_full = File.expand_path([@file_path, @file_name].join('/')) if File.exist? @file_full file_contents = File.read(@file_full) @memory = YAML.load(file_contents) else create_file ...
[ "def", "read_file", "@file_path", "=", "'~/.local/share/wmctile'", "@file_name", "=", "'memory.yml'", "@file_full", "=", "File", ".", "expand_path", "(", "[", "@file_path", ",", "@file_name", "]", ".", "join", "(", "'/'", ")", ")", "if", "File", ".", "exist?",...
Memory init function. Creates a default yaml file if it's non-existent. Reads the yaml file, creating it if non-existent. @return [void]
[ "Memory", "init", "function", ".", "Creates", "a", "default", "yaml", "file", "if", "it", "s", "non", "-", "existent", "." ]
a41af5afa310b09c8ba1bd45a134b9b2a87d1a35
https://github.com/mreq/wmctile/blob/a41af5afa310b09c8ba1bd45a134b9b2a87d1a35/lib/wmctile/memory.rb#L20-L32
4,263
sethvargo/community-zero
lib/community_zero/endpoint.rb
CommunityZero.Endpoint.call
def call(request) m = request.method.downcase.to_sym # Only respond to listed methods unless respond_to?(m) allowed = METHODS.select { |m| respond_to?(m) }.map(&:upcase).join(', ') return [ 405, { 'Content-Type' => 'text/plain', 'Allow' => allowed }, "Met...
ruby
def call(request) m = request.method.downcase.to_sym # Only respond to listed methods unless respond_to?(m) allowed = METHODS.select { |m| respond_to?(m) }.map(&:upcase).join(', ') return [ 405, { 'Content-Type' => 'text/plain', 'Allow' => allowed }, "Met...
[ "def", "call", "(", "request", ")", "m", "=", "request", ".", "method", ".", "downcase", ".", "to_sym", "# Only respond to listed methods", "unless", "respond_to?", "(", "m", ")", "allowed", "=", "METHODS", ".", "select", "{", "|", "m", "|", "respond_to?", ...
Call the request. @param [CommunityZero::Request] request the request object
[ "Call", "the", "request", "." ]
08a22c47c865deb6a5f931cb4d9f747a2b9d3459
https://github.com/sethvargo/community-zero/blob/08a22c47c865deb6a5f931cb4d9f747a2b9d3459/lib/community_zero/endpoint.rb#L76-L94
4,264
code-and-effect/effective_pages
app/models/effective/page.rb
Effective.Page.duplicate!
def duplicate! Page.new(attributes.except('id', 'updated_at', 'created_at')).tap do |page| page.title = page.title + ' (Copy)' page.slug = page.slug + '-copy' page.draft = true regions.each do |region| page.regions.build(region.attributes.except('id', 'updated_at', 'crea...
ruby
def duplicate! Page.new(attributes.except('id', 'updated_at', 'created_at')).tap do |page| page.title = page.title + ' (Copy)' page.slug = page.slug + '-copy' page.draft = true regions.each do |region| page.regions.build(region.attributes.except('id', 'updated_at', 'crea...
[ "def", "duplicate!", "Page", ".", "new", "(", "attributes", ".", "except", "(", "'id'", ",", "'updated_at'", ",", "'created_at'", ")", ")", ".", "tap", "do", "|", "page", "|", "page", ".", "title", "=", "page", ".", "title", "+", "' (Copy)'", "page", ...
Returns a duplicated post object, or throws an exception
[ "Returns", "a", "duplicated", "post", "object", "or", "throws", "an", "exception" ]
ff00e2d76055985ab65f570747bc9a5f2748f817
https://github.com/code-and-effect/effective_pages/blob/ff00e2d76055985ab65f570747bc9a5f2748f817/app/models/effective/page.rb#L46-L58
4,265
sagmor/yard-mruby
lib/yard/mruby/parser/c/header_parser.rb
YARD::MRuby::Parser::C.HeaderParser.consume_directive
def consume_directive super if @in_body_statements @newline = false start = @index line = @line statement = DirectiveStatement.new(nil, @file, line) @statements << statement attach_comment(statement) multiline = false advance_loop do chr = char cas...
ruby
def consume_directive super if @in_body_statements @newline = false start = @index line = @line statement = DirectiveStatement.new(nil, @file, line) @statements << statement attach_comment(statement) multiline = false advance_loop do chr = char cas...
[ "def", "consume_directive", "super", "if", "@in_body_statements", "@newline", "=", "false", "start", "=", "@index", "line", "=", "@line", "statement", "=", "DirectiveStatement", ".", "new", "(", "nil", ",", "@file", ",", "line", ")", "@statements", "<<", "stat...
Consumes a directive and generates a DirectiveStatement
[ "Consumes", "a", "directive", "and", "generates", "a", "DirectiveStatement" ]
c20c2f415d15235fdc96ac177cb008eb3e11358a
https://github.com/sagmor/yard-mruby/blob/c20c2f415d15235fdc96ac177cb008eb3e11358a/lib/yard/mruby/parser/c/header_parser.rb#L5-L36
4,266
r7kamura/xrc
lib/xrc/client.rb
Xrc.Client.reply
def reply(options) say( body: options[:body], from: options[:to].to, to: options[:to].from, type: options[:to].type, ) end
ruby
def reply(options) say( body: options[:body], from: options[:to].to, to: options[:to].from, type: options[:to].type, ) end
[ "def", "reply", "(", "options", ")", "say", "(", "body", ":", "options", "[", ":body", "]", ",", "from", ":", "options", "[", ":to", "]", ".", "to", ",", "to", ":", "options", "[", ":to", "]", ".", "from", ",", "type", ":", "options", "[", ":to...
Replies to given message @option options [Xrc::Messages::Base] :to A message object given from server @option options [String] :body A text to be sent to server @return [REXML::Element] Returns an element sent to server @example client.reply(body: "Thanks", to: message)
[ "Replies", "to", "given", "message" ]
ddc0af9682fc2cdaf851f88a3f0953a1478f1954
https://github.com/r7kamura/xrc/blob/ddc0af9682fc2cdaf851f88a3f0953a1478f1954/lib/xrc/client.rb#L106-L113
4,267
r7kamura/xrc
lib/xrc/client.rb
Xrc.Client.say
def say(options) post Elements::Message.new( body: options[:body], from: options[:from], to: options[:to], type: options[:type], ) end
ruby
def say(options) post Elements::Message.new( body: options[:body], from: options[:from], to: options[:to], type: options[:type], ) end
[ "def", "say", "(", "options", ")", "post", "Elements", "::", "Message", ".", "new", "(", "body", ":", "options", "[", ":body", "]", ",", "from", ":", "options", "[", ":from", "]", ",", "to", ":", "options", "[", ":to", "]", ",", "type", ":", "opt...
Send a message @option options [String] :body Message body @option options [String] :from Sender's JID @option options [String] :to Address JID @option options [String] :type Message type (e.g. chat, groupchat) @return [REXML::Element] Returns an element sent to server @example client.say(body: "Thanks", from:...
[ "Send", "a", "message" ]
ddc0af9682fc2cdaf851f88a3f0953a1478f1954
https://github.com/r7kamura/xrc/blob/ddc0af9682fc2cdaf851f88a3f0953a1478f1954/lib/xrc/client.rb#L123-L130
4,268
scrapper/perobs
lib/perobs/BigArray.rb
PEROBS.BigArray.[]=
def []=(index, value) index = validate_index_range(index) @store.transaction do if index < @entry_counter # Overwrite of an existing element @root.set(index, value) elsif index == @entry_counter # Append right at the end @root.insert(index, value) ...
ruby
def []=(index, value) index = validate_index_range(index) @store.transaction do if index < @entry_counter # Overwrite of an existing element @root.set(index, value) elsif index == @entry_counter # Append right at the end @root.insert(index, value) ...
[ "def", "[]=", "(", "index", ",", "value", ")", "index", "=", "validate_index_range", "(", "index", ")", "@store", ".", "transaction", "do", "if", "index", "<", "@entry_counter", "# Overwrite of an existing element", "@root", ".", "set", "(", "index", ",", "val...
Store the value at the given index. If the index already exists the old value will be overwritten. @param index [Integer] Position in the array @param value [Integer] value
[ "Store", "the", "value", "at", "the", "given", "index", ".", "If", "the", "index", "already", "exists", "the", "old", "value", "will", "be", "overwritten", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/BigArray.rb#L78-L98
4,269
scrapper/perobs
lib/perobs/BigArray.rb
PEROBS.BigArray.insert
def insert(index, value) index = validate_index_range(index) if index < @entry_counter # Insert in between existing elements @store.transaction do @root.insert(index, value) self.entry_counter += 1 end else self[index] = value end end
ruby
def insert(index, value) index = validate_index_range(index) if index < @entry_counter # Insert in between existing elements @store.transaction do @root.insert(index, value) self.entry_counter += 1 end else self[index] = value end end
[ "def", "insert", "(", "index", ",", "value", ")", "index", "=", "validate_index_range", "(", "index", ")", "if", "index", "<", "@entry_counter", "# Insert in between existing elements", "@store", ".", "transaction", "do", "@root", ".", "insert", "(", "index", ",...
Insert the value at the given index. If the index already exists the old value will be overwritten. @param index [Integer] Position in the array @param value [Integer] value
[ "Insert", "the", "value", "at", "the", "given", "index", ".", "If", "the", "index", "already", "exists", "the", "old", "value", "will", "be", "overwritten", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/BigArray.rb#L108-L120
4,270
scrapper/perobs
lib/perobs/BigArray.rb
PEROBS.BigArray.delete_if
def delete_if old_root = @root clear old_root.each do |k, v| if !yield(k, v) insert(k, v) end end end
ruby
def delete_if old_root = @root clear old_root.each do |k, v| if !yield(k, v) insert(k, v) end end end
[ "def", "delete_if", "old_root", "=", "@root", "clear", "old_root", ".", "each", "do", "|", "k", ",", "v", "|", "if", "!", "yield", "(", "k", ",", "v", ")", "insert", "(", "k", ",", "v", ")", "end", "end", "end" ]
Delete all entries for which the passed block yields true. The implementation is optimized for large bulk deletes. It rebuilds a new BTree for the elements to keep. If only few elements are deleted the overhead of rebuilding the BTree is rather high. @yield [key, value]
[ "Delete", "all", "entries", "for", "which", "the", "passed", "block", "yields", "true", ".", "The", "implementation", "is", "optimized", "for", "large", "bulk", "deletes", ".", "It", "rebuilds", "a", "new", "BTree", "for", "the", "elements", "to", "keep", ...
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/BigArray.rb#L171-L179
4,271
scrapper/perobs
lib/perobs/BigArray.rb
PEROBS.BigArray.each
def each(&block) node = @first_leaf while node break unless node.each(&block) node = node.next_sibling end end
ruby
def each(&block) node = @first_leaf while node break unless node.each(&block) node = node.next_sibling end end
[ "def", "each", "(", "&", "block", ")", "node", "=", "@first_leaf", "while", "node", "break", "unless", "node", ".", "each", "(", "block", ")", "node", "=", "node", ".", "next_sibling", "end", "end" ]
Iterate over all entries in the tree. Entries are always sorted by the key. @yield [key, value]
[ "Iterate", "over", "all", "entries", "in", "the", "tree", ".", "Entries", "are", "always", "sorted", "by", "the", "key", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/BigArray.rb#L196-L202
4,272
scrapper/perobs
lib/perobs/BigArray.rb
PEROBS.BigArray.reverse_each
def reverse_each(&block) node = @last_leaf while node break unless node.reverse_each(&block) node = node.prev_sibling end end
ruby
def reverse_each(&block) node = @last_leaf while node break unless node.reverse_each(&block) node = node.prev_sibling end end
[ "def", "reverse_each", "(", "&", "block", ")", "node", "=", "@last_leaf", "while", "node", "break", "unless", "node", ".", "reverse_each", "(", "block", ")", "node", "=", "node", ".", "prev_sibling", "end", "end" ]
Iterate over all entries in the tree in reverse order. Entries are always sorted by the key. @yield [key, value]
[ "Iterate", "over", "all", "entries", "in", "the", "tree", "in", "reverse", "order", ".", "Entries", "are", "always", "sorted", "by", "the", "key", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/BigArray.rb#L207-L213
4,273
scrapper/perobs
lib/perobs/BigArray.rb
PEROBS.BigArray.to_a
def to_a ary = [] node = @first_leaf while node do ary += node.values node = node.next_sibling end ary end
ruby
def to_a ary = [] node = @first_leaf while node do ary += node.values node = node.next_sibling end ary end
[ "def", "to_a", "ary", "=", "[", "]", "node", "=", "@first_leaf", "while", "node", "do", "ary", "+=", "node", ".", "values", "node", "=", "node", ".", "next_sibling", "end", "ary", "end" ]
Convert the BigArray into a Ruby Array. This is primarily intended for debugging as real-world BigArray objects are likely too big to fit into memory.
[ "Convert", "the", "BigArray", "into", "a", "Ruby", "Array", ".", "This", "is", "primarily", "intended", "for", "debugging", "as", "real", "-", "world", "BigArray", "objects", "are", "likely", "too", "big", "to", "fit", "into", "memory", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/BigArray.rb#L218-L227
4,274
scrapper/perobs
lib/perobs/SpaceTreeNode.rb
PEROBS.SpaceTreeNode.save
def save bytes = [ @blob_address, @size, @parent ? @parent.node_address : 0, @smaller ? @smaller.node_address : 0, @equal ? @equal.node_address : 0, @larger ? @larger.node_address : 0].pack(NODE_BYTES_FORMAT) @tree.nodes.store_blob(@node_addres...
ruby
def save bytes = [ @blob_address, @size, @parent ? @parent.node_address : 0, @smaller ? @smaller.node_address : 0, @equal ? @equal.node_address : 0, @larger ? @larger.node_address : 0].pack(NODE_BYTES_FORMAT) @tree.nodes.store_blob(@node_addres...
[ "def", "save", "bytes", "=", "[", "@blob_address", ",", "@size", ",", "@parent", "?", "@parent", ".", "node_address", ":", "0", ",", "@smaller", "?", "@smaller", ".", "node_address", ":", "0", ",", "@equal", "?", "@equal", ".", "node_address", ":", "0", ...
Save the node into the blob file.
[ "Save", "the", "node", "into", "the", "blob", "file", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/SpaceTreeNode.rb#L128-L135
4,275
scrapper/perobs
lib/perobs/SpaceTreeNode.rb
PEROBS.SpaceTreeNode.add_space
def add_space(address, size) node = self loop do if node.size == 0 # This happens only for the root node if the tree is empty. node.set_size_and_address(size, address) break elsif size < node.size # The new size is smaller than this node. if...
ruby
def add_space(address, size) node = self loop do if node.size == 0 # This happens only for the root node if the tree is empty. node.set_size_and_address(size, address) break elsif size < node.size # The new size is smaller than this node. if...
[ "def", "add_space", "(", "address", ",", "size", ")", "node", "=", "self", "loop", "do", "if", "node", ".", "size", "==", "0", "# This happens only for the root node if the tree is empty.", "node", ".", "set_size_and_address", "(", "size", ",", "address", ")", "...
Add a new node for the given address and size to the tree. @param address [Integer] address of the free space @param size [Integer] size of the free space
[ "Add", "a", "new", "node", "for", "the", "given", "address", "and", "size", "to", "the", "tree", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/SpaceTreeNode.rb#L140-L183
4,276
scrapper/perobs
lib/perobs/SpaceTreeNode.rb
PEROBS.SpaceTreeNode.has_space?
def has_space?(address, size) node = self loop do if node.blob_address == address return size == node.size elsif size < node.size && node.smaller node = node.smaller elsif size > node.size && node.larger node = node.larger elsif size == node.size...
ruby
def has_space?(address, size) node = self loop do if node.blob_address == address return size == node.size elsif size < node.size && node.smaller node = node.smaller elsif size > node.size && node.larger node = node.larger elsif size == node.size...
[ "def", "has_space?", "(", "address", ",", "size", ")", "node", "=", "self", "loop", "do", "if", "node", ".", "blob_address", "==", "address", "return", "size", "==", "node", ".", "size", "elsif", "size", "<", "node", ".", "size", "&&", "node", ".", "...
Check if this node or any sub-node has an entry for the given address and size. @param address [Integer] address of the free space @param size [Integer] size of the free space @return [Boolean] True if found, otherwise false
[ "Check", "if", "this", "node", "or", "any", "sub", "-", "node", "has", "an", "entry", "for", "the", "given", "address", "and", "size", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/SpaceTreeNode.rb#L190-L205
4,277
scrapper/perobs
lib/perobs/SpaceTreeNode.rb
PEROBS.SpaceTreeNode.relink_parent
def relink_parent(node) if @parent if @parent.smaller == self @parent.set_link('@smaller', node) elsif @parent.equal == self @parent.set_link('@equal', node) elsif @parent.larger == self @parent.set_link('@larger', node) else PEROBS.log.fatal...
ruby
def relink_parent(node) if @parent if @parent.smaller == self @parent.set_link('@smaller', node) elsif @parent.equal == self @parent.set_link('@equal', node) elsif @parent.larger == self @parent.set_link('@larger', node) else PEROBS.log.fatal...
[ "def", "relink_parent", "(", "node", ")", "if", "@parent", "if", "@parent", ".", "smaller", "==", "self", "@parent", ".", "set_link", "(", "'@smaller'", ",", "node", ")", "elsif", "@parent", ".", "equal", "==", "self", "@parent", ".", "set_link", "(", "'...
Replace the link in the parent node of the current node that points to the current node with the given node. @param node [SpaceTreeNode]
[ "Replace", "the", "link", "in", "the", "parent", "node", "of", "the", "current", "node", "that", "points", "to", "the", "current", "node", "with", "the", "given", "node", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/SpaceTreeNode.rb#L382-L402
4,278
scrapper/perobs
lib/perobs/SpaceTreeNode.rb
PEROBS.SpaceTreeNode.to_a
def to_a ary = [] each do |node, mode, stack| if mode == :on_enter ary << [ node.blob_address, node.size ] end end ary end
ruby
def to_a ary = [] each do |node, mode, stack| if mode == :on_enter ary << [ node.blob_address, node.size ] end end ary end
[ "def", "to_a", "ary", "=", "[", "]", "each", "do", "|", "node", ",", "mode", ",", "stack", "|", "if", "mode", "==", ":on_enter", "ary", "<<", "[", "node", ".", "blob_address", ",", "node", ".", "size", "]", "end", "end", "ary", "end" ]
Compare this node to another node. @return [Boolean] true if node address is identical, false otherwise Collects address and size touples of all nodes in the tree with a depth-first strategy and stores them in an Array. @return [Array] Array with [ address, size ] touples.
[ "Compare", "this", "node", "to", "another", "node", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/SpaceTreeNode.rb#L467-L477
4,279
scrapper/perobs
lib/perobs/SpaceTreeNode.rb
PEROBS.SpaceTreeNode.check
def check(flat_file, count) node_counter = 0 max_depth = 0 @tree.progressmeter.start('Checking space list entries', count) do |pm| each do |node, mode, stack| max_depth = stack.size if stack.size > max_depth case mode when :smaller if node.smaller ...
ruby
def check(flat_file, count) node_counter = 0 max_depth = 0 @tree.progressmeter.start('Checking space list entries', count) do |pm| each do |node, mode, stack| max_depth = stack.size if stack.size > max_depth case mode when :smaller if node.smaller ...
[ "def", "check", "(", "flat_file", ",", "count", ")", "node_counter", "=", "0", "max_depth", "=", "0", "@tree", ".", "progressmeter", ".", "start", "(", "'Checking space list entries'", ",", "count", ")", "do", "|", "pm", "|", "each", "do", "|", "node", "...
Check this node and all sub nodes for possible structural or logical errors. @param flat_file [FlatFile] If given, check that the space is also present in the given flat file. @param count [Integer] The total number of entries in the tree @return [false,true] True if OK, false otherwise
[ "Check", "this", "node", "and", "all", "sub", "nodes", "for", "possible", "structural", "or", "logical", "errors", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/SpaceTreeNode.rb#L523-L586
4,280
scrapper/perobs
lib/perobs/SpaceTreeNode.rb
PEROBS.SpaceTreeNode.check_node_link
def check_node_link(link, stack) if (node = instance_variable_get('@' + link)) # Node links must only be of class SpaceTreeNodeLink unless node.nil? || node.is_a?(SpaceTreeNodeLink) PEROBS.log.error "Node link #{link} of node #{to_s} " + "is of class #{node.class}" ...
ruby
def check_node_link(link, stack) if (node = instance_variable_get('@' + link)) # Node links must only be of class SpaceTreeNodeLink unless node.nil? || node.is_a?(SpaceTreeNodeLink) PEROBS.log.error "Node link #{link} of node #{to_s} " + "is of class #{node.class}" ...
[ "def", "check_node_link", "(", "link", ",", "stack", ")", "if", "(", "node", "=", "instance_variable_get", "(", "'@'", "+", "link", ")", ")", "# Node links must only be of class SpaceTreeNodeLink", "unless", "node", ".", "nil?", "||", "node", ".", "is_a?", "(", ...
Check the integrity of the given sub-node link and the parent link pointing back to this node. @param link [String] 'smaller', 'equal' or 'larger' @param stack [Array] List of parent nodes [ address, mode ] touples @return [Boolean] true of OK, false otherwise
[ "Check", "the", "integrity", "of", "the", "given", "sub", "-", "node", "link", "and", "the", "parent", "link", "pointing", "back", "to", "this", "node", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/SpaceTreeNode.rb#L593-L629
4,281
scrapper/perobs
lib/perobs/SpaceTreeNode.rb
PEROBS.SpaceTreeNode.to_tree_s
def to_tree_s str = '' each do |node, mode, stack| if mode == :on_enter begin branch_mark = node.parent.nil? ? '' : node.parent.smaller == node ? '<' : node.parent.equal == node ? '=' : node.parent.larger == node ? '>' : '@' ...
ruby
def to_tree_s str = '' each do |node, mode, stack| if mode == :on_enter begin branch_mark = node.parent.nil? ? '' : node.parent.smaller == node ? '<' : node.parent.equal == node ? '=' : node.parent.larger == node ? '>' : '@' ...
[ "def", "to_tree_s", "str", "=", "''", "each", "do", "|", "node", ",", "mode", ",", "stack", "|", "if", "mode", "==", ":on_enter", "begin", "branch_mark", "=", "node", ".", "parent", ".", "nil?", "?", "''", ":", "node", ".", "parent", ".", "smaller", ...
Convert the node and all child nodes into a tree like text form. @return [String]
[ "Convert", "the", "node", "and", "all", "child", "nodes", "into", "a", "tree", "like", "text", "form", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/SpaceTreeNode.rb#L633-L654
4,282
scrapper/perobs
lib/perobs/SpaceTreeNode.rb
PEROBS.SpaceTreeNode.text_tree_prefix
def text_tree_prefix if (node = @parent) str = '+' else # Prefix start for root node line str = 'o' end while node last_child = false if node.parent if node.parent.smaller == node last_child = node.parent.equal.nil? && node.parent.la...
ruby
def text_tree_prefix if (node = @parent) str = '+' else # Prefix start for root node line str = 'o' end while node last_child = false if node.parent if node.parent.smaller == node last_child = node.parent.equal.nil? && node.parent.la...
[ "def", "text_tree_prefix", "if", "(", "node", "=", "@parent", ")", "str", "=", "'+'", "else", "# Prefix start for root node line", "str", "=", "'o'", "end", "while", "node", "last_child", "=", "false", "if", "node", ".", "parent", "if", "node", ".", "parent"...
The indentation and arch routing for the text tree. @return [String]
[ "The", "indentation", "and", "arch", "routing", "for", "the", "text", "tree", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/SpaceTreeNode.rb#L658-L687
4,283
scrapper/perobs
lib/perobs/PersistentObjectCacheLine.rb
PEROBS.PersistentObjectCacheLine.flush
def flush(now) if now || @entries.length > WATERMARK @entries.each do |e| if e.modified e.obj.save e.modified = false end end # Delete all but the first WATERMARK entry. @entries = @entries[0..WATERMARK - 1] if @entries.length > WATERMAR...
ruby
def flush(now) if now || @entries.length > WATERMARK @entries.each do |e| if e.modified e.obj.save e.modified = false end end # Delete all but the first WATERMARK entry. @entries = @entries[0..WATERMARK - 1] if @entries.length > WATERMAR...
[ "def", "flush", "(", "now", ")", "if", "now", "||", "@entries", ".", "length", ">", "WATERMARK", "@entries", ".", "each", "do", "|", "e", "|", "if", "e", ".", "modified", "e", ".", "obj", ".", "save", "e", ".", "modified", "=", "false", "end", "e...
Save all modified entries and delete all but the most recently added.
[ "Save", "all", "modified", "entries", "and", "delete", "all", "but", "the", "most", "recently", "added", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/PersistentObjectCacheLine.rb#L82-L94
4,284
Absolight/epp-client
lib/epp-client/contact.rb
EPPClient.Contact.contact_check
def contact_check(*contacts) contacts.flatten! response = send_request(contact_check_xml(*contacts)) get_result(:xml => response, :callback => :contact_check_process) end
ruby
def contact_check(*contacts) contacts.flatten! response = send_request(contact_check_xml(*contacts)) get_result(:xml => response, :callback => :contact_check_process) end
[ "def", "contact_check", "(", "*", "contacts", ")", "contacts", ".", "flatten!", "response", "=", "send_request", "(", "contact_check_xml", "(", "contacts", ")", ")", "get_result", "(", ":xml", "=>", "response", ",", ":callback", "=>", ":contact_check_process", "...
Check the availability of contacts takes list of contacts as arguments returns an array of hashes containing three fields : [<tt>:id</tt>] the contact id [<tt>:avail</tt>] wether the contact id can be provisionned. [<tt>:reason</tt>] the server-specific text to help explain why the object cannot be provisi...
[ "Check", "the", "availability", "of", "contacts" ]
c0025daee5e7087f60b654595a8e7d92e966c54e
https://github.com/Absolight/epp-client/blob/c0025daee5e7087f60b654595a8e7d92e966c54e/lib/epp-client/contact.rb#L31-L36
4,285
Absolight/epp-client
lib/epp-client/contact.rb
EPPClient.Contact.contact_info
def contact_info(args) args = { :id => args } if args.is_a?(String) response = send_request(contact_info_xml(args)) get_result(:xml => response, :callback => :contact_info_process) end
ruby
def contact_info(args) args = { :id => args } if args.is_a?(String) response = send_request(contact_info_xml(args)) get_result(:xml => response, :callback => :contact_info_process) end
[ "def", "contact_info", "(", "args", ")", "args", "=", "{", ":id", "=>", "args", "}", "if", "args", ".", "is_a?", "(", "String", ")", "response", "=", "send_request", "(", "contact_info_xml", "(", "args", ")", ")", "get_result", "(", ":xml", "=>", "resp...
Returns the informations about a contact Takes either a unique argument, either a string, representing the contact id or a hash with the following keys : [<tt>:id</tt>] the contact id, and optionnaly [<tt>:authInfo</tt>] an optional authentication information. Returned is a hash mapping as closely as possible t...
[ "Returns", "the", "informations", "about", "a", "contact" ]
c0025daee5e7087f60b654595a8e7d92e966c54e
https://github.com/Absolight/epp-client/blob/c0025daee5e7087f60b654595a8e7d92e966c54e/lib/epp-client/contact.rb#L122-L127
4,286
mreq/wmctile
lib/wmctile/window.rb
Wmctile.Window.find_window
def find_window(current_workspace_only = false) @matching_windows = Wmctile.window_list.grep(@regexp_string) filter_out_workspaces if current_workspace_only if @matching_windows.count > 1 filter_more_matching_windows elsif @matching_windows.count == 1 @matching_line = @matching_w...
ruby
def find_window(current_workspace_only = false) @matching_windows = Wmctile.window_list.grep(@regexp_string) filter_out_workspaces if current_workspace_only if @matching_windows.count > 1 filter_more_matching_windows elsif @matching_windows.count == 1 @matching_line = @matching_w...
[ "def", "find_window", "(", "current_workspace_only", "=", "false", ")", "@matching_windows", "=", "Wmctile", ".", "window_list", ".", "grep", "(", "@regexp_string", ")", "filter_out_workspaces", "if", "current_workspace_only", "if", "@matching_windows", ".", "count", ...
Window init function. Tries to find an id. @param [Hash] arguments command line options @param [String] window_string command line string given Filters down the window_list to @matching_windows. @param [Boolean] current_workspace_only Should only the current workspace be used? @return [void]
[ "Window", "init", "function", ".", "Tries", "to", "find", "an", "id", "." ]
a41af5afa310b09c8ba1bd45a134b9b2a87d1a35
https://github.com/mreq/wmctile/blob/a41af5afa310b09c8ba1bd45a134b9b2a87d1a35/lib/wmctile/window.rb#L26-L37
4,287
xinminlabs/synvert-core
lib/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action.rb
Synvert::Core.Rewriter::ReplaceErbStmtWithExprAction.begin_pos
def begin_pos node_begin_pos = @node.loc.expression.begin_pos while @node.loc.expression.source_buffer.source[node_begin_pos -= 1] == ' ' end node_begin_pos - Engine::ERUBY_STMT_SPLITTER.length + 1 end
ruby
def begin_pos node_begin_pos = @node.loc.expression.begin_pos while @node.loc.expression.source_buffer.source[node_begin_pos -= 1] == ' ' end node_begin_pos - Engine::ERUBY_STMT_SPLITTER.length + 1 end
[ "def", "begin_pos", "node_begin_pos", "=", "@node", ".", "loc", ".", "expression", ".", "begin_pos", "while", "@node", ".", "loc", ".", "expression", ".", "source_buffer", ".", "source", "[", "node_begin_pos", "-=", "1", "]", "==", "' '", "end", "node_begin_...
Begin position of code to replace. @return [Integer] begin position.
[ "Begin", "position", "of", "code", "to", "replace", "." ]
a490bfd30eaec81002d10f8fb61b49138708e46c
https://github.com/xinminlabs/synvert-core/blob/a490bfd30eaec81002d10f8fb61b49138708e46c/lib/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action.rb#L14-L19
4,288
xinminlabs/synvert-core
lib/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action.rb
Synvert::Core.Rewriter::ReplaceErbStmtWithExprAction.end_pos
def end_pos node_begin_pos = @node.loc.expression.begin_pos node_begin_pos += @node.loc.expression.source.index "do" while @node.loc.expression.source_buffer.source[node_begin_pos += 1] != '@' end node_begin_pos end
ruby
def end_pos node_begin_pos = @node.loc.expression.begin_pos node_begin_pos += @node.loc.expression.source.index "do" while @node.loc.expression.source_buffer.source[node_begin_pos += 1] != '@' end node_begin_pos end
[ "def", "end_pos", "node_begin_pos", "=", "@node", ".", "loc", ".", "expression", ".", "begin_pos", "node_begin_pos", "+=", "@node", ".", "loc", ".", "expression", ".", "source", ".", "index", "\"do\"", "while", "@node", ".", "loc", ".", "expression", ".", ...
End position of code to replace. @return [Integer] end position.
[ "End", "position", "of", "code", "to", "replace", "." ]
a490bfd30eaec81002d10f8fb61b49138708e46c
https://github.com/xinminlabs/synvert-core/blob/a490bfd30eaec81002d10f8fb61b49138708e46c/lib/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action.rb#L24-L30
4,289
xinminlabs/synvert-core
lib/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action.rb
Synvert::Core.Rewriter::ReplaceErbStmtWithExprAction.rewritten_code
def rewritten_code @node.loc.expression.source_buffer.source[begin_pos...end_pos].sub(Engine::ERUBY_STMT_SPLITTER, "@output_buffer.append= ") .sub(Engine::ERUBY_STMT_SPLITTER, Engine::ERUBY_EXPR_SPLITTER) end
ruby
def rewritten_code @node.loc.expression.source_buffer.source[begin_pos...end_pos].sub(Engine::ERUBY_STMT_SPLITTER, "@output_buffer.append= ") .sub(Engine::ERUBY_STMT_SPLITTER, Engine::ERUBY_EXPR_SPLITTER) end
[ "def", "rewritten_code", "@node", ".", "loc", ".", "expression", ".", "source_buffer", ".", "source", "[", "begin_pos", "...", "end_pos", "]", ".", "sub", "(", "Engine", "::", "ERUBY_STMT_SPLITTER", ",", "\"@output_buffer.append= \"", ")", ".", "sub", "(", "En...
The rewritten erb expr code. @return [String] rewritten code.
[ "The", "rewritten", "erb", "expr", "code", "." ]
a490bfd30eaec81002d10f8fb61b49138708e46c
https://github.com/xinminlabs/synvert-core/blob/a490bfd30eaec81002d10f8fb61b49138708e46c/lib/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action.rb#L35-L38
4,290
jeffnyman/tapestry
lib/tapestry/factory.rb
Tapestry.Factory.verify_page
def verify_page(context) return if context.url_match_attribute.nil? return if context.has_correct_url? raise Tapestry::Errors::PageURLFromFactoryNotVerified end
ruby
def verify_page(context) return if context.url_match_attribute.nil? return if context.has_correct_url? raise Tapestry::Errors::PageURLFromFactoryNotVerified end
[ "def", "verify_page", "(", "context", ")", "return", "if", "context", ".", "url_match_attribute", ".", "nil?", "return", "if", "context", ".", "has_correct_url?", "raise", "Tapestry", "::", "Errors", "::", "PageURLFromFactoryNotVerified", "end" ]
This method is used to provide a means for checking if a page has been navigated to correctly as part of a context. This is useful because the context signature should remain highly readable, and checks for whether a given page has been reached would make the context definition look sloppy.
[ "This", "method", "is", "used", "to", "provide", "a", "means", "for", "checking", "if", "a", "page", "has", "been", "navigated", "to", "correctly", "as", "part", "of", "a", "context", ".", "This", "is", "useful", "because", "the", "context", "signature", ...
da28652dd6de71e415cd2c01afd89f641938a05b
https://github.com/jeffnyman/tapestry/blob/da28652dd6de71e415cd2c01afd89f641938a05b/lib/tapestry/factory.rb#L86-L90
4,291
scrapper/perobs
lib/perobs/Cache.rb
PEROBS.Cache.cache_read
def cache_read(obj) # This is just a safety check. It can probably be disabled in the future # to increase performance. if obj.respond_to?(:is_poxreference?) # If this condition triggers, we have a bug in the library. PEROBS.log.fatal "POXReference objects should never be cached" ...
ruby
def cache_read(obj) # This is just a safety check. It can probably be disabled in the future # to increase performance. if obj.respond_to?(:is_poxreference?) # If this condition triggers, we have a bug in the library. PEROBS.log.fatal "POXReference objects should never be cached" ...
[ "def", "cache_read", "(", "obj", ")", "# This is just a safety check. It can probably be disabled in the future", "# to increase performance.", "if", "obj", ".", "respond_to?", "(", ":is_poxreference?", ")", "# If this condition triggers, we have a bug in the library.", "PEROBS", "."...
Create a new Cache object. @param bits [Integer] Number of bits for the cache index. This parameter heavilty affects the performance and memory consumption of the cache. Add an PEROBS::Object to the read cache. @param obj [PEROBS::ObjectBase]
[ "Create", "a", "new", "Cache", "object", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/Cache.rb#L54-L62
4,292
scrapper/perobs
lib/perobs/Cache.rb
PEROBS.Cache.begin_transaction
def begin_transaction if @transaction_stack.empty? # The new transaction is the top-level transaction. Flush the write # buffer to save the current state of all objects. flush else # Save a copy of all objects that were modified during the enclosing # transaction. ...
ruby
def begin_transaction if @transaction_stack.empty? # The new transaction is the top-level transaction. Flush the write # buffer to save the current state of all objects. flush else # Save a copy of all objects that were modified during the enclosing # transaction. ...
[ "def", "begin_transaction", "if", "@transaction_stack", ".", "empty?", "# The new transaction is the top-level transaction. Flush the write", "# buffer to save the current state of all objects.", "flush", "else", "# Save a copy of all objects that were modified during the enclosing", "# transa...
Tell the cache to start a new transaction. If no other transaction is active, the write cache is flushed before the transaction is started.
[ "Tell", "the", "cache", "to", "start", "a", "new", "transaction", ".", "If", "no", "other", "transaction", "is", "active", "the", "write", "cache", "is", "flushed", "before", "the", "transaction", "is", "started", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/Cache.rb#L128-L143
4,293
scrapper/perobs
lib/perobs/Cache.rb
PEROBS.Cache.end_transaction
def end_transaction case @transaction_stack.length when 0 PEROBS.log.fatal 'No ongoing transaction to end' when 1 # All transactions completed successfully. Write all modified objects # into the backend storage. @transaction_stack.pop.each { |id| @transaction_objects[id...
ruby
def end_transaction case @transaction_stack.length when 0 PEROBS.log.fatal 'No ongoing transaction to end' when 1 # All transactions completed successfully. Write all modified objects # into the backend storage. @transaction_stack.pop.each { |id| @transaction_objects[id...
[ "def", "end_transaction", "case", "@transaction_stack", ".", "length", "when", "0", "PEROBS", ".", "log", ".", "fatal", "'No ongoing transaction to end'", "when", "1", "# All transactions completed successfully. Write all modified objects", "# into the backend storage.", "@transa...
Tell the cache to end the currently active transaction. All write operations of the current transaction will be synced to the storage back-end.
[ "Tell", "the", "cache", "to", "end", "the", "currently", "active", "transaction", ".", "All", "write", "operations", "of", "the", "current", "transaction", "will", "be", "synced", "to", "the", "storage", "back", "-", "end", "." ]
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/Cache.rb#L148-L166
4,294
scrapper/perobs
lib/perobs/Cache.rb
PEROBS.Cache.abort_transaction
def abort_transaction if @transaction_stack.empty? PEROBS.log.fatal 'No ongoing transaction to abort' end @transaction_stack.pop.each do |id| @transaction_objects[id]._restore(@transaction_stack.length) end end
ruby
def abort_transaction if @transaction_stack.empty? PEROBS.log.fatal 'No ongoing transaction to abort' end @transaction_stack.pop.each do |id| @transaction_objects[id]._restore(@transaction_stack.length) end end
[ "def", "abort_transaction", "if", "@transaction_stack", ".", "empty?", "PEROBS", ".", "log", ".", "fatal", "'No ongoing transaction to abort'", "end", "@transaction_stack", ".", "pop", ".", "each", "do", "|", "id", "|", "@transaction_objects", "[", "id", "]", ".",...
Tell the cache to abort the currently active transaction. All modified objects will be restored from the storage back-end to their state before the transaction started.
[ "Tell", "the", "cache", "to", "abort", "the", "currently", "active", "transaction", ".", "All", "modified", "objects", "will", "be", "restored", "from", "the", "storage", "back", "-", "end", "to", "their", "state", "before", "the", "transaction", "started", ...
1c9327656912cf96683849f92d260546af856adf
https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/Cache.rb#L171-L178
4,295
proglottis/glicko2
lib/glicko2/player.rb
Glicko2.Player.update_obj
def update_obj mean, sd = rating.to_glicko_rating @obj.rating = mean @obj.rating_deviation = sd @obj.volatility = volatility end
ruby
def update_obj mean, sd = rating.to_glicko_rating @obj.rating = mean @obj.rating_deviation = sd @obj.volatility = volatility end
[ "def", "update_obj", "mean", ",", "sd", "=", "rating", ".", "to_glicko_rating", "@obj", ".", "rating", "=", "mean", "@obj", ".", "rating_deviation", "=", "sd", "@obj", ".", "volatility", "=", "volatility", "end" ]
Update seed object with this player's values
[ "Update", "seed", "object", "with", "this", "player", "s", "values" ]
8ede9a758a1a35b2bc5e6d4706aad856ec8f7812
https://github.com/proglottis/glicko2/blob/8ede9a758a1a35b2bc5e6d4706aad856ec8f7812/lib/glicko2/player.rb#L22-L27
4,296
dirkholzapfel/abuelo
lib/abuelo/graph.rb
Abuelo.Graph.add_node
def add_node(node) raise Abuelo::Exceptions::NodeAlreadyExistsError if has_node?(node) @nodes[node.name] = node node.graph = self self end
ruby
def add_node(node) raise Abuelo::Exceptions::NodeAlreadyExistsError if has_node?(node) @nodes[node.name] = node node.graph = self self end
[ "def", "add_node", "(", "node", ")", "raise", "Abuelo", "::", "Exceptions", "::", "NodeAlreadyExistsError", "if", "has_node?", "(", "node", ")", "@nodes", "[", "node", ".", "name", "]", "=", "node", "node", ".", "graph", "=", "self", "self", "end" ]
Adds a node to the graph. @param [Abuelo::Node] node to add @return [Abuelo::Graph] the graph @raise [Abuelo::Exceptions::NodeAlreadyExistsError] if the node is already contained in the graph
[ "Adds", "a", "node", "to", "the", "graph", "." ]
3395b4ea386a12dfe747228eaf400029bcc1143a
https://github.com/dirkholzapfel/abuelo/blob/3395b4ea386a12dfe747228eaf400029bcc1143a/lib/abuelo/graph.rb#L80-L87
4,297
dirkholzapfel/abuelo
lib/abuelo/graph.rb
Abuelo.Graph.add_edge
def add_edge(edge, opts = {}) raise Abuelo::Exceptions::EdgeAlreadyExistsError if has_edge?(edge) @edges[edge.node_1] ||= {} @edges[edge.node_1][edge.node_2] = edge if undirected? && !opts[:symmetric] add_edge(edge.symmetric, symmetric: true) end self end
ruby
def add_edge(edge, opts = {}) raise Abuelo::Exceptions::EdgeAlreadyExistsError if has_edge?(edge) @edges[edge.node_1] ||= {} @edges[edge.node_1][edge.node_2] = edge if undirected? && !opts[:symmetric] add_edge(edge.symmetric, symmetric: true) end self end
[ "def", "add_edge", "(", "edge", ",", "opts", "=", "{", "}", ")", "raise", "Abuelo", "::", "Exceptions", "::", "EdgeAlreadyExistsError", "if", "has_edge?", "(", "edge", ")", "@edges", "[", "edge", ".", "node_1", "]", "||=", "{", "}", "@edges", "[", "edg...
Adds an edge to the graph. Auto-adds the symmetric counterpart if graph is undirected. @param [Abuelo::Edge] edge to add @return [Abuelo::Graph] the graph @raise [Abuelo::Exceptions::EdgeAlreadyExistsError] if the edge is already contained in the graph
[ "Adds", "an", "edge", "to", "the", "graph", ".", "Auto", "-", "adds", "the", "symmetric", "counterpart", "if", "graph", "is", "undirected", "." ]
3395b4ea386a12dfe747228eaf400029bcc1143a
https://github.com/dirkholzapfel/abuelo/blob/3395b4ea386a12dfe747228eaf400029bcc1143a/lib/abuelo/graph.rb#L154-L165
4,298
xinminlabs/synvert-core
lib/synvert/core/rewriter/instance.rb
Synvert::Core.Rewriter::Instance.process
def process file_pattern = File.join(Configuration.instance.get(:path), @file_pattern) Dir.glob(file_pattern).each do |file_path| unless Configuration.instance.get(:skip_files).include? file_path begin conflict_actions = [] source = self.class.file_source(file_path)...
ruby
def process file_pattern = File.join(Configuration.instance.get(:path), @file_pattern) Dir.glob(file_pattern).each do |file_path| unless Configuration.instance.get(:skip_files).include? file_path begin conflict_actions = [] source = self.class.file_source(file_path)...
[ "def", "process", "file_pattern", "=", "File", ".", "join", "(", "Configuration", ".", "instance", ".", "get", "(", ":path", ")", ",", "@file_pattern", ")", "Dir", ".", "glob", "(", "file_pattern", ")", ".", "each", "do", "|", "file_path", "|", "unless",...
Initialize an instance. @param rewriter [Synvert::Core::Rewriter] @param file_pattern [String] pattern to find files, e.g. spec/**/*_spec.rb @param options [Hash] instance options, it includes :sort_by. @param block [Block] block code to find nodes, match conditions and rewrite code. @return [Synvert::Core::Rewri...
[ "Initialize", "an", "instance", "." ]
a490bfd30eaec81002d10f8fb61b49138708e46c
https://github.com/xinminlabs/synvert-core/blob/a490bfd30eaec81002d10f8fb61b49138708e46c/lib/synvert/core/rewriter/instance.rb#L88-L125
4,299
xinminlabs/synvert-core
lib/synvert/core/rewriter/instance.rb
Synvert::Core.Rewriter::Instance.get_conflict_actions
def get_conflict_actions i = @actions.length - 1 j = i - 1 conflict_actions = [] return if i < 0 begin_pos = @actions[i].begin_pos while j > -1 if begin_pos <= @actions[j].end_pos conflict_actions << @actions.delete_at(j) else i = j begi...
ruby
def get_conflict_actions i = @actions.length - 1 j = i - 1 conflict_actions = [] return if i < 0 begin_pos = @actions[i].begin_pos while j > -1 if begin_pos <= @actions[j].end_pos conflict_actions << @actions.delete_at(j) else i = j begi...
[ "def", "get_conflict_actions", "i", "=", "@actions", ".", "length", "-", "1", "j", "=", "i", "-", "1", "conflict_actions", "=", "[", "]", "return", "if", "i", "<", "0", "begin_pos", "=", "@actions", "[", "i", "]", ".", "begin_pos", "while", "j", ">",...
It changes source code from bottom to top, and it can change source code twice at the same time, So if there is an overlap between two actions, it removes the conflict actions and operate them in the next loop.
[ "It", "changes", "source", "code", "from", "bottom", "to", "top", "and", "it", "can", "change", "source", "code", "twice", "at", "the", "same", "time", "So", "if", "there", "is", "an", "overlap", "between", "two", "actions", "it", "removes", "the", "conf...
a490bfd30eaec81002d10f8fb61b49138708e46c
https://github.com/xinminlabs/synvert-core/blob/a490bfd30eaec81002d10f8fb61b49138708e46c/lib/synvert/core/rewriter/instance.rb#L265-L282