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
sequence
docstring
stringlengths
8
16k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
94
266
partition
stringclasses
1 value
jinx/core
lib/jinx/helpers/hasher.rb
Jinx.Hasher.assoc_values
def assoc_values(*others) all_keys = keys others.each { |hash| all_keys.concat(hash.keys) } all_keys.to_compact_hash do |k| others.map { |other| other[k] }.unshift(self[k]) end end
ruby
def assoc_values(*others) all_keys = keys others.each { |hash| all_keys.concat(hash.keys) } all_keys.to_compact_hash do |k| others.map { |other| other[k] }.unshift(self[k]) end end
[ "def", "assoc_values", "(", "*", "others", ")", "all_keys", "=", "keys", "others", ".", "each", "{", "|", "hash", "|", "all_keys", ".", "concat", "(", "hash", ".", "keys", ")", "}", "all_keys", ".", "to_compact_hash", "do", "|", "k", "|", "others", ".", "map", "{", "|", "other", "|", "other", "[", "k", "]", "}", ".", "unshift", "(", "self", "[", "k", "]", ")", "end", "end" ]
Returns a hash which associates each key in this hash with the value mapped by the others. @example {:a => 1, :b => 2}.assoc_values({:a => 3, :c => 4}) #=> {:a => [1, 3], :b => [2, nil], :c => [nil, 4]} {:a => 1, :b => 2}.assoc_values({:a => 3}, {:a => 4, :b => 5}) #=> {:a => [1, 3, 4], :b => [2, nil, 5]} @param [<Hasher>] others the other Hashers to associate with this Hasher @return [Hash] the association hash
[ "Returns", "a", "hash", "which", "associates", "each", "key", "in", "this", "hash", "with", "the", "value", "mapped", "by", "the", "others", "." ]
964a274cc9d7ab74613910e8375e12ed210a434d
https://github.com/jinx/core/blob/964a274cc9d7ab74613910e8375e12ed210a434d/lib/jinx/helpers/hasher.rb#L225-L231
train
jinx/core
lib/jinx/helpers/hasher.rb
Jinx.Hasher.enum_keys_with_value
def enum_keys_with_value(target_value=nil, &filter) # :yields: value return enum_keys_with_value { |v| v == target_value } if target_value filter_on_value(&filter).keys end
ruby
def enum_keys_with_value(target_value=nil, &filter) # :yields: value return enum_keys_with_value { |v| v == target_value } if target_value filter_on_value(&filter).keys end
[ "def", "enum_keys_with_value", "(", "target_value", "=", "nil", ",", "&", "filter", ")", "return", "enum_keys_with_value", "{", "|", "v", "|", "v", "==", "target_value", "}", "if", "target_value", "filter_on_value", "(", "&", "filter", ")", ".", "keys", "end" ]
Returns an Enumerable whose each block is called on each key which maps to a value which either equals the given target_value or satisfies the filter block. @param target_value the filter value @yield [value] the filter block @return [Enumerable] the filtered keys
[ "Returns", "an", "Enumerable", "whose", "each", "block", "is", "called", "on", "each", "key", "which", "maps", "to", "a", "value", "which", "either", "equals", "the", "given", "target_value", "or", "satisfies", "the", "filter", "block", "." ]
964a274cc9d7ab74613910e8375e12ed210a434d
https://github.com/jinx/core/blob/964a274cc9d7ab74613910e8375e12ed210a434d/lib/jinx/helpers/hasher.rb#L239-L242
train
jinx/core
lib/jinx/helpers/hasher.rb
Jinx.Hasher.copy_recursive
def copy_recursive copy = Hash.new keys.each do |k| value = self[k] copy[k] = Hash === value ? value.copy_recursive : value end copy end
ruby
def copy_recursive copy = Hash.new keys.each do |k| value = self[k] copy[k] = Hash === value ? value.copy_recursive : value end copy end
[ "def", "copy_recursive", "copy", "=", "Hash", ".", "new", "keys", ".", "each", "do", "|", "k", "|", "value", "=", "self", "[", "k", "]", "copy", "[", "k", "]", "=", "Hash", "===", "value", "?", "value", ".", "copy_recursive", ":", "value", "end", "copy", "end" ]
Returns a new Hash that recursively copies this hash's values. Values of type hash are copied using copy_recursive. Other values are unchanged. This method is useful for preserving and restoring hash associations. @return [Hash] a deep copy of this Hasher
[ "Returns", "a", "new", "Hash", "that", "recursively", "copies", "this", "hash", "s", "values", ".", "Values", "of", "type", "hash", "are", "copied", "using", "copy_recursive", ".", "Other", "values", "are", "unchanged", "." ]
964a274cc9d7ab74613910e8375e12ed210a434d
https://github.com/jinx/core/blob/964a274cc9d7ab74613910e8375e12ed210a434d/lib/jinx/helpers/hasher.rb#L316-L323
train
benton/rds_backup_service
lib/rds_backup_service/model/email.rb
RDSBackup.Email.body
def body msg = "Hello.\n\n" if job.status == 200 msg += "Your backup of database #{job.rds_id} is complete.\n"+ (job.files.empty? ? "" : "Output is at #{job.files.first[:url]}\n") else msg += "Your backup is incomplete. (job ID #{job.backup_id})\n" end msg += "Job status: #{job.message}" end
ruby
def body msg = "Hello.\n\n" if job.status == 200 msg += "Your backup of database #{job.rds_id} is complete.\n"+ (job.files.empty? ? "" : "Output is at #{job.files.first[:url]}\n") else msg += "Your backup is incomplete. (job ID #{job.backup_id})\n" end msg += "Job status: #{job.message}" end
[ "def", "body", "msg", "=", "\"Hello.\\n\\n\"", "if", "job", ".", "status", "==", "200", "msg", "+=", "\"Your backup of database #{job.rds_id} is complete.\\n\"", "+", "(", "job", ".", "files", ".", "empty?", "?", "\"\"", ":", "\"Output is at #{job.files.first[:url]}\\n\"", ")", "else", "msg", "+=", "\"Your backup is incomplete. (job ID #{job.backup_id})\\n\"", "end", "msg", "+=", "\"Job status: #{job.message}\"", "end" ]
defines the body of a Job's status email
[ "defines", "the", "body", "of", "a", "Job", "s", "status", "email" ]
4930dd47e78a510f0a8abe21a5f9e1a483dda96f
https://github.com/benton/rds_backup_service/blob/4930dd47e78a510f0a8abe21a5f9e1a483dda96f/lib/rds_backup_service/model/email.rb#L36-L45
train
robacarp/bootstraps_bootstraps
lib/bootstraps_bootstraps/bootstrap_form_helper.rb
BootstrapsBootstraps.BootstrapFormHelper.bootstrapped_form
def bootstrapped_form object, options={}, &block options[:builder] = BootstrapFormBuilder form_for object, options, &block end
ruby
def bootstrapped_form object, options={}, &block options[:builder] = BootstrapFormBuilder form_for object, options, &block end
[ "def", "bootstrapped_form", "object", ",", "options", "=", "{", "}", ",", "&", "block", "options", "[", ":builder", "]", "=", "BootstrapFormBuilder", "form_for", "object", ",", "options", ",", "&", "block", "end" ]
merely setup the form_for to use our new form builder
[ "merely", "setup", "the", "form_for", "to", "use", "our", "new", "form", "builder" ]
34ccd3cae58e7c4926c0f98f3ac40e6cecb42296
https://github.com/robacarp/bootstraps_bootstraps/blob/34ccd3cae58e7c4926c0f98f3ac40e6cecb42296/lib/bootstraps_bootstraps/bootstrap_form_helper.rb#L4-L7
train
xtoddx/maturate
lib/maturate.rb
Maturate.InstanceMethods.api_version
def api_version version = params[:api_version] return current_api_version if version == 'current' api_versions.include?(version) ? version : current_api_version end
ruby
def api_version version = params[:api_version] return current_api_version if version == 'current' api_versions.include?(version) ? version : current_api_version end
[ "def", "api_version", "version", "=", "params", "[", ":api_version", "]", "return", "current_api_version", "if", "version", "==", "'current'", "api_versions", ".", "include?", "(", "version", ")", "?", "version", ":", "current_api_version", "end" ]
The api version of the current request
[ "The", "api", "version", "of", "the", "current", "request" ]
6acb72efe720e8b61dd777a4b190c4a6869bc30c
https://github.com/xtoddx/maturate/blob/6acb72efe720e8b61dd777a4b190c4a6869bc30c/lib/maturate.rb#L186-L190
train
jeremiahishere/trackable_tasks
lib/trackable_tasks/base.rb
TrackableTasks.Base.allowable_log_level
def allowable_log_level(log_level) log_level = "" if log_level.nil? log_level = log_level.to_sym unless log_level.is_a?(Symbol) if !@log_levels.include?(log_level) log_level = :notice end return log_level end
ruby
def allowable_log_level(log_level) log_level = "" if log_level.nil? log_level = log_level.to_sym unless log_level.is_a?(Symbol) if !@log_levels.include?(log_level) log_level = :notice end return log_level end
[ "def", "allowable_log_level", "(", "log_level", ")", "log_level", "=", "\"\"", "if", "log_level", ".", "nil?", "log_level", "=", "log_level", ".", "to_sym", "unless", "log_level", ".", "is_a?", "(", "Symbol", ")", "if", "!", "@log_levels", ".", "include?", "(", "log_level", ")", "log_level", "=", ":notice", "end", "return", "log_level", "end" ]
Initializes the task run and sets the start time @param [Symbol] log_level The log level for the task, defaults to notice Checks if the log level is an allowable level, then returns it or notice if it is not allowable @param [Sybmol] log_level Log level to check @return [Symbol] The given log level or notice if it is not allowable
[ "Initializes", "the", "task", "run", "and", "sets", "the", "start", "time" ]
8702672a7b38efa936fd285a0025e04e4b025908
https://github.com/jeremiahishere/trackable_tasks/blob/8702672a7b38efa936fd285a0025e04e4b025908/lib/trackable_tasks/base.rb#L38-L45
train
jeremiahishere/trackable_tasks
lib/trackable_tasks/base.rb
TrackableTasks.Base.run_task
def run_task begin run rescue Exception => e @task_run.add_error_text(e.class.name + ": " + e.message) @task_run.add_error_text(e.backtrace.inspect) @task_run.success = false end finally @task_run.end_time = Time.now @task_run.save end
ruby
def run_task begin run rescue Exception => e @task_run.add_error_text(e.class.name + ": " + e.message) @task_run.add_error_text(e.backtrace.inspect) @task_run.success = false end finally @task_run.end_time = Time.now @task_run.save end
[ "def", "run_task", "begin", "run", "rescue", "Exception", "=>", "e", "@task_run", ".", "add_error_text", "(", "e", ".", "class", ".", "name", "+", "\": \"", "+", "e", ".", "message", ")", "@task_run", ".", "add_error_text", "(", "e", ".", "backtrace", ".", "inspect", ")", "@task_run", ".", "success", "=", "false", "end", "finally", "@task_run", ".", "end_time", "=", "Time", ".", "now", "@task_run", ".", "save", "end" ]
this calls task with error catching if an error is caught, sets success to false and records the error either way, sets an end time and saves the task run information After the run completes, whether or not the run succeeds, run finally If finally has an error, don't catch it
[ "this", "calls", "task", "with", "error", "catching", "if", "an", "error", "is", "caught", "sets", "success", "to", "false", "and", "records", "the", "error", "either", "way", "sets", "an", "end", "time", "and", "saves", "the", "task", "run", "information" ]
8702672a7b38efa936fd285a0025e04e4b025908
https://github.com/jeremiahishere/trackable_tasks/blob/8702672a7b38efa936fd285a0025e04e4b025908/lib/trackable_tasks/base.rb#L53-L66
train
DeNA/mobilize-base
lib/mobilize-base/models/runner.rb
Mobilize.Runner.force_due
def force_due r = self r.update_attributes(:started_at=>(Time.now.utc - Jobtracker.runner_read_freq - 1.second)) end
ruby
def force_due r = self r.update_attributes(:started_at=>(Time.now.utc - Jobtracker.runner_read_freq - 1.second)) end
[ "def", "force_due", "r", "=", "self", "r", ".", "update_attributes", "(", ":started_at", "=>", "(", "Time", ".", "now", ".", "utc", "-", "Jobtracker", ".", "runner_read_freq", "-", "1", ".", "second", ")", ")", "end" ]
update runner started_at to be whatever the notification is - 1.second which will force runner to be due
[ "update", "runner", "started_at", "to", "be", "whatever", "the", "notification", "is", "-", "1", ".", "second", "which", "will", "force", "runner", "to", "be", "due" ]
0c9d3ba7f1648629f6fc9218a00a1366f1e43a75
https://github.com/DeNA/mobilize-base/blob/0c9d3ba7f1648629f6fc9218a00a1366f1e43a75/lib/mobilize-base/models/runner.rb#L131-L134
train
triglav-dataflow/triglav-client-ruby
lib/triglav_client/api/users_api.rb
TriglavClient.UsersApi.create_user
def create_user(user, opts = {}) data, _status_code, _headers = create_user_with_http_info(user, opts) return data end
ruby
def create_user(user, opts = {}) data, _status_code, _headers = create_user_with_http_info(user, opts) return data end
[ "def", "create_user", "(", "user", ",", "opts", "=", "{", "}", ")", "data", ",", "_status_code", ",", "_headers", "=", "create_user_with_http_info", "(", "user", ",", "opts", ")", "return", "data", "end" ]
Creates a new user in the store @param user User to add to the store @param [Hash] opts the optional parameters @return [UserResponse]
[ "Creates", "a", "new", "user", "in", "the", "store" ]
b2f3781d65ee032ba96eb703fbd789c713a5e0bd
https://github.com/triglav-dataflow/triglav-client-ruby/blob/b2f3781d65ee032ba96eb703fbd789c713a5e0bd/lib/triglav_client/api/users_api.rb#L39-L42
train
triglav-dataflow/triglav-client-ruby
lib/triglav_client/api/users_api.rb
TriglavClient.UsersApi.get_user
def get_user(id, opts = {}) data, _status_code, _headers = get_user_with_http_info(id, opts) return data end
ruby
def get_user(id, opts = {}) data, _status_code, _headers = get_user_with_http_info(id, opts) return data end
[ "def", "get_user", "(", "id", ",", "opts", "=", "{", "}", ")", "data", ",", "_status_code", ",", "_headers", "=", "get_user_with_http_info", "(", "id", ",", "opts", ")", "return", "data", "end" ]
Returns a single user @param id ID of user to fetch @param [Hash] opts the optional parameters @return [UserResponse]
[ "Returns", "a", "single", "user" ]
b2f3781d65ee032ba96eb703fbd789c713a5e0bd
https://github.com/triglav-dataflow/triglav-client-ruby/blob/b2f3781d65ee032ba96eb703fbd789c713a5e0bd/lib/triglav_client/api/users_api.rb#L152-L155
train
triglav-dataflow/triglav-client-ruby
lib/triglav_client/api/users_api.rb
TriglavClient.UsersApi.update_user
def update_user(id, user, opts = {}) data, _status_code, _headers = update_user_with_http_info(id, user, opts) return data end
ruby
def update_user(id, user, opts = {}) data, _status_code, _headers = update_user_with_http_info(id, user, opts) return data end
[ "def", "update_user", "(", "id", ",", "user", ",", "opts", "=", "{", "}", ")", "data", ",", "_status_code", ",", "_headers", "=", "update_user_with_http_info", "(", "id", ",", "user", ",", "opts", ")", "return", "data", "end" ]
Updates a single user @param id ID of user to fetch @param user User parameters to update @param [Hash] opts the optional parameters @return [UserResponse]
[ "Updates", "a", "single", "user" ]
b2f3781d65ee032ba96eb703fbd789c713a5e0bd
https://github.com/triglav-dataflow/triglav-client-ruby/blob/b2f3781d65ee032ba96eb703fbd789c713a5e0bd/lib/triglav_client/api/users_api.rb#L263-L266
train
romgrod/dater
lib/dater.rb
Dater.Resolver.time_for_period
def time_for_period(string=nil) @last_date = case string when /today/,/now/ now when /tomorrow/ tomorrow_time when /yesterday/ yesterday_time when /sunday/, /monday/, /tuesday/, /wednesday/, /thursday/, /friday/, /saturday/ time_for_weekday(string) when /next/ now + period_of_time_from_string(string.gsub("next","1")) when /last/ now - period_of_time_from_string(string.gsub("last","1")) when /\d[\sa-zA-Z]+\sbefore/ @last_date ||= now @last_date -= period_of_time_from_string(string) when /\d[\sa-zA-Z]+\sago/ @last_date ||= now now - period_of_time_from_string(string) when /\d[\sa-zA-Z]+\slater/ @last_date ||= now @last_date += period_of_time_from_string(string) when /in/,/\d\sminutes?/,/\d\shours?/,/\d\sdays?/, /\d\smonths?/, /\d\sweeks?/, /\d\syears?/ now + period_of_time_from_string(string) when /\d+.\d+.\d+/ time_from_date(string) when /rand/,/future/ now + rand(100_000_000) when /past/ now - rand(100_000_000) end return @last_date end
ruby
def time_for_period(string=nil) @last_date = case string when /today/,/now/ now when /tomorrow/ tomorrow_time when /yesterday/ yesterday_time when /sunday/, /monday/, /tuesday/, /wednesday/, /thursday/, /friday/, /saturday/ time_for_weekday(string) when /next/ now + period_of_time_from_string(string.gsub("next","1")) when /last/ now - period_of_time_from_string(string.gsub("last","1")) when /\d[\sa-zA-Z]+\sbefore/ @last_date ||= now @last_date -= period_of_time_from_string(string) when /\d[\sa-zA-Z]+\sago/ @last_date ||= now now - period_of_time_from_string(string) when /\d[\sa-zA-Z]+\slater/ @last_date ||= now @last_date += period_of_time_from_string(string) when /in/,/\d\sminutes?/,/\d\shours?/,/\d\sdays?/, /\d\smonths?/, /\d\sweeks?/, /\d\syears?/ now + period_of_time_from_string(string) when /\d+.\d+.\d+/ time_from_date(string) when /rand/,/future/ now + rand(100_000_000) when /past/ now - rand(100_000_000) end return @last_date end
[ "def", "time_for_period", "(", "string", "=", "nil", ")", "@last_date", "=", "case", "string", "when", "/", "/", ",", "/", "/", "now", "when", "/", "/", "tomorrow_time", "when", "/", "/", "yesterday_time", "when", "/", "/", ",", "/", "/", ",", "/", "/", ",", "/", "/", ",", "/", "/", ",", "/", "/", ",", "/", "/", "time_for_weekday", "(", "string", ")", "when", "/", "/", "now", "+", "period_of_time_from_string", "(", "string", ".", "gsub", "(", "\"next\"", ",", "\"1\"", ")", ")", "when", "/", "/", "now", "-", "period_of_time_from_string", "(", "string", ".", "gsub", "(", "\"last\"", ",", "\"1\"", ")", ")", "when", "/", "\\d", "\\s", "\\s", "/", "@last_date", "||=", "now", "@last_date", "-=", "period_of_time_from_string", "(", "string", ")", "when", "/", "\\d", "\\s", "\\s", "/", "@last_date", "||=", "now", "now", "-", "period_of_time_from_string", "(", "string", ")", "when", "/", "\\d", "\\s", "\\s", "/", "@last_date", "||=", "now", "@last_date", "+=", "period_of_time_from_string", "(", "string", ")", "when", "/", "/", ",", "/", "\\d", "\\s", "/", ",", "/", "\\d", "\\s", "/", ",", "/", "\\d", "\\s", "/", ",", "/", "\\d", "\\s", "/", ",", "/", "\\d", "\\s", "/", ",", "/", "\\d", "\\s", "/", "now", "+", "period_of_time_from_string", "(", "string", ")", "when", "/", "\\d", "\\d", "\\d", "/", "time_from_date", "(", "string", ")", "when", "/", "/", ",", "/", "/", "now", "+", "rand", "(", "100_000_000", ")", "when", "/", "/", "now", "-", "rand", "(", "100_000_000", ")", "end", "return", "@last_date", "end" ]
Returns the formatted date according to the given period of time expresed in a literal way @param [String] period = time expressed literally (e.g: in 2 days) @return [String] formatted time
[ "Returns", "the", "formatted", "date", "according", "to", "the", "given", "period", "of", "time", "expresed", "in", "a", "literal", "way" ]
b3c1d597e81ed21e62c2874725349502e6f606f8
https://github.com/romgrod/dater/blob/b3c1d597e81ed21e62c2874725349502e6f606f8/lib/dater.rb#L70-L119
train
romgrod/dater
lib/dater.rb
Dater.Resolver.is_required_day?
def is_required_day?(time, day) day_to_ask = "#{day}?" result = eval("time.#{day_to_ask}") if time.respond_to? day_to_ask.to_sym return result end
ruby
def is_required_day?(time, day) day_to_ask = "#{day}?" result = eval("time.#{day_to_ask}") if time.respond_to? day_to_ask.to_sym return result end
[ "def", "is_required_day?", "(", "time", ",", "day", ")", "day_to_ask", "=", "\"#{day}?\"", "result", "=", "eval", "(", "\"time.#{day_to_ask}\"", ")", "if", "time", ".", "respond_to?", "day_to_ask", ".", "to_sym", "return", "result", "end" ]
Method to know if the day is the required day @param [Time] time @param [String] day = to match in case statement @return [Boolean] = true if day is the required day
[ "Method", "to", "know", "if", "the", "day", "is", "the", "required", "day" ]
b3c1d597e81ed21e62c2874725349502e6f606f8
https://github.com/romgrod/dater/blob/b3c1d597e81ed21e62c2874725349502e6f606f8/lib/dater.rb#L176-L180
train
romgrod/dater
lib/dater.rb
Dater.Resolver.multiply_by
def multiply_by(string) return minute_mult(string) || hour_mult(string) || day_mult(string) || week_mult(string) || month_mult(string) || year_mult(string) || 1 end
ruby
def multiply_by(string) return minute_mult(string) || hour_mult(string) || day_mult(string) || week_mult(string) || month_mult(string) || year_mult(string) || 1 end
[ "def", "multiply_by", "(", "string", ")", "return", "minute_mult", "(", "string", ")", "||", "hour_mult", "(", "string", ")", "||", "day_mult", "(", "string", ")", "||", "week_mult", "(", "string", ")", "||", "month_mult", "(", "string", ")", "||", "year_mult", "(", "string", ")", "||", "1", "end" ]
Returns seconds to multiply by for the given string @param [String] period = the period of time expressed in a literal way @return [Fixnum] number to multiply by
[ "Returns", "seconds", "to", "multiply", "by", "for", "the", "given", "string" ]
b3c1d597e81ed21e62c2874725349502e6f606f8
https://github.com/romgrod/dater/blob/b3c1d597e81ed21e62c2874725349502e6f606f8/lib/dater.rb#L299-L301
train
romgrod/dater
lib/dater.rb
Dater.Resolver.time_from_date
def time_from_date(date) numbers=date.scan(/\d+/).map!{|i| i.to_i} day=numbers[2-numbers.index(numbers.max)] Date.new(numbers.max,numbers[1],day).to_time end
ruby
def time_from_date(date) numbers=date.scan(/\d+/).map!{|i| i.to_i} day=numbers[2-numbers.index(numbers.max)] Date.new(numbers.max,numbers[1],day).to_time end
[ "def", "time_from_date", "(", "date", ")", "numbers", "=", "date", ".", "scan", "(", "/", "\\d", "/", ")", ".", "map!", "{", "|", "i", "|", "i", ".", "to_i", "}", "day", "=", "numbers", "[", "2", "-", "numbers", ".", "index", "(", "numbers", ".", "max", ")", "]", "Date", ".", "new", "(", "numbers", ".", "max", ",", "numbers", "[", "1", "]", ",", "day", ")", ".", "to_time", "end" ]
Return the Time object according to the splitted date in the given array @param [String] date @return [Time]
[ "Return", "the", "Time", "object", "according", "to", "the", "splitted", "date", "in", "the", "given", "array" ]
b3c1d597e81ed21e62c2874725349502e6f606f8
https://github.com/romgrod/dater/blob/b3c1d597e81ed21e62c2874725349502e6f606f8/lib/dater.rb#L309-L313
train
romgrod/dater
lib/dater.rb
Dater.Resolver.method_missing
def method_missing(meth) self.class.send :define_method, meth do string = meth.to_s.gsub("_"," ") self.for("for('#{string}')") end begin self.send(meth.to_s) rescue raise "Method does not exists (#{meth})." end end
ruby
def method_missing(meth) self.class.send :define_method, meth do string = meth.to_s.gsub("_"," ") self.for("for('#{string}')") end begin self.send(meth.to_s) rescue raise "Method does not exists (#{meth})." end end
[ "def", "method_missing", "(", "meth", ")", "self", ".", "class", ".", "send", ":define_method", ",", "meth", "do", "string", "=", "meth", ".", "to_s", ".", "gsub", "(", "\"_\"", ",", "\" \"", ")", "self", ".", "for", "(", "\"for('#{string}')\"", ")", "end", "begin", "self", ".", "send", "(", "meth", ".", "to_s", ")", "rescue", "raise", "\"Method does not exists (#{meth}).\"", "end", "end" ]
Try to convert Missing methods to string and call to for method with converted string
[ "Try", "to", "convert", "Missing", "methods", "to", "string", "and", "call", "to", "for", "method", "with", "converted", "string" ]
b3c1d597e81ed21e62c2874725349502e6f606f8
https://github.com/romgrod/dater/blob/b3c1d597e81ed21e62c2874725349502e6f606f8/lib/dater.rb#L327-L337
train
barkerest/incline
app/models/incline/action_security.rb
Incline.ActionSecurity.update_flags
def update_flags self.allow_anon = self.require_anon = self.require_admin = self.unknown_controller = self.non_standard = false self.unknown_controller = true klass = ::Incline.get_controller_class(controller_name) if klass self.unknown_controller = false if klass.require_admin_for?(action_name) self.require_admin = true elsif klass.require_anon_for?(action_name) self.require_anon = true elsif klass.allow_anon_for?(action_name) self.allow_anon = true end # if the authentication methods are overridden, set a flag to alert the user that standard security may not be honored. unless klass.instance_method(:valid_user?).owner == Incline::Extensions::ActionControllerBase && klass.instance_method(:authorize!).owner == Incline::Extensions::ActionControllerBase self.non_standard = true end end end
ruby
def update_flags self.allow_anon = self.require_anon = self.require_admin = self.unknown_controller = self.non_standard = false self.unknown_controller = true klass = ::Incline.get_controller_class(controller_name) if klass self.unknown_controller = false if klass.require_admin_for?(action_name) self.require_admin = true elsif klass.require_anon_for?(action_name) self.require_anon = true elsif klass.allow_anon_for?(action_name) self.allow_anon = true end # if the authentication methods are overridden, set a flag to alert the user that standard security may not be honored. unless klass.instance_method(:valid_user?).owner == Incline::Extensions::ActionControllerBase && klass.instance_method(:authorize!).owner == Incline::Extensions::ActionControllerBase self.non_standard = true end end end
[ "def", "update_flags", "self", ".", "allow_anon", "=", "self", ".", "require_anon", "=", "self", ".", "require_admin", "=", "self", ".", "unknown_controller", "=", "self", ".", "non_standard", "=", "false", "self", ".", "unknown_controller", "=", "true", "klass", "=", "::", "Incline", ".", "get_controller_class", "(", "controller_name", ")", "if", "klass", "self", ".", "unknown_controller", "=", "false", "if", "klass", ".", "require_admin_for?", "(", "action_name", ")", "self", ".", "require_admin", "=", "true", "elsif", "klass", ".", "require_anon_for?", "(", "action_name", ")", "self", ".", "require_anon", "=", "true", "elsif", "klass", ".", "allow_anon_for?", "(", "action_name", ")", "self", ".", "allow_anon", "=", "true", "end", "unless", "klass", ".", "instance_method", "(", ":valid_user?", ")", ".", "owner", "==", "Incline", "::", "Extensions", "::", "ActionControllerBase", "&&", "klass", ".", "instance_method", "(", ":authorize!", ")", ".", "owner", "==", "Incline", "::", "Extensions", "::", "ActionControllerBase", "self", ".", "non_standard", "=", "true", "end", "end", "end" ]
Updates the flags based on the controller configuration.
[ "Updates", "the", "flags", "based", "on", "the", "controller", "configuration", "." ]
1ff08db7aa8ab7f86b223268b700bc67d15bb8aa
https://github.com/barkerest/incline/blob/1ff08db7aa8ab7f86b223268b700bc67d15bb8aa/app/models/incline/action_security.rb#L30-L54
train
barkerest/incline
app/models/incline/action_security.rb
Incline.ActionSecurity.permitted
def permitted(refresh = false) @permitted = nil if refresh @permitted ||= if require_admin? 'Administrators Only' elsif require_anon? 'Anonymous Only' elsif allow_anon? 'Everyone' elsif groups.any? names = groups.pluck(:name).map{|v| "\"#{v}\""} 'Members of ' + if names.count == 1 names.first elsif names.count == 2 names.join(' or ') else names[0...-1].join(', ') + ', or ' + names.last end else 'All Users' end + if non_standard ' (Non-Standard)' else '' end end
ruby
def permitted(refresh = false) @permitted = nil if refresh @permitted ||= if require_admin? 'Administrators Only' elsif require_anon? 'Anonymous Only' elsif allow_anon? 'Everyone' elsif groups.any? names = groups.pluck(:name).map{|v| "\"#{v}\""} 'Members of ' + if names.count == 1 names.first elsif names.count == 2 names.join(' or ') else names[0...-1].join(', ') + ', or ' + names.last end else 'All Users' end + if non_standard ' (Non-Standard)' else '' end end
[ "def", "permitted", "(", "refresh", "=", "false", ")", "@permitted", "=", "nil", "if", "refresh", "@permitted", "||=", "if", "require_admin?", "'Administrators Only'", "elsif", "require_anon?", "'Anonymous Only'", "elsif", "allow_anon?", "'Everyone'", "elsif", "groups", ".", "any?", "names", "=", "groups", ".", "pluck", "(", ":name", ")", ".", "map", "{", "|", "v", "|", "\"\\\"#{v}\\\"\"", "}", "'Members of '", "+", "if", "names", ".", "count", "==", "1", "names", ".", "first", "elsif", "names", ".", "count", "==", "2", "names", ".", "join", "(", "' or '", ")", "else", "names", "[", "0", "...", "-", "1", "]", ".", "join", "(", "', '", ")", "+", "', or '", "+", "names", ".", "last", "end", "else", "'All Users'", "end", "+", "if", "non_standard", "' (Non-Standard)'", "else", "''", "end", "end" ]
Gets a string describing who is permitted to execute the action.
[ "Gets", "a", "string", "describing", "who", "is", "permitted", "to", "execute", "the", "action", "." ]
1ff08db7aa8ab7f86b223268b700bc67d15bb8aa
https://github.com/barkerest/incline/blob/1ff08db7aa8ab7f86b223268b700bc67d15bb8aa/app/models/incline/action_security.rb#L129-L156
train
barkerest/incline
app/models/incline/action_security.rb
Incline.ActionSecurity.group_ids=
def group_ids=(values) values ||= [] values = [ values ] unless values.is_a?(::Array) values = values.reject{|v| v.blank?}.map{|v| v.to_i} self.groups = Incline::AccessGroup.where(id: values).to_a end
ruby
def group_ids=(values) values ||= [] values = [ values ] unless values.is_a?(::Array) values = values.reject{|v| v.blank?}.map{|v| v.to_i} self.groups = Incline::AccessGroup.where(id: values).to_a end
[ "def", "group_ids", "=", "(", "values", ")", "values", "||=", "[", "]", "values", "=", "[", "values", "]", "unless", "values", ".", "is_a?", "(", "::", "Array", ")", "values", "=", "values", ".", "reject", "{", "|", "v", "|", "v", ".", "blank?", "}", ".", "map", "{", "|", "v", "|", "v", ".", "to_i", "}", "self", ".", "groups", "=", "Incline", "::", "AccessGroup", ".", "where", "(", "id", ":", "values", ")", ".", "to_a", "end" ]
Sets the group IDs accepted by this action.
[ "Sets", "the", "group", "IDs", "accepted", "by", "this", "action", "." ]
1ff08db7aa8ab7f86b223268b700bc67d15bb8aa
https://github.com/barkerest/incline/blob/1ff08db7aa8ab7f86b223268b700bc67d15bb8aa/app/models/incline/action_security.rb#L193-L198
train
TheComments/the_viking
lib/the_viking/akismet.rb
TheViking.Akismet.check_comment
def check_comment(options = {}) return false if invalid_options? message = call_akismet('comment-check', options) { :spam => !self.class.valid_responses.include?(message), :message => message } end
ruby
def check_comment(options = {}) return false if invalid_options? message = call_akismet('comment-check', options) { :spam => !self.class.valid_responses.include?(message), :message => message } end
[ "def", "check_comment", "(", "options", "=", "{", "}", ")", "return", "false", "if", "invalid_options?", "message", "=", "call_akismet", "(", "'comment-check'", ",", "options", ")", "{", ":spam", "=>", "!", "self", ".", "class", ".", "valid_responses", ".", "include?", "(", "message", ")", ",", ":message", "=>", "message", "}", "end" ]
This is basically the core of everything. This call takes a number of arguments and characteristics about the submitted content and then returns a thumbs up or thumbs down. Almost everything is optional, but performance can drop dramatically if you exclude certain elements. ==== Arguments +options+ <Hash>:: describes the comment being verified The following keys are available for the +options+ hash: +user_ip+ (*required*):: IP address of the comment submitter. +user_agent+ (*required*):: user agent information. +referrer+ (<i>note spelling</i>):: the content of the HTTP_REFERER header should be sent here. +permalink+:: permanent location of the entry the comment was submitted to +comment_type+:: may be blank, comment, trackback, pingback, or a made up value like "registration". +comment_author+:: submitted name with the comment +comment_author_email+:: submitted email address +comment_author_url+:: commenter URL +comment_content+:: the content that was submitted Other server enviroment variables:: In PHP there is an array of enviroment variables called <tt>_SERVER</tt> which contains information about the web server itself as well as a key/value for every HTTP header sent with the request. This data is highly useful to Akismet as how the submited content interacts with the server can be very telling, so please include as much information as possible.
[ "This", "is", "basically", "the", "core", "of", "everything", ".", "This", "call", "takes", "a", "number", "of", "arguments", "and", "characteristics", "about", "the", "submitted", "content", "and", "then", "returns", "a", "thumbs", "up", "or", "thumbs", "down", ".", "Almost", "everything", "is", "optional", "but", "performance", "can", "drop", "dramatically", "if", "you", "exclude", "certain", "elements", "." ]
66ab061d5c07789377b07d875f99267e3846665f
https://github.com/TheComments/the_viking/blob/66ab061d5c07789377b07d875f99267e3846665f/lib/the_viking/akismet.rb#L95-L99
train
TheComments/the_viking
lib/the_viking/akismet.rb
TheViking.Akismet.call_akismet
def call_akismet(akismet_function, options = {}) http_post( Net::HTTP.new([self.options[:api_key], self.class.host].join('.'), options[:proxy_host], options[:proxy_port]), akismet_function, options.update(:blog => self.options[:blog]).to_query ) end
ruby
def call_akismet(akismet_function, options = {}) http_post( Net::HTTP.new([self.options[:api_key], self.class.host].join('.'), options[:proxy_host], options[:proxy_port]), akismet_function, options.update(:blog => self.options[:blog]).to_query ) end
[ "def", "call_akismet", "(", "akismet_function", ",", "options", "=", "{", "}", ")", "http_post", "(", "Net", "::", "HTTP", ".", "new", "(", "[", "self", ".", "options", "[", ":api_key", "]", ",", "self", ".", "class", ".", "host", "]", ".", "join", "(", "'.'", ")", ",", "options", "[", ":proxy_host", "]", ",", "options", "[", ":proxy_port", "]", ")", ",", "akismet_function", ",", "options", ".", "update", "(", ":blog", "=>", "self", ".", "options", "[", ":blog", "]", ")", ".", "to_query", ")", "end" ]
Internal call to Akismet. Prepares the data for posting to the Akismet service. ==== Arguments +akismet_function+ <String>:: the Akismet function that should be called The following keys are available to configure a given call to Akismet: +user_ip+ (*required*):: IP address of the comment submitter. +user_agent+ (*required*):: user agent information. +referrer+ (<i>note spelling</i>):: the content of the HTTP_REFERER header should be sent here. +permalink+:: the permanent location of the entry the comment was submitted to. +comment_type+:: may be blank, comment, trackback, pingback, or a made up value like "registration". +comment_author+:: submitted name with the comment +comment_author_email+:: submitted email address +comment_author_url+:: commenter URL +comment_content+:: the content that was submitted Other server enviroment variables:: In PHP there is an array of enviroment variables called <tt>_SERVER</tt> which contains information about the web server itself as well as a key/value for every HTTP header sent with the request. This data is highly useful to Akismet as how the submited content interacts with the server can be very telling, so please include as much information as possible.
[ "Internal", "call", "to", "Akismet", ".", "Prepares", "the", "data", "for", "posting", "to", "the", "Akismet", "service", "." ]
66ab061d5c07789377b07d875f99267e3846665f
https://github.com/TheComments/the_viking/blob/66ab061d5c07789377b07d875f99267e3846665f/lib/the_viking/akismet.rb#L165-L171
train
KatanaCode/evvnt
lib/evvnt/actions.rb
Evvnt.Actions.define_action
def define_action(action, &block) action = action.to_sym defined_actions << action unless defined_actions.include?(action) if action.in?(Evvnt::ClassTemplateMethods.instance_methods) define_class_action(action, &block) end if action.in?(Evvnt::InstanceTemplateMethods.instance_methods) define_instance_action(action, &block) end action end
ruby
def define_action(action, &block) action = action.to_sym defined_actions << action unless defined_actions.include?(action) if action.in?(Evvnt::ClassTemplateMethods.instance_methods) define_class_action(action, &block) end if action.in?(Evvnt::InstanceTemplateMethods.instance_methods) define_instance_action(action, &block) end action end
[ "def", "define_action", "(", "action", ",", "&", "block", ")", "action", "=", "action", ".", "to_sym", "defined_actions", "<<", "action", "unless", "defined_actions", ".", "include?", "(", "action", ")", "if", "action", ".", "in?", "(", "Evvnt", "::", "ClassTemplateMethods", ".", "instance_methods", ")", "define_class_action", "(", "action", ",", "&", "block", ")", "end", "if", "action", ".", "in?", "(", "Evvnt", "::", "InstanceTemplateMethods", ".", "instance_methods", ")", "define_instance_action", "(", "action", ",", "&", "block", ")", "end", "action", "end" ]
Define an action for this class to map on to the Evvnt API for this class's resource. action - A Symbol or String representing the action name. Should be one of the template actions if block is not provided. block - A Proc to be used as the action method definition when custom behaviour is required. Examples class Package < Evvnt::Base # Define using the template `all` method define_action :all define_action :mine do # define the custom behaviour here end end Returns Symbol
[ "Define", "an", "action", "for", "this", "class", "to", "map", "on", "to", "the", "Evvnt", "API", "for", "this", "class", "s", "resource", "." ]
e13f6d84af09a71819356620fb25685a6cd159c9
https://github.com/KatanaCode/evvnt/blob/e13f6d84af09a71819356620fb25685a6cd159c9/lib/evvnt/actions.rb#L51-L61
train
TonFw/br_open_data
lib/br_open_data/parent_service.rb
BROpenData.ParentService.get_request
def get_request(hash=true) resp = RestClient.get get_url hash ? Hash.from_xml(resp).it_keys_to_sym : resp end
ruby
def get_request(hash=true) resp = RestClient.get get_url hash ? Hash.from_xml(resp).it_keys_to_sym : resp end
[ "def", "get_request", "(", "hash", "=", "true", ")", "resp", "=", "RestClient", ".", "get", "get_url", "hash", "?", "Hash", ".", "from_xml", "(", "resp", ")", ".", "it_keys_to_sym", ":", "resp", "end" ]
send GET HTTP request
[ "send", "GET", "HTTP", "request" ]
c0ddfbf0b38137aa4246d634468520a755248dae
https://github.com/TonFw/br_open_data/blob/c0ddfbf0b38137aa4246d634468520a755248dae/lib/br_open_data/parent_service.rb#L30-L33
train
EcomDev/ecomdev-chefspec
lib/ecomdev/chefspec/helpers/platform.rb
EcomDev::ChefSpec::Helpers.Platform.filter
def filter(*conditions) latest = !conditions.select {|item| item === true }.empty? filters = translate_conditions(conditions) items = list(latest) unless filters.empty? items = items.select do |item| !filters.select {|filter| match_filter(filter, item) }.empty? end end items end
ruby
def filter(*conditions) latest = !conditions.select {|item| item === true }.empty? filters = translate_conditions(conditions) items = list(latest) unless filters.empty? items = items.select do |item| !filters.select {|filter| match_filter(filter, item) }.empty? end end items end
[ "def", "filter", "(", "*", "conditions", ")", "latest", "=", "!", "conditions", ".", "select", "{", "|", "item", "|", "item", "===", "true", "}", ".", "empty?", "filters", "=", "translate_conditions", "(", "conditions", ")", "items", "=", "list", "(", "latest", ")", "unless", "filters", ".", "empty?", "items", "=", "items", ".", "select", "do", "|", "item", "|", "!", "filters", ".", "select", "{", "|", "filter", "|", "match_filter", "(", "filter", ",", "item", ")", "}", ".", "empty?", "end", "end", "items", "end" ]
Returns list of available os versions filtered by conditions Each condition is treated as OR operation If no condition is specified all items are listed If TrueClass is supplied as one of the arguments it filters only last versions
[ "Returns", "list", "of", "available", "os", "versions", "filtered", "by", "conditions" ]
67abb6d882aef11a8726b296e4db4bf715ec5869
https://github.com/EcomDev/ecomdev-chefspec/blob/67abb6d882aef11a8726b296e4db4bf715ec5869/lib/ecomdev/chefspec/helpers/platform.rb#L53-L64
train
EcomDev/ecomdev-chefspec
lib/ecomdev/chefspec/helpers/platform.rb
EcomDev::ChefSpec::Helpers.Platform.is_version
def is_version(string) return false if string === false || string === true || string.nil? string.to_s.match(/^\d+[\d\.a-zA-Z\-_~]*/) end
ruby
def is_version(string) return false if string === false || string === true || string.nil? string.to_s.match(/^\d+[\d\.a-zA-Z\-_~]*/) end
[ "def", "is_version", "(", "string", ")", "return", "false", "if", "string", "===", "false", "||", "string", "===", "true", "||", "string", ".", "nil?", "string", ".", "to_s", ".", "match", "(", "/", "\\d", "\\d", "\\.", "\\-", "/", ")", "end" ]
Returns `true` if provided value is a version string @param string [String, Symbol] value to check @return [TrueClass, FalseClass]
[ "Returns", "true", "if", "provided", "value", "is", "a", "version", "string" ]
67abb6d882aef11a8726b296e4db4bf715ec5869
https://github.com/EcomDev/ecomdev-chefspec/blob/67abb6d882aef11a8726b296e4db4bf715ec5869/lib/ecomdev/chefspec/helpers/platform.rb#L106-L109
train
EcomDev/ecomdev-chefspec
lib/ecomdev/chefspec/helpers/platform.rb
EcomDev::ChefSpec::Helpers.Platform.is_os
def is_os(string) return false if string === false || string === true || string.nil? @os.key?(string.to_sym) end
ruby
def is_os(string) return false if string === false || string === true || string.nil? @os.key?(string.to_sym) end
[ "def", "is_os", "(", "string", ")", "return", "false", "if", "string", "===", "false", "||", "string", "===", "true", "||", "string", ".", "nil?", "@os", ".", "key?", "(", "string", ".", "to_sym", ")", "end" ]
Returns `true` if provided value is a registered OS @param string [String, Symbol] value to check @return [TrueClass, FalseClass]
[ "Returns", "true", "if", "provided", "value", "is", "a", "registered", "OS" ]
67abb6d882aef11a8726b296e4db4bf715ec5869
https://github.com/EcomDev/ecomdev-chefspec/blob/67abb6d882aef11a8726b296e4db4bf715ec5869/lib/ecomdev/chefspec/helpers/platform.rb#L114-L117
train
EcomDev/ecomdev-chefspec
lib/ecomdev/chefspec/helpers/platform.rb
EcomDev::ChefSpec::Helpers.Platform.match_filter
def match_filter(filter, item) filter.each_pair do |key, value| unless item.key?(key) return false end unless value.is_a?(Array) return false if value != item[key] else return true if value.empty? return false unless value.include?(item[key]) end end true end
ruby
def match_filter(filter, item) filter.each_pair do |key, value| unless item.key?(key) return false end unless value.is_a?(Array) return false if value != item[key] else return true if value.empty? return false unless value.include?(item[key]) end end true end
[ "def", "match_filter", "(", "filter", ",", "item", ")", "filter", ".", "each_pair", "do", "|", "key", ",", "value", "|", "unless", "item", ".", "key?", "(", "key", ")", "return", "false", "end", "unless", "value", ".", "is_a?", "(", "Array", ")", "return", "false", "if", "value", "!=", "item", "[", "key", "]", "else", "return", "true", "if", "value", ".", "empty?", "return", "false", "unless", "value", ".", "include?", "(", "item", "[", "key", "]", ")", "end", "end", "true", "end" ]
Returns true if item matches filter conditions @param filter [Hash{Symbol => String, Symbol}] @param item [Hash{Symbol => String, Symbol}] @return [true, false]
[ "Returns", "true", "if", "item", "matches", "filter", "conditions" ]
67abb6d882aef11a8726b296e4db4bf715ec5869
https://github.com/EcomDev/ecomdev-chefspec/blob/67abb6d882aef11a8726b296e4db4bf715ec5869/lib/ecomdev/chefspec/helpers/platform.rb#L123-L136
train
EcomDev/ecomdev-chefspec
lib/ecomdev/chefspec/helpers/platform.rb
EcomDev::ChefSpec::Helpers.Platform.list
def list(latest = false) result = [] @os.map do |os, versions| unless latest versions.each { |version| result << {os: os, version: version}} else result << {os: os, version: versions.last} if versions.length > 0 end end result end
ruby
def list(latest = false) result = [] @os.map do |os, versions| unless latest versions.each { |version| result << {os: os, version: version}} else result << {os: os, version: versions.last} if versions.length > 0 end end result end
[ "def", "list", "(", "latest", "=", "false", ")", "result", "=", "[", "]", "@os", ".", "map", "do", "|", "os", ",", "versions", "|", "unless", "latest", "versions", ".", "each", "{", "|", "version", "|", "result", "<<", "{", "os", ":", "os", ",", "version", ":", "version", "}", "}", "else", "result", "<<", "{", "os", ":", "os", ",", "version", ":", "versions", ".", "last", "}", "if", "versions", ".", "length", ">", "0", "end", "end", "result", "end" ]
Returns list of available os versions @param [TrueClass, FalseClass] latest specify if would like to receive only latest @return [Array<Hash{Symbol => String, Symbol}>] list of os versions in view of hash
[ "Returns", "list", "of", "available", "os", "versions" ]
67abb6d882aef11a8726b296e4db4bf715ec5869
https://github.com/EcomDev/ecomdev-chefspec/blob/67abb6d882aef11a8726b296e4db4bf715ec5869/lib/ecomdev/chefspec/helpers/platform.rb#L144-L154
train
gemeraldbeanstalk/stalk_climber
lib/stalk_climber/connection.rb
StalkClimber.Connection.fetch_and_cache_job
def fetch_and_cache_job(job_id) job = fetch_job(job_id) self.cached_jobs[job_id] = job unless job.nil? @min_climbed_job_id = job_id if job_id < @min_climbed_job_id @max_climbed_job_id = job_id if job_id > @max_climbed_job_id return job end
ruby
def fetch_and_cache_job(job_id) job = fetch_job(job_id) self.cached_jobs[job_id] = job unless job.nil? @min_climbed_job_id = job_id if job_id < @min_climbed_job_id @max_climbed_job_id = job_id if job_id > @max_climbed_job_id return job end
[ "def", "fetch_and_cache_job", "(", "job_id", ")", "job", "=", "fetch_job", "(", "job_id", ")", "self", ".", "cached_jobs", "[", "job_id", "]", "=", "job", "unless", "job", ".", "nil?", "@min_climbed_job_id", "=", "job_id", "if", "job_id", "<", "@min_climbed_job_id", "@max_climbed_job_id", "=", "job_id", "if", "job_id", ">", "@max_climbed_job_id", "return", "job", "end" ]
Helper method, similar to fetch_job, that retrieves the job identified by +job_id+, caches it, and updates counters before returning the job. If the job does not exist, nothing is cached, however counters will be updated, and nil is returned
[ "Helper", "method", "similar", "to", "fetch_job", "that", "retrieves", "the", "job", "identified", "by", "+", "job_id", "+", "caches", "it", "and", "updates", "counters", "before", "returning", "the", "job", ".", "If", "the", "job", "does", "not", "exist", "nothing", "is", "cached", "however", "counters", "will", "be", "updated", "and", "nil", "is", "returned" ]
d22f74bbae864ca2771d15621ccbf29d8e86521a
https://github.com/gemeraldbeanstalk/stalk_climber/blob/d22f74bbae864ca2771d15621ccbf29d8e86521a/lib/stalk_climber/connection.rb#L144-L150
train
rit-sse-mycroft/template-ruby
lib/mycroft/messages.rb
Mycroft.Messages.connect_to_mycroft
def connect_to_mycroft if ARGV.include?("--no-tls") @client = TCPSocket.open(@host, @port) else socket = TCPSocket.new(@host, @port) ssl_context = OpenSSL::SSL::SSLContext.new ssl_context.cert = OpenSSL::X509::Certificate.new(File.open(@cert)) ssl_context.key = OpenSSL::PKey::RSA.new(File.open(@key)) @client = OpenSSL::SSL::SSLSocket.new(socket, ssl_context) begin @client.connect rescue end end end
ruby
def connect_to_mycroft if ARGV.include?("--no-tls") @client = TCPSocket.open(@host, @port) else socket = TCPSocket.new(@host, @port) ssl_context = OpenSSL::SSL::SSLContext.new ssl_context.cert = OpenSSL::X509::Certificate.new(File.open(@cert)) ssl_context.key = OpenSSL::PKey::RSA.new(File.open(@key)) @client = OpenSSL::SSL::SSLSocket.new(socket, ssl_context) begin @client.connect rescue end end end
[ "def", "connect_to_mycroft", "if", "ARGV", ".", "include?", "(", "\"--no-tls\"", ")", "@client", "=", "TCPSocket", ".", "open", "(", "@host", ",", "@port", ")", "else", "socket", "=", "TCPSocket", ".", "new", "(", "@host", ",", "@port", ")", "ssl_context", "=", "OpenSSL", "::", "SSL", "::", "SSLContext", ".", "new", "ssl_context", ".", "cert", "=", "OpenSSL", "::", "X509", "::", "Certificate", ".", "new", "(", "File", ".", "open", "(", "@cert", ")", ")", "ssl_context", ".", "key", "=", "OpenSSL", "::", "PKey", "::", "RSA", ".", "new", "(", "File", ".", "open", "(", "@key", ")", ")", "@client", "=", "OpenSSL", "::", "SSL", "::", "SSLSocket", ".", "new", "(", "socket", ",", "ssl_context", ")", "begin", "@client", ".", "connect", "rescue", "end", "end", "end" ]
connects to mycroft aka starts tls if necessary
[ "connects", "to", "mycroft", "aka", "starts", "tls", "if", "necessary" ]
60ede42375b4647b9770bc9a03e614f8d90233ac
https://github.com/rit-sse-mycroft/template-ruby/blob/60ede42375b4647b9770bc9a03e614f8d90233ac/lib/mycroft/messages.rb#L10-L24
train
rit-sse-mycroft/template-ruby
lib/mycroft/messages.rb
Mycroft.Messages.send_manifest
def send_manifest begin manifest = JSON.parse(File.read(@manifest)) manifest['instanceId'] = "#{Socket.gethostname}_#{SecureRandom.uuid}" if @generate_instance_ids @instance_id = manifest['instanceId'] rescue end send_message('APP_MANIFEST', manifest) end
ruby
def send_manifest begin manifest = JSON.parse(File.read(@manifest)) manifest['instanceId'] = "#{Socket.gethostname}_#{SecureRandom.uuid}" if @generate_instance_ids @instance_id = manifest['instanceId'] rescue end send_message('APP_MANIFEST', manifest) end
[ "def", "send_manifest", "begin", "manifest", "=", "JSON", ".", "parse", "(", "File", ".", "read", "(", "@manifest", ")", ")", "manifest", "[", "'instanceId'", "]", "=", "\"#{Socket.gethostname}_#{SecureRandom.uuid}\"", "if", "@generate_instance_ids", "@instance_id", "=", "manifest", "[", "'instanceId'", "]", "rescue", "end", "send_message", "(", "'APP_MANIFEST'", ",", "manifest", ")", "end" ]
Sends the app manifest to mycroft
[ "Sends", "the", "app", "manifest", "to", "mycroft" ]
60ede42375b4647b9770bc9a03e614f8d90233ac
https://github.com/rit-sse-mycroft/template-ruby/blob/60ede42375b4647b9770bc9a03e614f8d90233ac/lib/mycroft/messages.rb#L27-L35
train
rit-sse-mycroft/template-ruby
lib/mycroft/messages.rb
Mycroft.Messages.query
def query(capability, action, data, priority = 30, instance_id = nil) query_message = { id: SecureRandom.uuid, capability: capability, action: action, data: data, priority: priority, instanceId: [] } query_message[:instanceId] = instance_id unless instance_id.nil? send_message('MSG_QUERY', query_message) end
ruby
def query(capability, action, data, priority = 30, instance_id = nil) query_message = { id: SecureRandom.uuid, capability: capability, action: action, data: data, priority: priority, instanceId: [] } query_message[:instanceId] = instance_id unless instance_id.nil? send_message('MSG_QUERY', query_message) end
[ "def", "query", "(", "capability", ",", "action", ",", "data", ",", "priority", "=", "30", ",", "instance_id", "=", "nil", ")", "query_message", "=", "{", "id", ":", "SecureRandom", ".", "uuid", ",", "capability", ":", "capability", ",", "action", ":", "action", ",", "data", ":", "data", ",", "priority", ":", "priority", ",", "instanceId", ":", "[", "]", "}", "query_message", "[", ":instanceId", "]", "=", "instance_id", "unless", "instance_id", ".", "nil?", "send_message", "(", "'MSG_QUERY'", ",", "query_message", ")", "end" ]
Sends a query to mycroft
[ "Sends", "a", "query", "to", "mycroft" ]
60ede42375b4647b9770bc9a03e614f8d90233ac
https://github.com/rit-sse-mycroft/template-ruby/blob/60ede42375b4647b9770bc9a03e614f8d90233ac/lib/mycroft/messages.rb#L52-L64
train
rit-sse-mycroft/template-ruby
lib/mycroft/messages.rb
Mycroft.Messages.broadcast
def broadcast(content) message = { id: SecureRandom.uuid, content: content } send_message('MSG_BROADCAST', message) end
ruby
def broadcast(content) message = { id: SecureRandom.uuid, content: content } send_message('MSG_BROADCAST', message) end
[ "def", "broadcast", "(", "content", ")", "message", "=", "{", "id", ":", "SecureRandom", ".", "uuid", ",", "content", ":", "content", "}", "send_message", "(", "'MSG_BROADCAST'", ",", "message", ")", "end" ]
Sends a broadcast to the mycroft message board
[ "Sends", "a", "broadcast", "to", "the", "mycroft", "message", "board" ]
60ede42375b4647b9770bc9a03e614f8d90233ac
https://github.com/rit-sse-mycroft/template-ruby/blob/60ede42375b4647b9770bc9a03e614f8d90233ac/lib/mycroft/messages.rb#L83-L90
train
saclark/lite_page
lib/lite_page/page_initializers.rb
LitePage.PageInitializers.visit
def visit(page_class, query_params = {}, browser = @browser) page = page_class.new(browser) url = query_params.empty? ? page.page_url : page.page_url(query_params) browser.goto(url) yield page if block_given? page end
ruby
def visit(page_class, query_params = {}, browser = @browser) page = page_class.new(browser) url = query_params.empty? ? page.page_url : page.page_url(query_params) browser.goto(url) yield page if block_given? page end
[ "def", "visit", "(", "page_class", ",", "query_params", "=", "{", "}", ",", "browser", "=", "@browser", ")", "page", "=", "page_class", ".", "new", "(", "browser", ")", "url", "=", "query_params", ".", "empty?", "?", "page", ".", "page_url", ":", "page", ".", "page_url", "(", "query_params", ")", "browser", ".", "goto", "(", "url", ")", "yield", "page", "if", "block_given?", "page", "end" ]
Initializes an instance of the given page class, drives the given browser instance to the page's url with any given query parameters appended, yields the page instance to a block if given, and returns the page instance. @param page_class [Class] the page class @param query_params [Hash, Array] the query parameters to append to the page url to viist @param browser [Object] the browser instance @yield [page] yields page instance to a block
[ "Initializes", "an", "instance", "of", "the", "given", "page", "class", "drives", "the", "given", "browser", "instance", "to", "the", "page", "s", "url", "with", "any", "given", "query", "parameters", "appended", "yields", "the", "page", "instance", "to", "a", "block", "if", "given", "and", "returns", "the", "page", "instance", "." ]
efa3ae28a49428ee60c6ee95b51c5d79f603acec
https://github.com/saclark/lite_page/blob/efa3ae28a49428ee60c6ee95b51c5d79f603acec/lib/lite_page/page_initializers.rb#L11-L19
train
saclark/lite_page
lib/lite_page/page_initializers.rb
LitePage.PageInitializers.on
def on(page_class, browser = @browser) page = page_class.new(browser) yield page if block_given? page end
ruby
def on(page_class, browser = @browser) page = page_class.new(browser) yield page if block_given? page end
[ "def", "on", "(", "page_class", ",", "browser", "=", "@browser", ")", "page", "=", "page_class", ".", "new", "(", "browser", ")", "yield", "page", "if", "block_given?", "page", "end" ]
Initializes and returns an instance of the given page class. Yields the page instance to a block if given. @param page_class [Class] the page class @param browser [Object] the browser instance @yield [page] yields page instance to a block
[ "Initializes", "and", "returns", "an", "instance", "of", "the", "given", "page", "class", ".", "Yields", "the", "page", "instance", "to", "a", "block", "if", "given", "." ]
efa3ae28a49428ee60c6ee95b51c5d79f603acec
https://github.com/saclark/lite_page/blob/efa3ae28a49428ee60c6ee95b51c5d79f603acec/lib/lite_page/page_initializers.rb#L27-L31
train
starrhorne/konfig
lib/konfig/store.rb
Konfig.Store.load_directory
def load_directory(path) unless File.directory?(path) raise "Konfig couldn't load because it was unable to access #{ path }. Please make sure the directory exists and has the correct permissions." end Dir[File.join(path, "*.yml")].each { |f| load_file(f) } end
ruby
def load_directory(path) unless File.directory?(path) raise "Konfig couldn't load because it was unable to access #{ path }. Please make sure the directory exists and has the correct permissions." end Dir[File.join(path, "*.yml")].each { |f| load_file(f) } end
[ "def", "load_directory", "(", "path", ")", "unless", "File", ".", "directory?", "(", "path", ")", "raise", "\"Konfig couldn't load because it was unable to access #{ path }. Please make sure the directory exists and has the correct permissions.\"", "end", "Dir", "[", "File", ".", "join", "(", "path", ",", "\"*.yml\"", ")", "]", ".", "each", "{", "|", "f", "|", "load_file", "(", "f", ")", "}", "end" ]
Loads all yml files in a directory into this store Will not recurse into subdirectories. @param [String] path to directory
[ "Loads", "all", "yml", "files", "in", "a", "directory", "into", "this", "store", "Will", "not", "recurse", "into", "subdirectories", "." ]
5d655945586a489868bb868243d9c0da18c90228
https://github.com/starrhorne/konfig/blob/5d655945586a489868bb868243d9c0da18c90228/lib/konfig/store.rb#L16-L23
train
starrhorne/konfig
lib/konfig/store.rb
Konfig.Store.load_file
def load_file(path) d = YAML.load_file(path) if d.is_a?(Hash) d = HashWithIndifferentAccess.new(d) e = Evaluator.new(d) d = process(d, e) end @data[File.basename(path, ".yml").downcase] = d end
ruby
def load_file(path) d = YAML.load_file(path) if d.is_a?(Hash) d = HashWithIndifferentAccess.new(d) e = Evaluator.new(d) d = process(d, e) end @data[File.basename(path, ".yml").downcase] = d end
[ "def", "load_file", "(", "path", ")", "d", "=", "YAML", ".", "load_file", "(", "path", ")", "if", "d", ".", "is_a?", "(", "Hash", ")", "d", "=", "HashWithIndifferentAccess", ".", "new", "(", "d", ")", "e", "=", "Evaluator", ".", "new", "(", "d", ")", "d", "=", "process", "(", "d", ",", "e", ")", "end", "@data", "[", "File", ".", "basename", "(", "path", ",", "\".yml\"", ")", ".", "downcase", "]", "=", "d", "end" ]
Loads a single yml file into the store @param [String] path to file
[ "Loads", "a", "single", "yml", "file", "into", "the", "store" ]
5d655945586a489868bb868243d9c0da18c90228
https://github.com/starrhorne/konfig/blob/5d655945586a489868bb868243d9c0da18c90228/lib/konfig/store.rb#L27-L37
train
codescrum/bebox
lib/bebox/commands/profile_commands.rb
Bebox.ProfileCommands.profile_new_command
def profile_new_command(profile_command) profile_command.desc _('cli.profile.new.desc') profile_command.arg_name "[name]" profile_command.command :new do |profile_new_command| profile_new_command.flag :p, :arg_name => 'path', :desc => _('cli.profile.new.path_flag_desc') profile_new_command.action do |global_options,options,args| path = options[:p] || '' help_now!(error(_('cli.profile.new.name_arg_missing'))) if args.count == 0 Bebox::ProfileWizard.new.create_new_profile(project_root, args.first, path) end end end
ruby
def profile_new_command(profile_command) profile_command.desc _('cli.profile.new.desc') profile_command.arg_name "[name]" profile_command.command :new do |profile_new_command| profile_new_command.flag :p, :arg_name => 'path', :desc => _('cli.profile.new.path_flag_desc') profile_new_command.action do |global_options,options,args| path = options[:p] || '' help_now!(error(_('cli.profile.new.name_arg_missing'))) if args.count == 0 Bebox::ProfileWizard.new.create_new_profile(project_root, args.first, path) end end end
[ "def", "profile_new_command", "(", "profile_command", ")", "profile_command", ".", "desc", "_", "(", "'cli.profile.new.desc'", ")", "profile_command", ".", "arg_name", "\"[name]\"", "profile_command", ".", "command", ":new", "do", "|", "profile_new_command", "|", "profile_new_command", ".", "flag", ":p", ",", ":arg_name", "=>", "'path'", ",", ":desc", "=>", "_", "(", "'cli.profile.new.path_flag_desc'", ")", "profile_new_command", ".", "action", "do", "|", "global_options", ",", "options", ",", "args", "|", "path", "=", "options", "[", ":p", "]", "||", "''", "help_now!", "(", "error", "(", "_", "(", "'cli.profile.new.name_arg_missing'", ")", ")", ")", "if", "args", ".", "count", "==", "0", "Bebox", "::", "ProfileWizard", ".", "new", ".", "create_new_profile", "(", "project_root", ",", "args", ".", "first", ",", "path", ")", "end", "end", "end" ]
Profile new command
[ "Profile", "new", "command" ]
0d19315847103341e599d32837ab0bd75524e5be
https://github.com/codescrum/bebox/blob/0d19315847103341e599d32837ab0bd75524e5be/lib/bebox/commands/profile_commands.rb#L19-L30
train
codescrum/bebox
lib/bebox/commands/profile_commands.rb
Bebox.ProfileCommands.profile_remove_command
def profile_remove_command(profile_command) profile_command.desc _('cli.profile.remove.desc') profile_command.command :remove do |profile_remove_command| profile_remove_command.action do |global_options,options,args| Bebox::ProfileWizard.new.remove_profile(project_root) end end end
ruby
def profile_remove_command(profile_command) profile_command.desc _('cli.profile.remove.desc') profile_command.command :remove do |profile_remove_command| profile_remove_command.action do |global_options,options,args| Bebox::ProfileWizard.new.remove_profile(project_root) end end end
[ "def", "profile_remove_command", "(", "profile_command", ")", "profile_command", ".", "desc", "_", "(", "'cli.profile.remove.desc'", ")", "profile_command", ".", "command", ":remove", "do", "|", "profile_remove_command", "|", "profile_remove_command", ".", "action", "do", "|", "global_options", ",", "options", ",", "args", "|", "Bebox", "::", "ProfileWizard", ".", "new", ".", "remove_profile", "(", "project_root", ")", "end", "end", "end" ]
Profile remove command
[ "Profile", "remove", "command" ]
0d19315847103341e599d32837ab0bd75524e5be
https://github.com/codescrum/bebox/blob/0d19315847103341e599d32837ab0bd75524e5be/lib/bebox/commands/profile_commands.rb#L33-L40
train
codescrum/bebox
lib/bebox/commands/profile_commands.rb
Bebox.ProfileCommands.profile_list_command
def profile_list_command(profile_command) profile_command.desc _('cli.profile.list.desc') profile_command.command :list do |profile_list_command| profile_list_command.action do |global_options,options,args| profiles = Bebox::ProfileWizard.new.list_profiles(project_root) title _('cli.profile.list.current_profiles') profiles.map{|profile| msg(profile)} warn(_('cli.profile.list.no_profiles')) if profiles.empty? linebreak end end end
ruby
def profile_list_command(profile_command) profile_command.desc _('cli.profile.list.desc') profile_command.command :list do |profile_list_command| profile_list_command.action do |global_options,options,args| profiles = Bebox::ProfileWizard.new.list_profiles(project_root) title _('cli.profile.list.current_profiles') profiles.map{|profile| msg(profile)} warn(_('cli.profile.list.no_profiles')) if profiles.empty? linebreak end end end
[ "def", "profile_list_command", "(", "profile_command", ")", "profile_command", ".", "desc", "_", "(", "'cli.profile.list.desc'", ")", "profile_command", ".", "command", ":list", "do", "|", "profile_list_command", "|", "profile_list_command", ".", "action", "do", "|", "global_options", ",", "options", ",", "args", "|", "profiles", "=", "Bebox", "::", "ProfileWizard", ".", "new", ".", "list_profiles", "(", "project_root", ")", "title", "_", "(", "'cli.profile.list.current_profiles'", ")", "profiles", ".", "map", "{", "|", "profile", "|", "msg", "(", "profile", ")", "}", "warn", "(", "_", "(", "'cli.profile.list.no_profiles'", ")", ")", "if", "profiles", ".", "empty?", "linebreak", "end", "end", "end" ]
Profile list command
[ "Profile", "list", "command" ]
0d19315847103341e599d32837ab0bd75524e5be
https://github.com/codescrum/bebox/blob/0d19315847103341e599d32837ab0bd75524e5be/lib/bebox/commands/profile_commands.rb#L43-L54
train
aetherised/ark-util
lib/ark/text.rb
ARK.TextBuilder.wrap
def wrap(width: 78, indent: 0, indent_after: false, segments: false) if segments text = Text.wrap_segments(@lines[@line], width: width, indent: indent, indent_after: indent_after) else text = Text.wrap(@lines[@line], width: width, indent: indent, indent_after: indent_after) end @lines.delete_at(@line) @line -= 1 text.split("\n").each {|line| self.next(line) } return self end
ruby
def wrap(width: 78, indent: 0, indent_after: false, segments: false) if segments text = Text.wrap_segments(@lines[@line], width: width, indent: indent, indent_after: indent_after) else text = Text.wrap(@lines[@line], width: width, indent: indent, indent_after: indent_after) end @lines.delete_at(@line) @line -= 1 text.split("\n").each {|line| self.next(line) } return self end
[ "def", "wrap", "(", "width", ":", "78", ",", "indent", ":", "0", ",", "indent_after", ":", "false", ",", "segments", ":", "false", ")", "if", "segments", "text", "=", "Text", ".", "wrap_segments", "(", "@lines", "[", "@line", "]", ",", "width", ":", "width", ",", "indent", ":", "indent", ",", "indent_after", ":", "indent_after", ")", "else", "text", "=", "Text", ".", "wrap", "(", "@lines", "[", "@line", "]", ",", "width", ":", "width", ",", "indent", ":", "indent", ",", "indent_after", ":", "indent_after", ")", "end", "@lines", ".", "delete_at", "(", "@line", ")", "@line", "-=", "1", "text", ".", "split", "(", "\"\\n\"", ")", ".", "each", "{", "|", "line", "|", "self", ".", "next", "(", "line", ")", "}", "return", "self", "end" ]
Wrap the current line to +width+, with an optional +indent+. After wrapping, the current line will be the last line wrapped.
[ "Wrap", "the", "current", "line", "to", "+", "width", "+", "with", "an", "optional", "+", "indent", "+", ".", "After", "wrapping", "the", "current", "line", "will", "be", "the", "last", "line", "wrapped", "." ]
d7573ad0e44568a394808dfa895b9375de1bc3fd
https://github.com/aetherised/ark-util/blob/d7573ad0e44568a394808dfa895b9375de1bc3fd/lib/ark/text.rb#L67-L77
train
RudyComputing/shopsense-ruby
lib/shopsense/api.rb
Shopsense.API.search
def search( search_string = nil, index = 0, num_results = 10) raise "no search string provieded!" if( search_string === nil) fts = "fts=" + search_string.split().join( '+').to_s min = "min=" + index.to_s count = "count=" + num_results.to_s args = [fts, min, count].join( '&') return call_api( __method__, args) end
ruby
def search( search_string = nil, index = 0, num_results = 10) raise "no search string provieded!" if( search_string === nil) fts = "fts=" + search_string.split().join( '+').to_s min = "min=" + index.to_s count = "count=" + num_results.to_s args = [fts, min, count].join( '&') return call_api( __method__, args) end
[ "def", "search", "(", "search_string", "=", "nil", ",", "index", "=", "0", ",", "num_results", "=", "10", ")", "raise", "\"no search string provieded!\"", "if", "(", "search_string", "===", "nil", ")", "fts", "=", "\"fts=\"", "+", "search_string", ".", "split", "(", ")", ".", "join", "(", "'+'", ")", ".", "to_s", "min", "=", "\"min=\"", "+", "index", ".", "to_s", "count", "=", "\"count=\"", "+", "num_results", ".", "to_s", "args", "=", "[", "fts", ",", "min", ",", "count", "]", ".", "join", "(", "'&'", ")", "return", "call_api", "(", "__method__", ",", "args", ")", "end" ]
Searches the shopsense API @param [String] search_string The string to be in the query. @param [Integer] index The start index of results returned. @param [Integer] num_results The number of results to be returned. @return A list of Product objects. Each Product has an id, name, description, price, retailer, brand name, categories, images in small/medium/large, and a URL that forwards to the retailer's site.
[ "Searches", "the", "shopsense", "API" ]
956c92567c6cbc140b12e48239ae7812fa65782f
https://github.com/RudyComputing/shopsense-ruby/blob/956c92567c6cbc140b12e48239ae7812fa65782f/lib/shopsense/api.rb#L15-L24
train
RudyComputing/shopsense-ruby
lib/shopsense/api.rb
Shopsense.API.get_look
def get_look( look_id = nil) raise "no look_id provieded!" if( look_id === nil) look = "look=" + look_id.to_s return call_api( __method__, look) end
ruby
def get_look( look_id = nil) raise "no look_id provieded!" if( look_id === nil) look = "look=" + look_id.to_s return call_api( __method__, look) end
[ "def", "get_look", "(", "look_id", "=", "nil", ")", "raise", "\"no look_id provieded!\"", "if", "(", "look_id", "===", "nil", ")", "look", "=", "\"look=\"", "+", "look_id", ".", "to_s", "return", "call_api", "(", "__method__", ",", "look", ")", "end" ]
This method returns information about a particular look and its products. @param [Integer] look_id The ID number of the look. An easy way to get a look's ID is to go to the Stylebook page that contains the look at the ShopStyle website and right-click on the button that you use to edit the look. From the popup menu, select "Copy Link" and paste that into any text editor. The "lookId" query parameter of that URL is the value to use for this API method. @return [String] single look, with title, description, a set of tags, and a list of products. The products have the fields listed (see #search)
[ "This", "method", "returns", "information", "about", "a", "particular", "look", "and", "its", "products", "." ]
956c92567c6cbc140b12e48239ae7812fa65782f
https://github.com/RudyComputing/shopsense-ruby/blob/956c92567c6cbc140b12e48239ae7812fa65782f/lib/shopsense/api.rb#L75-L81
train
RudyComputing/shopsense-ruby
lib/shopsense/api.rb
Shopsense.API.get_stylebook
def get_stylebook( user_name = nil, index = 0, num_results = 10) raise "no user_name provieded!" if( user_name === nil) handle = "handle=" + user_name.to_s min = "min=" + index.to_s count = "count=" + num_results.to_s args = [handle, min, count].join( '&') return call_api( __method__, args) end
ruby
def get_stylebook( user_name = nil, index = 0, num_results = 10) raise "no user_name provieded!" if( user_name === nil) handle = "handle=" + user_name.to_s min = "min=" + index.to_s count = "count=" + num_results.to_s args = [handle, min, count].join( '&') return call_api( __method__, args) end
[ "def", "get_stylebook", "(", "user_name", "=", "nil", ",", "index", "=", "0", ",", "num_results", "=", "10", ")", "raise", "\"no user_name provieded!\"", "if", "(", "user_name", "===", "nil", ")", "handle", "=", "\"handle=\"", "+", "user_name", ".", "to_s", "min", "=", "\"min=\"", "+", "index", ".", "to_s", "count", "=", "\"count=\"", "+", "num_results", ".", "to_s", "args", "=", "[", "handle", ",", "min", ",", "count", "]", ".", "join", "(", "'&'", ")", "return", "call_api", "(", "__method__", ",", "args", ")", "end" ]
This method returns information about a particular user's Stylebook, the looks within that Stylebook, and the title and description associated with each look. @param [String] username The username of the Stylebook owner. @param [Integer] index The start index of results returned. @param [Integer] num_results The number of results to be returned. @return [String] A look id of the user's Stylebook, the look id of each individual look within that Stylebook, and the title and description associated with each look.
[ "This", "method", "returns", "information", "about", "a", "particular", "user", "s", "Stylebook", "the", "looks", "within", "that", "Stylebook", "and", "the", "title", "and", "description", "associated", "with", "each", "look", "." ]
956c92567c6cbc140b12e48239ae7812fa65782f
https://github.com/RudyComputing/shopsense-ruby/blob/956c92567c6cbc140b12e48239ae7812fa65782f/lib/shopsense/api.rb#L100-L109
train
RudyComputing/shopsense-ruby
lib/shopsense/api.rb
Shopsense.API.get_looks
def get_looks( look_type = nil, index = 0, num_results = 10) raise "invalid filter type must be one of the following: #{self.look_types}" if( !self.look_types.include?( look_type)) type = "type=" + look_type.to_s min = "min=" + index.to_s count = "count=" + num_results.to_s args = [type, min, count].join( '&') return call_api( __method__, args) end
ruby
def get_looks( look_type = nil, index = 0, num_results = 10) raise "invalid filter type must be one of the following: #{self.look_types}" if( !self.look_types.include?( look_type)) type = "type=" + look_type.to_s min = "min=" + index.to_s count = "count=" + num_results.to_s args = [type, min, count].join( '&') return call_api( __method__, args) end
[ "def", "get_looks", "(", "look_type", "=", "nil", ",", "index", "=", "0", ",", "num_results", "=", "10", ")", "raise", "\"invalid filter type must be one of the following: #{self.look_types}\"", "if", "(", "!", "self", ".", "look_types", ".", "include?", "(", "look_type", ")", ")", "type", "=", "\"type=\"", "+", "look_type", ".", "to_s", "min", "=", "\"min=\"", "+", "index", ".", "to_s", "count", "=", "\"count=\"", "+", "num_results", ".", "to_s", "args", "=", "[", "type", ",", "min", ",", "count", "]", ".", "join", "(", "'&'", ")", "return", "call_api", "(", "__method__", ",", "args", ")", "end" ]
This method returns information about looks that match different kinds of searches. @param [Integer] look_type The type of search to perform. Supported values are: New - Recently created looks. TopRated - Recently created looks that are highly rated. Celebrities - Looks owned by celebrity users. Featured - Looks from featured stylebooks. @param [String] username The username of the Stylebook owner. @param [Integer] index The start index of results returned. @param [Integer] num_results The number of results to be returned. @return [String] A list of looks of the given type.
[ "This", "method", "returns", "information", "about", "looks", "that", "match", "different", "kinds", "of", "searches", "." ]
956c92567c6cbc140b12e48239ae7812fa65782f
https://github.com/RudyComputing/shopsense-ruby/blob/956c92567c6cbc140b12e48239ae7812fa65782f/lib/shopsense/api.rb#L126-L135
train
RudyComputing/shopsense-ruby
lib/shopsense/api.rb
Shopsense.API.get_trends
def get_trends( category = "", products = 0) cat = "cat=" + category.to_s products = "products=" + products.to_s args = [cat, products].join( '&') return call_api( __method__, args) end
ruby
def get_trends( category = "", products = 0) cat = "cat=" + category.to_s products = "products=" + products.to_s args = [cat, products].join( '&') return call_api( __method__, args) end
[ "def", "get_trends", "(", "category", "=", "\"\"", ",", "products", "=", "0", ")", "cat", "=", "\"cat=\"", "+", "category", ".", "to_s", "products", "=", "\"products=\"", "+", "products", ".", "to_s", "args", "=", "[", "cat", ",", "products", "]", ".", "join", "(", "'&'", ")", "return", "call_api", "(", "__method__", ",", "args", ")", "end" ]
This method returns the popular brands for a given category along with a sample product for the brand-category combination. @param [String] category Category you want to restrict the popularity search for. This is an optional parameter. If category is not supplied, all the popular brands regardless of category will be returned. @return [String] A list of trends in the given category. Each trend has a brand, category, url, and optionally the top-ranked product for each brand/category.
[ "This", "method", "returns", "the", "popular", "brands", "for", "a", "given", "category", "along", "with", "a", "sample", "product", "for", "the", "brand", "-", "category", "combination", "." ]
956c92567c6cbc140b12e48239ae7812fa65782f
https://github.com/RudyComputing/shopsense-ruby/blob/956c92567c6cbc140b12e48239ae7812fa65782f/lib/shopsense/api.rb#L160-L166
train
RudyComputing/shopsense-ruby
lib/shopsense/api.rb
Shopsense.API.call_api
def call_api( method, args = nil) method_url = self.api_url + self.send( "#{method}_path") pid = "pid=" + self.partner_id format = "format=" + self.format site = "site=" + self.site if( args === nil) then uri = URI.parse( method_url.to_s + [pid, format, site].join('&').to_s) else uri = URI.parse( method_url.to_s + [pid, format, site, args].join('&').to_s) end return Net::HTTP.get( uri) end
ruby
def call_api( method, args = nil) method_url = self.api_url + self.send( "#{method}_path") pid = "pid=" + self.partner_id format = "format=" + self.format site = "site=" + self.site if( args === nil) then uri = URI.parse( method_url.to_s + [pid, format, site].join('&').to_s) else uri = URI.parse( method_url.to_s + [pid, format, site, args].join('&').to_s) end return Net::HTTP.get( uri) end
[ "def", "call_api", "(", "method", ",", "args", "=", "nil", ")", "method_url", "=", "self", ".", "api_url", "+", "self", ".", "send", "(", "\"#{method}_path\"", ")", "pid", "=", "\"pid=\"", "+", "self", ".", "partner_id", "format", "=", "\"format=\"", "+", "self", ".", "format", "site", "=", "\"site=\"", "+", "self", ".", "site", "if", "(", "args", "===", "nil", ")", "then", "uri", "=", "URI", ".", "parse", "(", "method_url", ".", "to_s", "+", "[", "pid", ",", "format", ",", "site", "]", ".", "join", "(", "'&'", ")", ".", "to_s", ")", "else", "uri", "=", "URI", ".", "parse", "(", "method_url", ".", "to_s", "+", "[", "pid", ",", "format", ",", "site", ",", "args", "]", ".", "join", "(", "'&'", ")", ".", "to_s", ")", "end", "return", "Net", "::", "HTTP", ".", "get", "(", "uri", ")", "end" ]
This method is used for making the http calls building off the DSL of this module. @param [String] method The method which is to be used in the call to Shopsense @param [String] args A concatenated group of arguments seperated by a an & symbol and spces substitued with a + symbol. @return [String] A list of the data returned
[ "This", "method", "is", "used", "for", "making", "the", "http", "calls", "building", "off", "the", "DSL", "of", "this", "module", "." ]
956c92567c6cbc140b12e48239ae7812fa65782f
https://github.com/RudyComputing/shopsense-ruby/blob/956c92567c6cbc140b12e48239ae7812fa65782f/lib/shopsense/api.rb#L175-L188
train
jgoizueta/numerals
lib/numerals/format/symbols/digits.rb
Numerals.Format::Symbols::Digits.digits_text
def digits_text(digit_values, options={}) insignificant_digits = options[:insignificant_digits] || 0 num_digits = digit_values.reduce(0) { |num, digit| digit.nil? ? num : num + 1 } num_digits -= insignificant_digits digit_values.map { |d| if d.nil? options[:separator] else num_digits -= 1 if num_digits >= 0 digit_symbol(d, options) else options[:insignificant_symbol] end end }.join end
ruby
def digits_text(digit_values, options={}) insignificant_digits = options[:insignificant_digits] || 0 num_digits = digit_values.reduce(0) { |num, digit| digit.nil? ? num : num + 1 } num_digits -= insignificant_digits digit_values.map { |d| if d.nil? options[:separator] else num_digits -= 1 if num_digits >= 0 digit_symbol(d, options) else options[:insignificant_symbol] end end }.join end
[ "def", "digits_text", "(", "digit_values", ",", "options", "=", "{", "}", ")", "insignificant_digits", "=", "options", "[", ":insignificant_digits", "]", "||", "0", "num_digits", "=", "digit_values", ".", "reduce", "(", "0", ")", "{", "|", "num", ",", "digit", "|", "digit", ".", "nil?", "?", "num", ":", "num", "+", "1", "}", "num_digits", "-=", "insignificant_digits", "digit_values", ".", "map", "{", "|", "d", "|", "if", "d", ".", "nil?", "options", "[", ":separator", "]", "else", "num_digits", "-=", "1", "if", "num_digits", ">=", "0", "digit_symbol", "(", "d", ",", "options", ")", "else", "options", "[", ":insignificant_symbol", "]", "end", "end", "}", ".", "join", "end" ]
Convert sequence of digits to its text representation. The nil value can be used in the digits sequence to represent the group separator.
[ "Convert", "sequence", "of", "digits", "to", "its", "text", "representation", ".", "The", "nil", "value", "can", "be", "used", "in", "the", "digits", "sequence", "to", "represent", "the", "group", "separator", "." ]
a195e75f689af926537f791441bf8d11590c99c0
https://github.com/jgoizueta/numerals/blob/a195e75f689af926537f791441bf8d11590c99c0/lib/numerals/format/symbols/digits.rb#L91-L109
train
Dahie/woro
lib/woro/task_list.rb
Woro.TaskList.width
def width @width ||= list.map { |t| t.name_with_args ? t.name_with_args.length : 0 }.max || 10 end
ruby
def width @width ||= list.map { |t| t.name_with_args ? t.name_with_args.length : 0 }.max || 10 end
[ "def", "width", "@width", "||=", "list", ".", "map", "{", "|", "t", "|", "t", ".", "name_with_args", "?", "t", ".", "name_with_args", ".", "length", ":", "0", "}", ".", "max", "||", "10", "end" ]
Determine the max count of characters for all task names. @return [integer] count of characters
[ "Determine", "the", "max", "count", "of", "characters", "for", "all", "task", "names", "." ]
796873cca145c61cd72c7363551e10d402f867c6
https://github.com/Dahie/woro/blob/796873cca145c61cd72c7363551e10d402f867c6/lib/woro/task_list.rb#L17-L19
train
Dahie/woro
lib/woro/task_list.rb
Woro.TaskList.print
def print list.each do |entry| entry.headline ? print_headline(entry) : print_task_description(entry) end end
ruby
def print list.each do |entry| entry.headline ? print_headline(entry) : print_task_description(entry) end end
[ "def", "print", "list", ".", "each", "do", "|", "entry", "|", "entry", ".", "headline", "?", "print_headline", "(", "entry", ")", ":", "print_task_description", "(", "entry", ")", "end", "end" ]
Print the current task list to console.
[ "Print", "the", "current", "task", "list", "to", "console", "." ]
796873cca145c61cd72c7363551e10d402f867c6
https://github.com/Dahie/woro/blob/796873cca145c61cd72c7363551e10d402f867c6/lib/woro/task_list.rb#L30-L34
train
riddopic/garcun
lib/garcon/task/event.rb
Garcon.Event.wait
def wait(timeout = nil) @mutex.lock unless @set remaining = Condition::Result.new(timeout) while !@set && remaining.can_wait? remaining = @condition.wait(@mutex, remaining.remaining_time) end end @set ensure @mutex.unlock end
ruby
def wait(timeout = nil) @mutex.lock unless @set remaining = Condition::Result.new(timeout) while !@set && remaining.can_wait? remaining = @condition.wait(@mutex, remaining.remaining_time) end end @set ensure @mutex.unlock end
[ "def", "wait", "(", "timeout", "=", "nil", ")", "@mutex", ".", "lock", "unless", "@set", "remaining", "=", "Condition", "::", "Result", ".", "new", "(", "timeout", ")", "while", "!", "@set", "&&", "remaining", ".", "can_wait?", "remaining", "=", "@condition", ".", "wait", "(", "@mutex", ",", "remaining", ".", "remaining_time", ")", "end", "end", "@set", "ensure", "@mutex", ".", "unlock", "end" ]
Wait a given number of seconds for the `Event` to be set by another thread. Will wait forever when no `timeout` value is given. Returns immediately if the `Event` has already been set. @return [Boolean] true if the `Event` was set before timeout else false
[ "Wait", "a", "given", "number", "of", "seconds", "for", "the", "Event", "to", "be", "set", "by", "another", "thread", ".", "Will", "wait", "forever", "when", "no", "timeout", "value", "is", "given", ".", "Returns", "immediately", "if", "the", "Event", "has", "already", "been", "set", "." ]
c2409bd8cf9c14b967a719810dab5269d69b42de
https://github.com/riddopic/garcun/blob/c2409bd8cf9c14b967a719810dab5269d69b42de/lib/garcon/task/event.rb#L104-L117
train
robfors/ruby-sumac
lib/sumac/remote_object.rb
Sumac.RemoteObject.method_missing
def method_missing(method_name, *arguments, &block) # TODO: blocks not working yet arguments << block.to_lambda if block_given? reqeust = {object: self, method: method_name.to_s, arguments: arguments} begin return_value = @object_request_broker.call(reqeust) rescue ClosedObjectRequestBrokerError raise StaleObjectError end end
ruby
def method_missing(method_name, *arguments, &block) # TODO: blocks not working yet arguments << block.to_lambda if block_given? reqeust = {object: self, method: method_name.to_s, arguments: arguments} begin return_value = @object_request_broker.call(reqeust) rescue ClosedObjectRequestBrokerError raise StaleObjectError end end
[ "def", "method_missing", "(", "method_name", ",", "*", "arguments", ",", "&", "block", ")", "arguments", "<<", "block", ".", "to_lambda", "if", "block_given?", "reqeust", "=", "{", "object", ":", "self", ",", "method", ":", "method_name", ".", "to_s", ",", "arguments", ":", "arguments", "}", "begin", "return_value", "=", "@object_request_broker", ".", "call", "(", "reqeust", ")", "rescue", "ClosedObjectRequestBrokerError", "raise", "StaleObjectError", "end", "end" ]
Makes a calls to the object on the remote endpoint. @note will block until the call has completed @param method_name [String] method to call @param arguments [Array<Array,Boolean,Exception,ExposedObject,Float,Hash,Integer,nil,String>] arguments being passed @raise [ClosedObjectRequestBrokerError] if broker is closed before the request is sent or respose is received @raise [UnexposedObjectError] if an object being sent is an invalid type @raise [StaleObjectError] if an object being sent has been forgoten by this endpoint (may not be forgoten by the remote endpoint yet) @raise [RemoteError] if an error was raised during call @raise [ArgumentError,StaleObjectError,UnexposedMethodError,UnexposedObjectError] if one is raised by the remote endpoint when trying to call the method or return a value (but not during the call) @return [Array,Boolean,Exception,ExposedObject,Float,Hash,Integer,nil,String] value returned from the call on remote endpoint
[ "Makes", "a", "calls", "to", "the", "object", "on", "the", "remote", "endpoint", "." ]
524fa68b7d1bb10a74baa69cd594ab2b8cae20a3
https://github.com/robfors/ruby-sumac/blob/524fa68b7d1bb10a74baa69cd594ab2b8cae20a3/lib/sumac/remote_object.rb#L64-L72
train
barkerest/shells
lib/shells/shell_base/hooks.rb
Shells.ShellBase.run_hook
def run_hook(hook_name, *args) list = self.class.all_hooks(hook_name) shell = self list.each do |hook| result = hook.call(shell, *args) return :break if result == :break end list.any? end
ruby
def run_hook(hook_name, *args) list = self.class.all_hooks(hook_name) shell = self list.each do |hook| result = hook.call(shell, *args) return :break if result == :break end list.any? end
[ "def", "run_hook", "(", "hook_name", ",", "*", "args", ")", "list", "=", "self", ".", "class", ".", "all_hooks", "(", "hook_name", ")", "shell", "=", "self", "list", ".", "each", "do", "|", "hook", "|", "result", "=", "hook", ".", "call", "(", "shell", ",", "*", "args", ")", "return", ":break", "if", "result", "==", ":break", "end", "list", ".", "any?", "end" ]
Runs a hook in the current shell instance. The hook method is passed the shell as the first argument then the arguments passed to this method. Return false unless the hook was executed. Returns :break if one of the hook methods returns :break.
[ "Runs", "a", "hook", "in", "the", "current", "shell", "instance", "." ]
674a0254f48cea01b0ae8979933f13892e398506
https://github.com/barkerest/shells/blob/674a0254f48cea01b0ae8979933f13892e398506/lib/shells/shell_base/hooks.rb#L66-L74
train
mrsimonfletcher/roroacms
app/controllers/roroacms/application_controller.rb
Roroacms.ApplicationController.add_breadcrumb
def add_breadcrumb(name, url = 'javascript:;', atts = {}) hash = { name: name, url: url, atts: atts } @breadcrumbs << hash end
ruby
def add_breadcrumb(name, url = 'javascript:;', atts = {}) hash = { name: name, url: url, atts: atts } @breadcrumbs << hash end
[ "def", "add_breadcrumb", "(", "name", ",", "url", "=", "'javascript:;'", ",", "atts", "=", "{", "}", ")", "hash", "=", "{", "name", ":", "name", ",", "url", ":", "url", ",", "atts", ":", "atts", "}", "@breadcrumbs", "<<", "hash", "end" ]
add a breadcrumb to the breadcrumb hash
[ "add", "a", "breadcrumb", "to", "the", "breadcrumb", "hash" ]
62654a2f2a48e3adb3105f4dafb6e315b460eaf4
https://github.com/mrsimonfletcher/roroacms/blob/62654a2f2a48e3adb3105f4dafb6e315b460eaf4/app/controllers/roroacms/application_controller.rb#L128-L131
train
mrsimonfletcher/roroacms
app/controllers/roroacms/application_controller.rb
Roroacms.ApplicationController.authorize_demo
def authorize_demo if !request.xhr? && !request.get? && ( !current_user.blank? && current_user.username.downcase == 'demo' && Setting.get('demonstration_mode') == 'Y' ) redirect_to :back, flash: { error: I18n.t('generic.demo_notification') } and return end render :inline => 'demo' and return if params[:action] == 'save_menu' && !current_user.blank? && current_user.username.downcase == 'demo' && Setting.get('demonstration_mode') == 'Y' end
ruby
def authorize_demo if !request.xhr? && !request.get? && ( !current_user.blank? && current_user.username.downcase == 'demo' && Setting.get('demonstration_mode') == 'Y' ) redirect_to :back, flash: { error: I18n.t('generic.demo_notification') } and return end render :inline => 'demo' and return if params[:action] == 'save_menu' && !current_user.blank? && current_user.username.downcase == 'demo' && Setting.get('demonstration_mode') == 'Y' end
[ "def", "authorize_demo", "if", "!", "request", ".", "xhr?", "&&", "!", "request", ".", "get?", "&&", "(", "!", "current_user", ".", "blank?", "&&", "current_user", ".", "username", ".", "downcase", "==", "'demo'", "&&", "Setting", ".", "get", "(", "'demonstration_mode'", ")", "==", "'Y'", ")", "redirect_to", ":back", ",", "flash", ":", "{", "error", ":", "I18n", ".", "t", "(", "'generic.demo_notification'", ")", "}", "and", "return", "end", "render", ":inline", "=>", "'demo'", "and", "return", "if", "params", "[", ":action", "]", "==", "'save_menu'", "&&", "!", "current_user", ".", "blank?", "&&", "current_user", ".", "username", ".", "downcase", "==", "'demo'", "&&", "Setting", ".", "get", "(", "'demonstration_mode'", ")", "==", "'Y'", "end" ]
restricts any CRUD functions if you are logged in as the username of demo and you have demonstration mode turned on
[ "restricts", "any", "CRUD", "functions", "if", "you", "are", "logged", "in", "as", "the", "username", "of", "demo", "and", "you", "have", "demonstration", "mode", "turned", "on" ]
62654a2f2a48e3adb3105f4dafb6e315b460eaf4
https://github.com/mrsimonfletcher/roroacms/blob/62654a2f2a48e3adb3105f4dafb6e315b460eaf4/app/controllers/roroacms/application_controller.rb#L135-L142
train
mrsimonfletcher/roroacms
app/controllers/roroacms/application_controller.rb
Roroacms.ApplicationController.mark_required
def mark_required(object, attribute) "*" if object.class.validators_on(attribute).map(&:class).include? ActiveModel::Validations::PresenceValidator end
ruby
def mark_required(object, attribute) "*" if object.class.validators_on(attribute).map(&:class).include? ActiveModel::Validations::PresenceValidator end
[ "def", "mark_required", "(", "object", ",", "attribute", ")", "\"*\"", "if", "object", ".", "class", ".", "validators_on", "(", "attribute", ")", ".", "map", "(", "&", ":class", ")", ".", "include?", "ActiveModel", "::", "Validations", "::", "PresenceValidator", "end" ]
Adds an asterix to the field if it is required.
[ "Adds", "an", "asterix", "to", "the", "field", "if", "it", "is", "required", "." ]
62654a2f2a48e3adb3105f4dafb6e315b460eaf4
https://github.com/mrsimonfletcher/roroacms/blob/62654a2f2a48e3adb3105f4dafb6e315b460eaf4/app/controllers/roroacms/application_controller.rb#L146-L148
train
mayth/Chizuru
lib/chizuru/user_stream.rb
Chizuru.UserStream.connect
def connect uri = URI.parse("https://userstream.twitter.com/2/user.json?track=#{@screen_name}") https = Net::HTTP.new(uri.host, uri.port) https.use_ssl = true https.ca_file = @ca_file https.verify_mode = OpenSSL::SSL::VERIFY_PEER https.verify_depth = 5 https.start do |https| request = Net::HTTP::Get.new(uri.request_uri, "User-Agent" => @user_agent, "Accept-Encoding" => "identity") request.oauth!(https, @credential.consumer, @credential.access_token) buf = "" https.request(request) do |response| response.read_body do |chunk| buf << chunk while ((line = buf[/.+?(\r\n)+/m]) != nil) begin buf.sub!(line, "") line.strip! status = Yajl::Parser.parse(line) rescue break end yield status end end end end end
ruby
def connect uri = URI.parse("https://userstream.twitter.com/2/user.json?track=#{@screen_name}") https = Net::HTTP.new(uri.host, uri.port) https.use_ssl = true https.ca_file = @ca_file https.verify_mode = OpenSSL::SSL::VERIFY_PEER https.verify_depth = 5 https.start do |https| request = Net::HTTP::Get.new(uri.request_uri, "User-Agent" => @user_agent, "Accept-Encoding" => "identity") request.oauth!(https, @credential.consumer, @credential.access_token) buf = "" https.request(request) do |response| response.read_body do |chunk| buf << chunk while ((line = buf[/.+?(\r\n)+/m]) != nil) begin buf.sub!(line, "") line.strip! status = Yajl::Parser.parse(line) rescue break end yield status end end end end end
[ "def", "connect", "uri", "=", "URI", ".", "parse", "(", "\"https://userstream.twitter.com/2/user.json?track=#{@screen_name}\"", ")", "https", "=", "Net", "::", "HTTP", ".", "new", "(", "uri", ".", "host", ",", "uri", ".", "port", ")", "https", ".", "use_ssl", "=", "true", "https", ".", "ca_file", "=", "@ca_file", "https", ".", "verify_mode", "=", "OpenSSL", "::", "SSL", "::", "VERIFY_PEER", "https", ".", "verify_depth", "=", "5", "https", ".", "start", "do", "|", "https", "|", "request", "=", "Net", "::", "HTTP", "::", "Get", ".", "new", "(", "uri", ".", "request_uri", ",", "\"User-Agent\"", "=>", "@user_agent", ",", "\"Accept-Encoding\"", "=>", "\"identity\"", ")", "request", ".", "oauth!", "(", "https", ",", "@credential", ".", "consumer", ",", "@credential", ".", "access_token", ")", "buf", "=", "\"\"", "https", ".", "request", "(", "request", ")", "do", "|", "response", "|", "response", ".", "read_body", "do", "|", "chunk", "|", "buf", "<<", "chunk", "while", "(", "(", "line", "=", "buf", "[", "/", "\\r", "\\n", "/m", "]", ")", "!=", "nil", ")", "begin", "buf", ".", "sub!", "(", "line", ",", "\"\"", ")", "line", ".", "strip!", "status", "=", "Yajl", "::", "Parser", ".", "parse", "(", "line", ")", "rescue", "break", "end", "yield", "status", "end", "end", "end", "end", "end" ]
Connects to UserStreaming API. The block will be given the events or statuses from Twitter API in JSON format.
[ "Connects", "to", "UserStreaming", "API", "." ]
361bc595c2e4257313d134fe0f4f4cca65c88383
https://github.com/mayth/Chizuru/blob/361bc595c2e4257313d134fe0f4f4cca65c88383/lib/chizuru/user_stream.rb#L42-L75
train
rolandasb/gogcom
lib/gogcom/game.rb
Gogcom.Game.fetch
def fetch() name = urlfy(@name) page = Net::HTTP.get(URI("http://www.gog.com/game/" + name)) data = JSON.parse(page[/(?<=var gogData = )(.*)(?=;)/,1]) data end
ruby
def fetch() name = urlfy(@name) page = Net::HTTP.get(URI("http://www.gog.com/game/" + name)) data = JSON.parse(page[/(?<=var gogData = )(.*)(?=;)/,1]) data end
[ "def", "fetch", "(", ")", "name", "=", "urlfy", "(", "@name", ")", "page", "=", "Net", "::", "HTTP", ".", "get", "(", "URI", "(", "\"http://www.gog.com/game/\"", "+", "name", ")", ")", "data", "=", "JSON", ".", "parse", "(", "page", "[", "/", "/", ",", "1", "]", ")", "data", "end" ]
Fetches raw data and parses as JSON object @return [Object]
[ "Fetches", "raw", "data", "and", "parses", "as", "JSON", "object" ]
015de453bb214c9ccb51665ecadce1367e6d987d
https://github.com/rolandasb/gogcom/blob/015de453bb214c9ccb51665ecadce1367e6d987d/lib/gogcom/game.rb#L18-L23
train
rolandasb/gogcom
lib/gogcom/game.rb
Gogcom.Game.parse
def parse(data) game = GameItem.new(get_title(data), get_genres(data), get_download_size(data), get_release_date(data), get_description(data), get_price(data), get_avg_rating(data), get_avg_ratings_count(data), get_platforms(data), get_languages(data), get_developer(data), get_publisher(data), get_modes(data), get_bonus_content(data), get_reviews(data), get_pegi_age(data)) game end
ruby
def parse(data) game = GameItem.new(get_title(data), get_genres(data), get_download_size(data), get_release_date(data), get_description(data), get_price(data), get_avg_rating(data), get_avg_ratings_count(data), get_platforms(data), get_languages(data), get_developer(data), get_publisher(data), get_modes(data), get_bonus_content(data), get_reviews(data), get_pegi_age(data)) game end
[ "def", "parse", "(", "data", ")", "game", "=", "GameItem", ".", "new", "(", "get_title", "(", "data", ")", ",", "get_genres", "(", "data", ")", ",", "get_download_size", "(", "data", ")", ",", "get_release_date", "(", "data", ")", ",", "get_description", "(", "data", ")", ",", "get_price", "(", "data", ")", ",", "get_avg_rating", "(", "data", ")", ",", "get_avg_ratings_count", "(", "data", ")", ",", "get_platforms", "(", "data", ")", ",", "get_languages", "(", "data", ")", ",", "get_developer", "(", "data", ")", ",", "get_publisher", "(", "data", ")", ",", "get_modes", "(", "data", ")", ",", "get_bonus_content", "(", "data", ")", ",", "get_reviews", "(", "data", ")", ",", "get_pegi_age", "(", "data", ")", ")", "game", "end" ]
Parses raw data and returns game item. @param [Object] @return [Struct]
[ "Parses", "raw", "data", "and", "returns", "game", "item", "." ]
015de453bb214c9ccb51665ecadce1367e6d987d
https://github.com/rolandasb/gogcom/blob/015de453bb214c9ccb51665ecadce1367e6d987d/lib/gogcom/game.rb#L29-L38
train
nrser/nrser.rb
lib/nrser/errors/nicer_error.rb
NRSER.NicerError.format_message_segment
def format_message_segment segment return segment.to_summary if segment.respond_to?( :to_summary ) return segment if String === segment # TODO Do better! segment.inspect end
ruby
def format_message_segment segment return segment.to_summary if segment.respond_to?( :to_summary ) return segment if String === segment # TODO Do better! segment.inspect end
[ "def", "format_message_segment", "segment", "return", "segment", ".", "to_summary", "if", "segment", ".", "respond_to?", "(", ":to_summary", ")", "return", "segment", "if", "String", "===", "segment", "segment", ".", "inspect", "end" ]
Construct a nicer error. @param [Array] message Main message segments. See {#format_message} and {#format_message_segment} for an understanding of how they are, well, formatted. @param [Binding?] binding When provided any details string will be rendered using it's {Binding#erb} method. @param [nil | String | Proc<()=>String> | #to_s] details Additional text details to add to the extended message. When: 1. `nil` - no details will be added. 2. `String` - the value will be used. If `binding:` is provided, it will be rendered against it as ERB. 3. `Proc<()=>String>` - if and when an extended message is needed the proc will be called, and the resulting string will be used as in (2). 4. `#to_s` - catch all; if and when an extended message is needed `#to_s` will be called on the value and the result will be used as in (2). @param [Hash<Symbol, VALUE>] context Any additional names and values to dump with an extended message. #initialize Format a segment of the error message. Strings are simply returned. Other things are inspected (for now). @param [Object] segment The segment. @return [String] The formatted string for the segment. @todo This should talk to config when that comes about to find out how to dump things.
[ "Construct", "a", "nicer", "error", "." ]
7db9a729ec65894dfac13fd50851beae8b809738
https://github.com/nrser/nrser.rb/blob/7db9a729ec65894dfac13fd50851beae8b809738/lib/nrser/errors/nicer_error.rb#L158-L165
train
nrser/nrser.rb
lib/nrser/errors/nicer_error.rb
NRSER.NicerError.to_s
def to_s extended: nil # The way to get the superclass' message message = super() # If `extended` is explicitly `false` then just return that return message if extended == false # Otherwise, see if the extended message was explicitly requested, # of if we're configured to provide it as well. # # Either way, don't add it it's empty. # if (extended || add_extended_message?) && !extended_message.empty? message + "\n\n" + extended_message else message end end
ruby
def to_s extended: nil # The way to get the superclass' message message = super() # If `extended` is explicitly `false` then just return that return message if extended == false # Otherwise, see if the extended message was explicitly requested, # of if we're configured to provide it as well. # # Either way, don't add it it's empty. # if (extended || add_extended_message?) && !extended_message.empty? message + "\n\n" + extended_message else message end end
[ "def", "to_s", "extended", ":", "nil", "message", "=", "super", "(", ")", "return", "message", "if", "extended", "==", "false", "if", "(", "extended", "||", "add_extended_message?", ")", "&&", "!", "extended_message", ".", "empty?", "message", "+", "\"\\n\\n\"", "+", "extended_message", "else", "message", "end", "end" ]
Get the message or the extended message. @note This is a bit weird, having to do with what I can tell about the built-in errors and how they handle their message - they have *no* instance variables, and seem to rely on `#to_s` to get the message out of C-land, however that works. {Exception#message} just forwards here, so I overrode that with {#message} to just get the *summary/super-message* from this method. @param [Boolean?] extended Flag to explicitly control summary/super or extended message: 1. `nil` - call {#add_extended_message?} to decide (default). 2. `false` - return just the *summary/super-message*. 3. `true` - always add the *extended message* (unless it's empty). @return [String]
[ "Get", "the", "message", "or", "the", "extended", "message", "." ]
7db9a729ec65894dfac13fd50851beae8b809738
https://github.com/nrser/nrser.rb/blob/7db9a729ec65894dfac13fd50851beae8b809738/lib/nrser/errors/nicer_error.rb#L319-L337
train
timotheeguerin/clin
lib/clin/command_mixin/core.rb
Clin::CommandMixin::Core.ClassMethods.inherited
def inherited(subclass) subclass._arguments = [] subclass._description = '' subclass._abstract = false subclass._skip_options = false subclass._exe_name = @_exe_name subclass._default_priority = @_default_priority.to_f / 2 subclass._priority = 0 super end
ruby
def inherited(subclass) subclass._arguments = [] subclass._description = '' subclass._abstract = false subclass._skip_options = false subclass._exe_name = @_exe_name subclass._default_priority = @_default_priority.to_f / 2 subclass._priority = 0 super end
[ "def", "inherited", "(", "subclass", ")", "subclass", ".", "_arguments", "=", "[", "]", "subclass", ".", "_description", "=", "''", "subclass", ".", "_abstract", "=", "false", "subclass", ".", "_skip_options", "=", "false", "subclass", ".", "_exe_name", "=", "@_exe_name", "subclass", ".", "_default_priority", "=", "@_default_priority", ".", "to_f", "/", "2", "subclass", ".", "_priority", "=", "0", "super", "end" ]
Trigger when a class inherit this class Rest class_attributes that should not be shared with subclass @param subclass [Clin::Command]
[ "Trigger", "when", "a", "class", "inherit", "this", "class", "Rest", "class_attributes", "that", "should", "not", "be", "shared", "with", "subclass" ]
43d41c47f9c652065ab7ce636d48a9fe1754135e
https://github.com/timotheeguerin/clin/blob/43d41c47f9c652065ab7ce636d48a9fe1754135e/lib/clin/command_mixin/core.rb#L24-L33
train
timotheeguerin/clin
lib/clin/command_mixin/core.rb
Clin::CommandMixin::Core.ClassMethods.arguments
def arguments(args = nil) return @_arguments if args.nil? @_arguments = [] [*args].map(&:split).flatten.each do |arg| @_arguments << Clin::Argument.new(arg) end end
ruby
def arguments(args = nil) return @_arguments if args.nil? @_arguments = [] [*args].map(&:split).flatten.each do |arg| @_arguments << Clin::Argument.new(arg) end end
[ "def", "arguments", "(", "args", "=", "nil", ")", "return", "@_arguments", "if", "args", ".", "nil?", "@_arguments", "=", "[", "]", "[", "*", "args", "]", ".", "map", "(", "&", ":split", ")", ".", "flatten", ".", "each", "do", "|", "arg", "|", "@_arguments", "<<", "Clin", "::", "Argument", ".", "new", "(", "arg", ")", "end", "end" ]
Set or get the arguments for the command @param args [Array<String>] List of arguments to set. If nil it just return the current args.
[ "Set", "or", "get", "the", "arguments", "for", "the", "command" ]
43d41c47f9c652065ab7ce636d48a9fe1754135e
https://github.com/timotheeguerin/clin/blob/43d41c47f9c652065ab7ce636d48a9fe1754135e/lib/clin/command_mixin/core.rb#L75-L81
train
stormbrew/rack-bridge
lib/bridge/tcp_server.rb
Bridge.TCPSocket.verify
def verify() send_bridge_request() begin line = gets() match = line.match(%r{^HTTP/1\.[01] ([0-9]{3,3}) (.*)$}) if (!match) raise "HTTP BRIDGE error: bridge server sent incorrect reply to bridge request." end case code = match[1].to_i when 100, 101 return true when 401 # 401 Access Denied, key wasn't right. raise "HTTP BRIDGE error #{code}: host key was invalid or missing, but required." when 503, 504 # 503 Service Unavailable or 504 Gateway Timeout raise "HTTP BRIDGE error #{code}: could not verify server can handle requests because it's overloaded." else raise "HTTP BRIDGE error #{code}: #{match[2]} unknown error connecting to bridge server." end ensure close() # once we do this, we just assume the connection is useless. end end
ruby
def verify() send_bridge_request() begin line = gets() match = line.match(%r{^HTTP/1\.[01] ([0-9]{3,3}) (.*)$}) if (!match) raise "HTTP BRIDGE error: bridge server sent incorrect reply to bridge request." end case code = match[1].to_i when 100, 101 return true when 401 # 401 Access Denied, key wasn't right. raise "HTTP BRIDGE error #{code}: host key was invalid or missing, but required." when 503, 504 # 503 Service Unavailable or 504 Gateway Timeout raise "HTTP BRIDGE error #{code}: could not verify server can handle requests because it's overloaded." else raise "HTTP BRIDGE error #{code}: #{match[2]} unknown error connecting to bridge server." end ensure close() # once we do this, we just assume the connection is useless. end end
[ "def", "verify", "(", ")", "send_bridge_request", "(", ")", "begin", "line", "=", "gets", "(", ")", "match", "=", "line", ".", "match", "(", "%r{", "\\.", "}", ")", "if", "(", "!", "match", ")", "raise", "\"HTTP BRIDGE error: bridge server sent incorrect reply to bridge request.\"", "end", "case", "code", "=", "match", "[", "1", "]", ".", "to_i", "when", "100", ",", "101", "return", "true", "when", "401", "raise", "\"HTTP BRIDGE error #{code}: host key was invalid or missing, but required.\"", "when", "503", ",", "504", "raise", "\"HTTP BRIDGE error #{code}: could not verify server can handle requests because it's overloaded.\"", "else", "raise", "\"HTTP BRIDGE error #{code}: #{match[2]} unknown error connecting to bridge server.\"", "end", "ensure", "close", "(", ")", "end", "end" ]
This just tries to determine if the server will honor requests as specified above so that the TCPServer initializer can error out early if it won't.
[ "This", "just", "tries", "to", "determine", "if", "the", "server", "will", "honor", "requests", "as", "specified", "above", "so", "that", "the", "TCPServer", "initializer", "can", "error", "out", "early", "if", "it", "won", "t", "." ]
96a94de9e901f73b9ee5200d2b4be55a74912c04
https://github.com/stormbrew/rack-bridge/blob/96a94de9e901f73b9ee5200d2b4be55a74912c04/lib/bridge/tcp_server.rb#L38-L59
train
stormbrew/rack-bridge
lib/bridge/tcp_server.rb
Bridge.TCPSocket.setup
def setup() send_bridge_request code = nil name = nil headers = [] while (line = gets()) line = line.strip if (line == "") case code.to_i when 100 # 100 Continue, just a ping. Ignore. code = name = nil headers = [] next when 101 # 101 Upgrade, successfuly got a connection. write("HTTP/1.1 100 Continue\r\n\r\n") # let the server know we're still here. return self when 401 # 401 Access Denied, key wasn't right. close() raise "HTTP BRIDGE error #{code}: host key was invalid or missing, but required." when 503, 504 # 503 Service Unavailable or 504 Gateway Timeout, just retry. close() sleep_time = headers.find {|header| header["Retry-After"] } || 5 raise RetryError.new("BRIDGE server timed out or is overloaded, wait #{sleep_time}s to try again.", sleep_time) else raise "HTTP BRIDGE error #{code}: #{name} waiting for connection." end end if (!code && !name) # This is the initial response line if (match = line.match(%r{^HTTP/1\.[01] ([0-9]{3,3}) (.*)$})) code = match[1] name = match[2] next else raise "Parse error in BRIDGE request reply." end else if (match = line.match(%r{^(.+?):\s+(.+)$})) headers.push({match[1] => match[2]}) else raise "Parse error in BRIDGE request reply's headers." end end end return nil end
ruby
def setup() send_bridge_request code = nil name = nil headers = [] while (line = gets()) line = line.strip if (line == "") case code.to_i when 100 # 100 Continue, just a ping. Ignore. code = name = nil headers = [] next when 101 # 101 Upgrade, successfuly got a connection. write("HTTP/1.1 100 Continue\r\n\r\n") # let the server know we're still here. return self when 401 # 401 Access Denied, key wasn't right. close() raise "HTTP BRIDGE error #{code}: host key was invalid or missing, but required." when 503, 504 # 503 Service Unavailable or 504 Gateway Timeout, just retry. close() sleep_time = headers.find {|header| header["Retry-After"] } || 5 raise RetryError.new("BRIDGE server timed out or is overloaded, wait #{sleep_time}s to try again.", sleep_time) else raise "HTTP BRIDGE error #{code}: #{name} waiting for connection." end end if (!code && !name) # This is the initial response line if (match = line.match(%r{^HTTP/1\.[01] ([0-9]{3,3}) (.*)$})) code = match[1] name = match[2] next else raise "Parse error in BRIDGE request reply." end else if (match = line.match(%r{^(.+?):\s+(.+)$})) headers.push({match[1] => match[2]}) else raise "Parse error in BRIDGE request reply's headers." end end end return nil end
[ "def", "setup", "(", ")", "send_bridge_request", "code", "=", "nil", "name", "=", "nil", "headers", "=", "[", "]", "while", "(", "line", "=", "gets", "(", ")", ")", "line", "=", "line", ".", "strip", "if", "(", "line", "==", "\"\"", ")", "case", "code", ".", "to_i", "when", "100", "code", "=", "name", "=", "nil", "headers", "=", "[", "]", "next", "when", "101", "write", "(", "\"HTTP/1.1 100 Continue\\r\\n\\r\\n\"", ")", "return", "self", "when", "401", "close", "(", ")", "raise", "\"HTTP BRIDGE error #{code}: host key was invalid or missing, but required.\"", "when", "503", ",", "504", "close", "(", ")", "sleep_time", "=", "headers", ".", "find", "{", "|", "header", "|", "header", "[", "\"Retry-After\"", "]", "}", "||", "5", "raise", "RetryError", ".", "new", "(", "\"BRIDGE server timed out or is overloaded, wait #{sleep_time}s to try again.\"", ",", "sleep_time", ")", "else", "raise", "\"HTTP BRIDGE error #{code}: #{name} waiting for connection.\"", "end", "end", "if", "(", "!", "code", "&&", "!", "name", ")", "if", "(", "match", "=", "line", ".", "match", "(", "%r{", "\\.", "}", ")", ")", "code", "=", "match", "[", "1", "]", "name", "=", "match", "[", "2", "]", "next", "else", "raise", "\"Parse error in BRIDGE request reply.\"", "end", "else", "if", "(", "match", "=", "line", ".", "match", "(", "%r{", "\\s", "}", ")", ")", "headers", ".", "push", "(", "{", "match", "[", "1", "]", "=>", "match", "[", "2", "]", "}", ")", "else", "raise", "\"Parse error in BRIDGE request reply's headers.\"", "end", "end", "end", "return", "nil", "end" ]
This does the full setup process on the request, returning only when the connection is actually available.
[ "This", "does", "the", "full", "setup", "process", "on", "the", "request", "returning", "only", "when", "the", "connection", "is", "actually", "available", "." ]
96a94de9e901f73b9ee5200d2b4be55a74912c04
https://github.com/stormbrew/rack-bridge/blob/96a94de9e901f73b9ee5200d2b4be55a74912c04/lib/bridge/tcp_server.rb#L63-L108
train
MBO/attrtastic
lib/attrtastic/semantic_attributes_helper.rb
Attrtastic.SemanticAttributesHelper.semantic_attributes_for
def semantic_attributes_for(record, options = {}, &block) options[:html] ||= {} html_class = [ "attrtastic", record.class.to_s.underscore, options[:html][:class] ].compact.join(" ") output = tag(:div, { :class => html_class}, true) if block_given? output << capture(SemanticAttributesBuilder.new(record, self), &block) else output << capture(SemanticAttributesBuilder.new(record, self)) do |attr| attr.attributes end end output.safe_concat("</div>") end
ruby
def semantic_attributes_for(record, options = {}, &block) options[:html] ||= {} html_class = [ "attrtastic", record.class.to_s.underscore, options[:html][:class] ].compact.join(" ") output = tag(:div, { :class => html_class}, true) if block_given? output << capture(SemanticAttributesBuilder.new(record, self), &block) else output << capture(SemanticAttributesBuilder.new(record, self)) do |attr| attr.attributes end end output.safe_concat("</div>") end
[ "def", "semantic_attributes_for", "(", "record", ",", "options", "=", "{", "}", ",", "&", "block", ")", "options", "[", ":html", "]", "||=", "{", "}", "html_class", "=", "[", "\"attrtastic\"", ",", "record", ".", "class", ".", "to_s", ".", "underscore", ",", "options", "[", ":html", "]", "[", ":class", "]", "]", ".", "compact", ".", "join", "(", "\" \"", ")", "output", "=", "tag", "(", ":div", ",", "{", ":class", "=>", "html_class", "}", ",", "true", ")", "if", "block_given?", "output", "<<", "capture", "(", "SemanticAttributesBuilder", ".", "new", "(", "record", ",", "self", ")", ",", "&", "block", ")", "else", "output", "<<", "capture", "(", "SemanticAttributesBuilder", ".", "new", "(", "record", ",", "self", ")", ")", "do", "|", "attr", "|", "attr", ".", "attributes", "end", "end", "output", ".", "safe_concat", "(", "\"</div>\"", ")", "end" ]
Creates attributes for given object @param[ActiveRecord] record AR instance record for which to display attributes @param[Hash] options Opions @option options [Hash] :html ({}) Hash with optional :class html class name for html block @yield [attr] Block which is yield inside of markup @yieldparam [SemanticAttributesBuilder] builder Builder for attributes for given AR record @example <%= semantic_attributes_for @user do |attr| %> <%= attr.attributes do %> <%= attr.attribute :name %> <%= attr.attribute :email %> <% end %> <% end %> @example <%= semantic_attributes_for @user %>
[ "Creates", "attributes", "for", "given", "object" ]
c024a1c42b665eed590004236e2d067d1ca59a4e
https://github.com/MBO/attrtastic/blob/c024a1c42b665eed590004236e2d067d1ca59a4e/lib/attrtastic/semantic_attributes_helper.rb#L44-L58
train
reidmorrison/jruby-hornetq
lib/hornetq/client/requestor_pattern.rb
HornetQ::Client.RequestorPattern.wait_for_reply
def wait_for_reply(user_id, timeout) # We only want the reply to the supplied message_id, so set filter on message id filter = "#{Java::org.hornetq.api.core::FilterConstants::HORNETQ_USERID} = 'ID:#{user_id}'" if user_id @session.consumer(:queue_name => @reply_queue, :filter=>filter) do |consumer| consumer.receive(timeout) end end
ruby
def wait_for_reply(user_id, timeout) # We only want the reply to the supplied message_id, so set filter on message id filter = "#{Java::org.hornetq.api.core::FilterConstants::HORNETQ_USERID} = 'ID:#{user_id}'" if user_id @session.consumer(:queue_name => @reply_queue, :filter=>filter) do |consumer| consumer.receive(timeout) end end
[ "def", "wait_for_reply", "(", "user_id", ",", "timeout", ")", "filter", "=", "\"#{Java::org.hornetq.api.core::FilterConstants::HORNETQ_USERID} = 'ID:#{user_id}'\"", "if", "user_id", "@session", ".", "consumer", "(", ":queue_name", "=>", "@reply_queue", ",", ":filter", "=>", "filter", ")", "do", "|", "consumer", "|", "consumer", ".", "receive", "(", "timeout", ")", "end", "end" ]
Asynchronous wait for reply Parameters: user_id: the user defined id to correlate a response for Supply a nil user_id to receive any message from the queue Returns the message received Note: Call submit_request before calling this method
[ "Asynchronous", "wait", "for", "reply" ]
528245f06b18e038eadaff5d3315eb95fc4d849d
https://github.com/reidmorrison/jruby-hornetq/blob/528245f06b18e038eadaff5d3315eb95fc4d849d/lib/hornetq/client/requestor_pattern.rb#L98-L104
train
adventistmedia/worldly
lib/worldly/country.rb
Worldly.Country.build_fields
def build_fields if @data.key?(:fields) @data[:fields].each do |k,v| v[:required] = true unless v.key?(:required) end else {city: {label:'City', required: true}, region: {label: 'Province', required: false}, postcode: {label: 'Post Code', required: false} } end end
ruby
def build_fields if @data.key?(:fields) @data[:fields].each do |k,v| v[:required] = true unless v.key?(:required) end else {city: {label:'City', required: true}, region: {label: 'Province', required: false}, postcode: {label: 'Post Code', required: false} } end end
[ "def", "build_fields", "if", "@data", ".", "key?", "(", ":fields", ")", "@data", "[", ":fields", "]", ".", "each", "do", "|", "k", ",", "v", "|", "v", "[", ":required", "]", "=", "true", "unless", "v", ".", "key?", "(", ":required", ")", "end", "else", "{", "city", ":", "{", "label", ":", "'City'", ",", "required", ":", "true", "}", ",", "region", ":", "{", "label", ":", "'Province'", ",", "required", ":", "false", "}", ",", "postcode", ":", "{", "label", ":", "'Post Code'", ",", "required", ":", "false", "}", "}", "end", "end" ]
all fields are required by default unless otherwise stated
[ "all", "fields", "are", "required", "by", "default", "unless", "otherwise", "stated" ]
f2ce6458623a9b79248887d08a9b3383341ab217
https://github.com/adventistmedia/worldly/blob/f2ce6458623a9b79248887d08a9b3383341ab217/lib/worldly/country.rb#L176-L184
train
saclark/lite_page
lib/lite_page.rb
LitePage.ClassMethods.page_url
def page_url(url) define_method(:page_url) do |query_params = {}| uri = URI(url) existing_params = URI.decode_www_form(uri.query || '') new_params = query_params.to_a unless existing_params.empty? && new_params.empty? combined_params = existing_params.push(*new_params) uri.query = URI.encode_www_form(combined_params) end uri.to_s end end
ruby
def page_url(url) define_method(:page_url) do |query_params = {}| uri = URI(url) existing_params = URI.decode_www_form(uri.query || '') new_params = query_params.to_a unless existing_params.empty? && new_params.empty? combined_params = existing_params.push(*new_params) uri.query = URI.encode_www_form(combined_params) end uri.to_s end end
[ "def", "page_url", "(", "url", ")", "define_method", "(", ":page_url", ")", "do", "|", "query_params", "=", "{", "}", "|", "uri", "=", "URI", "(", "url", ")", "existing_params", "=", "URI", ".", "decode_www_form", "(", "uri", ".", "query", "||", "''", ")", "new_params", "=", "query_params", ".", "to_a", "unless", "existing_params", ".", "empty?", "&&", "new_params", ".", "empty?", "combined_params", "=", "existing_params", ".", "push", "(", "*", "new_params", ")", "uri", ".", "query", "=", "URI", ".", "encode_www_form", "(", "combined_params", ")", "end", "uri", ".", "to_s", "end", "end" ]
Defines an instance method `page_url` which returns the url passed to this method and takes optional query parameters that will be appended to the url if given. @param url [String] the page url @return [Symbol] the name of the defined method (ruby 2.1+)
[ "Defines", "an", "instance", "method", "page_url", "which", "returns", "the", "url", "passed", "to", "this", "method", "and", "takes", "optional", "query", "parameters", "that", "will", "be", "appended", "to", "the", "url", "if", "given", "." ]
efa3ae28a49428ee60c6ee95b51c5d79f603acec
https://github.com/saclark/lite_page/blob/efa3ae28a49428ee60c6ee95b51c5d79f603acec/lib/lite_page.rb#L28-L41
train
jinx/core
lib/jinx/resource/merge_visitor.rb
Jinx.MergeVisitor.merge
def merge(source, target) # trivial case return target if source.equal?(target) # the domain attributes to merge mas = @mergeable.call(source) unless mas.empty? then logger.debug { "Merging #{source.qp} #{mas.to_series} into #{target.qp}..." } end # merge the non-domain attributes target.merge_attributes(source) # merge the source domain attributes into the target target.merge_attributes(source, mas, @matches, &@filter) end
ruby
def merge(source, target) # trivial case return target if source.equal?(target) # the domain attributes to merge mas = @mergeable.call(source) unless mas.empty? then logger.debug { "Merging #{source.qp} #{mas.to_series} into #{target.qp}..." } end # merge the non-domain attributes target.merge_attributes(source) # merge the source domain attributes into the target target.merge_attributes(source, mas, @matches, &@filter) end
[ "def", "merge", "(", "source", ",", "target", ")", "return", "target", "if", "source", ".", "equal?", "(", "target", ")", "mas", "=", "@mergeable", ".", "call", "(", "source", ")", "unless", "mas", ".", "empty?", "then", "logger", ".", "debug", "{", "\"Merging #{source.qp} #{mas.to_series} into #{target.qp}...\"", "}", "end", "target", ".", "merge_attributes", "(", "source", ")", "target", ".", "merge_attributes", "(", "source", ",", "mas", ",", "@matches", ",", "&", "@filter", ")", "end" ]
Merges the given source object into the target object. @param [Resource] source the domain object to merge from @param [Resource] target the domain object to merge into @return [Resource] the merged target
[ "Merges", "the", "given", "source", "object", "into", "the", "target", "object", "." ]
964a274cc9d7ab74613910e8375e12ed210a434d
https://github.com/jinx/core/blob/964a274cc9d7ab74613910e8375e12ed210a434d/lib/jinx/resource/merge_visitor.rb#L52-L64
train
codescrum/bebox
lib/bebox/node.rb
Bebox.Node.checkpoint_parameter_from_file
def checkpoint_parameter_from_file(node_type, parameter) Bebox::Node.checkpoint_parameter_from_file(self.project_root, self.environment, self.hostname, node_type, parameter) end
ruby
def checkpoint_parameter_from_file(node_type, parameter) Bebox::Node.checkpoint_parameter_from_file(self.project_root, self.environment, self.hostname, node_type, parameter) end
[ "def", "checkpoint_parameter_from_file", "(", "node_type", ",", "parameter", ")", "Bebox", "::", "Node", ".", "checkpoint_parameter_from_file", "(", "self", ".", "project_root", ",", "self", ".", "environment", ",", "self", ".", "hostname", ",", "node_type", ",", "parameter", ")", "end" ]
Get node checkpoint parameter from the yml file
[ "Get", "node", "checkpoint", "parameter", "from", "the", "yml", "file" ]
0d19315847103341e599d32837ab0bd75524e5be
https://github.com/codescrum/bebox/blob/0d19315847103341e599d32837ab0bd75524e5be/lib/bebox/node.rb#L38-L40
train
codescrum/bebox
lib/bebox/node.rb
Bebox.Node.prepare
def prepare started_at = DateTime.now.to_s prepare_deploy prepare_common_installation puppet_installation create_prepare_checkpoint(started_at) end
ruby
def prepare started_at = DateTime.now.to_s prepare_deploy prepare_common_installation puppet_installation create_prepare_checkpoint(started_at) end
[ "def", "prepare", "started_at", "=", "DateTime", ".", "now", ".", "to_s", "prepare_deploy", "prepare_common_installation", "puppet_installation", "create_prepare_checkpoint", "(", "started_at", ")", "end" ]
Prepare the configured nodes
[ "Prepare", "the", "configured", "nodes" ]
0d19315847103341e599d32837ab0bd75524e5be
https://github.com/codescrum/bebox/blob/0d19315847103341e599d32837ab0bd75524e5be/lib/bebox/node.rb#L49-L55
train
codescrum/bebox
lib/bebox/node.rb
Bebox.Node.create_hiera_template
def create_hiera_template options = {ssh_key: Bebox::Project.public_ssh_key_from_file(project_root, environment), project_name: Bebox::Project.shortname_from_file(project_root)} Bebox::Provision.generate_hiera_for_steps(self.project_root, "node.yaml.erb", self.hostname, options) end
ruby
def create_hiera_template options = {ssh_key: Bebox::Project.public_ssh_key_from_file(project_root, environment), project_name: Bebox::Project.shortname_from_file(project_root)} Bebox::Provision.generate_hiera_for_steps(self.project_root, "node.yaml.erb", self.hostname, options) end
[ "def", "create_hiera_template", "options", "=", "{", "ssh_key", ":", "Bebox", "::", "Project", ".", "public_ssh_key_from_file", "(", "project_root", ",", "environment", ")", ",", "project_name", ":", "Bebox", "::", "Project", ".", "shortname_from_file", "(", "project_root", ")", "}", "Bebox", "::", "Provision", ".", "generate_hiera_for_steps", "(", "self", ".", "project_root", ",", "\"node.yaml.erb\"", ",", "self", ".", "hostname", ",", "options", ")", "end" ]
Create the puppet hiera template file
[ "Create", "the", "puppet", "hiera", "template", "file" ]
0d19315847103341e599d32837ab0bd75524e5be
https://github.com/codescrum/bebox/blob/0d19315847103341e599d32837ab0bd75524e5be/lib/bebox/node.rb#L82-L85
train
codescrum/bebox
lib/bebox/node.rb
Bebox.Node.create_node_checkpoint
def create_node_checkpoint # Set the creation time for the node self.created_at = DateTime.now.to_s # Create the checkpoint file from template Bebox::Environment.create_checkpoint_directories(project_root, environment) generate_file_from_template("#{Bebox::FilesHelper::templates_path}/node/node.yml.erb", "#{project_root}/.checkpoints/environments/#{environment}/nodes/#{hostname}.yml", {node: self}) end
ruby
def create_node_checkpoint # Set the creation time for the node self.created_at = DateTime.now.to_s # Create the checkpoint file from template Bebox::Environment.create_checkpoint_directories(project_root, environment) generate_file_from_template("#{Bebox::FilesHelper::templates_path}/node/node.yml.erb", "#{project_root}/.checkpoints/environments/#{environment}/nodes/#{hostname}.yml", {node: self}) end
[ "def", "create_node_checkpoint", "self", ".", "created_at", "=", "DateTime", ".", "now", ".", "to_s", "Bebox", "::", "Environment", ".", "create_checkpoint_directories", "(", "project_root", ",", "environment", ")", "generate_file_from_template", "(", "\"#{Bebox::FilesHelper::templates_path}/node/node.yml.erb\"", ",", "\"#{project_root}/.checkpoints/environments/#{environment}/nodes/#{hostname}.yml\"", ",", "{", "node", ":", "self", "}", ")", "end" ]
Create checkpoint for node
[ "Create", "checkpoint", "for", "node" ]
0d19315847103341e599d32837ab0bd75524e5be
https://github.com/codescrum/bebox/blob/0d19315847103341e599d32837ab0bd75524e5be/lib/bebox/node.rb#L105-L111
train
jphenow/m2m_fast_insert
lib/m2m_fast_insert/has_and_belongs_to_many_override.rb
M2MFastInsert.HasAndBelongsToManyOverride.define_fast_methods_for_model
def define_fast_methods_for_model(name, options) join_table = options[:join_table] join_column_name = name.to_s.downcase.singularize define_method "fast_#{join_column_name}_ids_insert" do |*args| table_name = self.class.table_name.singularize insert = M2MFastInsert::Base.new id, join_column_name, table_name, join_table, *args insert.fast_insert end end
ruby
def define_fast_methods_for_model(name, options) join_table = options[:join_table] join_column_name = name.to_s.downcase.singularize define_method "fast_#{join_column_name}_ids_insert" do |*args| table_name = self.class.table_name.singularize insert = M2MFastInsert::Base.new id, join_column_name, table_name, join_table, *args insert.fast_insert end end
[ "def", "define_fast_methods_for_model", "(", "name", ",", "options", ")", "join_table", "=", "options", "[", ":join_table", "]", "join_column_name", "=", "name", ".", "to_s", ".", "downcase", ".", "singularize", "define_method", "\"fast_#{join_column_name}_ids_insert\"", "do", "|", "*", "args", "|", "table_name", "=", "self", ".", "class", ".", "table_name", ".", "singularize", "insert", "=", "M2MFastInsert", "::", "Base", ".", "new", "id", ",", "join_column_name", ",", "table_name", ",", "join_table", ",", "*", "args", "insert", ".", "fast_insert", "end", "end" ]
Get necessary table and column information so we can define fast insertion methods name - Plural name of the model we're associating with options - see ActiveRecord docs
[ "Get", "necessary", "table", "and", "column", "information", "so", "we", "can", "define", "fast", "insertion", "methods" ]
df5be1e6ac38327b6461911cbee3d547d9715cb6
https://github.com/jphenow/m2m_fast_insert/blob/df5be1e6ac38327b6461911cbee3d547d9715cb6/lib/m2m_fast_insert/has_and_belongs_to_many_override.rb#L27-L35
train
blambeau/yargi
lib/yargi/random.rb
Yargi.Random.execute
def execute graph = Digraph.new{|g| vertex_count.times do |i| vertex = g.add_vertex vertex_builder.call(vertex,i) if vertex_builder end edge_count.times do |i| source = g.ith_vertex(Kernel.rand(vertex_count)) target = g.ith_vertex(Kernel.rand(vertex_count)) edge = g.connect(source, target) edge_builder.call(edge,i) if edge_builder end } strip ? _strip(graph) : graph end
ruby
def execute graph = Digraph.new{|g| vertex_count.times do |i| vertex = g.add_vertex vertex_builder.call(vertex,i) if vertex_builder end edge_count.times do |i| source = g.ith_vertex(Kernel.rand(vertex_count)) target = g.ith_vertex(Kernel.rand(vertex_count)) edge = g.connect(source, target) edge_builder.call(edge,i) if edge_builder end } strip ? _strip(graph) : graph end
[ "def", "execute", "graph", "=", "Digraph", ".", "new", "{", "|", "g", "|", "vertex_count", ".", "times", "do", "|", "i", "|", "vertex", "=", "g", ".", "add_vertex", "vertex_builder", ".", "call", "(", "vertex", ",", "i", ")", "if", "vertex_builder", "end", "edge_count", ".", "times", "do", "|", "i", "|", "source", "=", "g", ".", "ith_vertex", "(", "Kernel", ".", "rand", "(", "vertex_count", ")", ")", "target", "=", "g", ".", "ith_vertex", "(", "Kernel", ".", "rand", "(", "vertex_count", ")", ")", "edge", "=", "g", ".", "connect", "(", "source", ",", "target", ")", "edge_builder", ".", "call", "(", "edge", ",", "i", ")", "if", "edge_builder", "end", "}", "strip", "?", "_strip", "(", "graph", ")", ":", "graph", "end" ]
Creates an algorithm instance Executes the random generation
[ "Creates", "an", "algorithm", "instance", "Executes", "the", "random", "generation" ]
100141e96d245a0a8211cd4f7590909be149bc3c
https://github.com/blambeau/yargi/blob/100141e96d245a0a8211cd4f7590909be149bc3c/lib/yargi/random.rb#L35-L49
train
Raybeam/myreplicator
app/models/myreplicator/log.rb
Myreplicator.Log.kill
def kill return false unless hostname == Socket.gethostname begin Process.kill('KILL', pid) self.state = "killed" self.save! rescue Errno::ESRCH puts "pid #{pid} does not exist!" mark_dead end end
ruby
def kill return false unless hostname == Socket.gethostname begin Process.kill('KILL', pid) self.state = "killed" self.save! rescue Errno::ESRCH puts "pid #{pid} does not exist!" mark_dead end end
[ "def", "kill", "return", "false", "unless", "hostname", "==", "Socket", ".", "gethostname", "begin", "Process", ".", "kill", "(", "'KILL'", ",", "pid", ")", "self", ".", "state", "=", "\"killed\"", "self", ".", "save!", "rescue", "Errno", "::", "ESRCH", "puts", "\"pid #{pid} does not exist!\"", "mark_dead", "end", "end" ]
Kills the job if running Using PID
[ "Kills", "the", "job", "if", "running", "Using", "PID" ]
470938e70f46886b525c65a4a464b4cf8383d00d
https://github.com/Raybeam/myreplicator/blob/470938e70f46886b525c65a4a464b4cf8383d00d/app/models/myreplicator/log.rb#L69-L79
train
Raybeam/myreplicator
app/models/myreplicator/log.rb
Myreplicator.Log.running?
def running? logs = Log.where(:file => file, :job_type => job_type, :state => "running", :export_id => export_id, :hostname => hostname) if logs.count > 0 logs.each do |log| begin Process.getpgid(log.pid) puts "still running #{log.file}" return true rescue Errno::ESRCH log.mark_dead end end end return false end
ruby
def running? logs = Log.where(:file => file, :job_type => job_type, :state => "running", :export_id => export_id, :hostname => hostname) if logs.count > 0 logs.each do |log| begin Process.getpgid(log.pid) puts "still running #{log.file}" return true rescue Errno::ESRCH log.mark_dead end end end return false end
[ "def", "running?", "logs", "=", "Log", ".", "where", "(", ":file", "=>", "file", ",", ":job_type", "=>", "job_type", ",", ":state", "=>", "\"running\"", ",", ":export_id", "=>", "export_id", ",", ":hostname", "=>", "hostname", ")", "if", "logs", ".", "count", ">", "0", "logs", ".", "each", "do", "|", "log", "|", "begin", "Process", ".", "getpgid", "(", "log", ".", "pid", ")", "puts", "\"still running #{log.file}\"", "return", "true", "rescue", "Errno", "::", "ESRCH", "log", ".", "mark_dead", "end", "end", "end", "return", "false", "end" ]
Checks to see if the PID of the log is active or not
[ "Checks", "to", "see", "if", "the", "PID", "of", "the", "log", "is", "active", "or", "not" ]
470938e70f46886b525c65a4a464b4cf8383d00d
https://github.com/Raybeam/myreplicator/blob/470938e70f46886b525c65a4a464b4cf8383d00d/app/models/myreplicator/log.rb#L84-L104
train
feduxorg/the_array_comparator
lib/the_array_comparator/strategy_dispatcher.rb
TheArrayComparator.StrategyDispatcher.register
def register(name, klass) if valid_strategy? klass available_strategies[name.to_sym] = klass else fail exception_to_raise_for_invalid_strategy, "Registering #{klass} failed. It does not support \"#{class_must_have_methods.join('-, ')}\"-method" end end
ruby
def register(name, klass) if valid_strategy? klass available_strategies[name.to_sym] = klass else fail exception_to_raise_for_invalid_strategy, "Registering #{klass} failed. It does not support \"#{class_must_have_methods.join('-, ')}\"-method" end end
[ "def", "register", "(", "name", ",", "klass", ")", "if", "valid_strategy?", "klass", "available_strategies", "[", "name", ".", "to_sym", "]", "=", "klass", "else", "fail", "exception_to_raise_for_invalid_strategy", ",", "\"Registering #{klass} failed. It does not support \\\"#{class_must_have_methods.join('-, ')}\\\"-method\"", "end", "end" ]
Register a new comparator strategy @param [String,Symbol] name The name which can be used to refer to the registered strategy @param [Comparator] klass The strategy class which should be registered @raise user defined exception Raise exception if an incompatible strategy class is given. Please see #exception_to_raise_for_invalid_strategy for more information
[ "Register", "a", "new", "comparator", "strategy" ]
66cdaf953909a34366cbee2b519dfcf306bc03c7
https://github.com/feduxorg/the_array_comparator/blob/66cdaf953909a34366cbee2b519dfcf306bc03c7/lib/the_array_comparator/strategy_dispatcher.rb#L52-L58
train
chef-workflow/furnish-ip
lib/furnish/range_set.rb
Furnish.RangeSet.assign_group_items
def assign_group_items(name, items, raise_if_exists=false) group = group_items(name) if items.kind_of?(Array) items = Set[*items] elsif !items.kind_of?(Set) items = Set[items] end c_allocated = allocated.count c_group = group.count items.each do |item| utf8_item = item.encode("UTF-8") allocated.add(utf8_item) group.add(utf8_item) end if raise_if_exists raise unless group.count == c_group + items.count && allocated.count == c_allocated + items.count end replace_group(name, group) return items end
ruby
def assign_group_items(name, items, raise_if_exists=false) group = group_items(name) if items.kind_of?(Array) items = Set[*items] elsif !items.kind_of?(Set) items = Set[items] end c_allocated = allocated.count c_group = group.count items.each do |item| utf8_item = item.encode("UTF-8") allocated.add(utf8_item) group.add(utf8_item) end if raise_if_exists raise unless group.count == c_group + items.count && allocated.count == c_allocated + items.count end replace_group(name, group) return items end
[ "def", "assign_group_items", "(", "name", ",", "items", ",", "raise_if_exists", "=", "false", ")", "group", "=", "group_items", "(", "name", ")", "if", "items", ".", "kind_of?", "(", "Array", ")", "items", "=", "Set", "[", "*", "items", "]", "elsif", "!", "items", ".", "kind_of?", "(", "Set", ")", "items", "=", "Set", "[", "items", "]", "end", "c_allocated", "=", "allocated", ".", "count", "c_group", "=", "group", ".", "count", "items", ".", "each", "do", "|", "item", "|", "utf8_item", "=", "item", ".", "encode", "(", "\"UTF-8\"", ")", "allocated", ".", "add", "(", "utf8_item", ")", "group", ".", "add", "(", "utf8_item", ")", "end", "if", "raise_if_exists", "raise", "unless", "group", ".", "count", "==", "c_group", "+", "items", ".", "count", "&&", "allocated", ".", "count", "==", "c_allocated", "+", "items", ".", "count", "end", "replace_group", "(", "name", ",", "group", ")", "return", "items", "end" ]
Assign one or more items to a group. This method is additive, so multitemle calls will grow the group, not replace it.
[ "Assign", "one", "or", "more", "items", "to", "a", "group", ".", "This", "method", "is", "additive", "so", "multitemle", "calls", "will", "grow", "the", "group", "not", "replace", "it", "." ]
52c356d62d96ede988d915ebb48bd9e77269a52a
https://github.com/chef-workflow/furnish-ip/blob/52c356d62d96ede988d915ebb48bd9e77269a52a/lib/furnish/range_set.rb#L110-L135
train
chef-workflow/furnish-ip
lib/furnish/range_set.rb
Furnish.RangeSet.remove_from_group
def remove_from_group(name, items) group = group_items(name) items.each do |item| utf8_item = item.encode("UTF-8") deallocate(utf8_item) group.delete(utf8_item) end replace_group(name, group) return items end
ruby
def remove_from_group(name, items) group = group_items(name) items.each do |item| utf8_item = item.encode("UTF-8") deallocate(utf8_item) group.delete(utf8_item) end replace_group(name, group) return items end
[ "def", "remove_from_group", "(", "name", ",", "items", ")", "group", "=", "group_items", "(", "name", ")", "items", ".", "each", "do", "|", "item", "|", "utf8_item", "=", "item", ".", "encode", "(", "\"UTF-8\"", ")", "deallocate", "(", "utf8_item", ")", "group", ".", "delete", "(", "utf8_item", ")", "end", "replace_group", "(", "name", ",", "group", ")", "return", "items", "end" ]
Remove the items from the group provided by name, also deallocates them.
[ "Remove", "the", "items", "from", "the", "group", "provided", "by", "name", "also", "deallocates", "them", "." ]
52c356d62d96ede988d915ebb48bd9e77269a52a
https://github.com/chef-workflow/furnish-ip/blob/52c356d62d96ede988d915ebb48bd9e77269a52a/lib/furnish/range_set.rb#L140-L152
train
chef-workflow/furnish-ip
lib/furnish/range_set.rb
Furnish.RangeSet.decommission_group
def decommission_group(name) group = group_items(name) group.each do |item| deallocate(item) end groups.delete(name) return name end
ruby
def decommission_group(name) group = group_items(name) group.each do |item| deallocate(item) end groups.delete(name) return name end
[ "def", "decommission_group", "(", "name", ")", "group", "=", "group_items", "(", "name", ")", "group", ".", "each", "do", "|", "item", "|", "deallocate", "(", "item", ")", "end", "groups", ".", "delete", "(", "name", ")", "return", "name", "end" ]
Remove a group and free its allocated item addresses.
[ "Remove", "a", "group", "and", "free", "its", "allocated", "item", "addresses", "." ]
52c356d62d96ede988d915ebb48bd9e77269a52a
https://github.com/chef-workflow/furnish-ip/blob/52c356d62d96ede988d915ebb48bd9e77269a52a/lib/furnish/range_set.rb#L157-L167
train
roberthoner/encrypted_store
lib/encrypted_store/instance.rb
EncryptedStore.Instance.preload_keys
def preload_keys(amount = 12) keys = EncryptedStore::ActiveRecord.preload_keys(amount) keys.each { |k| (@_decrypted_keys ||= {})[k.id] = k.decrypted_key } end
ruby
def preload_keys(amount = 12) keys = EncryptedStore::ActiveRecord.preload_keys(amount) keys.each { |k| (@_decrypted_keys ||= {})[k.id] = k.decrypted_key } end
[ "def", "preload_keys", "(", "amount", "=", "12", ")", "keys", "=", "EncryptedStore", "::", "ActiveRecord", ".", "preload_keys", "(", "amount", ")", "keys", ".", "each", "{", "|", "k", "|", "(", "@_decrypted_keys", "||=", "{", "}", ")", "[", "k", ".", "id", "]", "=", "k", ".", "decrypted_key", "}", "end" ]
Preloads the most recent `amount` keys.
[ "Preloads", "the", "most", "recent", "amount", "keys", "." ]
89e78eb19e0cb710b08b71209e42eda085dcaa8a
https://github.com/roberthoner/encrypted_store/blob/89e78eb19e0cb710b08b71209e42eda085dcaa8a/lib/encrypted_store/instance.rb#L17-L20
train
raygao/rforce-raygao
lib/rforce/binding.rb
RForce.Binding.login
def login(user, password) @user = user @password = password response = call_remote(:login, [:username, user, :password, password]) raise "Incorrect user name / password [#{response.fault}]" unless response.loginResponse result = response[:loginResponse][:result] @session_id = result[:sessionId] init_server(result[:serverUrl]) response end
ruby
def login(user, password) @user = user @password = password response = call_remote(:login, [:username, user, :password, password]) raise "Incorrect user name / password [#{response.fault}]" unless response.loginResponse result = response[:loginResponse][:result] @session_id = result[:sessionId] init_server(result[:serverUrl]) response end
[ "def", "login", "(", "user", ",", "password", ")", "@user", "=", "user", "@password", "=", "password", "response", "=", "call_remote", "(", ":login", ",", "[", ":username", ",", "user", ",", ":password", ",", "password", "]", ")", "raise", "\"Incorrect user name / password [#{response.fault}]\"", "unless", "response", ".", "loginResponse", "result", "=", "response", "[", ":loginResponse", "]", "[", ":result", "]", "@session_id", "=", "result", "[", ":sessionId", "]", "init_server", "(", "result", "[", ":serverUrl", "]", ")", "response", "end" ]
Log in to the server with a user name and password, remembering the session ID returned to us by SalesForce.
[ "Log", "in", "to", "the", "server", "with", "a", "user", "name", "and", "password", "remembering", "the", "session", "ID", "returned", "to", "us", "by", "SalesForce", "." ]
21bf35db2844f3e43b1cf8d290bfc0f413384fbf
https://github.com/raygao/rforce-raygao/blob/21bf35db2844f3e43b1cf8d290bfc0f413384fbf/lib/rforce/binding.rb#L98-L112
train
raygao/rforce-raygao
lib/rforce/binding.rb
RForce.Binding.login_with_oauth
def login_with_oauth result = @server.post @oauth[:login_url], '', {} case result when Net::HTTPSuccess doc = REXML::Document.new result.body @session_id = doc.elements['*/sessionId'].text server_url = doc.elements['*/serverUrl'].text init_server server_url return {:sessionId => @sessionId, :serverUrl => server_url} when Net::HTTPUnauthorized raise 'Invalid OAuth tokens' else raise 'Unexpected error: #{response.inspect}' end end
ruby
def login_with_oauth result = @server.post @oauth[:login_url], '', {} case result when Net::HTTPSuccess doc = REXML::Document.new result.body @session_id = doc.elements['*/sessionId'].text server_url = doc.elements['*/serverUrl'].text init_server server_url return {:sessionId => @sessionId, :serverUrl => server_url} when Net::HTTPUnauthorized raise 'Invalid OAuth tokens' else raise 'Unexpected error: #{response.inspect}' end end
[ "def", "login_with_oauth", "result", "=", "@server", ".", "post", "@oauth", "[", ":login_url", "]", ",", "''", ",", "{", "}", "case", "result", "when", "Net", "::", "HTTPSuccess", "doc", "=", "REXML", "::", "Document", ".", "new", "result", ".", "body", "@session_id", "=", "doc", ".", "elements", "[", "'*/sessionId'", "]", ".", "text", "server_url", "=", "doc", ".", "elements", "[", "'*/serverUrl'", "]", ".", "text", "init_server", "server_url", "return", "{", ":sessionId", "=>", "@sessionId", ",", ":serverUrl", "=>", "server_url", "}", "when", "Net", "::", "HTTPUnauthorized", "raise", "'Invalid OAuth tokens'", "else", "raise", "'Unexpected error: #{response.inspect}'", "end", "end" ]
Log in to the server with OAuth, remembering the session ID returned to us by SalesForce.
[ "Log", "in", "to", "the", "server", "with", "OAuth", "remembering", "the", "session", "ID", "returned", "to", "us", "by", "SalesForce", "." ]
21bf35db2844f3e43b1cf8d290bfc0f413384fbf
https://github.com/raygao/rforce-raygao/blob/21bf35db2844f3e43b1cf8d290bfc0f413384fbf/lib/rforce/binding.rb#L116-L132
train
raygao/rforce-raygao
lib/rforce/binding.rb
RForce.Binding.method_missing
def method_missing(method, *args) unless args.size == 1 && [Hash, Array].include?(args[0].class) raise 'Expected 1 Hash or Array argument' end call_remote method, args[0] end
ruby
def method_missing(method, *args) unless args.size == 1 && [Hash, Array].include?(args[0].class) raise 'Expected 1 Hash or Array argument' end call_remote method, args[0] end
[ "def", "method_missing", "(", "method", ",", "*", "args", ")", "unless", "args", ".", "size", "==", "1", "&&", "[", "Hash", ",", "Array", "]", ".", "include?", "(", "args", "[", "0", "]", ".", "class", ")", "raise", "'Expected 1 Hash or Array argument'", "end", "call_remote", "method", ",", "args", "[", "0", "]", "end" ]
Turns method calls on this object into remote SOAP calls.
[ "Turns", "method", "calls", "on", "this", "object", "into", "remote", "SOAP", "calls", "." ]
21bf35db2844f3e43b1cf8d290bfc0f413384fbf
https://github.com/raygao/rforce-raygao/blob/21bf35db2844f3e43b1cf8d290bfc0f413384fbf/lib/rforce/binding.rb#L247-L253
train
barkerest/shells
lib/shells/shell_base/interface.rb
Shells.ShellBase.teardown
def teardown #:doc: unless options[:quit].to_s.strip == '' self.ignore_io_error = true exec_ignore_code options[:quit], command_timeout: 1, timeout_error: false end end
ruby
def teardown #:doc: unless options[:quit].to_s.strip == '' self.ignore_io_error = true exec_ignore_code options[:quit], command_timeout: 1, timeout_error: false end end
[ "def", "teardown", "unless", "options", "[", ":quit", "]", ".", "to_s", ".", "strip", "==", "''", "self", ".", "ignore_io_error", "=", "true", "exec_ignore_code", "options", "[", ":quit", "]", ",", "command_timeout", ":", "1", ",", "timeout_error", ":", "false", "end", "end" ]
Tears down the shell session. This method is called after the session block is run before disconnecting the shell. The default implementation simply sends the quit command to the shell and waits up to 1 second for a result. This method will be called even if an exception is raised during the session.
[ "Tears", "down", "the", "shell", "session", "." ]
674a0254f48cea01b0ae8979933f13892e398506
https://github.com/barkerest/shells/blob/674a0254f48cea01b0ae8979933f13892e398506/lib/shells/shell_base/interface.rb#L37-L42
train
richard-viney/lightstreamer
lib/lightstreamer/post_request.rb
Lightstreamer.PostRequest.execute_multiple
def execute_multiple(url, bodies) response = Excon.post url, body: bodies.join("\r\n"), expects: 200, connect_timeout: 15 response_lines = response.body.split("\n").map(&:strip) errors = [] errors << parse_error(response_lines) until response_lines.empty? raise LightstreamerError if errors.size != bodies.size errors rescue Excon::Error => error raise Errors::ConnectionError, error.message end
ruby
def execute_multiple(url, bodies) response = Excon.post url, body: bodies.join("\r\n"), expects: 200, connect_timeout: 15 response_lines = response.body.split("\n").map(&:strip) errors = [] errors << parse_error(response_lines) until response_lines.empty? raise LightstreamerError if errors.size != bodies.size errors rescue Excon::Error => error raise Errors::ConnectionError, error.message end
[ "def", "execute_multiple", "(", "url", ",", "bodies", ")", "response", "=", "Excon", ".", "post", "url", ",", "body", ":", "bodies", ".", "join", "(", "\"\\r\\n\"", ")", ",", "expects", ":", "200", ",", "connect_timeout", ":", "15", "response_lines", "=", "response", ".", "body", ".", "split", "(", "\"\\n\"", ")", ".", "map", "(", "&", ":strip", ")", "errors", "=", "[", "]", "errors", "<<", "parse_error", "(", "response_lines", ")", "until", "response_lines", ".", "empty?", "raise", "LightstreamerError", "if", "errors", ".", "size", "!=", "bodies", ".", "size", "errors", "rescue", "Excon", "::", "Error", "=>", "error", "raise", "Errors", "::", "ConnectionError", ",", "error", ".", "message", "end" ]
Sends a POST request to the specified Lightstreamer URL that concatenates multiple individual POST request bodies into one to avoid sending lots of individual requests. The return value is an array with one entry per body and indicates the error state returned by the server for that body's request, or `nil` if no error occurred. @param [String] url The URL to send the POST request to. @param [Array<String>] bodies The individual POST request bodies that are to be sent together in one request. These should be created with {#request_body}. @return [Array<LightstreamerError, nil>] The execution result of each of the passed bodies. If an entry is `nil` then no error occurred when executing that body.
[ "Sends", "a", "POST", "request", "to", "the", "specified", "Lightstreamer", "URL", "that", "concatenates", "multiple", "individual", "POST", "request", "bodies", "into", "one", "to", "avoid", "sending", "lots", "of", "individual", "requests", ".", "The", "return", "value", "is", "an", "array", "with", "one", "entry", "per", "body", "and", "indicates", "the", "error", "state", "returned", "by", "the", "server", "for", "that", "body", "s", "request", "or", "nil", "if", "no", "error", "occurred", "." ]
7be6350bd861495a52ca35a8640a1e6df34cf9d1
https://github.com/richard-viney/lightstreamer/blob/7be6350bd861495a52ca35a8640a1e6df34cf9d1/lib/lightstreamer/post_request.rb#L29-L42
train
richard-viney/lightstreamer
lib/lightstreamer/post_request.rb
Lightstreamer.PostRequest.request_body
def request_body(query) params = {} query.each do |key, value| next if value.nil? value = value.map(&:to_s).join(' ') if value.is_a? Array params[key] = value end URI.encode_www_form params end
ruby
def request_body(query) params = {} query.each do |key, value| next if value.nil? value = value.map(&:to_s).join(' ') if value.is_a? Array params[key] = value end URI.encode_www_form params end
[ "def", "request_body", "(", "query", ")", "params", "=", "{", "}", "query", ".", "each", "do", "|", "key", ",", "value", "|", "next", "if", "value", ".", "nil?", "value", "=", "value", ".", "map", "(", "&", ":to_s", ")", ".", "join", "(", "' '", ")", "if", "value", ".", "is_a?", "Array", "params", "[", "key", "]", "=", "value", "end", "URI", ".", "encode_www_form", "params", "end" ]
Returns the request body to send for a POST request with the given options. @param [Hash] query The POST request's query params. @return [String] The request body for the given query params.
[ "Returns", "the", "request", "body", "to", "send", "for", "a", "POST", "request", "with", "the", "given", "options", "." ]
7be6350bd861495a52ca35a8640a1e6df34cf9d1
https://github.com/richard-viney/lightstreamer/blob/7be6350bd861495a52ca35a8640a1e6df34cf9d1/lib/lightstreamer/post_request.rb#L49-L59
train
richard-viney/lightstreamer
lib/lightstreamer/post_request.rb
Lightstreamer.PostRequest.parse_error
def parse_error(response_lines) first_line = response_lines.shift return nil if first_line == 'OK' return Errors::SyncError.new if first_line == 'SYNC ERROR' if first_line == 'ERROR' error_code = response_lines.shift LightstreamerError.build response_lines.shift, error_code else LightstreamerError.new first_line end end
ruby
def parse_error(response_lines) first_line = response_lines.shift return nil if first_line == 'OK' return Errors::SyncError.new if first_line == 'SYNC ERROR' if first_line == 'ERROR' error_code = response_lines.shift LightstreamerError.build response_lines.shift, error_code else LightstreamerError.new first_line end end
[ "def", "parse_error", "(", "response_lines", ")", "first_line", "=", "response_lines", ".", "shift", "return", "nil", "if", "first_line", "==", "'OK'", "return", "Errors", "::", "SyncError", ".", "new", "if", "first_line", "==", "'SYNC ERROR'", "if", "first_line", "==", "'ERROR'", "error_code", "=", "response_lines", ".", "shift", "LightstreamerError", ".", "build", "response_lines", ".", "shift", ",", "error_code", "else", "LightstreamerError", ".", "new", "first_line", "end", "end" ]
Parses the next error from the given lines that were returned by a POST request. The consumed lines are removed from the passed array. @param [Array<String>] response_lines @return [LightstreamerError, nil]
[ "Parses", "the", "next", "error", "from", "the", "given", "lines", "that", "were", "returned", "by", "a", "POST", "request", ".", "The", "consumed", "lines", "are", "removed", "from", "the", "passed", "array", "." ]
7be6350bd861495a52ca35a8640a1e6df34cf9d1
https://github.com/richard-viney/lightstreamer/blob/7be6350bd861495a52ca35a8640a1e6df34cf9d1/lib/lightstreamer/post_request.rb#L67-L79
train
Sacristan/ga_collector_pusher
lib/ga_collector_pusher/instance.rb
GACollectorPusher.Instance.add_exception
def add_exception description: nil, is_fatal: false is_fatal_int = is_fatal ? 1 : 0 @params = { t: "exception", exd: description, exf: is_fatal_int } send_to_ga end
ruby
def add_exception description: nil, is_fatal: false is_fatal_int = is_fatal ? 1 : 0 @params = { t: "exception", exd: description, exf: is_fatal_int } send_to_ga end
[ "def", "add_exception", "description", ":", "nil", ",", "is_fatal", ":", "false", "is_fatal_int", "=", "is_fatal", "?", "1", ":", "0", "@params", "=", "{", "t", ":", "\"exception\"", ",", "exd", ":", "description", ",", "exf", ":", "is_fatal_int", "}", "send_to_ga", "end" ]
convert bool to integer
[ "convert", "bool", "to", "integer" ]
851132d88b3b4259f10e0deb5a1cc787538d51ab
https://github.com/Sacristan/ga_collector_pusher/blob/851132d88b3b4259f10e0deb5a1cc787538d51ab/lib/ga_collector_pusher/instance.rb#L74-L84
train
lulibrary/aspire
lib/aspire/util.rb
Aspire.Util.child_url?
def child_url?(url1, url2, api = nil, strict: false) parent_url?(url2, url1, api, strict: strict) end
ruby
def child_url?(url1, url2, api = nil, strict: false) parent_url?(url2, url1, api, strict: strict) end
[ "def", "child_url?", "(", "url1", ",", "url2", ",", "api", "=", "nil", ",", "strict", ":", "false", ")", "parent_url?", "(", "url2", ",", "url1", ",", "api", ",", "strict", ":", "strict", ")", "end" ]
Returns true if the first URL is the child of the second URL @param url1 [Aspire::Caching::CacheEntry, String] the first URL @param url2 [Aspire::Caching::CacheEntry, String] the second URL @param api [Aspire::API::LinkedData] the API for generating canonical URLs @param strict [Boolean] if true, the URL must be a parent of this entry, otherwise the URL must be a parent or the same as this entry @return [Boolean] true if the URL is a child of the cache entry, false otherwise
[ "Returns", "true", "if", "the", "first", "URL", "is", "the", "child", "of", "the", "second", "URL" ]
623f481a2e79b9cb0b5feb923da438eb1ed2abfe
https://github.com/lulibrary/aspire/blob/623f481a2e79b9cb0b5feb923da438eb1ed2abfe/lib/aspire/util.rb#L23-L25
train
lulibrary/aspire
lib/aspire/util.rb
Aspire.Util.linked_data
def linked_data(uri, ld) uri = linked_data_path(uri) return nil unless uri && ld # The URI used to retrieve the data may be the canonical URI or a # tenancy aliases. We ignore the host part of the URIs and match just # the path ld.each { |u, data| return data if uri == linked_data_path(u) } # No match was found nil end
ruby
def linked_data(uri, ld) uri = linked_data_path(uri) return nil unless uri && ld # The URI used to retrieve the data may be the canonical URI or a # tenancy aliases. We ignore the host part of the URIs and match just # the path ld.each { |u, data| return data if uri == linked_data_path(u) } # No match was found nil end
[ "def", "linked_data", "(", "uri", ",", "ld", ")", "uri", "=", "linked_data_path", "(", "uri", ")", "return", "nil", "unless", "uri", "&&", "ld", "ld", ".", "each", "{", "|", "u", ",", "data", "|", "return", "data", "if", "uri", "==", "linked_data_path", "(", "u", ")", "}", "nil", "end" ]
Returns the data for a URI from a parsed linked data API response which may contain multiple objects @param uri [String] the URI of the object @param ld [Hash] the parsed JSON data from the Aspire linked data API @return [Hash] the parsed JSON data for the URI
[ "Returns", "the", "data", "for", "a", "URI", "from", "a", "parsed", "linked", "data", "API", "response", "which", "may", "contain", "multiple", "objects" ]
623f481a2e79b9cb0b5feb923da438eb1ed2abfe
https://github.com/lulibrary/aspire/blob/623f481a2e79b9cb0b5feb923da438eb1ed2abfe/lib/aspire/util.rb#L56-L65
train
lulibrary/aspire
lib/aspire/util.rb
Aspire.Util.linked_data_path
def linked_data_path(uri) URI.parse(uri).path rescue URI::InvalidComponentError, URI::InvalidURIError nil end
ruby
def linked_data_path(uri) URI.parse(uri).path rescue URI::InvalidComponentError, URI::InvalidURIError nil end
[ "def", "linked_data_path", "(", "uri", ")", "URI", ".", "parse", "(", "uri", ")", ".", "path", "rescue", "URI", "::", "InvalidComponentError", ",", "URI", "::", "InvalidURIError", "nil", "end" ]
Returns the path of a URI @param uri [String] the URI @return [String, nil] the URI path or nil if invalid
[ "Returns", "the", "path", "of", "a", "URI" ]
623f481a2e79b9cb0b5feb923da438eb1ed2abfe
https://github.com/lulibrary/aspire/blob/623f481a2e79b9cb0b5feb923da438eb1ed2abfe/lib/aspire/util.rb#L70-L74
train
lulibrary/aspire
lib/aspire/util.rb
Aspire.Util.list_url?
def list_url?(u = nil, parsed: nil) return false if (u.nil? || u.empty?) && parsed.nil? parsed ||= parse_url(u) child_type = parsed[:child_type] parsed[:type] == 'lists' && (child_type.nil? || child_type.empty?) end
ruby
def list_url?(u = nil, parsed: nil) return false if (u.nil? || u.empty?) && parsed.nil? parsed ||= parse_url(u) child_type = parsed[:child_type] parsed[:type] == 'lists' && (child_type.nil? || child_type.empty?) end
[ "def", "list_url?", "(", "u", "=", "nil", ",", "parsed", ":", "nil", ")", "return", "false", "if", "(", "u", ".", "nil?", "||", "u", ".", "empty?", ")", "&&", "parsed", ".", "nil?", "parsed", "||=", "parse_url", "(", "u", ")", "child_type", "=", "parsed", "[", ":child_type", "]", "parsed", "[", ":type", "]", "==", "'lists'", "&&", "(", "child_type", ".", "nil?", "||", "child_type", ".", "empty?", ")", "end" ]
Returns true if a URL is a list URL, false otherwise @param u [String] the URL of the API object @return [Boolean] true if the URL is a list URL, false otherwise
[ "Returns", "true", "if", "a", "URL", "is", "a", "list", "URL", "false", "otherwise" ]
623f481a2e79b9cb0b5feb923da438eb1ed2abfe
https://github.com/lulibrary/aspire/blob/623f481a2e79b9cb0b5feb923da438eb1ed2abfe/lib/aspire/util.rb#L86-L91
train
lulibrary/aspire
lib/aspire/util.rb
Aspire.Util.parent_url?
def parent_url?(url1, url2, api = nil, strict: false) u1 = url_for_comparison(url1, api, parsed: true) u2 = url_for_comparison(url2, api, parsed: true) # Both URLs must have the same parent return false unless u1[:type] == u2[:type] && u1[:id] == u2[:id] # Non-strict comparison requires only the same parent object return true unless strict # Strict comparison requires that this entry is a child of the URL u1[:child_type].nil? && !u2[:child_type].nil? ? true : false end
ruby
def parent_url?(url1, url2, api = nil, strict: false) u1 = url_for_comparison(url1, api, parsed: true) u2 = url_for_comparison(url2, api, parsed: true) # Both URLs must have the same parent return false unless u1[:type] == u2[:type] && u1[:id] == u2[:id] # Non-strict comparison requires only the same parent object return true unless strict # Strict comparison requires that this entry is a child of the URL u1[:child_type].nil? && !u2[:child_type].nil? ? true : false end
[ "def", "parent_url?", "(", "url1", ",", "url2", ",", "api", "=", "nil", ",", "strict", ":", "false", ")", "u1", "=", "url_for_comparison", "(", "url1", ",", "api", ",", "parsed", ":", "true", ")", "u2", "=", "url_for_comparison", "(", "url2", ",", "api", ",", "parsed", ":", "true", ")", "return", "false", "unless", "u1", "[", ":type", "]", "==", "u2", "[", ":type", "]", "&&", "u1", "[", ":id", "]", "==", "u2", "[", ":id", "]", "return", "true", "unless", "strict", "u1", "[", ":child_type", "]", ".", "nil?", "&&", "!", "u2", "[", ":child_type", "]", ".", "nil?", "?", "true", ":", "false", "end" ]
Returns true if the first URL is the parent of the second URL @param url1 [Aspire::Caching::CacheEntry, String] the first URL @param url2 [Aspire::Caching::CacheEntry, String] the second URL @param api [Aspire::API::LinkedData] the API for generating canonical URLs @param strict [Boolean] if true, the first URL must be a parent of the second URL, otherwise the first URL must be a parent or the same as the second. @return [Boolean] true if the URL has the same parent as this entry
[ "Returns", "true", "if", "the", "first", "URL", "is", "the", "parent", "of", "the", "second", "URL" ]
623f481a2e79b9cb0b5feb923da438eb1ed2abfe
https://github.com/lulibrary/aspire/blob/623f481a2e79b9cb0b5feb923da438eb1ed2abfe/lib/aspire/util.rb#L108-L117
train
lulibrary/aspire
lib/aspire/util.rb
Aspire.Util.url_for_comparison
def url_for_comparison(url, api = nil, parsed: false) if url.is_a?(MatchData) && parsed url elsif parsed && url.respond_to?(:parsed_url) url.parsed_url elsif !parsed && url.respond_to?(url) url.url else result = api.nil? ? url.to_s : api.canonical_url(url.to_s) parsed ? parse_url(result) : result end end
ruby
def url_for_comparison(url, api = nil, parsed: false) if url.is_a?(MatchData) && parsed url elsif parsed && url.respond_to?(:parsed_url) url.parsed_url elsif !parsed && url.respond_to?(url) url.url else result = api.nil? ? url.to_s : api.canonical_url(url.to_s) parsed ? parse_url(result) : result end end
[ "def", "url_for_comparison", "(", "url", ",", "api", "=", "nil", ",", "parsed", ":", "false", ")", "if", "url", ".", "is_a?", "(", "MatchData", ")", "&&", "parsed", "url", "elsif", "parsed", "&&", "url", ".", "respond_to?", "(", ":parsed_url", ")", "url", ".", "parsed_url", "elsif", "!", "parsed", "&&", "url", ".", "respond_to?", "(", "url", ")", "url", ".", "url", "else", "result", "=", "api", ".", "nil?", "?", "url", ".", "to_s", ":", "api", ".", "canonical_url", "(", "url", ".", "to_s", ")", "parsed", "?", "parse_url", "(", "result", ")", ":", "result", "end", "end" ]
Returns a parsed or unparsed URL for comparison @param url [Aspire::Caching::CacheEntry, String] the URL @param api [Aspire::API::LinkedData] the API for generating canonical URLs @param parsed [Boolean] if true, return a parsed URL, otherwise return an unparsed URL string @return [Aspire::Caching::CacheEntry, String] the URL for comparison
[ "Returns", "a", "parsed", "or", "unparsed", "URL", "for", "comparison" ]
623f481a2e79b9cb0b5feb923da438eb1ed2abfe
https://github.com/lulibrary/aspire/blob/623f481a2e79b9cb0b5feb923da438eb1ed2abfe/lib/aspire/util.rb#L153-L164
train
lulibrary/aspire
lib/aspire/util.rb
Aspire.Util.url_path
def url_path # Get the path component of the URL as a relative path filename = URI.parse(url).path filename.slice!(0) # Remove the leading / # Return the path with '.json' extension if not already present filename.end_with?('.json') ? filename : "#{filename}.json" rescue URI::InvalidComponentError, URI::InvalidURIError # Return nil if the URL is invalid nil end
ruby
def url_path # Get the path component of the URL as a relative path filename = URI.parse(url).path filename.slice!(0) # Remove the leading / # Return the path with '.json' extension if not already present filename.end_with?('.json') ? filename : "#{filename}.json" rescue URI::InvalidComponentError, URI::InvalidURIError # Return nil if the URL is invalid nil end
[ "def", "url_path", "filename", "=", "URI", ".", "parse", "(", "url", ")", ".", "path", "filename", ".", "slice!", "(", "0", ")", "filename", ".", "end_with?", "(", "'.json'", ")", "?", "filename", ":", "\"#{filename}.json\"", "rescue", "URI", "::", "InvalidComponentError", ",", "URI", "::", "InvalidURIError", "nil", "end" ]
Returns the path from the URL as a relative filename
[ "Returns", "the", "path", "from", "the", "URL", "as", "a", "relative", "filename" ]
623f481a2e79b9cb0b5feb923da438eb1ed2abfe
https://github.com/lulibrary/aspire/blob/623f481a2e79b9cb0b5feb923da438eb1ed2abfe/lib/aspire/util.rb#L167-L176
train
Dev-Crea/swagger-docs-generator
lib/swagger_docs_generator/generator.rb
SwaggerDocsGenerator.Generator.import_documentations
def import_documentations require SwaggerDocsGenerator.file_base SwaggerDocsGenerator.file_docs.each { |rb| require rb } end
ruby
def import_documentations require SwaggerDocsGenerator.file_base SwaggerDocsGenerator.file_docs.each { |rb| require rb } end
[ "def", "import_documentations", "require", "SwaggerDocsGenerator", ".", "file_base", "SwaggerDocsGenerator", ".", "file_docs", ".", "each", "{", "|", "rb", "|", "require", "rb", "}", "end" ]
Import documentation file
[ "Import", "documentation", "file" ]
5d3de176aa1119cb38100b451bee028d66c0809d
https://github.com/Dev-Crea/swagger-docs-generator/blob/5d3de176aa1119cb38100b451bee028d66c0809d/lib/swagger_docs_generator/generator.rb#L20-L23
train