id
int32
0
24.9k
repo
stringlengths
5
58
path
stringlengths
9
168
func_name
stringlengths
9
130
original_string
stringlengths
66
10.5k
language
stringclasses
1 value
code
stringlengths
66
10.5k
code_tokens
list
docstring
stringlengths
8
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
94
266
3,900
rightscale/right_link
lib/instance/cook/executable_sequence.rb
RightScale.ExecutableSequence.report_failure
def report_failure(title, msg) @ok = false @failure_title = title @failure_message = msg # note that the errback handler is expected to audit the message based on # the preserved title and message and so we don't audit it here. EM.next_tick { fail } true end
ruby
def report_failure(title, msg) @ok = false @failure_title = title @failure_message = msg # note that the errback handler is expected to audit the message based on # the preserved title and message and so we don't audit it here. EM.next_tick { fail } true end
[ "def", "report_failure", "(", "title", ",", "msg", ")", "@ok", "=", "false", "@failure_title", "=", "title", "@failure_message", "=", "msg", "# note that the errback handler is expected to audit the message based on", "# the preserved title and message and so we don't audit it here...
Set status with failure message and audit it === Parameters title(String):: Title used to update audit status msg(String):: Failure message === Return true:: Always return true
[ "Set", "status", "with", "failure", "message", "and", "audit", "it" ]
b33a209c20a8a0942dd9f1fe49a08030d4ca209f
https://github.com/rightscale/right_link/blob/b33a209c20a8a0942dd9f1fe49a08030d4ca209f/lib/instance/cook/executable_sequence.rb#L676-L684
3,901
rightscale/right_link
lib/instance/cook/executable_sequence.rb
RightScale.ExecutableSequence.chef_error
def chef_error(e) if e.is_a?(::RightScale::Exceptions::Exec) msg = "External command error: " if match = /RightScale::Exceptions::Exec: (.*)/.match(e.message) cmd_output = match[1] else cmd_output = e.message end msg += cmd_output msg += "\nThe c...
ruby
def chef_error(e) if e.is_a?(::RightScale::Exceptions::Exec) msg = "External command error: " if match = /RightScale::Exceptions::Exec: (.*)/.match(e.message) cmd_output = match[1] else cmd_output = e.message end msg += cmd_output msg += "\nThe c...
[ "def", "chef_error", "(", "e", ")", "if", "e", ".", "is_a?", "(", "::", "RightScale", "::", "Exceptions", "::", "Exec", ")", "msg", "=", "\"External command error: \"", "if", "match", "=", "/", "/", ".", "match", "(", "e", ".", "message", ")", "cmd_out...
Wrap chef exception with explanatory information and show context of failure === Parameters e(Exception):: Exception raised while executing Chef recipe === Return msg(String):: Human friendly error message
[ "Wrap", "chef", "exception", "with", "explanatory", "information", "and", "show", "context", "of", "failure" ]
b33a209c20a8a0942dd9f1fe49a08030d4ca209f
https://github.com/rightscale/right_link/blob/b33a209c20a8a0942dd9f1fe49a08030d4ca209f/lib/instance/cook/executable_sequence.rb#L694-L742
3,902
rightscale/right_link
lib/instance/cook/executable_sequence.rb
RightScale.ExecutableSequence.context_line
def context_line(lines, index, padding, prefix=nil) return '' if index < 1 || index > lines.size margin = prefix ? prefix * index.to_s.size : index.to_s "#{margin}#{' ' * ([padding - margin.size, 0].max)} #{lines[index - 1]}" end
ruby
def context_line(lines, index, padding, prefix=nil) return '' if index < 1 || index > lines.size margin = prefix ? prefix * index.to_s.size : index.to_s "#{margin}#{' ' * ([padding - margin.size, 0].max)} #{lines[index - 1]}" end
[ "def", "context_line", "(", "lines", ",", "index", ",", "padding", ",", "prefix", "=", "nil", ")", "return", "''", "if", "index", "<", "1", "||", "index", ">", "lines", ".", "size", "margin", "=", "prefix", "?", "prefix", "*", "index", ".", "to_s", ...
Format a single line for the error context, return empty string if given index is negative or greater than the lines array size === Parameters lines(Array):: Lines of text index(Integer):: Index of line that should be formatted for context padding(Integer):: Number of character to pad line with (includes prefix) ...
[ "Format", "a", "single", "line", "for", "the", "error", "context", "return", "empty", "string", "if", "given", "index", "is", "negative", "or", "greater", "than", "the", "lines", "array", "size" ]
b33a209c20a8a0942dd9f1fe49a08030d4ca209f
https://github.com/rightscale/right_link/blob/b33a209c20a8a0942dd9f1fe49a08030d4ca209f/lib/instance/cook/executable_sequence.rb#L753-L757
3,903
rightscale/right_link
lib/instance/cook/executable_sequence.rb
RightScale.ExecutableSequence.retry_execution
def retry_execution(retry_message, times = AgentConfig.max_packages_install_retries) count = 0 success = false begin count += 1 success = yield @audit.append_info("\n#{retry_message}\n") unless success || count > times end while !success && count <= times succes...
ruby
def retry_execution(retry_message, times = AgentConfig.max_packages_install_retries) count = 0 success = false begin count += 1 success = yield @audit.append_info("\n#{retry_message}\n") unless success || count > times end while !success && count <= times succes...
[ "def", "retry_execution", "(", "retry_message", ",", "times", "=", "AgentConfig", ".", "max_packages_install_retries", ")", "count", "=", "0", "success", "=", "false", "begin", "count", "+=", "1", "success", "=", "yield", "@audit", ".", "append_info", "(", "\"...
Retry executing given block given number of times Block should return true when it succeeds === Parameters retry_message(String):: Message to audit before retrying times(Integer):: Number of times block should be retried before giving up === Block Block to be executed === Return success(Boolean):: true if ex...
[ "Retry", "executing", "given", "block", "given", "number", "of", "times", "Block", "should", "return", "true", "when", "it", "succeeds" ]
b33a209c20a8a0942dd9f1fe49a08030d4ca209f
https://github.com/rightscale/right_link/blob/b33a209c20a8a0942dd9f1fe49a08030d4ca209f/lib/instance/cook/executable_sequence.rb#L771-L780
3,904
arineng/jcrvalidator
lib/jcr/parts.rb
JCR.JcrParts.get_start
def get_start( line ) retval = nil m = /^\s*;\s*start_part\s*(.+)[^\s]*/.match( line ) if m && m[1] retval = m[1] end return retval end
ruby
def get_start( line ) retval = nil m = /^\s*;\s*start_part\s*(.+)[^\s]*/.match( line ) if m && m[1] retval = m[1] end return retval end
[ "def", "get_start", "(", "line", ")", "retval", "=", "nil", "m", "=", "/", "\\s", "\\s", "\\s", "\\s", "/", ".", "match", "(", "line", ")", "if", "m", "&&", "m", "[", "1", "]", "retval", "=", "m", "[", "1", "]", "end", "return", "retval", "en...
Determines if the the line is a start_part comment. Return the file name otherwise nil
[ "Determines", "if", "the", "the", "line", "is", "a", "start_part", "comment", ".", "Return", "the", "file", "name", "otherwise", "nil" ]
69325242727e5e5b671db5ec287ad3b31fd91653
https://github.com/arineng/jcrvalidator/blob/69325242727e5e5b671db5ec287ad3b31fd91653/lib/jcr/parts.rb#L38-L45
3,905
arineng/jcrvalidator
lib/jcr/parts.rb
JCR.JcrParts.get_all
def get_all( line ) retval = nil m = /^\s*;\s*all_parts\s*(.+)[^\s]*/.match( line ) if m && m[1] retval = m[1] end return retval end
ruby
def get_all( line ) retval = nil m = /^\s*;\s*all_parts\s*(.+)[^\s]*/.match( line ) if m && m[1] retval = m[1] end return retval end
[ "def", "get_all", "(", "line", ")", "retval", "=", "nil", "m", "=", "/", "\\s", "\\s", "\\s", "\\s", "/", ".", "match", "(", "line", ")", "if", "m", "&&", "m", "[", "1", "]", "retval", "=", "m", "[", "1", "]", "end", "return", "retval", "end"...
Determines if the the line is an all_parts comment. Return the file name otherwise nil
[ "Determines", "if", "the", "the", "line", "is", "an", "all_parts", "comment", ".", "Return", "the", "file", "name", "otherwise", "nil" ]
69325242727e5e5b671db5ec287ad3b31fd91653
https://github.com/arineng/jcrvalidator/blob/69325242727e5e5b671db5ec287ad3b31fd91653/lib/jcr/parts.rb#L49-L56
3,906
arineng/jcrvalidator
lib/jcr/parts.rb
JCR.JcrParts.get_end
def get_end( line ) retval = nil m = /^\s*;\s*end_part/.match( line ) if m retval = true end return retval end
ruby
def get_end( line ) retval = nil m = /^\s*;\s*end_part/.match( line ) if m retval = true end return retval end
[ "def", "get_end", "(", "line", ")", "retval", "=", "nil", "m", "=", "/", "\\s", "\\s", "/", ".", "match", "(", "line", ")", "if", "m", "retval", "=", "true", "end", "return", "retval", "end" ]
Determines if the the line is an end_parts comment. Return true otherwise nil
[ "Determines", "if", "the", "the", "line", "is", "an", "end_parts", "comment", ".", "Return", "true", "otherwise", "nil" ]
69325242727e5e5b671db5ec287ad3b31fd91653
https://github.com/arineng/jcrvalidator/blob/69325242727e5e5b671db5ec287ad3b31fd91653/lib/jcr/parts.rb#L60-L67
3,907
arineng/jcrvalidator
lib/jcr/parts.rb
JCR.JcrParts.process_ruleset
def process_ruleset( ruleset, dirname = nil ) all_file_names = [] all_parts = [] all_parts_name = nil current_part = nil current_part_name = nil ruleset.lines do |line| if !all_parts_name && ( all_parts_name = get_all( line ) ) all_parts_name = File.join( dirname, a...
ruby
def process_ruleset( ruleset, dirname = nil ) all_file_names = [] all_parts = [] all_parts_name = nil current_part = nil current_part_name = nil ruleset.lines do |line| if !all_parts_name && ( all_parts_name = get_all( line ) ) all_parts_name = File.join( dirname, a...
[ "def", "process_ruleset", "(", "ruleset", ",", "dirname", "=", "nil", ")", "all_file_names", "=", "[", "]", "all_parts", "=", "[", "]", "all_parts_name", "=", "nil", "current_part", "=", "nil", "current_part_name", "=", "nil", "ruleset", ".", "lines", "do", ...
processes the lines ruleset is to be a string read in using File.read
[ "processes", "the", "lines", "ruleset", "is", "to", "be", "a", "string", "read", "in", "using", "File", ".", "read" ]
69325242727e5e5b671db5ec287ad3b31fd91653
https://github.com/arineng/jcrvalidator/blob/69325242727e5e5b671db5ec287ad3b31fd91653/lib/jcr/parts.rb#L71-L118
3,908
mattThousand/sad_panda
lib/sad_panda/polarity.rb
SadPanda.Polarity.call
def call words = stems_for(remove_stopwords_in(@words)) score_polarities_for(frequencies_for(words)) polarities.empty? ? 5.0 : (polarities.inject(0){ |sum, polarity| sum + polarity } / polarities.length) end
ruby
def call words = stems_for(remove_stopwords_in(@words)) score_polarities_for(frequencies_for(words)) polarities.empty? ? 5.0 : (polarities.inject(0){ |sum, polarity| sum + polarity } / polarities.length) end
[ "def", "call", "words", "=", "stems_for", "(", "remove_stopwords_in", "(", "@words", ")", ")", "score_polarities_for", "(", "frequencies_for", "(", "words", ")", ")", "polarities", ".", "empty?", "?", "5.0", ":", "(", "polarities", ".", "inject", "(", "0", ...
Main method that initiates calculating polarity
[ "Main", "method", "that", "initiates", "calculating", "polarity" ]
2ccb1496529d5c5a453d3822fa44b746295f3962
https://github.com/mattThousand/sad_panda/blob/2ccb1496529d5c5a453d3822fa44b746295f3962/lib/sad_panda/polarity.rb#L16-L22
3,909
mattThousand/sad_panda
lib/sad_panda/polarity.rb
SadPanda.Polarity.score_emoticon_polarity
def score_emoticon_polarity happy = happy_emoticon?(words) sad = sad_emoticon?(words) polarities << 5.0 if happy && sad polarities << 8.0 if happy polarities << 2.0 if sad end
ruby
def score_emoticon_polarity happy = happy_emoticon?(words) sad = sad_emoticon?(words) polarities << 5.0 if happy && sad polarities << 8.0 if happy polarities << 2.0 if sad end
[ "def", "score_emoticon_polarity", "happy", "=", "happy_emoticon?", "(", "words", ")", "sad", "=", "sad_emoticon?", "(", "words", ")", "polarities", "<<", "5.0", "if", "happy", "&&", "sad", "polarities", "<<", "8.0", "if", "happy", "polarities", "<<", "2.0", ...
Checks if words has happy or sad emoji and adds polarity for it
[ "Checks", "if", "words", "has", "happy", "or", "sad", "emoji", "and", "adds", "polarity", "for", "it" ]
2ccb1496529d5c5a453d3822fa44b746295f3962
https://github.com/mattThousand/sad_panda/blob/2ccb1496529d5c5a453d3822fa44b746295f3962/lib/sad_panda/polarity.rb#L27-L34
3,910
mattThousand/sad_panda
lib/sad_panda/polarity.rb
SadPanda.Polarity.score_polarities_for
def score_polarities_for(word_frequencies) word_frequencies.each do |word, frequency| polarity = SadPanda::Bank::POLARITIES[word.to_sym] polarities << (polarity * frequency.to_f) if polarity end score_emoticon_polarity end
ruby
def score_polarities_for(word_frequencies) word_frequencies.each do |word, frequency| polarity = SadPanda::Bank::POLARITIES[word.to_sym] polarities << (polarity * frequency.to_f) if polarity end score_emoticon_polarity end
[ "def", "score_polarities_for", "(", "word_frequencies", ")", "word_frequencies", ".", "each", "do", "|", "word", ",", "frequency", "|", "polarity", "=", "SadPanda", "::", "Bank", "::", "POLARITIES", "[", "word", ".", "to_sym", "]", "polarities", "<<", "(", "...
Appends polarities of words to array polarities
[ "Appends", "polarities", "of", "words", "to", "array", "polarities" ]
2ccb1496529d5c5a453d3822fa44b746295f3962
https://github.com/mattThousand/sad_panda/blob/2ccb1496529d5c5a453d3822fa44b746295f3962/lib/sad_panda/polarity.rb#L37-L44
3,911
rightscale/right_link
lib/instance/network_configurator/centos_network_configurator.rb
RightScale.CentosNetworkConfigurator.network_route_add
def network_route_add(network, nat_server_ip) super route_str = "#{network} via #{nat_server_ip}" begin if @boot logger.info "Adding route to network #{route_str}" device = route_device(network, nat_server_ip) if device update_route_file(network, nat_...
ruby
def network_route_add(network, nat_server_ip) super route_str = "#{network} via #{nat_server_ip}" begin if @boot logger.info "Adding route to network #{route_str}" device = route_device(network, nat_server_ip) if device update_route_file(network, nat_...
[ "def", "network_route_add", "(", "network", ",", "nat_server_ip", ")", "super", "route_str", "=", "\"#{network} via #{nat_server_ip}\"", "begin", "if", "@boot", "logger", ".", "info", "\"Adding route to network #{route_str}\"", "device", "=", "route_device", "(", "network...
This is now quite tricky. We do two routing passes, a pass before the system networking is setup (@boot is true) in which we setup static system config files and a pass after system networking (@boot is false) in which we fix up the remaining routes cases involving DHCP. We have to set any routes involving DHCP pos...
[ "This", "is", "now", "quite", "tricky", ".", "We", "do", "two", "routing", "passes", "a", "pass", "before", "the", "system", "networking", "is", "setup", "(" ]
b33a209c20a8a0942dd9f1fe49a08030d4ca209f
https://github.com/rightscale/right_link/blob/b33a209c20a8a0942dd9f1fe49a08030d4ca209f/lib/instance/network_configurator/centos_network_configurator.rb#L67-L102
3,912
rightscale/right_link
lib/instance/network_configurator/centos_network_configurator.rb
RightScale.CentosNetworkConfigurator.update_route_file
def update_route_file(network, nat_server_ip, device) raise "ERROR: invalid nat_server_ip : '#{nat_server_ip}'" unless valid_ipv4?(nat_server_ip) raise "ERROR: invalid CIDR network : '#{network}'" unless valid_ipv4_cidr?(network) routes_file = routes_file(device) ip_route_cmd = ip_route_cmd(net...
ruby
def update_route_file(network, nat_server_ip, device) raise "ERROR: invalid nat_server_ip : '#{nat_server_ip}'" unless valid_ipv4?(nat_server_ip) raise "ERROR: invalid CIDR network : '#{network}'" unless valid_ipv4_cidr?(network) routes_file = routes_file(device) ip_route_cmd = ip_route_cmd(net...
[ "def", "update_route_file", "(", "network", ",", "nat_server_ip", ",", "device", ")", "raise", "\"ERROR: invalid nat_server_ip : '#{nat_server_ip}'\"", "unless", "valid_ipv4?", "(", "nat_server_ip", ")", "raise", "\"ERROR: invalid CIDR network : '#{network}'\"", "unless", "vali...
Persist network route to file If the file does not exist, it will be created. If the route already exists, it will not be added again. === Parameters network(String):: target network in CIDR notation nat_server_ip(String):: the IP address of the NAT "router" === Return result(True):: Always returns true
[ "Persist", "network", "route", "to", "file" ]
b33a209c20a8a0942dd9f1fe49a08030d4ca209f
https://github.com/rightscale/right_link/blob/b33a209c20a8a0942dd9f1fe49a08030d4ca209f/lib/instance/network_configurator/centos_network_configurator.rb#L149-L163
3,913
rightscale/right_link
lib/instance/network_configurator/centos_network_configurator.rb
RightScale.CentosNetworkConfigurator.write_adaptor_config
def write_adaptor_config(device, data) config_file = config_file(device) raise "FATAL: invalid device name of '#{device}' specified for static IP allocation" unless device.match(/eth[0-9+]/) logger.info "Writing persistent network configuration to #{config_file}" File.open(config_file, "w") { |f...
ruby
def write_adaptor_config(device, data) config_file = config_file(device) raise "FATAL: invalid device name of '#{device}' specified for static IP allocation" unless device.match(/eth[0-9+]/) logger.info "Writing persistent network configuration to #{config_file}" File.open(config_file, "w") { |f...
[ "def", "write_adaptor_config", "(", "device", ",", "data", ")", "config_file", "=", "config_file", "(", "device", ")", "raise", "\"FATAL: invalid device name of '#{device}' specified for static IP allocation\"", "unless", "device", ".", "match", "(", "/", "/", ")", "log...
Persist device config to a file If the file does not exist, it will be created. === Parameters device(String):: target device name data(String):: target device config
[ "Persist", "device", "config", "to", "a", "file" ]
b33a209c20a8a0942dd9f1fe49a08030d4ca209f
https://github.com/rightscale/right_link/blob/b33a209c20a8a0942dd9f1fe49a08030d4ca209f/lib/instance/network_configurator/centos_network_configurator.rb#L225-L230
3,914
rightscale/right_link
lib/instance/network_configurator/centos_network_configurator.rb
RightScale.CentosNetworkConfigurator.update_config_file
def update_config_file(filename, line, exists_str=nil, append_str=nil) FileUtils.mkdir_p(File.dirname(filename)) # make sure the directory exists if read_config_file(filename).include?(line) exists_str ||= "Config already exists in #{filename}" logger.info exists_str else app...
ruby
def update_config_file(filename, line, exists_str=nil, append_str=nil) FileUtils.mkdir_p(File.dirname(filename)) # make sure the directory exists if read_config_file(filename).include?(line) exists_str ||= "Config already exists in #{filename}" logger.info exists_str else app...
[ "def", "update_config_file", "(", "filename", ",", "line", ",", "exists_str", "=", "nil", ",", "append_str", "=", "nil", ")", "FileUtils", ".", "mkdir_p", "(", "File", ".", "dirname", "(", "filename", ")", ")", "# make sure the directory exists", "if", "read_c...
Add line to config file If the file does not exist, it will be created. If the line already exists, it will not be added again. === Parameters filename(String):: absolute path to config file line(String):: line to add === Return result(Hash):: Hash-like leaf value
[ "Add", "line", "to", "config", "file" ]
b33a209c20a8a0942dd9f1fe49a08030d4ca209f
https://github.com/rightscale/right_link/blob/b33a209c20a8a0942dd9f1fe49a08030d4ca209f/lib/instance/network_configurator/centos_network_configurator.rb#L299-L312
3,915
rightscale/right_link
lib/instance/network_configurator/centos_network_configurator.rb
RightScale.CentosNetworkConfigurator.read_config_file
def read_config_file(filename) contents = "" File.open(filename, "r") { |f| contents = f.read() } if File.exists?(filename) contents end
ruby
def read_config_file(filename) contents = "" File.open(filename, "r") { |f| contents = f.read() } if File.exists?(filename) contents end
[ "def", "read_config_file", "(", "filename", ")", "contents", "=", "\"\"", "File", ".", "open", "(", "filename", ",", "\"r\"", ")", "{", "|", "f", "|", "contents", "=", "f", ".", "read", "(", ")", "}", "if", "File", ".", "exists?", "(", "filename", ...
Read contents of config file If file doesn't exist, return empty string === Return result(String):: All lines in file
[ "Read", "contents", "of", "config", "file" ]
b33a209c20a8a0942dd9f1fe49a08030d4ca209f
https://github.com/rightscale/right_link/blob/b33a209c20a8a0942dd9f1fe49a08030d4ca209f/lib/instance/network_configurator/centos_network_configurator.rb#L320-L324
3,916
rightscale/right_link
lib/instance/network_configurator/centos_network_configurator.rb
RightScale.CentosNetworkConfigurator.append_config_file
def append_config_file(filename, line) File.open(filename, "a") { |f| f.puts(line) } end
ruby
def append_config_file(filename, line) File.open(filename, "a") { |f| f.puts(line) } end
[ "def", "append_config_file", "(", "filename", ",", "line", ")", "File", ".", "open", "(", "filename", ",", "\"a\"", ")", "{", "|", "f", "|", "f", ".", "puts", "(", "line", ")", "}", "end" ]
Appends line to config file
[ "Appends", "line", "to", "config", "file" ]
b33a209c20a8a0942dd9f1fe49a08030d4ca209f
https://github.com/rightscale/right_link/blob/b33a209c20a8a0942dd9f1fe49a08030d4ca209f/lib/instance/network_configurator/centos_network_configurator.rb#L328-L330
3,917
rightscale/right_link
lib/instance/cook/cook.rb
RightScale.Cook.run
def run # 1. Load configuration settings options = OptionsBag.load agent_id = options[:identity] AgentConfig.root_dir = options[:root_dir] Log.program_name = 'RightLink' Log.facility = 'user' Log.log_to_file_only(options[:log_to_file_only]) Log.init(agent_id, options[:l...
ruby
def run # 1. Load configuration settings options = OptionsBag.load agent_id = options[:identity] AgentConfig.root_dir = options[:root_dir] Log.program_name = 'RightLink' Log.facility = 'user' Log.log_to_file_only(options[:log_to_file_only]) Log.init(agent_id, options[:l...
[ "def", "run", "# 1. Load configuration settings", "options", "=", "OptionsBag", ".", "load", "agent_id", "=", "options", "[", ":identity", "]", "AgentConfig", ".", "root_dir", "=", "options", "[", ":root_dir", "]", "Log", ".", "program_name", "=", "'RightLink'", ...
Run bundle given in stdin
[ "Run", "bundle", "given", "in", "stdin" ]
b33a209c20a8a0942dd9f1fe49a08030d4ca209f
https://github.com/rightscale/right_link/blob/b33a209c20a8a0942dd9f1fe49a08030d4ca209f/lib/instance/cook/cook.rb#L42-L120
3,918
rightscale/right_link
lib/instance/cook/cook.rb
RightScale.Cook.send_push
def send_push(type, payload = nil, target = nil, opts = {}) cmd = {:name => :send_push, :type => type, :payload => payload, :target => target, :options => opts} # Need to execute on EM main thread where command client is running EM.next_tick { @client.send_command(cmd) } end
ruby
def send_push(type, payload = nil, target = nil, opts = {}) cmd = {:name => :send_push, :type => type, :payload => payload, :target => target, :options => opts} # Need to execute on EM main thread where command client is running EM.next_tick { @client.send_command(cmd) } end
[ "def", "send_push", "(", "type", ",", "payload", "=", "nil", ",", "target", "=", "nil", ",", "opts", "=", "{", "}", ")", "cmd", "=", "{", ":name", "=>", ":send_push", ",", ":type", "=>", "type", ",", ":payload", "=>", "payload", ",", ":target", "=>...
Helper method to send a request to one or more targets with no response expected See InstanceCommands for details
[ "Helper", "method", "to", "send", "a", "request", "to", "one", "or", "more", "targets", "with", "no", "response", "expected", "See", "InstanceCommands", "for", "details" ]
b33a209c20a8a0942dd9f1fe49a08030d4ca209f
https://github.com/rightscale/right_link/blob/b33a209c20a8a0942dd9f1fe49a08030d4ca209f/lib/instance/cook/cook.rb#L141-L145
3,919
rightscale/right_link
lib/instance/cook/cook.rb
RightScale.Cook.load_tags
def load_tags(timeout) cmd = { :name => :get_tags } res = blocking_request(cmd, timeout) raise TagError.new("Retrieving current tags failed: #{res.inspect}") unless res.kind_of?(Array) ::Chef::Log.info("Successfully loaded current tags: '#{res.join("', '")}'") res end
ruby
def load_tags(timeout) cmd = { :name => :get_tags } res = blocking_request(cmd, timeout) raise TagError.new("Retrieving current tags failed: #{res.inspect}") unless res.kind_of?(Array) ::Chef::Log.info("Successfully loaded current tags: '#{res.join("', '")}'") res end
[ "def", "load_tags", "(", "timeout", ")", "cmd", "=", "{", ":name", "=>", ":get_tags", "}", "res", "=", "blocking_request", "(", "cmd", ",", "timeout", ")", "raise", "TagError", ".", "new", "(", "\"Retrieving current tags failed: #{res.inspect}\"", ")", "unless",...
Retrieve current instance tags === Parameters timeout(Fixnum):: Number of seconds to wait for agent response
[ "Retrieve", "current", "instance", "tags" ]
b33a209c20a8a0942dd9f1fe49a08030d4ca209f
https://github.com/rightscale/right_link/blob/b33a209c20a8a0942dd9f1fe49a08030d4ca209f/lib/instance/cook/cook.rb#L211-L218
3,920
rightscale/right_link
lib/instance/cook/cook.rb
RightScale.Cook.send_inputs_patch
def send_inputs_patch(sequence) if has_default_thread? begin cmd = { :name => :set_inputs_patch, :patch => sequence.inputs_patch } @client.send_command(cmd) rescue Exception => e fail('Failed to update inputs', Log.format("Failed to apply inputs patch after execution"...
ruby
def send_inputs_patch(sequence) if has_default_thread? begin cmd = { :name => :set_inputs_patch, :patch => sequence.inputs_patch } @client.send_command(cmd) rescue Exception => e fail('Failed to update inputs', Log.format("Failed to apply inputs patch after execution"...
[ "def", "send_inputs_patch", "(", "sequence", ")", "if", "has_default_thread?", "begin", "cmd", "=", "{", ":name", "=>", ":set_inputs_patch", ",", ":patch", "=>", "sequence", ".", "inputs_patch", "}", "@client", ".", "send_command", "(", "cmd", ")", "rescue", "...
Initialize instance variables Report inputs patch to core
[ "Initialize", "instance", "variables", "Report", "inputs", "patch", "to", "core" ]
b33a209c20a8a0942dd9f1fe49a08030d4ca209f
https://github.com/rightscale/right_link/blob/b33a209c20a8a0942dd9f1fe49a08030d4ca209f/lib/instance/cook/cook.rb#L234-L246
3,921
rightscale/right_link
lib/instance/cook/cook.rb
RightScale.Cook.report_failure
def report_failure(subject) begin AuditStub.instance.append_error(subject.failure_title, :category => RightScale::EventCategories::CATEGORY_ERROR) if subject.failure_title AuditStub.instance.append_error(subject.failure_message) if subject.failure_message rescue Exception => e fail('...
ruby
def report_failure(subject) begin AuditStub.instance.append_error(subject.failure_title, :category => RightScale::EventCategories::CATEGORY_ERROR) if subject.failure_title AuditStub.instance.append_error(subject.failure_message) if subject.failure_message rescue Exception => e fail('...
[ "def", "report_failure", "(", "subject", ")", "begin", "AuditStub", ".", "instance", ".", "append_error", "(", "subject", ".", "failure_title", ",", ":category", "=>", "RightScale", "::", "EventCategories", "::", "CATEGORY_ERROR", ")", "if", "subject", ".", "fai...
Report failure to core
[ "Report", "failure", "to", "core" ]
b33a209c20a8a0942dd9f1fe49a08030d4ca209f
https://github.com/rightscale/right_link/blob/b33a209c20a8a0942dd9f1fe49a08030d4ca209f/lib/instance/cook/cook.rb#L249-L258
3,922
rightscale/right_link
lib/instance/cook/cook.rb
RightScale.Cook.fail
def fail(title, message=nil) $stderr.puts title $stderr.puts message || title if @client @client.stop { AuditStub.instance.stop { exit(1) } } else exit(1) end end
ruby
def fail(title, message=nil) $stderr.puts title $stderr.puts message || title if @client @client.stop { AuditStub.instance.stop { exit(1) } } else exit(1) end end
[ "def", "fail", "(", "title", ",", "message", "=", "nil", ")", "$stderr", ".", "puts", "title", "$stderr", ".", "puts", "message", "||", "title", "if", "@client", "@client", ".", "stop", "{", "AuditStub", ".", "instance", ".", "stop", "{", "exit", "(", ...
Print failure message and exit abnormally
[ "Print", "failure", "message", "and", "exit", "abnormally" ]
b33a209c20a8a0942dd9f1fe49a08030d4ca209f
https://github.com/rightscale/right_link/blob/b33a209c20a8a0942dd9f1fe49a08030d4ca209f/lib/instance/cook/cook.rb#L261-L269
3,923
rightscale/right_link
lib/instance/cook/cook.rb
RightScale.Cook.stop
def stop AuditStub.instance.stop do @client.stop do |timeout| Log.info('[cook] Failed to stop command client cleanly, forcing shutdown...') if timeout EM.stop end end end
ruby
def stop AuditStub.instance.stop do @client.stop do |timeout| Log.info('[cook] Failed to stop command client cleanly, forcing shutdown...') if timeout EM.stop end end end
[ "def", "stop", "AuditStub", ".", "instance", ".", "stop", "do", "@client", ".", "stop", "do", "|", "timeout", "|", "Log", ".", "info", "(", "'[cook] Failed to stop command client cleanly, forcing shutdown...'", ")", "if", "timeout", "EM", ".", "stop", "end", "en...
Stop command client then stop auditor stub then EM
[ "Stop", "command", "client", "then", "stop", "auditor", "stub", "then", "EM" ]
b33a209c20a8a0942dd9f1fe49a08030d4ca209f
https://github.com/rightscale/right_link/blob/b33a209c20a8a0942dd9f1fe49a08030d4ca209f/lib/instance/cook/cook.rb#L272-L279
3,924
rightscale/right_link
lib/instance/cook/cook.rb
RightScale.Cook.blocking_request
def blocking_request(cmd, timeout) raise BlockingError, "Blocking request not allowed on EM main thread for command #{cmd.inspect}" if EM.reactor_thread? # Use a queue to block and wait for response response_queue = Queue.new # Need to execute on EM main thread where command client is running ...
ruby
def blocking_request(cmd, timeout) raise BlockingError, "Blocking request not allowed on EM main thread for command #{cmd.inspect}" if EM.reactor_thread? # Use a queue to block and wait for response response_queue = Queue.new # Need to execute on EM main thread where command client is running ...
[ "def", "blocking_request", "(", "cmd", ",", "timeout", ")", "raise", "BlockingError", ",", "\"Blocking request not allowed on EM main thread for command #{cmd.inspect}\"", "if", "EM", ".", "reactor_thread?", "# Use a queue to block and wait for response", "response_queue", "=", "...
Provides a blocking request for the given command Can only be called when on EM defer thread === Parameters cmd(Hash):: request to send === Return response(String):: raw response === Raise BlockingError:: If request called when on EM main thread
[ "Provides", "a", "blocking", "request", "for", "the", "given", "command", "Can", "only", "be", "called", "when", "on", "EM", "defer", "thread" ]
b33a209c20a8a0942dd9f1fe49a08030d4ca209f
https://github.com/rightscale/right_link/blob/b33a209c20a8a0942dd9f1fe49a08030d4ca209f/lib/instance/cook/cook.rb#L292-L299
3,925
rightscale/right_link
lib/instance/cook/cook.rb
RightScale.Cook.load
def load(data, error_message, format = nil) serializer = Serializer.new(format) content = nil begin content = serializer.load(data) rescue Exception => e fail(error_message, "Failed to load #{serializer.format.to_s} data (#{e}):\n#{data.inspect}") end content end
ruby
def load(data, error_message, format = nil) serializer = Serializer.new(format) content = nil begin content = serializer.load(data) rescue Exception => e fail(error_message, "Failed to load #{serializer.format.to_s} data (#{e}):\n#{data.inspect}") end content end
[ "def", "load", "(", "data", ",", "error_message", ",", "format", "=", "nil", ")", "serializer", "=", "Serializer", ".", "new", "(", "format", ")", "content", "=", "nil", "begin", "content", "=", "serializer", ".", "load", "(", "data", ")", "rescue", "E...
Load serialized content fail if serialized data is invalid === Parameters data(String):: Serialized content error_message(String):: Error to be logged/audited in case of failure format(Symbol):: Serialization format === Return content(String):: Unserialized content
[ "Load", "serialized", "content", "fail", "if", "serialized", "data", "is", "invalid" ]
b33a209c20a8a0942dd9f1fe49a08030d4ca209f
https://github.com/rightscale/right_link/blob/b33a209c20a8a0942dd9f1fe49a08030d4ca209f/lib/instance/cook/cook.rb#L311-L320
3,926
piotrmurach/verse
lib/verse/wrapping.rb
Verse.Wrapping.wrap
def wrap(wrap_at = DEFAULT_WIDTH) if text.length < wrap_at.to_i || wrap_at.to_i.zero? return text end ansi_stack = [] text.split(NEWLINE, -1).map do |paragraph| format_paragraph(paragraph, wrap_at, ansi_stack) end * NEWLINE end
ruby
def wrap(wrap_at = DEFAULT_WIDTH) if text.length < wrap_at.to_i || wrap_at.to_i.zero? return text end ansi_stack = [] text.split(NEWLINE, -1).map do |paragraph| format_paragraph(paragraph, wrap_at, ansi_stack) end * NEWLINE end
[ "def", "wrap", "(", "wrap_at", "=", "DEFAULT_WIDTH", ")", "if", "text", ".", "length", "<", "wrap_at", ".", "to_i", "||", "wrap_at", ".", "to_i", ".", "zero?", "return", "text", "end", "ansi_stack", "=", "[", "]", "text", ".", "split", "(", "NEWLINE", ...
Wrap a text into lines no longer than wrap_at length. Preserves existing lines and existing word boundaries. @example wrapping = Verse::Wrapping.new "Some longish text" wrapping.wrap(8) # => >Some >longish >text @api public
[ "Wrap", "a", "text", "into", "lines", "no", "longer", "than", "wrap_at", "length", ".", "Preserves", "existing", "lines", "and", "existing", "word", "boundaries", "." ]
4e3b9e4b3741600ee58e24478d463bfc553786f2
https://github.com/piotrmurach/verse/blob/4e3b9e4b3741600ee58e24478d463bfc553786f2/lib/verse/wrapping.rb#L41-L49
3,927
davetron5000/moocow
lib/moocow/endpoint.rb
RTM.Endpoint.url_for
def url_for(method,params={},endpoint='rest') params['api_key'] = @api_key params['method'] = method if method signature = sign(params) url = BASE_URL + endpoint + '/' + params_to_url(params.merge({'api_sig' => signature})) url end
ruby
def url_for(method,params={},endpoint='rest') params['api_key'] = @api_key params['method'] = method if method signature = sign(params) url = BASE_URL + endpoint + '/' + params_to_url(params.merge({'api_sig' => signature})) url end
[ "def", "url_for", "(", "method", ",", "params", "=", "{", "}", ",", "endpoint", "=", "'rest'", ")", "params", "[", "'api_key'", "]", "=", "@api_key", "params", "[", "'method'", "]", "=", "method", "if", "method", "signature", "=", "sign", "(", "params"...
Get the url for a particular call, doing the signing and all that other stuff. [method] the RTM method to call [params] hash of parameters. The +method+, +api_key+, and +api_sig+ parameters should _not_ be included. [endpoint] the endpoint relate to BASE_URL at which this request should be made.
[ "Get", "the", "url", "for", "a", "particular", "call", "doing", "the", "signing", "and", "all", "that", "other", "stuff", "." ]
92377d31d76728097fe505a5d0bf5dd7f034c9d5
https://github.com/davetron5000/moocow/blob/92377d31d76728097fe505a5d0bf5dd7f034c9d5/lib/moocow/endpoint.rb#L85-L91
3,928
davetron5000/moocow
lib/moocow/endpoint.rb
RTM.Endpoint.params_to_url
def params_to_url(params) string = '?' params.each do |k,v| string += CGI::escape(k) string += '=' string += CGI::escape(v) string += '&' end string end
ruby
def params_to_url(params) string = '?' params.each do |k,v| string += CGI::escape(k) string += '=' string += CGI::escape(v) string += '&' end string end
[ "def", "params_to_url", "(", "params", ")", "string", "=", "'?'", "params", ".", "each", "do", "|", "k", ",", "v", "|", "string", "+=", "CGI", "::", "escape", "(", "k", ")", "string", "+=", "'='", "string", "+=", "CGI", "::", "escape", "(", "v", ...
Turns params into a URL
[ "Turns", "params", "into", "a", "URL" ]
92377d31d76728097fe505a5d0bf5dd7f034c9d5
https://github.com/davetron5000/moocow/blob/92377d31d76728097fe505a5d0bf5dd7f034c9d5/lib/moocow/endpoint.rb#L119-L128
3,929
davetron5000/moocow
lib/moocow/endpoint.rb
RTM.Endpoint.sign
def sign(params) raise "Something's wrong; @secret is nil" if @secret.nil? sign_me = @secret params.keys.sort.each do |key| sign_me += key raise "Omit params with nil values; key #{key} was nil" if params[key].nil? sign_me += params[key] end return Digest::MD5.hexdi...
ruby
def sign(params) raise "Something's wrong; @secret is nil" if @secret.nil? sign_me = @secret params.keys.sort.each do |key| sign_me += key raise "Omit params with nil values; key #{key} was nil" if params[key].nil? sign_me += params[key] end return Digest::MD5.hexdi...
[ "def", "sign", "(", "params", ")", "raise", "\"Something's wrong; @secret is nil\"", "if", "@secret", ".", "nil?", "sign_me", "=", "@secret", "params", ".", "keys", ".", "sort", ".", "each", "do", "|", "key", "|", "sign_me", "+=", "key", "raise", "\"Omit par...
Signs the request given the params and secret key [params] hash of parameters
[ "Signs", "the", "request", "given", "the", "params", "and", "secret", "key" ]
92377d31d76728097fe505a5d0bf5dd7f034c9d5
https://github.com/davetron5000/moocow/blob/92377d31d76728097fe505a5d0bf5dd7f034c9d5/lib/moocow/endpoint.rb#L134-L143
3,930
flippa/ralexa
lib/ralexa/top_sites.rb
Ralexa.TopSites.country
def country(code, limit, params = {}) paginating_collection( limit, PER_PAGE, {"ResponseGroup" => "Country", "CountryCode" => code.to_s.upcase}, params, &top_sites_parser ) end
ruby
def country(code, limit, params = {}) paginating_collection( limit, PER_PAGE, {"ResponseGroup" => "Country", "CountryCode" => code.to_s.upcase}, params, &top_sites_parser ) end
[ "def", "country", "(", "code", ",", "limit", ",", "params", "=", "{", "}", ")", "paginating_collection", "(", "limit", ",", "PER_PAGE", ",", "{", "\"ResponseGroup\"", "=>", "\"Country\"", ",", "\"CountryCode\"", "=>", "code", ".", "to_s", ".", "upcase", "}...
Top sites for the specified two letter country code.
[ "Top", "sites", "for", "the", "specified", "two", "letter", "country", "code", "." ]
fd5bdff102fe52f5c2898b1f917a12a1f17f25de
https://github.com/flippa/ralexa/blob/fd5bdff102fe52f5c2898b1f917a12a1f17f25de/lib/ralexa/top_sites.rb#L18-L26
3,931
flippa/ralexa
lib/ralexa/top_sites.rb
Ralexa.TopSites.list_countries
def list_countries(params = {}) collection({"ResponseGroup" => "ListCountries"}, params) do |document| path = "//TopSitesResult/Alexa/TopSites/Countries" document.at(path).elements.map do |node| Country.new( node.at("Name").text, node.at("Code").text, ...
ruby
def list_countries(params = {}) collection({"ResponseGroup" => "ListCountries"}, params) do |document| path = "//TopSitesResult/Alexa/TopSites/Countries" document.at(path).elements.map do |node| Country.new( node.at("Name").text, node.at("Code").text, ...
[ "def", "list_countries", "(", "params", "=", "{", "}", ")", "collection", "(", "{", "\"ResponseGroup\"", "=>", "\"ListCountries\"", "}", ",", "params", ")", "do", "|", "document", "|", "path", "=", "\"//TopSitesResult/Alexa/TopSites/Countries\"", "document", ".", ...
All countries that have Alexa top sites.
[ "All", "countries", "that", "have", "Alexa", "top", "sites", "." ]
fd5bdff102fe52f5c2898b1f917a12a1f17f25de
https://github.com/flippa/ralexa/blob/fd5bdff102fe52f5c2898b1f917a12a1f17f25de/lib/ralexa/top_sites.rb#L29-L42
3,932
jrichardlai/taskrabbit
lib/taskrabbit/smash.rb
Taskrabbit.Smash.reload
def reload(method, path, options = {}) self.loaded = true response = request(method, path, self.class, Smash::filtered_options(options)) self.merge!(response) clear_errors !redirect? rescue Smash::Error => e self.merge!(e.response) if e.response.is_a?(Hash) false end
ruby
def reload(method, path, options = {}) self.loaded = true response = request(method, path, self.class, Smash::filtered_options(options)) self.merge!(response) clear_errors !redirect? rescue Smash::Error => e self.merge!(e.response) if e.response.is_a?(Hash) false end
[ "def", "reload", "(", "method", ",", "path", ",", "options", "=", "{", "}", ")", "self", ".", "loaded", "=", "true", "response", "=", "request", "(", "method", ",", "path", ",", "self", ".", "class", ",", "Smash", "::", "filtered_options", "(", "opti...
reload the object after doing a query to the api
[ "reload", "the", "object", "after", "doing", "a", "query", "to", "the", "api" ]
26f8526b60091a46b444e7b736137133868fb3c2
https://github.com/jrichardlai/taskrabbit/blob/26f8526b60091a46b444e7b736137133868fb3c2/lib/taskrabbit/smash.rb#L63-L72
3,933
jrichardlai/taskrabbit
lib/taskrabbit/smash.rb
Taskrabbit.Smash.[]
def [](property) value = nil return value unless (value = super(property)).nil? if api and !loaded # load the object if trying to access a property self.loaded = true fetch end super(property) end
ruby
def [](property) value = nil return value unless (value = super(property)).nil? if api and !loaded # load the object if trying to access a property self.loaded = true fetch end super(property) end
[ "def", "[]", "(", "property", ")", "value", "=", "nil", "return", "value", "unless", "(", "value", "=", "super", "(", "property", ")", ")", ".", "nil?", "if", "api", "and", "!", "loaded", "# load the object if trying to access a property", "self", ".", "load...
get the property from the hash if the value is not set and the object has not been loaded, try to load it
[ "get", "the", "property", "from", "the", "hash", "if", "the", "value", "is", "not", "set", "and", "the", "object", "has", "not", "been", "loaded", "try", "to", "load", "it" ]
26f8526b60091a46b444e7b736137133868fb3c2
https://github.com/jrichardlai/taskrabbit/blob/26f8526b60091a46b444e7b736137133868fb3c2/lib/taskrabbit/smash.rb#L79-L88
3,934
christinedraper/knife-topo
lib/chef/knife/topo/bootstrap_helper.rb
KnifeTopo.BootstrapHelper.run_bootstrap
def run_bootstrap(data, bootstrap_args, overwrite = false) node_name = data['name'] args = setup_bootstrap_args(bootstrap_args, data) delete_client_node(node_name) if overwrite ui.info "Bootstrapping node #{node_name}" run_cmd(Chef::Knife::Bootstrap, args) rescue StandardError => e ...
ruby
def run_bootstrap(data, bootstrap_args, overwrite = false) node_name = data['name'] args = setup_bootstrap_args(bootstrap_args, data) delete_client_node(node_name) if overwrite ui.info "Bootstrapping node #{node_name}" run_cmd(Chef::Knife::Bootstrap, args) rescue StandardError => e ...
[ "def", "run_bootstrap", "(", "data", ",", "bootstrap_args", ",", "overwrite", "=", "false", ")", "node_name", "=", "data", "[", "'name'", "]", "args", "=", "setup_bootstrap_args", "(", "bootstrap_args", ",", "data", ")", "delete_client_node", "(", "node_name", ...
Setup the bootstrap args and run the bootstrap command
[ "Setup", "the", "bootstrap", "args", "and", "run", "the", "bootstrap", "command" ]
323f5767a6ed98212629888323c4e694fec820ca
https://github.com/christinedraper/knife-topo/blob/323f5767a6ed98212629888323c4e694fec820ca/lib/chef/knife/topo/bootstrap_helper.rb#L28-L40
3,935
marks/truevault.rb
lib/truevault/authorization.rb
TrueVault.Authorization.login
def login(options = {}) body = { body: { username: options[:username], password: options[:password], account_id: options[:account_id] } } self.class.post("/#{@api_ver}/auth/login", body) end
ruby
def login(options = {}) body = { body: { username: options[:username], password: options[:password], account_id: options[:account_id] } } self.class.post("/#{@api_ver}/auth/login", body) end
[ "def", "login", "(", "options", "=", "{", "}", ")", "body", "=", "{", "body", ":", "{", "username", ":", "options", "[", ":username", "]", ",", "password", ":", "options", "[", ":password", "]", ",", "account_id", ":", "options", "[", ":account_id", ...
AUTHORIZATION API Methods logs in a user the account_id is different from user id response TVAuth.login( username: "bar", password: "foo", account_id: "00000000-0000-0000-0000-000000000000" )
[ "AUTHORIZATION", "API", "Methods" ]
d0d22fc0945de324e45e7d300a37542949ee67b9
https://github.com/marks/truevault.rb/blob/d0d22fc0945de324e45e7d300a37542949ee67b9/lib/truevault/authorization.rb#L17-L26
3,936
rhenium/plum
lib/plum/frame.rb
Plum.Frame.flags
def flags fs = FRAME_FLAGS[type] [0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80] .select { |v| @flags_value & v > 0 } .map { |val| fs && fs.key(val) || ("unknown_%02x" % val).to_sym } end
ruby
def flags fs = FRAME_FLAGS[type] [0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80] .select { |v| @flags_value & v > 0 } .map { |val| fs && fs.key(val) || ("unknown_%02x" % val).to_sym } end
[ "def", "flags", "fs", "=", "FRAME_FLAGS", "[", "type", "]", "[", "0x01", ",", "0x02", ",", "0x04", ",", "0x08", ",", "0x10", ",", "0x20", ",", "0x40", ",", "0x80", "]", ".", "select", "{", "|", "v", "|", "@flags_value", "&", "v", ">", "0", "}",...
Returns the set flags on the frame. @return [Array<Symbol>] The flags.
[ "Returns", "the", "set", "flags", "on", "the", "frame", "." ]
9190801a092d46c7079ccee201b212b2d7985952
https://github.com/rhenium/plum/blob/9190801a092d46c7079ccee201b212b2d7985952/lib/plum/frame.rb#L119-L124
3,937
rhenium/plum
lib/plum/frame.rb
Plum.Frame.flags=
def flags=(values) val = 0 FRAME_FLAGS_MAP.values_at(*values).each { |c| val |= c if c } @flags_value = val end
ruby
def flags=(values) val = 0 FRAME_FLAGS_MAP.values_at(*values).each { |c| val |= c if c } @flags_value = val end
[ "def", "flags", "=", "(", "values", ")", "val", "=", "0", "FRAME_FLAGS_MAP", ".", "values_at", "(", "values", ")", ".", "each", "{", "|", "c", "|", "val", "|=", "c", "if", "c", "}", "@flags_value", "=", "val", "end" ]
Sets the frame flags. @param values [Array<Symbol>] The flags.
[ "Sets", "the", "frame", "flags", "." ]
9190801a092d46c7079ccee201b212b2d7985952
https://github.com/rhenium/plum/blob/9190801a092d46c7079ccee201b212b2d7985952/lib/plum/frame.rb#L128-L134
3,938
rhenium/plum
lib/plum/connection.rb
Plum.Connection.receive
def receive(new_data) return if @state == :closed return if new_data.empty? @buffer << new_data consume_buffer rescue RemoteConnectionError => e callback(:connection_error, e) goaway(e.http2_error_type) close end
ruby
def receive(new_data) return if @state == :closed return if new_data.empty? @buffer << new_data consume_buffer rescue RemoteConnectionError => e callback(:connection_error, e) goaway(e.http2_error_type) close end
[ "def", "receive", "(", "new_data", ")", "return", "if", "@state", "==", ":closed", "return", "if", "new_data", ".", "empty?", "@buffer", "<<", "new_data", "consume_buffer", "rescue", "RemoteConnectionError", "=>", "e", "callback", "(", ":connection_error", ",", ...
Receives the specified data and process. @param new_data [String] The data received from the peer.
[ "Receives", "the", "specified", "data", "and", "process", "." ]
9190801a092d46c7079ccee201b212b2d7985952
https://github.com/rhenium/plum/blob/9190801a092d46c7079ccee201b212b2d7985952/lib/plum/connection.rb#L49-L58
3,939
rhenium/plum
lib/plum/connection.rb
Plum.Connection.stream
def stream(stream_id, update_max_id = true) raise ArgumentError, "stream_id can't be 0" if stream_id == 0 stream = @streams[stream_id] if stream if stream.state == :idle && stream_id < @max_stream_ids[stream_id % 2] stream.set_state(:closed_implicitly) end elsif stream...
ruby
def stream(stream_id, update_max_id = true) raise ArgumentError, "stream_id can't be 0" if stream_id == 0 stream = @streams[stream_id] if stream if stream.state == :idle && stream_id < @max_stream_ids[stream_id % 2] stream.set_state(:closed_implicitly) end elsif stream...
[ "def", "stream", "(", "stream_id", ",", "update_max_id", "=", "true", ")", "raise", "ArgumentError", ",", "\"stream_id can't be 0\"", "if", "stream_id", "==", "0", "stream", "=", "@streams", "[", "stream_id", "]", "if", "stream", "if", "stream", ".", "state", ...
Returns a Stream object with the specified ID. @param stream_id [Integer] the stream id @return [Stream] the stream
[ "Returns", "a", "Stream", "object", "with", "the", "specified", "ID", "." ]
9190801a092d46c7079ccee201b212b2d7985952
https://github.com/rhenium/plum/blob/9190801a092d46c7079ccee201b212b2d7985952/lib/plum/connection.rb#L64-L83
3,940
rhenium/plum
lib/plum/connection.rb
Plum.Connection.settings
def settings(**new_settings) send_immediately Frame::Settings.new(**new_settings) old_settings = @local_settings.dup @local_settings.merge!(new_settings) @hpack_decoder.limit = @local_settings[:header_table_size] update_recv_initial_window_size(@local_settings[:initial_window_size] - old...
ruby
def settings(**new_settings) send_immediately Frame::Settings.new(**new_settings) old_settings = @local_settings.dup @local_settings.merge!(new_settings) @hpack_decoder.limit = @local_settings[:header_table_size] update_recv_initial_window_size(@local_settings[:initial_window_size] - old...
[ "def", "settings", "(", "**", "new_settings", ")", "send_immediately", "Frame", "::", "Settings", ".", "new", "(", "**", "new_settings", ")", "old_settings", "=", "@local_settings", ".", "dup", "@local_settings", ".", "merge!", "(", "new_settings", ")", "@hpack_...
Sends local settings to the peer. @param new_settings [Hash<Symbol, Integer>]
[ "Sends", "local", "settings", "to", "the", "peer", "." ]
9190801a092d46c7079ccee201b212b2d7985952
https://github.com/rhenium/plum/blob/9190801a092d46c7079ccee201b212b2d7985952/lib/plum/connection.rb#L87-L95
3,941
rhenium/plum
lib/plum/connection.rb
Plum.Connection.goaway
def goaway(error_type = :no_error, message = "") last_id = @max_stream_ids.max send_immediately Frame::Goaway.new(last_id, error_type, message) end
ruby
def goaway(error_type = :no_error, message = "") last_id = @max_stream_ids.max send_immediately Frame::Goaway.new(last_id, error_type, message) end
[ "def", "goaway", "(", "error_type", "=", ":no_error", ",", "message", "=", "\"\"", ")", "last_id", "=", "@max_stream_ids", ".", "max", "send_immediately", "Frame", "::", "Goaway", ".", "new", "(", "last_id", ",", "error_type", ",", "message", ")", "end" ]
Sends GOAWAY frame to the peer and closes the connection. @param error_type [Symbol] The error type to be contained in the GOAWAY frame.
[ "Sends", "GOAWAY", "frame", "to", "the", "peer", "and", "closes", "the", "connection", "." ]
9190801a092d46c7079ccee201b212b2d7985952
https://github.com/rhenium/plum/blob/9190801a092d46c7079ccee201b212b2d7985952/lib/plum/connection.rb#L106-L109
3,942
zinosama/transitionable
lib/transitionable.rb
Transitionable.ClassMethods.transition
def transition(name, states = self::STATES, transitions = self::TRANSITIONS) self.state_machines ||= {} self.state_machines[name] = { states: states.values, transitions: transitions } self.state_machines[name][:states].each do |this_state| method_name = "#{this_state}?".to_sym raise 'M...
ruby
def transition(name, states = self::STATES, transitions = self::TRANSITIONS) self.state_machines ||= {} self.state_machines[name] = { states: states.values, transitions: transitions } self.state_machines[name][:states].each do |this_state| method_name = "#{this_state}?".to_sym raise 'M...
[ "def", "transition", "(", "name", ",", "states", "=", "self", "::", "STATES", ",", "transitions", "=", "self", "::", "TRANSITIONS", ")", "self", ".", "state_machines", "||=", "{", "}", "self", ".", "state_machines", "[", "name", "]", "=", "{", "states", ...
This assumes states is a hash
[ "This", "assumes", "states", "is", "a", "hash" ]
c2208bffbc377e68106d1349f18201941058e34e
https://github.com/zinosama/transitionable/blob/c2208bffbc377e68106d1349f18201941058e34e/lib/transitionable.rb#L22-L32
3,943
kandebonfim/itcsscli
lib/itcsscli.rb
Itcsscli.Core.inuit_find_modules
def inuit_find_modules(current_module) current_config = YAML.load_file(@ITCSS_CONFIG_FILE) current_inuit_modules = current_config["inuit_modules"].select{ |p| p.include? current_module } current_inuit_modules.map{ |p| inuit_imports_path p } end
ruby
def inuit_find_modules(current_module) current_config = YAML.load_file(@ITCSS_CONFIG_FILE) current_inuit_modules = current_config["inuit_modules"].select{ |p| p.include? current_module } current_inuit_modules.map{ |p| inuit_imports_path p } end
[ "def", "inuit_find_modules", "(", "current_module", ")", "current_config", "=", "YAML", ".", "load_file", "(", "@ITCSS_CONFIG_FILE", ")", "current_inuit_modules", "=", "current_config", "[", "\"inuit_modules\"", "]", ".", "select", "{", "|", "p", "|", "p", ".", ...
Inuit Helper Methods
[ "Inuit", "Helper", "Methods" ]
11ac53187a8c6af389e3aefabe0b54f0dd591526
https://github.com/kandebonfim/itcsscli/blob/11ac53187a8c6af389e3aefabe0b54f0dd591526/lib/itcsscli.rb#L370-L374
3,944
artemk/syntaxer
lib/syntaxer/writer.rb
Syntaxer.Writer.block
def block name, param = nil, &b sp = ' '*2 if name == :lang || name == :languages body = yield self if block_given? param = ":#{param.to_s}" unless param.nil? "#{sp}#{name.to_s} #{param} do\n#{body}\n#{sp}end\n" end
ruby
def block name, param = nil, &b sp = ' '*2 if name == :lang || name == :languages body = yield self if block_given? param = ":#{param.to_s}" unless param.nil? "#{sp}#{name.to_s} #{param} do\n#{body}\n#{sp}end\n" end
[ "def", "block", "name", ",", "param", "=", "nil", ",", "&", "b", "sp", "=", "' '", "*", "2", "if", "name", "==", ":lang", "||", "name", "==", ":languages", "body", "=", "yield", "self", "if", "block_given?", "param", "=", "\":#{param.to_s}\"", "unless"...
Create DSL block @param [Symbol, String] block name @param [String] parameter that is passed in to block @return [String] DSL block string
[ "Create", "DSL", "block" ]
7557318e9ab1554b38cb8df9d00f2ff4acc701cb
https://github.com/artemk/syntaxer/blob/7557318e9ab1554b38cb8df9d00f2ff4acc701cb/lib/syntaxer/writer.rb#L63-L68
3,945
artemk/syntaxer
lib/syntaxer/writer.rb
Syntaxer.Writer.property
def property name, prop return '' if EXCLUDE_PROPERTIES.include?(name.to_s) || prop.nil? || (prop.kind_of?(Array) && prop.empty?) prop = prop.flatten.map{|p| "'#{p}'"}.join(', ') if prop.respond_to?(:flatten) && name.to_sym != :folders prop = @paths.map{|f| "'#{f}'"}.join(',') if name.to_sym ==...
ruby
def property name, prop return '' if EXCLUDE_PROPERTIES.include?(name.to_s) || prop.nil? || (prop.kind_of?(Array) && prop.empty?) prop = prop.flatten.map{|p| "'#{p}'"}.join(', ') if prop.respond_to?(:flatten) && name.to_sym != :folders prop = @paths.map{|f| "'#{f}'"}.join(',') if name.to_sym ==...
[ "def", "property", "name", ",", "prop", "return", "''", "if", "EXCLUDE_PROPERTIES", ".", "include?", "(", "name", ".", "to_s", ")", "||", "prop", ".", "nil?", "||", "(", "prop", ".", "kind_of?", "(", "Array", ")", "&&", "prop", ".", "empty?", ")", "p...
Create DSL property of block @param [String] name of the property @param [Syntaxer::Runner, Array] properties @return [String] DSL property string
[ "Create", "DSL", "property", "of", "block" ]
7557318e9ab1554b38cb8df9d00f2ff4acc701cb
https://github.com/artemk/syntaxer/blob/7557318e9ab1554b38cb8df9d00f2ff4acc701cb/lib/syntaxer/writer.rb#L75-L85
3,946
rightscale/scheduled_job
lib/scheduled_job.rb
ScheduledJob.ScheduledJobClassMethods.schedule_job
def schedule_job(job = nil) if can_schedule_job?(job) callback = ScheduledJob.config.fast_mode in_fast_mode = callback ? callback.call(self) : false run_at = in_fast_mode ? Time.now.utc + 1 : time_to_recur(Time.now.utc) Delayed::Job.enqueue(new, :run_at => run_at, :queue => queue...
ruby
def schedule_job(job = nil) if can_schedule_job?(job) callback = ScheduledJob.config.fast_mode in_fast_mode = callback ? callback.call(self) : false run_at = in_fast_mode ? Time.now.utc + 1 : time_to_recur(Time.now.utc) Delayed::Job.enqueue(new, :run_at => run_at, :queue => queue...
[ "def", "schedule_job", "(", "job", "=", "nil", ")", "if", "can_schedule_job?", "(", "job", ")", "callback", "=", "ScheduledJob", ".", "config", ".", "fast_mode", "in_fast_mode", "=", "callback", "?", "callback", ".", "call", "(", "self", ")", ":", "false",...
This method should be called when scheduling a recurring job as it checks to ensure no other instances of the job are already running.
[ "This", "method", "should", "be", "called", "when", "scheduling", "a", "recurring", "job", "as", "it", "checks", "to", "ensure", "no", "other", "instances", "of", "the", "job", "are", "already", "running", "." ]
9e41d330eb636c03a8239d76e19e336492db7e87
https://github.com/rightscale/scheduled_job/blob/9e41d330eb636c03a8239d76e19e336492db7e87/lib/scheduled_job.rb#L83-L92
3,947
ibaralf/site_prism_plus
lib/site_prism_plus/page.rb
SitePrismPlus.Page.load_and_verify
def load_and_verify(verify_element, url_hash = nil) result = true @metrics.start_time if url_hash.nil? load else load(url_hash) end if verify_element result = wait_till_element_visible(verify_element, 3) end @metrics.log_metric(@page_name, 'load', ...
ruby
def load_and_verify(verify_element, url_hash = nil) result = true @metrics.start_time if url_hash.nil? load else load(url_hash) end if verify_element result = wait_till_element_visible(verify_element, 3) end @metrics.log_metric(@page_name, 'load', ...
[ "def", "load_and_verify", "(", "verify_element", ",", "url_hash", "=", "nil", ")", "result", "=", "true", "@metrics", ".", "start_time", "if", "url_hash", ".", "nil?", "load", "else", "load", "(", "url_hash", ")", "end", "if", "verify_element", "result", "="...
Page loads typically takes longer.
[ "Page", "loads", "typically", "takes", "longer", "." ]
cfa56006122ed7ed62889cbcda97e8c406e06f01
https://github.com/ibaralf/site_prism_plus/blob/cfa56006122ed7ed62889cbcda97e8c406e06f01/lib/site_prism_plus/page.rb#L24-L37
3,948
alexrothenberg/motion-addressbook
motion/address_book/ios/person.rb
AddressBook.Person.load_ab_person
def load_ab_person @attributes ||= {} Person.single_value_property_map.each do |ab_property, attr_key| if attributes[attr_key] set_field(ab_property, attributes[attr_key]) else remove_field(ab_property) end end if attributes[:is_org] set_fiel...
ruby
def load_ab_person @attributes ||= {} Person.single_value_property_map.each do |ab_property, attr_key| if attributes[attr_key] set_field(ab_property, attributes[attr_key]) else remove_field(ab_property) end end if attributes[:is_org] set_fiel...
[ "def", "load_ab_person", "@attributes", "||=", "{", "}", "Person", ".", "single_value_property_map", ".", "each", "do", "|", "ab_property", ",", "attr_key", "|", "if", "attributes", "[", "attr_key", "]", "set_field", "(", "ab_property", ",", "attributes", "[", ...
instantiates ABPerson record from attributes
[ "instantiates", "ABPerson", "record", "from", "attributes" ]
6f1cfb486d27397da48dc202d79e61f4b0c295af
https://github.com/alexrothenberg/motion-addressbook/blob/6f1cfb486d27397da48dc202d79e61f4b0c295af/motion/address_book/ios/person.rb#L373-L399
3,949
jmettraux/rufus-rtm
lib/rufus/rtm/resources.rb
Rufus::RTM.Task.tags=
def tags= (tags) tags = tags.split(',') if tags.is_a?(String) @tags = TagArray.new(list_id, tags) queue_operation('setTasks', tags.join(',')) end
ruby
def tags= (tags) tags = tags.split(',') if tags.is_a?(String) @tags = TagArray.new(list_id, tags) queue_operation('setTasks', tags.join(',')) end
[ "def", "tags", "=", "(", "tags", ")", "tags", "=", "tags", ".", "split", "(", "','", ")", "if", "tags", ".", "is_a?", "(", "String", ")", "@tags", "=", "TagArray", ".", "new", "(", "list_id", ",", "tags", ")", "queue_operation", "(", "'setTasks'", ...
Sets the tags for the task.
[ "Sets", "the", "tags", "for", "the", "task", "." ]
b5e36129f92325749d131391558e93e109ed0e61
https://github.com/jmettraux/rufus-rtm/blob/b5e36129f92325749d131391558e93e109ed0e61/lib/rufus/rtm/resources.rb#L179-L186
3,950
rhenium/plum
lib/plum/client/response.rb
Plum.Response.on_chunk
def on_chunk(&block) raise "Body already read" if @on_chunk raise ArgumentError, "block must be given" unless block_given? @on_chunk = block unless @body.empty? @body.each(&block) @body.clear end self end
ruby
def on_chunk(&block) raise "Body already read" if @on_chunk raise ArgumentError, "block must be given" unless block_given? @on_chunk = block unless @body.empty? @body.each(&block) @body.clear end self end
[ "def", "on_chunk", "(", "&", "block", ")", "raise", "\"Body already read\"", "if", "@on_chunk", "raise", "ArgumentError", ",", "\"block must be given\"", "unless", "block_given?", "@on_chunk", "=", "block", "unless", "@body", ".", "empty?", "@body", ".", "each", "...
Set callback that will be called when received a chunk of response body. @yield [chunk] A chunk of the response body.
[ "Set", "callback", "that", "will", "be", "called", "when", "received", "a", "chunk", "of", "response", "body", "." ]
9190801a092d46c7079ccee201b212b2d7985952
https://github.com/rhenium/plum/blob/9190801a092d46c7079ccee201b212b2d7985952/lib/plum/client/response.rb#L57-L66
3,951
dmacvicar/bicho
lib/bicho/client.rb
Bicho.Client.create_bug
def create_bug(product, component, summary, version, **kwargs) params = {} params = params.merge(kwargs) params[:product] = product params[:component] = component params[:summary] = summary params[:version] = version ret = @client.call('Bug.create', params) handle_faults(...
ruby
def create_bug(product, component, summary, version, **kwargs) params = {} params = params.merge(kwargs) params[:product] = product params[:component] = component params[:summary] = summary params[:version] = version ret = @client.call('Bug.create', params) handle_faults(...
[ "def", "create_bug", "(", "product", ",", "component", ",", "summary", ",", "version", ",", "**", "kwargs", ")", "params", "=", "{", "}", "params", "=", "params", ".", "merge", "(", "kwargs", ")", "params", "[", ":product", "]", "=", "product", "params...
Create a bug @param product - the name of the product the bug is being filed against @param component - the name of a component in the product above. @param summary - a brief description of the bug being filed. @param version - version of the product above; the version the bug was found in. @param **kwargs - keyw...
[ "Create", "a", "bug" ]
fff403fcc5b1e1b6c81defd7c6434e9499aa1a63
https://github.com/dmacvicar/bicho/blob/fff403fcc5b1e1b6c81defd7c6434e9499aa1a63/lib/bicho/client.rb#L198-L208
3,952
dmacvicar/bicho
lib/bicho/client.rb
Bicho.Client.search_bugs
def search_bugs(query) # allow plain strings to be passed, interpretting them query = Query.new.summary(query) if query.is_a?(String) ret = @client.call('Bug.search', query.query_map) handle_faults(ret) bugs = [] ret['bugs'].each do |bug_data| bugs << Bug.new(self, bug_data)...
ruby
def search_bugs(query) # allow plain strings to be passed, interpretting them query = Query.new.summary(query) if query.is_a?(String) ret = @client.call('Bug.search', query.query_map) handle_faults(ret) bugs = [] ret['bugs'].each do |bug_data| bugs << Bug.new(self, bug_data)...
[ "def", "search_bugs", "(", "query", ")", "# allow plain strings to be passed, interpretting them", "query", "=", "Query", ".", "new", ".", "summary", "(", "query", ")", "if", "query", ".", "is_a?", "(", "String", ")", "ret", "=", "@client", ".", "call", "(", ...
Search for a bug +query+ has to be either a +Query+ object or a +String+ that will be searched in the summary of the bugs.
[ "Search", "for", "a", "bug" ]
fff403fcc5b1e1b6c81defd7c6434e9499aa1a63
https://github.com/dmacvicar/bicho/blob/fff403fcc5b1e1b6c81defd7c6434e9499aa1a63/lib/bicho/client.rb#L216-L227
3,953
dmacvicar/bicho
lib/bicho/client.rb
Bicho.Client.expand_named_query
def expand_named_query(what) url = @api_url.clone url.path = '/buglist.cgi' url.query = "cmdtype=runnamed&namedcmd=#{URI.escape(what)}&ctype=atom" logger.info("Expanding named query: '#{what}' to #{url.request_uri}") fetch_named_query_url(url, 5) end
ruby
def expand_named_query(what) url = @api_url.clone url.path = '/buglist.cgi' url.query = "cmdtype=runnamed&namedcmd=#{URI.escape(what)}&ctype=atom" logger.info("Expanding named query: '#{what}' to #{url.request_uri}") fetch_named_query_url(url, 5) end
[ "def", "expand_named_query", "(", "what", ")", "url", "=", "@api_url", ".", "clone", "url", ".", "path", "=", "'/buglist.cgi'", "url", ".", "query", "=", "\"cmdtype=runnamed&namedcmd=#{URI.escape(what)}&ctype=atom\"", "logger", ".", "info", "(", "\"Expanding named que...
Given a named query's name, runs it on the server @returns [Array<String>] list of bugs
[ "Given", "a", "named", "query", "s", "name", "runs", "it", "on", "the", "server" ]
fff403fcc5b1e1b6c81defd7c6434e9499aa1a63
https://github.com/dmacvicar/bicho/blob/fff403fcc5b1e1b6c81defd7c6434e9499aa1a63/lib/bicho/client.rb#L232-L238
3,954
dmacvicar/bicho
lib/bicho/client.rb
Bicho.Client.fetch_named_query_url
def fetch_named_query_url(url, redirects_left) raise 'You need to be authenticated to use named queries' unless @userid http = Net::HTTP.new(@api_url.host, @api_url.port) http.set_debug_output(Bicho::LoggerIODevice.new) http.verify_mode = OpenSSL::SSL::VERIFY_NONE http.use_ssl = (@api_url....
ruby
def fetch_named_query_url(url, redirects_left) raise 'You need to be authenticated to use named queries' unless @userid http = Net::HTTP.new(@api_url.host, @api_url.port) http.set_debug_output(Bicho::LoggerIODevice.new) http.verify_mode = OpenSSL::SSL::VERIFY_NONE http.use_ssl = (@api_url....
[ "def", "fetch_named_query_url", "(", "url", ",", "redirects_left", ")", "raise", "'You need to be authenticated to use named queries'", "unless", "@userid", "http", "=", "Net", "::", "HTTP", ".", "new", "(", "@api_url", ".", "host", ",", "@api_url", ".", "port", "...
Fetches a named query by its full url @private @returns [Array<String>] list of bugs
[ "Fetches", "a", "named", "query", "by", "its", "full", "url" ]
fff403fcc5b1e1b6c81defd7c6434e9499aa1a63
https://github.com/dmacvicar/bicho/blob/fff403fcc5b1e1b6c81defd7c6434e9499aa1a63/lib/bicho/client.rb#L258-L292
3,955
dmacvicar/bicho
lib/bicho/client.rb
Bicho.Client.get_bugs
def get_bugs(*ids) params = {} params[:ids] = normalize_ids ids bugs = [] ret = @client.call('Bug.get', params) handle_faults(ret) ret['bugs'].each do |bug_data| bugs << Bug.new(self, bug_data) end bugs end
ruby
def get_bugs(*ids) params = {} params[:ids] = normalize_ids ids bugs = [] ret = @client.call('Bug.get', params) handle_faults(ret) ret['bugs'].each do |bug_data| bugs << Bug.new(self, bug_data) end bugs end
[ "def", "get_bugs", "(", "*", "ids", ")", "params", "=", "{", "}", "params", "[", ":ids", "]", "=", "normalize_ids", "ids", "bugs", "=", "[", "]", "ret", "=", "@client", ".", "call", "(", "'Bug.get'", ",", "params", ")", "handle_faults", "(", "ret", ...
Retrieves one or more bugs by id @return [Array<Bug>] a list of bugs
[ "Retrieves", "one", "or", "more", "bugs", "by", "id" ]
fff403fcc5b1e1b6c81defd7c6434e9499aa1a63
https://github.com/dmacvicar/bicho/blob/fff403fcc5b1e1b6c81defd7c6434e9499aa1a63/lib/bicho/client.rb#L302-L313
3,956
dmacvicar/bicho
lib/bicho/client.rb
Bicho.Client.add_attachment
def add_attachment(summary, file, *ids, **kwargs) params = {} params[:ids] = ids params[:summary] = summary params[:content_type] = kwargs.fetch(:content_type, 'application/octet-stream') params[:file_name] = kwargs.fetch(:file_name, File.basename(file)) params[:is_patch] = kwargs[:p...
ruby
def add_attachment(summary, file, *ids, **kwargs) params = {} params[:ids] = ids params[:summary] = summary params[:content_type] = kwargs.fetch(:content_type, 'application/octet-stream') params[:file_name] = kwargs.fetch(:file_name, File.basename(file)) params[:is_patch] = kwargs[:p...
[ "def", "add_attachment", "(", "summary", ",", "file", ",", "*", "ids", ",", "**", "kwargs", ")", "params", "=", "{", "}", "params", "[", ":ids", "]", "=", "ids", "params", "[", ":summary", "]", "=", "summary", "params", "[", ":content_type", "]", "="...
Add an attachment to bugs with given ids Params: @param summary - a short string describing the attachment @param file - [File] object to attach @param *ids - a list of bug ids to which the attachment will be added @param **kwargs - optional keyword-args that may contain: - content_type - content type of the at...
[ "Add", "an", "attachment", "to", "bugs", "with", "given", "ids" ]
fff403fcc5b1e1b6c81defd7c6434e9499aa1a63
https://github.com/dmacvicar/bicho/blob/fff403fcc5b1e1b6c81defd7c6434e9499aa1a63/lib/bicho/client.rb#L363-L376
3,957
GomaaK/sshez
lib/sshez/exec.rb
Sshez.Exec.connect
def connect(alias_name, options) file = File.open(FILE_PATH, 'r') servers = all_hosts_in(file) if servers.include?alias_name PRINTER.verbose_print "Connecting to #{alias_name}" exec "ssh #{alias_name}" else PRINTER.print "Could not find host `#{alias_name}`" end ...
ruby
def connect(alias_name, options) file = File.open(FILE_PATH, 'r') servers = all_hosts_in(file) if servers.include?alias_name PRINTER.verbose_print "Connecting to #{alias_name}" exec "ssh #{alias_name}" else PRINTER.print "Could not find host `#{alias_name}`" end ...
[ "def", "connect", "(", "alias_name", ",", "options", ")", "file", "=", "File", ".", "open", "(", "FILE_PATH", ",", "'r'", ")", "servers", "=", "all_hosts_in", "(", "file", ")", "if", "servers", ".", "include?", "alias_name", "PRINTER", ".", "verbose_print"...
connects to host using alias
[ "connects", "to", "host", "using", "alias" ]
6771012c2b29c2f28fdaf42372f93f70dbcbb291
https://github.com/GomaaK/sshez/blob/6771012c2b29c2f28fdaf42372f93f70dbcbb291/lib/sshez/exec.rb#L42-L51
3,958
GomaaK/sshez
lib/sshez/exec.rb
Sshez.Exec.add
def add(alias_name, user, host, options) begin PRINTER.verbose_print "Adding\n" config_append = form(alias_name, user, host, options) PRINTER.verbose_print config_append unless options.test file = File.open(FILE_PATH, 'a+') file.write(config_append) fi...
ruby
def add(alias_name, user, host, options) begin PRINTER.verbose_print "Adding\n" config_append = form(alias_name, user, host, options) PRINTER.verbose_print config_append unless options.test file = File.open(FILE_PATH, 'a+') file.write(config_append) fi...
[ "def", "add", "(", "alias_name", ",", "user", ",", "host", ",", "options", ")", "begin", "PRINTER", ".", "verbose_print", "\"Adding\\n\"", "config_append", "=", "form", "(", "alias_name", ",", "user", ",", "host", ",", "options", ")", "PRINTER", ".", "verb...
append an alias for the given user@host with the options passed
[ "append", "an", "alias", "for", "the", "given", "user" ]
6771012c2b29c2f28fdaf42372f93f70dbcbb291
https://github.com/GomaaK/sshez/blob/6771012c2b29c2f28fdaf42372f93f70dbcbb291/lib/sshez/exec.rb#L56-L78
3,959
GomaaK/sshez
lib/sshez/exec.rb
Sshez.Exec.all_hosts_in
def all_hosts_in(file) servers = [] file.each do |line| if line.include?('Host ') servers << line.sub('Host ', '').strip end end servers end
ruby
def all_hosts_in(file) servers = [] file.each do |line| if line.include?('Host ') servers << line.sub('Host ', '').strip end end servers end
[ "def", "all_hosts_in", "(", "file", ")", "servers", "=", "[", "]", "file", ".", "each", "do", "|", "line", "|", "if", "line", ".", "include?", "(", "'Host '", ")", "servers", "<<", "line", ".", "sub", "(", "'Host '", ",", "''", ")", ".", "strip", ...
Returns all the alias names of in the file
[ "Returns", "all", "the", "alias", "names", "of", "in", "the", "file" ]
6771012c2b29c2f28fdaf42372f93f70dbcbb291
https://github.com/GomaaK/sshez/blob/6771012c2b29c2f28fdaf42372f93f70dbcbb291/lib/sshez/exec.rb#L170-L178
3,960
propublica/thinner
lib/thinner/command_line.rb
Thinner.CommandLine.options!
def options! @options = {} @option_parser = OptionParser.new(BANNER) do |opts| opts.on("-b", "--batch_length BATCH", "Number of urls to purge at once") do |b| @options[:batch_length] = b.to_i end opts.on("-t", "--sleep_time SLEEP", "Time to wait in between batches") do |t| ...
ruby
def options! @options = {} @option_parser = OptionParser.new(BANNER) do |opts| opts.on("-b", "--batch_length BATCH", "Number of urls to purge at once") do |b| @options[:batch_length] = b.to_i end opts.on("-t", "--sleep_time SLEEP", "Time to wait in between batches") do |t| ...
[ "def", "options!", "@options", "=", "{", "}", "@option_parser", "=", "OptionParser", ".", "new", "(", "BANNER", ")", "do", "|", "opts", "|", "opts", ".", "on", "(", "\"-b\"", ",", "\"--batch_length BATCH\"", ",", "\"Number of urls to purge at once\"", ")", "do...
Parse the command line options using OptionParser.
[ "Parse", "the", "command", "line", "options", "using", "OptionParser", "." ]
6fd2a676c379aed8b59e2677fa7650975a83037f
https://github.com/propublica/thinner/blob/6fd2a676c379aed8b59e2677fa7650975a83037f/lib/thinner/command_line.rb#L40-L76
3,961
kristianmandrup/cancan-permits
lib/cancan-permits/permit/base.rb
Permit.Base.licenses
def licenses *names names.to_strings.each do |name| begin module_name = "#{name.camelize}License" clazz = module_name.constantize rescue raise "License #{module_name} is not defined" end begin clazz.new(self).enforce! rescue...
ruby
def licenses *names names.to_strings.each do |name| begin module_name = "#{name.camelize}License" clazz = module_name.constantize rescue raise "License #{module_name} is not defined" end begin clazz.new(self).enforce! rescue...
[ "def", "licenses", "*", "names", "names", ".", "to_strings", ".", "each", "do", "|", "name", "|", "begin", "module_name", "=", "\"#{name.camelize}License\"", "clazz", "=", "module_name", ".", "constantize", "rescue", "raise", "\"License #{module_name} is not defined\"...
where and how is this used???
[ "where", "and", "how", "is", "this", "used???" ]
cbc56d299751118b5b6629af0f77917b3d762d61
https://github.com/kristianmandrup/cancan-permits/blob/cbc56d299751118b5b6629af0f77917b3d762d61/lib/cancan-permits/permit/base.rb#L46-L61
3,962
kristianmandrup/cancan-permits
lib/cancan-permits/permit/base.rb
Permit.Base.executor
def executor(user_account, options = {}) @executor ||= case self.class.name when /System/ then Permit::Executor::System.new self, user_account, options else Permit::Executor::Base.new self, user_account, options end end
ruby
def executor(user_account, options = {}) @executor ||= case self.class.name when /System/ then Permit::Executor::System.new self, user_account, options else Permit::Executor::Base.new self, user_account, options end end
[ "def", "executor", "(", "user_account", ",", "options", "=", "{", "}", ")", "@executor", "||=", "case", "self", ".", "class", ".", "name", "when", "/", "/", "then", "Permit", "::", "Executor", "::", "System", ".", "new", "self", ",", "user_account", ",...
return the executor used to execute the permit
[ "return", "the", "executor", "used", "to", "execute", "the", "permit" ]
cbc56d299751118b5b6629af0f77917b3d762d61
https://github.com/kristianmandrup/cancan-permits/blob/cbc56d299751118b5b6629af0f77917b3d762d61/lib/cancan-permits/permit/base.rb#L95-L102
3,963
awead/solr_ead
lib/solr_ead/indexer.rb
SolrEad.Indexer.update
def update file solr_doc = om_document(File.new(file)).to_solr delete solr_doc["id"] solr.add solr_doc add_components(file) unless options[:simple] solr.commit end
ruby
def update file solr_doc = om_document(File.new(file)).to_solr delete solr_doc["id"] solr.add solr_doc add_components(file) unless options[:simple] solr.commit end
[ "def", "update", "file", "solr_doc", "=", "om_document", "(", "File", ".", "new", "(", "file", ")", ")", ".", "to_solr", "delete", "solr_doc", "[", "\"id\"", "]", "solr", ".", "add", "solr_doc", "add_components", "(", "file", ")", "unless", "options", "[...
Updates your ead from a given file by first deleting the existing ead document and any component documents, then creating a new index from the supplied file. This method will also commit the results to your solr server when complete.
[ "Updates", "your", "ead", "from", "a", "given", "file", "by", "first", "deleting", "the", "existing", "ead", "document", "and", "any", "component", "documents", "then", "creating", "a", "new", "index", "from", "the", "supplied", "file", ".", "This", "method"...
54a5f5217152882946be6d4ee6deda0e1c80263c
https://github.com/awead/solr_ead/blob/54a5f5217152882946be6d4ee6deda0e1c80263c/lib/solr_ead/indexer.rb#L57-L63
3,964
awead/solr_ead
lib/solr_ead/indexer.rb
SolrEad.Indexer.om_document
def om_document file options[:document] ? options[:document].from_xml(File.new(file)) : SolrEad::Document.from_xml(File.new(file)) end
ruby
def om_document file options[:document] ? options[:document].from_xml(File.new(file)) : SolrEad::Document.from_xml(File.new(file)) end
[ "def", "om_document", "file", "options", "[", ":document", "]", "?", "options", "[", ":document", "]", ".", "from_xml", "(", "File", ".", "new", "(", "file", ")", ")", ":", "SolrEad", "::", "Document", ".", "from_xml", "(", "File", ".", "new", "(", "...
Returns an OM document from a given file. Determines if you have specified a custom definition for your ead document. If you've defined a class CustomDocument, and have passed it as an option to your indexer, then SolrEad will use that class instead of SolrEad::Document.
[ "Returns", "an", "OM", "document", "from", "a", "given", "file", "." ]
54a5f5217152882946be6d4ee6deda0e1c80263c
https://github.com/awead/solr_ead/blob/54a5f5217152882946be6d4ee6deda0e1c80263c/lib/solr_ead/indexer.rb#L79-L81
3,965
awead/solr_ead
lib/solr_ead/indexer.rb
SolrEad.Indexer.om_component_from_node
def om_component_from_node node options[:component] ? options[:component].from_xml(prep(node)) : SolrEad::Component.from_xml(prep(node)) end
ruby
def om_component_from_node node options[:component] ? options[:component].from_xml(prep(node)) : SolrEad::Component.from_xml(prep(node)) end
[ "def", "om_component_from_node", "node", "options", "[", ":component", "]", "?", "options", "[", ":component", "]", ".", "from_xml", "(", "prep", "(", "node", ")", ")", ":", "SolrEad", "::", "Component", ".", "from_xml", "(", "prep", "(", "node", ")", ")...
Returns an OM document from a given Nokogiri node Determines if you have specified a custom definition for your ead component. If you've defined a class CustomComponent, and have passed it as an option to your indexer, then SolrEad will use that class instead of SolrEad::Component.
[ "Returns", "an", "OM", "document", "from", "a", "given", "Nokogiri", "node" ]
54a5f5217152882946be6d4ee6deda0e1c80263c
https://github.com/awead/solr_ead/blob/54a5f5217152882946be6d4ee6deda0e1c80263c/lib/solr_ead/indexer.rb#L88-L90
3,966
awead/solr_ead
lib/solr_ead/indexer.rb
SolrEad.Indexer.solr_url
def solr_url if defined?(Rails.root) ::YAML.load(ERB.new(File.read(File.join(Rails.root,"config","solr.yml"))).result)[Rails.env]['url'] elsif ENV['RAILS_ENV'] ::YAML.load(ERB.new(File.read("config/solr.yml")).result)[ENV['RAILS_ENV']]['url'] else ::YAML.load(ERB.new(File.read("config/solr...
ruby
def solr_url if defined?(Rails.root) ::YAML.load(ERB.new(File.read(File.join(Rails.root,"config","solr.yml"))).result)[Rails.env]['url'] elsif ENV['RAILS_ENV'] ::YAML.load(ERB.new(File.read("config/solr.yml")).result)[ENV['RAILS_ENV']]['url'] else ::YAML.load(ERB.new(File.read("config/solr...
[ "def", "solr_url", "if", "defined?", "(", "Rails", ".", "root", ")", "::", "YAML", ".", "load", "(", "ERB", ".", "new", "(", "File", ".", "read", "(", "File", ".", "join", "(", "Rails", ".", "root", ",", "\"config\"", ",", "\"solr.yml\"", ")", ")",...
Determines the url to our solr service by consulting yaml files
[ "Determines", "the", "url", "to", "our", "solr", "service", "by", "consulting", "yaml", "files" ]
54a5f5217152882946be6d4ee6deda0e1c80263c
https://github.com/awead/solr_ead/blob/54a5f5217152882946be6d4ee6deda0e1c80263c/lib/solr_ead/indexer.rb#L124-L132
3,967
propublica/thinner
lib/thinner/client.rb
Thinner.Client.purge_urls
def purge_urls @current_job.each do |url| begin @varnish.start if @varnish.stopped? while(!@varnish.running?) do sleep 0.1 end if @varnish.purge :url, url @logger.info "Purged url: #{url}" @purged_urls << url else @logger.warn "Co...
ruby
def purge_urls @current_job.each do |url| begin @varnish.start if @varnish.stopped? while(!@varnish.running?) do sleep 0.1 end if @varnish.purge :url, url @logger.info "Purged url: #{url}" @purged_urls << url else @logger.warn "Co...
[ "def", "purge_urls", "@current_job", ".", "each", "do", "|", "url", "|", "begin", "@varnish", ".", "start", "if", "@varnish", ".", "stopped?", "while", "(", "!", "@varnish", ".", "running?", ")", "do", "sleep", "0.1", "end", "if", "@varnish", ".", "purge...
Once a batch is ready the Client fires off purge requests on the list of urls.
[ "Once", "a", "batch", "is", "ready", "the", "Client", "fires", "off", "purge", "requests", "on", "the", "list", "of", "urls", "." ]
6fd2a676c379aed8b59e2677fa7650975a83037f
https://github.com/propublica/thinner/blob/6fd2a676c379aed8b59e2677fa7650975a83037f/lib/thinner/client.rb#L46-L62
3,968
propublica/thinner
lib/thinner/client.rb
Thinner.Client.handle_errors
def handle_errors trap('HUP') { } trap('TERM') { close_log; Process.exit! } trap('KILL') { close_log; Process.exit! } trap('INT') { close_log; Process.exit! } end
ruby
def handle_errors trap('HUP') { } trap('TERM') { close_log; Process.exit! } trap('KILL') { close_log; Process.exit! } trap('INT') { close_log; Process.exit! } end
[ "def", "handle_errors", "trap", "(", "'HUP'", ")", "{", "}", "trap", "(", "'TERM'", ")", "{", "close_log", ";", "Process", ".", "exit!", "}", "trap", "(", "'KILL'", ")", "{", "close_log", ";", "Process", ".", "exit!", "}", "trap", "(", "'INT'", ")", ...
Trap certain signals so the Client can report back the progress of the job and close the log.
[ "Trap", "certain", "signals", "so", "the", "Client", "can", "report", "back", "the", "progress", "of", "the", "job", "and", "close", "the", "log", "." ]
6fd2a676c379aed8b59e2677fa7650975a83037f
https://github.com/propublica/thinner/blob/6fd2a676c379aed8b59e2677fa7650975a83037f/lib/thinner/client.rb#L66-L71
3,969
propublica/thinner
lib/thinner/client.rb
Thinner.Client.logger
def logger if !@log_file.respond_to?(:write) STDOUT.reopen(File.open(@log_file, (File::WRONLY | File::APPEND | File::CREAT))) end @logger = Logger.new(STDOUT) end
ruby
def logger if !@log_file.respond_to?(:write) STDOUT.reopen(File.open(@log_file, (File::WRONLY | File::APPEND | File::CREAT))) end @logger = Logger.new(STDOUT) end
[ "def", "logger", "if", "!", "@log_file", ".", "respond_to?", "(", ":write", ")", "STDOUT", ".", "reopen", "(", "File", ".", "open", "(", "@log_file", ",", "(", "File", "::", "WRONLY", "|", "File", "::", "APPEND", "|", "File", "::", "CREAT", ")", ")",...
The logger redirects all STDOUT writes to a logger instance.
[ "The", "logger", "redirects", "all", "STDOUT", "writes", "to", "a", "logger", "instance", "." ]
6fd2a676c379aed8b59e2677fa7650975a83037f
https://github.com/propublica/thinner/blob/6fd2a676c379aed8b59e2677fa7650975a83037f/lib/thinner/client.rb#L74-L79
3,970
kevintyll/resque_manager
app/helpers/resque_manager/resque_helper.rb
ResqueManager.ResqueHelper.time_filter
def time_filter(id, name, value) html = "<select id=\"#{id}\" name=\"#{name}\">" html += "<option value=\"\">-</option>" [1, 3, 6, 12, 24].each do |h| selected = h.to_s == value ? 'selected="selected"' : '' html += "<option #{selected} value=\"#{h}\">#{h} #{h==1 ? "hour" : "hours"} ago...
ruby
def time_filter(id, name, value) html = "<select id=\"#{id}\" name=\"#{name}\">" html += "<option value=\"\">-</option>" [1, 3, 6, 12, 24].each do |h| selected = h.to_s == value ? 'selected="selected"' : '' html += "<option #{selected} value=\"#{h}\">#{h} #{h==1 ? "hour" : "hours"} ago...
[ "def", "time_filter", "(", "id", ",", "name", ",", "value", ")", "html", "=", "\"<select id=\\\"#{id}\\\" name=\\\"#{name}\\\">\"", "html", "+=", "\"<option value=\\\"\\\">-</option>\"", "[", "1", ",", "3", ",", "6", ",", "12", ",", "24", "]", ".", "each", "do...
resque-cleaner helpers
[ "resque", "-", "cleaner", "helpers" ]
470e1a79232dcdd9820ee45e5371fe57309883b1
https://github.com/kevintyll/resque_manager/blob/470e1a79232dcdd9820ee45e5371fe57309883b1/app/helpers/resque_manager/resque_helper.rb#L105-L118
3,971
rhenium/plum
lib/plum/stream.rb
Plum.Stream.receive_frame
def receive_frame(frame) validate_received_frame(frame) consume_recv_window(frame) case frame when Frame::Data then receive_data(frame) when Frame::Headers then receive_headers(frame) when Frame::Priority then receive_priority(frame) when Frame::RstStream then...
ruby
def receive_frame(frame) validate_received_frame(frame) consume_recv_window(frame) case frame when Frame::Data then receive_data(frame) when Frame::Headers then receive_headers(frame) when Frame::Priority then receive_priority(frame) when Frame::RstStream then...
[ "def", "receive_frame", "(", "frame", ")", "validate_received_frame", "(", "frame", ")", "consume_recv_window", "(", "frame", ")", "case", "frame", "when", "Frame", "::", "Data", "then", "receive_data", "(", "frame", ")", "when", "Frame", "::", "Headers", "the...
Processes received frames for this stream. Internal use. @private
[ "Processes", "received", "frames", "for", "this", "stream", ".", "Internal", "use", "." ]
9190801a092d46c7079ccee201b212b2d7985952
https://github.com/rhenium/plum/blob/9190801a092d46c7079ccee201b212b2d7985952/lib/plum/stream.rb#L30-L51
3,972
rhenium/plum
lib/plum/stream.rb
Plum.Stream.promise
def promise(headers) stream = @connection.reserve_stream(weight: self.weight + 1, parent: self) encoded = @connection.hpack_encoder.encode(headers) frame = Frame::PushPromise.new(id, stream.id, encoded, end_headers: true) send frame stream end
ruby
def promise(headers) stream = @connection.reserve_stream(weight: self.weight + 1, parent: self) encoded = @connection.hpack_encoder.encode(headers) frame = Frame::PushPromise.new(id, stream.id, encoded, end_headers: true) send frame stream end
[ "def", "promise", "(", "headers", ")", "stream", "=", "@connection", ".", "reserve_stream", "(", "weight", ":", "self", ".", "weight", "+", "1", ",", "parent", ":", "self", ")", "encoded", "=", "@connection", ".", "hpack_encoder", ".", "encode", "(", "he...
Reserves a stream to server push. Sends PUSH_PROMISE and create new stream. @param headers [Enumerable<String, String>] The *request* headers. It must contain all of them: ':authority', ':method', ':scheme' and ':path'. @return [Stream] The stream to send push response.
[ "Reserves", "a", "stream", "to", "server", "push", ".", "Sends", "PUSH_PROMISE", "and", "create", "new", "stream", "." ]
9190801a092d46c7079ccee201b212b2d7985952
https://github.com/rhenium/plum/blob/9190801a092d46c7079ccee201b212b2d7985952/lib/plum/stream.rb#L90-L96
3,973
rhenium/plum
lib/plum/stream.rb
Plum.Stream.send_data
def send_data(data = "", end_stream: true) max = @connection.remote_settings[:max_frame_size] if data.is_a?(IO) until data.eof? fragment = data.readpartial(max) send Frame::Data.new(id, fragment, end_stream: end_stream && data.eof?) end else send Frame::Data...
ruby
def send_data(data = "", end_stream: true) max = @connection.remote_settings[:max_frame_size] if data.is_a?(IO) until data.eof? fragment = data.readpartial(max) send Frame::Data.new(id, fragment, end_stream: end_stream && data.eof?) end else send Frame::Data...
[ "def", "send_data", "(", "data", "=", "\"\"", ",", "end_stream", ":", "true", ")", "max", "=", "@connection", ".", "remote_settings", "[", ":max_frame_size", "]", "if", "data", ".", "is_a?", "(", "IO", ")", "until", "data", ".", "eof?", "fragment", "=", ...
Sends DATA frame. If the data is larger than MAX_FRAME_SIZE, DATA frame will be splitted. @param data [String, IO] The data to send. @param end_stream [Boolean] Set END_STREAM flag or not.
[ "Sends", "DATA", "frame", ".", "If", "the", "data", "is", "larger", "than", "MAX_FRAME_SIZE", "DATA", "frame", "will", "be", "splitted", "." ]
9190801a092d46c7079ccee201b212b2d7985952
https://github.com/rhenium/plum/blob/9190801a092d46c7079ccee201b212b2d7985952/lib/plum/stream.rb#L111-L122
3,974
christinedraper/knife-topo
lib/chef/knife/topo_delete.rb
KnifeTopo.TopoDelete.remove_node_from_topology
def remove_node_from_topology(node_name) # load then update and save the node node = Chef::Node.load(node_name) if node['topo'] && node['topo']['name'] == @topo_name node.rm('topo', 'name') ui.info "Removing node #{node.name} from topology" node.save end node ...
ruby
def remove_node_from_topology(node_name) # load then update and save the node node = Chef::Node.load(node_name) if node['topo'] && node['topo']['name'] == @topo_name node.rm('topo', 'name') ui.info "Removing node #{node.name} from topology" node.save end node ...
[ "def", "remove_node_from_topology", "(", "node_name", ")", "# load then update and save the node", "node", "=", "Chef", "::", "Node", ".", "load", "(", "node_name", ")", "if", "node", "[", "'topo'", "]", "&&", "node", "[", "'topo'", "]", "[", "'name'", "]", ...
Remove the topo name attribute from all nodes, so topo search knows they are not in the topology
[ "Remove", "the", "topo", "name", "attribute", "from", "all", "nodes", "so", "topo", "search", "knows", "they", "are", "not", "in", "the", "topology" ]
323f5767a6ed98212629888323c4e694fec820ca
https://github.com/christinedraper/knife-topo/blob/323f5767a6ed98212629888323c4e694fec820ca/lib/chef/knife/topo_delete.rb#L82-L96
3,975
edraut/coney_island
lib/coney_island/jobs_cache.rb
ConeyIsland.JobsCache.caching_jobs
def caching_jobs(&blk) _was_caching = caching_jobs? cache_jobs blk.call flush_jobs self.is_caching_jobs = _was_caching self end
ruby
def caching_jobs(&blk) _was_caching = caching_jobs? cache_jobs blk.call flush_jobs self.is_caching_jobs = _was_caching self end
[ "def", "caching_jobs", "(", "&", "blk", ")", "_was_caching", "=", "caching_jobs?", "cache_jobs", "blk", ".", "call", "flush_jobs", "self", ".", "is_caching_jobs", "=", "_was_caching", "self", "end" ]
Caches jobs for the duration of the block, flushes them at the end.
[ "Caches", "jobs", "for", "the", "duration", "of", "the", "block", "flushes", "them", "at", "the", "end", "." ]
73994b7d0c85d37879c1def70dcc02959a2c43bf
https://github.com/edraut/coney_island/blob/73994b7d0c85d37879c1def70dcc02959a2c43bf/lib/coney_island/jobs_cache.rb#L31-L38
3,976
edraut/coney_island
lib/coney_island/jobs_cache.rb
ConeyIsland.JobsCache.flush_jobs
def flush_jobs # Get all the jobs, one at a time, pulling from the list while job = self.cached_jobs.shift # Map the array to the right things job_id, args = *job # Submit! takes care of rescuing, error logging, etc and never caches submit! args, job_id end self ...
ruby
def flush_jobs # Get all the jobs, one at a time, pulling from the list while job = self.cached_jobs.shift # Map the array to the right things job_id, args = *job # Submit! takes care of rescuing, error logging, etc and never caches submit! args, job_id end self ...
[ "def", "flush_jobs", "# Get all the jobs, one at a time, pulling from the list", "while", "job", "=", "self", ".", "cached_jobs", ".", "shift", "# Map the array to the right things", "job_id", ",", "args", "=", "job", "# Submit! takes care of rescuing, error logging, etc and never ...
Publish all the cached jobs
[ "Publish", "all", "the", "cached", "jobs" ]
73994b7d0c85d37879c1def70dcc02959a2c43bf
https://github.com/edraut/coney_island/blob/73994b7d0c85d37879c1def70dcc02959a2c43bf/lib/coney_island/jobs_cache.rb#L47-L56
3,977
NingenUA/seafile-api
lib/seafile-api/directory.rb
SeafileApi.Connect.share_dir
def share_dir(email,path,perm="r",repo=self.repo,s_type="d") post_share_dir(repo,{"email"=> email, "path"=> path,"s_type"=> s_type,"perm"=> perm}) end
ruby
def share_dir(email,path,perm="r",repo=self.repo,s_type="d") post_share_dir(repo,{"email"=> email, "path"=> path,"s_type"=> s_type,"perm"=> perm}) end
[ "def", "share_dir", "(", "email", ",", "path", ",", "perm", "=", "\"r\"", ",", "repo", "=", "self", ".", "repo", ",", "s_type", "=", "\"d\"", ")", "post_share_dir", "(", "repo", ",", "{", "\"email\"", "=>", "email", ",", "\"path\"", "=>", "path", ","...
You do not have permission to perform this action
[ "You", "do", "not", "have", "permission", "to", "perform", "this", "action" ]
b5fb16e7fca21d9241f92fbd22500e8d488b7464
https://github.com/NingenUA/seafile-api/blob/b5fb16e7fca21d9241f92fbd22500e8d488b7464/lib/seafile-api/directory.rb#L19-L21
3,978
artemk/syntaxer
lib/syntaxer/checker.rb
Syntaxer.RepoChecker.process
def process @rule_files.each do |rule_name, rule| if rule[:rule].deferred @deferred_process << rule else rule[:files].each do |file| full_path = File.join(@runner.options.root_path,file) check(rule[:rule], full_path) end end end ...
ruby
def process @rule_files.each do |rule_name, rule| if rule[:rule].deferred @deferred_process << rule else rule[:files].each do |file| full_path = File.join(@runner.options.root_path,file) check(rule[:rule], full_path) end end end ...
[ "def", "process", "@rule_files", ".", "each", "do", "|", "rule_name", ",", "rule", "|", "if", "rule", "[", ":rule", "]", ".", "deferred", "@deferred_process", "<<", "rule", "else", "rule", "[", ":files", "]", ".", "each", "do", "|", "file", "|", "full_...
Check syntax in repository directory @see Checker#process
[ "Check", "syntax", "in", "repository", "directory" ]
7557318e9ab1554b38cb8df9d00f2ff4acc701cb
https://github.com/artemk/syntaxer/blob/7557318e9ab1554b38cb8df9d00f2ff4acc701cb/lib/syntaxer/checker.rb#L84-L101
3,979
artemk/syntaxer
lib/syntaxer/checker.rb
Syntaxer.PlainChecker.process
def process @deferred_process = [] @reader.rules.each do |rule| if rule.deferred @deferred_process << rule else rule.files_list(@runner.options.root_path).each do |file| check(rule, file) end end end @deferred_process.each ...
ruby
def process @deferred_process = [] @reader.rules.each do |rule| if rule.deferred @deferred_process << rule else rule.files_list(@runner.options.root_path).each do |file| check(rule, file) end end end @deferred_process.each ...
[ "def", "process", "@deferred_process", "=", "[", "]", "@reader", ".", "rules", ".", "each", "do", "|", "rule", "|", "if", "rule", ".", "deferred", "@deferred_process", "<<", "rule", "else", "rule", ".", "files_list", "(", "@runner", ".", "options", ".", ...
Check syntax in indicated directory @see Checker#process
[ "Check", "syntax", "in", "indicated", "directory" ]
7557318e9ab1554b38cb8df9d00f2ff4acc701cb
https://github.com/artemk/syntaxer/blob/7557318e9ab1554b38cb8df9d00f2ff4acc701cb/lib/syntaxer/checker.rb#L119-L136
3,980
roverdotcom/danger-jira_sync
lib/jira_sync/plugin.rb
Danger.DangerJiraSync.configure
def configure(jira_url:, jira_username:, jira_api_token:) warn "danger-jira_sync plugin configuration is missing jira_url" if jira_url.blank? warn "danger-jira_sync plugin configuration is missing jira_username" if jira_username.blank? warn "danger-jira_sync plugin configuration is missing jira_api_to...
ruby
def configure(jira_url:, jira_username:, jira_api_token:) warn "danger-jira_sync plugin configuration is missing jira_url" if jira_url.blank? warn "danger-jira_sync plugin configuration is missing jira_username" if jira_username.blank? warn "danger-jira_sync plugin configuration is missing jira_api_to...
[ "def", "configure", "(", "jira_url", ":", ",", "jira_username", ":", ",", "jira_api_token", ":", ")", "warn", "\"danger-jira_sync plugin configuration is missing jira_url\"", "if", "jira_url", ".", "blank?", "warn", "\"danger-jira_sync plugin configuration is missing jira_usern...
Configures the Jira REST Client with your credentials @param jira_url [String] The full url to your Jira instance, e.g., "https://myjirainstance.atlassian.net" @param jira_username [String] The username to use for accessing the Jira instance. Commonly, this is an email address. @param jira_api_token [String]...
[ "Configures", "the", "Jira", "REST", "Client", "with", "your", "credentials" ]
0cb6a3c74fcde3c2b2fee7ff339f84c48b46c2fb
https://github.com/roverdotcom/danger-jira_sync/blob/0cb6a3c74fcde3c2b2fee7ff339f84c48b46c2fb/lib/jira_sync/plugin.rb#L45-L57
3,981
roverdotcom/danger-jira_sync
lib/jira_sync/plugin.rb
Danger.DangerJiraSync.autolabel_pull_request
def autolabel_pull_request(issue_prefixes, project: true, components: true, labels: false) raise NotConfiguredError unless @jira_client raise(ArgumentError, "issue_prefixes cannot be empty") if issue_prefixes.empty? issue_keys = extract_issue_keys_from_pull_request(issue_prefixes) return if iss...
ruby
def autolabel_pull_request(issue_prefixes, project: true, components: true, labels: false) raise NotConfiguredError unless @jira_client raise(ArgumentError, "issue_prefixes cannot be empty") if issue_prefixes.empty? issue_keys = extract_issue_keys_from_pull_request(issue_prefixes) return if iss...
[ "def", "autolabel_pull_request", "(", "issue_prefixes", ",", "project", ":", "true", ",", "components", ":", "true", ",", "labels", ":", "false", ")", "raise", "NotConfiguredError", "unless", "@jira_client", "raise", "(", "ArgumentError", ",", "\"issue_prefixes cann...
Labels the Pull Request with Jira Project Keys and Component Names @param issue_prefixes [Array<String>] An array of issue key prefixes; this is often the project key. These must be present in the title or body of the Pull Request @param project [Boolean] Label using the Jira Ticket's Project Key? @param comp...
[ "Labels", "the", "Pull", "Request", "with", "Jira", "Project", "Keys", "and", "Component", "Names" ]
0cb6a3c74fcde3c2b2fee7ff339f84c48b46c2fb
https://github.com/roverdotcom/danger-jira_sync/blob/0cb6a3c74fcde3c2b2fee7ff339f84c48b46c2fb/lib/jira_sync/plugin.rb#L71-L90
3,982
kevintyll/resque_manager
lib/resque_manager/overrides/resque/worker.rb
Resque.Worker.startup
def startup enable_gc_optimizations if Thread.current == Thread.main register_signal_handlers prune_dead_workers end run_hook :before_first_fork register_worker # Fix buffering so we can `rake resque:work > resque.log` and # get output from the child in there. ...
ruby
def startup enable_gc_optimizations if Thread.current == Thread.main register_signal_handlers prune_dead_workers end run_hook :before_first_fork register_worker # Fix buffering so we can `rake resque:work > resque.log` and # get output from the child in there. ...
[ "def", "startup", "enable_gc_optimizations", "if", "Thread", ".", "current", "==", "Thread", ".", "main", "register_signal_handlers", "prune_dead_workers", "end", "run_hook", ":before_first_fork", "register_worker", "# Fix buffering so we can `rake resque:work > resque.log` and", ...
Runs all the methods needed when a worker begins its lifecycle. OVERRIDE for multithreaded workers
[ "Runs", "all", "the", "methods", "needed", "when", "a", "worker", "begins", "its", "lifecycle", ".", "OVERRIDE", "for", "multithreaded", "workers" ]
470e1a79232dcdd9820ee45e5371fe57309883b1
https://github.com/kevintyll/resque_manager/blob/470e1a79232dcdd9820ee45e5371fe57309883b1/lib/resque_manager/overrides/resque/worker.rb#L63-L75
3,983
kevintyll/resque_manager
lib/resque_manager/overrides/resque/worker.rb
Resque.Worker.reconnect
def reconnect tries = 0 begin redis.synchronize do |client| client.reconnect end rescue Redis::BaseConnectionError if (tries += 1) <= 3 log "Error reconnecting to Redis; retrying" sleep(tries) retry else log "Error recon...
ruby
def reconnect tries = 0 begin redis.synchronize do |client| client.reconnect end rescue Redis::BaseConnectionError if (tries += 1) <= 3 log "Error reconnecting to Redis; retrying" sleep(tries) retry else log "Error recon...
[ "def", "reconnect", "tries", "=", "0", "begin", "redis", ".", "synchronize", "do", "|", "client", "|", "client", ".", "reconnect", "end", "rescue", "Redis", "::", "BaseConnectionError", "if", "(", "tries", "+=", "1", ")", "<=", "3", "log", "\"Error reconne...
override so we can synchronize the client on the reconnect for multithreaded workers.
[ "override", "so", "we", "can", "synchronize", "the", "client", "on", "the", "reconnect", "for", "multithreaded", "workers", "." ]
470e1a79232dcdd9820ee45e5371fe57309883b1
https://github.com/kevintyll/resque_manager/blob/470e1a79232dcdd9820ee45e5371fe57309883b1/lib/resque_manager/overrides/resque/worker.rb#L187-L203
3,984
GomaaK/sshez
lib/sshez/parser.rb
Sshez.Parser.options_for_add
def options_for_add(opts, options) opts.on('-p', '--port PORT', 'Specify a port') do |port| options.file_content.port_text = " Port #{port}\n" end opts.on('-i', '--identity_file [key]', 'Add identity') do |key_path| options.file_content.identity_file_text ...
ruby
def options_for_add(opts, options) opts.on('-p', '--port PORT', 'Specify a port') do |port| options.file_content.port_text = " Port #{port}\n" end opts.on('-i', '--identity_file [key]', 'Add identity') do |key_path| options.file_content.identity_file_text ...
[ "def", "options_for_add", "(", "opts", ",", "options", ")", "opts", ".", "on", "(", "'-p'", ",", "'--port PORT'", ",", "'Specify a port'", ")", "do", "|", "port", "|", "options", ".", "file_content", ".", "port_text", "=", "\" Port #{port}\\n\"", "end", "op...
Returns the options specifice to the add command only
[ "Returns", "the", "options", "specifice", "to", "the", "add", "command", "only" ]
6771012c2b29c2f28fdaf42372f93f70dbcbb291
https://github.com/GomaaK/sshez/blob/6771012c2b29c2f28fdaf42372f93f70dbcbb291/lib/sshez/parser.rb#L66-L81
3,985
GomaaK/sshez
lib/sshez/parser.rb
Sshez.Parser.common_options
def common_options(opts, options) opts.separator '' opts.separator 'Common options:' # Another typical switch to print the version. opts.on('-v', '--version', 'Show version') do PRINTER.print Sshez.version options.halt = true end opts.on('-z', '--verbose', 'Verbose Ou...
ruby
def common_options(opts, options) opts.separator '' opts.separator 'Common options:' # Another typical switch to print the version. opts.on('-v', '--version', 'Show version') do PRINTER.print Sshez.version options.halt = true end opts.on('-z', '--verbose', 'Verbose Ou...
[ "def", "common_options", "(", "opts", ",", "options", ")", "opts", ".", "separator", "''", "opts", ".", "separator", "'Common options:'", "# Another typical switch to print the version.", "opts", ".", "on", "(", "'-v'", ",", "'--version'", ",", "'Show version'", ")"...
Returns the standard options
[ "Returns", "the", "standard", "options" ]
6771012c2b29c2f28fdaf42372f93f70dbcbb291
https://github.com/GomaaK/sshez/blob/6771012c2b29c2f28fdaf42372f93f70dbcbb291/lib/sshez/parser.rb#L86-L102
3,986
christinedraper/knife-topo
lib/chef/knife/topo_export.rb
KnifeTopo.TopoExport.node_export
def node_export(node_name) load_node_data(node_name, config[:min_priority]) rescue Net::HTTPServerException => e raise unless e.to_s =~ /^404/ empty_node(node_name) end
ruby
def node_export(node_name) load_node_data(node_name, config[:min_priority]) rescue Net::HTTPServerException => e raise unless e.to_s =~ /^404/ empty_node(node_name) end
[ "def", "node_export", "(", "node_name", ")", "load_node_data", "(", "node_name", ",", "config", "[", ":min_priority", "]", ")", "rescue", "Net", "::", "HTTPServerException", "=>", "e", "raise", "unless", "e", ".", "to_s", "=~", "/", "/", "empty_node", "(", ...
get actual node properties for export
[ "get", "actual", "node", "properties", "for", "export" ]
323f5767a6ed98212629888323c4e694fec820ca
https://github.com/christinedraper/knife-topo/blob/323f5767a6ed98212629888323c4e694fec820ca/lib/chef/knife/topo_export.rb#L131-L136
3,987
christinedraper/knife-topo
lib/chef/knife/topo_export.rb
KnifeTopo.TopoExport.update_nodes!
def update_nodes!(nodes) @node_names.each do |node_name| # find out if the node is already in the array found = nodes.index { |n| n['name'] == node_name } if found.nil? nodes.push(node_export(node_name)) else nodes[found] = node_export(node_name) end ...
ruby
def update_nodes!(nodes) @node_names.each do |node_name| # find out if the node is already in the array found = nodes.index { |n| n['name'] == node_name } if found.nil? nodes.push(node_export(node_name)) else nodes[found] = node_export(node_name) end ...
[ "def", "update_nodes!", "(", "nodes", ")", "@node_names", ".", "each", "do", "|", "node_name", "|", "# find out if the node is already in the array", "found", "=", "nodes", ".", "index", "{", "|", "n", "|", "n", "[", "'name'", "]", "==", "node_name", "}", "i...
put node details in node array, overwriting existing details
[ "put", "node", "details", "in", "node", "array", "overwriting", "existing", "details" ]
323f5767a6ed98212629888323c4e694fec820ca
https://github.com/christinedraper/knife-topo/blob/323f5767a6ed98212629888323c4e694fec820ca/lib/chef/knife/topo_export.rb#L139-L149
3,988
dmacvicar/bicho
lib/bicho/cli/commands/attachments.rb
Bicho::CLI::Commands.Attachments.download
def download(bug, supportconfig_only) bug.attachments.each do |attachment| filename = "bsc#{bug.id}-#{attachment.id}-#{attachment.props['file_name']}" if supportconfig_only next unless attachment.content_type == 'application/x-gzip' || attachment.content_type == 'ap...
ruby
def download(bug, supportconfig_only) bug.attachments.each do |attachment| filename = "bsc#{bug.id}-#{attachment.id}-#{attachment.props['file_name']}" if supportconfig_only next unless attachment.content_type == 'application/x-gzip' || attachment.content_type == 'ap...
[ "def", "download", "(", "bug", ",", "supportconfig_only", ")", "bug", ".", "attachments", ".", "each", "do", "|", "attachment", "|", "filename", "=", "\"bsc#{bug.id}-#{attachment.id}-#{attachment.props['file_name']}\"", "if", "supportconfig_only", "next", "unless", "att...
check for supportconfigs and download
[ "check", "for", "supportconfigs", "and", "download" ]
fff403fcc5b1e1b6c81defd7c6434e9499aa1a63
https://github.com/dmacvicar/bicho/blob/fff403fcc5b1e1b6c81defd7c6434e9499aa1a63/lib/bicho/cli/commands/attachments.rb#L35-L54
3,989
mikemackintosh/ruby-qualys
lib/qualys/config.rb
Qualys.Config.load!
def load!(path) settings = YAML.safe_load(ERB.new(File.new(path).read).result)['api'] from_hash(settings) if settings.is_a? Hash end
ruby
def load!(path) settings = YAML.safe_load(ERB.new(File.new(path).read).result)['api'] from_hash(settings) if settings.is_a? Hash end
[ "def", "load!", "(", "path", ")", "settings", "=", "YAML", ".", "safe_load", "(", "ERB", ".", "new", "(", "File", ".", "new", "(", "path", ")", ".", "read", ")", ".", "result", ")", "[", "'api'", "]", "from_hash", "(", "settings", ")", "if", "set...
Load the settings from a compliant Qualys.yml file. This can be used for easy setup with frameworks other than Rails. @example Configure Qualys. Qualys.load!("/path/to/qualys.yml") @param [ String ] path The path to the file.
[ "Load", "the", "settings", "from", "a", "compliant", "Qualys", ".", "yml", "file", ".", "This", "can", "be", "used", "for", "easy", "setup", "with", "frameworks", "other", "than", "Rails", "." ]
6479d72fdd60ada7ef8245bf3161ef09c282eca8
https://github.com/mikemackintosh/ruby-qualys/blob/6479d72fdd60ada7ef8245bf3161ef09c282eca8/lib/qualys/config.rb#L28-L31
3,990
imathis/esvg
lib/esvg/svgs.rb
Esvg.Svgs.embed_script
def embed_script(names=nil) if production? embeds = buildable_svgs(names).map(&:embed) else embeds = find_svgs(names).map(&:embed) end write_cache if cache_stale? if !embeds.empty? "<script>#{js(embeds.join("\n"))}</script>" end end
ruby
def embed_script(names=nil) if production? embeds = buildable_svgs(names).map(&:embed) else embeds = find_svgs(names).map(&:embed) end write_cache if cache_stale? if !embeds.empty? "<script>#{js(embeds.join("\n"))}</script>" end end
[ "def", "embed_script", "(", "names", "=", "nil", ")", "if", "production?", "embeds", "=", "buildable_svgs", "(", "names", ")", ".", "map", "(", ":embed", ")", "else", "embeds", "=", "find_svgs", "(", "names", ")", ".", "map", "(", ":embed", ")", "end",...
Embed svg symbols
[ "Embed", "svg", "symbols" ]
0a555daaf6b6860c0a85865461c64e241bc92842
https://github.com/imathis/esvg/blob/0a555daaf6b6860c0a85865461c64e241bc92842/lib/esvg/svgs.rb#L128-L141
3,991
flippa/ralexa
lib/ralexa/url_info.rb
Ralexa.UrlInfo.get
def get(url, params = {}) result({"ResponseGroup" => "Related,TrafficData,ContentData", "Url" => url}, params) do |doc| @document = doc { speed_median_load_time: speed_median_load_time, speed_load_percentile: speed_load_percentile, link_count: ...
ruby
def get(url, params = {}) result({"ResponseGroup" => "Related,TrafficData,ContentData", "Url" => url}, params) do |doc| @document = doc { speed_median_load_time: speed_median_load_time, speed_load_percentile: speed_load_percentile, link_count: ...
[ "def", "get", "(", "url", ",", "params", "=", "{", "}", ")", "result", "(", "{", "\"ResponseGroup\"", "=>", "\"Related,TrafficData,ContentData\"", ",", "\"Url\"", "=>", "url", "}", ",", "params", ")", "do", "|", "doc", "|", "@document", "=", "doc", "{", ...
Alexa data for an individual site
[ "Alexa", "data", "for", "an", "individual", "site" ]
fd5bdff102fe52f5c2898b1f917a12a1f17f25de
https://github.com/flippa/ralexa/blob/fd5bdff102fe52f5c2898b1f917a12a1f17f25de/lib/ralexa/url_info.rb#L5-L27
3,992
magoosh/motion_record
lib/motion_record/persistence.rb
MotionRecord.Persistence.apply_persistence_timestamps
def apply_persistence_timestamps self.updated_at = Time.now if self.class.attribute_names.include?(:updated_at) self.created_at ||= Time.now if self.class.attribute_names.include?(:created_at) end
ruby
def apply_persistence_timestamps self.updated_at = Time.now if self.class.attribute_names.include?(:updated_at) self.created_at ||= Time.now if self.class.attribute_names.include?(:created_at) end
[ "def", "apply_persistence_timestamps", "self", ".", "updated_at", "=", "Time", ".", "now", "if", "self", ".", "class", ".", "attribute_names", ".", "include?", "(", ":updated_at", ")", "self", ".", "created_at", "||=", "Time", ".", "now", "if", "self", ".", ...
Update persistence auto-timestamp attributes
[ "Update", "persistence", "auto", "-", "timestamp", "attributes" ]
843958568853464a205ae8c446960affcba82387
https://github.com/magoosh/motion_record/blob/843958568853464a205ae8c446960affcba82387/lib/motion_record/persistence.rb#L59-L62
3,993
romainberger/shop
lib/shop/shopconfig.rb
Shop.ShopConfig.get
def get(namespace = false, key = false, defaultValue = '') if namespace && key value = @config[namespace][key] if value return value else return defaultValue end end return @config if !@config.empty? get_config end
ruby
def get(namespace = false, key = false, defaultValue = '') if namespace && key value = @config[namespace][key] if value return value else return defaultValue end end return @config if !@config.empty? get_config end
[ "def", "get", "(", "namespace", "=", "false", ",", "key", "=", "false", ",", "defaultValue", "=", "''", ")", "if", "namespace", "&&", "key", "value", "=", "@config", "[", "namespace", "]", "[", "key", "]", "if", "value", "return", "value", "else", "r...
Returns the whole config or a specific value namespace - the namespace where the key is searched key - the key neede defaultValue - default value to return if the value is nil
[ "Returns", "the", "whole", "config", "or", "a", "specific", "value" ]
0cbfdf098027c7d5bb049f5181c5bbb3854cb543
https://github.com/romainberger/shop/blob/0cbfdf098027c7d5bb049f5181c5bbb3854cb543/lib/shop/shopconfig.rb#L20-L33
3,994
bamnet/attachable
lib/attachable.rb
Attachable.ClassMethods.attachable
def attachable(options = {}) # Store the default prefix for file data # Defaults to "file" cattr_accessor :attachment_file_prefix self.attachment_file_prefix = (options[:file_prefix] || :file).to_s # Setup the default scope so the file data isn't included by default. # Generat...
ruby
def attachable(options = {}) # Store the default prefix for file data # Defaults to "file" cattr_accessor :attachment_file_prefix self.attachment_file_prefix = (options[:file_prefix] || :file).to_s # Setup the default scope so the file data isn't included by default. # Generat...
[ "def", "attachable", "(", "options", "=", "{", "}", ")", "# Store the default prefix for file data", "# Defaults to \"file\"", "cattr_accessor", ":attachment_file_prefix", "self", ".", "attachment_file_prefix", "=", "(", "options", "[", ":file_prefix", "]", "||", ":file",...
Loads the attachable methods, scope, and config into the model.
[ "Loads", "the", "attachable", "methods", "scope", "and", "config", "into", "the", "model", "." ]
64592900db2790cc11d279ee131c1b25fbd11b15
https://github.com/bamnet/attachable/blob/64592900db2790cc11d279ee131c1b25fbd11b15/lib/attachable.rb#L12-L25
3,995
hollingberry/texmath-ruby
lib/texmath/converter.rb
TeXMath.Converter.convert
def convert(data) Open3.popen3(command) do |stdin, stdout, stderr| stdin.puts(data) stdin.close output = stdout.read error = stderr.read raise ConversionError, error unless error.empty? return output.strip end rescue Errno::ENOENT raise NoExecutable...
ruby
def convert(data) Open3.popen3(command) do |stdin, stdout, stderr| stdin.puts(data) stdin.close output = stdout.read error = stderr.read raise ConversionError, error unless error.empty? return output.strip end rescue Errno::ENOENT raise NoExecutable...
[ "def", "convert", "(", "data", ")", "Open3", ".", "popen3", "(", "command", ")", "do", "|", "stdin", ",", "stdout", ",", "stderr", "|", "stdin", ".", "puts", "(", "data", ")", "stdin", ".", "close", "output", "=", "stdout", ".", "read", "error", "=...
Convert `data` between formats. @return [String] the converted data
[ "Convert", "data", "between", "formats", "." ]
7a4cdb6cf7200e84bca371b03836c0498a813dd4
https://github.com/hollingberry/texmath-ruby/blob/7a4cdb6cf7200e84bca371b03836c0498a813dd4/lib/texmath/converter.rb#L47-L58
3,996
hallison/sinatra-mapping
lib/sinatra/mapping.rb
Sinatra.Mapping.map
def map(name, path = nil) @locations ||= {} if name.to_sym == :root @locations[:root] = cleanup_paths("/#{path}/") self.class.class_eval do define_method "#{name}_path" do |*paths| cleanup_paths("/#{@locations[:root]}/?") end end else @locations[name.to_sym]...
ruby
def map(name, path = nil) @locations ||= {} if name.to_sym == :root @locations[:root] = cleanup_paths("/#{path}/") self.class.class_eval do define_method "#{name}_path" do |*paths| cleanup_paths("/#{@locations[:root]}/?") end end else @locations[name.to_sym]...
[ "def", "map", "(", "name", ",", "path", "=", "nil", ")", "@locations", "||=", "{", "}", "if", "name", ".", "to_sym", "==", ":root", "@locations", "[", ":root", "]", "=", "cleanup_paths", "(", "\"/#{path}/\"", ")", "self", ".", "class", ".", "class_eval...
Write URL path method for use in HTTP methods. The map method most be used by following syntax: map <name>, <path> If name is equal :root, then returns path ended by slash "/". map :root, "tasks" #=> /tasks/ map :changes, "last-changes #=> /tasks/last-changes
[ "Write", "URL", "path", "method", "for", "use", "in", "HTTP", "methods", "." ]
693ce820304f5aea8e9af879d89c96b8b3fa02ed
https://github.com/hallison/sinatra-mapping/blob/693ce820304f5aea8e9af879d89c96b8b3fa02ed/lib/sinatra/mapping.rb#L27-L45
3,997
hallison/sinatra-mapping
lib/sinatra/mapping.rb
Sinatra.Mapping.map_path_to
def map_path_to(*args) script_name = args.shift if args.first.to_s =~ %r{^/\w.*} path_mapped(script_name, *locations_get_from(*args)) end
ruby
def map_path_to(*args) script_name = args.shift if args.first.to_s =~ %r{^/\w.*} path_mapped(script_name, *locations_get_from(*args)) end
[ "def", "map_path_to", "(", "*", "args", ")", "script_name", "=", "args", ".", "shift", "if", "args", ".", "first", ".", "to_s", "=~", "%r{", "\\w", "}", "path_mapped", "(", "script_name", ",", "locations_get_from", "(", "args", ")", ")", "end" ]
Check arguments. If argument is a symbol and exist map path before setted, then return path mapped by symbol name.
[ "Check", "arguments", ".", "If", "argument", "is", "a", "symbol", "and", "exist", "map", "path", "before", "setted", "then", "return", "path", "mapped", "by", "symbol", "name", "." ]
693ce820304f5aea8e9af879d89c96b8b3fa02ed
https://github.com/hallison/sinatra-mapping/blob/693ce820304f5aea8e9af879d89c96b8b3fa02ed/lib/sinatra/mapping.rb#L94-L97
3,998
hallison/sinatra-mapping
lib/sinatra/mapping.rb
Sinatra.Mapping.path_mapped
def path_mapped(script_name, *args) return cleanup_paths("/#{script_name}/#{@locations[:root]}") if args.empty? a = replace_symbols(script_name, *args) cleanup_paths("/#{script_name}/#{@locations[:root]}/#{a.join('/')}") end
ruby
def path_mapped(script_name, *args) return cleanup_paths("/#{script_name}/#{@locations[:root]}") if args.empty? a = replace_symbols(script_name, *args) cleanup_paths("/#{script_name}/#{@locations[:root]}/#{a.join('/')}") end
[ "def", "path_mapped", "(", "script_name", ",", "*", "args", ")", "return", "cleanup_paths", "(", "\"/#{script_name}/#{@locations[:root]}\"", ")", "if", "args", ".", "empty?", "a", "=", "replace_symbols", "(", "script_name", ",", "args", ")", "cleanup_paths", "(", ...
Returns all paths mapped by root path in prefix.
[ "Returns", "all", "paths", "mapped", "by", "root", "path", "in", "prefix", "." ]
693ce820304f5aea8e9af879d89c96b8b3fa02ed
https://github.com/hallison/sinatra-mapping/blob/693ce820304f5aea8e9af879d89c96b8b3fa02ed/lib/sinatra/mapping.rb#L100-L104
3,999
hallison/sinatra-mapping
lib/sinatra/mapping.rb
Sinatra.Mapping.replace_symbols
def replace_symbols(script_name, *args) args_new = [] args_copy = args.clone url = args[0].clone modifiers = args_copy[1] if modifiers.class == Hash modifiers.delete_if do |key, value| delete = url.include? (":" + key.to_s) if delete url.sub!( (":" + key.to_s), value...
ruby
def replace_symbols(script_name, *args) args_new = [] args_copy = args.clone url = args[0].clone modifiers = args_copy[1] if modifiers.class == Hash modifiers.delete_if do |key, value| delete = url.include? (":" + key.to_s) if delete url.sub!( (":" + key.to_s), value...
[ "def", "replace_symbols", "(", "script_name", ",", "*", "args", ")", "args_new", "=", "[", "]", "args_copy", "=", "args", ".", "clone", "url", "=", "args", "[", "0", "]", ".", "clone", "modifiers", "=", "args_copy", "[", "1", "]", "if", "modifiers", ...
Replace simbols in url for
[ "Replace", "simbols", "in", "url", "for" ]
693ce820304f5aea8e9af879d89c96b8b3fa02ed
https://github.com/hallison/sinatra-mapping/blob/693ce820304f5aea8e9af879d89c96b8b3fa02ed/lib/sinatra/mapping.rb#L108-L145