id
int32
0
24.9k
repo
stringlengths
5
58
path
stringlengths
9
168
func_name
stringlengths
9
130
original_string
stringlengths
66
10.5k
language
stringclasses
1 value
code
stringlengths
66
10.5k
code_tokens
list
docstring
stringlengths
8
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
94
266
2,600
slon1024/linear-regression
lib/linear-regression/base.rb
Regression.Base.covariance2
def covariance2(xs, ys) raise "Length xs and ys must be equal" unless xs.length == ys.length ev_x, ev_y = mean(xs), mean(ys) xs.zip(ys) .map{|x,y| (x-ev_x) * (y-ev_y)} .inject(0) {|sum, x| sum += x} / xs.length end
ruby
def covariance2(xs, ys) raise "Length xs and ys must be equal" unless xs.length == ys.length ev_x, ev_y = mean(xs), mean(ys) xs.zip(ys) .map{|x,y| (x-ev_x) * (y-ev_y)} .inject(0) {|sum, x| sum += x} / xs.length end
[ "def", "covariance2", "(", "xs", ",", "ys", ")", "raise", "\"Length xs and ys must be equal\"", "unless", "xs", ".", "length", "==", "ys", ".", "length", "ev_x", ",", "ev_y", "=", "mean", "(", "xs", ")", ",", "mean", "(", "ys", ")", "xs", ".", "zip", ...
Another way to implement covariance
[ "Another", "way", "to", "implement", "covariance" ]
cc6cb1adf36bf7fc66286c1c6de1b850737bdd03
https://github.com/slon1024/linear-regression/blob/cc6cb1adf36bf7fc66286c1c6de1b850737bdd03/lib/linear-regression/base.rb#L21-L28
2,601
tkrajina/geoelevations
lib/geoelevation.rb
GeoElevation.Srtm.get_file_name
def get_file_name(latitude, longitude) north_south = latitude >= 0 ? 'N' : 'S' east_west = longitude >= 0 ? 'E' : 'W' lat = latitude.floor.to_i.abs.to_s.rjust(2, '0') lon = longitude.floor.to_i.abs.to_s.rjust(3, '0') "#{north_south}#{lat}#{east_west}#{lon}.h...
ruby
def get_file_name(latitude, longitude) north_south = latitude >= 0 ? 'N' : 'S' east_west = longitude >= 0 ? 'E' : 'W' lat = latitude.floor.to_i.abs.to_s.rjust(2, '0') lon = longitude.floor.to_i.abs.to_s.rjust(3, '0') "#{north_south}#{lat}#{east_west}#{lon}.h...
[ "def", "get_file_name", "(", "latitude", ",", "longitude", ")", "north_south", "=", "latitude", ">=", "0", "?", "'N'", ":", "'S'", "east_west", "=", "longitude", ">=", "0", "?", "'E'", ":", "'W'", "lat", "=", "latitude", ".", "floor", ".", "to_i", ".",...
Return the file name no matter if the actual SRTM file exists.
[ "Return", "the", "file", "name", "no", "matter", "if", "the", "actual", "SRTM", "file", "exists", "." ]
2225da9108e651bfd9857ba010cb5c401b56b22a
https://github.com/tkrajina/geoelevations/blob/2225da9108e651bfd9857ba010cb5c401b56b22a/lib/geoelevation.rb#L81-L89
2,602
tkrajina/geoelevations
lib/geoelevation.rb
GeoElevation.SrtmFile.get_elevation
def get_elevation(latitude, longitude) if ! (@latitude <= latitude && latitude < @latitude + 1) raise "Invalid latitude #{latitude} for file #{@file_name}" end if ! (@longitude <= longitude && longitude < @longitude + 1) raise "Invalid longitude #{long...
ruby
def get_elevation(latitude, longitude) if ! (@latitude <= latitude && latitude < @latitude + 1) raise "Invalid latitude #{latitude} for file #{@file_name}" end if ! (@longitude <= longitude && longitude < @longitude + 1) raise "Invalid longitude #{long...
[ "def", "get_elevation", "(", "latitude", ",", "longitude", ")", "if", "!", "(", "@latitude", "<=", "latitude", "&&", "latitude", "<", "@latitude", "+", "1", ")", "raise", "\"Invalid latitude #{latitude} for file #{@file_name}\"", "end", "if", "!", "(", "@longitude...
If approximate is True then only the points from SRTM grid will be used, otherwise a basic aproximation of nearby points will be calculated.
[ "If", "approximate", "is", "True", "then", "only", "the", "points", "from", "SRTM", "grid", "will", "be", "used", "otherwise", "a", "basic", "aproximation", "of", "nearby", "points", "will", "be", "calculated", "." ]
2225da9108e651bfd9857ba010cb5c401b56b22a
https://github.com/tkrajina/geoelevations/blob/2225da9108e651bfd9857ba010cb5c401b56b22a/lib/geoelevation.rb#L128-L141
2,603
tkrajina/geoelevations
lib/geoelevation.rb
GeoElevation.Undulations.get_value_at_file_position
def get_value_at_file_position(position) @file.seek(4 + position * 4) bytes = @file.read(4) begin value = bytes[0].ord * 256**0 + bytes[1].ord * 256**1 + bytes[2].ord * 256**2 + bytes[3].ord * 256**3 result = unpack(value) rescue ...
ruby
def get_value_at_file_position(position) @file.seek(4 + position * 4) bytes = @file.read(4) begin value = bytes[0].ord * 256**0 + bytes[1].ord * 256**1 + bytes[2].ord * 256**2 + bytes[3].ord * 256**3 result = unpack(value) rescue ...
[ "def", "get_value_at_file_position", "(", "position", ")", "@file", ".", "seek", "(", "4", "+", "position", "*", "4", ")", "bytes", "=", "@file", ".", "read", "(", "4", ")", "begin", "value", "=", "bytes", "[", "0", "]", ".", "ord", "*", "256", "**...
Loads a value from the n-th position in the EGM file. Every position is a 4-byte real number.
[ "Loads", "a", "value", "from", "the", "n", "-", "th", "position", "in", "the", "EGM", "file", ".", "Every", "position", "is", "a", "4", "-", "byte", "real", "number", "." ]
2225da9108e651bfd9857ba010cb5c401b56b22a
https://github.com/tkrajina/geoelevations/blob/2225da9108e651bfd9857ba010cb5c401b56b22a/lib/geoelevation.rb#L214-L226
2,604
tkrajina/geoelevations
lib/geoelevation.rb
GeoElevation.Undulations.unpack
def unpack(n) sign = n >> 31 exponent = (n >> (32 - 9)) & 0b11111111 value = n & 0b11111111111111111111111 resul = nil if 1 <= exponent and exponent <= 254 result = (-1)**sign * (1 + value * 2**(-23)) * 2**(exponent - 127) elsif ex...
ruby
def unpack(n) sign = n >> 31 exponent = (n >> (32 - 9)) & 0b11111111 value = n & 0b11111111111111111111111 resul = nil if 1 <= exponent and exponent <= 254 result = (-1)**sign * (1 + value * 2**(-23)) * 2**(exponent - 127) elsif ex...
[ "def", "unpack", "(", "n", ")", "sign", "=", "n", ">>", "31", "exponent", "=", "(", "n", ">>", "(", "32", "-", "9", ")", ")", "&", "0b11111111", "value", "=", "n", "&", "0b11111111111111111111111", "resul", "=", "nil", "if", "1", "<=", "exponent", ...
Unpacks a number from the EGM file
[ "Unpacks", "a", "number", "from", "the", "EGM", "file" ]
2225da9108e651bfd9857ba010cb5c401b56b22a
https://github.com/tkrajina/geoelevations/blob/2225da9108e651bfd9857ba010cb5c401b56b22a/lib/geoelevation.rb#L229-L245
2,605
bdwyertech/chef-rundeck2
lib/chef-rundeck/state.rb
ChefRunDeck.State.add_state
def add_state(node, user, params) # => Create a Node-State Object (n = {}) && (n[:name] = node) n[:created] = DateTime.now n[:creator] = user n[:type] = params['type'] if params['type'] # => Build the Updated State update_state(n) # => Return the Added Node find_sta...
ruby
def add_state(node, user, params) # => Create a Node-State Object (n = {}) && (n[:name] = node) n[:created] = DateTime.now n[:creator] = user n[:type] = params['type'] if params['type'] # => Build the Updated State update_state(n) # => Return the Added Node find_sta...
[ "def", "add_state", "(", "node", ",", "user", ",", "params", ")", "# => Create a Node-State Object", "(", "n", "=", "{", "}", ")", "&&", "(", "n", "[", ":name", "]", "=", "node", ")", "n", "[", ":created", "]", "=", "DateTime", ".", "now", "n", "["...
=> Add Node to the State
[ "=", ">", "Add", "Node", "to", "the", "State" ]
5c67fa2a2f4cd01716a0859dd4b900e740dfc8f7
https://github.com/bdwyertech/chef-rundeck2/blob/5c67fa2a2f4cd01716a0859dd4b900e740dfc8f7/lib/chef-rundeck/state.rb#L52-L62
2,606
bdwyertech/chef-rundeck2
lib/chef-rundeck/state.rb
ChefRunDeck.State.delete_state
def delete_state(node) # => Find the Node existing = find_state(node) return 'Node not present in state' unless existing # => Delete the Node from State state.delete(existing) # => Write Out the Updated State write_state # => Return the Deleted Node existing end
ruby
def delete_state(node) # => Find the Node existing = find_state(node) return 'Node not present in state' unless existing # => Delete the Node from State state.delete(existing) # => Write Out the Updated State write_state # => Return the Deleted Node existing end
[ "def", "delete_state", "(", "node", ")", "# => Find the Node", "existing", "=", "find_state", "(", "node", ")", "return", "'Node not present in state'", "unless", "existing", "# => Delete the Node from State", "state", ".", "delete", "(", "existing", ")", "# => Write Ou...
=> Remove Node from the State
[ "=", ">", "Remove", "Node", "from", "the", "State" ]
5c67fa2a2f4cd01716a0859dd4b900e740dfc8f7
https://github.com/bdwyertech/chef-rundeck2/blob/5c67fa2a2f4cd01716a0859dd4b900e740dfc8f7/lib/chef-rundeck/state.rb#L65-L75
2,607
r7kamura/somemoji
lib/somemoji/emoji_collection.rb
Somemoji.EmojiCollection.replace_character
def replace_character(string, &block) string.gsub(character_pattern) do |character| block.call(find_by_character(character), character) end end
ruby
def replace_character(string, &block) string.gsub(character_pattern) do |character| block.call(find_by_character(character), character) end end
[ "def", "replace_character", "(", "string", ",", "&", "block", ")", "string", ".", "gsub", "(", "character_pattern", ")", "do", "|", "character", "|", "block", ".", "call", "(", "find_by_character", "(", "character", ")", ",", "character", ")", "end", "end"...
Replaces emoji characters in a given string with a given block result @param string [String] a string that to be replaced @return [String] a replaced result @example Somemoji.emoji_collection.replace_character("I ❤ Emoji") do |emoji| %(<img alt="#{emoji.character}" class="emoji" src="/images/emoji/#{emoji.ba...
[ "Replaces", "emoji", "characters", "in", "a", "given", "string", "with", "a", "given", "block", "result" ]
43563493df49e92a2c6d59671d04d1fc20849cc9
https://github.com/r7kamura/somemoji/blob/43563493df49e92a2c6d59671d04d1fc20849cc9/lib/somemoji/emoji_collection.rb#L109-L113
2,608
r7kamura/somemoji
lib/somemoji/emoji_collection.rb
Somemoji.EmojiCollection.replace_code
def replace_code(string, &block) string.gsub(code_pattern) do |matched_string| block.call(find_by_code(::Regexp.last_match(1)), matched_string) end end
ruby
def replace_code(string, &block) string.gsub(code_pattern) do |matched_string| block.call(find_by_code(::Regexp.last_match(1)), matched_string) end end
[ "def", "replace_code", "(", "string", ",", "&", "block", ")", "string", ".", "gsub", "(", "code_pattern", ")", "do", "|", "matched_string", "|", "block", ".", "call", "(", "find_by_code", "(", "::", "Regexp", ".", "last_match", "(", "1", ")", ")", ",",...
Replaces emoji codes in a given string with a given block result @param string [String] a string that to be replaced @return [String] a replaced result @example Somemoji.emoji_collection.replace_code("I :heart: Emoji") do |emoji| %(<img alt="#{emoji.character}" class="emoji" src="/images/emoji/#{emoji.base_p...
[ "Replaces", "emoji", "codes", "in", "a", "given", "string", "with", "a", "given", "block", "result" ]
43563493df49e92a2c6d59671d04d1fc20849cc9
https://github.com/r7kamura/somemoji/blob/43563493df49e92a2c6d59671d04d1fc20849cc9/lib/somemoji/emoji_collection.rb#L123-L127
2,609
r7kamura/somemoji
lib/somemoji/emoji_collection.rb
Somemoji.EmojiCollection.search_by_code
def search_by_code(pattern) self.class.new( select do |emoji| pattern === emoji.code || emoji.aliases.any? do |alias_code| pattern === alias_code end end ) end
ruby
def search_by_code(pattern) self.class.new( select do |emoji| pattern === emoji.code || emoji.aliases.any? do |alias_code| pattern === alias_code end end ) end
[ "def", "search_by_code", "(", "pattern", ")", "self", ".", "class", ".", "new", "(", "select", "do", "|", "emoji", "|", "pattern", "===", "emoji", ".", "code", "||", "emoji", ".", "aliases", ".", "any?", "do", "|", "alias_code", "|", "pattern", "===", ...
Searches emojis that match with given pattern @param pattern [Object] @return [Somemoji::EmojiCollection] @example Somemoji.emoji_collection.search_by_code(/^cus/).map(&:code) #=> ["custard", "customs"]
[ "Searches", "emojis", "that", "match", "with", "given", "pattern" ]
43563493df49e92a2c6d59671d04d1fc20849cc9
https://github.com/r7kamura/somemoji/blob/43563493df49e92a2c6d59671d04d1fc20849cc9/lib/somemoji/emoji_collection.rb#L135-L143
2,610
phallguy/scorpion
lib/scorpion/hunt.rb
Scorpion.Hunt.inject
def inject( object ) trip.object = object object.send :scorpion_hunt=, self object.injected_attributes.each do |attr| next if object.send "#{ attr.name }?" next if attr.lazy? object.send :inject_dependency, attr, fetch( attr.contract ) end object.send :on_injecte...
ruby
def inject( object ) trip.object = object object.send :scorpion_hunt=, self object.injected_attributes.each do |attr| next if object.send "#{ attr.name }?" next if attr.lazy? object.send :inject_dependency, attr, fetch( attr.contract ) end object.send :on_injecte...
[ "def", "inject", "(", "object", ")", "trip", ".", "object", "=", "object", "object", ".", "send", ":scorpion_hunt=", ",", "self", "object", ".", "injected_attributes", ".", "each", "do", "|", "attr", "|", "next", "if", "object", ".", "send", "\"#{ attr.nam...
Inject given `object` with its expected dependencies. @param [Scorpion::Object] object to be injected. @return [Scorpion::Object] the injected object.
[ "Inject", "given", "object", "with", "its", "expected", "dependencies", "." ]
0bc9c1111a37e35991d48543dec88a36f16d7aee
https://github.com/phallguy/scorpion/blob/0bc9c1111a37e35991d48543dec88a36f16d7aee/lib/scorpion/hunt.rb#L80-L94
2,611
phallguy/scorpion
lib/scorpion/attribute_set.rb
Scorpion.AttributeSet.define_attribute
def define_attribute( name, contract, **options ) attributes[name.to_sym] = Attribute.new name, contract, options end
ruby
def define_attribute( name, contract, **options ) attributes[name.to_sym] = Attribute.new name, contract, options end
[ "def", "define_attribute", "(", "name", ",", "contract", ",", "**", "options", ")", "attributes", "[", "name", ".", "to_sym", "]", "=", "Attribute", ".", "new", "name", ",", "contract", ",", "options", "end" ]
Define a single attribute with the given name that expects food that will satisfy the contract. @param [String] name of the attribute. @param [Class,Module,Symbol] contract that describes the desired behavior of the injected object. @return [Attribute] the attribute that was created.
[ "Define", "a", "single", "attribute", "with", "the", "given", "name", "that", "expects", "food", "that", "will", "satisfy", "the", "contract", "." ]
0bc9c1111a37e35991d48543dec88a36f16d7aee
https://github.com/phallguy/scorpion/blob/0bc9c1111a37e35991d48543dec88a36f16d7aee/lib/scorpion/attribute_set.rb#L78-L80
2,612
rvm/pluginator
lib/plugins/pluginator/extensions/plugins_map.rb
Pluginator::Extensions.PluginsMap.plugins_map
def plugins_map(type) @plugins_map ||= {} type = type.to_s @plugins_map[type] ||= Hash[ @plugins[type].map do |plugin| [class2name(plugin), plugin] end ] end
ruby
def plugins_map(type) @plugins_map ||= {} type = type.to_s @plugins_map[type] ||= Hash[ @plugins[type].map do |plugin| [class2name(plugin), plugin] end ] end
[ "def", "plugins_map", "(", "type", ")", "@plugins_map", "||=", "{", "}", "type", "=", "type", ".", "to_s", "@plugins_map", "[", "type", "]", "||=", "Hash", "[", "@plugins", "[", "type", "]", ".", "map", "do", "|", "plugin", "|", "[", "class2name", "(...
provide extra map of plugins with symbolized names as keys @param type [String] name of type to generate the map for @return [Hash] map of the names and plugin classes
[ "provide", "extra", "map", "of", "plugins", "with", "symbolized", "names", "as", "keys" ]
e205d0e69334e3789f48f20c6c4d4f9b3fdaaf2f
https://github.com/rvm/pluginator/blob/e205d0e69334e3789f48f20c6c4d4f9b3fdaaf2f/lib/plugins/pluginator/extensions/plugins_map.rb#L32-L40
2,613
grossvogel/websocket-gui
lib/websocket-gui/base.rb
WebsocketGui.Base.run!
def run!(runtime_config = {}) @websocket_config.merge! runtime_config EM.run do if @websocket_config[:tick_interval] EM.add_periodic_timer(@websocket_config[:tick_interval]) do socket_trigger(:on_tick, @socket_connected) end end EventMachine::WebSocket.run(host: @websocket_config[:so...
ruby
def run!(runtime_config = {}) @websocket_config.merge! runtime_config EM.run do if @websocket_config[:tick_interval] EM.add_periodic_timer(@websocket_config[:tick_interval]) do socket_trigger(:on_tick, @socket_connected) end end EventMachine::WebSocket.run(host: @websocket_config[:so...
[ "def", "run!", "(", "runtime_config", "=", "{", "}", ")", "@websocket_config", ".", "merge!", "runtime_config", "EM", ".", "run", "do", "if", "@websocket_config", "[", ":tick_interval", "]", "EM", ".", "add_periodic_timer", "(", "@websocket_config", "[", ":tick_...
start the socket server and the web server, and launch a browser to fetch the view from the web server
[ "start", "the", "socket", "server", "and", "the", "web", "server", "and", "launch", "a", "browser", "to", "fetch", "the", "view", "from", "the", "web", "server" ]
20f4f3f95312ea357c4afafbd1af4509d6fac1a1
https://github.com/grossvogel/websocket-gui/blob/20f4f3f95312ea357c4afafbd1af4509d6fac1a1/lib/websocket-gui/base.rb#L30-L63
2,614
rvm/pluginator
lib/plugins/pluginator/extensions/first_class.rb
Pluginator::Extensions.FirstClass.first_class!
def first_class!(type, klass) @plugins[type] or raise Pluginator::MissingType.new(type, @plugins.keys) klass = string2class(klass) plugins_map(type)[klass] or raise Pluginator::MissingPlugin.new(type, klass, plugins_map(type).keys) end
ruby
def first_class!(type, klass) @plugins[type] or raise Pluginator::MissingType.new(type, @plugins.keys) klass = string2class(klass) plugins_map(type)[klass] or raise Pluginator::MissingPlugin.new(type, klass, plugins_map(type).keys) end
[ "def", "first_class!", "(", "type", ",", "klass", ")", "@plugins", "[", "type", "]", "or", "raise", "Pluginator", "::", "MissingType", ".", "new", "(", "type", ",", "@plugins", ".", "keys", ")", "klass", "=", "string2class", "(", "klass", ")", "plugins_m...
Find first plugin whose class matches the given name. Behaves like `first_class` but throws exceptions if can not find anything. @param type [String] name of type to search for plugins @param klass [Symbol|String] name of the searched class @return [Class] The first plugin that matches the klass @raise [Plug...
[ "Find", "first", "plugin", "whose", "class", "matches", "the", "given", "name", ".", "Behaves", "like", "first_class", "but", "throws", "exceptions", "if", "can", "not", "find", "anything", "." ]
e205d0e69334e3789f48f20c6c4d4f9b3fdaaf2f
https://github.com/rvm/pluginator/blob/e205d0e69334e3789f48f20c6c4d4f9b3fdaaf2f/lib/plugins/pluginator/extensions/first_class.rb#L45-L50
2,615
8x8Cloud/zerigodns
lib/zerigodns/resource.rb
ZerigoDNS::Resource.ClassMethods.process_response
def process_response response without_root = response.body.values.first case when without_root.is_a?(Array) then process_array(response, without_root) when without_root.is_a?(Hash) then from_response(response, without_root) else without_root end end
ruby
def process_response response without_root = response.body.values.first case when without_root.is_a?(Array) then process_array(response, without_root) when without_root.is_a?(Hash) then from_response(response, without_root) else without_root end end
[ "def", "process_response", "response", "without_root", "=", "response", ".", "body", ".", "values", ".", "first", "case", "when", "without_root", ".", "is_a?", "(", "Array", ")", "then", "process_array", "(", "response", ",", "without_root", ")", "when", "with...
Removes the root from the response and hands it off to the class to process it Processes an array response by delegating to the includer's self.from_response @param [Faraday::Response] response The response @return [Object] The result of the parsed response.
[ "Removes", "the", "root", "from", "the", "response", "and", "hands", "it", "off", "to", "the", "class", "to", "process", "it", "Processes", "an", "array", "response", "by", "delegating", "to", "the", "includer", "s", "self", ".", "from_response" ]
cd6085851d8fbf9abaf0cc71345f01a30c85d661
https://github.com/8x8Cloud/zerigodns/blob/cd6085851d8fbf9abaf0cc71345f01a30c85d661/lib/zerigodns/resource.rb#L10-L17
2,616
phallguy/scorpion
lib/scorpion/object.rb
Scorpion.Object.inject_from
def inject_from( dependencies, overwrite = false ) injected_attributes.each do |attr| next unless dependencies.key? attr.name if overwrite || !send( "#{ attr.name }?" ) send( "#{ attr.name }=", dependencies[ attr.name ] ) end end dependencies end
ruby
def inject_from( dependencies, overwrite = false ) injected_attributes.each do |attr| next unless dependencies.key? attr.name if overwrite || !send( "#{ attr.name }?" ) send( "#{ attr.name }=", dependencies[ attr.name ] ) end end dependencies end
[ "def", "inject_from", "(", "dependencies", ",", "overwrite", "=", "false", ")", "injected_attributes", ".", "each", "do", "|", "attr", "|", "next", "unless", "dependencies", ".", "key?", "attr", ".", "name", "if", "overwrite", "||", "!", "send", "(", "\"#{...
Feed dependencies from a hash into their associated attributes. @param [Hash] dependencies hash describing attributes to inject. @param [Boolean] overwrite existing attributes with values in in the hash.
[ "Feed", "dependencies", "from", "a", "hash", "into", "their", "associated", "attributes", "." ]
0bc9c1111a37e35991d48543dec88a36f16d7aee
https://github.com/phallguy/scorpion/blob/0bc9c1111a37e35991d48543dec88a36f16d7aee/lib/scorpion/object.rb#L84-L94
2,617
phallguy/scorpion
lib/scorpion/object.rb
Scorpion.Object.inject_from!
def inject_from!( dependencies, overwrite = false ) injected_attributes.each do |attr| next unless dependencies.key? attr.name val = dependencies.delete( attr.name ) if overwrite || !send( "#{ attr.name }?" ) send( "#{ attr.name }=", val ) end end ...
ruby
def inject_from!( dependencies, overwrite = false ) injected_attributes.each do |attr| next unless dependencies.key? attr.name val = dependencies.delete( attr.name ) if overwrite || !send( "#{ attr.name }?" ) send( "#{ attr.name }=", val ) end end ...
[ "def", "inject_from!", "(", "dependencies", ",", "overwrite", "=", "false", ")", "injected_attributes", ".", "each", "do", "|", "attr", "|", "next", "unless", "dependencies", ".", "key?", "attr", ".", "name", "val", "=", "dependencies", ".", "delete", "(", ...
Injects dependenices from the hash and removes them from the hash. @see #inject_from
[ "Injects", "dependenices", "from", "the", "hash", "and", "removes", "them", "from", "the", "hash", "." ]
0bc9c1111a37e35991d48543dec88a36f16d7aee
https://github.com/phallguy/scorpion/blob/0bc9c1111a37e35991d48543dec88a36f16d7aee/lib/scorpion/object.rb#L98-L109
2,618
8x8Cloud/zerigodns
lib/zerigodns/resource/attributes.rb
ZerigoDNS::Resource::Attributes.InstanceMethods.method_missing
def method_missing mtd, *args if mtd.to_s.chars.to_a.last == '=' raise ArgumentError, "Invalid number of arguments (#{args.length} for 1)" if args.length != 1 attributes[mtd.to_s.slice(0,mtd.to_s.length-1)] = args.first else raise ArgumentError, "Invalid number of arguments (#{args.l...
ruby
def method_missing mtd, *args if mtd.to_s.chars.to_a.last == '=' raise ArgumentError, "Invalid number of arguments (#{args.length} for 1)" if args.length != 1 attributes[mtd.to_s.slice(0,mtd.to_s.length-1)] = args.first else raise ArgumentError, "Invalid number of arguments (#{args.l...
[ "def", "method_missing", "mtd", ",", "*", "args", "if", "mtd", ".", "to_s", ".", "chars", ".", "to_a", ".", "last", "==", "'='", "raise", "ArgumentError", ",", "\"Invalid number of arguments (#{args.length} for 1)\"", "if", "args", ".", "length", "!=", "1", "a...
Allows method-style access to the attributes.
[ "Allows", "method", "-", "style", "access", "to", "the", "attributes", "." ]
cd6085851d8fbf9abaf0cc71345f01a30c85d661
https://github.com/8x8Cloud/zerigodns/blob/cd6085851d8fbf9abaf0cc71345f01a30c85d661/lib/zerigodns/resource/attributes.rb#L10-L18
2,619
notnyt/beaglebone
lib/beaglebone/ain.rb
Beaglebone.AINPin.run_on_change
def run_on_change(callback, mv_change=10, interval=0.01, repeats=nil) AIN::run_on_change(callback, @pin, mv_change, interval, repeats) end
ruby
def run_on_change(callback, mv_change=10, interval=0.01, repeats=nil) AIN::run_on_change(callback, @pin, mv_change, interval, repeats) end
[ "def", "run_on_change", "(", "callback", ",", "mv_change", "=", "10", ",", "interval", "=", "0.01", ",", "repeats", "=", "nil", ")", "AIN", "::", "run_on_change", "(", "callback", ",", "@pin", ",", "mv_change", ",", "interval", ",", "repeats", ")", "end"...
Runs a callback after voltage changes by specified amount. This creates a new thread that runs in the background and polls at specified interval. @param callback A method to call when the change is detected This method should take 4 arguments: the pin, the previous voltage, the current voltage, and the counter @pa...
[ "Runs", "a", "callback", "after", "voltage", "changes", "by", "specified", "amount", ".", "This", "creates", "a", "new", "thread", "that", "runs", "in", "the", "background", "and", "polls", "at", "specified", "interval", "." ]
7caa8f19f017e4a3d489ce8a2e8526c2e36905d5
https://github.com/notnyt/beaglebone/blob/7caa8f19f017e4a3d489ce8a2e8526c2e36905d5/lib/beaglebone/ain.rb#L391-L393
2,620
notnyt/beaglebone
lib/beaglebone/ain.rb
Beaglebone.AINPin.run_on_threshold
def run_on_threshold(callback, mv_lower, mv_upper, mv_reset=10, interval=0.01, repeats=nil) AIN::run_on_threshold(callback, @pin, mv_lower, mv_upper, mv_reset, interval, repeats) end
ruby
def run_on_threshold(callback, mv_lower, mv_upper, mv_reset=10, interval=0.01, repeats=nil) AIN::run_on_threshold(callback, @pin, mv_lower, mv_upper, mv_reset, interval, repeats) end
[ "def", "run_on_threshold", "(", "callback", ",", "mv_lower", ",", "mv_upper", ",", "mv_reset", "=", "10", ",", "interval", "=", "0.01", ",", "repeats", "=", "nil", ")", "AIN", "::", "run_on_threshold", "(", "callback", ",", "@pin", ",", "mv_lower", ",", ...
Runs a callback after voltage changes beyond a certain threshold. This creates a new thread that runs in the background and polls at specified interval. When the voltage crosses the specified thresholds the callback is run. @param callback A method to call when the change is detected. This method should take 6 argu...
[ "Runs", "a", "callback", "after", "voltage", "changes", "beyond", "a", "certain", "threshold", ".", "This", "creates", "a", "new", "thread", "that", "runs", "in", "the", "background", "and", "polls", "at", "specified", "interval", ".", "When", "the", "voltag...
7caa8f19f017e4a3d489ce8a2e8526c2e36905d5
https://github.com/notnyt/beaglebone/blob/7caa8f19f017e4a3d489ce8a2e8526c2e36905d5/lib/beaglebone/ain.rb#L421-L423
2,621
notnyt/beaglebone
lib/beaglebone/ain.rb
Beaglebone.AINPin.run_once_on_threshold
def run_once_on_threshold(callback, mv_lower, mv_upper, mv_reset=10, interval=0.01) AIN::run_once_on_threshold(callback, @pin, mv_lower, mv_upper, mv_reset, interval) end
ruby
def run_once_on_threshold(callback, mv_lower, mv_upper, mv_reset=10, interval=0.01) AIN::run_once_on_threshold(callback, @pin, mv_lower, mv_upper, mv_reset, interval) end
[ "def", "run_once_on_threshold", "(", "callback", ",", "mv_lower", ",", "mv_upper", ",", "mv_reset", "=", "10", ",", "interval", "=", "0.01", ")", "AIN", "::", "run_once_on_threshold", "(", "callback", ",", "@pin", ",", "mv_lower", ",", "mv_upper", ",", "mv_r...
Runs a callback once after voltage crosses a specified threshold. Convenience method for run_on_threshold
[ "Runs", "a", "callback", "once", "after", "voltage", "crosses", "a", "specified", "threshold", ".", "Convenience", "method", "for", "run_on_threshold" ]
7caa8f19f017e4a3d489ce8a2e8526c2e36905d5
https://github.com/notnyt/beaglebone/blob/7caa8f19f017e4a3d489ce8a2e8526c2e36905d5/lib/beaglebone/ain.rb#L428-L430
2,622
datamapper/dm-validations
lib/data_mapper/validation.rb
DataMapper.Validation.validate
def validate(context_name = default_validation_context) errors.clear validation_violations(context_name).each { |v| errors.add(v) } self end
ruby
def validate(context_name = default_validation_context) errors.clear validation_violations(context_name).each { |v| errors.add(v) } self end
[ "def", "validate", "(", "context_name", "=", "default_validation_context", ")", "errors", ".", "clear", "validation_violations", "(", "context_name", ")", ".", "each", "{", "|", "v", "|", "errors", ".", "add", "(", "v", ")", "}", "self", "end" ]
Command a resource to populate its ViolationSet with any violations of its validation Rules in +context_name+ @api public
[ "Command", "a", "resource", "to", "populate", "its", "ViolationSet", "with", "any", "violations", "of", "its", "validation", "Rules", "in", "+", "context_name", "+" ]
21c8ebde52f70c404c2fc8e10242f8cd92b761fc
https://github.com/datamapper/dm-validations/blob/21c8ebde52f70c404c2fc8e10242f8cd92b761fc/lib/data_mapper/validation.rb#L23-L28
2,623
rvm/pluginator
lib/pluginator/group.rb
Pluginator.Group.register_plugin
def register_plugin(type, klass) type = type.to_s @plugins[type] ||= [] @plugins[type].push(klass) unless @plugins[type].include?(klass) end
ruby
def register_plugin(type, klass) type = type.to_s @plugins[type] ||= [] @plugins[type].push(klass) unless @plugins[type].include?(klass) end
[ "def", "register_plugin", "(", "type", ",", "klass", ")", "type", "=", "type", ".", "to_s", "@plugins", "[", "type", "]", "||=", "[", "]", "@plugins", "[", "type", "]", ".", "push", "(", "klass", ")", "unless", "@plugins", "[", "type", "]", ".", "i...
Register a new plugin, can be used to load custom plugins @param type [String] type for the klass @param klass [Class] klass of the plugin to add
[ "Register", "a", "new", "plugin", "can", "be", "used", "to", "load", "custom", "plugins" ]
e205d0e69334e3789f48f20c6c4d4f9b3fdaaf2f
https://github.com/rvm/pluginator/blob/e205d0e69334e3789f48f20c6c4d4f9b3fdaaf2f/lib/pluginator/group.rb#L47-L51
2,624
phallguy/scorpion
lib/scorpion/hunter.rb
Scorpion.Hunter.find_dependency
def find_dependency( hunt ) dependency = dependency_map.find( hunt.contract ) dependency ||= parent.find_dependency( hunt ) if parent dependency end
ruby
def find_dependency( hunt ) dependency = dependency_map.find( hunt.contract ) dependency ||= parent.find_dependency( hunt ) if parent dependency end
[ "def", "find_dependency", "(", "hunt", ")", "dependency", "=", "dependency_map", ".", "find", "(", "hunt", ".", "contract", ")", "dependency", "||=", "parent", ".", "find_dependency", "(", "hunt", ")", "if", "parent", "dependency", "end" ]
Find any explicitly defined dependencies that can satisfy the hunt. @param [Hunt] hunt being resolved. @return [Dependency] the matching dependency if found
[ "Find", "any", "explicitly", "defined", "dependencies", "that", "can", "satisfy", "the", "hunt", "." ]
0bc9c1111a37e35991d48543dec88a36f16d7aee
https://github.com/phallguy/scorpion/blob/0bc9c1111a37e35991d48543dec88a36f16d7aee/lib/scorpion/hunter.rb#L64-L69
2,625
rvm/pluginator
lib/plugins/pluginator/extensions/first_ask.rb
Pluginator::Extensions.FirstAsk.first_ask!
def first_ask!(type, method_name, *params) @plugins[type] or raise Pluginator::MissingType.new(type, @plugins.keys) try_to_find(type, method_name, params) or raise Pluginator::MissingPlugin.new(type, "first_ask: #{method_name}", plugins_map(type).keys) end
ruby
def first_ask!(type, method_name, *params) @plugins[type] or raise Pluginator::MissingType.new(type, @plugins.keys) try_to_find(type, method_name, params) or raise Pluginator::MissingPlugin.new(type, "first_ask: #{method_name}", plugins_map(type).keys) end
[ "def", "first_ask!", "(", "type", ",", "method_name", ",", "*", "params", ")", "@plugins", "[", "type", "]", "or", "raise", "Pluginator", "::", "MissingType", ".", "new", "(", "type", ",", "@plugins", ".", "keys", ")", "try_to_find", "(", "type", ",", ...
Call a method on plugin and return first one that returns `true`. Behaves like `first_ask` but throws exceptions if can not find anything. @param type [String] name of type to search for plugins @param method_name [Symbol] name of the method to execute @param params [Array] params to pass to the called method @ret...
[ "Call", "a", "method", "on", "plugin", "and", "return", "first", "one", "that", "returns", "true", ".", "Behaves", "like", "first_ask", "but", "throws", "exceptions", "if", "can", "not", "find", "anything", "." ]
e205d0e69334e3789f48f20c6c4d4f9b3fdaaf2f
https://github.com/rvm/pluginator/blob/e205d0e69334e3789f48f20c6c4d4f9b3fdaaf2f/lib/plugins/pluginator/extensions/first_ask.rb#L46-L50
2,626
notnyt/beaglebone
lib/beaglebone/gpio.rb
Beaglebone.GPIOPin.run_on_edge
def run_on_edge(callback, edge, timeout=nil, repeats=nil) GPIO::run_on_edge(callback, @pin, edge, timeout, repeats) end
ruby
def run_on_edge(callback, edge, timeout=nil, repeats=nil) GPIO::run_on_edge(callback, @pin, edge, timeout, repeats) end
[ "def", "run_on_edge", "(", "callback", ",", "edge", ",", "timeout", "=", "nil", ",", "repeats", "=", "nil", ")", "GPIO", "::", "run_on_edge", "(", "callback", ",", "@pin", ",", "edge", ",", "timeout", ",", "repeats", ")", "end" ]
Runs a callback on an edge trigger event. This creates a new thread that runs in the background @param callback A method to call when the edge trigger is detected. This method should take 3 arguments, the pin, the edge, and the counter @param edge should be a symbol representing the trigger type, e.g. :RISING, :FA...
[ "Runs", "a", "callback", "on", "an", "edge", "trigger", "event", ".", "This", "creates", "a", "new", "thread", "that", "runs", "in", "the", "background" ]
7caa8f19f017e4a3d489ce8a2e8526c2e36905d5
https://github.com/notnyt/beaglebone/blob/7caa8f19f017e4a3d489ce8a2e8526c2e36905d5/lib/beaglebone/gpio.rb#L652-L654
2,627
8x8Cloud/zerigodns
lib/zerigodns/resource/naming.rb
ZerigoDNS::Resource::Naming.ClassMethods.default_resource_name
def default_resource_name result = self.to_s.split("::").last.gsub(/([A-Z])/, '_\1').downcase result.slice 1, result.length end
ruby
def default_resource_name result = self.to_s.split("::").last.gsub(/([A-Z])/, '_\1').downcase result.slice 1, result.length end
[ "def", "default_resource_name", "result", "=", "self", ".", "to_s", ".", "split", "(", "\"::\"", ")", ".", "last", ".", "gsub", "(", "/", "/", ",", "'_\\1'", ")", ".", "downcase", "result", ".", "slice", "1", ",", "result", ".", "length", "end" ]
Default Resource Name @return [String] generated resource name from class name "e.g. ZerigoDNS::ZoneTemplate -> zone_template"
[ "Default", "Resource", "Name" ]
cd6085851d8fbf9abaf0cc71345f01a30c85d661
https://github.com/8x8Cloud/zerigodns/blob/cd6085851d8fbf9abaf0cc71345f01a30c85d661/lib/zerigodns/resource/naming.rb#L9-L12
2,628
edmundhighcock/hdf5
lib/hdf5.rb
Hdf5.H5Dataspace.offset_simple
def offset_simple(offsets) raise ArgumentError.new("offsets should have ndims elements") unless offsets.size == ndims basic_offset_simple(@id, offsets.ffi_mem_pointer_hsize_t) end
ruby
def offset_simple(offsets) raise ArgumentError.new("offsets should have ndims elements") unless offsets.size == ndims basic_offset_simple(@id, offsets.ffi_mem_pointer_hsize_t) end
[ "def", "offset_simple", "(", "offsets", ")", "raise", "ArgumentError", ".", "new", "(", "\"offsets should have ndims elements\"", ")", "unless", "offsets", ".", "size", "==", "ndims", "basic_offset_simple", "(", "@id", ",", "offsets", ".", "ffi_mem_pointer_hsize_t", ...
Set the offset of the dataspace. offsets should be an ndims-sized array of zero-based integer offsets.
[ "Set", "the", "offset", "of", "the", "dataspace", ".", "offsets", "should", "be", "an", "ndims", "-", "sized", "array", "of", "zero", "-", "based", "integer", "offsets", "." ]
908e90c249501f1583b1995bf20151a7f9e5fe03
https://github.com/edmundhighcock/hdf5/blob/908e90c249501f1583b1995bf20151a7f9e5fe03/lib/hdf5.rb#L294-L297
2,629
dblessing/rundeck-ruby
lib/rundeck/request.rb
Rundeck.Request.api_token_header
def api_token_header(options, path = nil) return nil if path == '/j_security_check' unless @api_token fail Error::MissingCredentials, 'Please set a api_token for user' end options[:headers] = {} if options[:headers].nil? options[:headers].merge!('X-Rundeck-Auth-Token' => @api_token...
ruby
def api_token_header(options, path = nil) return nil if path == '/j_security_check' unless @api_token fail Error::MissingCredentials, 'Please set a api_token for user' end options[:headers] = {} if options[:headers].nil? options[:headers].merge!('X-Rundeck-Auth-Token' => @api_token...
[ "def", "api_token_header", "(", "options", ",", "path", "=", "nil", ")", "return", "nil", "if", "path", "==", "'/j_security_check'", "unless", "@api_token", "fail", "Error", "::", "MissingCredentials", ",", "'Please set a api_token for user'", "end", "options", "[",...
Sets a PRIVATE-TOKEN header for requests. @raise [Error::MissingCredentials] if api_token not set.
[ "Sets", "a", "PRIVATE", "-", "TOKEN", "header", "for", "requests", "." ]
4faa9c7ebe59408ed92e91d68bd05cd9e8706dd2
https://github.com/dblessing/rundeck-ruby/blob/4faa9c7ebe59408ed92e91d68bd05cd9e8706dd2/lib/rundeck/request.rb#L70-L77
2,630
rvm/pluginator
lib/pluginator/name_converter.rb
Pluginator.NameConverter.name2class
def name2class(name) klass = Kernel name.to_s.split(%r{/}).each do |part| klass = klass.const_get( part.capitalize.gsub(/[_-](.)/) { |match| match[1].upcase } ) end klass end
ruby
def name2class(name) klass = Kernel name.to_s.split(%r{/}).each do |part| klass = klass.const_get( part.capitalize.gsub(/[_-](.)/) { |match| match[1].upcase } ) end klass end
[ "def", "name2class", "(", "name", ")", "klass", "=", "Kernel", "name", ".", "to_s", ".", "split", "(", "%r{", "}", ")", ".", "each", "do", "|", "part", "|", "klass", "=", "klass", ".", "const_get", "(", "part", ".", "capitalize", ".", "gsub", "(", ...
full_name => class
[ "full_name", "=", ">", "class" ]
e205d0e69334e3789f48f20c6c4d4f9b3fdaaf2f
https://github.com/rvm/pluginator/blob/e205d0e69334e3789f48f20c6c4d4f9b3fdaaf2f/lib/pluginator/name_converter.rb#L26-L34
2,631
phallguy/scorpion
lib/scorpion/stinger.rb
Scorpion.Stinger.sting!
def sting!( object ) return object unless scorpion if object assign_scorpion object assign_scorpion_to_enumerable object end object end
ruby
def sting!( object ) return object unless scorpion if object assign_scorpion object assign_scorpion_to_enumerable object end object end
[ "def", "sting!", "(", "object", ")", "return", "object", "unless", "scorpion", "if", "object", "assign_scorpion", "object", "assign_scorpion_to_enumerable", "object", "end", "object", "end" ]
Sting an object so that it will be injected with the scorpion and use it to resolve all dependencies. @param [#scorpion] object to sting. @return [object] the object that was stung.
[ "Sting", "an", "object", "so", "that", "it", "will", "be", "injected", "with", "the", "scorpion", "and", "use", "it", "to", "resolve", "all", "dependencies", "." ]
0bc9c1111a37e35991d48543dec88a36f16d7aee
https://github.com/phallguy/scorpion/blob/0bc9c1111a37e35991d48543dec88a36f16d7aee/lib/scorpion/stinger.rb#L34-L43
2,632
rvm/pluginator
lib/plugins/pluginator/extensions/matching.rb
Pluginator::Extensions.Matching.matching
def matching(type, list) list.map do |plugin| (plugins_map(type) || {})[string2class(plugin)] end end
ruby
def matching(type, list) list.map do |plugin| (plugins_map(type) || {})[string2class(plugin)] end end
[ "def", "matching", "(", "type", ",", "list", ")", "list", ".", "map", "do", "|", "plugin", "|", "(", "plugins_map", "(", "type", ")", "||", "{", "}", ")", "[", "string2class", "(", "plugin", ")", "]", "end", "end" ]
Map array of names to available plugins. @param type [String] name of type to search for plugins @param list [Array] list of plugin names to load @return [Array] list of loaded plugins
[ "Map", "array", "of", "names", "to", "available", "plugins", "." ]
e205d0e69334e3789f48f20c6c4d4f9b3fdaaf2f
https://github.com/rvm/pluginator/blob/e205d0e69334e3789f48f20c6c4d4f9b3fdaaf2f/lib/plugins/pluginator/extensions/matching.rb#L34-L38
2,633
rvm/pluginator
lib/plugins/pluginator/extensions/matching.rb
Pluginator::Extensions.Matching.matching!
def matching!(type, list) @plugins[type] or raise Pluginator::MissingType.new(type, @plugins.keys) list.map do |plugin| plugin = string2class(plugin) plugins_map(type)[plugin] or raise Pluginator::MissingPlugin.new(type, plugin, plugins_map(type).keys) end end
ruby
def matching!(type, list) @plugins[type] or raise Pluginator::MissingType.new(type, @plugins.keys) list.map do |plugin| plugin = string2class(plugin) plugins_map(type)[plugin] or raise Pluginator::MissingPlugin.new(type, plugin, plugins_map(type).keys) end end
[ "def", "matching!", "(", "type", ",", "list", ")", "@plugins", "[", "type", "]", "or", "raise", "Pluginator", "::", "MissingType", ".", "new", "(", "type", ",", "@plugins", ".", "keys", ")", "list", ".", "map", "do", "|", "plugin", "|", "plugin", "="...
Map array of names to available plugins. Behaves like `matching` but throws exceptions if can not find anything. @param type [String] name of type to search for plugins @param list [Array] list of plugin names to load @return [Array] list of loaded plugins @raise [Pluginator::MissingPlugin] when can not find...
[ "Map", "array", "of", "names", "to", "available", "plugins", ".", "Behaves", "like", "matching", "but", "throws", "exceptions", "if", "can", "not", "find", "anything", "." ]
e205d0e69334e3789f48f20c6c4d4f9b3fdaaf2f
https://github.com/rvm/pluginator/blob/e205d0e69334e3789f48f20c6c4d4f9b3fdaaf2f/lib/plugins/pluginator/extensions/matching.rb#L46-L53
2,634
dblessing/rundeck-ruby
lib/rundeck/client.rb
Rundeck.Client.objectify
def objectify(result) if result.is_a?(Hash) ObjectifiedHash.new(result) elsif result.is_a?(Array) result.map { |e| ObjectifiedHash.new(e) } elsif result.nil? nil else fail Error::Parsing, "Couldn't parse a response body" end end
ruby
def objectify(result) if result.is_a?(Hash) ObjectifiedHash.new(result) elsif result.is_a?(Array) result.map { |e| ObjectifiedHash.new(e) } elsif result.nil? nil else fail Error::Parsing, "Couldn't parse a response body" end end
[ "def", "objectify", "(", "result", ")", "if", "result", ".", "is_a?", "(", "Hash", ")", "ObjectifiedHash", ".", "new", "(", "result", ")", "elsif", "result", ".", "is_a?", "(", "Array", ")", "result", ".", "map", "{", "|", "e", "|", "ObjectifiedHash", ...
Turn a hash into an object for easy accessibility. @note This method will objectify nested hashes/arrays. @param [Hash, Array] result An array or hash of results to turn into an object @return [Rundeck::ObjectifiedHash] if +result+ was a hash @return [Rundeck::ObjectifiedHash] if +result+ was an array @raise...
[ "Turn", "a", "hash", "into", "an", "object", "for", "easy", "accessibility", "." ]
4faa9c7ebe59408ed92e91d68bd05cd9e8706dd2
https://github.com/dblessing/rundeck-ruby/blob/4faa9c7ebe59408ed92e91d68bd05cd9e8706dd2/lib/rundeck/client.rb#L70-L80
2,635
8x8Cloud/zerigodns
lib/zerigodns/resource/rest.rb
ZerigoDNS::Resource::Rest.ClassMethods.convert
def convert object return {resource_name => object} if object.is_a? Hash {resource_name => object.to_hash} end
ruby
def convert object return {resource_name => object} if object.is_a? Hash {resource_name => object.to_hash} end
[ "def", "convert", "object", "return", "{", "resource_name", "=>", "object", "}", "if", "object", ".", "is_a?", "Hash", "{", "resource_name", "=>", "object", ".", "to_hash", "}", "end" ]
Converts a resource object to a hash. @param [Object] object to convert to a hash @raise [ArgumentError] if the object given does not respond to to_hash
[ "Converts", "a", "resource", "object", "to", "a", "hash", "." ]
cd6085851d8fbf9abaf0cc71345f01a30c85d661
https://github.com/8x8Cloud/zerigodns/blob/cd6085851d8fbf9abaf0cc71345f01a30c85d661/lib/zerigodns/resource/rest.rb#L68-L71
2,636
reqres-api/reqres_rspec
lib/reqres_rspec/collector.rb
ReqresRspec.Collector.sort
def sort self.records.sort! do |x,y| comp = x[:request][:symbolized_path] <=> y[:request][:symbolized_path] comp.zero? ? (x[:title] <=> y[:title]) : comp end end
ruby
def sort self.records.sort! do |x,y| comp = x[:request][:symbolized_path] <=> y[:request][:symbolized_path] comp.zero? ? (x[:title] <=> y[:title]) : comp end end
[ "def", "sort", "self", ".", "records", ".", "sort!", "do", "|", "x", ",", "y", "|", "comp", "=", "x", "[", ":request", "]", "[", ":symbolized_path", "]", "<=>", "y", "[", ":request", "]", "[", ":symbolized_path", "]", "comp", ".", "zero?", "?", "("...
sorts records alphabetically
[ "sorts", "records", "alphabetically" ]
149b67c01e37a2f0cd42c21fdc275ffe6bb9d579
https://github.com/reqres-api/reqres_rspec/blob/149b67c01e37a2f0cd42c21fdc275ffe6bb9d579/lib/reqres_rspec/collector.rb#L146-L151
2,637
reqres-api/reqres_rspec
lib/reqres_rspec/collector.rb
ReqresRspec.Collector.read_response_headers
def read_response_headers(response) raw_headers = response.headers headers = {} EXCLUDE_RESPONSE_HEADER_PATTERNS.each do |pattern| raw_headers = raw_headers.reject { |h| h if h.starts_with? pattern } end raw_headers.each do |key, val| headers.merge!(cleanup_header(key) => v...
ruby
def read_response_headers(response) raw_headers = response.headers headers = {} EXCLUDE_RESPONSE_HEADER_PATTERNS.each do |pattern| raw_headers = raw_headers.reject { |h| h if h.starts_with? pattern } end raw_headers.each do |key, val| headers.merge!(cleanup_header(key) => v...
[ "def", "read_response_headers", "(", "response", ")", "raw_headers", "=", "response", ".", "headers", "headers", "=", "{", "}", "EXCLUDE_RESPONSE_HEADER_PATTERNS", ".", "each", "do", "|", "pattern", "|", "raw_headers", "=", "raw_headers", ".", "reject", "{", "|"...
read and cleanup response headers returns Hash
[ "read", "and", "cleanup", "response", "headers", "returns", "Hash" ]
149b67c01e37a2f0cd42c21fdc275ffe6bb9d579
https://github.com/reqres-api/reqres_rspec/blob/149b67c01e37a2f0cd42c21fdc275ffe6bb9d579/lib/reqres_rspec/collector.rb#L168-L178
2,638
reqres-api/reqres_rspec
lib/reqres_rspec/collector.rb
ReqresRspec.Collector.get_symbolized_path
def get_symbolized_path(request) request_path = (request.env['REQUEST_URI'] || request.path).dup request_params = request.env['action_dispatch.request.parameters'] || request.env['rack.request.form_hash'] || request.env['rack.request.query_hash'] if request_params requ...
ruby
def get_symbolized_path(request) request_path = (request.env['REQUEST_URI'] || request.path).dup request_params = request.env['action_dispatch.request.parameters'] || request.env['rack.request.form_hash'] || request.env['rack.request.query_hash'] if request_params requ...
[ "def", "get_symbolized_path", "(", "request", ")", "request_path", "=", "(", "request", ".", "env", "[", "'REQUEST_URI'", "]", "||", "request", ".", "path", ")", ".", "dup", "request_params", "=", "request", ".", "env", "[", "'action_dispatch.request.parameters'...
replace each first occurrence of param's value in the request path Example: request path = /api/users/123 id = 123 symbolized path => /api/users/:id
[ "replace", "each", "first", "occurrence", "of", "param", "s", "value", "in", "the", "request", "path" ]
149b67c01e37a2f0cd42c21fdc275ffe6bb9d579
https://github.com/reqres-api/reqres_rspec/blob/149b67c01e37a2f0cd42c21fdc275ffe6bb9d579/lib/reqres_rspec/collector.rb#L210-L225
2,639
phallguy/scorpion
lib/scorpion/dependency_map.rb
Scorpion.DependencyMap.capture
def capture( contract, **options, &builder ) active_dependency_set.unshift Dependency::CapturedDependency.new( define_dependency( contract, options, &builder ) ) # rubocop:disable Metrics/LineLength end
ruby
def capture( contract, **options, &builder ) active_dependency_set.unshift Dependency::CapturedDependency.new( define_dependency( contract, options, &builder ) ) # rubocop:disable Metrics/LineLength end
[ "def", "capture", "(", "contract", ",", "**", "options", ",", "&", "builder", ")", "active_dependency_set", ".", "unshift", "Dependency", "::", "CapturedDependency", ".", "new", "(", "define_dependency", "(", "contract", ",", "options", ",", "builder", ")", ")...
Captures a single dependency and returns the same instance fore each request for the resource. @see #hunt_for @return [Dependency] the dependency to be hunted for.
[ "Captures", "a", "single", "dependency", "and", "returns", "the", "same", "instance", "fore", "each", "request", "for", "the", "resource", "." ]
0bc9c1111a37e35991d48543dec88a36f16d7aee
https://github.com/phallguy/scorpion/blob/0bc9c1111a37e35991d48543dec88a36f16d7aee/lib/scorpion/dependency_map.rb#L94-L96
2,640
phallguy/scorpion
lib/scorpion/dependency_map.rb
Scorpion.DependencyMap.replicate_from
def replicate_from( other_map ) other_map.each do |dependency| if replica = dependency.replicate dependency_set << replica end end self end
ruby
def replicate_from( other_map ) other_map.each do |dependency| if replica = dependency.replicate dependency_set << replica end end self end
[ "def", "replicate_from", "(", "other_map", ")", "other_map", ".", "each", "do", "|", "dependency", "|", "if", "replica", "=", "dependency", ".", "replicate", "dependency_set", "<<", "replica", "end", "end", "self", "end" ]
Replicates the dependency in `other_map` into this map. @param [Scorpion::DependencyMap] other_map to replicate from. @return [self]
[ "Replicates", "the", "dependency", "in", "other_map", "into", "this", "map", "." ]
0bc9c1111a37e35991d48543dec88a36f16d7aee
https://github.com/phallguy/scorpion/blob/0bc9c1111a37e35991d48543dec88a36f16d7aee/lib/scorpion/dependency_map.rb#L118-L126
2,641
notnyt/beaglebone
lib/beaglebone/spi.rb
Beaglebone.SPIDevice.xfer
def xfer(tx_data, readbytes=0, speed=nil, delay=nil, bpw=nil) SPI::xfer(@spi, tx_data, readbytes, speed, delay, bpw) end
ruby
def xfer(tx_data, readbytes=0, speed=nil, delay=nil, bpw=nil) SPI::xfer(@spi, tx_data, readbytes, speed, delay, bpw) end
[ "def", "xfer", "(", "tx_data", ",", "readbytes", "=", "0", ",", "speed", "=", "nil", ",", "delay", "=", "nil", ",", "bpw", "=", "nil", ")", "SPI", "::", "xfer", "(", "@spi", ",", "tx_data", ",", "readbytes", ",", "speed", ",", "delay", ",", "bpw"...
Initialize an SPI device. Returns an SPIDevice object @param spi should be a symbol representing the SPI device @param mode optional, default 0, specifies the SPI mode :SPI_MODE_0 through 3 @param speed optional, specifies the SPI communication speed @param bpw optional, specifies the bits per word @example ...
[ "Initialize", "an", "SPI", "device", ".", "Returns", "an", "SPIDevice", "object" ]
7caa8f19f017e4a3d489ce8a2e8526c2e36905d5
https://github.com/notnyt/beaglebone/blob/7caa8f19f017e4a3d489ce8a2e8526c2e36905d5/lib/beaglebone/spi.rb#L423-L425
2,642
dblessing/rundeck-ruby
lib/rundeck/configuration.rb
Rundeck.Configuration.options
def options VALID_OPTIONS_KEYS.reduce({}) do |option, key| option.merge!(key => send(key)) end end
ruby
def options VALID_OPTIONS_KEYS.reduce({}) do |option, key| option.merge!(key => send(key)) end end
[ "def", "options", "VALID_OPTIONS_KEYS", ".", "reduce", "(", "{", "}", ")", "do", "|", "option", ",", "key", "|", "option", ".", "merge!", "(", "key", "=>", "send", "(", "key", ")", ")", "end", "end" ]
Creates a hash of options and their values.
[ "Creates", "a", "hash", "of", "options", "and", "their", "values", "." ]
4faa9c7ebe59408ed92e91d68bd05cd9e8706dd2
https://github.com/dblessing/rundeck-ruby/blob/4faa9c7ebe59408ed92e91d68bd05cd9e8706dd2/lib/rundeck/configuration.rb#L25-L29
2,643
messagemedia/messages-ruby-sdk
lib/message_media_messages/controllers/replies_controller.rb
MessageMediaMessages.RepliesController.check_replies
def check_replies # Prepare query url. _path_url = '/v1/replies' _query_builder = Configuration.base_uri.dup _query_builder << _path_url _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json' } ...
ruby
def check_replies # Prepare query url. _path_url = '/v1/replies' _query_builder = Configuration.base_uri.dup _query_builder << _path_url _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json' } ...
[ "def", "check_replies", "# Prepare query url.\r", "_path_url", "=", "'/v1/replies'", "_query_builder", "=", "Configuration", ".", "base_uri", ".", "dup", "_query_builder", "<<", "_path_url", "_query_url", "=", "APIHelper", ".", "clean_url", "_query_builder", "# Prepare he...
Check for any replies that have been received. Replies are messages that have been sent from a handset in response to a message sent by an application or messages that have been sent from a handset to a inbound number associated with an account, known as a dedicated inbound number (contact <support@messagemedia.c...
[ "Check", "for", "any", "replies", "that", "have", "been", "received", ".", "Replies", "are", "messages", "that", "have", "been", "sent", "from", "a", "handset", "in", "response", "to", "a", "message", "sent", "by", "an", "application", "or", "messages", "t...
073f1f7ca5e4ff3df51b8eeafeaae2167ec6f311
https://github.com/messagemedia/messages-ruby-sdk/blob/073f1f7ca5e4ff3df51b8eeafeaae2167ec6f311/lib/message_media_messages/controllers/replies_controller.rb#L102-L126
2,644
gupta-ankit/fitgem_oauth2
lib/fitgem_oauth2/heartrate.rb
FitgemOauth2.Client.heartrate_time_series
def heartrate_time_series(start_date: nil, end_date: nil, period: nil) warn '[DEPRECATION] `heartrate_time_series` is deprecated. Please use `hr_series_for_date_range` or `hr_series_for_period` instead.' regular_time_series_guard( start_date: start_date, end_date: end_date, period:...
ruby
def heartrate_time_series(start_date: nil, end_date: nil, period: nil) warn '[DEPRECATION] `heartrate_time_series` is deprecated. Please use `hr_series_for_date_range` or `hr_series_for_period` instead.' regular_time_series_guard( start_date: start_date, end_date: end_date, period:...
[ "def", "heartrate_time_series", "(", "start_date", ":", "nil", ",", "end_date", ":", "nil", ",", "period", ":", "nil", ")", "warn", "'[DEPRECATION] `heartrate_time_series` is deprecated. Please use `hr_series_for_date_range` or `hr_series_for_period` instead.'", "regular_time_seri...
retrieve heartrate time series
[ "retrieve", "heartrate", "time", "series" ]
10caf154d351dcef54442d9092c445cd388ad09e
https://github.com/gupta-ankit/fitgem_oauth2/blob/10caf154d351dcef54442d9092c445cd388ad09e/lib/fitgem_oauth2/heartrate.rb#L24-L38
2,645
gupta-ankit/fitgem_oauth2
lib/fitgem_oauth2/heartrate.rb
FitgemOauth2.Client.intraday_heartrate_time_series
def intraday_heartrate_time_series(start_date: nil, end_date: nil, detail_level: nil, start_time: nil, end_time: nil) intraday_series_guard( start_date: start_date, end_date: end_date, detail_level: detail_level, start_time: start_time, end_time: end_time ) end...
ruby
def intraday_heartrate_time_series(start_date: nil, end_date: nil, detail_level: nil, start_time: nil, end_time: nil) intraday_series_guard( start_date: start_date, end_date: end_date, detail_level: detail_level, start_time: start_time, end_time: end_time ) end...
[ "def", "intraday_heartrate_time_series", "(", "start_date", ":", "nil", ",", "end_date", ":", "nil", ",", "detail_level", ":", "nil", ",", "start_time", ":", "nil", ",", "end_time", ":", "nil", ")", "intraday_series_guard", "(", "start_date", ":", "start_date", ...
retrieve intraday series for heartrate
[ "retrieve", "intraday", "series", "for", "heartrate" ]
10caf154d351dcef54442d9092c445cd388ad09e
https://github.com/gupta-ankit/fitgem_oauth2/blob/10caf154d351dcef54442d9092c445cd388ad09e/lib/fitgem_oauth2/heartrate.rb#L41-L59
2,646
messagemedia/messages-ruby-sdk
lib/message_media_messages/http/faraday_client.rb
MessageMediaMessages.FaradayClient.execute_as_string
def execute_as_string(http_request) response = @connection.send( http_request.http_method.downcase, http_request.query_url ) do |request| request.headers = http_request.headers unless http_request.parameters.empty? request.body = http_request.parameters ...
ruby
def execute_as_string(http_request) response = @connection.send( http_request.http_method.downcase, http_request.query_url ) do |request| request.headers = http_request.headers unless http_request.parameters.empty? request.body = http_request.parameters ...
[ "def", "execute_as_string", "(", "http_request", ")", "response", "=", "@connection", ".", "send", "(", "http_request", ".", "http_method", ".", "downcase", ",", "http_request", ".", "query_url", ")", "do", "|", "request", "|", "request", ".", "headers", "=", ...
The constructor. Method overridden from HttpClient.
[ "The", "constructor", ".", "Method", "overridden", "from", "HttpClient", "." ]
073f1f7ca5e4ff3df51b8eeafeaae2167ec6f311
https://github.com/messagemedia/messages-ruby-sdk/blob/073f1f7ca5e4ff3df51b8eeafeaae2167ec6f311/lib/message_media_messages/http/faraday_client.rb#L30-L41
2,647
messagemedia/messages-ruby-sdk
lib/message_media_messages/http/faraday_client.rb
MessageMediaMessages.FaradayClient.convert_response
def convert_response(response) HttpResponse.new(response.status, response.headers, response.body) end
ruby
def convert_response(response) HttpResponse.new(response.status, response.headers, response.body) end
[ "def", "convert_response", "(", "response", ")", "HttpResponse", ".", "new", "(", "response", ".", "status", ",", "response", ".", "headers", ",", "response", ".", "body", ")", "end" ]
Method overridden from HttpClient.
[ "Method", "overridden", "from", "HttpClient", "." ]
073f1f7ca5e4ff3df51b8eeafeaae2167ec6f311
https://github.com/messagemedia/messages-ruby-sdk/blob/073f1f7ca5e4ff3df51b8eeafeaae2167ec6f311/lib/message_media_messages/http/faraday_client.rb#L58-L60
2,648
dalpo/rails_admin_clone
lib/rails_admin_clone/model_cloner.rb
RailsAdminClone.ModelCloner.clone_object
def clone_object(old_object) object = build_from(old_object) assign_attributes_for(object, get_model_attributes_from(old_object)) object end
ruby
def clone_object(old_object) object = build_from(old_object) assign_attributes_for(object, get_model_attributes_from(old_object)) object end
[ "def", "clone_object", "(", "old_object", ")", "object", "=", "build_from", "(", "old_object", ")", "assign_attributes_for", "(", "object", ",", "get_model_attributes_from", "(", "old_object", ")", ")", "object", "end" ]
clone object without associations
[ "clone", "object", "without", "associations" ]
a56f005af9833fc1c7071a777f20ea154320ca72
https://github.com/dalpo/rails_admin_clone/blob/a56f005af9833fc1c7071a777f20ea154320ca72/lib/rails_admin_clone/model_cloner.rb#L82-L87
2,649
dalpo/rails_admin_clone
lib/rails_admin_clone/model_cloner.rb
RailsAdminClone.ModelCloner.clone_has_one
def clone_has_one(old_object, new_object) old_object.class.reflect_on_all_associations(:has_one).each do |association| old_association = old_object.send(association.name) build_has_one(new_object, association, old_association) if build_has_one?(old_object, association) end new_object ...
ruby
def clone_has_one(old_object, new_object) old_object.class.reflect_on_all_associations(:has_one).each do |association| old_association = old_object.send(association.name) build_has_one(new_object, association, old_association) if build_has_one?(old_object, association) end new_object ...
[ "def", "clone_has_one", "(", "old_object", ",", "new_object", ")", "old_object", ".", "class", ".", "reflect_on_all_associations", "(", ":has_one", ")", ".", "each", "do", "|", "association", "|", "old_association", "=", "old_object", ".", "send", "(", "associat...
clone has_one associations
[ "clone", "has_one", "associations" ]
a56f005af9833fc1c7071a777f20ea154320ca72
https://github.com/dalpo/rails_admin_clone/blob/a56f005af9833fc1c7071a777f20ea154320ca72/lib/rails_admin_clone/model_cloner.rb#L90-L97
2,650
dalpo/rails_admin_clone
lib/rails_admin_clone/model_cloner.rb
RailsAdminClone.ModelCloner.clone_has_many
def clone_has_many(old_object, new_object) associations = old_object.class.reflect_on_all_associations(:has_many) .select{|a| !a.options.keys.include?(:through)} associations.each do |association| old_object.send(association.name).each do |old_association| new_object.send(associat...
ruby
def clone_has_many(old_object, new_object) associations = old_object.class.reflect_on_all_associations(:has_many) .select{|a| !a.options.keys.include?(:through)} associations.each do |association| old_object.send(association.name).each do |old_association| new_object.send(associat...
[ "def", "clone_has_many", "(", "old_object", ",", "new_object", ")", "associations", "=", "old_object", ".", "class", ".", "reflect_on_all_associations", "(", ":has_many", ")", ".", "select", "{", "|", "a", "|", "!", "a", ".", "options", ".", "keys", ".", "...
clone has_many associations
[ "clone", "has_many", "associations" ]
a56f005af9833fc1c7071a777f20ea154320ca72
https://github.com/dalpo/rails_admin_clone/blob/a56f005af9833fc1c7071a777f20ea154320ca72/lib/rails_admin_clone/model_cloner.rb#L110-L123
2,651
jkotests/watir-nokogiri
lib/watir-nokogiri/elements/button.rb
WatirNokogiri.Button.text
def text assert_exists tn = @element.node_name.downcase case tn when 'input' @element.get_attribute(:value) when 'button' @element.text else raise Exception::Error, "unknown tag name for button: #{tn}" end end
ruby
def text assert_exists tn = @element.node_name.downcase case tn when 'input' @element.get_attribute(:value) when 'button' @element.text else raise Exception::Error, "unknown tag name for button: #{tn}" end end
[ "def", "text", "assert_exists", "tn", "=", "@element", ".", "node_name", ".", "downcase", "case", "tn", "when", "'input'", "@element", ".", "get_attribute", "(", ":value", ")", "when", "'button'", "@element", ".", "text", "else", "raise", "Exception", "::", ...
Returns the text of the button. For input elements, returns the "value" attribute. For button elements, returns the inner text. @return [String]
[ "Returns", "the", "text", "of", "the", "button", "." ]
32c783730bda83dfbeb97a78d7a21788bd726815
https://github.com/jkotests/watir-nokogiri/blob/32c783730bda83dfbeb97a78d7a21788bd726815/lib/watir-nokogiri/elements/button.rb#L26-L39
2,652
gupta-ankit/fitgem_oauth2
lib/fitgem_oauth2/activity.rb
FitgemOauth2.Client.intraday_activity_time_series
def intraday_activity_time_series(resource: nil, start_date: nil, end_date: nil, detail_level: nil, start_time: nil, end_time: nil) # converting to symbol to allow developer to use either 'calories' or :calories resource = resource.to_sym unless %i[calories step...
ruby
def intraday_activity_time_series(resource: nil, start_date: nil, end_date: nil, detail_level: nil, start_time: nil, end_time: nil) # converting to symbol to allow developer to use either 'calories' or :calories resource = resource.to_sym unless %i[calories step...
[ "def", "intraday_activity_time_series", "(", "resource", ":", "nil", ",", "start_date", ":", "nil", ",", "end_date", ":", "nil", ",", "detail_level", ":", "nil", ",", "start_time", ":", "nil", ",", "end_time", ":", "nil", ")", "# converting to symbol to allow de...
retrieves intraday activity time series. @param resource (required) for which the intrady series is retrieved. one of 'calories', 'steps', 'distance', 'floors', 'elevation' @param start_date (required) start date for the series @param end_date (optional) end date for the series, if not specified, the series is for 1...
[ "retrieves", "intraday", "activity", "time", "series", "." ]
10caf154d351dcef54442d9092c445cd388ad09e
https://github.com/gupta-ankit/fitgem_oauth2/blob/10caf154d351dcef54442d9092c445cd388ad09e/lib/fitgem_oauth2/activity.rb#L62-L99
2,653
gupta-ankit/fitgem_oauth2
lib/fitgem_oauth2/activity.rb
FitgemOauth2.Client.activity_list
def activity_list(date, sort, limit) date_param = format_date(date) if sort == "asc" date_param = "afterDate=#{date_param}" elsif sort == "desc" date_param = "beforeDate=#{date_param}" else raise FitgemOauth2::InvalidArgumentError, "sort can either be asc or desc" e...
ruby
def activity_list(date, sort, limit) date_param = format_date(date) if sort == "asc" date_param = "afterDate=#{date_param}" elsif sort == "desc" date_param = "beforeDate=#{date_param}" else raise FitgemOauth2::InvalidArgumentError, "sort can either be asc or desc" e...
[ "def", "activity_list", "(", "date", ",", "sort", ",", "limit", ")", "date_param", "=", "format_date", "(", "date", ")", "if", "sort", "==", "\"asc\"", "date_param", "=", "\"afterDate=#{date_param}\"", "elsif", "sort", "==", "\"desc\"", "date_param", "=", "\"b...
retrieves activity list for the user
[ "retrieves", "activity", "list", "for", "the", "user" ]
10caf154d351dcef54442d9092c445cd388ad09e
https://github.com/gupta-ankit/fitgem_oauth2/blob/10caf154d351dcef54442d9092c445cd388ad09e/lib/fitgem_oauth2/activity.rb#L119-L129
2,654
gupta-ankit/fitgem_oauth2
lib/fitgem_oauth2/activity.rb
FitgemOauth2.Client.update_activity_goals
def update_activity_goals(period, params) unless period && %w(daily weekly).include?(period) raise FitgemOauth2::InvalidArgumentError, "Goal period should either be 'daily' or 'weekly'" end post_call("user/#{user_id}/activities/goals/#{period}.json", params) end
ruby
def update_activity_goals(period, params) unless period && %w(daily weekly).include?(period) raise FitgemOauth2::InvalidArgumentError, "Goal period should either be 'daily' or 'weekly'" end post_call("user/#{user_id}/activities/goals/#{period}.json", params) end
[ "def", "update_activity_goals", "(", "period", ",", "params", ")", "unless", "period", "&&", "%w(", "daily", "weekly", ")", ".", "include?", "(", "period", ")", "raise", "FitgemOauth2", "::", "InvalidArgumentError", ",", "\"Goal period should either be 'daily' or 'wee...
update activity goals @param period period for the goal ('weekly' or 'daily') @param params the POST params for the request. Refer to Fitbit documentation for accepted format
[ "update", "activity", "goals" ]
10caf154d351dcef54442d9092c445cd388ad09e
https://github.com/gupta-ankit/fitgem_oauth2/blob/10caf154d351dcef54442d9092c445cd388ad09e/lib/fitgem_oauth2/activity.rb#L197-L202
2,655
gupta-ankit/fitgem_oauth2
lib/fitgem_oauth2/sleep.rb
FitgemOauth2.Client.sleep_time_series
def sleep_time_series(resource: nil, start_date: nil, end_date: nil, period: nil) unless start_date raise FitgemOauth2::InvalidArgumentError, 'Start date not provided.' end unless resource && SLEEP_RESOURCES.include?(resource) raise FitgemOauth2::InvalidArgumentError, "Invalid resourc...
ruby
def sleep_time_series(resource: nil, start_date: nil, end_date: nil, period: nil) unless start_date raise FitgemOauth2::InvalidArgumentError, 'Start date not provided.' end unless resource && SLEEP_RESOURCES.include?(resource) raise FitgemOauth2::InvalidArgumentError, "Invalid resourc...
[ "def", "sleep_time_series", "(", "resource", ":", "nil", ",", "start_date", ":", "nil", ",", "end_date", ":", "nil", ",", "period", ":", "nil", ")", "unless", "start_date", "raise", "FitgemOauth2", "::", "InvalidArgumentError", ",", "'Start date not provided.'", ...
retrieve time series data for sleep @param resource sleep resource to be requested @param start_date starting date for sleep time series @param end_date ending date for sleep time series @param period period for sleep time series
[ "retrieve", "time", "series", "data", "for", "sleep" ]
10caf154d351dcef54442d9092c445cd388ad09e
https://github.com/gupta-ankit/fitgem_oauth2/blob/10caf154d351dcef54442d9092c445cd388ad09e/lib/fitgem_oauth2/sleep.rb#L50-L72
2,656
jkotests/watir-nokogiri
lib/watir-nokogiri/elements/option.rb
WatirNokogiri.Option.text
def text assert_exists # A little unintuitive - we'll return the 'label' or 'text' attribute if # they exist, otherwise the inner text of the element attribute = [:label, :text].find { |a| attribute? a } if attribute @element.get_attribute(attribute) else @element....
ruby
def text assert_exists # A little unintuitive - we'll return the 'label' or 'text' attribute if # they exist, otherwise the inner text of the element attribute = [:label, :text].find { |a| attribute? a } if attribute @element.get_attribute(attribute) else @element....
[ "def", "text", "assert_exists", "# A little unintuitive - we'll return the 'label' or 'text' attribute if", "# they exist, otherwise the inner text of the element", "attribute", "=", "[", ":label", ",", ":text", "]", ".", "find", "{", "|", "a", "|", "attribute?", "a", "}", ...
Returns the text of option. Note that the text is either one of the following respectively: * label attribute * text attribute * inner element text @return [String]
[ "Returns", "the", "text", "of", "option", "." ]
32c783730bda83dfbeb97a78d7a21788bd726815
https://github.com/jkotests/watir-nokogiri/blob/32c783730bda83dfbeb97a78d7a21788bd726815/lib/watir-nokogiri/elements/option.rb#L67-L80
2,657
jkotests/watir-nokogiri
lib/watir-nokogiri/elements/element.rb
WatirNokogiri.Element.style
def style(property = nil) assert_exists styles = attribute_value('style').to_s.strip if property properties = Hash[styles.downcase.split(";").map { |p| p.split(":").map(&:strip) }] properties[property] else styles end end
ruby
def style(property = nil) assert_exists styles = attribute_value('style').to_s.strip if property properties = Hash[styles.downcase.split(";").map { |p| p.split(":").map(&:strip) }] properties[property] else styles end end
[ "def", "style", "(", "property", "=", "nil", ")", "assert_exists", "styles", "=", "attribute_value", "(", "'style'", ")", ".", "to_s", ".", "strip", "if", "property", "properties", "=", "Hash", "[", "styles", ".", "downcase", ".", "split", "(", "\";\"", ...
Returns given style property of this element. @example html.a(:id => "foo").style #=> "display: block" html.a(:id => "foo").style "display" #=> "block" @param [String] property @return [String]
[ "Returns", "given", "style", "property", "of", "this", "element", "." ]
32c783730bda83dfbeb97a78d7a21788bd726815
https://github.com/jkotests/watir-nokogiri/blob/32c783730bda83dfbeb97a78d7a21788bd726815/lib/watir-nokogiri/elements/element.rb#L155-L164
2,658
jkotests/watir-nokogiri
lib/watir-nokogiri/elements/element.rb
WatirNokogiri.Element.parent
def parent assert_exists e = @element.parent if e.kind_of?(Nokogiri::XML::Element) WatirNokogiri.element_class_for(e.node_name.downcase).new(@parent, :element => e) end end
ruby
def parent assert_exists e = @element.parent if e.kind_of?(Nokogiri::XML::Element) WatirNokogiri.element_class_for(e.node_name.downcase).new(@parent, :element => e) end end
[ "def", "parent", "assert_exists", "e", "=", "@element", ".", "parent", "if", "e", ".", "kind_of?", "(", "Nokogiri", "::", "XML", "::", "Element", ")", "WatirNokogiri", ".", "element_class_for", "(", "e", ".", "node_name", ".", "downcase", ")", ".", "new", ...
Returns parent element of current element.
[ "Returns", "parent", "element", "of", "current", "element", "." ]
32c783730bda83dfbeb97a78d7a21788bd726815
https://github.com/jkotests/watir-nokogiri/blob/32c783730bda83dfbeb97a78d7a21788bd726815/lib/watir-nokogiri/elements/element.rb#L170-L178
2,659
chetan/dht-sensor-ffi
lib/dht-sensor/app.rb
DhtSensor.App.to_hash
def to_hash(val) if @options[:humidity] then return {"humidity" => val.humidity} end if @options[:unit] == :c then if @options[:temperature] then return {"temperature" => val.temp} else return {"temperature" => val.temp, "humidity" => val.humidity} ...
ruby
def to_hash(val) if @options[:humidity] then return {"humidity" => val.humidity} end if @options[:unit] == :c then if @options[:temperature] then return {"temperature" => val.temp} else return {"temperature" => val.temp, "humidity" => val.humidity} ...
[ "def", "to_hash", "(", "val", ")", "if", "@options", "[", ":humidity", "]", "then", "return", "{", "\"humidity\"", "=>", "val", ".", "humidity", "}", "end", "if", "@options", "[", ":unit", "]", "==", ":c", "then", "if", "@options", "[", ":temperature", ...
Convert to sensor reading to hash
[ "Convert", "to", "sensor", "reading", "to", "hash" ]
fe7d6d0c64dc9c258bd823f7d1d41f7edf129cd2
https://github.com/chetan/dht-sensor-ffi/blob/fe7d6d0c64dc9c258bd823f7d1d41f7edf129cd2/lib/dht-sensor/app.rb#L58-L76
2,660
chetan/dht-sensor-ffi
lib/dht-sensor/app.rb
DhtSensor.App.print
def print(val) if @options[:humidity] then puts sprintf("Humidity: %.2f%%", val.humidity) return end if @options[:unit] == :c then if @options[:temperature] then puts sprintf("Temperature: %.2f C", val.temp) else puts sprintf("Temperature: %.2f C Hu...
ruby
def print(val) if @options[:humidity] then puts sprintf("Humidity: %.2f%%", val.humidity) return end if @options[:unit] == :c then if @options[:temperature] then puts sprintf("Temperature: %.2f C", val.temp) else puts sprintf("Temperature: %.2f C Hu...
[ "def", "print", "(", "val", ")", "if", "@options", "[", ":humidity", "]", "then", "puts", "sprintf", "(", "\"Humidity: %.2f%%\"", ",", "val", ".", "humidity", ")", "return", "end", "if", "@options", "[", ":unit", "]", "==", ":c", "then", "if", "@options"...
Print to stdout, taking the various output options into account
[ "Print", "to", "stdout", "taking", "the", "various", "output", "options", "into", "account" ]
fe7d6d0c64dc9c258bd823f7d1d41f7edf129cd2
https://github.com/chetan/dht-sensor-ffi/blob/fe7d6d0c64dc9c258bd823f7d1d41f7edf129cd2/lib/dht-sensor/app.rb#L79-L98
2,661
jkotests/watir-nokogiri
lib/watir-nokogiri/cell_container.rb
WatirNokogiri.CellContainer.cell
def cell(*args) cell = TableCell.new(self, extract_selector(args).merge(:tag_name => /^(th|td)$/)) cell.locator_class = ChildCellLocator cell end
ruby
def cell(*args) cell = TableCell.new(self, extract_selector(args).merge(:tag_name => /^(th|td)$/)) cell.locator_class = ChildCellLocator cell end
[ "def", "cell", "(", "*", "args", ")", "cell", "=", "TableCell", ".", "new", "(", "self", ",", "extract_selector", "(", "args", ")", ".", "merge", "(", ":tag_name", "=>", "/", "/", ")", ")", "cell", ".", "locator_class", "=", "ChildCellLocator", "cell",...
Returns table cell. @return [TableCell]
[ "Returns", "table", "cell", "." ]
32c783730bda83dfbeb97a78d7a21788bd726815
https://github.com/jkotests/watir-nokogiri/blob/32c783730bda83dfbeb97a78d7a21788bd726815/lib/watir-nokogiri/cell_container.rb#L10-L15
2,662
jkotests/watir-nokogiri
lib/watir-nokogiri/cell_container.rb
WatirNokogiri.CellContainer.cells
def cells(*args) cells = TableCellCollection.new(self, extract_selector(args).merge(:tag_name => /^(th|td)$/)) cells.locator_class = ChildCellLocator cells end
ruby
def cells(*args) cells = TableCellCollection.new(self, extract_selector(args).merge(:tag_name => /^(th|td)$/)) cells.locator_class = ChildCellLocator cells end
[ "def", "cells", "(", "*", "args", ")", "cells", "=", "TableCellCollection", ".", "new", "(", "self", ",", "extract_selector", "(", "args", ")", ".", "merge", "(", ":tag_name", "=>", "/", "/", ")", ")", "cells", ".", "locator_class", "=", "ChildCellLocato...
Returns table cells collection. @return [TableCell]
[ "Returns", "table", "cells", "collection", "." ]
32c783730bda83dfbeb97a78d7a21788bd726815
https://github.com/jkotests/watir-nokogiri/blob/32c783730bda83dfbeb97a78d7a21788bd726815/lib/watir-nokogiri/cell_container.rb#L23-L28
2,663
messagemedia/messages-ruby-sdk
lib/message_media_messages/models/base_model.rb
MessageMediaMessages.BaseModel.to_hash
def to_hash hash = {} instance_variables.each do |name| value = instance_variable_get(name) next if value.nil? name = name[1..-1] key = self.class.names.key?(name) ? self.class.names[name] : name if value.instance_of? Array hash[key] = value.map { |v...
ruby
def to_hash hash = {} instance_variables.each do |name| value = instance_variable_get(name) next if value.nil? name = name[1..-1] key = self.class.names.key?(name) ? self.class.names[name] : name if value.instance_of? Array hash[key] = value.map { |v...
[ "def", "to_hash", "hash", "=", "{", "}", "instance_variables", ".", "each", "do", "|", "name", "|", "value", "=", "instance_variable_get", "(", "name", ")", "next", "if", "value", ".", "nil?", "name", "=", "name", "[", "1", "..", "-", "1", "]", "key"...
Returns a Hash representation of the current object.
[ "Returns", "a", "Hash", "representation", "of", "the", "current", "object", "." ]
073f1f7ca5e4ff3df51b8eeafeaae2167ec6f311
https://github.com/messagemedia/messages-ruby-sdk/blob/073f1f7ca5e4ff3df51b8eeafeaae2167ec6f311/lib/message_media_messages/models/base_model.rb#L10-L29
2,664
jkotests/watir-nokogiri
lib/watir-nokogiri/document.rb
WatirNokogiri.Document.goto
def goto(file_path) html = File.read(file_path) @driver = Nokogiri::HTML.parse(html) end
ruby
def goto(file_path) html = File.read(file_path) @driver = Nokogiri::HTML.parse(html) end
[ "def", "goto", "(", "file_path", ")", "html", "=", "File", ".", "read", "(", "file_path", ")", "@driver", "=", "Nokogiri", "::", "HTML", ".", "parse", "(", "html", ")", "end" ]
Reads the given file as HTML. @example browser.goto "www.google.com" @param [String] uri The url. @return [String] The url you end up at.
[ "Reads", "the", "given", "file", "as", "HTML", "." ]
32c783730bda83dfbeb97a78d7a21788bd726815
https://github.com/jkotests/watir-nokogiri/blob/32c783730bda83dfbeb97a78d7a21788bd726815/lib/watir-nokogiri/document.rb#L47-L50
2,665
simonrepp/titlekit
lib/titlekit/job.rb
Titlekit.Job.run
def run @wants.each do |want| @haves.each do |have| import(have) retime(have, want) cull(have) group(have) want.subtitles += have.subtitles.clone end polish(want) export(want) end return true rescue AbortJob ...
ruby
def run @wants.each do |want| @haves.each do |have| import(have) retime(have, want) cull(have) group(have) want.subtitles += have.subtitles.clone end polish(want) export(want) end return true rescue AbortJob ...
[ "def", "run", "@wants", ".", "each", "do", "|", "want", "|", "@haves", ".", "each", "do", "|", "have", "|", "import", "(", "have", ")", "retime", "(", "have", ",", "want", ")", "cull", "(", "have", ")", "group", "(", "have", ")", "want", ".", "...
Starts a new job. A job requires at least one file you {Have} and one file you {Want} in order to be runable. Use {Job#have} and {Job#want} to add and obtain specification interfaces for the job. Runs the job. @return [Boolean] true if the job succeeds, false if it fails. {Job#report} provides information in...
[ "Starts", "a", "new", "job", "." ]
65d3743378aaf54544efb7c642cfc656085191db
https://github.com/simonrepp/titlekit/blob/65d3743378aaf54544efb7c642cfc656085191db/lib/titlekit/job.rb#L49-L67
2,666
simonrepp/titlekit
lib/titlekit/job.rb
Titlekit.Job.cull
def cull(have) have.subtitles.reject! { |subtitle| subtitle[:end] < 0 } have.subtitles.each do |subtitle| subtitle[:start] = 0 if subtitle[:start] < 0 end end
ruby
def cull(have) have.subtitles.reject! { |subtitle| subtitle[:end] < 0 } have.subtitles.each do |subtitle| subtitle[:start] = 0 if subtitle[:start] < 0 end end
[ "def", "cull", "(", "have", ")", "have", ".", "subtitles", ".", "reject!", "{", "|", "subtitle", "|", "subtitle", "[", ":end", "]", "<", "0", "}", "have", ".", "subtitles", ".", "each", "do", "|", "subtitle", "|", "subtitle", "[", ":start", "]", "=...
Cleans out subtitles that fell out of the usable time range @params have [Have] What we {Have}
[ "Cleans", "out", "subtitles", "that", "fell", "out", "of", "the", "usable", "time", "range" ]
65d3743378aaf54544efb7c642cfc656085191db
https://github.com/simonrepp/titlekit/blob/65d3743378aaf54544efb7c642cfc656085191db/lib/titlekit/job.rb#L265-L270
2,667
simonrepp/titlekit
lib/titlekit/job.rb
Titlekit.Job.retime_by_framerate
def retime_by_framerate(have, want) ratio = want.fps.to_f / have.fps.to_f have.subtitles.each do |subtitle| subtitle[:start] *= ratio subtitle[:end] *= ratio end end
ruby
def retime_by_framerate(have, want) ratio = want.fps.to_f / have.fps.to_f have.subtitles.each do |subtitle| subtitle[:start] *= ratio subtitle[:end] *= ratio end end
[ "def", "retime_by_framerate", "(", "have", ",", "want", ")", "ratio", "=", "want", ".", "fps", ".", "to_f", "/", "have", ".", "fps", ".", "to_f", "have", ".", "subtitles", ".", "each", "do", "|", "subtitle", "|", "subtitle", "[", ":start", "]", "*=",...
Rescales timecodes based on two differing framerates. @param have [Have] the subtitles we {Have} @param want [Want] the subtitles we {Want}
[ "Rescales", "timecodes", "based", "on", "two", "differing", "framerates", "." ]
65d3743378aaf54544efb7c642cfc656085191db
https://github.com/simonrepp/titlekit/blob/65d3743378aaf54544efb7c642cfc656085191db/lib/titlekit/job.rb#L461-L467
2,668
messagemedia/messages-ruby-sdk
lib/message_media_messages/http/http_client.rb
MessageMediaMessages.HttpClient.get
def get(query_url, headers: {}) HttpRequest.new(HttpMethodEnum::GET, query_url, headers: headers) end
ruby
def get(query_url, headers: {}) HttpRequest.new(HttpMethodEnum::GET, query_url, headers: headers) end
[ "def", "get", "(", "query_url", ",", "headers", ":", "{", "}", ")", "HttpRequest", ".", "new", "(", "HttpMethodEnum", "::", "GET", ",", "query_url", ",", "headers", ":", "headers", ")", "end" ]
Get a GET HttpRequest object. @param [String] The URL to send the request to. @param [Hash, Optional] The headers for the HTTP Request.
[ "Get", "a", "GET", "HttpRequest", "object", "." ]
073f1f7ca5e4ff3df51b8eeafeaae2167ec6f311
https://github.com/messagemedia/messages-ruby-sdk/blob/073f1f7ca5e4ff3df51b8eeafeaae2167ec6f311/lib/message_media_messages/http/http_client.rb#L36-L41
2,669
messagemedia/messages-ruby-sdk
lib/message_media_messages/http/http_client.rb
MessageMediaMessages.HttpClient.head
def head(query_url, headers: {}) HttpRequest.new(HttpMethodEnum::HEAD, query_url, headers: headers) end
ruby
def head(query_url, headers: {}) HttpRequest.new(HttpMethodEnum::HEAD, query_url, headers: headers) end
[ "def", "head", "(", "query_url", ",", "headers", ":", "{", "}", ")", "HttpRequest", ".", "new", "(", "HttpMethodEnum", "::", "HEAD", ",", "query_url", ",", "headers", ":", "headers", ")", "end" ]
Get a HEAD HttpRequest object. @param [String] The URL to send the request to. @param [Hash, Optional] The headers for the HTTP Request.
[ "Get", "a", "HEAD", "HttpRequest", "object", "." ]
073f1f7ca5e4ff3df51b8eeafeaae2167ec6f311
https://github.com/messagemedia/messages-ruby-sdk/blob/073f1f7ca5e4ff3df51b8eeafeaae2167ec6f311/lib/message_media_messages/http/http_client.rb#L46-L51
2,670
messagemedia/messages-ruby-sdk
lib/message_media_messages/http/http_client.rb
MessageMediaMessages.HttpClient.post
def post(query_url, headers: {}, parameters: {}) HttpRequest.new(HttpMethodEnum::POST, query_url, headers: headers, parameters: parameters) end
ruby
def post(query_url, headers: {}, parameters: {}) HttpRequest.new(HttpMethodEnum::POST, query_url, headers: headers, parameters: parameters) end
[ "def", "post", "(", "query_url", ",", "headers", ":", "{", "}", ",", "parameters", ":", "{", "}", ")", "HttpRequest", ".", "new", "(", "HttpMethodEnum", "::", "POST", ",", "query_url", ",", "headers", ":", "headers", ",", "parameters", ":", "parameters",...
Get a POST HttpRequest object. @param [String] The URL to send the request to. @param [Hash, Optional] The headers for the HTTP Request. @param [Hash, Optional] The parameters for the HTTP Request.
[ "Get", "a", "POST", "HttpRequest", "object", "." ]
073f1f7ca5e4ff3df51b8eeafeaae2167ec6f311
https://github.com/messagemedia/messages-ruby-sdk/blob/073f1f7ca5e4ff3df51b8eeafeaae2167ec6f311/lib/message_media_messages/http/http_client.rb#L57-L64
2,671
messagemedia/messages-ruby-sdk
lib/message_media_messages/http/http_client.rb
MessageMediaMessages.HttpClient.put
def put(query_url, headers: {}, parameters: {}) HttpRequest.new(HttpMethodEnum::PUT, query_url, headers: headers, parameters: parameters) end
ruby
def put(query_url, headers: {}, parameters: {}) HttpRequest.new(HttpMethodEnum::PUT, query_url, headers: headers, parameters: parameters) end
[ "def", "put", "(", "query_url", ",", "headers", ":", "{", "}", ",", "parameters", ":", "{", "}", ")", "HttpRequest", ".", "new", "(", "HttpMethodEnum", "::", "PUT", ",", "query_url", ",", "headers", ":", "headers", ",", "parameters", ":", "parameters", ...
Get a PUT HttpRequest object. @param [String] The URL to send the request to. @param [Hash, Optional] The headers for the HTTP Request. @param [Hash, Optional] The parameters for the HTTP Request.
[ "Get", "a", "PUT", "HttpRequest", "object", "." ]
073f1f7ca5e4ff3df51b8eeafeaae2167ec6f311
https://github.com/messagemedia/messages-ruby-sdk/blob/073f1f7ca5e4ff3df51b8eeafeaae2167ec6f311/lib/message_media_messages/http/http_client.rb#L70-L77
2,672
messagemedia/messages-ruby-sdk
lib/message_media_messages/http/http_client.rb
MessageMediaMessages.HttpClient.patch
def patch(query_url, headers: {}, parameters: {}) HttpRequest.new(HttpMethodEnum::PATCH, query_url, headers: headers, parameters: parameters) end
ruby
def patch(query_url, headers: {}, parameters: {}) HttpRequest.new(HttpMethodEnum::PATCH, query_url, headers: headers, parameters: parameters) end
[ "def", "patch", "(", "query_url", ",", "headers", ":", "{", "}", ",", "parameters", ":", "{", "}", ")", "HttpRequest", ".", "new", "(", "HttpMethodEnum", "::", "PATCH", ",", "query_url", ",", "headers", ":", "headers", ",", "parameters", ":", "parameters...
Get a PATCH HttpRequest object. @param [String] The URL to send the request to. @param [Hash, Optional] The headers for the HTTP Request. @param [Hash, Optional] The parameters for the HTTP Request.
[ "Get", "a", "PATCH", "HttpRequest", "object", "." ]
073f1f7ca5e4ff3df51b8eeafeaae2167ec6f311
https://github.com/messagemedia/messages-ruby-sdk/blob/073f1f7ca5e4ff3df51b8eeafeaae2167ec6f311/lib/message_media_messages/http/http_client.rb#L83-L90
2,673
messagemedia/messages-ruby-sdk
lib/message_media_messages/http/http_client.rb
MessageMediaMessages.HttpClient.delete
def delete(query_url, headers: {}, parameters: {}) HttpRequest.new(HttpMethodEnum::DELETE, query_url, headers: headers, parameters: parameters) end
ruby
def delete(query_url, headers: {}, parameters: {}) HttpRequest.new(HttpMethodEnum::DELETE, query_url, headers: headers, parameters: parameters) end
[ "def", "delete", "(", "query_url", ",", "headers", ":", "{", "}", ",", "parameters", ":", "{", "}", ")", "HttpRequest", ".", "new", "(", "HttpMethodEnum", "::", "DELETE", ",", "query_url", ",", "headers", ":", "headers", ",", "parameters", ":", "paramete...
Get a DELETE HttpRequest object. @param [String] The URL to send the request to. @param [Hash, Optional] The headers for the HTTP Request.
[ "Get", "a", "DELETE", "HttpRequest", "object", "." ]
073f1f7ca5e4ff3df51b8eeafeaae2167ec6f311
https://github.com/messagemedia/messages-ruby-sdk/blob/073f1f7ca5e4ff3df51b8eeafeaae2167ec6f311/lib/message_media_messages/http/http_client.rb#L95-L102
2,674
jnewland/capistrano-log_with_awesome
lib/capistrano/log_with_awesome.rb
Capistrano.LogWithAwesome.log
def log(level, message, line_prefix=nil) if level <= self.level indent = "%*s" % [Capistrano::Logger::MAX_LEVEL, "*" * (Capistrano::Logger::MAX_LEVEL - level)] (RUBY_VERSION >= "1.9" ? message.lines : message).each do |line| if line_prefix self.class.log_with_awesome "#{inden...
ruby
def log(level, message, line_prefix=nil) if level <= self.level indent = "%*s" % [Capistrano::Logger::MAX_LEVEL, "*" * (Capistrano::Logger::MAX_LEVEL - level)] (RUBY_VERSION >= "1.9" ? message.lines : message).each do |line| if line_prefix self.class.log_with_awesome "#{inden...
[ "def", "log", "(", "level", ",", "message", ",", "line_prefix", "=", "nil", ")", "if", "level", "<=", "self", ".", "level", "indent", "=", "\"%*s\"", "%", "[", "Capistrano", "::", "Logger", "::", "MAX_LEVEL", ",", "\"*\"", "*", "(", "Capistrano", "::",...
Log and do awesome things I wish there was a nicer way to do this. Hax on device.puts, maybe?
[ "Log", "and", "do", "awesome", "things", "I", "wish", "there", "was", "a", "nicer", "way", "to", "do", "this", ".", "Hax", "on", "device", ".", "puts", "maybe?" ]
863ced8128d7f78342e5c8953e32a4af8f81a725
https://github.com/jnewland/capistrano-log_with_awesome/blob/863ced8128d7f78342e5c8953e32a4af8f81a725/lib/capistrano/log_with_awesome.rb#L23-L35
2,675
jkraemer/acts_as_ferret
lib/acts_as_ferret/class_methods.rb
ActsAsFerret.ClassMethods.records_for_rebuild
def records_for_rebuild(batch_size = 1000) transaction do if use_fast_batches? offset = 0 while (rows = where([ "#{table_name}.id > ?", offset ]).limit(batch_size).all).any? offset = rows.last.id yield rows, offset end else order = "#...
ruby
def records_for_rebuild(batch_size = 1000) transaction do if use_fast_batches? offset = 0 while (rows = where([ "#{table_name}.id > ?", offset ]).limit(batch_size).all).any? offset = rows.last.id yield rows, offset end else order = "#...
[ "def", "records_for_rebuild", "(", "batch_size", "=", "1000", ")", "transaction", "do", "if", "use_fast_batches?", "offset", "=", "0", "while", "(", "rows", "=", "where", "(", "[", "\"#{table_name}.id > ?\"", ",", "offset", "]", ")", ".", "limit", "(", "batc...
runs across all records yielding those to be indexed when the index is rebuilt
[ "runs", "across", "all", "records", "yielding", "those", "to", "be", "indexed", "when", "the", "index", "is", "rebuilt" ]
1c3330c51a4d07298e6b89347077742636d9e3cf
https://github.com/jkraemer/acts_as_ferret/blob/1c3330c51a4d07298e6b89347077742636d9e3cf/lib/acts_as_ferret/class_methods.rb#L73-L88
2,676
jkraemer/acts_as_ferret
lib/acts_as_ferret/class_methods.rb
ActsAsFerret.ClassMethods.records_for_bulk_index
def records_for_bulk_index(ids, batch_size = 1000) transaction do offset = 0 ids.each_slice(batch_size) do |id_slice| records = where(:id => id_slice).all #yield records, offset yield where(:id => id_slice).all, offset offset += batch_size end ...
ruby
def records_for_bulk_index(ids, batch_size = 1000) transaction do offset = 0 ids.each_slice(batch_size) do |id_slice| records = where(:id => id_slice).all #yield records, offset yield where(:id => id_slice).all, offset offset += batch_size end ...
[ "def", "records_for_bulk_index", "(", "ids", ",", "batch_size", "=", "1000", ")", "transaction", "do", "offset", "=", "0", "ids", ".", "each_slice", "(", "batch_size", ")", "do", "|", "id_slice", "|", "records", "=", "where", "(", ":id", "=>", "id_slice", ...
yields the records with the given ids, in batches of batch_size
[ "yields", "the", "records", "with", "the", "given", "ids", "in", "batches", "of", "batch_size" ]
1c3330c51a4d07298e6b89347077742636d9e3cf
https://github.com/jkraemer/acts_as_ferret/blob/1c3330c51a4d07298e6b89347077742636d9e3cf/lib/acts_as_ferret/class_methods.rb#L91-L101
2,677
jimweirich/sorcerer
lib/sorcerer/subexpression.rb
Sorcerer.Subexpression.within_method_sexp
def within_method_sexp(sexp) case sexp.first when :call # [:call, target, ".", meth] recur(sexp[1]) when :method_add_block # [:method_add_block, call, block] within_method_sexp(sexp[1]) when :method_add_arg # [:method_add_arg, call, args] recur(sexp...
ruby
def within_method_sexp(sexp) case sexp.first when :call # [:call, target, ".", meth] recur(sexp[1]) when :method_add_block # [:method_add_block, call, block] within_method_sexp(sexp[1]) when :method_add_arg # [:method_add_arg, call, args] recur(sexp...
[ "def", "within_method_sexp", "(", "sexp", ")", "case", "sexp", ".", "first", "when", ":call", "# [:call, target, \".\", meth]", "recur", "(", "sexp", "[", "1", "]", ")", "when", ":method_add_block", "# [:method_add_block, call, block]", "within_method_sexp", "(", "sex...
When already handling a method call, we don't need to recur on some items.
[ "When", "already", "handling", "a", "method", "call", "we", "don", "t", "need", "to", "recur", "on", "some", "items", "." ]
438adba3ce0d9231fd657b72166f4f035422f53a
https://github.com/jimweirich/sorcerer/blob/438adba3ce0d9231fd657b72166f4f035422f53a/lib/sorcerer/subexpression.rb#L78-L90
2,678
blackwinter/brice
lib/brice/colours.rb
Brice.Colours.enable_irb
def enable_irb IRB::Inspector.class_eval { unless method_defined?(:inspect_value_with_colour) alias_method :inspect_value_without_colour, :inspect_value def inspect_value_with_colour(value) Colours.colourize(inspect_value_without_colour(value)) end end ...
ruby
def enable_irb IRB::Inspector.class_eval { unless method_defined?(:inspect_value_with_colour) alias_method :inspect_value_without_colour, :inspect_value def inspect_value_with_colour(value) Colours.colourize(inspect_value_without_colour(value)) end end ...
[ "def", "enable_irb", "IRB", "::", "Inspector", ".", "class_eval", "{", "unless", "method_defined?", "(", ":inspect_value_with_colour", ")", "alias_method", ":inspect_value_without_colour", ",", ":inspect_value", "def", "inspect_value_with_colour", "(", "value", ")", "Colo...
Enable colourized IRb results.
[ "Enable", "colourized", "IRb", "results", "." ]
abe86570bbc65d9d0f3f62c86cd8f88a65882254
https://github.com/blackwinter/brice/blob/abe86570bbc65d9d0f3f62c86cd8f88a65882254/lib/brice/colours.rb#L111-L123
2,679
blackwinter/brice
lib/brice/colours.rb
Brice.Colours.colourize
def colourize(str) ''.tap { |res| Tokenizer.tokenize(str.to_s) { |token, value| res << colourize_string(value, colours[token]) } } rescue => err Brice.error(self, __method__, err) str end
ruby
def colourize(str) ''.tap { |res| Tokenizer.tokenize(str.to_s) { |token, value| res << colourize_string(value, colours[token]) } } rescue => err Brice.error(self, __method__, err) str end
[ "def", "colourize", "(", "str", ")", "''", ".", "tap", "{", "|", "res", "|", "Tokenizer", ".", "tokenize", "(", "str", ".", "to_s", ")", "{", "|", "token", ",", "value", "|", "res", "<<", "colourize_string", "(", "value", ",", "colours", "[", "toke...
Colourize the results of inspect
[ "Colourize", "the", "results", "of", "inspect" ]
abe86570bbc65d9d0f3f62c86cd8f88a65882254
https://github.com/blackwinter/brice/blob/abe86570bbc65d9d0f3f62c86cd8f88a65882254/lib/brice/colours.rb#L192-L199
2,680
postmodern/gscraper
lib/gscraper/has_pages.rb
GScraper.HasPages.each_page
def each_page(indices) unless block_given? enum_for(:each_page,indices) else indices.map { |index| yield page_cache[index] } end end
ruby
def each_page(indices) unless block_given? enum_for(:each_page,indices) else indices.map { |index| yield page_cache[index] } end end
[ "def", "each_page", "(", "indices", ")", "unless", "block_given?", "enum_for", "(", ":each_page", ",", "indices", ")", "else", "indices", ".", "map", "{", "|", "index", "|", "yield", "page_cache", "[", "index", "]", "}", "end", "end" ]
Iterates over the pages at the specified indices. @param [Array, Range] indices The indices. @yield [page] The given block will be passed each page. @yieldparam [Page] page A page at one of the given indices.
[ "Iterates", "over", "the", "pages", "at", "the", "specified", "indices", "." ]
8370880a7b0c03b3c12a5ba3dfc19a6230187d6a
https://github.com/postmodern/gscraper/blob/8370880a7b0c03b3c12a5ba3dfc19a6230187d6a/lib/gscraper/has_pages.rb#L73-L79
2,681
postmodern/gscraper
lib/gscraper/has_pages.rb
GScraper.HasPages.each
def each return enum_for(:each) unless block_given? index = 1 until ((next_page = page_cache[index]).empty?) do yield next_page index = index + 1 end return self end
ruby
def each return enum_for(:each) unless block_given? index = 1 until ((next_page = page_cache[index]).empty?) do yield next_page index = index + 1 end return self end
[ "def", "each", "return", "enum_for", "(", ":each", ")", "unless", "block_given?", "index", "=", "1", "until", "(", "(", "next_page", "=", "page_cache", "[", "index", "]", ")", ".", "empty?", ")", "do", "yield", "next_page", "index", "=", "index", "+", ...
Iterates over all the pages of the query, until an empty page is encountered. @yield [page] A page with results from the query. @yieldparam [Page] page A non-empty page from the query.
[ "Iterates", "over", "all", "the", "pages", "of", "the", "query", "until", "an", "empty", "page", "is", "encountered", "." ]
8370880a7b0c03b3c12a5ba3dfc19a6230187d6a
https://github.com/postmodern/gscraper/blob/8370880a7b0c03b3c12a5ba3dfc19a6230187d6a/lib/gscraper/has_pages.rb#L91-L102
2,682
postmodern/gscraper
lib/gscraper/has_pages.rb
GScraper.HasPages.page_cache
def page_cache @page_cache ||= Hash.new { |hash,key| hash[key] = page(key.to_i) } end
ruby
def page_cache @page_cache ||= Hash.new { |hash,key| hash[key] = page(key.to_i) } end
[ "def", "page_cache", "@page_cache", "||=", "Hash", ".", "new", "{", "|", "hash", ",", "key", "|", "hash", "[", "key", "]", "=", "page", "(", "key", ".", "to_i", ")", "}", "end" ]
The cache of previously requested pages. @return [Hash]
[ "The", "cache", "of", "previously", "requested", "pages", "." ]
8370880a7b0c03b3c12a5ba3dfc19a6230187d6a
https://github.com/postmodern/gscraper/blob/8370880a7b0c03b3c12a5ba3dfc19a6230187d6a/lib/gscraper/has_pages.rb#L167-L169
2,683
jkraemer/acts_as_ferret
lib/acts_as_ferret/index.rb
ActsAsFerret.AbstractIndex.change_index_dir
def change_index_dir(new_dir) logger.debug "[#{index_name}] changing index dir to #{new_dir}" index_definition[:index_dir] = index_definition[:ferret][:path] = new_dir reopen! logger.debug "[#{index_name}] index dir is now #{new_dir}" end
ruby
def change_index_dir(new_dir) logger.debug "[#{index_name}] changing index dir to #{new_dir}" index_definition[:index_dir] = index_definition[:ferret][:path] = new_dir reopen! logger.debug "[#{index_name}] index dir is now #{new_dir}" end
[ "def", "change_index_dir", "(", "new_dir", ")", "logger", ".", "debug", "\"[#{index_name}] changing index dir to #{new_dir}\"", "index_definition", "[", ":index_dir", "]", "=", "index_definition", "[", ":ferret", "]", "[", ":path", "]", "=", "new_dir", "reopen!", "log...
Switches the index to a new index directory. Used by the DRb server when switching to a new index version.
[ "Switches", "the", "index", "to", "a", "new", "index", "directory", ".", "Used", "by", "the", "DRb", "server", "when", "switching", "to", "a", "new", "index", "version", "." ]
1c3330c51a4d07298e6b89347077742636d9e3cf
https://github.com/jkraemer/acts_as_ferret/blob/1c3330c51a4d07298e6b89347077742636d9e3cf/lib/acts_as_ferret/index.rb#L88-L93
2,684
xcres/xcres
lib/xcres/model/xcassets/bundle.rb
XCRes::XCAssets.Bundle.read
def read @resource_paths = Dir.chdir(path) do Dir['**/Contents.json'].map { |p| Pathname(p) + '..' } end @resources = @resource_paths.map do |path| Resource.new(self, path) end self end
ruby
def read @resource_paths = Dir.chdir(path) do Dir['**/Contents.json'].map { |p| Pathname(p) + '..' } end @resources = @resource_paths.map do |path| Resource.new(self, path) end self end
[ "def", "read", "@resource_paths", "=", "Dir", ".", "chdir", "(", "path", ")", "do", "Dir", "[", "'**/Contents.json'", "]", ".", "map", "{", "|", "p", "|", "Pathname", "(", "p", ")", "+", "'..'", "}", "end", "@resources", "=", "@resource_paths", ".", ...
Initialize a new file with given path @param [Pathname] path the location of the container Read the resources from disk @return [XCAssets::Bundle]
[ "Initialize", "a", "new", "file", "with", "given", "path" ]
4747b072ab316e7c6f389db9a3cad584e814fe43
https://github.com/xcres/xcres/blob/4747b072ab316e7c6f389db9a3cad584e814fe43/lib/xcres/model/xcassets/bundle.rb#L44-L52
2,685
xcres/xcres
lib/xcres/analyzer/strings_analyzer.rb
XCRes.StringsAnalyzer.build_section
def build_section selected_file_refs = selected_strings_file_refs # Apply ignore list file_paths = filter_exclusions(selected_file_refs.map(&:path)) filtered_file_refs = selected_file_refs.select { |file_ref| file_paths.include? file_ref.path } rel_file_paths = filtered_file_refs.map { |p...
ruby
def build_section selected_file_refs = selected_strings_file_refs # Apply ignore list file_paths = filter_exclusions(selected_file_refs.map(&:path)) filtered_file_refs = selected_file_refs.select { |file_ref| file_paths.include? file_ref.path } rel_file_paths = filtered_file_refs.map { |p...
[ "def", "build_section", "selected_file_refs", "=", "selected_strings_file_refs", "# Apply ignore list", "file_paths", "=", "filter_exclusions", "(", "selected_file_refs", ".", "map", "(", ":path", ")", ")", "filtered_file_refs", "=", "selected_file_refs", ".", "select", "...
Build the section @return [Section]
[ "Build", "the", "section" ]
4747b072ab316e7c6f389db9a3cad584e814fe43
https://github.com/xcres/xcres/blob/4747b072ab316e7c6f389db9a3cad584e814fe43/lib/xcres/analyzer/strings_analyzer.rb#L43-L60
2,686
xcres/xcres
lib/xcres/analyzer/strings_analyzer.rb
XCRes.StringsAnalyzer.info_plist_paths
def info_plist_paths @info_plist_paths ||= target.build_configurations.map do |config| config.build_settings['INFOPLIST_FILE'] end.compact.map { |file| Pathname(file) }.flatten.to_set end
ruby
def info_plist_paths @info_plist_paths ||= target.build_configurations.map do |config| config.build_settings['INFOPLIST_FILE'] end.compact.map { |file| Pathname(file) }.flatten.to_set end
[ "def", "info_plist_paths", "@info_plist_paths", "||=", "target", ".", "build_configurations", ".", "map", "do", "|", "config", "|", "config", ".", "build_settings", "[", "'INFOPLIST_FILE'", "]", "end", ".", "compact", ".", "map", "{", "|", "file", "|", "Pathna...
Discover Info.plist files by build settings of the application target @return [Set<Pathname>] the relative paths to the .plist-files
[ "Discover", "Info", ".", "plist", "files", "by", "build", "settings", "of", "the", "application", "target" ]
4747b072ab316e7c6f389db9a3cad584e814fe43
https://github.com/xcres/xcres/blob/4747b072ab316e7c6f389db9a3cad584e814fe43/lib/xcres/analyzer/strings_analyzer.rb#L124-L128
2,687
xcres/xcres
lib/xcres/analyzer/strings_analyzer.rb
XCRes.StringsAnalyzer.native_dev_languages
def native_dev_languages @native_dev_languages ||= absolute_info_plist_paths.map do |path| begin read_plist_key(path, :CFBundleDevelopmentRegion) rescue ArgumentError => e warn e end end.compact.to_set end
ruby
def native_dev_languages @native_dev_languages ||= absolute_info_plist_paths.map do |path| begin read_plist_key(path, :CFBundleDevelopmentRegion) rescue ArgumentError => e warn e end end.compact.to_set end
[ "def", "native_dev_languages", "@native_dev_languages", "||=", "absolute_info_plist_paths", ".", "map", "do", "|", "path", "|", "begin", "read_plist_key", "(", "path", ",", ":CFBundleDevelopmentRegion", ")", "rescue", "ArgumentError", "=>", "e", "warn", "e", "end", ...
Find the native development languages by trying to use the "Localization native development region" from Info.plist @return [Set<String>]
[ "Find", "the", "native", "development", "languages", "by", "trying", "to", "use", "the", "Localization", "native", "development", "region", "from", "Info", ".", "plist" ]
4747b072ab316e7c6f389db9a3cad584e814fe43
https://github.com/xcres/xcres/blob/4747b072ab316e7c6f389db9a3cad584e814fe43/lib/xcres/analyzer/strings_analyzer.rb#L154-L162
2,688
xcres/xcres
lib/xcres/analyzer/strings_analyzer.rb
XCRes.StringsAnalyzer.keys_by_file
def keys_by_file(path) begin # Load strings file contents strings = read_strings_file(path) # Reject generated identifiers used by Interface Builder strings.reject! { |key, _| /^[a-zA-Z0-9]{3}-[a-zA-Z0-9]{2,3}-[a-zA-Z0-9]{3}/.match(key) } keys = Hash[strings.map do |key, ...
ruby
def keys_by_file(path) begin # Load strings file contents strings = read_strings_file(path) # Reject generated identifiers used by Interface Builder strings.reject! { |key, _| /^[a-zA-Z0-9]{3}-[a-zA-Z0-9]{2,3}-[a-zA-Z0-9]{3}/.match(key) } keys = Hash[strings.map do |key, ...
[ "def", "keys_by_file", "(", "path", ")", "begin", "# Load strings file contents", "strings", "=", "read_strings_file", "(", "path", ")", "# Reject generated identifiers used by Interface Builder", "strings", ".", "reject!", "{", "|", "key", ",", "_", "|", "/", "/", ...
Read a file and collect all its keys @param [Pathname] path the path to the .strings file to read @return [Hash{String => Hash}]
[ "Read", "a", "file", "and", "collect", "all", "its", "keys" ]
4747b072ab316e7c6f389db9a3cad584e814fe43
https://github.com/xcres/xcres/blob/4747b072ab316e7c6f389db9a3cad584e814fe43/lib/xcres/analyzer/strings_analyzer.rb#L230-L248
2,689
jkraemer/acts_as_ferret
lib/acts_as_ferret/instance_methods.rb
ActsAsFerret.InstanceMethods.ferret_enabled?
def ferret_enabled?(is_bulk_index = false) @ferret_disabled.nil? && (is_bulk_index || self.class.ferret_enabled?) && (aaf_configuration[:if].nil? || aaf_configuration[:if].call(self)) end
ruby
def ferret_enabled?(is_bulk_index = false) @ferret_disabled.nil? && (is_bulk_index || self.class.ferret_enabled?) && (aaf_configuration[:if].nil? || aaf_configuration[:if].call(self)) end
[ "def", "ferret_enabled?", "(", "is_bulk_index", "=", "false", ")", "@ferret_disabled", ".", "nil?", "&&", "(", "is_bulk_index", "||", "self", ".", "class", ".", "ferret_enabled?", ")", "&&", "(", "aaf_configuration", "[", ":if", "]", ".", "nil?", "||", "aaf_...
compatibility returns true if ferret indexing is enabled for this record. The optional is_bulk_index parameter will be true if the method is called by rebuild_index or bulk_index, and false otherwise. If is_bulk_index is true, the class level ferret_enabled state will be ignored by this method (per-instance ferr...
[ "compatibility", "returns", "true", "if", "ferret", "indexing", "is", "enabled", "for", "this", "record", "." ]
1c3330c51a4d07298e6b89347077742636d9e3cf
https://github.com/jkraemer/acts_as_ferret/blob/1c3330c51a4d07298e6b89347077742636d9e3cf/lib/acts_as_ferret/instance_methods.rb#L49-L51
2,690
enebo/jmx
lib/jmx/notifier.rb
JMX.RubyNotificationEmitter.removeNotificationListener
def removeNotificationListener(listener, filter=nil, handback=nil) found = false listeners.delete_if do |clistener, (cfilter, chandback)| v = listener == clistener && filter == cfilter && handback == chandback found = true if v v end raise javax.management.ListenerNotFoun...
ruby
def removeNotificationListener(listener, filter=nil, handback=nil) found = false listeners.delete_if do |clistener, (cfilter, chandback)| v = listener == clistener && filter == cfilter && handback == chandback found = true if v v end raise javax.management.ListenerNotFoun...
[ "def", "removeNotificationListener", "(", "listener", ",", "filter", "=", "nil", ",", "handback", "=", "nil", ")", "found", "=", "false", "listeners", ".", "delete_if", "do", "|", "clistener", ",", "(", "cfilter", ",", "chandback", ")", "|", "v", "=", "l...
NotificationListener listener, NotificationFilter filter, Object handback
[ "NotificationListener", "listener", "NotificationFilter", "filter", "Object", "handback" ]
2418d7fcf941b2a5ee08a7881cff8c016dfd3ca7
https://github.com/enebo/jmx/blob/2418d7fcf941b2a5ee08a7881cff8c016dfd3ca7/lib/jmx/notifier.rb#L21-L29
2,691
enebo/jmx
lib/jmx/mbean_proxy.rb
JMX.MBeanProxy.[]
def [](name) attribute = @server.getAttribute(@object_name, name.to_s) return attribute.value if attribute.kind_of? javax.management.Attribute attribute end
ruby
def [](name) attribute = @server.getAttribute(@object_name, name.to_s) return attribute.value if attribute.kind_of? javax.management.Attribute attribute end
[ "def", "[]", "(", "name", ")", "attribute", "=", "@server", ".", "getAttribute", "(", "@object_name", ",", "name", ".", "to_s", ")", "return", "attribute", ".", "value", "if", "attribute", ".", "kind_of?", "javax", ".", "management", ".", "Attribute", "att...
Get MBean attribute specified by name. If it is just a plain attribute then unwrap the attribute and just return the value.
[ "Get", "MBean", "attribute", "specified", "by", "name", ".", "If", "it", "is", "just", "a", "plain", "attribute", "then", "unwrap", "the", "attribute", "and", "just", "return", "the", "value", "." ]
2418d7fcf941b2a5ee08a7881cff8c016dfd3ca7
https://github.com/enebo/jmx/blob/2418d7fcf941b2a5ee08a7881cff8c016dfd3ca7/lib/jmx/mbean_proxy.rb#L61-L65
2,692
enebo/jmx
lib/jmx/mbean_proxy.rb
JMX.MBeanProxy.[]=
def []=(name, value) @server.setAttribute @object_name, javax.management.Attribute.new(name.to_s, value) end
ruby
def []=(name, value) @server.setAttribute @object_name, javax.management.Attribute.new(name.to_s, value) end
[ "def", "[]=", "(", "name", ",", "value", ")", "@server", ".", "setAttribute", "@object_name", ",", "javax", ".", "management", ".", "Attribute", ".", "new", "(", "name", ".", "to_s", ",", "value", ")", "end" ]
Set MBean attribute specified by name to value
[ "Set", "MBean", "attribute", "specified", "by", "name", "to", "value" ]
2418d7fcf941b2a5ee08a7881cff8c016dfd3ca7
https://github.com/enebo/jmx/blob/2418d7fcf941b2a5ee08a7881cff8c016dfd3ca7/lib/jmx/mbean_proxy.rb#L69-L71
2,693
enebo/jmx
lib/jmx/mbean_proxy.rb
JMX.MBeanProxy.invoke
def invoke(name, *params) op = @info.operations.find { |o| o.name == name.to_s } raise NoMethodError.new("No such operation #{name}") unless op jargs, jtypes = java_args(op.signature, params) @server.invoke @object_name, op.name, jargs, jtypes end
ruby
def invoke(name, *params) op = @info.operations.find { |o| o.name == name.to_s } raise NoMethodError.new("No such operation #{name}") unless op jargs, jtypes = java_args(op.signature, params) @server.invoke @object_name, op.name, jargs, jtypes end
[ "def", "invoke", "(", "name", ",", "*", "params", ")", "op", "=", "@info", ".", "operations", ".", "find", "{", "|", "o", "|", "o", ".", "name", "==", "name", ".", "to_s", "}", "raise", "NoMethodError", ".", "new", "(", "\"No such operation #{name}\"",...
Invoke an operation. A NoMethodError will be thrown if this MBean cannot respond to the operation. FIXME: Add scoring to pick best match instead of first found
[ "Invoke", "an", "operation", ".", "A", "NoMethodError", "will", "be", "thrown", "if", "this", "MBean", "cannot", "respond", "to", "the", "operation", "." ]
2418d7fcf941b2a5ee08a7881cff8c016dfd3ca7
https://github.com/enebo/jmx/blob/2418d7fcf941b2a5ee08a7881cff8c016dfd3ca7/lib/jmx/mbean_proxy.rb#L78-L85
2,694
enebo/jmx
lib/jmx/mbean_proxy.rb
JMX.MBeanProxy.java_types
def java_types(params) return nil if params.nil? params.map {|e| e.class.java_class.name }.to_java(:string) end
ruby
def java_types(params) return nil if params.nil? params.map {|e| e.class.java_class.name }.to_java(:string) end
[ "def", "java_types", "(", "params", ")", "return", "nil", "if", "params", ".", "nil?", "params", ".", "map", "{", "|", "e", "|", "e", ".", "class", ".", "java_class", ".", "name", "}", ".", "to_java", "(", ":string", ")", "end" ]
Convert a collection of java objects to their Java class name equivalents
[ "Convert", "a", "collection", "of", "java", "objects", "to", "their", "Java", "class", "name", "equivalents" ]
2418d7fcf941b2a5ee08a7881cff8c016dfd3ca7
https://github.com/enebo/jmx/blob/2418d7fcf941b2a5ee08a7881cff8c016dfd3ca7/lib/jmx/mbean_proxy.rb#L154-L158
2,695
jmatsu/danger-apkstats
lib/apkstats/command/executable.rb
Apkstats::Command.Executable.compare_with
def compare_with(apk_filepath, other_apk_filepath) base = Apkstats::Entity::ApkInfo.new(self, apk_filepath) other = Apkstats::Entity::ApkInfo.new(self, other_apk_filepath) Apkstats::Entity::ApkInfoDiff.new(base, other).to_h end
ruby
def compare_with(apk_filepath, other_apk_filepath) base = Apkstats::Entity::ApkInfo.new(self, apk_filepath) other = Apkstats::Entity::ApkInfo.new(self, other_apk_filepath) Apkstats::Entity::ApkInfoDiff.new(base, other).to_h end
[ "def", "compare_with", "(", "apk_filepath", ",", "other_apk_filepath", ")", "base", "=", "Apkstats", "::", "Entity", "::", "ApkInfo", ".", "new", "(", "self", ",", "apk_filepath", ")", "other", "=", "Apkstats", "::", "Entity", "::", "ApkInfo", ".", "new", ...
Compare two apk files and return results. { base: { file_size: Integer, download_size: Integer, required_features: Array<String>, non_required_features: Array<String>, permissions: Array<String>, min_sdk: String, target_sdk: String, method_reference_count: Integer, dex_...
[ "Compare", "two", "apk", "files", "and", "return", "results", "." ]
bc450681dc7bcc2bd340997f6f167ed3b430376e
https://github.com/jmatsu/danger-apkstats/blob/bc450681dc7bcc2bd340997f6f167ed3b430376e/lib/apkstats/command/executable.rb#L61-L66
2,696
xcres/xcres
lib/xcres/analyzer/analyzer.rb
XCRes.Analyzer.new_section
def new_section(name, data, options={}) XCRes::Section.new(name, data, self.options.merge(options)) end
ruby
def new_section(name, data, options={}) XCRes::Section.new(name, data, self.options.merge(options)) end
[ "def", "new_section", "(", "name", ",", "data", ",", "options", "=", "{", "}", ")", "XCRes", "::", "Section", ".", "new", "(", "name", ",", "data", ",", "self", ".", "options", ".", "merge", "(", "options", ")", ")", "end" ]
Create a new +Section+. @param [String] name see Section#name @param [Hash] items see Section#items @param [Hash] options see Section#options @return [XCRes::Section]
[ "Create", "a", "new", "+", "Section", "+", "." ]
4747b072ab316e7c6f389db9a3cad584e814fe43
https://github.com/xcres/xcres/blob/4747b072ab316e7c6f389db9a3cad584e814fe43/lib/xcres/analyzer/analyzer.rb#L80-L82
2,697
xcres/xcres
lib/xcres/analyzer/analyzer.rb
XCRes.Analyzer.filter_exclusions
def filter_exclusions file_paths file_paths.reject do |path| exclude_file_patterns.any? { |pattern| File.fnmatch("#{pattern}", path) || File.fnmatch("**/#{pattern}", path) } end end
ruby
def filter_exclusions file_paths file_paths.reject do |path| exclude_file_patterns.any? { |pattern| File.fnmatch("#{pattern}", path) || File.fnmatch("**/#{pattern}", path) } end end
[ "def", "filter_exclusions", "file_paths", "file_paths", ".", "reject", "do", "|", "path", "|", "exclude_file_patterns", ".", "any?", "{", "|", "pattern", "|", "File", ".", "fnmatch", "(", "\"#{pattern}\"", ",", "path", ")", "||", "File", ".", "fnmatch", "(",...
Apply the configured exclude file patterns to a list of files @param [Array<Pathname>] file_paths the list of files to filter @param [Array<Pathname>] the filtered list of files
[ "Apply", "the", "configured", "exclude", "file", "patterns", "to", "a", "list", "of", "files" ]
4747b072ab316e7c6f389db9a3cad584e814fe43
https://github.com/xcres/xcres/blob/4747b072ab316e7c6f389db9a3cad584e814fe43/lib/xcres/analyzer/analyzer.rb#L92-L96
2,698
xcres/xcres
lib/xcres/analyzer/analyzer.rb
XCRes.Analyzer.find_file_refs_by_extname
def find_file_refs_by_extname(extname) project.files.select do |file_ref| File.extname(file_ref.path) == extname \ && is_file_ref_included_in_application_target?(file_ref) end end
ruby
def find_file_refs_by_extname(extname) project.files.select do |file_ref| File.extname(file_ref.path) == extname \ && is_file_ref_included_in_application_target?(file_ref) end end
[ "def", "find_file_refs_by_extname", "(", "extname", ")", "project", ".", "files", ".", "select", "do", "|", "file_ref", "|", "File", ".", "extname", "(", "file_ref", ".", "path", ")", "==", "extname", "&&", "is_file_ref_included_in_application_target?", "(", "fi...
Discover all references to files with a specific extension in project, which belong to a resources build phase of an application target. @param [String] extname the extname, which contains a leading dot e.g.: '.bundle', '.strings' @return [Array<PBXFileReference>]
[ "Discover", "all", "references", "to", "files", "with", "a", "specific", "extension", "in", "project", "which", "belong", "to", "a", "resources", "build", "phase", "of", "an", "application", "target", "." ]
4747b072ab316e7c6f389db9a3cad584e814fe43
https://github.com/xcres/xcres/blob/4747b072ab316e7c6f389db9a3cad584e814fe43/lib/xcres/analyzer/analyzer.rb#L107-L112
2,699
xcres/xcres
lib/xcres/analyzer/analyzer.rb
XCRes.Analyzer.resources_files
def resources_files target.resources_build_phase.files.map do |build_file| if build_file.file_ref.is_a?(Xcodeproj::Project::Object::PBXGroup) build_file.file_ref.recursive_children else [build_file.file_ref] end end.flatten.compact end
ruby
def resources_files target.resources_build_phase.files.map do |build_file| if build_file.file_ref.is_a?(Xcodeproj::Project::Object::PBXGroup) build_file.file_ref.recursive_children else [build_file.file_ref] end end.flatten.compact end
[ "def", "resources_files", "target", ".", "resources_build_phase", ".", "files", ".", "map", "do", "|", "build_file", "|", "if", "build_file", ".", "file_ref", ".", "is_a?", "(", "Xcodeproj", "::", "Project", "::", "Object", "::", "PBXGroup", ")", "build_file",...
Find files in resources build phases of application targets @return [Array<PBXFileReference>]
[ "Find", "files", "in", "resources", "build", "phases", "of", "application", "targets" ]
4747b072ab316e7c6f389db9a3cad584e814fe43
https://github.com/xcres/xcres/blob/4747b072ab316e7c6f389db9a3cad584e814fe43/lib/xcres/analyzer/analyzer.rb#L130-L138