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
19,700
instana/ruby-sensor
lib/instana/tracing/trace.rb
Instana.Trace.add_backtrace_to_span
def add_backtrace_to_span(bt, limit = nil, span) frame_count = 0 span[:stack] = [] bt.each do |i| # If the stack has the full instana gem version in it's path # then don't include that frame. Also don't exclude the Rack module. if !i.match(/instana\/instrumentation\/rack.rb/)....
ruby
def add_backtrace_to_span(bt, limit = nil, span) frame_count = 0 span[:stack] = [] bt.each do |i| # If the stack has the full instana gem version in it's path # then don't include that frame. Also don't exclude the Rack module. if !i.match(/instana\/instrumentation\/rack.rb/)....
[ "def", "add_backtrace_to_span", "(", "bt", ",", "limit", "=", "nil", ",", "span", ")", "frame_count", "=", "0", "span", "[", ":stack", "]", "=", "[", "]", "bt", ".", "each", "do", "|", "i", "|", "# If the stack has the full instana gem version in it's path", ...
Adds the passed in backtrace to the specified span. Backtrace can be one generated from Kernel.caller or one attached to an exception @param bt [Array] the backtrace @param limit [Integer] Limit the backtrace to the top <limit> frames @param span [Span] the span to add the backtrace to or if unspecified the cu...
[ "Adds", "the", "passed", "in", "backtrace", "to", "the", "specified", "span", ".", "Backtrace", "can", "be", "one", "generated", "from", "Kernel", ".", "caller", "or", "one", "attached", "to", "an", "exception" ]
9d1b3e46b22c4f77919f67ff6ee5831dad5d5b99
https://github.com/instana/ruby-sensor/blob/9d1b3e46b22c4f77919f67ff6ee5831dad5d5b99/lib/instana/tracing/trace.rb#L297-L319
19,701
Origen-SDK/origen
lib/origen/parameters.rb
Origen.Parameters.param?
def param?(name) _param = name.to_s =~ /^params./ ? name.to_s : 'params.' + name.to_s begin val = eval("self.#{_param}") rescue nil else val end end
ruby
def param?(name) _param = name.to_s =~ /^params./ ? name.to_s : 'params.' + name.to_s begin val = eval("self.#{_param}") rescue nil else val end end
[ "def", "param?", "(", "name", ")", "_param", "=", "name", ".", "to_s", "=~", "/", "/", "?", "name", ".", "to_s", ":", "'params.'", "+", "name", ".", "to_s", "begin", "val", "=", "eval", "(", "\"self.#{_param}\"", ")", "rescue", "nil", "else", "val", ...
Return value of param if it exists, nil otherwise.
[ "Return", "value", "of", "param", "if", "it", "exists", "nil", "otherwise", "." ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/parameters.rb#L73-L82
19,702
Origen-SDK/origen
lib/origen/controller.rb
Origen.Controller.model
def model @model ||= begin if self.class.path_to_model m = eval(self.class.path_to_model) if m if m.respond_to?(:_controller=) m.send(:_controller=, self) end else fail "No model object found at path: #{self.class.path_to_mode...
ruby
def model @model ||= begin if self.class.path_to_model m = eval(self.class.path_to_model) if m if m.respond_to?(:_controller=) m.send(:_controller=, self) end else fail "No model object found at path: #{self.class.path_to_mode...
[ "def", "model", "@model", "||=", "begin", "if", "self", ".", "class", ".", "path_to_model", "m", "=", "eval", "(", "self", ".", "class", ".", "path_to_model", ")", "if", "m", "if", "m", ".", "respond_to?", "(", ":_controller=", ")", "m", ".", "send", ...
Returns the controller's model
[ "Returns", "the", "controller", "s", "model" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/controller.rb#L65-L79
19,703
Origen-SDK/origen
lib/origen/controller.rb
Origen.Controller.method_missing
def method_missing(method, *args, &block) if model.respond_to?(method) # This method is handled separately since it is important to produce a proxy method # that takes no arguments, otherwise the register address lookup system mistakes it # for a legacy way of calculating the base address ...
ruby
def method_missing(method, *args, &block) if model.respond_to?(method) # This method is handled separately since it is important to produce a proxy method # that takes no arguments, otherwise the register address lookup system mistakes it # for a legacy way of calculating the base address ...
[ "def", "method_missing", "(", "method", ",", "*", "args", ",", "&", "block", ")", "if", "model", ".", "respond_to?", "(", "method", ")", "# This method is handled separately since it is important to produce a proxy method", "# that takes no arguments, otherwise the register add...
Used to proxy all method and attribute requests not implemented on the controller to the model. On first call of a missing method a method is generated to avoid the missing lookup next time, this should be faster for repeated lookups of the same method, e.g. reg
[ "Used", "to", "proxy", "all", "method", "and", "attribute", "requests", "not", "implemented", "on", "the", "controller", "to", "the", "model", "." ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/controller.rb#L122-L142
19,704
Origen-SDK/origen
lib/origen/chips.rb
Origen.Chips.has_chip?
def has_chip?(s, options = {}) _chips options = { group: nil, family: nil, performance: nil, chip: nil, creating_spec: false }.update(options) options[:chip] = s !!show_chips(options) end
ruby
def has_chip?(s, options = {}) _chips options = { group: nil, family: nil, performance: nil, chip: nil, creating_spec: false }.update(options) options[:chip] = s !!show_chips(options) end
[ "def", "has_chip?", "(", "s", ",", "options", "=", "{", "}", ")", "_chips", "options", "=", "{", "group", ":", "nil", ",", "family", ":", "nil", ",", "performance", ":", "nil", ",", "chip", ":", "nil", ",", "creating_spec", ":", "false", "}", ".", ...
Check if the current IP has a spec
[ "Check", "if", "the", "current", "IP", "has", "a", "spec" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/chips.rb#L86-L97
19,705
Origen-SDK/origen
lib/origen/chips.rb
Origen.Chips.filter_hash
def filter_hash(hash, filter) fail 'Hash argument is not a Hash!' unless hash.is_a? Hash filtered_hash = {} select_logic = case filter when String then 'k[Regexp.new(filter)]' when (Fixnum || Integer || Float || Numeric) then "k[Regexp.new('#{filter}')]" when Regexp then 'k[fil...
ruby
def filter_hash(hash, filter) fail 'Hash argument is not a Hash!' unless hash.is_a? Hash filtered_hash = {} select_logic = case filter when String then 'k[Regexp.new(filter)]' when (Fixnum || Integer || Float || Numeric) then "k[Regexp.new('#{filter}')]" when Regexp then 'k[fil...
[ "def", "filter_hash", "(", "hash", ",", "filter", ")", "fail", "'Hash argument is not a Hash!'", "unless", "hash", ".", "is_a?", "Hash", "filtered_hash", "=", "{", "}", "select_logic", "=", "case", "filter", "when", "String", "then", "'k[Regexp.new(filter)]'", "wh...
Return a hash based on the filter provided
[ "Return", "a", "hash", "based", "on", "the", "filter", "provided" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/chips.rb#L220-L237
19,706
Origen-SDK/origen
lib/c99/nvm.rb
C99.NVMSub.add_reg_with_block_format
def add_reg_with_block_format # ** Data Register 3 ** # This is dreg add_reg :dreg, 0x1000, size: 16 do |reg| # This is dreg bit 15 reg.bit 15, :bit15, reset: 1 # **Bit 14** - This does something cool # # 0 | Coolness is disabled # 1 | Coolness is ena...
ruby
def add_reg_with_block_format # ** Data Register 3 ** # This is dreg add_reg :dreg, 0x1000, size: 16 do |reg| # This is dreg bit 15 reg.bit 15, :bit15, reset: 1 # **Bit 14** - This does something cool # # 0 | Coolness is disabled # 1 | Coolness is ena...
[ "def", "add_reg_with_block_format", "# ** Data Register 3 **", "# This is dreg", "add_reg", ":dreg", ",", "0x1000", ",", "size", ":", "16", "do", "|", "reg", "|", "# This is dreg bit 15", "reg", ".", "bit", "15", ",", ":bit15", ",", "reset", ":", "1", "# **Bit 1...
Tests that the block format for defining registers works
[ "Tests", "that", "the", "block", "format", "for", "defining", "registers", "works" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/c99/nvm.rb#L68-L108
19,707
Origen-SDK/origen
lib/origen/registers.rb
Origen.Registers.add_reg
def add_reg(id, address, size = nil, bit_info = {}, &_block) if address.is_a?(Hash) fail 'add_reg requires the address to be supplied as the 2nd argument, e.g. add_reg :my_reg, 0x1000' end size, bit_info = nil, size if size.is_a?(Hash) size ||= bit_info.delete(:size) || 32 descript...
ruby
def add_reg(id, address, size = nil, bit_info = {}, &_block) if address.is_a?(Hash) fail 'add_reg requires the address to be supplied as the 2nd argument, e.g. add_reg :my_reg, 0x1000' end size, bit_info = nil, size if size.is_a?(Hash) size ||= bit_info.delete(:size) || 32 descript...
[ "def", "add_reg", "(", "id", ",", "address", ",", "size", "=", "nil", ",", "bit_info", "=", "{", "}", ",", "&", "_block", ")", "if", "address", ".", "is_a?", "(", "Hash", ")", "fail", "'add_reg requires the address to be supplied as the 2nd argument, e.g. add_re...
Add a register. When adding a register you must supply a name, an address, size in bits, and bit definitions, any bits that are not declared will be filled with dummy bit objects that are not writable and will read back as 0. @example Name Address Size Bit Definitions add_reg :control, 0x00,...
[ "Add", "a", "register", ".", "When", "adding", "a", "register", "you", "must", "supply", "a", "name", "an", "address", "size", "in", "bits", "and", "bit", "definitions", "any", "bits", "that", "are", "not", "declared", "will", "be", "filled", "with", "du...
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/registers.rb#L310-L369
19,708
Origen-SDK/origen
lib/origen/registers.rb
Origen.Registers.bit
def bit(index, name, attrs = {}) if index.is_a?(Range) msb = index.first lsb = index.last msb, lsb = lsb, msb if lsb > msb pos = lsb bits = (msb - lsb).abs + 1 elsif index.is_a?(Numeric) pos = index bits = 1 else fail 'No valid index supp...
ruby
def bit(index, name, attrs = {}) if index.is_a?(Range) msb = index.first lsb = index.last msb, lsb = lsb, msb if lsb > msb pos = lsb bits = (msb - lsb).abs + 1 elsif index.is_a?(Numeric) pos = index bits = 1 else fail 'No valid index supp...
[ "def", "bit", "(", "index", ",", "name", ",", "attrs", "=", "{", "}", ")", "if", "index", ".", "is_a?", "(", "Range", ")", "msb", "=", "index", ".", "first", "lsb", "=", "index", ".", "last", "msb", ",", "lsb", "=", "lsb", ",", "msb", "if", "...
Called within an add_reg block to define bits
[ "Called", "within", "an", "add_reg", "block", "to", "define", "bits" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/registers.rb#L387-L421
19,709
Origen-SDK/origen
lib/origen/registers.rb
Origen.Registers.default_reg_metadata
def default_reg_metadata Origen::Registers.reg_metadata[self.class] ||= {} if block_given? collector = Origen::Utility::Collector.new yield collector Origen::Registers.reg_metadata[self.class].merge!(collector.to_h) end Origen::Registers.reg_metadata[self.class] end
ruby
def default_reg_metadata Origen::Registers.reg_metadata[self.class] ||= {} if block_given? collector = Origen::Utility::Collector.new yield collector Origen::Registers.reg_metadata[self.class].merge!(collector.to_h) end Origen::Registers.reg_metadata[self.class] end
[ "def", "default_reg_metadata", "Origen", "::", "Registers", ".", "reg_metadata", "[", "self", ".", "class", "]", "||=", "{", "}", "if", "block_given?", "collector", "=", "Origen", "::", "Utility", "::", "Collector", ".", "new", "yield", "collector", "Origen", ...
Can be called to add app specific meta data that is isolated to all registers defined within a given class
[ "Can", "be", "called", "to", "add", "app", "specific", "meta", "data", "that", "is", "isolated", "to", "all", "registers", "defined", "within", "a", "given", "class" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/registers.rb#L427-L435
19,710
Origen-SDK/origen
lib/origen/registers.rb
Origen.Registers.has_reg?
def has_reg?(name, params = {}) params = { test_for_true_false: true }.update(params) if params.key?(:enabled_features) || params.key?(:enabled_feature) return !!get_registers(params).include?(name) else params[:enabled_features] = :default return !!get_registers(...
ruby
def has_reg?(name, params = {}) params = { test_for_true_false: true }.update(params) if params.key?(:enabled_features) || params.key?(:enabled_feature) return !!get_registers(params).include?(name) else params[:enabled_features] = :default return !!get_registers(...
[ "def", "has_reg?", "(", "name", ",", "params", "=", "{", "}", ")", "params", "=", "{", "test_for_true_false", ":", "true", "}", ".", "update", "(", "params", ")", "if", "params", ".", "key?", "(", ":enabled_features", ")", "||", "params", ".", "key?", ...
Returns true if the object contains a register matching the given name
[ "Returns", "true", "if", "the", "object", "contains", "a", "register", "matching", "the", "given", "name" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/registers.rb#L491-L501
19,711
Origen-SDK/origen
lib/origen/registers.rb
Origen.Registers.reg
def reg(*args, &block) if block_given? || (args[1].is_a?(Integer) && !try(:_initialized?)) @reg_define_file = define_file(caller[0]) add_reg(*args, &block) else # Example use cases: # reg(:reg2) # reg(:name => :reg2) # reg('/reg2/') if !args.empty? && ...
ruby
def reg(*args, &block) if block_given? || (args[1].is_a?(Integer) && !try(:_initialized?)) @reg_define_file = define_file(caller[0]) add_reg(*args, &block) else # Example use cases: # reg(:reg2) # reg(:name => :reg2) # reg('/reg2/') if !args.empty? && ...
[ "def", "reg", "(", "*", "args", ",", "&", "block", ")", "if", "block_given?", "||", "(", "args", "[", "1", "]", ".", "is_a?", "(", "Integer", ")", "&&", "!", "try", "(", ":_initialized?", ")", ")", "@reg_define_file", "=", "define_file", "(", "caller...
Returns -the register object matching the given name -or a hash of all registes matching a given regular expression -or a hash of all registers, associated with a feature, if no name is specified. Can also be used to define a new register if a block is supplied in which case it is equivalent to calling add_reg...
[ "Returns", "-", "the", "register", "object", "matching", "the", "given", "name", "-", "or", "a", "hash", "of", "all", "registes", "matching", "a", "given", "regular", "expression", "-", "or", "a", "hash", "of", "all", "registers", "associated", "with", "a"...
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/registers.rb#L511-L591
19,712
Origen-SDK/origen
lib/origen/regression_manager.rb
Origen.RegressionManager.prepare_targets
def prepare_targets(options) targets = [options[:target], options[:targets]].flatten.compact if targets.empty? puts 'You must supply the targets you are going to run in the options' puts 'passed to regression_manager.run.' fail end Origen.target.loop(options) { |_options|...
ruby
def prepare_targets(options) targets = [options[:target], options[:targets]].flatten.compact if targets.empty? puts 'You must supply the targets you are going to run in the options' puts 'passed to regression_manager.run.' fail end Origen.target.loop(options) { |_options|...
[ "def", "prepare_targets", "(", "options", ")", "targets", "=", "[", "options", "[", ":target", "]", ",", "options", "[", ":targets", "]", "]", ".", "flatten", ".", "compact", "if", "targets", ".", "empty?", "puts", "'You must supply the targets you are going to ...
Cycle through all targets in the upcoming run to ensure that all output directories exist
[ "Cycle", "through", "all", "targets", "in", "the", "upcoming", "run", "to", "ensure", "that", "all", "output", "directories", "exist" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/regression_manager.rb#L160-L169
19,713
Origen-SDK/origen
lib/origen/regression_manager.rb
Origen.RegressionManager.regression_command_file
def regression_command_file first_call = caller.find { |line| line =~ /regression_manager.rb.*run/ } app_caller_line = caller[caller.index(first_call) + 1] app_caller_line =~ /(.*\.rb)/ path = Pathname.new(Regexp.last_match[1]) end
ruby
def regression_command_file first_call = caller.find { |line| line =~ /regression_manager.rb.*run/ } app_caller_line = caller[caller.index(first_call) + 1] app_caller_line =~ /(.*\.rb)/ path = Pathname.new(Regexp.last_match[1]) end
[ "def", "regression_command_file", "first_call", "=", "caller", ".", "find", "{", "|", "line", "|", "line", "=~", "/", "/", "}", "app_caller_line", "=", "caller", "[", "caller", ".", "index", "(", "first_call", ")", "+", "1", "]", "app_caller_line", "=~", ...
Returns a full path to the regression command file within the local application
[ "Returns", "a", "full", "path", "to", "the", "regression", "command", "file", "within", "the", "local", "application" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/regression_manager.rb#L254-L259
19,714
Origen-SDK/origen
lib/origen/componentable.rb
Origen.Componentable._add
def _add(name, options = {}, &block) # Add the name and parent to the options if they aren't already given # If the parent isn't available on the includer class, it will remain nil. options = { name: name, parent: parent }.merge(options) options = Origen::Utility.collect...
ruby
def _add(name, options = {}, &block) # Add the name and parent to the options if they aren't already given # If the parent isn't available on the includer class, it will remain nil. options = { name: name, parent: parent }.merge(options) options = Origen::Utility.collect...
[ "def", "_add", "(", "name", ",", "options", "=", "{", "}", ",", "&", "block", ")", "# Add the name and parent to the options if they aren't already given", "# If the parent isn't available on the includer class, it will remain nil.", "options", "=", "{", "name", ":", "name", ...
Adds a new item to the componentable container. @note All options added will be passed to the subclasses instantiation. @note The options is only valid for the stock :add method. @note Any extra options provided are still passed to the subclasses instantiation. @param name [Symbol] Name to reference the new compone...
[ "Adds", "a", "new", "item", "to", "the", "componentable", "container", "." ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/componentable.rb#L430-L447
19,715
Origen-SDK/origen
lib/origen/componentable.rb
Origen.Componentable.move
def move(to_move, new_name, options = {}) overwrite = options[:overwrite] || false if @_componentable_container.key?(new_name) && !overwrite # The move location already exists and override was not specified fail Origen::Componentable::NameInUseError, "#{_singleton_name} name :#{new_name} is...
ruby
def move(to_move, new_name, options = {}) overwrite = options[:overwrite] || false if @_componentable_container.key?(new_name) && !overwrite # The move location already exists and override was not specified fail Origen::Componentable::NameInUseError, "#{_singleton_name} name :#{new_name} is...
[ "def", "move", "(", "to_move", ",", "new_name", ",", "options", "=", "{", "}", ")", "overwrite", "=", "options", "[", ":overwrite", "]", "||", "false", "if", "@_componentable_container", ".", "key?", "(", "new_name", ")", "&&", "!", "overwrite", "# The mov...
Moves a component object from one name to another. @param to_move [Symbol] Component name to move elsewhere. @param new_name [Symbol] New name to give to the component from :to_move. @return [Symbol] The component moved. @raise [Origen::Componentable::NameInUseError] Raised if :new_name is already in use and the :o...
[ "Moves", "a", "component", "object", "from", "one", "name", "to", "another", "." ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/componentable.rb#L556-L571
19,716
Origen-SDK/origen
lib/origen/componentable.rb
Origen.Componentable.delete
def delete(to_delete) obj = delete!(to_delete) fail Origen::Componentable::NameDoesNotExistError, "#{_singleton_name} name :#{to_delete} does not exist" if obj.nil? obj end
ruby
def delete(to_delete) obj = delete!(to_delete) fail Origen::Componentable::NameDoesNotExistError, "#{_singleton_name} name :#{to_delete} does not exist" if obj.nil? obj end
[ "def", "delete", "(", "to_delete", ")", "obj", "=", "delete!", "(", "to_delete", ")", "fail", "Origen", "::", "Componentable", "::", "NameDoesNotExistError", ",", "\"#{_singleton_name} name :#{to_delete} does not exist\"", "if", "obj", ".", "nil?", "obj", "end" ]
Deletes a component from the componentable container @param name [Symbol] Name of component to delete @return [Hash(Symbol, <ComponentableItem>)] containing the name of the component deleted and its component. @raise [Origen::Componentable::NameDoesNotExistsError] Raised if :to_copy name does not exists.
[ "Deletes", "a", "component", "from", "the", "componentable", "container" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/componentable.rb#L577-L581
19,717
Origen-SDK/origen
lib/origen/componentable.rb
Origen.Componentable.delete_all
def delete_all # delete individual objects one by one, making sure to delete all accessors as well returns = {} @_componentable_container.each do |key, val| delete!(key) returns[key] = val end returns end
ruby
def delete_all # delete individual objects one by one, making sure to delete all accessors as well returns = {} @_componentable_container.each do |key, val| delete!(key) returns[key] = val end returns end
[ "def", "delete_all", "# delete individual objects one by one, making sure to delete all accessors as well", "returns", "=", "{", "}", "@_componentable_container", ".", "each", "do", "|", "key", ",", "val", "|", "delete!", "(", "key", ")", "returns", "[", "key", "]", "...
Deletes all of the components in the container. @return [Hash(Symbol, <ComponentableItem>)] Hash containing all of the deleted items.
[ "Deletes", "all", "of", "the", "components", "in", "the", "container", "." ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/componentable.rb#L602-L610
19,718
Origen-SDK/origen
lib/origen/sub_blocks.rb
Origen.SubBlocks.init_sub_blocks
def init_sub_blocks(*args) options = args.find { |a| a.is_a?(Hash) } @custom_attrs = (options ? options.dup : {}).with_indifferent_access # Delete these keys which are either meta data added by Origen or are already covered by # dedicated methods %w(parent name base_address reg_base_addres...
ruby
def init_sub_blocks(*args) options = args.find { |a| a.is_a?(Hash) } @custom_attrs = (options ? options.dup : {}).with_indifferent_access # Delete these keys which are either meta data added by Origen or are already covered by # dedicated methods %w(parent name base_address reg_base_addres...
[ "def", "init_sub_blocks", "(", "*", "args", ")", "options", "=", "args", ".", "find", "{", "|", "a", "|", "a", ".", "is_a?", "(", "Hash", ")", "}", "@custom_attrs", "=", "(", "options", "?", "options", ".", "dup", ":", "{", "}", ")", ".", "with_i...
This will be called whenever an object that includes this module is instantiated @api private
[ "This", "will", "be", "called", "whenever", "an", "object", "that", "includes", "this", "module", "is", "instantiated" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/sub_blocks.rb#L7-L37
19,719
Origen-SDK/origen
lib/origen/sub_blocks.rb
Origen.SubBlocks.owns_registers?
def owns_registers? if regs regs.is_a?(Origen::Registers::RegCollection) && !regs.empty? else false end end
ruby
def owns_registers? if regs regs.is_a?(Origen::Registers::RegCollection) && !regs.empty? else false end end
[ "def", "owns_registers?", "if", "regs", "regs", ".", "is_a?", "(", "Origen", "::", "Registers", "::", "RegCollection", ")", "&&", "!", "regs", ".", "empty?", "else", "false", "end", "end" ]
Returns true if the given sub block owns at least one register
[ "Returns", "true", "if", "the", "given", "sub", "block", "owns", "at", "least", "one", "register" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/sub_blocks.rb#L257-L263
19,720
Origen-SDK/origen
lib/origen/sub_blocks.rb
Origen.SubBlock.method_missing
def method_missing(method, *args, &block) super rescue NoMethodError return regs(method) if self.has_reg?(method) return ports(method) if self.has_port?(method) if method.to_s =~ /=$/ define_singleton_method(method) do |val| instance_variable_set("@#{method.to_s.sub('=', ''...
ruby
def method_missing(method, *args, &block) super rescue NoMethodError return regs(method) if self.has_reg?(method) return ports(method) if self.has_port?(method) if method.to_s =~ /=$/ define_singleton_method(method) do |val| instance_variable_set("@#{method.to_s.sub('=', ''...
[ "def", "method_missing", "(", "method", ",", "*", "args", ",", "&", "block", ")", "super", "rescue", "NoMethodError", "return", "regs", "(", "method", ")", "if", "self", ".", "has_reg?", "(", "method", ")", "return", "ports", "(", "method", ")", "if", ...
Used to create attribute accessors on the fly. On first call of a missing method a method is generated to avoid the missing lookup next time, this should be faster for repeated lookups of the same method, e.g. reg
[ "Used", "to", "create", "attribute", "accessors", "on", "the", "fly", "." ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/sub_blocks.rb#L509-L524
19,721
Origen-SDK/origen
lib/origen/specs.rb
Origen.Specs.documentation
def documentation(header_info, selection, applicable_devices, link) _documentation # Create a new documenation and place it in the 5-D hash @_documentation[header_info[:section]][header_info[:subsection]][selection[:interface]][selection[:type]][selection[:sub_type]][selection[:mode]][selection[:audie...
ruby
def documentation(header_info, selection, applicable_devices, link) _documentation # Create a new documenation and place it in the 5-D hash @_documentation[header_info[:section]][header_info[:subsection]][selection[:interface]][selection[:type]][selection[:sub_type]][selection[:mode]][selection[:audie...
[ "def", "documentation", "(", "header_info", ",", "selection", ",", "applicable_devices", ",", "link", ")", "_documentation", "# Create a new documenation and place it in the 5-D hash", "@_documentation", "[", "header_info", "[", ":section", "]", "]", "[", "header_info", "...
Adds a new documentation notion to the block
[ "Adds", "a", "new", "documentation", "notion", "to", "the", "block" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/specs.rb#L137-L141
19,722
Origen-SDK/origen
lib/origen/specs.rb
Origen.Specs.spec_feature
def spec_feature(id, attrs, device, text, internal_comment) # Welguisz: No idea why this is here, but keeping it here because it follows other blocks _spec_features # Create a new feature and place it in the features 2-D Hash @_spec_features[id][device] = Spec_Features.new(id, attrs, device, te...
ruby
def spec_feature(id, attrs, device, text, internal_comment) # Welguisz: No idea why this is here, but keeping it here because it follows other blocks _spec_features # Create a new feature and place it in the features 2-D Hash @_spec_features[id][device] = Spec_Features.new(id, attrs, device, te...
[ "def", "spec_feature", "(", "id", ",", "attrs", ",", "device", ",", "text", ",", "internal_comment", ")", "# Welguisz: No idea why this is here, but keeping it here because it follows other blocks", "_spec_features", "# Create a new feature and place it in the features 2-D Hash", "@...
Adds a new feature to the block
[ "Adds", "a", "new", "feature", "to", "the", "block" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/specs.rb#L144-L149
19,723
Origen-SDK/origen
lib/origen/specs.rb
Origen.Specs.notes
def notes(options = {}) # Create a default 2 item hash and update if options is supplied options = { id: nil, type: nil }.update(options) return nil if @_notes.nil? return nil if @_notes.empty? # Empty 2-D Hash to be used for notes found based on id and type n...
ruby
def notes(options = {}) # Create a default 2 item hash and update if options is supplied options = { id: nil, type: nil }.update(options) return nil if @_notes.nil? return nil if @_notes.empty? # Empty 2-D Hash to be used for notes found based on id and type n...
[ "def", "notes", "(", "options", "=", "{", "}", ")", "# Create a default 2 item hash and update if options is supplied", "options", "=", "{", "id", ":", "nil", ",", "type", ":", "nil", "}", ".", "update", "(", "options", ")", "return", "nil", "if", "@_notes", ...
Returns a Note object from the notes hash
[ "Returns", "a", "Note", "object", "from", "the", "notes", "hash" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/specs.rb#L223-L252
19,724
Origen-SDK/origen
lib/origen/specs.rb
Origen.Specs.specs_to_table_string
def specs_to_table_string(specs_to_be_shown) whitespace_padding = 3 table = [] attrs_to_be_shown = { name: SpecTableAttr.new('Name', true, 'Name'.length + whitespace_padding), symbol: SpecTableAttr.new('Symbol', false, 'Symbol'.length + whitespace_padding), ...
ruby
def specs_to_table_string(specs_to_be_shown) whitespace_padding = 3 table = [] attrs_to_be_shown = { name: SpecTableAttr.new('Name', true, 'Name'.length + whitespace_padding), symbol: SpecTableAttr.new('Symbol', false, 'Symbol'.length + whitespace_padding), ...
[ "def", "specs_to_table_string", "(", "specs_to_be_shown", ")", "whitespace_padding", "=", "3", "table", "=", "[", "]", "attrs_to_be_shown", "=", "{", "name", ":", "SpecTableAttr", ".", "new", "(", "'Name'", ",", "true", ",", "'Name'", ".", "length", "+", "wh...
Method to print a spec table to the console
[ "Method", "to", "print", "a", "spec", "table", "to", "the", "console" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/specs.rb#L726-L788
19,725
Origen-SDK/origen
lib/origen/application.rb
Origen.Application.maillist_parse
def maillist_parse(file) maillist = [] # if file doesn't exist, just return empty array, otherwise, parse for emails if File.exist?(file) File.readlines(file).each do |line| if index = (line =~ /\#/) # line contains some kind of comment # check if there is an...
ruby
def maillist_parse(file) maillist = [] # if file doesn't exist, just return empty array, otherwise, parse for emails if File.exist?(file) File.readlines(file).each do |line| if index = (line =~ /\#/) # line contains some kind of comment # check if there is an...
[ "def", "maillist_parse", "(", "file", ")", "maillist", "=", "[", "]", "# if file doesn't exist, just return empty array, otherwise, parse for emails", "if", "File", ".", "exist?", "(", "file", ")", "File", ".", "readlines", "(", "file", ")", ".", "each", "do", "|"...
Parses maillist file and returns an array of email address
[ "Parses", "maillist", "file", "and", "returns", "an", "array", "of", "email", "address" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/application.rb#L240-L261
19,726
Origen-SDK/origen
lib/origen/application.rb
Origen.Application.server_data
def server_data if name == :origen @server_data ||= Origen.client.origen else @server_data ||= Origen.client.plugins.find { |p| p[:origen_name].downcase == name.to_s.downcase } end end
ruby
def server_data if name == :origen @server_data ||= Origen.client.origen else @server_data ||= Origen.client.plugins.find { |p| p[:origen_name].downcase == name.to_s.downcase } end end
[ "def", "server_data", "if", "name", "==", ":origen", "@server_data", "||=", "Origen", ".", "client", ".", "origen", "else", "@server_data", "||=", "Origen", ".", "client", ".", "plugins", ".", "find", "{", "|", "p", "|", "p", "[", ":origen_name", "]", "....
Returns the server data packet available for the given application, returns nil if none is found
[ "Returns", "the", "server", "data", "packet", "available", "for", "the", "given", "application", "returns", "nil", "if", "none", "is", "found" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/application.rb#L285-L291
19,727
Origen-SDK/origen
lib/origen/application.rb
Origen.Application.release_date
def release_date(version = Origen.app.version.prefixed) time = release_time(version) time ? time.to_date : nil end
ruby
def release_date(version = Origen.app.version.prefixed) time = release_time(version) time ? time.to_date : nil end
[ "def", "release_date", "(", "version", "=", "Origen", ".", "app", ".", "version", ".", "prefixed", ")", "time", "=", "release_time", "(", "version", ")", "time", "?", "time", ".", "to_date", ":", "nil", "end" ]
Returns the release date for the current or given application version
[ "Returns", "the", "release", "date", "for", "the", "current", "or", "given", "application", "version" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/application.rb#L436-L439
19,728
Origen-SDK/origen
lib/origen/application.rb
Origen.Application.dynamic_resource
def dynamic_resource(name, default, options = {}) @static_resources ||= {} @transient_resources ||= {} if @load_event == :static || (!@load_event && options[:adding]) if options[:set] @static_resources[name] = default else @static_resources[name] ||= defaul...
ruby
def dynamic_resource(name, default, options = {}) @static_resources ||= {} @transient_resources ||= {} if @load_event == :static || (!@load_event && options[:adding]) if options[:set] @static_resources[name] = default else @static_resources[name] ||= defaul...
[ "def", "dynamic_resource", "(", "name", ",", "default", ",", "options", "=", "{", "}", ")", "@static_resources", "||=", "{", "}", "@transient_resources", "||=", "{", "}", "if", "@load_event", "==", ":static", "||", "(", "!", "@load_event", "&&", "options", ...
Enable for debugging to see what the currently tracked objects are def object_store [@load_event, @static_resources, @transient_resources] end
[ "Enable", "for", "debugging", "to", "see", "what", "the", "currently", "tracked", "objects", "are", "def", "object_store", "[" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/application.rb#L857-L882
19,729
Origen-SDK/origen
lib/origen/client.rb
Origen.Client.release!
def release! version = Origen.app.version body = { version: version.to_s } if version.production? body[:type] = :production else body[:type] = :development end post("plugins/#{Origen.app.name}/release", body: body) end
ruby
def release! version = Origen.app.version body = { version: version.to_s } if version.production? body[:type] = :production else body[:type] = :development end post("plugins/#{Origen.app.name}/release", body: body) end
[ "def", "release!", "version", "=", "Origen", ".", "app", ".", "version", "body", "=", "{", "version", ":", "version", ".", "to_s", "}", "if", "version", ".", "production?", "body", "[", ":type", "]", "=", ":production", "else", "body", "[", ":type", "]...
This will be called by the Origen release process to post the latest app version information to the server
[ "This", "will", "be", "called", "by", "the", "Origen", "release", "process", "to", "post", "the", "latest", "app", "version", "information", "to", "the", "server" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/client.rb#L66-L75
19,730
Origen-SDK/origen
lib/origen/model.rb
Origen.Model.current_mode=
def current_mode=(id) @current_mode = id.is_a?(ChipMode) ? id.id : id Origen.app.listeners_for(:on_mode_changed).each do |listener| listener.on_mode_changed(mode: @current_mode, instance: self) end @current_mode end
ruby
def current_mode=(id) @current_mode = id.is_a?(ChipMode) ? id.id : id Origen.app.listeners_for(:on_mode_changed).each do |listener| listener.on_mode_changed(mode: @current_mode, instance: self) end @current_mode end
[ "def", "current_mode", "=", "(", "id", ")", "@current_mode", "=", "id", ".", "is_a?", "(", "ChipMode", ")", "?", "id", ".", "id", ":", "id", "Origen", ".", "app", ".", "listeners_for", "(", ":on_mode_changed", ")", ".", "each", "do", "|", "listener", ...
Set the current mode configuration of the current model
[ "Set", "the", "current", "mode", "configuration", "of", "the", "current", "model" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/model.rb#L219-L225
19,731
Origen-SDK/origen
lib/origen/model.rb
Origen.Model.modes
def modes(id = nil, _options = {}) id = nil if id.is_a?(Hash) if id _modes[id] else _modes.ids end end
ruby
def modes(id = nil, _options = {}) id = nil if id.is_a?(Hash) if id _modes[id] else _modes.ids end end
[ "def", "modes", "(", "id", "=", "nil", ",", "_options", "=", "{", "}", ")", "id", "=", "nil", "if", "id", ".", "is_a?", "(", "Hash", ")", "if", "id", "_modes", "[", "id", "]", "else", "_modes", ".", "ids", "end", "end" ]
Returns an array containing the IDs of all known modes if no ID is supplied, otherwise returns an object representing the given mode ID
[ "Returns", "an", "array", "containing", "the", "IDs", "of", "all", "known", "modes", "if", "no", "ID", "is", "supplied", "otherwise", "returns", "an", "object", "representing", "the", "given", "mode", "ID" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/model.rb#L242-L249
19,732
Origen-SDK/origen
lib/origen/model.rb
Origen.Model.with_each_mode
def with_each_mode begin orig = current_mode rescue orig = nil end modes.each do |_id, mode| self.current_mode = mode yield mode end self.current_mode = orig end
ruby
def with_each_mode begin orig = current_mode rescue orig = nil end modes.each do |_id, mode| self.current_mode = mode yield mode end self.current_mode = orig end
[ "def", "with_each_mode", "begin", "orig", "=", "current_mode", "rescue", "orig", "=", "nil", "end", "modes", ".", "each", "do", "|", "_id", ",", "mode", "|", "self", ".", "current_mode", "=", "mode", "yield", "mode", "end", "self", ".", "current_mode", "...
Executes the given block of code for each known chip mode, inside the block the current mode of the top level block will be set to the given mode. At the end of the block the current mode will be restored to whatever it was before entering the block.
[ "Executes", "the", "given", "block", "of", "code", "for", "each", "known", "chip", "mode", "inside", "the", "block", "the", "current", "mode", "of", "the", "top", "level", "block", "will", "be", "set", "to", "the", "given", "mode", "." ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/model.rb#L265-L276
19,733
Origen-SDK/origen
lib/origen/model.rb
Origen.Model.find_specs
def find_specs specs_found = [] # Check for specs the object owns if self.respond_to? :specs object_specs = specs unless object_specs.nil? if object_specs.class == Origen::Specs::Spec specs_found << object_specs else specs_found.concat(object...
ruby
def find_specs specs_found = [] # Check for specs the object owns if self.respond_to? :specs object_specs = specs unless object_specs.nil? if object_specs.class == Origen::Specs::Spec specs_found << object_specs else specs_found.concat(object...
[ "def", "find_specs", "specs_found", "=", "[", "]", "# Check for specs the object owns", "if", "self", ".", "respond_to?", ":specs", "object_specs", "=", "specs", "unless", "object_specs", ".", "nil?", "if", "object_specs", ".", "class", "==", "Origen", "::", "Spec...
Returns all specs found for the model. if none found it returns an empty array
[ "Returns", "all", "specs", "found", "for", "the", "model", ".", "if", "none", "found", "it", "returns", "an", "empty", "array" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/model.rb#L287-L312
19,734
Origen-SDK/origen
lib/origen/model.rb
Origen.Model.delete_all_specs_and_notes
def delete_all_specs_and_notes(obj = nil) obj = self if obj.nil? obj.delete_all_specs obj.delete_all_notes obj.delete_all_exhibits obj.children.each do |_name, child| next unless child.has_specs? delete_all_specs_and_notes(child) end end
ruby
def delete_all_specs_and_notes(obj = nil) obj = self if obj.nil? obj.delete_all_specs obj.delete_all_notes obj.delete_all_exhibits obj.children.each do |_name, child| next unless child.has_specs? delete_all_specs_and_notes(child) end end
[ "def", "delete_all_specs_and_notes", "(", "obj", "=", "nil", ")", "obj", "=", "self", "if", "obj", ".", "nil?", "obj", ".", "delete_all_specs", "obj", ".", "delete_all_notes", "obj", ".", "delete_all_exhibits", "obj", ".", "children", ".", "each", "do", "|",...
Delete all specs and notes for self recursively
[ "Delete", "all", "specs", "and", "notes", "for", "self", "recursively" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/model.rb#L315-L324
19,735
Origen-SDK/origen
lib/origen/model.rb
Origen.Model.method_missing
def method_missing(method, *args, &block) if controller.respond_to?(method) define_singleton_method(method) do |*args, &block| controller.send(method, *args, &block) end send(method, *args, &block) else super end end
ruby
def method_missing(method, *args, &block) if controller.respond_to?(method) define_singleton_method(method) do |*args, &block| controller.send(method, *args, &block) end send(method, *args, &block) else super end end
[ "def", "method_missing", "(", "method", ",", "*", "args", ",", "&", "block", ")", "if", "controller", ".", "respond_to?", "(", "method", ")", "define_singleton_method", "(", "method", ")", "do", "|", "*", "args", ",", "&", "block", "|", "controller", "."...
Used to proxy all method and attribute requests not implemented on the model to the controller. On first call of a missing method a method is generated to avoid the missing lookup next time, this should be faster for repeated lookups of the same method, e.g. reg
[ "Used", "to", "proxy", "all", "method", "and", "attribute", "requests", "not", "implemented", "on", "the", "model", "to", "the", "controller", "." ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/model.rb#L342-L351
19,736
Origen-SDK/origen
lib/origen/users.rb
Origen.Users.current_user
def current_user core_id = Origen::Users::User.current_user_id user = app_users.find { |user| user.core_id == core_id } user || User.new(core_id) end
ruby
def current_user core_id = Origen::Users::User.current_user_id user = app_users.find { |user| user.core_id == core_id } user || User.new(core_id) end
[ "def", "current_user", "core_id", "=", "Origen", "::", "Users", "::", "User", ".", "current_user_id", "user", "=", "app_users", ".", "find", "{", "|", "user", "|", "user", ".", "core_id", "==", "core_id", "}", "user", "||", "User", ".", "new", "(", "co...
Returns a user object representing the current user, will return a default user object if the current user is not known to the generator
[ "Returns", "a", "user", "object", "representing", "the", "current", "user", "will", "return", "a", "default", "user", "object", "if", "the", "current", "user", "is", "not", "known", "to", "the", "generator" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/users.rb#L19-L23
19,737
Origen-SDK/origen
lib/origen/version_string.rb
Origen.VersionString.numeric
def numeric if latest? 1_000_000_000_000_000_000_000_000_000 elsif semantic? # This assumes each counter will never go > 1000 if development? self =~ /v?(\d+).(\d+).(\d+).(dev|pre)(\d+)/ (Regexp.last_match[1].to_i * 1000 * 1000 * 1000) + (Regexp.last_m...
ruby
def numeric if latest? 1_000_000_000_000_000_000_000_000_000 elsif semantic? # This assumes each counter will never go > 1000 if development? self =~ /v?(\d+).(\d+).(\d+).(dev|pre)(\d+)/ (Regexp.last_match[1].to_i * 1000 * 1000 * 1000) + (Regexp.last_m...
[ "def", "numeric", "if", "latest?", "1_000_000_000_000_000_000_000_000_000", "elsif", "semantic?", "# This assumes each counter will never go > 1000", "if", "development?", "self", "=~", "/", "\\d", "\\d", "\\d", "\\d", "/", "(", "Regexp", ".", "last_match", "[", "1", ...
Returns a numeric representation of the version, this can be used for chronological comparison with other versions
[ "Returns", "a", "numeric", "representation", "of", "the", "version", "this", "can", "be", "used", "for", "chronological", "comparison", "with", "other", "versions" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/version_string.rb#L255-L277
19,738
Origen-SDK/origen
lib/origen/version_string.rb
Origen.VersionString.to_time
def to_time if latest? Time.new(10_000, 1, 1) elsif timestamp? if development? self =~ /\w+_(\d\d\d\d)_(\d\d)_(\d\d)_(\d\d)_(\d\d)$/ Time.new(Regexp.last_match[1], Regexp.last_match[2], Regexp.last_match[3], Regexp.last_match[4], Regexp.last_match[5]) else ...
ruby
def to_time if latest? Time.new(10_000, 1, 1) elsif timestamp? if development? self =~ /\w+_(\d\d\d\d)_(\d\d)_(\d\d)_(\d\d)_(\d\d)$/ Time.new(Regexp.last_match[1], Regexp.last_match[2], Regexp.last_match[3], Regexp.last_match[4], Regexp.last_match[5]) else ...
[ "def", "to_time", "if", "latest?", "Time", ".", "new", "(", "10_000", ",", "1", ",", "1", ")", "elsif", "timestamp?", "if", "development?", "self", "=~", "/", "\\w", "\\d", "\\d", "\\d", "\\d", "\\d", "\\d", "\\d", "\\d", "\\d", "\\d", "\\d", "\\d", ...
Returns the version as a time, only applicable for timestamps, otherwise an error will be raised
[ "Returns", "the", "version", "as", "a", "time", "only", "applicable", "for", "timestamps", "otherwise", "an", "error", "will", "be", "raised" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/version_string.rb#L281-L295
19,739
Origen-SDK/origen
lib/origen/version_string.rb
Origen.VersionString.validate_condition!
def validate_condition!(condition, tag) tag = VersionString.new(tag) tag.validate!("The version condition, #{condition}, is not valid!") tag end
ruby
def validate_condition!(condition, tag) tag = VersionString.new(tag) tag.validate!("The version condition, #{condition}, is not valid!") tag end
[ "def", "validate_condition!", "(", "condition", ",", "tag", ")", "tag", "=", "VersionString", ".", "new", "(", "tag", ")", "tag", ".", "validate!", "(", "\"The version condition, #{condition}, is not valid!\"", ")", "tag", "end" ]
Validates the given condition and the extracted tag, returns the tag wrapped in a VersionString if valid, will raise an error if not
[ "Validates", "the", "given", "condition", "and", "the", "extracted", "tag", "returns", "the", "tag", "wrapped", "in", "a", "VersionString", "if", "valid", "will", "raise", "an", "error", "if", "not" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/version_string.rb#L312-L316
19,740
Origen-SDK/origen
lib/origen/remote_manager.rb
Origen.RemoteManager.delete_symlink
def delete_symlink(path) if Origen.running_on_windows? # Don't use regular rm on windows symlink, will delete into the remote dir! system("call cmd /c rmdir #{path.to_s.gsub('/', '\\')}") FileUtils.rm_f("#{path}_is_a_symlink") else FileUtils.rm_f(path) end end
ruby
def delete_symlink(path) if Origen.running_on_windows? # Don't use regular rm on windows symlink, will delete into the remote dir! system("call cmd /c rmdir #{path.to_s.gsub('/', '\\')}") FileUtils.rm_f("#{path}_is_a_symlink") else FileUtils.rm_f(path) end end
[ "def", "delete_symlink", "(", "path", ")", "if", "Origen", ".", "running_on_windows?", "# Don't use regular rm on windows symlink, will delete into the remote dir!", "system", "(", "\"call cmd /c rmdir #{path.to_s.gsub('/', '\\\\')}\"", ")", "FileUtils", ".", "rm_f", "(", "\"#{pa...
Manually handle symlink deletion to support windows @api private
[ "Manually", "handle", "symlink", "deletion", "to", "support", "windows" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/remote_manager.rb#L100-L108
19,741
Origen-SDK/origen
lib/origen/remote_manager.rb
Origen.RemoteManager.process_remotes
def process_remotes remotes.each do |_name, remote| dir = workspace_of(remote) rc_url = remote[:rc_url] || remote[:vault] tag = remote[:tag].nil? ? Origen::VersionString.new(remote[:version]) : Origen::VersionString.new(remote[:tag]) version_file = dir.to_s + '/.current_version' ...
ruby
def process_remotes remotes.each do |_name, remote| dir = workspace_of(remote) rc_url = remote[:rc_url] || remote[:vault] tag = remote[:tag].nil? ? Origen::VersionString.new(remote[:version]) : Origen::VersionString.new(remote[:tag]) version_file = dir.to_s + '/.current_version' ...
[ "def", "process_remotes", "remotes", ".", "each", "do", "|", "_name", ",", "remote", "|", "dir", "=", "workspace_of", "(", "remote", ")", "rc_url", "=", "remote", "[", ":rc_url", "]", "||", "remote", "[", ":vault", "]", "tag", "=", "remote", "[", ":tag...
Process each remote
[ "Process", "each", "remote" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/remote_manager.rb#L131-L161
19,742
Origen-SDK/origen
lib/origen/remote_manager.rb
Origen.RemoteManager.path_enabled?
def path_enabled?(remote) dir = workspace_of(remote) File.exist?(dir) && symlink?(dir) end
ruby
def path_enabled?(remote) dir = workspace_of(remote) File.exist?(dir) && symlink?(dir) end
[ "def", "path_enabled?", "(", "remote", ")", "dir", "=", "workspace_of", "(", "remote", ")", "File", ".", "exist?", "(", "dir", ")", "&&", "symlink?", "(", "dir", ")", "end" ]
Returns true if the given import is currently setup as a path
[ "Returns", "true", "if", "the", "given", "import", "is", "currently", "setup", "as", "a", "path" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/remote_manager.rb#L242-L245
19,743
Origen-SDK/origen
lib/origen/remote_manager.rb
Origen.RemoteManager.update!
def update! ensure_remotes_directory dirty_remotes.each do |_name, remote| dir = workspace_of(remote) if remote[:path] || path_enabled?(remote) if symlink?(dir) delete_symlink(dir) else FileUtils.rm_rf(dir) if File.exist?(dir) end ...
ruby
def update! ensure_remotes_directory dirty_remotes.each do |_name, remote| dir = workspace_of(remote) if remote[:path] || path_enabled?(remote) if symlink?(dir) delete_symlink(dir) else FileUtils.rm_rf(dir) if File.exist?(dir) end ...
[ "def", "update!", "ensure_remotes_directory", "dirty_remotes", ".", "each", "do", "|", "_name", ",", "remote", "|", "dir", "=", "workspace_of", "(", "remote", ")", "if", "remote", "[", ":path", "]", "||", "path_enabled?", "(", "remote", ")", "if", "symlink?"...
Makes all dirty remotes clean
[ "Makes", "all", "dirty", "remotes", "clean" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/remote_manager.rb#L323-L365
19,744
Origen-SDK/origen
lib/origen/remote_manager.rb
Origen.RemoteManager.prefix_tag
def prefix_tag(tag) tag = Origen::VersionString.new(tag) if tag.semantic? tag.prefixed else tag end end
ruby
def prefix_tag(tag) tag = Origen::VersionString.new(tag) if tag.semantic? tag.prefixed else tag end end
[ "def", "prefix_tag", "(", "tag", ")", "tag", "=", "Origen", "::", "VersionString", ".", "new", "(", "tag", ")", "if", "tag", ".", "semantic?", "tag", ".", "prefixed", "else", "tag", "end", "end" ]
If the supplied tag looks like a semantic version number, then make sure it has the 'v' prefix
[ "If", "the", "supplied", "tag", "looks", "like", "a", "semantic", "version", "number", "then", "make", "sure", "it", "has", "the", "v", "prefix" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/remote_manager.rb#L385-L392
19,745
Origen-SDK/origen
lib/origen/top_level.rb
Origen.TopLevel.current_package=
def current_package=(val) @current_package_id = case val when ChipPackage val.id else packages.include?(val) ? val : nil end end
ruby
def current_package=(val) @current_package_id = case val when ChipPackage val.id else packages.include?(val) ? val : nil end end
[ "def", "current_package", "=", "(", "val", ")", "@current_package_id", "=", "case", "val", "when", "ChipPackage", "val", ".", "id", "else", "packages", ".", "include?", "(", "val", ")", "?", "val", ":", "nil", "end", "end" ]
Use this to specify the current package option for the given SoC. This allows different pin configurations to be specified by package.
[ "Use", "this", "to", "specify", "the", "current", "package", "option", "for", "the", "given", "SoC", "." ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/top_level.rb#L65-L72
19,746
Origen-SDK/origen
lib/origen/top_level.rb
Origen.TopLevel.packages
def packages(id = nil, _options = {}) id, options = nil, id if id.is_a?(Hash) if id _packages[id] else _packages.ids end end
ruby
def packages(id = nil, _options = {}) id, options = nil, id if id.is_a?(Hash) if id _packages[id] else _packages.ids end end
[ "def", "packages", "(", "id", "=", "nil", ",", "_options", "=", "{", "}", ")", "id", ",", "options", "=", "nil", ",", "id", "if", "id", ".", "is_a?", "(", "Hash", ")", "if", "id", "_packages", "[", "id", "]", "else", "_packages", ".", "ids", "e...
Returns an array containing the IDs of all known configurations if no ID is supplied, otherwise returns an object representing the given package ID
[ "Returns", "an", "array", "containing", "the", "IDs", "of", "all", "known", "configurations", "if", "no", "ID", "is", "supplied", "otherwise", "returns", "an", "object", "representing", "the", "given", "package", "ID" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/top_level.rb#L87-L94
19,747
Origen-SDK/origen
lib/origen/errata.rb
Origen.Errata.erratum
def erratum(id, ip_block, overview = {}, status = {}, sw_workaround = {}) _errata @_errata[id][ip_block][status[:disposition]] = HwErratum.new(id, ip_block, overview, status, sw_workaround) end
ruby
def erratum(id, ip_block, overview = {}, status = {}, sw_workaround = {}) _errata @_errata[id][ip_block][status[:disposition]] = HwErratum.new(id, ip_block, overview, status, sw_workaround) end
[ "def", "erratum", "(", "id", ",", "ip_block", ",", "overview", "=", "{", "}", ",", "status", "=", "{", "}", ",", "sw_workaround", "=", "{", "}", ")", "_errata", "@_errata", "[", "id", "]", "[", "ip_block", "]", "[", "status", "[", ":disposition", "...
Define and instantiate an erratum object
[ "Define", "and", "instantiate", "an", "erratum", "object" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/errata.rb#L11-L14
19,748
Origen-SDK/origen
lib/origen/errata.rb
Origen.Errata.errata
def errata(options = {}) options = { id: nil, ip_block: nil, disposition: nil }.update(options) return nil if @_errata.nil? return nil if @_errata.empty? errata_found = Hash.new do |h, k| h[k] = Hash.new do |hh, kk| hh[kk] = {} ...
ruby
def errata(options = {}) options = { id: nil, ip_block: nil, disposition: nil }.update(options) return nil if @_errata.nil? return nil if @_errata.empty? errata_found = Hash.new do |h, k| h[k] = Hash.new do |hh, kk| hh[kk] = {} ...
[ "def", "errata", "(", "options", "=", "{", "}", ")", "options", "=", "{", "id", ":", "nil", ",", "ip_block", ":", "nil", ",", "disposition", ":", "nil", "}", ".", "update", "(", "options", ")", "return", "nil", "if", "@_errata", ".", "nil?", "retur...
Returns an erratum or list of erratum that meet a specific criteria
[ "Returns", "an", "erratum", "or", "list", "of", "erratum", "that", "meet", "a", "specific", "criteria" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/errata.rb#L17-L50
19,749
Origen-SDK/origen
lib/origen/errata.rb
Origen.Errata.sw_workaround
def sw_workaround(id, overview = {}, resolution = {}) _sw_workarounds @_sw_workarounds[id] = SwErratumWorkaround.new(id, overview, resolution) end
ruby
def sw_workaround(id, overview = {}, resolution = {}) _sw_workarounds @_sw_workarounds[id] = SwErratumWorkaround.new(id, overview, resolution) end
[ "def", "sw_workaround", "(", "id", ",", "overview", "=", "{", "}", ",", "resolution", "=", "{", "}", ")", "_sw_workarounds", "@_sw_workarounds", "[", "id", "]", "=", "SwErratumWorkaround", ".", "new", "(", "id", ",", "overview", ",", "resolution", ")", "...
Define and instantiate a sw_workaround object
[ "Define", "and", "instantiate", "a", "sw_workaround", "object" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/errata.rb#L53-L56
19,750
Origen-SDK/origen
lib/origen/errata.rb
Origen.Errata.sw_workarounds
def sw_workarounds(options = {}) options = { id: nil }.update(options) return nil if @_sw_workarounds.nil? return nil if @_sw_workarounds.empty? sw_workarounds_found = Hash.new do |h, k| h[k] = {} end # filter on id filter_hash(@_sw_workarounds, options[...
ruby
def sw_workarounds(options = {}) options = { id: nil }.update(options) return nil if @_sw_workarounds.nil? return nil if @_sw_workarounds.empty? sw_workarounds_found = Hash.new do |h, k| h[k] = {} end # filter on id filter_hash(@_sw_workarounds, options[...
[ "def", "sw_workarounds", "(", "options", "=", "{", "}", ")", "options", "=", "{", "id", ":", "nil", "}", ".", "update", "(", "options", ")", "return", "nil", "if", "@_sw_workarounds", ".", "nil?", "return", "nil", "if", "@_sw_workarounds", ".", "empty?",...
Returns a sw_workaround object with a specific id
[ "Returns", "a", "sw_workaround", "object", "with", "a", "specific", "id" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/errata.rb#L59-L81
19,751
Origen-SDK/origen
lib/origen/site_config.rb
Origen.SiteConfig.add_as_highest
def add_as_highest(var, value) # Don't want to override anything, so just shift in a dummy site config instance at the highest level and # set the value there. c = Config.new(path: :runtime, parent: self, values: { var.to_s => value }) configs.prepend(Config.new(path: :runtime, parent: self, val...
ruby
def add_as_highest(var, value) # Don't want to override anything, so just shift in a dummy site config instance at the highest level and # set the value there. c = Config.new(path: :runtime, parent: self, values: { var.to_s => value }) configs.prepend(Config.new(path: :runtime, parent: self, val...
[ "def", "add_as_highest", "(", "var", ",", "value", ")", "# Don't want to override anything, so just shift in a dummy site config instance at the highest level and", "# set the value there.", "c", "=", "Config", ".", "new", "(", "path", ":", ":runtime", ",", "parent", ":", "...
Dynamically add a new site variable at the highest priority.
[ "Dynamically", "add", "a", "new", "site", "variable", "at", "the", "highest", "priority", "." ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/site_config.rb#L116-L121
19,752
Origen-SDK/origen
lib/origen/site_config.rb
Origen.SiteConfig.add_as_lowest
def add_as_lowest(var, value) # Don't want to override anything, so just shift in a dummy site config at the lowest level and # set the value there. configs.append(Config.new(path: :runtime, parent: self, values: { var.to_s => value })) end
ruby
def add_as_lowest(var, value) # Don't want to override anything, so just shift in a dummy site config at the lowest level and # set the value there. configs.append(Config.new(path: :runtime, parent: self, values: { var.to_s => value })) end
[ "def", "add_as_lowest", "(", "var", ",", "value", ")", "# Don't want to override anything, so just shift in a dummy site config at the lowest level and", "# set the value there.", "configs", ".", "append", "(", "Config", ".", "new", "(", "path", ":", ":runtime", ",", "paren...
Dynamically add a new site variable at the lowest priority. Essentially, this sets a new default value.
[ "Dynamically", "add", "a", "new", "site", "variable", "at", "the", "lowest", "priority", ".", "Essentially", "this", "sets", "a", "new", "default", "value", "." ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/site_config.rb#L126-L130
19,753
Origen-SDK/origen
lib/origen/site_config.rb
Origen.SiteConfig.vars_by_configs
def vars_by_configs vars = {} configs.each do |c| vars = c.values.map { |k, v| [k, c] }.to_h.merge(vars) end vars end
ruby
def vars_by_configs vars = {} configs.each do |c| vars = c.values.map { |k, v| [k, c] }.to_h.merge(vars) end vars end
[ "def", "vars_by_configs", "vars", "=", "{", "}", "configs", ".", "each", "do", "|", "c", "|", "vars", "=", "c", ".", "values", ".", "map", "{", "|", "k", ",", "v", "|", "[", "k", ",", "c", "]", "}", ".", "to_h", ".", "merge", "(", "vars", "...
Gets all config variables as a hash, but the hash's values are the Config instances which defines the highest priority of each var, instead of the var's value itself.
[ "Gets", "all", "config", "variables", "as", "a", "hash", "but", "the", "hash", "s", "values", "are", "the", "Config", "instances", "which", "defines", "the", "highest", "priority", "of", "each", "var", "instead", "of", "the", "var", "s", "value", "itself",...
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/site_config.rb#L204-L210
19,754
Origen-SDK/origen
lib/origen/site_config.rb
Origen.SiteConfig.configs!
def configs! # This global is set when Origen is first required, it generally means that what is considered # to be the pwd for the purposes of looking for a site_config file is the place from where the # user invoked Origen. Otherwise if the running app switches the PWD it can lead to confusing ...
ruby
def configs! # This global is set when Origen is first required, it generally means that what is considered # to be the pwd for the purposes of looking for a site_config file is the place from where the # user invoked Origen. Otherwise if the running app switches the PWD it can lead to confusing ...
[ "def", "configs!", "# This global is set when Origen is first required, it generally means that what is considered", "# to be the pwd for the purposes of looking for a site_config file is the place from where the", "# user invoked Origen. Otherwise if the running app switches the PWD it can lead to confusin...
Forces a reparse of the site configs. This will set the configs along the current path first, then, using those values, will add a site config at the home directory.
[ "Forces", "a", "reparse", "of", "the", "site", "configs", ".", "This", "will", "set", "the", "configs", "along", "the", "current", "path", "first", "then", "using", "those", "values", "will", "add", "a", "site", "config", "at", "the", "home", "directory", ...
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/site_config.rb#L383-L428
19,755
Origen-SDK/origen
lib/origen/file_handler.rb
Origen.FileHandler.open_list
def open_list(file) f = clean_path_to(file, allow_missing: true) if f f = File.open(f, 'r') elsif File.exist?("#{Origen.root}/list/#{File.basename(file)}") f = File.open("#{Origen.root}/list/#{File.basename(file)}", 'r') elsif @last_opened_list_dir && File.exist?("#{@last_opened_...
ruby
def open_list(file) f = clean_path_to(file, allow_missing: true) if f f = File.open(f, 'r') elsif File.exist?("#{Origen.root}/list/#{File.basename(file)}") f = File.open("#{Origen.root}/list/#{File.basename(file)}", 'r') elsif @last_opened_list_dir && File.exist?("#{@last_opened_...
[ "def", "open_list", "(", "file", ")", "f", "=", "clean_path_to", "(", "file", ",", "allow_missing", ":", "true", ")", "if", "f", "f", "=", "File", ".", "open", "(", "f", ",", "'r'", ")", "elsif", "File", ".", "exist?", "(", "\"#{Origen.root}/list/#{Fil...
Returns the contents of the given list file in an array, if it can be found, if not will raise an error
[ "Returns", "the", "contents", "of", "the", "given", "list", "file", "in", "an", "array", "if", "it", "can", "be", "found", "if", "not", "will", "raise", "an", "error" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/file_handler.rb#L44-L62
19,756
Origen-SDK/origen
lib/origen/file_handler.rb
Origen.FileHandler.clean_path_to
def clean_path_to(file, options = {}) # Allow individual calls to this method to specify additional custom load paths to consider if options[:load_paths] [options[:load_paths]].each do |root| if File.exist?("#{root}/#{file}") return Pathname.new("#{root}/#{file}") end...
ruby
def clean_path_to(file, options = {}) # Allow individual calls to this method to specify additional custom load paths to consider if options[:load_paths] [options[:load_paths]].each do |root| if File.exist?("#{root}/#{file}") return Pathname.new("#{root}/#{file}") end...
[ "def", "clean_path_to", "(", "file", ",", "options", "=", "{", "}", ")", "# Allow individual calls to this method to specify additional custom load paths to consider", "if", "options", "[", ":load_paths", "]", "[", "options", "[", ":load_paths", "]", "]", ".", "each", ...
Returns a full path to the given file or directory, raises an error if it can't be resolved
[ "Returns", "a", "full", "path", "to", "the", "given", "file", "or", "directory", "raises", "an", "error", "if", "it", "can", "t", "be", "resolved" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/file_handler.rb#L100-L148
19,757
Origen-SDK/origen
lib/origen/file_handler.rb
Origen.FileHandler.relative_to_absolute
def relative_to_absolute(path) if Pathname.new(path).absolute? Pathname.new(path) else Pathname.new("#{Pathname.pwd}/#{path}") end end
ruby
def relative_to_absolute(path) if Pathname.new(path).absolute? Pathname.new(path) else Pathname.new("#{Pathname.pwd}/#{path}") end end
[ "def", "relative_to_absolute", "(", "path", ")", "if", "Pathname", ".", "new", "(", "path", ")", ".", "absolute?", "Pathname", ".", "new", "(", "path", ")", "else", "Pathname", ".", "new", "(", "\"#{Pathname.pwd}/#{path}\"", ")", "end", "end" ]
Returns an absolute path for the given
[ "Returns", "an", "absolute", "path", "for", "the", "given" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/file_handler.rb#L198-L204
19,758
Origen-SDK/origen
lib/origen/file_handler.rb
Origen.FileHandler.inject_import_path
def inject_import_path(path, options = {}) path = path.to_s unless path.is_a?(String) if path =~ /(.*?)\/.*/ import_name = Regexp.last_match[1].downcase.to_sym if import_name == :origen || import_name == :origen_core || Origen.app.plugins.names.include?(import_name) || import_name...
ruby
def inject_import_path(path, options = {}) path = path.to_s unless path.is_a?(String) if path =~ /(.*?)\/.*/ import_name = Regexp.last_match[1].downcase.to_sym if import_name == :origen || import_name == :origen_core || Origen.app.plugins.names.include?(import_name) || import_name...
[ "def", "inject_import_path", "(", "path", ",", "options", "=", "{", "}", ")", "path", "=", "path", ".", "to_s", "unless", "path", ".", "is_a?", "(", "String", ")", "if", "path", "=~", "/", "\\/", "/", "import_name", "=", "Regexp", ".", "last_match", ...
If the current path looks like it is a reference to an import, the path will be replaced with the absolute path to the local import directory
[ "If", "the", "current", "path", "looks", "like", "it", "is", "a", "reference", "to", "an", "import", "the", "path", "will", "be", "replaced", "with", "the", "absolute", "path", "to", "the", "local", "import", "directory" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/file_handler.rb#L248-L275
19,759
Origen-SDK/origen
lib/origen/file_handler.rb
Origen.FileHandler.add_underscore_to
def add_underscore_to(file) f = Pathname.new(file) if f.basename.to_s =~ /^_/ file else "#{f.dirname}/_#{f.basename}" end end
ruby
def add_underscore_to(file) f = Pathname.new(file) if f.basename.to_s =~ /^_/ file else "#{f.dirname}/_#{f.basename}" end end
[ "def", "add_underscore_to", "(", "file", ")", "f", "=", "Pathname", ".", "new", "(", "file", ")", "if", "f", ".", "basename", ".", "to_s", "=~", "/", "/", "file", "else", "\"#{f.dirname}/_#{f.basename}\"", "end", "end" ]
Insert _ in file name if not present
[ "Insert", "_", "in", "file", "name", "if", "not", "present" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/file_handler.rb#L284-L291
19,760
Origen-SDK/origen
lib/origen/file_handler.rb
Origen.FileHandler.sub_dir_of
def sub_dir_of(file, base = base_directory) file = Pathname.new(file) unless file.respond_to?(:relative_path_from) base = Pathname.new(base) unless base.respond_to?(:relative_path_from) rel = file.relative_path_from(base) if file.directory? rel else rel.dirname end ...
ruby
def sub_dir_of(file, base = base_directory) file = Pathname.new(file) unless file.respond_to?(:relative_path_from) base = Pathname.new(base) unless base.respond_to?(:relative_path_from) rel = file.relative_path_from(base) if file.directory? rel else rel.dirname end ...
[ "def", "sub_dir_of", "(", "file", ",", "base", "=", "base_directory", ")", "file", "=", "Pathname", ".", "new", "(", "file", ")", "unless", "file", ".", "respond_to?", "(", ":relative_path_from", ")", "base", "=", "Pathname", ".", "new", "(", "base", ")"...
Returns the sub directory of the current base directory that the given file is in
[ "Returns", "the", "sub", "directory", "of", "the", "current", "base", "directory", "that", "the", "given", "file", "is", "in" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/file_handler.rb#L429-L438
19,761
Origen-SDK/origen
lib/origen/file_handler.rb
Origen.FileHandler.open_for_write
def open_for_write(path) dir = Pathname.new(path).dirname FileUtils.mkdir_p(dir) unless File.exist?(dir) File.open(path, 'w') do |f| yield f end end
ruby
def open_for_write(path) dir = Pathname.new(path).dirname FileUtils.mkdir_p(dir) unless File.exist?(dir) File.open(path, 'w') do |f| yield f end end
[ "def", "open_for_write", "(", "path", ")", "dir", "=", "Pathname", ".", "new", "(", "path", ")", ".", "dirname", "FileUtils", ".", "mkdir_p", "(", "dir", ")", "unless", "File", ".", "exist?", "(", "dir", ")", "File", ".", "open", "(", "path", ",", ...
Convenience method to use when you want to write to a file, this takes care of ensuring that the directory exists prior to attempting to open the file
[ "Convenience", "method", "to", "use", "when", "you", "want", "to", "write", "to", "a", "file", "this", "takes", "care", "of", "ensuring", "that", "the", "directory", "exists", "prior", "to", "attempting", "to", "open", "the", "file" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/file_handler.rb#L443-L449
19,762
Origen-SDK/origen
lib/origen/bugs.rb
Origen.Bugs.has_bug?
def has_bug?(name, _options = {}) unless self.respond_to?(:version) && version puts 'To test for the presence of a bug the object must implement an attribute' puts "called 'version' which returns the IP version represented by the the object." fail 'Version undefined!' end name ...
ruby
def has_bug?(name, _options = {}) unless self.respond_to?(:version) && version puts 'To test for the presence of a bug the object must implement an attribute' puts "called 'version' which returns the IP version represented by the the object." fail 'Version undefined!' end name ...
[ "def", "has_bug?", "(", "name", ",", "_options", "=", "{", "}", ")", "unless", "self", ".", "respond_to?", "(", ":version", ")", "&&", "version", "puts", "'To test for the presence of a bug the object must implement an attribute'", "puts", "\"called 'version' which return...
Returns true if the version of the IP represented by the object has the bug of the given name
[ "Returns", "true", "if", "the", "version", "of", "the", "IP", "represented", "by", "the", "object", "has", "the", "bug", "of", "the", "given", "name" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/bugs.rb#L25-L37
19,763
Origen-SDK/origen
lib/origen/log.rb
Origen.Log.level=
def level=(val) unless LEVELS.include?(val) fail "Unknown log level, valid values are: #{LEVELS}" end # Map the log4r levels to our simplified 3 level system # log4r level order is DEBUG < INFO < WARN < ERROR < FATAL case val when :normal # Output everything except de...
ruby
def level=(val) unless LEVELS.include?(val) fail "Unknown log level, valid values are: #{LEVELS}" end # Map the log4r levels to our simplified 3 level system # log4r level order is DEBUG < INFO < WARN < ERROR < FATAL case val when :normal # Output everything except de...
[ "def", "level", "=", "(", "val", ")", "unless", "LEVELS", ".", "include?", "(", "val", ")", "fail", "\"Unknown log level, valid values are: #{LEVELS}\"", "end", "# Map the log4r levels to our simplified 3 level system", "# log4r level order is DEBUG < INFO < WARN < ERROR < FATAL", ...
Set the logger level, for valid values see LEVELS
[ "Set", "the", "logger", "level", "for", "valid", "values", "see", "LEVELS" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/log.rb#L54-L76
19,764
Origen-SDK/origen
lib/origen/log.rb
Origen.Log.log_files
def log_files(method, *args) # When running remotely on an LSF client, the LSF manager will capture STDOUT (i.e. the console log output) # and save it to a log file. # Don't write to the last log file in that case because we would have multiple processes all vying to # write to it at the same ti...
ruby
def log_files(method, *args) # When running remotely on an LSF client, the LSF manager will capture STDOUT (i.e. the console log output) # and save it to a log file. # Don't write to the last log file in that case because we would have multiple processes all vying to # write to it at the same ti...
[ "def", "log_files", "(", "method", ",", "*", "args", ")", "# When running remotely on an LSF client, the LSF manager will capture STDOUT (i.e. the console log output)", "# and save it to a log file.", "# Don't write to the last log file in that case because we would have multiple processes all v...
Sends the given method and arguments to all file logger instances
[ "Sends", "the", "given", "method", "and", "arguments", "to", "all", "file", "logger", "instances" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/log.rb#L332-L339
19,765
Origen-SDK/origen
lib/origen/pins.rb
Origen.Pins.pin_pattern_order
def pin_pattern_order(*pin_ids) if pin_ids.last.is_a?(Hash) options = pin_ids.pop else options = {} end pin_ids.each do |id| if pin_aliases[id] Origen.app.pin_names[pin_aliases[id].first] = id id = pin_aliases[id].first end Origen.app.p...
ruby
def pin_pattern_order(*pin_ids) if pin_ids.last.is_a?(Hash) options = pin_ids.pop else options = {} end pin_ids.each do |id| if pin_aliases[id] Origen.app.pin_names[pin_aliases[id].first] = id id = pin_aliases[id].first end Origen.app.p...
[ "def", "pin_pattern_order", "(", "*", "pin_ids", ")", "if", "pin_ids", ".", "last", ".", "is_a?", "(", "Hash", ")", "options", "=", "pin_ids", ".", "pop", "else", "options", "=", "{", "}", "end", "pin_ids", ".", "each", "do", "|", "id", "|", "if", ...
Specify the order that pins will appear in the output pattern, unspecified pins will appear in an arbitrary order at the end API v2, deprecated
[ "Specify", "the", "order", "that", "pins", "will", "appear", "in", "the", "output", "pattern", "unspecified", "pins", "will", "appear", "in", "an", "arbitrary", "order", "at", "the", "end" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/pins.rb#L323-L337
19,766
Origen-SDK/origen
lib/origen/pins.rb
Origen.Pins.all_power_pins
def all_power_pins(id = nil, _options = {}, &_block) if id pin = Origen.pin_bank.find(id, ignore_context: true, power_pin: true) else Origen.pin_bank.all_power_pins end end
ruby
def all_power_pins(id = nil, _options = {}, &_block) if id pin = Origen.pin_bank.find(id, ignore_context: true, power_pin: true) else Origen.pin_bank.all_power_pins end end
[ "def", "all_power_pins", "(", "id", "=", "nil", ",", "_options", "=", "{", "}", ",", "&", "_block", ")", "if", "id", "pin", "=", "Origen", ".", "pin_bank", ".", "find", "(", "id", ",", "ignore_context", ":", "true", ",", "power_pin", ":", "true", "...
Equivalent to the all_pins method but considers power pins rather than regular pins
[ "Equivalent", "to", "the", "all_pins", "method", "but", "considers", "power", "pins", "rather", "than", "regular", "pins" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/pins.rb#L552-L558
19,767
Origen-SDK/origen
lib/origen/pins.rb
Origen.Pins.all_other_pins
def all_other_pins(id = nil, _options = {}, &_block) if id pin = Origen.pin_bank.find(id, ignore_context: true, other_pin: true) else Origen.pin_bank.all_other_pins end end
ruby
def all_other_pins(id = nil, _options = {}, &_block) if id pin = Origen.pin_bank.find(id, ignore_context: true, other_pin: true) else Origen.pin_bank.all_other_pins end end
[ "def", "all_other_pins", "(", "id", "=", "nil", ",", "_options", "=", "{", "}", ",", "&", "_block", ")", "if", "id", "pin", "=", "Origen", ".", "pin_bank", ".", "find", "(", "id", ",", "ignore_context", ":", "true", ",", "other_pin", ":", "true", "...
Equivalent to the all_pins method but considers other pins rather than regular pins
[ "Equivalent", "to", "the", "all_pins", "method", "but", "considers", "other", "pins", "rather", "than", "regular", "pins" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/pins.rb#L570-L576
19,768
Origen-SDK/origen
lib/origen/pins.rb
Origen.Pins.power_pins
def power_pins(id = nil, options = {}, &block) id, options = nil, id if id.is_a?(Hash) options = { power_pin: true }.merge(options) pins(id, options, &block) end
ruby
def power_pins(id = nil, options = {}, &block) id, options = nil, id if id.is_a?(Hash) options = { power_pin: true }.merge(options) pins(id, options, &block) end
[ "def", "power_pins", "(", "id", "=", "nil", ",", "options", "=", "{", "}", ",", "&", "block", ")", "id", ",", "options", "=", "nil", ",", "id", "if", "id", ".", "is_a?", "(", "Hash", ")", "options", "=", "{", "power_pin", ":", "true", "}", ".",...
Equivalent to the pins method but considers power pins rather than regular pins
[ "Equivalent", "to", "the", "pins", "method", "but", "considers", "power", "pins", "rather", "than", "regular", "pins" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/pins.rb#L734-L740
19,769
Origen-SDK/origen
lib/origen/pins.rb
Origen.Pins.ground_pins
def ground_pins(id = nil, options = {}, &block) id, options = nil, id if id.is_a?(Hash) options = { ground_pin: true }.merge(options) pins(id, options, &block) end
ruby
def ground_pins(id = nil, options = {}, &block) id, options = nil, id if id.is_a?(Hash) options = { ground_pin: true }.merge(options) pins(id, options, &block) end
[ "def", "ground_pins", "(", "id", "=", "nil", ",", "options", "=", "{", "}", ",", "&", "block", ")", "id", ",", "options", "=", "nil", ",", "id", "if", "id", ".", "is_a?", "(", "Hash", ")", "options", "=", "{", "ground_pin", ":", "true", "}", "....
Equivalent to the pins method but considers ground pins rather than regular pins
[ "Equivalent", "to", "the", "pins", "method", "but", "considers", "ground", "pins", "rather", "than", "regular", "pins" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/pins.rb#L744-L750
19,770
Origen-SDK/origen
lib/origen/pins.rb
Origen.Pins.other_pins
def other_pins(id = nil, options = {}, &block) id, options = nil, id if id.is_a?(Hash) options = { other_pin: true }.merge(options) pins(id, options, &block) end
ruby
def other_pins(id = nil, options = {}, &block) id, options = nil, id if id.is_a?(Hash) options = { other_pin: true }.merge(options) pins(id, options, &block) end
[ "def", "other_pins", "(", "id", "=", "nil", ",", "options", "=", "{", "}", ",", "&", "block", ")", "id", ",", "options", "=", "nil", ",", "id", "if", "id", ".", "is_a?", "(", "Hash", ")", "options", "=", "{", "other_pin", ":", "true", "}", ".",...
Equivalent to the pins method but considers other pins rather than regular pins
[ "Equivalent", "to", "the", "pins", "method", "but", "considers", "other", "pins", "rather", "than", "regular", "pins" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/pins.rb#L754-L760
19,771
Origen-SDK/origen
lib/origen/pins.rb
Origen.Pins.virtual_pins
def virtual_pins(id = nil, options = {}, &block) id, options = nil, id if id.is_a?(Hash) options = { virtual_pin: true }.merge(options) pins(id, options, &block) end
ruby
def virtual_pins(id = nil, options = {}, &block) id, options = nil, id if id.is_a?(Hash) options = { virtual_pin: true }.merge(options) pins(id, options, &block) end
[ "def", "virtual_pins", "(", "id", "=", "nil", ",", "options", "=", "{", "}", ",", "&", "block", ")", "id", ",", "options", "=", "nil", ",", "id", "if", "id", ".", "is_a?", "(", "Hash", ")", "options", "=", "{", "virtual_pin", ":", "true", "}", ...
Equivalent to the pins method but considers virtual pins rather than regular pins
[ "Equivalent", "to", "the", "pins", "method", "but", "considers", "virtual", "pins", "rather", "than", "regular", "pins" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/pins.rb#L764-L770
19,772
Origen-SDK/origen
lib/origen/pins.rb
Origen.Pins.delete_pin
def delete_pin(id, options = {}) id = id.to_sym # Check if this is a Pin or a PinGroup if pin_groups.key? id Origen.pin_bank.delete_pingroup(Origen.pin_bank.find_pin_group(id, options)) elsif pins(id).class.to_s.match(/Pin/) Origen.pin_bank.delete_pin(Origen.pin_bank.find(id, opt...
ruby
def delete_pin(id, options = {}) id = id.to_sym # Check if this is a Pin or a PinGroup if pin_groups.key? id Origen.pin_bank.delete_pingroup(Origen.pin_bank.find_pin_group(id, options)) elsif pins(id).class.to_s.match(/Pin/) Origen.pin_bank.delete_pin(Origen.pin_bank.find(id, opt...
[ "def", "delete_pin", "(", "id", ",", "options", "=", "{", "}", ")", "id", "=", "id", ".", "to_sym", "# Check if this is a Pin or a PinGroup", "if", "pin_groups", ".", "key?", "id", "Origen", ".", "pin_bank", ".", "delete_pingroup", "(", "Origen", ".", "pin_b...
Delete any pin or pin group. If arg is a pin then delete the pin and any instances of it in any pin groups
[ "Delete", "any", "pin", "or", "pin", "group", ".", "If", "arg", "is", "a", "pin", "then", "delete", "the", "pin", "and", "any", "instances", "of", "it", "in", "any", "pin", "groups" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/pins.rb#L779-L789
19,773
Origen-SDK/origen
lib/origen/global_methods.rb
Origen.GlobalMethods.render
def render(*args, &block) if $_compiler_stack && $_compiler_stack.last $_compiler_stack.last.render(*args, &block) else Origen.generator.compiler.render(*args, &block) end end
ruby
def render(*args, &block) if $_compiler_stack && $_compiler_stack.last $_compiler_stack.last.render(*args, &block) else Origen.generator.compiler.render(*args, &block) end end
[ "def", "render", "(", "*", "args", ",", "&", "block", ")", "if", "$_compiler_stack", "&&", "$_compiler_stack", ".", "last", "$_compiler_stack", ".", "last", ".", "render", "(", "args", ",", "block", ")", "else", "Origen", ".", "generator", ".", "compiler",...
Render an ERB template
[ "Render", "an", "ERB", "template" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/global_methods.rb#L33-L39
19,774
Origen-SDK/origen
lib/origen/features.rb
Origen.Features.feature
def feature(name = nil) if !name self.class.features.keys else if self.class.features.key?(name) self.class.features[name] else fail "Feature #{name} does not exist!" end end end
ruby
def feature(name = nil) if !name self.class.features.keys else if self.class.features.key?(name) self.class.features[name] else fail "Feature #{name} does not exist!" end end end
[ "def", "feature", "(", "name", "=", "nil", ")", "if", "!", "name", "self", ".", "class", ".", "features", ".", "keys", "else", "if", "self", ".", "class", ".", "features", ".", "key?", "(", "name", ")", "self", ".", "class", ".", "features", "[", ...
Returns an array of the names of all associated features
[ "Returns", "an", "array", "of", "the", "names", "of", "all", "associated", "features" ]
f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac
https://github.com/Origen-SDK/origen/blob/f05e9dd190fcb90284084ba6e2bd4b0fe0c7f4ac/lib/origen/features.rb#L91-L101
19,775
JoshCheek/ttt
lib/ttt/computer_player.rb
TTT.ComputerPlayer.imperative_move
def imperative_move # if we can win *this turn*, then take it because # it rates winning next turn the same as winning in 3 turns game.available_moves.each do |move| new_game = game.pristine_mark move return move if new_game.over? && new_game.winner == player_number end ...
ruby
def imperative_move # if we can win *this turn*, then take it because # it rates winning next turn the same as winning in 3 turns game.available_moves.each do |move| new_game = game.pristine_mark move return move if new_game.over? && new_game.winner == player_number end ...
[ "def", "imperative_move", "# if we can win *this turn*, then take it because", "# it rates winning next turn the same as winning in 3 turns", "game", ".", "available_moves", ".", "each", "do", "|", "move", "|", "new_game", "=", "game", ".", "pristine_mark", "move", "return", ...
allows us to override ratings in cases where they make the robot look stupid
[ "allows", "us", "to", "override", "ratings", "in", "cases", "where", "they", "make", "the", "robot", "look", "stupid" ]
1b10b6ac18ccf066d992abdc12ec6e43acf55f08
https://github.com/JoshCheek/ttt/blob/1b10b6ac18ccf066d992abdc12ec6e43acf55f08/lib/ttt/computer_player.rb#L42-L60
19,776
lightstep/lightstep-tracer-ruby
lib/lightstep/tracer.rb
LightStep.Tracer.start_span
def start_span(operation_name, child_of: nil, references: nil, start_time: nil, tags: nil, ignore_active_scope: false) if child_of.nil? && references.nil? && !ignore_active_scope child_of = active_span end Span.new( tracer: self, operation_name: operation_name, child_o...
ruby
def start_span(operation_name, child_of: nil, references: nil, start_time: nil, tags: nil, ignore_active_scope: false) if child_of.nil? && references.nil? && !ignore_active_scope child_of = active_span end Span.new( tracer: self, operation_name: operation_name, child_o...
[ "def", "start_span", "(", "operation_name", ",", "child_of", ":", "nil", ",", "references", ":", "nil", ",", "start_time", ":", "nil", ",", "tags", ":", "nil", ",", "ignore_active_scope", ":", "false", ")", "if", "child_of", ".", "nil?", "&&", "references"...
Starts a new span. @param operation_name [String] The operation name for the Span @param child_of [SpanContext] SpanContext that acts as a parent to the newly-started Span. If a Span instance is provided, its .span_context is automatically substituted. @param references [Array<SpanContext>] An array...
[ "Starts", "a", "new", "span", "." ]
72f5669a4afabe81a3fb396cda61c47b7d01ec33
https://github.com/lightstep/lightstep-tracer-ruby/blob/72f5669a4afabe81a3fb396cda61c47b7d01ec33/lib/lightstep/tracer.rb#L142-L156
19,777
lightstep/lightstep-tracer-ruby
lib/lightstep/tracer.rb
LightStep.Tracer.extract
def extract(format, carrier) case format when OpenTracing::FORMAT_TEXT_MAP extract_from_text_map(carrier) when OpenTracing::FORMAT_BINARY warn 'Binary join format not yet implemented' nil when OpenTracing::FORMAT_RACK extract_from_rack(carrier) else ...
ruby
def extract(format, carrier) case format when OpenTracing::FORMAT_TEXT_MAP extract_from_text_map(carrier) when OpenTracing::FORMAT_BINARY warn 'Binary join format not yet implemented' nil when OpenTracing::FORMAT_RACK extract_from_rack(carrier) else ...
[ "def", "extract", "(", "format", ",", "carrier", ")", "case", "format", "when", "OpenTracing", "::", "FORMAT_TEXT_MAP", "extract_from_text_map", "(", "carrier", ")", "when", "OpenTracing", "::", "FORMAT_BINARY", "warn", "'Binary join format not yet implemented'", "nil",...
Extract a SpanContext from a carrier @param format [OpenTracing::FORMAT_TEXT_MAP, OpenTracing::FORMAT_BINARY, OpenTracing::FORMAT_RACK] @param carrier [Carrier] A carrier object of the type dictated by the specified `format` @return [SpanContext] the extracted SpanContext or nil if none could be found
[ "Extract", "a", "SpanContext", "from", "a", "carrier" ]
72f5669a4afabe81a3fb396cda61c47b7d01ec33
https://github.com/lightstep/lightstep-tracer-ruby/blob/72f5669a4afabe81a3fb396cda61c47b7d01ec33/lib/lightstep/tracer.rb#L180-L193
19,778
lightstep/lightstep-tracer-ruby
lib/lightstep/span.rb
LightStep.Span.set_baggage
def set_baggage(baggage = {}) @context = SpanContext.new( id: context.id, trace_id: context.trace_id, baggage: baggage ) end
ruby
def set_baggage(baggage = {}) @context = SpanContext.new( id: context.id, trace_id: context.trace_id, baggage: baggage ) end
[ "def", "set_baggage", "(", "baggage", "=", "{", "}", ")", "@context", "=", "SpanContext", ".", "new", "(", "id", ":", "context", ".", "id", ",", "trace_id", ":", "context", ".", "trace_id", ",", "baggage", ":", "baggage", ")", "end" ]
Set all baggage at once. This will reset the baggage to the given param. @param baggage [Hash] new baggage for the span
[ "Set", "all", "baggage", "at", "once", ".", "This", "will", "reset", "the", "baggage", "to", "the", "given", "param", "." ]
72f5669a4afabe81a3fb396cda61c47b7d01ec33
https://github.com/lightstep/lightstep-tracer-ruby/blob/72f5669a4afabe81a3fb396cda61c47b7d01ec33/lib/lightstep/span.rb#L93-L99
19,779
lightstep/lightstep-tracer-ruby
lib/lightstep/span.rb
LightStep.Span.to_h
def to_h { runtime_guid: tracer.guid, span_guid: context.id, trace_guid: context.trace_id, span_name: operation_name, attributes: tags.map {|key, value| {Key: key.to_s, Value: value} }, oldest_micros: start_micros, youngest_micros: end_micr...
ruby
def to_h { runtime_guid: tracer.guid, span_guid: context.id, trace_guid: context.trace_id, span_name: operation_name, attributes: tags.map {|key, value| {Key: key.to_s, Value: value} }, oldest_micros: start_micros, youngest_micros: end_micr...
[ "def", "to_h", "{", "runtime_guid", ":", "tracer", ".", "guid", ",", "span_guid", ":", "context", ".", "id", ",", "trace_guid", ":", "context", ".", "trace_id", ",", "span_name", ":", "operation_name", ",", "attributes", ":", "tags", ".", "map", "{", "|"...
Hash representation of a span
[ "Hash", "representation", "of", "a", "span" ]
72f5669a4afabe81a3fb396cda61c47b7d01ec33
https://github.com/lightstep/lightstep-tracer-ruby/blob/72f5669a4afabe81a3fb396cda61c47b7d01ec33/lib/lightstep/span.rb#L154-L169
19,780
lightstep/lightstep-tracer-ruby
lib/lightstep/scope_manager.rb
LightStep.ScopeManager.activate
def activate(span:, finish_on_close: true) return active if active && active.span == span LightStep::Scope.new(manager: self, span: span, finish_on_close: finish_on_close).tap do |scope| add_scope(scope) end end
ruby
def activate(span:, finish_on_close: true) return active if active && active.span == span LightStep::Scope.new(manager: self, span: span, finish_on_close: finish_on_close).tap do |scope| add_scope(scope) end end
[ "def", "activate", "(", "span", ":", ",", "finish_on_close", ":", "true", ")", "return", "active", "if", "active", "&&", "active", ".", "span", "==", "span", "LightStep", "::", "Scope", ".", "new", "(", "manager", ":", "self", ",", "span", ":", "span",...
Make a span instance active. @param span [Span] the Span that should become active @param finish_on_close [Boolean] whether the Span should automatically be finished when Scope#close is called @return [Scope] instance to control the end of the active period for the Span. It is a programming error to neglect to...
[ "Make", "a", "span", "instance", "active", "." ]
72f5669a4afabe81a3fb396cda61c47b7d01ec33
https://github.com/lightstep/lightstep-tracer-ruby/blob/72f5669a4afabe81a3fb396cda61c47b7d01ec33/lib/lightstep/scope_manager.rb#L19-L24
19,781
NCSU-Libraries/lentil
lib/lentil/instagram_harvester.rb
Lentil.InstagramHarvester.configure_connection
def configure_connection(opts = {}) opts['client_id'] ||= Lentil::Engine::APP_CONFIG["instagram_client_id"] opts['client_secret'] ||= Lentil::Engine::APP_CONFIG["instagram_client_secret"] opts['access_token'] ||= Lentil::Engine::APP_CONFIG["instagram_access_token"] || nil Instagram.configure do...
ruby
def configure_connection(opts = {}) opts['client_id'] ||= Lentil::Engine::APP_CONFIG["instagram_client_id"] opts['client_secret'] ||= Lentil::Engine::APP_CONFIG["instagram_client_secret"] opts['access_token'] ||= Lentil::Engine::APP_CONFIG["instagram_access_token"] || nil Instagram.configure do...
[ "def", "configure_connection", "(", "opts", "=", "{", "}", ")", "opts", "[", "'client_id'", "]", "||=", "Lentil", "::", "Engine", "::", "APP_CONFIG", "[", "\"instagram_client_id\"", "]", "opts", "[", "'client_secret'", "]", "||=", "Lentil", "::", "Engine", "...
Configure the Instagram class in preparation requests. @options opts [String] :client_id (Lentil::Engine::APP_CONFIG["instagram_client_id"]) The Instagram client ID @options opts [String] :client_secret (Lentil::Engine::APP_CONFIG["instagram_client_secret"]) The Instagram client secret @options opts [String] :acces...
[ "Configure", "the", "Instagram", "class", "in", "preparation", "requests", "." ]
c31775447a52db1781c05f6724ae293698527fe6
https://github.com/NCSU-Libraries/lentil/blob/c31775447a52db1781c05f6724ae293698527fe6/lib/lentil/instagram_harvester.rb#L20-L33
19,782
NCSU-Libraries/lentil
lib/lentil/instagram_harvester.rb
Lentil.InstagramHarvester.configure_comment_connection
def configure_comment_connection(access_token = nil) access_token ||= Lentil::Engine::APP_CONFIG["instagram_access_token"] || nil raise "instagram_access_token must be defined as a parameter or in the application config" unless access_token configure_connection({'access_token' => access_token}) en...
ruby
def configure_comment_connection(access_token = nil) access_token ||= Lentil::Engine::APP_CONFIG["instagram_access_token"] || nil raise "instagram_access_token must be defined as a parameter or in the application config" unless access_token configure_connection({'access_token' => access_token}) en...
[ "def", "configure_comment_connection", "(", "access_token", "=", "nil", ")", "access_token", "||=", "Lentil", "::", "Engine", "::", "APP_CONFIG", "[", "\"instagram_access_token\"", "]", "||", "nil", "raise", "\"instagram_access_token must be defined as a parameter or in the a...
Configure the Instagram class in preparation for leaving comments @param access_token = nil [String] Instagram access token for the writing account
[ "Configure", "the", "Instagram", "class", "in", "preparation", "for", "leaving", "comments" ]
c31775447a52db1781c05f6724ae293698527fe6
https://github.com/NCSU-Libraries/lentil/blob/c31775447a52db1781c05f6724ae293698527fe6/lib/lentil/instagram_harvester.rb#L40-L44
19,783
NCSU-Libraries/lentil
lib/lentil/instagram_harvester.rb
Lentil.InstagramHarvester.fetch_recent_images_by_tag
def fetch_recent_images_by_tag(tag = nil) configure_connection tag ||= Lentil::Engine::APP_CONFIG["default_image_search_tag"] Instagram.tag_recent_media(tag, :count=>10) end
ruby
def fetch_recent_images_by_tag(tag = nil) configure_connection tag ||= Lentil::Engine::APP_CONFIG["default_image_search_tag"] Instagram.tag_recent_media(tag, :count=>10) end
[ "def", "fetch_recent_images_by_tag", "(", "tag", "=", "nil", ")", "configure_connection", "tag", "||=", "Lentil", "::", "Engine", "::", "APP_CONFIG", "[", "\"default_image_search_tag\"", "]", "Instagram", ".", "tag_recent_media", "(", "tag", ",", ":count", "=>", "...
Queries the Instagram API for recent images with a given tag. @param [String] tag The tag to query by @return [Hashie::Mash] The data returned by Instagram API
[ "Queries", "the", "Instagram", "API", "for", "recent", "images", "with", "a", "given", "tag", "." ]
c31775447a52db1781c05f6724ae293698527fe6
https://github.com/NCSU-Libraries/lentil/blob/c31775447a52db1781c05f6724ae293698527fe6/lib/lentil/instagram_harvester.rb#L51-L55
19,784
NCSU-Libraries/lentil
lib/lentil/instagram_harvester.rb
Lentil.InstagramHarvester.extract_image_data
def extract_image_data(instagram_metadata) { url: instagram_metadata.link, external_id: instagram_metadata.id, large_url: instagram_metadata.images.standard_resolution.url, name: instagram_metadata.caption && instagram_metadata.caption.text, tags: instagram_metadata.tags, ...
ruby
def extract_image_data(instagram_metadata) { url: instagram_metadata.link, external_id: instagram_metadata.id, large_url: instagram_metadata.images.standard_resolution.url, name: instagram_metadata.caption && instagram_metadata.caption.text, tags: instagram_metadata.tags, ...
[ "def", "extract_image_data", "(", "instagram_metadata", ")", "{", "url", ":", "instagram_metadata", ".", "link", ",", "external_id", ":", "instagram_metadata", ".", "id", ",", "large_url", ":", "instagram_metadata", ".", "images", ".", "standard_resolution", ".", ...
Produce processed image metadata from Instagram metadata. This metadata is accepted by the save_image method. @param [Hashie::Mash] instagram_metadata The single image metadata returned by Instagram API @return [Hash] processed image metadata
[ "Produce", "processed", "image", "metadata", "from", "Instagram", "metadata", ".", "This", "metadata", "is", "accepted", "by", "the", "save_image", "method", "." ]
c31775447a52db1781c05f6724ae293698527fe6
https://github.com/NCSU-Libraries/lentil/blob/c31775447a52db1781c05f6724ae293698527fe6/lib/lentil/instagram_harvester.rb#L94-L107
19,785
NCSU-Libraries/lentil
lib/lentil/instagram_harvester.rb
Lentil.InstagramHarvester.save_image
def save_image(image_data) instagram_service = Lentil::Service.where(:name => "Instagram").first user_record = instagram_service.users.where(:user_name => image_data[:user][:username]). first_or_create!({:full_name => image_data[:user][:full_name], :bio => image_data[:user][:bio]}) raise Du...
ruby
def save_image(image_data) instagram_service = Lentil::Service.where(:name => "Instagram").first user_record = instagram_service.users.where(:user_name => image_data[:user][:username]). first_or_create!({:full_name => image_data[:user][:full_name], :bio => image_data[:user][:bio]}) raise Du...
[ "def", "save_image", "(", "image_data", ")", "instagram_service", "=", "Lentil", "::", "Service", ".", "where", "(", ":name", "=>", "\"Instagram\"", ")", ".", "first", "user_record", "=", "instagram_service", ".", "users", ".", "where", "(", ":user_name", "=>"...
Takes return from Instagram API gem and adds image, users, and tags to the database. @raise [DuplicateImageError] This method does not accept duplicate external image IDs @param [Hash] image_data processed Instagram image metadata @return [Image] new Image object
[ "Takes", "return", "from", "Instagram", "API", "gem", "and", "adds", "image", "users", "and", "tags", "to", "the", "database", "." ]
c31775447a52db1781c05f6724ae293698527fe6
https://github.com/NCSU-Libraries/lentil/blob/c31775447a52db1781c05f6724ae293698527fe6/lib/lentil/instagram_harvester.rb#L118-L151
19,786
NCSU-Libraries/lentil
lib/lentil/instagram_harvester.rb
Lentil.InstagramHarvester.save_instagram_load
def save_instagram_load(instagram_load, raise_dupes=false) # Handle collections of images and individual images images = instagram_load if !images.kind_of?(Array) images = [images] end images.collect {|image| begin save_image(extract_image_data(image)) r...
ruby
def save_instagram_load(instagram_load, raise_dupes=false) # Handle collections of images and individual images images = instagram_load if !images.kind_of?(Array) images = [images] end images.collect {|image| begin save_image(extract_image_data(image)) r...
[ "def", "save_instagram_load", "(", "instagram_load", ",", "raise_dupes", "=", "false", ")", "# Handle collections of images and individual images", "images", "=", "instagram_load", "if", "!", "images", ".", "kind_of?", "(", "Array", ")", "images", "=", "[", "images", ...
Takes return from Instagram API gem and adds all new images, users, and tags to the database. @param [Hashie::Mash] instagram_load The content returned by the Instagram gem @param [Boolean] raise_dupes Whether to raise exceptions for duplicate images @raise [DuplicateImageError] If there are duplicate images and ...
[ "Takes", "return", "from", "Instagram", "API", "gem", "and", "adds", "all", "new", "images", "users", "and", "tags", "to", "the", "database", "." ]
c31775447a52db1781c05f6724ae293698527fe6
https://github.com/NCSU-Libraries/lentil/blob/c31775447a52db1781c05f6724ae293698527fe6/lib/lentil/instagram_harvester.rb#L162-L183
19,787
NCSU-Libraries/lentil
lib/lentil/instagram_harvester.rb
Lentil.InstagramHarvester.harvest_image_data
def harvest_image_data(image) response = Typhoeus.get(image.large_url(false), followlocation: true) if response.success? raise "Invalid content type: " + response.headers['Content-Type'] unless (response.headers['Content-Type'] == 'image/jpeg') elsif response.timed_out? raise "Request...
ruby
def harvest_image_data(image) response = Typhoeus.get(image.large_url(false), followlocation: true) if response.success? raise "Invalid content type: " + response.headers['Content-Type'] unless (response.headers['Content-Type'] == 'image/jpeg') elsif response.timed_out? raise "Request...
[ "def", "harvest_image_data", "(", "image", ")", "response", "=", "Typhoeus", ".", "get", "(", "image", ".", "large_url", "(", "false", ")", ",", "followlocation", ":", "true", ")", "if", "response", ".", "success?", "raise", "\"Invalid content type: \"", "+", ...
Retrieve the binary image data for a given Image object @param [Image] image An Image model object from the Instagram service @raise [Exception] If there are request problems @return [String] Binary image data
[ "Retrieve", "the", "binary", "image", "data", "for", "a", "given", "Image", "object" ]
c31775447a52db1781c05f6724ae293698527fe6
https://github.com/NCSU-Libraries/lentil/blob/c31775447a52db1781c05f6724ae293698527fe6/lib/lentil/instagram_harvester.rb#L206-L220
19,788
NCSU-Libraries/lentil
lib/lentil/instagram_harvester.rb
Lentil.InstagramHarvester.harvest_video_data
def harvest_video_data(image) response = Typhoeus.get(image.video_url, followlocation: true) if response.success? raise "Invalid content type: " + response.headers['Content-Type'] unless (response.headers['Content-Type'] == 'video/mp4') elsif response.timed_out? raise "Request timed o...
ruby
def harvest_video_data(image) response = Typhoeus.get(image.video_url, followlocation: true) if response.success? raise "Invalid content type: " + response.headers['Content-Type'] unless (response.headers['Content-Type'] == 'video/mp4') elsif response.timed_out? raise "Request timed o...
[ "def", "harvest_video_data", "(", "image", ")", "response", "=", "Typhoeus", ".", "get", "(", "image", ".", "video_url", ",", "followlocation", ":", "true", ")", "if", "response", ".", "success?", "raise", "\"Invalid content type: \"", "+", "response", ".", "h...
Retrieve the binary video data for a given Image object @param [Image] image An Image model object from the Instagram service @raise [Exception] If there are request problems @return [String] Binary video data
[ "Retrieve", "the", "binary", "video", "data", "for", "a", "given", "Image", "object" ]
c31775447a52db1781c05f6724ae293698527fe6
https://github.com/NCSU-Libraries/lentil/blob/c31775447a52db1781c05f6724ae293698527fe6/lib/lentil/instagram_harvester.rb#L230-L244
19,789
NCSU-Libraries/lentil
lib/lentil/instagram_harvester.rb
Lentil.InstagramHarvester.leave_image_comment
def leave_image_comment(image, comment) configure_comment_connection Instagram.client.create_media_comment(image.external_identifier, comment) end
ruby
def leave_image_comment(image, comment) configure_comment_connection Instagram.client.create_media_comment(image.external_identifier, comment) end
[ "def", "leave_image_comment", "(", "image", ",", "comment", ")", "configure_comment_connection", "Instagram", ".", "client", ".", "create_media_comment", "(", "image", ".", "external_identifier", ",", "comment", ")", "end" ]
Leave a comment containing the donor agreement on an Instagram image @param image [type] An Image model object from the Instagram service @raise [Exception] If a comment submission fails @authenticated true @return [Hashie::Mash] Instagram response
[ "Leave", "a", "comment", "containing", "the", "donor", "agreement", "on", "an", "Instagram", "image" ]
c31775447a52db1781c05f6724ae293698527fe6
https://github.com/NCSU-Libraries/lentil/blob/c31775447a52db1781c05f6724ae293698527fe6/lib/lentil/instagram_harvester.rb#L275-L278
19,790
NCSU-Libraries/lentil
lib/lentil/popularity_calculator.rb
Lentil.PopularityCalculator.calculate_popularity
def calculate_popularity(image) # A staff like is worth 10 points if (image.staff_like === false) staff_like_points = 0 else staff_like_points = 10 end # likes have diminishing returns # 10 likes is 13 points # 100 likes is 25 points if image.like_votes_...
ruby
def calculate_popularity(image) # A staff like is worth 10 points if (image.staff_like === false) staff_like_points = 0 else staff_like_points = 10 end # likes have diminishing returns # 10 likes is 13 points # 100 likes is 25 points if image.like_votes_...
[ "def", "calculate_popularity", "(", "image", ")", "# A staff like is worth 10 points", "if", "(", "image", ".", "staff_like", "===", "false", ")", "staff_like_points", "=", "0", "else", "staff_like_points", "=", "10", "end", "# likes have diminishing returns", "# 10 lik...
Takes image object and returns a popularity score @param [object] image object with image data @return [integer] popularity score of image
[ "Takes", "image", "object", "and", "returns", "a", "popularity", "score" ]
c31775447a52db1781c05f6724ae293698527fe6
https://github.com/NCSU-Libraries/lentil/blob/c31775447a52db1781c05f6724ae293698527fe6/lib/lentil/popularity_calculator.rb#L9-L37
19,791
NCSU-Libraries/lentil
lib/lentil/popularity_calculator.rb
Lentil.PopularityCalculator.update_image_popularity_score
def update_image_popularity_score(image_to_update = :all) def get_score_write_to_db(image) popularity_score = calculate_popularity(image) image.update_attribute(:popular_score, popularity_score) end if image_to_update == :all images = Lentil::Image.find(image_to_update) ...
ruby
def update_image_popularity_score(image_to_update = :all) def get_score_write_to_db(image) popularity_score = calculate_popularity(image) image.update_attribute(:popular_score, popularity_score) end if image_to_update == :all images = Lentil::Image.find(image_to_update) ...
[ "def", "update_image_popularity_score", "(", "image_to_update", "=", ":all", ")", "def", "get_score_write_to_db", "(", "image", ")", "popularity_score", "=", "calculate_popularity", "(", "image", ")", "image", ".", "update_attribute", "(", ":popular_score", ",", "popu...
Takes an image id and updates its popularity score @param [integer] id of image to update defaults to :all @return [boolean] success/failure of update
[ "Takes", "an", "image", "id", "and", "updates", "its", "popularity", "score" ]
c31775447a52db1781c05f6724ae293698527fe6
https://github.com/NCSU-Libraries/lentil/blob/c31775447a52db1781c05f6724ae293698527fe6/lib/lentil/popularity_calculator.rb#L44-L60
19,792
gaffneyc/usps
lib/usps/request/city_and_state_lookup.rb
USPS::Request.CityAndStateLookup.build
def build super do |builder| @zip_codes.each_with_index do |zip, i| builder.tag!('ZipCode', :ID => i) do builder.tag!('Zip5', zip) end end end end
ruby
def build super do |builder| @zip_codes.each_with_index do |zip, i| builder.tag!('ZipCode', :ID => i) do builder.tag!('Zip5', zip) end end end end
[ "def", "build", "super", "do", "|", "builder", "|", "@zip_codes", ".", "each_with_index", "do", "|", "zip", ",", "i", "|", "builder", ".", "tag!", "(", "'ZipCode'", ",", ":ID", "=>", "i", ")", "do", "builder", ".", "tag!", "(", "'Zip5'", ",", "zip", ...
Given a list of zip codes, looks up what city and state they are associated with. The USPS api is only capable of handling at most 5 zip codes per request.
[ "Given", "a", "list", "of", "zip", "codes", "looks", "up", "what", "city", "and", "state", "they", "are", "associated", "with", "." ]
77020c04a5207e0e0cbc7deab2024a1ec39ee738
https://github.com/gaffneyc/usps/blob/77020c04a5207e0e0cbc7deab2024a1ec39ee738/lib/usps/request/city_and_state_lookup.rb#L22-L30
19,793
plexus/yaks
yaks/lib/yaks/configurable.rb
Yaks.Configurable.def_set
def def_set(*method_names) method_names.each do |method_name| define_singleton_method method_name do |arg = Undefined, &block| if arg.equal?(Undefined) unless block raise ArgumentError, "setting #{method_name}: no value and no block given" end se...
ruby
def def_set(*method_names) method_names.each do |method_name| define_singleton_method method_name do |arg = Undefined, &block| if arg.equal?(Undefined) unless block raise ArgumentError, "setting #{method_name}: no value and no block given" end se...
[ "def", "def_set", "(", "*", "method_names", ")", "method_names", ".", "each", "do", "|", "method_name", "|", "define_singleton_method", "method_name", "do", "|", "arg", "=", "Undefined", ",", "&", "block", "|", "if", "arg", ".", "equal?", "(", "Undefined", ...
Create a DSL method to set a certain config property. The generated method will take either a plain value, or a block, which will be captured and stored instead.
[ "Create", "a", "DSL", "method", "to", "set", "a", "certain", "config", "property", ".", "The", "generated", "method", "will", "take", "either", "a", "plain", "value", "or", "a", "block", "which", "will", "be", "captured", "and", "stored", "instead", "." ]
75c41e5d9c56cbb12ec95385d725676175f04f06
https://github.com/plexus/yaks/blob/75c41e5d9c56cbb12ec95385d725676175f04f06/yaks/lib/yaks/configurable.rb#L34-L50
19,794
plexus/yaks
yaks/lib/yaks/configurable.rb
Yaks.Configurable.def_forward
def def_forward(mappings, *names) if mappings.instance_of? Hash mappings.each do |method_name, target| define_singleton_method method_name do |*args, &block| self.config = config.public_send(target, *args, &block) end end else def_forward([mappings, *n...
ruby
def def_forward(mappings, *names) if mappings.instance_of? Hash mappings.each do |method_name, target| define_singleton_method method_name do |*args, &block| self.config = config.public_send(target, *args, &block) end end else def_forward([mappings, *n...
[ "def", "def_forward", "(", "mappings", ",", "*", "names", ")", "if", "mappings", ".", "instance_of?", "Hash", "mappings", ".", "each", "do", "|", "method_name", ",", "target", "|", "define_singleton_method", "method_name", "do", "|", "*", "args", ",", "&", ...
Forward a method to the config object. This assumes the method will return an updated config instance. Either takes a list of methods to forward, or a mapping (hash) of source to destination method name.
[ "Forward", "a", "method", "to", "the", "config", "object", ".", "This", "assumes", "the", "method", "will", "return", "an", "updated", "config", "instance", "." ]
75c41e5d9c56cbb12ec95385d725676175f04f06
https://github.com/plexus/yaks/blob/75c41e5d9c56cbb12ec95385d725676175f04f06/yaks/lib/yaks/configurable.rb#L57-L67
19,795
plexus/yaks
yaks/lib/yaks/configurable.rb
Yaks.Configurable.def_add
def def_add(name, options) old_verbose, $VERBOSE = $VERBOSE, false # skip method redefinition warning define_singleton_method name do |*args, &block| defaults = options.fetch(:defaults, {}) klass = options.fetch(:create) if args.last.instance_of?(Hash) args[-1] = defaul...
ruby
def def_add(name, options) old_verbose, $VERBOSE = $VERBOSE, false # skip method redefinition warning define_singleton_method name do |*args, &block| defaults = options.fetch(:defaults, {}) klass = options.fetch(:create) if args.last.instance_of?(Hash) args[-1] = defaul...
[ "def", "def_add", "(", "name", ",", "options", ")", "old_verbose", ",", "$VERBOSE", "=", "$VERBOSE", ",", "false", "# skip method redefinition warning", "define_singleton_method", "name", "do", "|", "*", "args", ",", "&", "block", "|", "defaults", "=", "options"...
Generate a DSL method that creates a certain type of domain object, and adds it to a list on the config. def_add :fieldset, create: Fieldset, append_to: :fields This will generate a `fieldset` method, which will call `Fieldset.create`, and append the result to `config.fields`
[ "Generate", "a", "DSL", "method", "that", "creates", "a", "certain", "type", "of", "domain", "object", "and", "adds", "it", "to", "a", "list", "on", "the", "config", "." ]
75c41e5d9c56cbb12ec95385d725676175f04f06
https://github.com/plexus/yaks/blob/75c41e5d9c56cbb12ec95385d725676175f04f06/yaks/lib/yaks/configurable.rb#L76-L95
19,796
plexus/yaks
yaks/lib/yaks/default_policy.rb
Yaks.DefaultPolicy.derive_mapper_from_collection
def derive_mapper_from_collection(collection) if m = collection.first name = "#{m.class.name.split('::').last}CollectionMapper" begin return @options[:namespace].const_get(name) rescue NameError # rubocop:disable Lint/HandleExceptions end end beg...
ruby
def derive_mapper_from_collection(collection) if m = collection.first name = "#{m.class.name.split('::').last}CollectionMapper" begin return @options[:namespace].const_get(name) rescue NameError # rubocop:disable Lint/HandleExceptions end end beg...
[ "def", "derive_mapper_from_collection", "(", "collection", ")", "if", "m", "=", "collection", ".", "first", "name", "=", "\"#{m.class.name.split('::').last}CollectionMapper\"", "begin", "return", "@options", "[", ":namespace", "]", ".", "const_get", "(", "name", ")", ...
Derives a mapper from the given collection. @param collection [Object] @return [Class] A mapper, typically a subclass of Yaks::Mapper
[ "Derives", "a", "mapper", "from", "the", "given", "collection", "." ]
75c41e5d9c56cbb12ec95385d725676175f04f06
https://github.com/plexus/yaks/blob/75c41e5d9c56cbb12ec95385d725676175f04f06/yaks/lib/yaks/default_policy.rb#L41-L54
19,797
plexus/yaks
yaks/lib/yaks/default_policy.rb
Yaks.DefaultPolicy.derive_mapper_from_item
def derive_mapper_from_item(item) klass = item.class namespaces = klass.name.split("::")[0...-1] begin return build_mapper_class(namespaces, klass) rescue NameError klass = next_class_for_lookup(item, namespaces, klass) retry if klass end raise_mapper_not_foun...
ruby
def derive_mapper_from_item(item) klass = item.class namespaces = klass.name.split("::")[0...-1] begin return build_mapper_class(namespaces, klass) rescue NameError klass = next_class_for_lookup(item, namespaces, klass) retry if klass end raise_mapper_not_foun...
[ "def", "derive_mapper_from_item", "(", "item", ")", "klass", "=", "item", ".", "class", "namespaces", "=", "klass", ".", "name", ".", "split", "(", "\"::\"", ")", "[", "0", "...", "-", "1", "]", "begin", "return", "build_mapper_class", "(", "namespaces", ...
Derives a mapper from the given item. This item should not be a collection. @param item [Object] @return [Class] A mapper, typically a subclass of Yaks::Mapper @raise [RuntimeError] only occurs when no mapper is found for the given item.
[ "Derives", "a", "mapper", "from", "the", "given", "item", ".", "This", "item", "should", "not", "be", "a", "collection", "." ]
75c41e5d9c56cbb12ec95385d725676175f04f06
https://github.com/plexus/yaks/blob/75c41e5d9c56cbb12ec95385d725676175f04f06/yaks/lib/yaks/default_policy.rb#L63-L73
19,798
benedikt/mongoid-tree
lib/mongoid/tree.rb
Mongoid.Tree.root
def root if parent_ids.present? base_class.find(parent_ids.first) else self.root? ? self : self.parent.root end end
ruby
def root if parent_ids.present? base_class.find(parent_ids.first) else self.root? ? self : self.parent.root end end
[ "def", "root", "if", "parent_ids", ".", "present?", "base_class", ".", "find", "(", "parent_ids", ".", "first", ")", "else", "self", ".", "root?", "?", "self", ":", "self", ".", "parent", ".", "root", "end", "end" ]
Returns this document's root node. Returns `self` if the current document is a root node @example node = Node.find(...) node.root @return [Mongoid::Document] The documents root node
[ "Returns", "this", "document", "s", "root", "node", ".", "Returns", "self", "if", "the", "current", "document", "is", "a", "root", "node" ]
0970a945a16a1539511f6dd2017e78f1ba54d4bd
https://github.com/benedikt/mongoid-tree/blob/0970a945a16a1539511f6dd2017e78f1ba54d4bd/lib/mongoid/tree.rb#L277-L283
19,799
benedikt/mongoid-tree
lib/mongoid/tree.rb
Mongoid.Tree.nullify_children
def nullify_children children.each do |c| c.parent = c.parent_id = nil c.save end end
ruby
def nullify_children children.each do |c| c.parent = c.parent_id = nil c.save end end
[ "def", "nullify_children", "children", ".", "each", "do", "|", "c", "|", "c", ".", "parent", "=", "c", ".", "parent_id", "=", "nil", "c", ".", "save", "end", "end" ]
Nullifies all children's parent_id @return [undefined]
[ "Nullifies", "all", "children", "s", "parent_id" ]
0970a945a16a1539511f6dd2017e78f1ba54d4bd
https://github.com/benedikt/mongoid-tree/blob/0970a945a16a1539511f6dd2017e78f1ba54d4bd/lib/mongoid/tree.rb#L391-L396