repo
stringlengths
5
58
path
stringlengths
9
168
func_name
stringlengths
9
130
original_string
stringlengths
66
10.5k
language
stringclasses
1 value
code
stringlengths
66
10.5k
code_tokens
list
docstring
stringlengths
8
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
94
266
partition
stringclasses
1 value
kschiess/zack
lib/zack/server.rb
Zack.Server.exception_handling
def exception_handling(exception_handler, control) begin yield rescue => exception # If we have an exception handler, it gets handed all the exceptions. # No exceptions stop the operation. if exception_handler exception_handler.call(exception, control) ...
ruby
def exception_handling(exception_handler, control) begin yield rescue => exception # If we have an exception handler, it gets handed all the exceptions. # No exceptions stop the operation. if exception_handler exception_handler.call(exception, control) ...
[ "def", "exception_handling", "(", "exception_handler", ",", "control", ")", "begin", "yield", "rescue", "=>", "exception", "if", "exception_handler", "exception_handler", ".", "call", "(", "exception", ",", "control", ")", "else", "raise", "end", "end", "end" ]
Defines how the server handles exception.
[ "Defines", "how", "the", "server", "handles", "exception", "." ]
a9ac7cc672f1760961fae45bfe8f4be68b2ca7d9
https://github.com/kschiess/zack/blob/a9ac7cc672f1760961fae45bfe8f4be68b2ca7d9/lib/zack/server.rb#L110-L123
train
dpla/KriKri
lib/krikri/ldp/rdf_source.rb
Krikri::LDP.RdfSource.save_with_provenance
def save_with_provenance(activity_uri) predicate = exists? ? REVISED_URI : GENERATED_URI self << RDF::Statement(self, predicate, activity_uri) save end
ruby
def save_with_provenance(activity_uri) predicate = exists? ? REVISED_URI : GENERATED_URI self << RDF::Statement(self, predicate, activity_uri) save end
[ "def", "save_with_provenance", "(", "activity_uri", ")", "predicate", "=", "exists?", "?", "REVISED_URI", ":", "GENERATED_URI", "self", "<<", "RDF", "::", "Statement", "(", "self", ",", "predicate", ",", "activity_uri", ")", "save", "end" ]
Adds an appropritate provenance statement with the given URI and saves the resource. This method treats RDFSources as stateful resources. This is in conflict with the PROV model, which assumes each revision is its own Resource. The internal predicate `dpla:wasRevisedBy` is used for non-generating revisions of sta...
[ "Adds", "an", "appropritate", "provenance", "statement", "with", "the", "given", "URI", "and", "saves", "the", "resource", "." ]
0ac26e60ce1bba60caa40263a562796267cf833f
https://github.com/dpla/KriKri/blob/0ac26e60ce1bba60caa40263a562796267cf833f/lib/krikri/ldp/rdf_source.rb#L85-L89
train
dpla/KriKri
lib/krikri/entity_consumer.rb
Krikri.EntityConsumer.assign_generator_activity!
def assign_generator_activity!(opts) if opts.include?(:generator_uri) generator_uri = opts.delete(:generator_uri) @entity_source = @generator_activity = Krikri::Activity.from_uri(generator_uri) end end
ruby
def assign_generator_activity!(opts) if opts.include?(:generator_uri) generator_uri = opts.delete(:generator_uri) @entity_source = @generator_activity = Krikri::Activity.from_uri(generator_uri) end end
[ "def", "assign_generator_activity!", "(", "opts", ")", "if", "opts", ".", "include?", "(", ":generator_uri", ")", "generator_uri", "=", "opts", ".", "delete", "(", ":generator_uri", ")", "@entity_source", "=", "@generator_activity", "=", "Krikri", "::", "Activity"...
Store this agent's generator activity, which is the activity that produced the target entities upon which the current agent will operate. It is assumed that the agent class will define #entity_behavior, which returns the class of the appropriate behavior. `generator_uri' can be a string or RDF::URI. In the futu...
[ "Store", "this", "agent", "s", "generator", "activity", "which", "is", "the", "activity", "that", "produced", "the", "target", "entities", "upon", "which", "the", "current", "agent", "will", "operate", "." ]
0ac26e60ce1bba60caa40263a562796267cf833f
https://github.com/dpla/KriKri/blob/0ac26e60ce1bba60caa40263a562796267cf833f/lib/krikri/entity_consumer.rb#L41-L47
train
ninjudd/deep_clonable
lib/deep_clonable.rb
DeepClonable.InstanceMethods.deep_vars
def deep_vars instance_variables.select do |var| value = instance_variable_get(var) value.kind_of?(Array) or value.kind_of?(Hash) or value.kind_of?(DeepClonable::InstanceMethods) end end
ruby
def deep_vars instance_variables.select do |var| value = instance_variable_get(var) value.kind_of?(Array) or value.kind_of?(Hash) or value.kind_of?(DeepClonable::InstanceMethods) end end
[ "def", "deep_vars", "instance_variables", ".", "select", "do", "|", "var", "|", "value", "=", "instance_variable_get", "(", "var", ")", "value", ".", "kind_of?", "(", "Array", ")", "or", "value", ".", "kind_of?", "(", "Hash", ")", "or", "value", ".", "ki...
You can override deep_vars in your class to specify which instance_variables should be deep cloned. As it is, all Arrays and Hashes are deep cloned.
[ "You", "can", "override", "deep_vars", "in", "your", "class", "to", "specify", "which", "instance_variables", "should", "be", "deep", "cloned", ".", "As", "it", "is", "all", "Arrays", "and", "Hashes", "are", "deep", "cloned", "." ]
71be86f190c7643a07f44eb9b32ab48f88f0cbc4
https://github.com/ninjudd/deep_clonable/blob/71be86f190c7643a07f44eb9b32ab48f88f0cbc4/lib/deep_clonable.rb#L31-L36
train
nudded/GoogleReaderAPI
lib/google-reader-api/api.rb
GoogleReaderApi.Api.post_request
def post_request(url,args) uri = URI.parse(url) req = Net::HTTP::Post.new(uri.path) req.set_form_data(args) request(uri,req) end
ruby
def post_request(url,args) uri = URI.parse(url) req = Net::HTTP::Post.new(uri.path) req.set_form_data(args) request(uri,req) end
[ "def", "post_request", "(", "url", ",", "args", ")", "uri", "=", "URI", ".", "parse", "(", "url", ")", "req", "=", "Net", "::", "HTTP", "::", "Post", ".", "new", "(", "uri", ".", "path", ")", "req", ".", "set_form_data", "(", "args", ")", "reques...
url as a string the post data as a hash
[ "url", "as", "a", "string", "the", "post", "data", "as", "a", "hash" ]
1773adf4011ade0ac20c4e9057eaeffce1c5f7c9
https://github.com/nudded/GoogleReaderAPI/blob/1773adf4011ade0ac20c4e9057eaeffce1c5f7c9/lib/google-reader-api/api.rb#L48-L53
train
rubinius/rubinius-core-api
lib/rubinius/kernel/common/tuple.rb
Rubinius.Tuple.swap
def swap(a, b) temp = at(a) put a, at(b) put b, temp end
ruby
def swap(a, b) temp = at(a) put a, at(b) put b, temp end
[ "def", "swap", "(", "a", ",", "b", ")", "temp", "=", "at", "(", "a", ")", "put", "a", ",", "at", "(", "b", ")", "put", "b", ",", "temp", "end" ]
Swap elements of the two indexes.
[ "Swap", "elements", "of", "the", "two", "indexes", "." ]
8d01207061518355da9b53274fe8766ecf85fdfe
https://github.com/rubinius/rubinius-core-api/blob/8d01207061518355da9b53274fe8766ecf85fdfe/lib/rubinius/kernel/common/tuple.rb#L113-L117
train
tlux/vnstat-ruby
lib/vnstat/utils.rb
Vnstat.Utils.system_call
def system_call(*args) result = SystemCall.call(*args) return result.success_result if result.success? return yield(result.error_result) if block_given? result.error_result end
ruby
def system_call(*args) result = SystemCall.call(*args) return result.success_result if result.success? return yield(result.error_result) if block_given? result.error_result end
[ "def", "system_call", "(", "*", "args", ")", "result", "=", "SystemCall", ".", "call", "(", "*", "args", ")", "return", "result", ".", "success_result", "if", "result", ".", "success?", "return", "yield", "(", "result", ".", "error_result", ")", "if", "b...
Initiates a system call with the given arguments. @param [Array] args The arguments for the system call. @overload system_call(*args) @return [String] The output of STDOUT or STDERR, depending of the exit status of the called command. @overload system_call(*args, &block) @yield [error_result] A block y...
[ "Initiates", "a", "system", "call", "with", "the", "given", "arguments", "." ]
06939a65f8453b49b8bae749efcbe08ce86099e8
https://github.com/tlux/vnstat-ruby/blob/06939a65f8453b49b8bae749efcbe08ce86099e8/lib/vnstat/utils.rb#L25-L31
train
spox/splib
lib/splib/monitor.rb
Splib.Monitor.signal
def signal synchronize do while(t = @threads.shift) if(t && t.alive? && t.stop?) t.wakeup break else next end end end end
ruby
def signal synchronize do while(t = @threads.shift) if(t && t.alive? && t.stop?) t.wakeup break else next end end end end
[ "def", "signal", "synchronize", "do", "while", "(", "t", "=", "@threads", ".", "shift", ")", "if", "(", "t", "&&", "t", ".", "alive?", "&&", "t", ".", "stop?", ")", "t", ".", "wakeup", "break", "else", "next", "end", "end", "end", "end" ]
Wake up earliest thread
[ "Wake", "up", "earliest", "thread" ]
fd4451243ce4c9a319e74b33e6decdd09a509f43
https://github.com/spox/splib/blob/fd4451243ce4c9a319e74b33e6decdd09a509f43/lib/splib/monitor.rb#L58-L69
train
spox/splib
lib/splib/monitor.rb
Splib.Monitor.broadcast
def broadcast synchronize do @threads.dup.each do |t| t.wakeup if t.alive? && t.stop? end end end
ruby
def broadcast synchronize do @threads.dup.each do |t| t.wakeup if t.alive? && t.stop? end end end
[ "def", "broadcast", "synchronize", "do", "@threads", ".", "dup", ".", "each", "do", "|", "t", "|", "t", ".", "wakeup", "if", "t", ".", "alive?", "&&", "t", ".", "stop?", "end", "end", "end" ]
Wake up all threads
[ "Wake", "up", "all", "threads" ]
fd4451243ce4c9a319e74b33e6decdd09a509f43
https://github.com/spox/splib/blob/fd4451243ce4c9a319e74b33e6decdd09a509f43/lib/splib/monitor.rb#L71-L77
train
spox/splib
lib/splib/monitor.rb
Splib.Monitor.try_lock
def try_lock locked = false Thread.exclusive do clean unless(locked?(false)) do_lock locked = true else locked = owner?(Thread.current) end end locked end
ruby
def try_lock locked = false Thread.exclusive do clean unless(locked?(false)) do_lock locked = true else locked = owner?(Thread.current) end end locked end
[ "def", "try_lock", "locked", "=", "false", "Thread", ".", "exclusive", "do", "clean", "unless", "(", "locked?", "(", "false", ")", ")", "do_lock", "locked", "=", "true", "else", "locked", "=", "owner?", "(", "Thread", ".", "current", ")", "end", "end", ...
Attempt to lock. Returns true if lock is aquired and false if not.
[ "Attempt", "to", "lock", ".", "Returns", "true", "if", "lock", "is", "aquired", "and", "false", "if", "not", "." ]
fd4451243ce4c9a319e74b33e6decdd09a509f43
https://github.com/spox/splib/blob/fd4451243ce4c9a319e74b33e6decdd09a509f43/lib/splib/monitor.rb#L94-L106
train
spox/splib
lib/splib/monitor.rb
Splib.Monitor.clean
def clean @locks.delete_if{|t|!t.alive?} if(@lock_owner && !@lock_owner.alive?) @lock_owner = @locks.empty? ? nil : @locks.shift @lock_owner.wakeup if @lock_owner && !owner?(Thread.current) end end
ruby
def clean @locks.delete_if{|t|!t.alive?} if(@lock_owner && !@lock_owner.alive?) @lock_owner = @locks.empty? ? nil : @locks.shift @lock_owner.wakeup if @lock_owner && !owner?(Thread.current) end end
[ "def", "clean", "@locks", ".", "delete_if", "{", "|", "t", "|", "!", "t", ".", "alive?", "}", "if", "(", "@lock_owner", "&&", "!", "@lock_owner", ".", "alive?", ")", "@lock_owner", "=", "@locks", ".", "empty?", "?", "nil", ":", "@locks", ".", "shift"...
This is a simple helper method to help keep threads from ending up stuck waiting for a lock when a thread locks the monitor and then decides to die without unlocking. It is only called when new locks are attempted or a check is made if the monitor is currently locked.
[ "This", "is", "a", "simple", "helper", "method", "to", "help", "keep", "threads", "from", "ending", "up", "stuck", "waiting", "for", "a", "lock", "when", "a", "thread", "locks", "the", "monitor", "and", "then", "decides", "to", "die", "without", "unlocking...
fd4451243ce4c9a319e74b33e6decdd09a509f43
https://github.com/spox/splib/blob/fd4451243ce4c9a319e74b33e6decdd09a509f43/lib/splib/monitor.rb#L130-L136
train
spox/splib
lib/splib/monitor.rb
Splib.Monitor.do_unlock
def do_unlock unless(owner?(Thread.current)) raise ThreadError.new("Thread #{Thread.current} is not the current owner: #{@lock_owner}") end Thread.exclusive do @locks.delete_if{|t|!t.alive?} unless(@locks.empty?) old_owner = @lock_owner @lock_owner = @locks....
ruby
def do_unlock unless(owner?(Thread.current)) raise ThreadError.new("Thread #{Thread.current} is not the current owner: #{@lock_owner}") end Thread.exclusive do @locks.delete_if{|t|!t.alive?} unless(@locks.empty?) old_owner = @lock_owner @lock_owner = @locks....
[ "def", "do_unlock", "unless", "(", "owner?", "(", "Thread", ".", "current", ")", ")", "raise", "ThreadError", ".", "new", "(", "\"Thread #{Thread.current} is not the current owner: #{@lock_owner}\"", ")", "end", "Thread", ".", "exclusive", "do", "@locks", ".", "dele...
Unlock the monitor
[ "Unlock", "the", "monitor" ]
fd4451243ce4c9a319e74b33e6decdd09a509f43
https://github.com/spox/splib/blob/fd4451243ce4c9a319e74b33e6decdd09a509f43/lib/splib/monitor.rb#L162-L176
train
spox/splib
lib/splib/monitor.rb
Splib.Monitor.start_timer
def start_timer @timer = Thread.new do begin until(@stop) do cur = [] t = 0.0 Thread.exclusive do t = @timers.values.min cur = @timers.dup end t = 0.0 if !t.nil? && t < 0.0 a = 0.0 beg...
ruby
def start_timer @timer = Thread.new do begin until(@stop) do cur = [] t = 0.0 Thread.exclusive do t = @timers.values.min cur = @timers.dup end t = 0.0 if !t.nil? && t < 0.0 a = 0.0 beg...
[ "def", "start_timer", "@timer", "=", "Thread", ".", "new", "do", "begin", "until", "(", "@stop", ")", "do", "cur", "=", "[", "]", "t", "=", "0.0", "Thread", ".", "exclusive", "do", "t", "=", "@timers", ".", "values", ".", "min", "cur", "=", "@timer...
Starts the timer for waiting threads with a timeout
[ "Starts", "the", "timer", "for", "waiting", "threads", "with", "a", "timeout" ]
fd4451243ce4c9a319e74b33e6decdd09a509f43
https://github.com/spox/splib/blob/fd4451243ce4c9a319e74b33e6decdd09a509f43/lib/splib/monitor.rb#L179-L214
train
nbulaj/alpha_card
lib/alpha_card/resource.rb
AlphaCard.Resource.attributes_for_request
def attributes_for_request(attrs = filled_attributes) return attrs if self.class::ORIGIN_TRANSACTION_VARIABLES.empty? attrs.each_with_object({}) do |(attr, value), request_attrs| request_attrs[self.class::ORIGIN_TRANSACTION_VARIABLES.fetch(attr, attr)] = value end end
ruby
def attributes_for_request(attrs = filled_attributes) return attrs if self.class::ORIGIN_TRANSACTION_VARIABLES.empty? attrs.each_with_object({}) do |(attr, value), request_attrs| request_attrs[self.class::ORIGIN_TRANSACTION_VARIABLES.fetch(attr, attr)] = value end end
[ "def", "attributes_for_request", "(", "attrs", "=", "filled_attributes", ")", "return", "attrs", "if", "self", ".", "class", "::", "ORIGIN_TRANSACTION_VARIABLES", ".", "empty?", "attrs", ".", "each_with_object", "(", "{", "}", ")", "do", "|", "(", "attr", ",",...
Returns only filled attributes with the original Alpha Card Services transaction variables names. @param attrs [Hash] Attributes that must be converted to AlphaCard request params/ Default value is <code>filled_attributes</code>. @example order = AlphaCard::Order.new(id: '1', tax: nil, po_number: 'PO123')...
[ "Returns", "only", "filled", "attributes", "with", "the", "original", "Alpha", "Card", "Services", "transaction", "variables", "names", "." ]
06fefc2dbbf0e7002fabb2be361b8d72a178f559
https://github.com/nbulaj/alpha_card/blob/06fefc2dbbf0e7002fabb2be361b8d72a178f559/lib/alpha_card/resource.rb#L26-L32
train
nbulaj/alpha_card
lib/alpha_card/resource.rb
AlphaCard.Resource.validate_required_attributes!
def validate_required_attributes! unless required_attributes? blank_attribute = required_attributes.detect { |attr| self[attr].nil? || self[attr].empty? } raise ValidationError, "#{blank_attribute} can't be blank" end end
ruby
def validate_required_attributes! unless required_attributes? blank_attribute = required_attributes.detect { |attr| self[attr].nil? || self[attr].empty? } raise ValidationError, "#{blank_attribute} can't be blank" end end
[ "def", "validate_required_attributes!", "unless", "required_attributes?", "blank_attribute", "=", "required_attributes", ".", "detect", "{", "|", "attr", "|", "self", "[", "attr", "]", ".", "nil?", "||", "self", "[", "attr", "]", ".", "empty?", "}", "raise", "...
Validate required attributes to be filled. Raises an exception if one of the attribute is not specified. @raise [AlphaCard::InvalidObjectError] error if required attributes not set
[ "Validate", "required", "attributes", "to", "be", "filled", ".", "Raises", "an", "exception", "if", "one", "of", "the", "attribute", "is", "not", "specified", "." ]
06fefc2dbbf0e7002fabb2be361b8d72a178f559
https://github.com/nbulaj/alpha_card/blob/06fefc2dbbf0e7002fabb2be361b8d72a178f559/lib/alpha_card/resource.rb#L58-L64
train
elastics/elastics
elastics-client/lib/elastics/utility_methods.rb
Elastics.UtilityMethods.dump_one
def dump_one(*vars) refresh_index(*vars) document = search_by_id({:params => {:_source => '*'}}, *vars) document.delete('_score') document end
ruby
def dump_one(*vars) refresh_index(*vars) document = search_by_id({:params => {:_source => '*'}}, *vars) document.delete('_score') document end
[ "def", "dump_one", "(", "*", "vars", ")", "refresh_index", "(", "*", "vars", ")", "document", "=", "search_by_id", "(", "{", ":params", "=>", "{", ":_source", "=>", "'*'", "}", "}", ",", "*", "vars", ")", "document", ".", "delete", "(", "'_score'", "...
refresh and pull the full document from the index
[ "refresh", "and", "pull", "the", "full", "document", "from", "the", "index" ]
85517ec32fd30d3bb4b80223dc103fed482e4a3d
https://github.com/elastics/elastics/blob/85517ec32fd30d3bb4b80223dc103fed482e4a3d/elastics-client/lib/elastics/utility_methods.rb#L67-L72
train
elastics/elastics
elastics-client/lib/elastics/utility_methods.rb
Elastics.UtilityMethods.post_bulk_collection
def post_bulk_collection(collection, options={}) raise ArgumentError, "Array expected as :collection, got #{collection.inspect}" \ unless collection.is_a?(Array) bulk_string = '' collection.each do |d| bulk_string << build_bulk_string(d, options) end post_bulk_string(:b...
ruby
def post_bulk_collection(collection, options={}) raise ArgumentError, "Array expected as :collection, got #{collection.inspect}" \ unless collection.is_a?(Array) bulk_string = '' collection.each do |d| bulk_string << build_bulk_string(d, options) end post_bulk_string(:b...
[ "def", "post_bulk_collection", "(", "collection", ",", "options", "=", "{", "}", ")", "raise", "ArgumentError", ",", "\"Array expected as :collection, got #{collection.inspect}\"", "unless", "collection", ".", "is_a?", "(", "Array", ")", "bulk_string", "=", "''", "col...
You should use Elastics.post_bulk_string if you have an already formatted bulk data-string
[ "You", "should", "use", "Elastics", ".", "post_bulk_string", "if", "you", "have", "an", "already", "formatted", "bulk", "data", "-", "string" ]
85517ec32fd30d3bb4b80223dc103fed482e4a3d
https://github.com/elastics/elastics/blob/85517ec32fd30d3bb4b80223dc103fed482e4a3d/elastics-client/lib/elastics/utility_methods.rb#L75-L83
train
AnkurGel/dictionary-rb
lib/dictionary-rb/dictionary.rb
DictionaryRB.Dictionary.examples
def examples @doc ||= Nokogiri::HTML(open(PREFIX + CGI::escape(@word))) @example_results ||= @doc.css('.exsentences').map{ |x| x.text.strip }.reject(&:empty?).flatten @example_results #to prevent above computations on repeated call on object end
ruby
def examples @doc ||= Nokogiri::HTML(open(PREFIX + CGI::escape(@word))) @example_results ||= @doc.css('.exsentences').map{ |x| x.text.strip }.reject(&:empty?).flatten @example_results #to prevent above computations on repeated call on object end
[ "def", "examples", "@doc", "||=", "Nokogiri", "::", "HTML", "(", "open", "(", "PREFIX", "+", "CGI", "::", "escape", "(", "@word", ")", ")", ")", "@example_results", "||=", "@doc", ".", "css", "(", "'.exsentences'", ")", ".", "map", "{", "|", "x", "|"...
Fetches and gives the examples for the word @example word.examples #=> ["There is an easy answer to this question, and it involves some good news and  some bad news.", "Then there was an awkward silence as though they were waiting for me to answer  another question.",..] @return [Array] containing th...
[ "Fetches", "and", "gives", "the", "examples", "for", "the", "word" ]
92566325aee598f46b584817373017e6097300b4
https://github.com/AnkurGel/dictionary-rb/blob/92566325aee598f46b584817373017e6097300b4/lib/dictionary-rb/dictionary.rb#L64-L68
train
AnkurGel/dictionary-rb
lib/dictionary-rb/dictionary.rb
DictionaryRB.Dictionary.similar_words
def similar_words @doc ||= Nokogiri::HTML(open(PREFIX + CGI::escape(@word))) @similar_words = @doc.css("#relatedwords .fla a").map(&:text).reject(&:empty?) @similar_words end
ruby
def similar_words @doc ||= Nokogiri::HTML(open(PREFIX + CGI::escape(@word))) @similar_words = @doc.css("#relatedwords .fla a").map(&:text).reject(&:empty?) @similar_words end
[ "def", "similar_words", "@doc", "||=", "Nokogiri", "::", "HTML", "(", "open", "(", "PREFIX", "+", "CGI", "::", "escape", "(", "@word", ")", ")", ")", "@similar_words", "=", "@doc", ".", "css", "(", "\"#relatedwords .fla a\"", ")", ".", "map", "(", "&", ...
Fetches and gives synonyms for the word @example word.similar_words #=> => ["answer", "inquire", "question mark", "sentence",.. ] @return [Array] containing similar words
[ "Fetches", "and", "gives", "synonyms", "for", "the", "word" ]
92566325aee598f46b584817373017e6097300b4
https://github.com/AnkurGel/dictionary-rb/blob/92566325aee598f46b584817373017e6097300b4/lib/dictionary-rb/dictionary.rb#L75-L79
train
dpla/KriKri
lib/krikri/random_search_index_document_builder.rb
Krikri.RandomSearchIndexDocumentBuilder.query_params
def query_params params = { :id => '*:*', :sort => "random_#{rand(9999)} desc", :rows => 1 } return params unless provider_id.present? provider = RDF::URI(Krikri::Provider.base_uri) / provider_id params[:fq] = "provider_id:\"#{provider}\"" params end
ruby
def query_params params = { :id => '*:*', :sort => "random_#{rand(9999)} desc", :rows => 1 } return params unless provider_id.present? provider = RDF::URI(Krikri::Provider.base_uri) / provider_id params[:fq] = "provider_id:\"#{provider}\"" params end
[ "def", "query_params", "params", "=", "{", ":id", "=>", "'*:*'", ",", ":sort", "=>", "\"random_#{rand(9999)} desc\"", ",", ":rows", "=>", "1", "}", "return", "params", "unless", "provider_id", ".", "present?", "provider", "=", "RDF", "::", "URI", "(", "Krikr...
Parameters for the Solr request. Limits search by @provider_id if it has been specified.
[ "Parameters", "for", "the", "Solr", "request", ".", "Limits", "search", "by" ]
0ac26e60ce1bba60caa40263a562796267cf833f
https://github.com/dpla/KriKri/blob/0ac26e60ce1bba60caa40263a562796267cf833f/lib/krikri/random_search_index_document_builder.rb#L30-L39
train
dpla/KriKri
app/helpers/krikri/records_helper.rb
Krikri.RecordsHelper.random_record_id
def random_record_id(provider_id) doc = Krikri::RandomSearchIndexDocumentBuilder.new do self.provider_id = provider_id end.document doc.present? ? local_name(doc.id) : nil end
ruby
def random_record_id(provider_id) doc = Krikri::RandomSearchIndexDocumentBuilder.new do self.provider_id = provider_id end.document doc.present? ? local_name(doc.id) : nil end
[ "def", "random_record_id", "(", "provider_id", ")", "doc", "=", "Krikri", "::", "RandomSearchIndexDocumentBuilder", ".", "new", "do", "self", ".", "provider_id", "=", "provider_id", "end", ".", "document", "doc", ".", "present?", "?", "local_name", "(", "doc", ...
Return the id of a document randomly selected from the search index. @param provider_id [String, nil] the id of the provider that the randomly selected document will belong to. @return [String, nil] the id of the randomly selected document. If none are available, gives `nil`
[ "Return", "the", "id", "of", "a", "document", "randomly", "selected", "from", "the", "search", "index", "." ]
0ac26e60ce1bba60caa40263a562796267cf833f
https://github.com/dpla/KriKri/blob/0ac26e60ce1bba60caa40263a562796267cf833f/app/helpers/krikri/records_helper.rb#L11-L17
train
daytonn/architecture-js
lib/sprockets/lib/sprockets/pathname.rb
Sprockets.Pathname.find
def find(location, kind = :file) location = File.join(absolute_location, location) File.send("#{kind}?", location) ? Pathname.new(environment, location) : nil end
ruby
def find(location, kind = :file) location = File.join(absolute_location, location) File.send("#{kind}?", location) ? Pathname.new(environment, location) : nil end
[ "def", "find", "(", "location", ",", "kind", "=", ":file", ")", "location", "=", "File", ".", "join", "(", "absolute_location", ",", "location", ")", "File", ".", "send", "(", "\"#{kind}?\"", ",", "location", ")", "?", "Pathname", ".", "new", "(", "env...
Returns a Pathname for the location relative to this pathname's absolute location.
[ "Returns", "a", "Pathname", "for", "the", "location", "relative", "to", "this", "pathname", "s", "absolute", "location", "." ]
c0e891425e1a71b7eca21aa2513cff8b856636f0
https://github.com/daytonn/architecture-js/blob/c0e891425e1a71b7eca21aa2513cff8b856636f0/lib/sprockets/lib/sprockets/pathname.rb#L11-L14
train
dpla/KriKri
lib/krikri/search_results_helper_behavior.rb
Krikri.SearchResultsHelperBehavior.render_enriched_record
def render_enriched_record(document) agg = document.aggregation return error_msg('Aggregation not found.') unless agg.present? JSON.pretty_generate(agg.to_jsonld['@graph']) end
ruby
def render_enriched_record(document) agg = document.aggregation return error_msg('Aggregation not found.') unless agg.present? JSON.pretty_generate(agg.to_jsonld['@graph']) end
[ "def", "render_enriched_record", "(", "document", ")", "agg", "=", "document", ".", "aggregation", "return", "error_msg", "(", "'Aggregation not found.'", ")", "unless", "agg", ".", "present?", "JSON", ".", "pretty_generate", "(", "agg", ".", "to_jsonld", "[", "...
Render enriched record for view @param [Krikri::SearchIndexDocument] @return [String]
[ "Render", "enriched", "record", "for", "view" ]
0ac26e60ce1bba60caa40263a562796267cf833f
https://github.com/dpla/KriKri/blob/0ac26e60ce1bba60caa40263a562796267cf833f/lib/krikri/search_results_helper_behavior.rb#L25-L29
train
dpla/KriKri
lib/krikri/search_results_helper_behavior.rb
Krikri.SearchResultsHelperBehavior.render_original_record
def render_original_record(document) agg = document.aggregation return error_msg('Aggregation not found.') unless agg.present? begin original_record = agg.original_record rescue StandardError => e logger.error e.message return error_msg(e.message) end return...
ruby
def render_original_record(document) agg = document.aggregation return error_msg('Aggregation not found.') unless agg.present? begin original_record = agg.original_record rescue StandardError => e logger.error e.message return error_msg(e.message) end return...
[ "def", "render_original_record", "(", "document", ")", "agg", "=", "document", ".", "aggregation", "return", "error_msg", "(", "'Aggregation not found.'", ")", "unless", "agg", ".", "present?", "begin", "original_record", "=", "agg", ".", "original_record", "rescue"...
Render original record for view @param [Krikri::SearchIndexDocument] @return [String]
[ "Render", "original", "record", "for", "view" ]
0ac26e60ce1bba60caa40263a562796267cf833f
https://github.com/dpla/KriKri/blob/0ac26e60ce1bba60caa40263a562796267cf833f/lib/krikri/search_results_helper_behavior.rb#L34-L48
train
KatanaCode/cookie_alert
app/controllers/cookie_alert/cookies_controller.rb
CookieAlert.CookiesController.cookie_accepted
def cookie_accepted # Get the visitor's current page URL or, if nil?, default to the application root. Resue block needed for bots visitor_current_url = begin cookies.signed[CookieAlert.config.cookie_name.to_sym].split(CookieAlert.config.cookie_value_text_separator)[1] rescue main_ap...
ruby
def cookie_accepted # Get the visitor's current page URL or, if nil?, default to the application root. Resue block needed for bots visitor_current_url = begin cookies.signed[CookieAlert.config.cookie_name.to_sym].split(CookieAlert.config.cookie_value_text_separator)[1] rescue main_ap...
[ "def", "cookie_accepted", "visitor_current_url", "=", "begin", "cookies", ".", "signed", "[", "CookieAlert", ".", "config", ".", "cookie_name", ".", "to_sym", "]", ".", "split", "(", "CookieAlert", ".", "config", ".", "cookie_value_text_separator", ")", "[", "1"...
Implement cookie acceptance when a visitor click the 'accept' button
[ "Implement", "cookie", "acceptance", "when", "a", "visitor", "click", "the", "accept", "button" ]
2b576deb563b1f5297cf867dd28879e47880ee21
https://github.com/KatanaCode/cookie_alert/blob/2b576deb563b1f5297cf867dd28879e47880ee21/app/controllers/cookie_alert/cookies_controller.rb#L7-L43
train
at1as/Terminal-Chess
lib/terminal_chess/board.rb
TerminalChess.Board.check?
def check?(color, proposed_manifest = @piece_locations, recurse_for_checkmate = false) enemy_attack_vectors = {} player_attack_vectors = {} king_loc = [] enemy_color = opposing_color(color) proposed_manifest.each do |piece, details| if details[:color] == enemy_color ...
ruby
def check?(color, proposed_manifest = @piece_locations, recurse_for_checkmate = false) enemy_attack_vectors = {} player_attack_vectors = {} king_loc = [] enemy_color = opposing_color(color) proposed_manifest.each do |piece, details| if details[:color] == enemy_color ...
[ "def", "check?", "(", "color", ",", "proposed_manifest", "=", "@piece_locations", ",", "recurse_for_checkmate", "=", "false", ")", "enemy_attack_vectors", "=", "{", "}", "player_attack_vectors", "=", "{", "}", "king_loc", "=", "[", "]", "enemy_color", "=", "oppo...
Return whether the player of a specified color has their king currently in check by checking the attack vectors of all the opponents players against the king location Also, check whether king currently in check, has all of their valid moves within their opponents attack vectors, and therefore are in checkmate (@chec...
[ "Return", "whether", "the", "player", "of", "a", "specified", "color", "has", "their", "king", "currently", "in", "check", "by", "checking", "the", "attack", "vectors", "of", "all", "the", "opponents", "players", "against", "the", "king", "location", "Also", ...
330c03b6f9e730e93657b65be69e29046e5f37bc
https://github.com/at1as/Terminal-Chess/blob/330c03b6f9e730e93657b65be69e29046e5f37bc/lib/terminal_chess/board.rb#L194-L249
train
CryptoProcessing/cryptoprocessing.rb
lib/cryptoprocessing/models/account.rb
Cryptoprocessing.Account.transactions
def transactions(options = {}) agent.transactions(self['id'], options) do |data, resp| yield(data, resp) if block_given? end end
ruby
def transactions(options = {}) agent.transactions(self['id'], options) do |data, resp| yield(data, resp) if block_given? end end
[ "def", "transactions", "(", "options", "=", "{", "}", ")", "agent", ".", "transactions", "(", "self", "[", "'id'", "]", ",", "options", ")", "do", "|", "data", ",", "resp", "|", "yield", "(", "data", ",", "resp", ")", "if", "block_given?", "end", "...
List of transactions
[ "List", "of", "transactions" ]
54cd6c697e47cd1124dd348e96b0f11facac9b79
https://github.com/CryptoProcessing/cryptoprocessing.rb/blob/54cd6c697e47cd1124dd348e96b0f11facac9b79/lib/cryptoprocessing/models/account.rb#L13-L17
train
CryptoProcessing/cryptoprocessing.rb
lib/cryptoprocessing/models/account.rb
Cryptoprocessing.Account.transactions_by_address
def transactions_by_address(address, options = {}) agent.transactions_by_address(self['id'], address, options) do |data, resp| yield(data, resp) if block_given? end end
ruby
def transactions_by_address(address, options = {}) agent.transactions_by_address(self['id'], address, options) do |data, resp| yield(data, resp) if block_given? end end
[ "def", "transactions_by_address", "(", "address", ",", "options", "=", "{", "}", ")", "agent", ".", "transactions_by_address", "(", "self", "[", "'id'", "]", ",", "address", ",", "options", ")", "do", "|", "data", ",", "resp", "|", "yield", "(", "data", ...
List of transactions by address
[ "List", "of", "transactions", "by", "address" ]
54cd6c697e47cd1124dd348e96b0f11facac9b79
https://github.com/CryptoProcessing/cryptoprocessing.rb/blob/54cd6c697e47cd1124dd348e96b0f11facac9b79/lib/cryptoprocessing/models/account.rb#L20-L24
train
tlux/vnstat-ruby
lib/vnstat/interface_collection.rb
Vnstat.InterfaceCollection.[]
def [](id) interfaces_hash.fetch(id.to_s) do raise UnknownInterface.new(id.to_s), "Unknown interface: #{id}" end end
ruby
def [](id) interfaces_hash.fetch(id.to_s) do raise UnknownInterface.new(id.to_s), "Unknown interface: #{id}" end end
[ "def", "[]", "(", "id", ")", "interfaces_hash", ".", "fetch", "(", "id", ".", "to_s", ")", "do", "raise", "UnknownInterface", ".", "new", "(", "id", ".", "to_s", ")", ",", "\"Unknown interface: #{id}\"", "end", "end" ]
Returns traffic information for a certain interface. @param [String] id The name of the interface. @raise [UnknownInterface] An error that is raised if the specified interface is not tracked. @return [Interface]
[ "Returns", "traffic", "information", "for", "a", "certain", "interface", "." ]
06939a65f8453b49b8bae749efcbe08ce86099e8
https://github.com/tlux/vnstat-ruby/blob/06939a65f8453b49b8bae749efcbe08ce86099e8/lib/vnstat/interface_collection.rb#L50-L55
train
mikemackintosh/ruby-easyrsa
lib/easyrsa/certificate.rb
EasyRSA.Certificate.gen_subject
def gen_subject subject_name = "/C=#{EasyRSA::Config.country}" subject_name += "/ST=#{EasyRSA::Config.state}" unless !EasyRSA::Config.state || EasyRSA::Config.state.empty? subject_name += "/L=#{EasyRSA::Config.city}" subject_name += "/O=#{EasyRSA::Config.company}" subject_name +=...
ruby
def gen_subject subject_name = "/C=#{EasyRSA::Config.country}" subject_name += "/ST=#{EasyRSA::Config.state}" unless !EasyRSA::Config.state || EasyRSA::Config.state.empty? subject_name += "/L=#{EasyRSA::Config.city}" subject_name += "/O=#{EasyRSA::Config.company}" subject_name +=...
[ "def", "gen_subject", "subject_name", "=", "\"/C=#{EasyRSA::Config.country}\"", "subject_name", "+=", "\"/ST=#{EasyRSA::Config.state}\"", "unless", "!", "EasyRSA", "::", "Config", ".", "state", "||", "EasyRSA", "::", "Config", ".", "state", ".", "empty?", "subject_name"...
Cert subject for End-User
[ "Cert", "subject", "for", "End", "-", "User" ]
a3ae2d420454e04f0c75e1a4e54caa7cda6fe29a
https://github.com/mikemackintosh/ruby-easyrsa/blob/a3ae2d420454e04f0c75e1a4e54caa7cda6fe29a/lib/easyrsa/certificate.rb#L105-L116
train
tlux/vnstat-ruby
lib/vnstat/interface.rb
Vnstat.Interface.nick=
def nick=(nick) success = Utils.call_executable_returning_status( '-i', id, '--nick', nick, '--update' ) unless success raise Error, "Unable to set nickname for interface (#{id}). " \ 'Please make sure the vnstat daemon is not running while ' \ '...
ruby
def nick=(nick) success = Utils.call_executable_returning_status( '-i', id, '--nick', nick, '--update' ) unless success raise Error, "Unable to set nickname for interface (#{id}). " \ 'Please make sure the vnstat daemon is not running while ' \ '...
[ "def", "nick", "=", "(", "nick", ")", "success", "=", "Utils", ".", "call_executable_returning_status", "(", "'-i'", ",", "id", ",", "'--nick'", ",", "nick", ",", "'--update'", ")", "unless", "success", "raise", "Error", ",", "\"Unable to set nickname for interf...
Sets the alias name for the interface. @raise [Error] Raised when a new nickname could not be set. @param [String] nick The alias name for the interface.
[ "Sets", "the", "alias", "name", "for", "the", "interface", "." ]
06939a65f8453b49b8bae749efcbe08ce86099e8
https://github.com/tlux/vnstat-ruby/blob/06939a65f8453b49b8bae749efcbe08ce86099e8/lib/vnstat/interface.rb#L85-L95
train
ericchapman/ruby_wamp_rails
lib/wamp_rails/client.rb
WampRails.Client.open
def open # Create the background thread self.thread = Thread.new do EM.tick_loop do unless self.cmd_queue.empty? command = self.cmd_queue.pop self._execute_command(command) end end self.wamp.open end end
ruby
def open # Create the background thread self.thread = Thread.new do EM.tick_loop do unless self.cmd_queue.empty? command = self.cmd_queue.pop self._execute_command(command) end end self.wamp.open end end
[ "def", "open", "self", ".", "thread", "=", "Thread", ".", "new", "do", "EM", ".", "tick_loop", "do", "unless", "self", ".", "cmd_queue", ".", "empty?", "command", "=", "self", ".", "cmd_queue", ".", "pop", "self", ".", "_execute_command", "(", "command",...
Constructor for creating a client. Options are @param options [Hash] The different options to pass to the connection @option options [String] :name - The name of the WAMP Client @option options [WampClient::Connection] :wamp - Allows a different WAMP to be passed in @option options [String] :uri The uri of the WAM...
[ "Constructor", "for", "creating", "a", "client", ".", "Options", "are" ]
026672c759448d73348ac0e315ae8fbf35f51b9f
https://github.com/ericchapman/ruby_wamp_rails/blob/026672c759448d73348ac0e315ae8fbf35f51b9f/lib/wamp_rails/client.rb#L95-L106
train
ericchapman/ruby_wamp_rails
lib/wamp_rails/client.rb
WampRails.Client.add_procedure
def add_procedure(procedure, klass, options=nil) options ||= {} raise WampRails::Error.new('"add_procedure" must be called BEFORE "open"') if self.thread self.registrations << WampRails::Command::Register.new(procedure, klass, options, self) end
ruby
def add_procedure(procedure, klass, options=nil) options ||= {} raise WampRails::Error.new('"add_procedure" must be called BEFORE "open"') if self.thread self.registrations << WampRails::Command::Register.new(procedure, klass, options, self) end
[ "def", "add_procedure", "(", "procedure", ",", "klass", ",", "options", "=", "nil", ")", "options", "||=", "{", "}", "raise", "WampRails", "::", "Error", ".", "new", "(", "'\"add_procedure\" must be called BEFORE \"open\"'", ")", "if", "self", ".", "thread", "...
Adds a procedure to the client
[ "Adds", "a", "procedure", "to", "the", "client" ]
026672c759448d73348ac0e315ae8fbf35f51b9f
https://github.com/ericchapman/ruby_wamp_rails/blob/026672c759448d73348ac0e315ae8fbf35f51b9f/lib/wamp_rails/client.rb#L125-L129
train
ericchapman/ruby_wamp_rails
lib/wamp_rails/client.rb
WampRails.Client.add_subscription
def add_subscription(topic, klass, options=nil) options ||= {} raise WampRails::Error.new('"add_subscription" must be called BEFORE "open"') if self.thread self.subscriptions << WampRails::Command::Subscribe.new(topic, klass, options, self) end
ruby
def add_subscription(topic, klass, options=nil) options ||= {} raise WampRails::Error.new('"add_subscription" must be called BEFORE "open"') if self.thread self.subscriptions << WampRails::Command::Subscribe.new(topic, klass, options, self) end
[ "def", "add_subscription", "(", "topic", ",", "klass", ",", "options", "=", "nil", ")", "options", "||=", "{", "}", "raise", "WampRails", "::", "Error", ".", "new", "(", "'\"add_subscription\" must be called BEFORE \"open\"'", ")", "if", "self", ".", "thread", ...
Adds a subscription to the client
[ "Adds", "a", "subscription", "to", "the", "client" ]
026672c759448d73348ac0e315ae8fbf35f51b9f
https://github.com/ericchapman/ruby_wamp_rails/blob/026672c759448d73348ac0e315ae8fbf35f51b9f/lib/wamp_rails/client.rb#L132-L136
train
ericchapman/ruby_wamp_rails
lib/wamp_rails/client.rb
WampRails.Client.call
def call(procedure, args=nil, kwargs=nil, options={}, &callback) command = WampRails::Command::Call.new(procedure, args, kwargs, options, self) self._queue_command(command, callback) end
ruby
def call(procedure, args=nil, kwargs=nil, options={}, &callback) command = WampRails::Command::Call.new(procedure, args, kwargs, options, self) self._queue_command(command, callback) end
[ "def", "call", "(", "procedure", ",", "args", "=", "nil", ",", "kwargs", "=", "nil", ",", "options", "=", "{", "}", ",", "&", "callback", ")", "command", "=", "WampRails", "::", "Command", "::", "Call", ".", "new", "(", "procedure", ",", "args", ",...
endregion region WAMP Methods Performs a WAMP call @note This method is blocking if the callback is not nil
[ "endregion", "region", "WAMP", "Methods", "Performs", "a", "WAMP", "call" ]
026672c759448d73348ac0e315ae8fbf35f51b9f
https://github.com/ericchapman/ruby_wamp_rails/blob/026672c759448d73348ac0e315ae8fbf35f51b9f/lib/wamp_rails/client.rb#L144-L147
train
ericchapman/ruby_wamp_rails
lib/wamp_rails/client.rb
WampRails.Client.publish
def publish(topic, args=nil, kwargs=nil, options={}, &callback) command = WampRails::Command::Publish.new(topic, args, kwargs, options, self) self._queue_command(command, callback) end
ruby
def publish(topic, args=nil, kwargs=nil, options={}, &callback) command = WampRails::Command::Publish.new(topic, args, kwargs, options, self) self._queue_command(command, callback) end
[ "def", "publish", "(", "topic", ",", "args", "=", "nil", ",", "kwargs", "=", "nil", ",", "options", "=", "{", "}", ",", "&", "callback", ")", "command", "=", "WampRails", "::", "Command", "::", "Publish", ".", "new", "(", "topic", ",", "args", ",",...
Performs a WAMP publish @note This method is blocking if the callback is not nil
[ "Performs", "a", "WAMP", "publish" ]
026672c759448d73348ac0e315ae8fbf35f51b9f
https://github.com/ericchapman/ruby_wamp_rails/blob/026672c759448d73348ac0e315ae8fbf35f51b9f/lib/wamp_rails/client.rb#L151-L154
train
ericchapman/ruby_wamp_rails
lib/wamp_rails/client.rb
WampRails.Client.register
def register(procedure, klass, options={}, &callback) command = WampRails::Command::Register.new(procedure, klass, options, self) self._queue_command(command, callback) end
ruby
def register(procedure, klass, options={}, &callback) command = WampRails::Command::Register.new(procedure, klass, options, self) self._queue_command(command, callback) end
[ "def", "register", "(", "procedure", ",", "klass", ",", "options", "=", "{", "}", ",", "&", "callback", ")", "command", "=", "WampRails", "::", "Command", "::", "Register", ".", "new", "(", "procedure", ",", "klass", ",", "options", ",", "self", ")", ...
Performs a WAMP register @note This method is blocking if the callback is not nil
[ "Performs", "a", "WAMP", "register" ]
026672c759448d73348ac0e315ae8fbf35f51b9f
https://github.com/ericchapman/ruby_wamp_rails/blob/026672c759448d73348ac0e315ae8fbf35f51b9f/lib/wamp_rails/client.rb#L158-L161
train
ericchapman/ruby_wamp_rails
lib/wamp_rails/client.rb
WampRails.Client.subscribe
def subscribe(topic, klass, options={}, &callback) command = WampRails::Command::Subscribe.new(topic, klass, options, self) self._queue_command(command, callback) end
ruby
def subscribe(topic, klass, options={}, &callback) command = WampRails::Command::Subscribe.new(topic, klass, options, self) self._queue_command(command, callback) end
[ "def", "subscribe", "(", "topic", ",", "klass", ",", "options", "=", "{", "}", ",", "&", "callback", ")", "command", "=", "WampRails", "::", "Command", "::", "Subscribe", ".", "new", "(", "topic", ",", "klass", ",", "options", ",", "self", ")", "self...
Performs a WAMP subscribe @note This method is blocking if the callback is not nil
[ "Performs", "a", "WAMP", "subscribe" ]
026672c759448d73348ac0e315ae8fbf35f51b9f
https://github.com/ericchapman/ruby_wamp_rails/blob/026672c759448d73348ac0e315ae8fbf35f51b9f/lib/wamp_rails/client.rb#L165-L168
train
ericchapman/ruby_wamp_rails
lib/wamp_rails/client.rb
WampRails.Client._queue_command
def _queue_command(command, callback=nil) # If the current thread is the EM thread, execute the command. Else put it in the queue if self.thread == Thread.current self._execute_command(command) else self.cmd_queue.push(command) end # If the callback is defined, block unt...
ruby
def _queue_command(command, callback=nil) # If the current thread is the EM thread, execute the command. Else put it in the queue if self.thread == Thread.current self._execute_command(command) else self.cmd_queue.push(command) end # If the callback is defined, block unt...
[ "def", "_queue_command", "(", "command", ",", "callback", "=", "nil", ")", "if", "self", ".", "thread", "==", "Thread", ".", "current", "self", ".", "_execute_command", "(", "command", ")", "else", "self", ".", "cmd_queue", ".", "push", "(", "command", "...
endregion region Private Methods Queues the command and blocks it the callback is not nil @param [WampRails::Command::Base] - The command to queue @param [Block] - The block to call when complete
[ "endregion", "region", "Private", "Methods", "Queues", "the", "command", "and", "blocks", "it", "the", "callback", "is", "not", "nil" ]
026672c759448d73348ac0e315ae8fbf35f51b9f
https://github.com/ericchapman/ruby_wamp_rails/blob/026672c759448d73348ac0e315ae8fbf35f51b9f/lib/wamp_rails/client.rb#L177-L191
train
elastics/elastics
elastics-admin/lib/elastics/admin_live_reindex.rb
Elastics.LiveReindex.track_external_change
def track_external_change(app_id, action, document) return unless Conf.redis Conf.redis.rpush("#{KEYS[:changes]}-#{app_id}", MultiJson.encode([action, document])) end
ruby
def track_external_change(app_id, action, document) return unless Conf.redis Conf.redis.rpush("#{KEYS[:changes]}-#{app_id}", MultiJson.encode([action, document])) end
[ "def", "track_external_change", "(", "app_id", ",", "action", ",", "document", ")", "return", "unless", "Conf", ".", "redis", "Conf", ".", "redis", ".", "rpush", "(", "\"#{KEYS[:changes]}-#{app_id}\"", ",", "MultiJson", ".", "encode", "(", "[", "action", ",", ...
use this method when you are tracking the change of another app you must pass the app_id of the app being affected by the change
[ "use", "this", "method", "when", "you", "are", "tracking", "the", "change", "of", "another", "app", "you", "must", "pass", "the", "app_id", "of", "the", "app", "being", "affected", "by", "the", "change" ]
85517ec32fd30d3bb4b80223dc103fed482e4a3d
https://github.com/elastics/elastics/blob/85517ec32fd30d3bb4b80223dc103fed482e4a3d/elastics-admin/lib/elastics/admin_live_reindex.rb#L106-L109
train
appium/appium_doc_lint
lib/appium_doc_lint/lint.rb
Appium.Lint.report
def report data return nil if data.nil? || data.empty? result = '' data.each do |file_name, analysis| rel_path = File.join('.', File.expand_path(file_name).sub(Dir.pwd, '')) result += "\n#{rel_path}\n" analysis.each do |line_number, warning| result += " #{line_number...
ruby
def report data return nil if data.nil? || data.empty? result = '' data.each do |file_name, analysis| rel_path = File.join('.', File.expand_path(file_name).sub(Dir.pwd, '')) result += "\n#{rel_path}\n" analysis.each do |line_number, warning| result += " #{line_number...
[ "def", "report", "data", "return", "nil", "if", "data", ".", "nil?", "||", "data", ".", "empty?", "result", "=", "''", "data", ".", "each", "do", "|", "file_name", ",", "analysis", "|", "rel_path", "=", "File", ".", "join", "(", "'.'", ",", "File", ...
Format data into a report
[ "Format", "data", "into", "a", "report" ]
7774d7d382da6afe594a64188b198b52bb1dfe14
https://github.com/appium/appium_doc_lint/blob/7774d7d382da6afe594a64188b198b52bb1dfe14/lib/appium_doc_lint/lint.rb#L82-L95
train
scryptmouse/dux
lib/dux/blankness.rb
Dux.Blankness.blankish?
def blankish?(value) case value when nil, false true when Dux[:nan?] true when String, Symbol value.empty? || value =~ WHITESPACE_ONLY when Dux[:blank?] value.blank? when Hash value.empty? when Array, Enumerable Dux.attempt(value,...
ruby
def blankish?(value) case value when nil, false true when Dux[:nan?] true when String, Symbol value.empty? || value =~ WHITESPACE_ONLY when Dux[:blank?] value.blank? when Hash value.empty? when Array, Enumerable Dux.attempt(value,...
[ "def", "blankish?", "(", "value", ")", "case", "value", "when", "nil", ",", "false", "true", "when", "Dux", "[", ":nan?", "]", "true", "when", "String", ",", "Symbol", "value", ".", "empty?", "||", "value", "=~", "WHITESPACE_ONLY", "when", "Dux", "[", ...
Check if a provided object is semantically empty. @param [Object] value
[ "Check", "if", "a", "provided", "object", "is", "semantically", "empty", "." ]
94a9b05fcfede36369e93d9c3a339365e55dc38a
https://github.com/scryptmouse/dux/blob/94a9b05fcfede36369e93d9c3a339365e55dc38a/lib/dux/blankness.rb#L15-L34
train
dpla/KriKri
lib/krikri/qa_query_client.rb
Krikri.QAQueryClient.build_optional_patterns
def build_optional_patterns(predicates) return [[TYPE, predicates, VALUE]] unless predicates.is_a? Enumerable var1 = TYPE patterns = predicates.each_with_object([]) do |predicate, ps| var2 = (ps.count == predicates.size - 1) ? VALUE : "obj#{ps.count}".to_sym ps << [v...
ruby
def build_optional_patterns(predicates) return [[TYPE, predicates, VALUE]] unless predicates.is_a? Enumerable var1 = TYPE patterns = predicates.each_with_object([]) do |predicate, ps| var2 = (ps.count == predicates.size - 1) ? VALUE : "obj#{ps.count}".to_sym ps << [v...
[ "def", "build_optional_patterns", "(", "predicates", ")", "return", "[", "[", "TYPE", ",", "predicates", ",", "VALUE", "]", "]", "unless", "predicates", ".", "is_a?", "Enumerable", "var1", "=", "TYPE", "patterns", "=", "predicates", ".", "each_with_object", "(...
Builds patterns matching a predicate or chain of predicates given, assigning an unbound variable to each set of matches and passing it to the next pattern. @param predicates [#to_uri, Array<#to_uri>] a predicate or list of predicates to build patterns against. @return [Array<Array<#to_term>>] An array of patte...
[ "Builds", "patterns", "matching", "a", "predicate", "or", "chain", "of", "predicates", "given", "assigning", "an", "unbound", "variable", "to", "each", "set", "of", "matches", "and", "passing", "it", "to", "the", "next", "pattern", "." ]
0ac26e60ce1bba60caa40263a562796267cf833f
https://github.com/dpla/KriKri/blob/0ac26e60ce1bba60caa40263a562796267cf833f/lib/krikri/qa_query_client.rb#L141-L152
train
at1as/Terminal-Chess
lib/terminal_chess/move.rb
TerminalChess.Move.possible_moves
def possible_moves(p1, manifest, castling = false) return [] if manifest[p1][:type].nil? allowed = [] type = manifest[p1][:type] my_color = manifest[p1][:color] constants(manifest, my_color, type) return [] if unoccupied?(p1) if type == :king allowed += [mov...
ruby
def possible_moves(p1, manifest, castling = false) return [] if manifest[p1][:type].nil? allowed = [] type = manifest[p1][:type] my_color = manifest[p1][:color] constants(manifest, my_color, type) return [] if unoccupied?(p1) if type == :king allowed += [mov...
[ "def", "possible_moves", "(", "p1", ",", "manifest", ",", "castling", "=", "false", ")", "return", "[", "]", "if", "manifest", "[", "p1", "]", "[", ":type", "]", ".", "nil?", "allowed", "=", "[", "]", "type", "=", "manifest", "[", "p1", "]", "[", ...
Calls methods below to return a list of positions which are valid moves for piece at index p1, given the current board layout as defined in manifest
[ "Calls", "methods", "below", "to", "return", "a", "list", "of", "positions", "which", "are", "valid", "moves", "for", "piece", "at", "index", "p1", "given", "the", "current", "board", "layout", "as", "defined", "in", "manifest" ]
330c03b6f9e730e93657b65be69e29046e5f37bc
https://github.com/at1as/Terminal-Chess/blob/330c03b6f9e730e93657b65be69e29046e5f37bc/lib/terminal_chess/move.rb#L22-L56
train
at1as/Terminal-Chess
lib/terminal_chess/move.rb
TerminalChess.Move.move_pawn
def move_pawn(p1) col = get_col_from_index(p1) valid = [] # Piece color defines direction of travel. Enemy presence defines # the validity of diagonal movements if Move.color == :red valid << (p1 - 8) if unoccupied?(p1 - 8) valid << (p1 - 7) if piece_color(p1 - 7) == Move....
ruby
def move_pawn(p1) col = get_col_from_index(p1) valid = [] # Piece color defines direction of travel. Enemy presence defines # the validity of diagonal movements if Move.color == :red valid << (p1 - 8) if unoccupied?(p1 - 8) valid << (p1 - 7) if piece_color(p1 - 7) == Move....
[ "def", "move_pawn", "(", "p1", ")", "col", "=", "get_col_from_index", "(", "p1", ")", "valid", "=", "[", "]", "if", "Move", ".", "color", "==", ":red", "valid", "<<", "(", "p1", "-", "8", ")", "if", "unoccupied?", "(", "p1", "-", "8", ")", "valid...
Returns all valid positions a pawn at index p1 can move to
[ "Returns", "all", "valid", "positions", "a", "pawn", "at", "index", "p1", "can", "move", "to" ]
330c03b6f9e730e93657b65be69e29046e5f37bc
https://github.com/at1as/Terminal-Chess/blob/330c03b6f9e730e93657b65be69e29046e5f37bc/lib/terminal_chess/move.rb#L59-L81
train
at1as/Terminal-Chess
lib/terminal_chess/move.rb
TerminalChess.Move.move_knight
def move_knight(p1) row = get_row_from_index(p1) col = get_col_from_index(p1) valid = [] valid_moves_no_friendly_fire = [] # Valid knight moves based on its board position valid << (p1 + 17) if row < 7 && col < 8 valid << (p1 + 15) if row < 7 && col > 1 valid << (p1 + 1...
ruby
def move_knight(p1) row = get_row_from_index(p1) col = get_col_from_index(p1) valid = [] valid_moves_no_friendly_fire = [] # Valid knight moves based on its board position valid << (p1 + 17) if row < 7 && col < 8 valid << (p1 + 15) if row < 7 && col > 1 valid << (p1 + 1...
[ "def", "move_knight", "(", "p1", ")", "row", "=", "get_row_from_index", "(", "p1", ")", "col", "=", "get_col_from_index", "(", "p1", ")", "valid", "=", "[", "]", "valid_moves_no_friendly_fire", "=", "[", "]", "valid", "<<", "(", "p1", "+", "17", ")", "...
Returns valid positions a knight at index p1 can move to
[ "Returns", "valid", "positions", "a", "knight", "at", "index", "p1", "can", "move", "to" ]
330c03b6f9e730e93657b65be69e29046e5f37bc
https://github.com/at1as/Terminal-Chess/blob/330c03b6f9e730e93657b65be69e29046e5f37bc/lib/terminal_chess/move.rb#L84-L108
train
jgoizueta/acts_as_scd
lib/acts_as_scd/class_methods.rb
ActsAsScd.ClassMethods.find_by_identity
def find_by_identity(identity, at_date=nil) # (at_date.nil? ? current : at(at_date)).where(IDENTITY_COLUMN=>identity).first if at_date.nil? q = current else q = at(at_date) end q = q.where(IDENTITY_COLUMN=>identity) q.first end
ruby
def find_by_identity(identity, at_date=nil) # (at_date.nil? ? current : at(at_date)).where(IDENTITY_COLUMN=>identity).first if at_date.nil? q = current else q = at(at_date) end q = q.where(IDENTITY_COLUMN=>identity) q.first end
[ "def", "find_by_identity", "(", "identity", ",", "at_date", "=", "nil", ")", "if", "at_date", ".", "nil?", "q", "=", "current", "else", "q", "=", "at", "(", "at_date", ")", "end", "q", "=", "q", ".", "where", "(", "IDENTITY_COLUMN", "=>", "identity", ...
Note that find_by_identity will return nil if there's not a current iteration of the identity
[ "Note", "that", "find_by_identity", "will", "return", "nil", "if", "there", "s", "not", "a", "current", "iteration", "of", "the", "identity" ]
29d01a673e24d42d2471f5b8e6f6fa92d82d6bda
https://github.com/jgoizueta/acts_as_scd/blob/29d01a673e24d42d2471f5b8e6f6fa92d82d6bda/lib/acts_as_scd/class_methods.rb#L60-L69
train
jgoizueta/acts_as_scd
lib/acts_as_scd/class_methods.rb
ActsAsScd.ClassMethods.create_identity
def create_identity(attributes, start=nil) start ||= START_OF_TIME create(attributes.merge(START_COLUMN=>start || START_OF_TIME)) end
ruby
def create_identity(attributes, start=nil) start ||= START_OF_TIME create(attributes.merge(START_COLUMN=>start || START_OF_TIME)) end
[ "def", "create_identity", "(", "attributes", ",", "start", "=", "nil", ")", "start", "||=", "START_OF_TIME", "create", "(", "attributes", ".", "merge", "(", "START_COLUMN", "=>", "start", "||", "START_OF_TIME", ")", ")", "end" ]
The first iteration can be defined with a specific start date, but that is in general a bad idea, since it complicates obtaining the first iteration
[ "The", "first", "iteration", "can", "be", "defined", "with", "a", "specific", "start", "date", "but", "that", "is", "in", "general", "a", "bad", "idea", "since", "it", "complicates", "obtaining", "the", "first", "iteration" ]
29d01a673e24d42d2471f5b8e6f6fa92d82d6bda
https://github.com/jgoizueta/acts_as_scd/blob/29d01a673e24d42d2471f5b8e6f6fa92d82d6bda/lib/acts_as_scd/class_methods.rb#L78-L81
train
mikemackintosh/ruby-easyrsa
lib/easyrsa/ca.rb
EasyRSA.CA.gen_issuer
def gen_issuer name = "/C=#{EasyRSA::Config.country}" name += "/ST=#{EasyRSA::Config.state}" unless !EasyRSA::Config.state || EasyRSA::Config.state.empty? name += "/L=#{EasyRSA::Config.city}" name += "/O=#{EasyRSA::Config.company}" name += "/OU=#{EasyRSA::Config.orgunit}" ...
ruby
def gen_issuer name = "/C=#{EasyRSA::Config.country}" name += "/ST=#{EasyRSA::Config.state}" unless !EasyRSA::Config.state || EasyRSA::Config.state.empty? name += "/L=#{EasyRSA::Config.city}" name += "/O=#{EasyRSA::Config.company}" name += "/OU=#{EasyRSA::Config.orgunit}" ...
[ "def", "gen_issuer", "name", "=", "\"/C=#{EasyRSA::Config.country}\"", "name", "+=", "\"/ST=#{EasyRSA::Config.state}\"", "unless", "!", "EasyRSA", "::", "Config", ".", "state", "||", "EasyRSA", "::", "Config", ".", "state", ".", "empty?", "name", "+=", "\"/L=#{EasyR...
Cert issuer details
[ "Cert", "issuer", "details" ]
a3ae2d420454e04f0c75e1a4e54caa7cda6fe29a
https://github.com/mikemackintosh/ruby-easyrsa/blob/a3ae2d420454e04f0c75e1a4e54caa7cda6fe29a/lib/easyrsa/ca.rb#L71-L83
train
mikemackintosh/ruby-easyrsa
lib/easyrsa/ca.rb
EasyRSA.CA.add_extensions
def add_extensions ef = OpenSSL::X509::ExtensionFactory.new ef.subject_certificate = @ca_cert ef.issuer_certificate = @ca_cert @ca_cert.add_extension ef.create_extension('subjectKeyIdentifier', 'hash') @ca_cert.add_extension ef.create_extension('basicConstraints', 'CA:TRUE', tru...
ruby
def add_extensions ef = OpenSSL::X509::ExtensionFactory.new ef.subject_certificate = @ca_cert ef.issuer_certificate = @ca_cert @ca_cert.add_extension ef.create_extension('subjectKeyIdentifier', 'hash') @ca_cert.add_extension ef.create_extension('basicConstraints', 'CA:TRUE', tru...
[ "def", "add_extensions", "ef", "=", "OpenSSL", "::", "X509", "::", "ExtensionFactory", ".", "new", "ef", ".", "subject_certificate", "=", "@ca_cert", "ef", ".", "issuer_certificate", "=", "@ca_cert", "@ca_cert", ".", "add_extension", "ef", ".", "create_extension",...
Add Extensions needed
[ "Add", "Extensions", "needed" ]
a3ae2d420454e04f0c75e1a4e54caa7cda6fe29a
https://github.com/mikemackintosh/ruby-easyrsa/blob/a3ae2d420454e04f0c75e1a4e54caa7cda6fe29a/lib/easyrsa/ca.rb#L86-L95
train
arkes/sorting_table_for
lib/sorting_table_for/table_builder.rb
SortingTableFor.TableBuilder.render_tbody
def render_tbody if @lines and @lines.size > 0 return Tools::html_safe(content_tag(:tbody, render_total_entries + Tools::html_safe(@lines.collect { |line| line.render_line }.join))) return Tools::html_safe(content_tag(:tr, content_tag(:td, I18n.t(:total_entries, :scope => :sorting_table_for, :valu...
ruby
def render_tbody if @lines and @lines.size > 0 return Tools::html_safe(content_tag(:tbody, render_total_entries + Tools::html_safe(@lines.collect { |line| line.render_line }.join))) return Tools::html_safe(content_tag(:tr, content_tag(:td, I18n.t(:total_entries, :scope => :sorting_table_for, :valu...
[ "def", "render_tbody", "if", "@lines", "and", "@lines", ".", "size", ">", "0", "return", "Tools", "::", "html_safe", "(", "content_tag", "(", ":tbody", ",", "render_total_entries", "+", "Tools", "::", "html_safe", "(", "@lines", ".", "collect", "{", "|", "...
Return the balise tbody and its content
[ "Return", "the", "balise", "tbody", "and", "its", "content" ]
cfc41f033ed1babd9b3536cd63ef854eafb6e94e
https://github.com/arkes/sorting_table_for/blob/cfc41f033ed1babd9b3536cd63ef854eafb6e94e/lib/sorting_table_for/table_builder.rb#L599-L605
train
arkes/sorting_table_for
lib/sorting_table_for/table_builder.rb
SortingTableFor.TableBuilder.render_total_entries
def render_total_entries if self.show_total_entries total_entries = @collection.total_entries rescue @collection.size header_total_cells = @header_line ? @header_line.total_cells : 0 max_cells = (@lines.first.total_cells > header_total_cells) ? @lines.first.total_cells : header_total_cells...
ruby
def render_total_entries if self.show_total_entries total_entries = @collection.total_entries rescue @collection.size header_total_cells = @header_line ? @header_line.total_cells : 0 max_cells = (@lines.first.total_cells > header_total_cells) ? @lines.first.total_cells : header_total_cells...
[ "def", "render_total_entries", "if", "self", ".", "show_total_entries", "total_entries", "=", "@collection", ".", "total_entries", "rescue", "@collection", ".", "size", "header_total_cells", "=", "@header_line", "?", "@header_line", ".", "total_cells", ":", "0", "max_...
Calculate the total entries Return a tr and td with a colspan of total entries
[ "Calculate", "the", "total", "entries", "Return", "a", "tr", "and", "td", "with", "a", "colspan", "of", "total", "entries" ]
cfc41f033ed1babd9b3536cd63ef854eafb6e94e
https://github.com/arkes/sorting_table_for/blob/cfc41f033ed1babd9b3536cd63ef854eafb6e94e/lib/sorting_table_for/table_builder.rb#L627-L635
train
dpla/KriKri
lib/krikri/search_index.rb
Krikri.SearchIndex.bulk_update_from_activity
def bulk_update_from_activity(activity) all_aggs = entities_as_json_hashes(activity) agg_batches = bulk_update_batches(all_aggs) agg_batches.each do |batch| index_with_error_handling(activity) { bulk_add(batch) } end end
ruby
def bulk_update_from_activity(activity) all_aggs = entities_as_json_hashes(activity) agg_batches = bulk_update_batches(all_aggs) agg_batches.each do |batch| index_with_error_handling(activity) { bulk_add(batch) } end end
[ "def", "bulk_update_from_activity", "(", "activity", ")", "all_aggs", "=", "entities_as_json_hashes", "(", "activity", ")", "agg_batches", "=", "bulk_update_batches", "(", "all_aggs", ")", "agg_batches", ".", "each", "do", "|", "batch", "|", "index_with_error_handling...
Given an activity, use the bulk-update method to load its revised entities into the search index. Any errors on bulk adds are caught and logged, and the batch is skipped. @param activity [Krikri::Activity]
[ "Given", "an", "activity", "use", "the", "bulk", "-", "update", "method", "to", "load", "its", "revised", "entities", "into", "the", "search", "index", "." ]
0ac26e60ce1bba60caa40263a562796267cf833f
https://github.com/dpla/KriKri/blob/0ac26e60ce1bba60caa40263a562796267cf833f/lib/krikri/search_index.rb#L56-L62
train
dpla/KriKri
lib/krikri/search_index.rb
Krikri.SearchIndex.bulk_update_batches
def bulk_update_batches(aggregations) en = Enumerator.new do |e| i = 1 batch = [] aggregations.each do |agg| batch << agg if i % @bulk_update_size == 0 e.yield batch batch = [] end i += 1 end e.yield batch if b...
ruby
def bulk_update_batches(aggregations) en = Enumerator.new do |e| i = 1 batch = [] aggregations.each do |agg| batch << agg if i % @bulk_update_size == 0 e.yield batch batch = [] end i += 1 end e.yield batch if b...
[ "def", "bulk_update_batches", "(", "aggregations", ")", "en", "=", "Enumerator", ".", "new", "do", "|", "e", "|", "i", "=", "1", "batch", "=", "[", "]", "aggregations", ".", "each", "do", "|", "agg", "|", "batch", "<<", "agg", "if", "i", "%", "@bul...
Enumerate arrays of JSON strings, one array per batch that is supposed to be loaded into the search index. @param aggregations [Enumerator] @return [Enumerator] Each array of JSON strings
[ "Enumerate", "arrays", "of", "JSON", "strings", "one", "array", "per", "batch", "that", "is", "supposed", "to", "be", "loaded", "into", "the", "search", "index", "." ]
0ac26e60ce1bba60caa40263a562796267cf833f
https://github.com/dpla/KriKri/blob/0ac26e60ce1bba60caa40263a562796267cf833f/lib/krikri/search_index.rb#L70-L85
train
dpla/KriKri
lib/krikri/search_index.rb
Krikri.SearchIndex.incremental_update_from_activity
def incremental_update_from_activity(activity) entities_as_json_hashes(activity).each do |h| index_with_error_handling(activity) { add(h) } end end
ruby
def incremental_update_from_activity(activity) entities_as_json_hashes(activity).each do |h| index_with_error_handling(activity) { add(h) } end end
[ "def", "incremental_update_from_activity", "(", "activity", ")", "entities_as_json_hashes", "(", "activity", ")", ".", "each", "do", "|", "h", "|", "index_with_error_handling", "(", "activity", ")", "{", "add", "(", "h", ")", "}", "end", "end" ]
Given an activity, load its revised entities into the search index one at a time. Any errors on individual record adds are caught and logged, and the record is skipped. @param activity [Krikri::Activity]
[ "Given", "an", "activity", "load", "its", "revised", "entities", "into", "the", "search", "index", "one", "at", "a", "time", "." ]
0ac26e60ce1bba60caa40263a562796267cf833f
https://github.com/dpla/KriKri/blob/0ac26e60ce1bba60caa40263a562796267cf833f/lib/krikri/search_index.rb#L95-L99
train
dpla/KriKri
lib/krikri/search_index.rb
Krikri.QASearchIndex.schema_keys
def schema_keys schema_file = File.join(Rails.root, 'solr_conf', 'schema.xml') file = File.open(schema_file) doc = Nokogiri::XML(file) file.close doc.xpath('//fields/field').map { |f| f.attr('name') } end
ruby
def schema_keys schema_file = File.join(Rails.root, 'solr_conf', 'schema.xml') file = File.open(schema_file) doc = Nokogiri::XML(file) file.close doc.xpath('//fields/field').map { |f| f.attr('name') } end
[ "def", "schema_keys", "schema_file", "=", "File", ".", "join", "(", "Rails", ".", "root", ",", "'solr_conf'", ",", "'schema.xml'", ")", "file", "=", "File", ".", "open", "(", "schema_file", ")", "doc", "=", "Nokogiri", "::", "XML", "(", "file", ")", "f...
Get field names from Solr schema in host application. Will raise exception if file not found. @return [Array]
[ "Get", "field", "names", "from", "Solr", "schema", "in", "host", "application", ".", "Will", "raise", "exception", "if", "file", "not", "found", "." ]
0ac26e60ce1bba60caa40263a562796267cf833f
https://github.com/dpla/KriKri/blob/0ac26e60ce1bba60caa40263a562796267cf833f/lib/krikri/search_index.rb#L230-L236
train
dpla/KriKri
lib/krikri/search_index.rb
Krikri.QASearchIndex.flat_hash
def flat_hash(hash, keys = []) new_hash = {} hash.each do |key, val| new_hash[format_key(keys + [key])] = val unless val.is_a?(Array) || val.is_a?(Hash) new_hash.merge!(flat_hash(val, keys + [key])) if val.is_a? Hash if val.is_a? Array val.each do |v| ...
ruby
def flat_hash(hash, keys = []) new_hash = {} hash.each do |key, val| new_hash[format_key(keys + [key])] = val unless val.is_a?(Array) || val.is_a?(Hash) new_hash.merge!(flat_hash(val, keys + [key])) if val.is_a? Hash if val.is_a? Array val.each do |v| ...
[ "def", "flat_hash", "(", "hash", ",", "keys", "=", "[", "]", ")", "new_hash", "=", "{", "}", "hash", ".", "each", "do", "|", "key", ",", "val", "|", "new_hash", "[", "format_key", "(", "keys", "+", "[", "key", "]", ")", "]", "=", "val", "unless...
Flattens a nested hash Joins keys with "_" and removes "@" symbols Example: flat_hash( {"a"=>"1", "b"=>{"c"=>"2", "d"=>"3"} ) => {"a"=>"1", "b_c"=>"2", "b_d"=>"3"}
[ "Flattens", "a", "nested", "hash", "Joins", "keys", "with", "_", "and", "removes" ]
0ac26e60ce1bba60caa40263a562796267cf833f
https://github.com/dpla/KriKri/blob/0ac26e60ce1bba60caa40263a562796267cf833f/lib/krikri/search_index.rb#L246-L270
train
schrodingersbox/meter_cat
lib/meter_cat/calculator.rb
MeterCat.Calculator.dependencies
def dependencies(names) names.each do |name| calculation = fetch(name, nil) next unless calculation calculation.dependencies.each do |dependency| names << dependency unless names.include?(dependency) end end end
ruby
def dependencies(names) names.each do |name| calculation = fetch(name, nil) next unless calculation calculation.dependencies.each do |dependency| names << dependency unless names.include?(dependency) end end end
[ "def", "dependencies", "(", "names", ")", "names", ".", "each", "do", "|", "name", "|", "calculation", "=", "fetch", "(", "name", ",", "nil", ")", "next", "unless", "calculation", "calculation", ".", "dependencies", ".", "each", "do", "|", "dependency", ...
Add any missing names required for calculations that are named
[ "Add", "any", "missing", "names", "required", "for", "calculations", "that", "are", "named" ]
b20d579749ef2facbf3b308d4fb39215a7eac2a1
https://github.com/schrodingersbox/meter_cat/blob/b20d579749ef2facbf3b308d4fb39215a7eac2a1/lib/meter_cat/calculator.rb#L31-L40
train
dpla/KriKri
lib/krikri/harvesters/couchdb_harvester.rb
Krikri::Harvesters.CouchdbHarvester.count
def count(opts = {}) view = opts[:view] || @opts[:view] # The count that we want is the total documents in the database minus # CouchDB design documents. Asking for the design documents will give us # the total count in addition to letting us determine the number of # design documents. ...
ruby
def count(opts = {}) view = opts[:view] || @opts[:view] # The count that we want is the total documents in the database minus # CouchDB design documents. Asking for the design documents will give us # the total count in addition to letting us determine the number of # design documents. ...
[ "def", "count", "(", "opts", "=", "{", "}", ")", "view", "=", "opts", "[", ":view", "]", "||", "@opts", "[", ":view", "]", "v", "=", "client", ".", "view", "(", "view", ",", "include_docs", ":", "false", ",", "stream", ":", "false", ",", "startke...
Return the total number of documents reported by a CouchDB view. @param opts [Hash] Analysand::Database#view options - view: database view name @return [Fixnum]
[ "Return", "the", "total", "number", "of", "documents", "reported", "by", "a", "CouchDB", "view", "." ]
0ac26e60ce1bba60caa40263a562796267cf833f
https://github.com/dpla/KriKri/blob/0ac26e60ce1bba60caa40263a562796267cf833f/lib/krikri/harvesters/couchdb_harvester.rb#L54-L68
train
dpla/KriKri
lib/krikri/harvesters/couchdb_harvester.rb
Krikri::Harvesters.CouchdbHarvester.records
def records(opts = {}) view = opts[:view] || @opts[:view] limit = opts[:limit] || @opts[:limit] record_rows(view, limit).map do |row| @record_class.build( mint_id(row['doc']['_id']), row['doc'].to_json, 'application/json' ) end end
ruby
def records(opts = {}) view = opts[:view] || @opts[:view] limit = opts[:limit] || @opts[:limit] record_rows(view, limit).map do |row| @record_class.build( mint_id(row['doc']['_id']), row['doc'].to_json, 'application/json' ) end end
[ "def", "records", "(", "opts", "=", "{", "}", ")", "view", "=", "opts", "[", ":view", "]", "||", "@opts", "[", ":view", "]", "limit", "=", "opts", "[", ":limit", "]", "||", "@opts", "[", ":limit", "]", "record_rows", "(", "view", ",", "limit", ")...
Makes requests to a CouchDB view to yield documents. The following will only send requests to the endpoint until it has 1000 records: records.take(1000) Batches of records are requested, in order to avoid using `Analysand::StreamingViewResponse`, and the CouchDB `startkey` parameter is used for greater eff...
[ "Makes", "requests", "to", "a", "CouchDB", "view", "to", "yield", "documents", "." ]
0ac26e60ce1bba60caa40263a562796267cf833f
https://github.com/dpla/KriKri/blob/0ac26e60ce1bba60caa40263a562796267cf833f/lib/krikri/harvesters/couchdb_harvester.rb#L86-L96
train
dpla/KriKri
lib/krikri/harvesters/couchdb_harvester.rb
Krikri::Harvesters.CouchdbHarvester.record_rows
def record_rows(view, limit) en = Enumerator.new do |e| view_opts = {include_docs: true, stream: false, limit: limit} rows_retrieved = 0 total_rows = nil loop do v = client.view(view, view_opts) total_rows ||= v.total_rows rows_retrieved += v.rows.size...
ruby
def record_rows(view, limit) en = Enumerator.new do |e| view_opts = {include_docs: true, stream: false, limit: limit} rows_retrieved = 0 total_rows = nil loop do v = client.view(view, view_opts) total_rows ||= v.total_rows rows_retrieved += v.rows.size...
[ "def", "record_rows", "(", "view", ",", "limit", ")", "en", "=", "Enumerator", ".", "new", "do", "|", "e", "|", "view_opts", "=", "{", "include_docs", ":", "true", ",", "stream", ":", "false", ",", "limit", ":", "limit", "}", "rows_retrieved", "=", "...
Return an enumerator that provides individual records from batched view requests. @return [Enumerator] @see #records
[ "Return", "an", "enumerator", "that", "provides", "individual", "records", "from", "batched", "view", "requests", "." ]
0ac26e60ce1bba60caa40263a562796267cf833f
https://github.com/dpla/KriKri/blob/0ac26e60ce1bba60caa40263a562796267cf833f/lib/krikri/harvesters/couchdb_harvester.rb#L104-L122
train
dpla/KriKri
lib/krikri/harvesters/couchdb_harvester.rb
Krikri::Harvesters.CouchdbHarvester.get_record
def get_record(identifier) doc = client.get!(CGI.escape(identifier)).body.to_json @record_class.build(mint_id(identifier), doc, 'application/json') end
ruby
def get_record(identifier) doc = client.get!(CGI.escape(identifier)).body.to_json @record_class.build(mint_id(identifier), doc, 'application/json') end
[ "def", "get_record", "(", "identifier", ")", "doc", "=", "client", ".", "get!", "(", "CGI", ".", "escape", "(", "identifier", ")", ")", ".", "body", ".", "to_json", "@record_class", ".", "build", "(", "mint_id", "(", "identifier", ")", ",", "doc", ",",...
Retrieves a specific document from CouchDB. Uses Analysand::Database#get!, which raises an exception if the document cannot be found. @see Analysand::Database#get!
[ "Retrieves", "a", "specific", "document", "from", "CouchDB", "." ]
0ac26e60ce1bba60caa40263a562796267cf833f
https://github.com/dpla/KriKri/blob/0ac26e60ce1bba60caa40263a562796267cf833f/lib/krikri/harvesters/couchdb_harvester.rb#L131-L134
train
aashishgarg/simple_notifications
lib/simple_notifications/base.rb
SimpleNotifications.Base.open_receiver_class
def open_receiver_class # Define association for receiver model [receivers_class(@@options[:receivers])].flatten.each do |base| base.class_eval do has_many :deliveries, class_name: 'SimpleNotifications::Delivery', as: :receiver has_many :received_notifications, through: :deliveri...
ruby
def open_receiver_class # Define association for receiver model [receivers_class(@@options[:receivers])].flatten.each do |base| base.class_eval do has_many :deliveries, class_name: 'SimpleNotifications::Delivery', as: :receiver has_many :received_notifications, through: :deliveri...
[ "def", "open_receiver_class", "[", "receivers_class", "(", "@@options", "[", ":receivers", "]", ")", "]", ".", "flatten", ".", "each", "do", "|", "base", "|", "base", ".", "class_eval", "do", "has_many", ":deliveries", ",", "class_name", ":", "'SimpleNotificat...
Opening the classes which are defined as receivers.
[ "Opening", "the", "classes", "which", "are", "defined", "as", "receivers", "." ]
e804f5c127fb72d61262e8c1cc4110d69f039b2f
https://github.com/aashishgarg/simple_notifications/blob/e804f5c127fb72d61262e8c1cc4110d69f039b2f/lib/simple_notifications/base.rb#L36-L44
train
aashishgarg/simple_notifications
lib/simple_notifications/base.rb
SimpleNotifications.Base.sender_class
def sender_class(sender) if sender.kind_of? Symbol reflections[sender.to_s].klass elsif sender.kind_of? ActiveRecord::Base sender.class else raise 'SimpleNotifications::SenderTypeError' end end
ruby
def sender_class(sender) if sender.kind_of? Symbol reflections[sender.to_s].klass elsif sender.kind_of? ActiveRecord::Base sender.class else raise 'SimpleNotifications::SenderTypeError' end end
[ "def", "sender_class", "(", "sender", ")", "if", "sender", ".", "kind_of?", "Symbol", "reflections", "[", "sender", ".", "to_s", "]", ".", "klass", "elsif", "sender", ".", "kind_of?", "ActiveRecord", "::", "Base", "sender", ".", "class", "else", "raise", "...
Provides the class of Sender
[ "Provides", "the", "class", "of", "Sender" ]
e804f5c127fb72d61262e8c1cc4110d69f039b2f
https://github.com/aashishgarg/simple_notifications/blob/e804f5c127fb72d61262e8c1cc4110d69f039b2f/lib/simple_notifications/base.rb#L168-L176
train
aashishgarg/simple_notifications
lib/simple_notifications/base.rb
SimpleNotifications.Base.receivers_class
def receivers_class(receivers) if receivers.kind_of? Symbol reflections[receivers.to_s].klass else if receivers.kind_of? ActiveRecord::Base receivers.class elsif receivers.kind_of? ActiveRecord::Relation receivers.klass elsif receivers.kind_of? Array ...
ruby
def receivers_class(receivers) if receivers.kind_of? Symbol reflections[receivers.to_s].klass else if receivers.kind_of? ActiveRecord::Base receivers.class elsif receivers.kind_of? ActiveRecord::Relation receivers.klass elsif receivers.kind_of? Array ...
[ "def", "receivers_class", "(", "receivers", ")", "if", "receivers", ".", "kind_of?", "Symbol", "reflections", "[", "receivers", ".", "to_s", "]", ".", "klass", "else", "if", "receivers", ".", "kind_of?", "ActiveRecord", "::", "Base", "receivers", ".", "class",...
Provides the classes of Receivers
[ "Provides", "the", "classes", "of", "Receivers" ]
e804f5c127fb72d61262e8c1cc4110d69f039b2f
https://github.com/aashishgarg/simple_notifications/blob/e804f5c127fb72d61262e8c1cc4110d69f039b2f/lib/simple_notifications/base.rb#L179-L193
train
dpla/KriKri
lib/krikri/harvesters/api_harvester.rb
Krikri::Harvesters.ApiHarvester.next_options
def next_options(opts, record_count) old_start = opts['params'].fetch('start', 0) opts['params']['start'] = old_start.to_i + record_count opts end
ruby
def next_options(opts, record_count) old_start = opts['params'].fetch('start', 0) opts['params']['start'] = old_start.to_i + record_count opts end
[ "def", "next_options", "(", "opts", ",", "record_count", ")", "old_start", "=", "opts", "[", "'params'", "]", ".", "fetch", "(", "'start'", ",", "0", ")", "opts", "[", "'params'", "]", "[", "'start'", "]", "=", "old_start", ".", "to_i", "+", "record_co...
Given a current set of options and a number of records from the last request, generate the options for the next request. @param opts [Hash] an options hash from the previous request @param record_count [#to_i] @return [Hash] the next request's options hash
[ "Given", "a", "current", "set", "of", "options", "and", "a", "number", "of", "records", "from", "the", "last", "request", "generate", "the", "options", "for", "the", "next", "request", "." ]
0ac26e60ce1bba60caa40263a562796267cf833f
https://github.com/dpla/KriKri/blob/0ac26e60ce1bba60caa40263a562796267cf833f/lib/krikri/harvesters/api_harvester.rb#L128-L132
train
12spokes/tandem
app/models/tandem/page.rb
Tandem.Page.do_before_validation
def do_before_validation prim_slug, i = slug, 0 prim_slug, i = $1, $2.to_i if slug =~ /^(.*)_([0-9]+)$/ return unless prim_slug.present? attempts = 0 conditions = new_record? ? ['slug = ?',slug] : ['slug = ? AND id != ?',slug,id] conditions[1] = "#{prim_slug}_#{i+=1}" while Page.wh...
ruby
def do_before_validation prim_slug, i = slug, 0 prim_slug, i = $1, $2.to_i if slug =~ /^(.*)_([0-9]+)$/ return unless prim_slug.present? attempts = 0 conditions = new_record? ? ['slug = ?',slug] : ['slug = ? AND id != ?',slug,id] conditions[1] = "#{prim_slug}_#{i+=1}" while Page.wh...
[ "def", "do_before_validation", "prim_slug", ",", "i", "=", "slug", ",", "0", "prim_slug", ",", "i", "=", "$1", ",", "$2", ".", "to_i", "if", "slug", "=~", "/", "/", "return", "unless", "prim_slug", ".", "present?", "attempts", "=", "0", "conditions", "...
auto increment slug until it is unique
[ "auto", "increment", "slug", "until", "it", "is", "unique" ]
6ad1cd041158c721c84a8c27809c1ddac1dbf6ce
https://github.com/12spokes/tandem/blob/6ad1cd041158c721c84a8c27809c1ddac1dbf6ce/app/models/tandem/page.rb#L25-L35
train
conjurinc/conjur-asset-policy
lib/conjur/policy/executor/create.rb
Conjur::Policy::Executor.CreateRecord.create_parameters
def create_parameters { record.id_attribute => record.id }.tap do |params| custom_attrs = attribute_names.inject({}) do |memo, attr| value = record.send(attr) memo[attr.to_s] = value if value memo end params.merge! custom_attrs params["ow...
ruby
def create_parameters { record.id_attribute => record.id }.tap do |params| custom_attrs = attribute_names.inject({}) do |memo, attr| value = record.send(attr) memo[attr.to_s] = value if value memo end params.merge! custom_attrs params["ow...
[ "def", "create_parameters", "{", "record", ".", "id_attribute", "=>", "record", ".", "id", "}", ".", "tap", "do", "|", "params", "|", "custom_attrs", "=", "attribute_names", ".", "inject", "(", "{", "}", ")", "do", "|", "memo", ",", "attr", "|", "value...
Each record is assumed to have an 'id' attribute required for creation. In addition, other create parameters can be specified by the +custom_attribute_names+ method on the record.
[ "Each", "record", "is", "assumed", "to", "have", "an", "id", "attribute", "required", "for", "creation", ".", "In", "addition", "other", "create", "parameters", "can", "be", "specified", "by", "the", "+", "custom_attribute_names", "+", "method", "on", "the", ...
c7672cf99aea2c3c6f0699be94018834d35ad7f0
https://github.com/conjurinc/conjur-asset-policy/blob/c7672cf99aea2c3c6f0699be94018834d35ad7f0/lib/conjur/policy/executor/create.rb#L37-L49
train
stormbrew/http_parser
lib/http/native_parser.rb
Http.NativeParser.fill_rack_env
def fill_rack_env(env = {}) env["rack.input"] = @body || StringIO.new env["REQUEST_METHOD"] = @method env["SCRIPT_NAME"] = "" env["REQUEST_URI"] = @path env["PATH_INFO"], query = @path.split("?", 2) env["QUERY_STRING"] = query || "" if (@headers["HOST"] && !env["SERVER_NAME"]) ...
ruby
def fill_rack_env(env = {}) env["rack.input"] = @body || StringIO.new env["REQUEST_METHOD"] = @method env["SCRIPT_NAME"] = "" env["REQUEST_URI"] = @path env["PATH_INFO"], query = @path.split("?", 2) env["QUERY_STRING"] = query || "" if (@headers["HOST"] && !env["SERVER_NAME"]) ...
[ "def", "fill_rack_env", "(", "env", "=", "{", "}", ")", "env", "[", "\"rack.input\"", "]", "=", "@body", "||", "StringIO", ".", "new", "env", "[", "\"REQUEST_METHOD\"", "]", "=", "@method", "env", "[", "\"SCRIPT_NAME\"", "]", "=", "\"\"", "env", "[", "...
Given a basic rack environment, will properly fill it in with the information gleaned from the parsed request. Note that this only fills the subset that can be determined by the parser library. Namely, the only rack. variable set is rack.input. You should also have defaults in place for SERVER_NAME and SERVER_PORT,...
[ "Given", "a", "basic", "rack", "environment", "will", "properly", "fill", "it", "in", "with", "the", "information", "gleaned", "from", "the", "parsed", "request", ".", "Note", "that", "this", "only", "fills", "the", "subset", "that", "can", "be", "determined...
b2b0e755b075e7f92286017f0303f83e6d59063d
https://github.com/stormbrew/http_parser/blob/b2b0e755b075e7f92286017f0303f83e6d59063d/lib/http/native_parser.rb#L295-L314
train
outcomesinsights/sequelizer
lib/sequelizer/monkey_patches/database_in_after_connect.rb
Sequel.ConnectionPool.make_new
def make_new(server) begin conn = @db.connect(server) if ac = @after_connect case ac.arity when 3 ac.call(conn, server, @db) when 2 ac.call(conn, server) else ac.call(conn) end end rescue Exception=...
ruby
def make_new(server) begin conn = @db.connect(server) if ac = @after_connect case ac.arity when 3 ac.call(conn, server, @db) when 2 ac.call(conn, server) else ac.call(conn) end end rescue Exception=...
[ "def", "make_new", "(", "server", ")", "begin", "conn", "=", "@db", ".", "connect", "(", "server", ")", "if", "ac", "=", "@after_connect", "case", "ac", ".", "arity", "when", "3", "ac", ".", "call", "(", "conn", ",", "server", ",", "@db", ")", "whe...
Return a new connection by calling the connection proc with the given server name, and checking for connection errors.
[ "Return", "a", "new", "connection", "by", "calling", "the", "connection", "proc", "with", "the", "given", "server", "name", "and", "checking", "for", "connection", "errors", "." ]
2a8b4a78410b1cf82ec19b45afdb4f65629b2ce2
https://github.com/outcomesinsights/sequelizer/blob/2a8b4a78410b1cf82ec19b45afdb4f65629b2ce2/lib/sequelizer/monkey_patches/database_in_after_connect.rb#L5-L23
train
dpla/KriKri
lib/krikri/async_uri_getter.rb
Krikri.AsyncUriGetter.add_request
def add_request(uri: nil, headers: {}, opts: {}) fail ArgumentError, "uri must be a URI; got: #{uri}" unless uri.is_a?(URI) Request.new(uri, headers, @default_opts.merge(opts)) end
ruby
def add_request(uri: nil, headers: {}, opts: {}) fail ArgumentError, "uri must be a URI; got: #{uri}" unless uri.is_a?(URI) Request.new(uri, headers, @default_opts.merge(opts)) end
[ "def", "add_request", "(", "uri", ":", "nil", ",", "headers", ":", "{", "}", ",", "opts", ":", "{", "}", ")", "fail", "ArgumentError", ",", "\"uri must be a URI; got: #{uri}\"", "unless", "uri", ".", "is_a?", "(", "URI", ")", "Request", ".", "new", "(", ...
Create a new asynchronous URL fetcher. @param opts [Hash] a hash of the supported options, which are: @option opts [Boolean] :follow_redirects Whether to follow HTTP 3xx redirects. @option opts [Integer] :max_redirects Number of redirects to follow before giving up. (default: 10) @option opts [Boolean] :inl...
[ "Create", "a", "new", "asynchronous", "URL", "fetcher", "." ]
0ac26e60ce1bba60caa40263a562796267cf833f
https://github.com/dpla/KriKri/blob/0ac26e60ce1bba60caa40263a562796267cf833f/lib/krikri/async_uri_getter.rb#L70-L73
train
chackoantony/exportable
lib/exportable/utils.rb
Exportable.Utils.get_export_options
def get_export_options(model, options) default_options = { only: model.attribute_names.map(&:to_sym), except: [], methods: [], header: true } options = default_options.merge(options) unless options[:only].is_a?(Array) && opt...
ruby
def get_export_options(model, options) default_options = { only: model.attribute_names.map(&:to_sym), except: [], methods: [], header: true } options = default_options.merge(options) unless options[:only].is_a?(Array) && opt...
[ "def", "get_export_options", "(", "model", ",", "options", ")", "default_options", "=", "{", "only", ":", "model", ".", "attribute_names", ".", "map", "(", "&", ":to_sym", ")", ",", "except", ":", "[", "]", ",", "methods", ":", "[", "]", ",", "header",...
Compute exportable options after overriding preferences
[ "Compute", "exportable", "options", "after", "overriding", "preferences" ]
fcfebfc80aa6a2c6f746dde23c4707dd289f76ff
https://github.com/chackoantony/exportable/blob/fcfebfc80aa6a2c6f746dde23c4707dd289f76ff/lib/exportable/utils.rb#L5-L16
train
jntullo/ruby-docker-cloud
lib/docker_cloud/api/node_type_api.rb
DockerCloud.NodeTypeAPI.get
def get(provider_name, node_type_name) name = "#{provider_name}/#{node_type_name}/" response = http_get(resource_url(name)) format_object(response, TYPE) end
ruby
def get(provider_name, node_type_name) name = "#{provider_name}/#{node_type_name}/" response = http_get(resource_url(name)) format_object(response, TYPE) end
[ "def", "get", "(", "provider_name", ",", "node_type_name", ")", "name", "=", "\"#{provider_name}/#{node_type_name}/\"", "response", "=", "http_get", "(", "resource_url", "(", "name", ")", ")", "format_object", "(", "response", ",", "TYPE", ")", "end" ]
Returns the details of a specific NodeType
[ "Returns", "the", "details", "of", "a", "specific", "NodeType" ]
ced8b8a7d7ed0fff2c158a555d0299cd27860721
https://github.com/jntullo/ruby-docker-cloud/blob/ced8b8a7d7ed0fff2c158a555d0299cd27860721/lib/docker_cloud/api/node_type_api.rb#L17-L21
train
Losant/losant-rest-ruby
lib/losant_rest/application_keys.rb
LosantRest.ApplicationKeys.get
def get(params = {}) params = Utils.symbolize_hash_keys(params) query_params = { _actions: false, _links: true, _embedded: true } headers = {} body = nil raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId) query_params[:sortField] = params[:s...
ruby
def get(params = {}) params = Utils.symbolize_hash_keys(params) query_params = { _actions: false, _links: true, _embedded: true } headers = {} body = nil raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId) query_params[:sortField] = params[:s...
[ "def", "get", "(", "params", "=", "{", "}", ")", "params", "=", "Utils", ".", "symbolize_hash_keys", "(", "params", ")", "query_params", "=", "{", "_actions", ":", "false", ",", "_links", ":", "true", ",", "_embedded", ":", "true", "}", "headers", "=",...
Returns the applicationKeys for an application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, appl...
[ "Returns", "the", "applicationKeys", "for", "an", "application" ]
4a66a70180a0d907c2e50e1edf06cb8312d00260
https://github.com/Losant/losant-rest-ruby/blob/4a66a70180a0d907c2e50e1edf06cb8312d00260/lib/losant_rest/application_keys.rb#L59-L86
train
Losant/losant-rest-ruby
lib/losant_rest/application_keys.rb
LosantRest.ApplicationKeys.post
def post(params = {}) params = Utils.symbolize_hash_keys(params) query_params = { _actions: false, _links: true, _embedded: true } headers = {} body = nil raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId) raise ArgumentError.new("application...
ruby
def post(params = {}) params = Utils.symbolize_hash_keys(params) query_params = { _actions: false, _links: true, _embedded: true } headers = {} body = nil raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId) raise ArgumentError.new("application...
[ "def", "post", "(", "params", "=", "{", "}", ")", "params", "=", "Utils", ".", "symbolize_hash_keys", "(", "params", ")", "query_params", "=", "{", "_actions", ":", "false", ",", "_links", ":", "true", ",", "_embedded", ":", "true", "}", "headers", "="...
Create a new applicationKey for an application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, applicationKeys.*, or applicationKeys.post. Parameters: * {s...
[ "Create", "a", "new", "applicationKey", "for", "an", "application" ]
4a66a70180a0d907c2e50e1edf06cb8312d00260
https://github.com/Losant/losant-rest-ruby/blob/4a66a70180a0d907c2e50e1edf06cb8312d00260/lib/losant_rest/application_keys.rb#L110-L133
train
culturecode/spatial_features
lib/spatial_features/utils.rb
SpatialFeatures.Utils.class_of
def class_of(object) case object when ActiveRecord::Base object.class when ActiveRecord::Relation object.klass when String object.constantize else object end end
ruby
def class_of(object) case object when ActiveRecord::Base object.class when ActiveRecord::Relation object.klass when String object.constantize else object end end
[ "def", "class_of", "(", "object", ")", "case", "object", "when", "ActiveRecord", "::", "Base", "object", ".", "class", "when", "ActiveRecord", "::", "Relation", "object", ".", "klass", "when", "String", "object", ".", "constantize", "else", "object", "end", ...
Returns the class for the given, class, scope, or record
[ "Returns", "the", "class", "for", "the", "given", "class", "scope", "or", "record" ]
557a4b8a855129dd51a3c2cfcdad8312083fb73a
https://github.com/culturecode/spatial_features/blob/557a4b8a855129dd51a3c2cfcdad8312083fb73a/lib/spatial_features/utils.rb#L13-L24
train
PRX/announce
lib/announce/subscriber.rb
Announce.Subscriber.delegate_event
def delegate_event(event) @message = event.deep_symbolize_keys @subject = message[:subject] @action = message[:action] if [message, subject, action].any? { |a| a.nil? } raise "Message, subject, and action are not all specified for '#{event.inspect}'" end if respond_to?(dele...
ruby
def delegate_event(event) @message = event.deep_symbolize_keys @subject = message[:subject] @action = message[:action] if [message, subject, action].any? { |a| a.nil? } raise "Message, subject, and action are not all specified for '#{event.inspect}'" end if respond_to?(dele...
[ "def", "delegate_event", "(", "event", ")", "@message", "=", "event", ".", "deep_symbolize_keys", "@subject", "=", "message", "[", ":subject", "]", "@action", "=", "message", "[", ":action", "]", "if", "[", "message", ",", "subject", ",", "action", "]", "....
For use in adapters to delegate to method named receive_subject_action
[ "For", "use", "in", "adapters", "to", "delegate", "to", "method", "named", "receive_subject_action" ]
fd9f6707059cf279411348ee4d5c6d1b1c6251d0
https://github.com/PRX/announce/blob/fd9f6707059cf279411348ee4d5c6d1b1c6251d0/lib/announce/subscriber.rb#L23-L37
train
mikemackintosh/ruby-easyrsa
lib/easyrsa/config.rb
EasyRSA.Config.load!
def load!(path) settings = YAML.load(ERB.new(File.new(path).read).result) if settings.present? from_hash(settings) end end
ruby
def load!(path) settings = YAML.load(ERB.new(File.new(path).read).result) if settings.present? from_hash(settings) end end
[ "def", "load!", "(", "path", ")", "settings", "=", "YAML", ".", "load", "(", "ERB", ".", "new", "(", "File", ".", "new", "(", "path", ")", ".", "read", ")", ".", "result", ")", "if", "settings", ".", "present?", "from_hash", "(", "settings", ")", ...
Load the settings from a compliant easyrsa.yml file. This can be used for easy setup with frameworks other than Rails. @example Configure easyrsa. easyrsa.load!("/path/to/easyrsa.yml") @param [ String ] path The path to the file.
[ "Load", "the", "settings", "from", "a", "compliant", "easyrsa", ".", "yml", "file", ".", "This", "can", "be", "used", "for", "easy", "setup", "with", "frameworks", "other", "than", "Rails", "." ]
a3ae2d420454e04f0c75e1a4e54caa7cda6fe29a
https://github.com/mikemackintosh/ruby-easyrsa/blob/a3ae2d420454e04f0c75e1a4e54caa7cda6fe29a/lib/easyrsa/config.rb#L30-L35
train
dpla/KriKri
app/controllers/krikri/records_controller.rb
Krikri.RecordsController.records_by_provider
def records_by_provider(solr_params, user_params) if @provider_id.present? rdf_subject = Krikri::Provider.base_uri + @provider_id solr_params[:fq] ||= [] solr_params[:fq] << "provider_id:\"#{rdf_subject}\"" end end
ruby
def records_by_provider(solr_params, user_params) if @provider_id.present? rdf_subject = Krikri::Provider.base_uri + @provider_id solr_params[:fq] ||= [] solr_params[:fq] << "provider_id:\"#{rdf_subject}\"" end end
[ "def", "records_by_provider", "(", "solr_params", ",", "user_params", ")", "if", "@provider_id", ".", "present?", "rdf_subject", "=", "Krikri", "::", "Provider", ".", "base_uri", "+", "@provider_id", "solr_params", "[", ":fq", "]", "||=", "[", "]", "solr_params"...
Limit the records returned by a Solr request to those belonging to the current provider. @param [Hash] solr_parameters a hash of parameters to be sent to Solr. @param [Hash] user_parameters a hash of user-supplied parameters.
[ "Limit", "the", "records", "returned", "by", "a", "Solr", "request", "to", "those", "belonging", "to", "the", "current", "provider", "." ]
0ac26e60ce1bba60caa40263a562796267cf833f
https://github.com/dpla/KriKri/blob/0ac26e60ce1bba60caa40263a562796267cf833f/app/controllers/krikri/records_controller.rb#L168-L174
train
Esri/geotrigger-ruby
lib/geotrigger/model.rb
Geotrigger.Model.post_list
def post_list models, params = {}, default_params = {} model = models.sub /s$/, '' params = default_params.merge params post(model + '/list', params)[models].map do |data| Geotrigger.const_get(model.capitalize).from_api data, @session end end
ruby
def post_list models, params = {}, default_params = {} model = models.sub /s$/, '' params = default_params.merge params post(model + '/list', params)[models].map do |data| Geotrigger.const_get(model.capitalize).from_api data, @session end end
[ "def", "post_list", "models", ",", "params", "=", "{", "}", ",", "default_params", "=", "{", "}", "model", "=", "models", ".", "sub", "/", "/", ",", "''", "params", "=", "default_params", ".", "merge", "params", "post", "(", "model", "+", "'/list'", ...
Create an instance and from given options +Hash+. [:session] +Session+ underlying session to use when talking to the API POST a request to this model's /list route, passing parameters. Returns a new instance of the model object with populated data via +Model.from_api+. [models] +String+ name of the model to req...
[ "Create", "an", "instance", "and", "from", "given", "options", "+", "Hash", "+", "." ]
41fbac4a25ec43427a51dc235a0dbc158e80ce02
https://github.com/Esri/geotrigger-ruby/blob/41fbac4a25ec43427a51dc235a0dbc158e80ce02/lib/geotrigger/model.rb#L49-L55
train
Esri/geotrigger-ruby
lib/geotrigger/model.rb
Geotrigger.Model.method_missing
def method_missing meth, *args meth_s = meth.to_s if meth_s =~ /=$/ and args.length == 1 key = meth_s.sub(/=$/,'').camelcase if @data and @data.key? key @data[key] = args[0] else super meth, *args end else key = meth_s.camelcase if @d...
ruby
def method_missing meth, *args meth_s = meth.to_s if meth_s =~ /=$/ and args.length == 1 key = meth_s.sub(/=$/,'').camelcase if @data and @data.key? key @data[key] = args[0] else super meth, *args end else key = meth_s.camelcase if @d...
[ "def", "method_missing", "meth", ",", "*", "args", "meth_s", "=", "meth", ".", "to_s", "if", "meth_s", "=~", "/", "/", "and", "args", ".", "length", "==", "1", "key", "=", "meth_s", ".", "sub", "(", "/", "/", ",", "''", ")", ".", "camelcase", "if...
Allows snake_case accessor to top-level data values keyed by their camelCase counterparts. An attempt to be moar Rubyish. device.tracking_profile #=> 'adaptive' device.trackingProfile #=> 'adaptive'
[ "Allows", "snake_case", "accessor", "to", "top", "-", "level", "data", "values", "keyed", "by", "their", "camelCase", "counterparts", ".", "An", "attempt", "to", "be", "moar", "Rubyish", "." ]
41fbac4a25ec43427a51dc235a0dbc158e80ce02
https://github.com/Esri/geotrigger-ruby/blob/41fbac4a25ec43427a51dc235a0dbc158e80ce02/lib/geotrigger/model.rb#L66-L83
train
MYOB-Technology/http_event_logger
lib/http_event_logger/adapter/net_http.rb
Net.HTTP.request_body_from
def request_body_from(req, body) req.body.nil? || req.body.size == 0 ? body : req.body end
ruby
def request_body_from(req, body) req.body.nil? || req.body.size == 0 ? body : req.body end
[ "def", "request_body_from", "(", "req", ",", "body", ")", "req", ".", "body", ".", "nil?", "||", "req", ".", "body", ".", "size", "==", "0", "?", "body", ":", "req", ".", "body", "end" ]
A bit convoluted because post_form uses form_data= to assign the data, so in that case req.body will be empty
[ "A", "bit", "convoluted", "because", "post_form", "uses", "form_data", "=", "to", "assign", "the", "data", "so", "in", "that", "case", "req", ".", "body", "will", "be", "empty" ]
f222f75395e09260b274d6f85c05062f0a2c8e43
https://github.com/MYOB-Technology/http_event_logger/blob/f222f75395e09260b274d6f85c05062f0a2c8e43/lib/http_event_logger/adapter/net_http.rb#L49-L51
train
dpla/KriKri
lib/krikri/enrichments/language_to_lexvo.rb
Krikri::Enrichments.LanguageToLexvo.enrich_value
def enrich_value(value) return enrich_node(value) if value.is_a?(ActiveTriples::Resource) && value.node? return value if value.is_a?(DPLA::MAP::Controlled::Language) return nil if value.is_a?(ActiveTriples::Resource) enrich_literal(value) end
ruby
def enrich_value(value) return enrich_node(value) if value.is_a?(ActiveTriples::Resource) && value.node? return value if value.is_a?(DPLA::MAP::Controlled::Language) return nil if value.is_a?(ActiveTriples::Resource) enrich_literal(value) end
[ "def", "enrich_value", "(", "value", ")", "return", "enrich_node", "(", "value", ")", "if", "value", ".", "is_a?", "(", "ActiveTriples", "::", "Resource", ")", "&&", "value", ".", "node?", "return", "value", "if", "value", ".", "is_a?", "(", "DPLA", "::"...
Runs the enrichment against a node. Can match literal values, and Language values with a provided label. @example with a matching value lang = enrich_value('finnish') #=> #<DPLA::MAP::Controlled::Language:0x3f(default)> lang.providedLabel #=> ['finnish'] lang.exactMatch.map(&:to_term) #=> [#<RDF::V...
[ "Runs", "the", "enrichment", "against", "a", "node", ".", "Can", "match", "literal", "values", "and", "Language", "values", "with", "a", "provided", "label", "." ]
0ac26e60ce1bba60caa40263a562796267cf833f
https://github.com/dpla/KriKri/blob/0ac26e60ce1bba60caa40263a562796267cf833f/lib/krikri/enrichments/language_to_lexvo.rb#L77-L83
train
dpla/KriKri
lib/krikri/enrichments/language_to_lexvo.rb
Krikri::Enrichments.LanguageToLexvo.enrich_literal
def enrich_literal(label) node = DPLA::MAP::Controlled::Language.new() node.providedLabel = label match = match_iso(label.to_s) match = match_label(label.to_s) if match.node? # if match is still a node, we didn't find anything return node if match.node? node.exactMatch = mat...
ruby
def enrich_literal(label) node = DPLA::MAP::Controlled::Language.new() node.providedLabel = label match = match_iso(label.to_s) match = match_label(label.to_s) if match.node? # if match is still a node, we didn't find anything return node if match.node? node.exactMatch = mat...
[ "def", "enrich_literal", "(", "label", ")", "node", "=", "DPLA", "::", "MAP", "::", "Controlled", "::", "Language", ".", "new", "(", ")", "node", ".", "providedLabel", "=", "label", "match", "=", "match_iso", "(", "label", ".", "to_s", ")", "match", "=...
Runs the enrichment over a string. @param label [#to_s] the string to match @return [ActiveTriples::Resource] a blank node with a `dpla:providedLabel` of `label` and a `skos:exactMatch` of the matching lexvo language, if any
[ "Runs", "the", "enrichment", "over", "a", "string", "." ]
0ac26e60ce1bba60caa40263a562796267cf833f
https://github.com/dpla/KriKri/blob/0ac26e60ce1bba60caa40263a562796267cf833f/lib/krikri/enrichments/language_to_lexvo.rb#L106-L119
train
fzxu/mongoid_order
lib/mongoid_order.rb
Mongoid.Orderable.move_above
def move_above(other) if position > other.position new_position = other.position other.lower_siblings.where(:position.lt => self.position).each { |s| s.inc(:position, 1) } other.inc(:position, 1) self.position = new_position save! else new_position = other.pos...
ruby
def move_above(other) if position > other.position new_position = other.position other.lower_siblings.where(:position.lt => self.position).each { |s| s.inc(:position, 1) } other.inc(:position, 1) self.position = new_position save! else new_position = other.pos...
[ "def", "move_above", "(", "other", ")", "if", "position", ">", "other", ".", "position", "new_position", "=", "other", ".", "position", "other", ".", "lower_siblings", ".", "where", "(", ":position", ".", "lt", "=>", "self", ".", "position", ")", ".", "e...
Move this node above the specified node This method changes the node's parent if nescessary.
[ "Move", "this", "node", "above", "the", "specified", "node" ]
803a80762a460c90f6cc6ad8e6ab123a6ab9c97d
https://github.com/fzxu/mongoid_order/blob/803a80762a460c90f6cc6ad8e6ab123a6ab9c97d/lib/mongoid_order.rb#L105-L118
train
zdennis/yap-shell-parser
lib/yap/shell/parser/lexer.rb
Yap::Shell.Parser::Lexer.whitespace_token
def whitespace_token if md=WHITESPACE.match(@chunk) input = md.to_a[0] input.length else did_not_match end end
ruby
def whitespace_token if md=WHITESPACE.match(@chunk) input = md.to_a[0] input.length else did_not_match end end
[ "def", "whitespace_token", "if", "md", "=", "WHITESPACE", ".", "match", "(", "@chunk", ")", "input", "=", "md", ".", "to_a", "[", "0", "]", "input", ".", "length", "else", "did_not_match", "end", "end" ]
Matches and consumes non-meaningful whitespace.
[ "Matches", "and", "consumes", "non", "-", "meaningful", "whitespace", "." ]
b3f3d31dd5cd1b05b381709338f0e2e47e970add
https://github.com/zdennis/yap-shell-parser/blob/b3f3d31dd5cd1b05b381709338f0e2e47e970add/lib/yap/shell/parser/lexer.rb#L365-L372
train
zdennis/yap-shell-parser
lib/yap/shell/parser/lexer.rb
Yap::Shell.Parser::Lexer.string_token
def string_token if %w(' ").include?(@chunk[0]) result = process_string @chunk[0..-1], @chunk[0] if @looking_for_args token :Argument, result.str, attrs: { quoted_by: @chunk[0] } else token :Command, result.str end result.consumed_length else ...
ruby
def string_token if %w(' ").include?(@chunk[0]) result = process_string @chunk[0..-1], @chunk[0] if @looking_for_args token :Argument, result.str, attrs: { quoted_by: @chunk[0] } else token :Command, result.str end result.consumed_length else ...
[ "def", "string_token", "if", "%w(", "'", "\"", ")", ".", "include?", "(", "@chunk", "[", "0", "]", ")", "result", "=", "process_string", "@chunk", "[", "0", "..", "-", "1", "]", ",", "@chunk", "[", "0", "]", "if", "@looking_for_args", "token", ":Argu...
Matches single and double quoted strings
[ "Matches", "single", "and", "double", "quoted", "strings" ]
b3f3d31dd5cd1b05b381709338f0e2e47e970add
https://github.com/zdennis/yap-shell-parser/blob/b3f3d31dd5cd1b05b381709338f0e2e47e970add/lib/yap/shell/parser/lexer.rb#L481-L493
train
dpla/KriKri
app/models/krikri/qa_report.rb
Krikri.QAReport.generate_field_report!
def generate_field_report! report = field_queries.inject({}) do |report_hash, (k, v)| report_hash[k] = solutions_to_hash(v.execute) report_hash end update(field_report: report) end
ruby
def generate_field_report! report = field_queries.inject({}) do |report_hash, (k, v)| report_hash[k] = solutions_to_hash(v.execute) report_hash end update(field_report: report) end
[ "def", "generate_field_report!", "report", "=", "field_queries", ".", "inject", "(", "{", "}", ")", "do", "|", "report_hash", ",", "(", "k", ",", "v", ")", "|", "report_hash", "[", "k", "]", "=", "solutions_to_hash", "(", "v", ".", "execute", ")", "rep...
Generates and saves the field report for the provider, sending SPARQL queries as necessary. @return [Hash]
[ "Generates", "and", "saves", "the", "field", "report", "for", "the", "provider", "sending", "SPARQL", "queries", "as", "necessary", "." ]
0ac26e60ce1bba60caa40263a562796267cf833f
https://github.com/dpla/KriKri/blob/0ac26e60ce1bba60caa40263a562796267cf833f/app/models/krikri/qa_report.rb#L46-L52
train
dpla/KriKri
app/models/krikri/qa_report.rb
Krikri.QAReport.generate_count_report!
def generate_count_report! report = count_queries.inject({}) do |report_hash, (k, v)| report_hash[k] = solutions_to_counts(v.execute) report_hash end update(count_report: report) end
ruby
def generate_count_report! report = count_queries.inject({}) do |report_hash, (k, v)| report_hash[k] = solutions_to_counts(v.execute) report_hash end update(count_report: report) end
[ "def", "generate_count_report!", "report", "=", "count_queries", ".", "inject", "(", "{", "}", ")", "do", "|", "report_hash", ",", "(", "k", ",", "v", ")", "|", "report_hash", "[", "k", "]", "=", "solutions_to_counts", "(", "v", ".", "execute", ")", "r...
Generates and saves the coun treport for the provider, sending SPARQL queries as necessary. @return [Hash]
[ "Generates", "and", "saves", "the", "coun", "treport", "for", "the", "provider", "sending", "SPARQL", "queries", "as", "necessary", "." ]
0ac26e60ce1bba60caa40263a562796267cf833f
https://github.com/dpla/KriKri/blob/0ac26e60ce1bba60caa40263a562796267cf833f/app/models/krikri/qa_report.rb#L59-L66
train
outcomesinsights/sequelizer
lib/sequelizer/connection_maker.rb
Sequelizer.ConnectionMaker.connection
def connection opts = options.to_hash extensions = options.extensions conn = if url = (opts.delete(:uri) || opts.delete(:url)) Sequel.connect(url, opts) else # Kerberos related options realm = opts[:realm] host_fqdn = opts[:host_fqdn] || opts[:host] princ...
ruby
def connection opts = options.to_hash extensions = options.extensions conn = if url = (opts.delete(:uri) || opts.delete(:url)) Sequel.connect(url, opts) else # Kerberos related options realm = opts[:realm] host_fqdn = opts[:host_fqdn] || opts[:host] princ...
[ "def", "connection", "opts", "=", "options", ".", "to_hash", "extensions", "=", "options", ".", "extensions", "conn", "=", "if", "url", "=", "(", "opts", ".", "delete", "(", ":uri", ")", "||", "opts", ".", "delete", "(", ":url", ")", ")", "Sequel", "...
Accepts an optional set of database options If no options are provided, attempts to read options from config/database.yml If config/database.yml doesn't exist, Dotenv is used to try to load a .env file, then uses any SEQUELIZER_* environment variables as database options Returns a Sequel connection to the datab...
[ "Accepts", "an", "optional", "set", "of", "database", "options" ]
2a8b4a78410b1cf82ec19b45afdb4f65629b2ce2
https://github.com/outcomesinsights/sequelizer/blob/2a8b4a78410b1cf82ec19b45afdb4f65629b2ce2/lib/sequelizer/connection_maker.rb#L25-L88
train
salsify/avro_schema_registry-client
lib/avro_schema_registry/client.rb
AvroSchemaRegistry.Client.register
def register(subject, schema, **params) lookup_subject_schema(subject, schema) rescue Excon::Errors::NotFound register_without_lookup(subject, schema, params) end
ruby
def register(subject, schema, **params) lookup_subject_schema(subject, schema) rescue Excon::Errors::NotFound register_without_lookup(subject, schema, params) end
[ "def", "register", "(", "subject", ",", "schema", ",", "**", "params", ")", "lookup_subject_schema", "(", "subject", ",", "schema", ")", "rescue", "Excon", "::", "Errors", "::", "NotFound", "register_without_lookup", "(", "subject", ",", "schema", ",", "params...
Override register to first check if a schema is registered by fingerprint Also, allow additional params to be passed to register.
[ "Override", "register", "to", "first", "check", "if", "a", "schema", "is", "registered", "by", "fingerprint", "Also", "allow", "additional", "params", "to", "be", "passed", "to", "register", "." ]
ae34346995d98a91709093f013f371153bdbedbc
https://github.com/salsify/avro_schema_registry-client/blob/ae34346995d98a91709093f013f371153bdbedbc/lib/avro_schema_registry/client.rb#L23-L27
train
salsify/avro_schema_registry-client
lib/avro_schema_registry/client.rb
AvroSchemaRegistry.Client.compatible?
def compatible?(subject, schema, version = 'latest', **params) data = post("/compatibility/subjects/#{subject}/versions/#{version}", expects: [200, 404], body: { schema: schema.to_s }.merge!(params).to_json) data.fetch('is_compatible', false) unless data.key?('error_code'...
ruby
def compatible?(subject, schema, version = 'latest', **params) data = post("/compatibility/subjects/#{subject}/versions/#{version}", expects: [200, 404], body: { schema: schema.to_s }.merge!(params).to_json) data.fetch('is_compatible', false) unless data.key?('error_code'...
[ "def", "compatible?", "(", "subject", ",", "schema", ",", "version", "=", "'latest'", ",", "**", "params", ")", "data", "=", "post", "(", "\"/compatibility/subjects/#{subject}/versions/#{version}\"", ",", "expects", ":", "[", "200", ",", "404", "]", ",", "body...
Override to add support for additional params
[ "Override", "to", "add", "support", "for", "additional", "params" ]
ae34346995d98a91709093f013f371153bdbedbc
https://github.com/salsify/avro_schema_registry-client/blob/ae34346995d98a91709093f013f371153bdbedbc/lib/avro_schema_registry/client.rb#L38-L43
train
huffpostdata/ruby-pollster
lib/pollster/api_client.rb
Pollster.ApiClient.call_api_tsv
def call_api_tsv(http_method, path, opts = {}) request = build_request(http_method, path, opts) response = request.run if @config.debugging @config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n" end unless response.success? if response.timed_out? ...
ruby
def call_api_tsv(http_method, path, opts = {}) request = build_request(http_method, path, opts) response = request.run if @config.debugging @config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n" end unless response.success? if response.timed_out? ...
[ "def", "call_api_tsv", "(", "http_method", ",", "path", ",", "opts", "=", "{", "}", ")", "request", "=", "build_request", "(", "http_method", ",", "path", ",", "opts", ")", "response", "=", "request", ".", "run", "if", "@config", ".", "debugging", "@conf...
Call an API with given options, and parse the TSV response. @return [Array<(Object, Fixnum, Hash)>] an array of 3 elements: the data deserialized from response body (could be nil), response status code and response headers.
[ "Call", "an", "API", "with", "given", "options", "and", "parse", "the", "TSV", "response", "." ]
32fb81b58e7fb39787a7591b8ede579301cd2b8b
https://github.com/huffpostdata/ruby-pollster/blob/32fb81b58e7fb39787a7591b8ede579301cd2b8b/lib/pollster/api_client.rb#L72-L102
train
arkes/sorting_table_for
lib/sorting_table_for/format_cell.rb
SortingTableFor.FormatCell.render_cell_tbody
def render_cell_tbody if @type == :action cell_value = action_link_to(@ask) elsif @ask cell_value = (@ask.is_a?(Symbol)) ? format_cell_value(@object[@ask], @ask) : format_cell_value(@ask) else cell_value = @block end cell_value = action_link_to(@options[:action], ce...
ruby
def render_cell_tbody if @type == :action cell_value = action_link_to(@ask) elsif @ask cell_value = (@ask.is_a?(Symbol)) ? format_cell_value(@object[@ask], @ask) : format_cell_value(@ask) else cell_value = @block end cell_value = action_link_to(@options[:action], ce...
[ "def", "render_cell_tbody", "if", "@type", "==", ":action", "cell_value", "=", "action_link_to", "(", "@ask", ")", "elsif", "@ask", "cell_value", "=", "(", "@ask", ".", "is_a?", "(", "Symbol", ")", ")", "?", "format_cell_value", "(", "@object", "[", "@ask", ...
Return a td with the formated value or action for columns
[ "Return", "a", "td", "with", "the", "formated", "value", "or", "action", "for", "columns" ]
cfc41f033ed1babd9b3536cd63ef854eafb6e94e
https://github.com/arkes/sorting_table_for/blob/cfc41f033ed1babd9b3536cd63ef854eafb6e94e/lib/sorting_table_for/format_cell.rb#L21-L31
train
arkes/sorting_table_for
lib/sorting_table_for/format_cell.rb
SortingTableFor.FormatCell.render_cell_thead
def render_cell_thead if @ask cell_value = (@ask.is_a?(Symbol)) ? I18n.t(@ask, {}, :header) : @ask else cell_value = @block end if @can_sort sort_on = @options[:sort_as] || @ask @html_options.merge!(:class => "#{@html_options[:class]} #{sorting_html_class(sort_on)...
ruby
def render_cell_thead if @ask cell_value = (@ask.is_a?(Symbol)) ? I18n.t(@ask, {}, :header) : @ask else cell_value = @block end if @can_sort sort_on = @options[:sort_as] || @ask @html_options.merge!(:class => "#{@html_options[:class]} #{sorting_html_class(sort_on)...
[ "def", "render_cell_thead", "if", "@ask", "cell_value", "=", "(", "@ask", ".", "is_a?", "(", "Symbol", ")", ")", "?", "I18n", ".", "t", "(", "@ask", ",", "{", "}", ",", ":header", ")", ":", "@ask", "else", "cell_value", "=", "@block", "end", "if", ...
Return a td with the formated value or action for headers
[ "Return", "a", "td", "with", "the", "formated", "value", "or", "action", "for", "headers" ]
cfc41f033ed1babd9b3536cd63ef854eafb6e94e
https://github.com/arkes/sorting_table_for/blob/cfc41f033ed1babd9b3536cd63ef854eafb6e94e/lib/sorting_table_for/format_cell.rb#L34-L47
train
arkes/sorting_table_for
lib/sorting_table_for/format_cell.rb
SortingTableFor.FormatCell.action_link_to
def action_link_to(action, block = nil) object_or_array = @@object_or_array.clone object_or_array.push @object return case action.to_sym when :delete create_link_to(block || I18n.t(:delete), object_or_array, @@options[:link_remote], :delete, I18n.t(:confirm_delete)) when :sho...
ruby
def action_link_to(action, block = nil) object_or_array = @@object_or_array.clone object_or_array.push @object return case action.to_sym when :delete create_link_to(block || I18n.t(:delete), object_or_array, @@options[:link_remote], :delete, I18n.t(:confirm_delete)) when :sho...
[ "def", "action_link_to", "(", "action", ",", "block", "=", "nil", ")", "object_or_array", "=", "@@object_or_array", ".", "clone", "object_or_array", ".", "push", "@object", "return", "case", "action", ".", "to_sym", "when", ":delete", "create_link_to", "(", "blo...
Create the link for actions Set the I18n translation or the given block for the link's name
[ "Create", "the", "link", "for", "actions", "Set", "the", "I18n", "translation", "or", "the", "given", "block", "for", "the", "link", "s", "name" ]
cfc41f033ed1babd9b3536cd63ef854eafb6e94e
https://github.com/arkes/sorting_table_for/blob/cfc41f033ed1babd9b3536cd63ef854eafb6e94e/lib/sorting_table_for/format_cell.rb#L84-L96
train
arkes/sorting_table_for
lib/sorting_table_for/format_cell.rb
SortingTableFor.FormatCell.create_link_to
def create_link_to(block, url, remote, method = nil, confirm = nil) if remote return link_to(block, url, :method => method, :confirm => confirm, :remote => true) end link_to(block, url, :method => method, :confirm => confirm) end
ruby
def create_link_to(block, url, remote, method = nil, confirm = nil) if remote return link_to(block, url, :method => method, :confirm => confirm, :remote => true) end link_to(block, url, :method => method, :confirm => confirm) end
[ "def", "create_link_to", "(", "block", ",", "url", ",", "remote", ",", "method", "=", "nil", ",", "confirm", "=", "nil", ")", "if", "remote", "return", "link_to", "(", "block", ",", "url", ",", ":method", "=>", "method", ",", ":confirm", "=>", "confirm...
Create the link based on object Set an ajax link if option link_remote is set to true
[ "Create", "the", "link", "based", "on", "object", "Set", "an", "ajax", "link", "if", "option", "link_remote", "is", "set", "to", "true" ]
cfc41f033ed1babd9b3536cd63ef854eafb6e94e
https://github.com/arkes/sorting_table_for/blob/cfc41f033ed1babd9b3536cd63ef854eafb6e94e/lib/sorting_table_for/format_cell.rb#L105-L110
train
arkes/sorting_table_for
lib/sorting_table_for/format_cell.rb
SortingTableFor.FormatCell.format_cell_value
def format_cell_value(value, attribute = nil) unless (ret_value = format_cell_value_as_ask(value)).nil? return ret_value end format_cell_value_as_type(value, attribute) end
ruby
def format_cell_value(value, attribute = nil) unless (ret_value = format_cell_value_as_ask(value)).nil? return ret_value end format_cell_value_as_type(value, attribute) end
[ "def", "format_cell_value", "(", "value", ",", "attribute", "=", "nil", ")", "unless", "(", "ret_value", "=", "format_cell_value_as_ask", "(", "value", ")", ")", ".", "nil?", "return", "ret_value", "end", "format_cell_value_as_type", "(", "value", ",", "attribut...
Return the formated cell's value
[ "Return", "the", "formated", "cell", "s", "value" ]
cfc41f033ed1babd9b3536cd63ef854eafb6e94e
https://github.com/arkes/sorting_table_for/blob/cfc41f033ed1babd9b3536cd63ef854eafb6e94e/lib/sorting_table_for/format_cell.rb#L152-L157
train
arkes/sorting_table_for
lib/sorting_table_for/format_cell.rb
SortingTableFor.FormatCell.format_cell_value_as_type
def format_cell_value_as_type(value, attribute) if value.is_a?(Time) or value.is_a?(Date) return ::I18n.l(value, :format => @options[:format] || TableBuilder.i18n_default_format_date) elsif TableBuilder.currency_columns.include?(attribute) return number_to_currency(value) elsif value.i...
ruby
def format_cell_value_as_type(value, attribute) if value.is_a?(Time) or value.is_a?(Date) return ::I18n.l(value, :format => @options[:format] || TableBuilder.i18n_default_format_date) elsif TableBuilder.currency_columns.include?(attribute) return number_to_currency(value) elsif value.i...
[ "def", "format_cell_value_as_type", "(", "value", ",", "attribute", ")", "if", "value", ".", "is_a?", "(", "Time", ")", "or", "value", ".", "is_a?", "(", "Date", ")", "return", "::", "I18n", ".", "l", "(", "value", ",", ":format", "=>", "@options", "["...
Format the value based on value's type
[ "Format", "the", "value", "based", "on", "value", "s", "type" ]
cfc41f033ed1babd9b3536cd63ef854eafb6e94e
https://github.com/arkes/sorting_table_for/blob/cfc41f033ed1babd9b3536cd63ef854eafb6e94e/lib/sorting_table_for/format_cell.rb#L171-L182
train
dpla/KriKri
app/controllers/krikri/qa_reports_controller.rb
Krikri.QaReportsController.show
def show @report = Krikri::QAReport.find(params[:id]) @type = params[:type] == 'count' ? :count : :field respond_to do |format| format.html format.csv { render text: @report.send("#{@type}_csv".to_sym).to_csv } end end
ruby
def show @report = Krikri::QAReport.find(params[:id]) @type = params[:type] == 'count' ? :count : :field respond_to do |format| format.html format.csv { render text: @report.send("#{@type}_csv".to_sym).to_csv } end end
[ "def", "show", "@report", "=", "Krikri", "::", "QAReport", ".", "find", "(", "params", "[", ":id", "]", ")", "@type", "=", "params", "[", ":type", "]", "==", "'count'", "?", ":count", ":", ":field", "respond_to", "do", "|", "format", "|", "format", "...
Rendering the report as either a full `field` report or a `count` report. Responds to format of `text/csv` with a CSV rendering of the requested report type.
[ "Rendering", "the", "report", "as", "either", "a", "full", "field", "report", "or", "a", "count", "report", "." ]
0ac26e60ce1bba60caa40263a562796267cf833f
https://github.com/dpla/KriKri/blob/0ac26e60ce1bba60caa40263a562796267cf833f/app/controllers/krikri/qa_reports_controller.rb#L18-L26
train