repo
stringlengths
5
58
path
stringlengths
9
168
func_name
stringlengths
9
130
original_string
stringlengths
66
10.5k
language
stringclasses
1 value
code
stringlengths
66
10.5k
code_tokens
list
docstring
stringlengths
8
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
94
266
partition
stringclasses
1 value
janko/down
lib/down/utils.rb
Down.Utils.filename_from_content_disposition
def filename_from_content_disposition(content_disposition) content_disposition = content_disposition.to_s escaped_filename = content_disposition[/filename\*=UTF-8''(\S+)/, 1] || content_disposition[/filename="([^"]*)"/, 1] || content_disposition[/filename=(\S+)/, 1] filename ...
ruby
def filename_from_content_disposition(content_disposition) content_disposition = content_disposition.to_s escaped_filename = content_disposition[/filename\*=UTF-8''(\S+)/, 1] || content_disposition[/filename="([^"]*)"/, 1] || content_disposition[/filename=(\S+)/, 1] filename ...
[ "def", "filename_from_content_disposition", "(", "content_disposition", ")", "content_disposition", "=", "content_disposition", ".", "to_s", "escaped_filename", "=", "content_disposition", "[", "/", "\\*", "\\S", "/", ",", "1", "]", "||", "content_disposition", "[", "...
Retrieves potential filename from the "Content-Disposition" header.
[ "Retrieves", "potential", "filename", "from", "the", "Content", "-", "Disposition", "header", "." ]
300ed69edd4de2ea8298f1b43e99de091976fe93
https://github.com/janko/down/blob/300ed69edd4de2ea8298f1b43e99de091976fe93/lib/down/utils.rb#L8-L19
train
janko/down
lib/down/wget.rb
Down.Wget.download
def download(url, *args, max_size: nil, content_length_proc: nil, progress_proc: nil, destination: nil, **options) io = open(url, *args, **options, rewindable: false) content_length_proc.call(io.size) if content_length_proc && io.size if max_size && io.size && io.size > max_size raise Down::...
ruby
def download(url, *args, max_size: nil, content_length_proc: nil, progress_proc: nil, destination: nil, **options) io = open(url, *args, **options, rewindable: false) content_length_proc.call(io.size) if content_length_proc && io.size if max_size && io.size && io.size > max_size raise Down::...
[ "def", "download", "(", "url", ",", "*", "args", ",", "max_size", ":", "nil", ",", "content_length_proc", ":", "nil", ",", "progress_proc", ":", "nil", ",", "destination", ":", "nil", ",", "**", "options", ")", "io", "=", "open", "(", "url", ",", "ar...
Initializes the backend with common defaults. Downlods the remote file to disk. Accepts wget command-line options and some additional options as well.
[ "Initializes", "the", "backend", "with", "common", "defaults", ".", "Downlods", "the", "remote", "file", "to", "disk", ".", "Accepts", "wget", "command", "-", "line", "options", "and", "some", "additional", "options", "as", "well", "." ]
300ed69edd4de2ea8298f1b43e99de091976fe93
https://github.com/janko/down/blob/300ed69edd4de2ea8298f1b43e99de091976fe93/lib/down/wget.rb#L32-L68
train
janko/down
lib/down/wget.rb
Down.Wget.open
def open(url, *args, rewindable: true, **options) arguments = generate_command(url, *args, **options) command = Down::Wget::Command.execute(arguments) # Wrap the wget command output in an IO-like object. output = Down::ChunkedIO.new( chunks: command.enum_for(:output), on_cl...
ruby
def open(url, *args, rewindable: true, **options) arguments = generate_command(url, *args, **options) command = Down::Wget::Command.execute(arguments) # Wrap the wget command output in an IO-like object. output = Down::ChunkedIO.new( chunks: command.enum_for(:output), on_cl...
[ "def", "open", "(", "url", ",", "*", "args", ",", "rewindable", ":", "true", ",", "**", "options", ")", "arguments", "=", "generate_command", "(", "url", ",", "args", ",", "**", "options", ")", "command", "=", "Down", "::", "Wget", "::", "Command", "...
Starts retrieving the remote file and returns an IO-like object which downloads the response body on-demand. Accepts wget command-line options.
[ "Starts", "retrieving", "the", "remote", "file", "and", "returns", "an", "IO", "-", "like", "object", "which", "downloads", "the", "response", "body", "on", "-", "demand", ".", "Accepts", "wget", "command", "-", "line", "options", "." ]
300ed69edd4de2ea8298f1b43e99de091976fe93
https://github.com/janko/down/blob/300ed69edd4de2ea8298f1b43e99de091976fe93/lib/down/wget.rb#L72-L117
train
janko/down
lib/down/wget.rb
Down.Wget.generate_command
def generate_command(url, *args, **options) command = %W[wget --no-verbose --save-headers -O -] options = @arguments.grep(Hash).inject({}, :merge).merge(options) args = @arguments.grep(->(o){!o.is_a?(Hash)}) + args (args + options.to_a).each do |option, value| if option.is_a?(String...
ruby
def generate_command(url, *args, **options) command = %W[wget --no-verbose --save-headers -O -] options = @arguments.grep(Hash).inject({}, :merge).merge(options) args = @arguments.grep(->(o){!o.is_a?(Hash)}) + args (args + options.to_a).each do |option, value| if option.is_a?(String...
[ "def", "generate_command", "(", "url", ",", "*", "args", ",", "**", "options", ")", "command", "=", "%W[", "wget", "--no-verbose", "--save-headers", "-O", "-", "]", "options", "=", "@arguments", ".", "grep", "(", "Hash", ")", ".", "inject", "(", "{", "...
Generates the wget command.
[ "Generates", "the", "wget", "command", "." ]
300ed69edd4de2ea8298f1b43e99de091976fe93
https://github.com/janko/down/blob/300ed69edd4de2ea8298f1b43e99de091976fe93/lib/down/wget.rb#L122-L142
train
janko/down
lib/down/http.rb
Down.Http.download
def download(url, max_size: nil, progress_proc: nil, content_length_proc: nil, destination: nil, **options, &block) response = request(url, **options, &block) content_length_proc.call(response.content_length) if content_length_proc && response.content_length if max_size && response.content_length &&...
ruby
def download(url, max_size: nil, progress_proc: nil, content_length_proc: nil, destination: nil, **options, &block) response = request(url, **options, &block) content_length_proc.call(response.content_length) if content_length_proc && response.content_length if max_size && response.content_length &&...
[ "def", "download", "(", "url", ",", "max_size", ":", "nil", ",", "progress_proc", ":", "nil", ",", "content_length_proc", ":", "nil", ",", "destination", ":", "nil", ",", "**", "options", ",", "&", "block", ")", "response", "=", "request", "(", "url", ...
Initializes the backend with common defaults. Downlods the remote file to disk. Accepts HTTP.rb options via a hash or a block, and some additional options as well.
[ "Initializes", "the", "backend", "with", "common", "defaults", ".", "Downlods", "the", "remote", "file", "to", "disk", ".", "Accepts", "HTTP", ".", "rb", "options", "via", "a", "hash", "or", "a", "block", "and", "some", "additional", "options", "as", "well...
300ed69edd4de2ea8298f1b43e99de091976fe93
https://github.com/janko/down/blob/300ed69edd4de2ea8298f1b43e99de091976fe93/lib/down/http.rb#L33-L66
train
janko/down
lib/down/http.rb
Down.Http.open
def open(url, rewindable: true, **options, &block) response = request(url, **options, &block) Down::ChunkedIO.new( chunks: enum_for(:stream_body, response), size: response.content_length, encoding: response.content_type.charset, rewindable: rewindable, da...
ruby
def open(url, rewindable: true, **options, &block) response = request(url, **options, &block) Down::ChunkedIO.new( chunks: enum_for(:stream_body, response), size: response.content_length, encoding: response.content_type.charset, rewindable: rewindable, da...
[ "def", "open", "(", "url", ",", "rewindable", ":", "true", ",", "**", "options", ",", "&", "block", ")", "response", "=", "request", "(", "url", ",", "**", "options", ",", "block", ")", "Down", "::", "ChunkedIO", ".", "new", "(", "chunks", ":", "en...
Starts retrieving the remote file and returns an IO-like object which downloads the response body on-demand. Accepts HTTP.rb options via a hash or a block.
[ "Starts", "retrieving", "the", "remote", "file", "and", "returns", "an", "IO", "-", "like", "object", "which", "downloads", "the", "response", "body", "on", "-", "demand", ".", "Accepts", "HTTP", ".", "rb", "options", "via", "a", "hash", "or", "a", "bloc...
300ed69edd4de2ea8298f1b43e99de091976fe93
https://github.com/janko/down/blob/300ed69edd4de2ea8298f1b43e99de091976fe93/lib/down/http.rb#L71-L81
train
janko/down
lib/down/http.rb
Down.Http.stream_body
def stream_body(response, &block) response.body.each(&block) rescue => exception request_error!(exception) ensure response.connection.close unless @client.persistent? end
ruby
def stream_body(response, &block) response.body.each(&block) rescue => exception request_error!(exception) ensure response.connection.close unless @client.persistent? end
[ "def", "stream_body", "(", "response", ",", "&", "block", ")", "response", ".", "body", ".", "each", "(", "block", ")", "rescue", "=>", "exception", "request_error!", "(", "exception", ")", "ensure", "response", ".", "connection", ".", "close", "unless", "...
Yields chunks of the response body to the block.
[ "Yields", "chunks", "of", "the", "response", "body", "to", "the", "block", "." ]
300ed69edd4de2ea8298f1b43e99de091976fe93
https://github.com/janko/down/blob/300ed69edd4de2ea8298f1b43e99de091976fe93/lib/down/http.rb#L104-L110
train
janko/down
lib/down/net_http.rb
Down.NetHttp.download
def download(url, options = {}) options = @options.merge(options) max_size = options.delete(:max_size) max_redirects = options.delete(:max_redirects) progress_proc = options.delete(:progress_proc) content_length_proc = options.delete(:content_length_proc) dest...
ruby
def download(url, options = {}) options = @options.merge(options) max_size = options.delete(:max_size) max_redirects = options.delete(:max_redirects) progress_proc = options.delete(:progress_proc) content_length_proc = options.delete(:content_length_proc) dest...
[ "def", "download", "(", "url", ",", "options", "=", "{", "}", ")", "options", "=", "@options", ".", "merge", "(", "options", ")", "max_size", "=", "options", ".", "delete", "(", ":max_size", ")", "max_redirects", "=", "options", ".", "delete", "(", ":m...
Initializes the backend with common defaults. Downloads a remote file to disk using open-uri. Accepts any open-uri options, and a few more.
[ "Initializes", "the", "backend", "with", "common", "defaults", ".", "Downloads", "a", "remote", "file", "to", "disk", "using", "open", "-", "uri", ".", "Accepts", "any", "open", "-", "uri", "options", "and", "a", "few", "more", "." ]
300ed69edd4de2ea8298f1b43e99de091976fe93
https://github.com/janko/down/blob/300ed69edd4de2ea8298f1b43e99de091976fe93/lib/down/net_http.rb#L27-L94
train
janko/down
lib/down/net_http.rb
Down.NetHttp.ensure_uri
def ensure_uri(url, allow_relative: false) begin uri = URI(url) rescue URI::InvalidURIError => exception raise Down::InvalidUrl, exception.message end unless allow_relative && uri.relative? raise Down::InvalidUrl, "URL scheme needs to be http or https: #{uri}" unless uri...
ruby
def ensure_uri(url, allow_relative: false) begin uri = URI(url) rescue URI::InvalidURIError => exception raise Down::InvalidUrl, exception.message end unless allow_relative && uri.relative? raise Down::InvalidUrl, "URL scheme needs to be http or https: #{uri}" unless uri...
[ "def", "ensure_uri", "(", "url", ",", "allow_relative", ":", "false", ")", "begin", "uri", "=", "URI", "(", "url", ")", "rescue", "URI", "::", "InvalidURIError", "=>", "exception", "raise", "Down", "::", "InvalidUrl", ",", "exception", ".", "message", "end...
Checks that the url is a valid URI and that its scheme is http or https.
[ "Checks", "that", "the", "url", "is", "a", "valid", "URI", "and", "that", "its", "scheme", "is", "http", "or", "https", "." ]
300ed69edd4de2ea8298f1b43e99de091976fe93
https://github.com/janko/down/blob/300ed69edd4de2ea8298f1b43e99de091976fe93/lib/down/net_http.rb#L272-L284
train
janko/down
lib/down/net_http.rb
Down.NetHttp.addressable_normalize
def addressable_normalize(url) addressable_uri = Addressable::URI.parse(url) addressable_uri.normalize.to_s end
ruby
def addressable_normalize(url) addressable_uri = Addressable::URI.parse(url) addressable_uri.normalize.to_s end
[ "def", "addressable_normalize", "(", "url", ")", "addressable_uri", "=", "Addressable", "::", "URI", ".", "parse", "(", "url", ")", "addressable_uri", ".", "normalize", ".", "to_s", "end" ]
Makes sure that the URL is properly encoded.
[ "Makes", "sure", "that", "the", "URL", "is", "properly", "encoded", "." ]
300ed69edd4de2ea8298f1b43e99de091976fe93
https://github.com/janko/down/blob/300ed69edd4de2ea8298f1b43e99de091976fe93/lib/down/net_http.rb#L287-L290
train
janko/down
lib/down/backend.rb
Down.Backend.download_result
def download_result(tempfile, destination) return tempfile unless destination tempfile.close # required for Windows FileUtils.mv tempfile.path, destination nil end
ruby
def download_result(tempfile, destination) return tempfile unless destination tempfile.close # required for Windows FileUtils.mv tempfile.path, destination nil end
[ "def", "download_result", "(", "tempfile", ",", "destination", ")", "return", "tempfile", "unless", "destination", "tempfile", ".", "close", "# required for Windows", "FileUtils", ".", "mv", "tempfile", ".", "path", ",", "destination", "nil", "end" ]
If destination path is defined, move tempfile to the destination, otherwise return the tempfile unchanged.
[ "If", "destination", "path", "is", "defined", "move", "tempfile", "to", "the", "destination", "otherwise", "return", "the", "tempfile", "unchanged", "." ]
300ed69edd4de2ea8298f1b43e99de091976fe93
https://github.com/janko/down/blob/300ed69edd4de2ea8298f1b43e99de091976fe93/lib/down/backend.rb#L24-L31
train
tubedude/xirr
lib/xirr/newton_method.rb
Xirr.NewtonMethod.xirr
def xirr guess, options func = Function.new(self, :xnpv) rate = [guess || cf.irr_guess] begin nlsolve(func, rate) (rate[0] <= -1 || rate[0].nan?) ? nil : rate[0].round(Xirr::PRECISION) # rate[0].round(Xirr::PRECISION) rescue nil end end
ruby
def xirr guess, options func = Function.new(self, :xnpv) rate = [guess || cf.irr_guess] begin nlsolve(func, rate) (rate[0] <= -1 || rate[0].nan?) ? nil : rate[0].round(Xirr::PRECISION) # rate[0].round(Xirr::PRECISION) rescue nil end end
[ "def", "xirr", "guess", ",", "options", "func", "=", "Function", ".", "new", "(", "self", ",", ":xnpv", ")", "rate", "=", "[", "guess", "||", "cf", ".", "irr_guess", "]", "begin", "nlsolve", "(", "func", ",", "rate", ")", "(", "rate", "[", "0", "...
Calculates XIRR using Newton method @return [BigDecimal] @param guess [Float]
[ "Calculates", "XIRR", "using", "Newton", "method" ]
e8488a95b217c463d54a5d311ce02a9474f22f7e
https://github.com/tubedude/xirr/blob/e8488a95b217c463d54a5d311ce02a9474f22f7e/lib/xirr/newton_method.rb#L47-L58
train
tubedude/xirr
lib/xirr/bisection.rb
Xirr.Bisection.xirr
def xirr(midpoint, options) # Initial values left = [BigDecimal.new(-0.99999999, Xirr::PRECISION), cf.irr_guess].min right = [BigDecimal.new(9.99999999, Xirr::PRECISION), cf.irr_guess + 1].max @original_right = right midpoint ||= cf.irr_guess midpoint, runs = loop_rates(left, midp...
ruby
def xirr(midpoint, options) # Initial values left = [BigDecimal.new(-0.99999999, Xirr::PRECISION), cf.irr_guess].min right = [BigDecimal.new(9.99999999, Xirr::PRECISION), cf.irr_guess + 1].max @original_right = right midpoint ||= cf.irr_guess midpoint, runs = loop_rates(left, midp...
[ "def", "xirr", "(", "midpoint", ",", "options", ")", "# Initial values", "left", "=", "[", "BigDecimal", ".", "new", "(", "-", "0.99999999", ",", "Xirr", "::", "PRECISION", ")", ",", "cf", ".", "irr_guess", "]", ".", "min", "right", "=", "[", "BigDecim...
Calculates yearly Internal Rate of Return @return [BigDecimal] @param midpoint [Float] An initial guess rate will override the {Cashflow#irr_guess}
[ "Calculates", "yearly", "Internal", "Rate", "of", "Return" ]
e8488a95b217c463d54a5d311ce02a9474f22f7e
https://github.com/tubedude/xirr/blob/e8488a95b217c463d54a5d311ce02a9474f22f7e/lib/xirr/bisection.rb#L11-L23
train
tubedude/xirr
lib/xirr/base.rb
Xirr.Base.xnpv
def xnpv(rate) cf.inject(0) do |sum, t| sum + (xnpv_c rate, t.amount, periods_from_start(t.date)) end end
ruby
def xnpv(rate) cf.inject(0) do |sum, t| sum + (xnpv_c rate, t.amount, periods_from_start(t.date)) end end
[ "def", "xnpv", "(", "rate", ")", "cf", ".", "inject", "(", "0", ")", "do", "|", "sum", ",", "t", "|", "sum", "+", "(", "xnpv_c", "rate", ",", "t", ".", "amount", ",", "periods_from_start", "(", "t", ".", "date", ")", ")", "end", "end" ]
Net Present Value function that will be used to reduce the cashflow @param rate [BigDecimal] @return [BigDecimal]
[ "Net", "Present", "Value", "function", "that", "will", "be", "used", "to", "reduce", "the", "cashflow" ]
e8488a95b217c463d54a5d311ce02a9474f22f7e
https://github.com/tubedude/xirr/blob/e8488a95b217c463d54a5d311ce02a9474f22f7e/lib/xirr/base.rb#L25-L29
train
rake-compiler/rake-compiler
lib/rake/extensiontask.rb
Rake.ExtensionTask.define_staging_file_tasks
def define_staging_file_tasks(files, lib_path, stage_path, platf, ruby_ver) files.each do |gem_file| # ignore directories and the binary extension next if File.directory?(gem_file) || gem_file == "#{lib_path}/#{binary(platf)}" stage_file = "#{stage_path}/#{gem_file}" # copy each f...
ruby
def define_staging_file_tasks(files, lib_path, stage_path, platf, ruby_ver) files.each do |gem_file| # ignore directories and the binary extension next if File.directory?(gem_file) || gem_file == "#{lib_path}/#{binary(platf)}" stage_file = "#{stage_path}/#{gem_file}" # copy each f...
[ "def", "define_staging_file_tasks", "(", "files", ",", "lib_path", ",", "stage_path", ",", "platf", ",", "ruby_ver", ")", "files", ".", "each", "do", "|", "gem_file", "|", "# ignore directories and the binary extension", "next", "if", "File", ".", "directory?", "(...
copy other gem files to staging directory
[ "copy", "other", "gem", "files", "to", "staging", "directory" ]
18b335a87000efe91db8997f586772150528f342
https://github.com/rake-compiler/rake-compiler/blob/18b335a87000efe91db8997f586772150528f342/lib/rake/extensiontask.rb#L91-L108
train
rake-compiler/rake-compiler
lib/rake/javaextensiontask.rb
Rake.JavaExtensionTask.java_extdirs_arg
def java_extdirs_arg extdirs = Java::java.lang.System.getProperty('java.ext.dirs') rescue nil extdirs = ENV['JAVA_EXT_DIR'] unless extdirs java_extdir = extdirs.nil? ? "" : "-extdirs \"#{extdirs}\"" end
ruby
def java_extdirs_arg extdirs = Java::java.lang.System.getProperty('java.ext.dirs') rescue nil extdirs = ENV['JAVA_EXT_DIR'] unless extdirs java_extdir = extdirs.nil? ? "" : "-extdirs \"#{extdirs}\"" end
[ "def", "java_extdirs_arg", "extdirs", "=", "Java", "::", "java", ".", "lang", ".", "System", ".", "getProperty", "(", "'java.ext.dirs'", ")", "rescue", "nil", "extdirs", "=", "ENV", "[", "'JAVA_EXT_DIR'", "]", "unless", "extdirs", "java_extdir", "=", "extdirs"...
Discover Java Extension Directories and build an extdirs argument
[ "Discover", "Java", "Extension", "Directories", "and", "build", "an", "extdirs", "argument" ]
18b335a87000efe91db8997f586772150528f342
https://github.com/rake-compiler/rake-compiler/blob/18b335a87000efe91db8997f586772150528f342/lib/rake/javaextensiontask.rb#L190-L194
train
WinRb/WinRM
lib/winrm/connection.rb
WinRM.Connection.shell
def shell(shell_type, shell_opts = {}) shell = shell_factory.create_shell(shell_type, shell_opts) if block_given? begin yield shell ensure shell.close end else shell end end
ruby
def shell(shell_type, shell_opts = {}) shell = shell_factory.create_shell(shell_type, shell_opts) if block_given? begin yield shell ensure shell.close end else shell end end
[ "def", "shell", "(", "shell_type", ",", "shell_opts", "=", "{", "}", ")", "shell", "=", "shell_factory", ".", "create_shell", "(", "shell_type", ",", "shell_opts", ")", "if", "block_given?", "begin", "yield", "shell", "ensure", "shell", ".", "close", "end", ...
Creates a new shell on the remote Windows server associated with this connection. @param shell_type [Symbol] The shell type :cmd or :powershell @param shell_opts [Hash] Options targeted for the created shell @return [Shell] PowerShell or Cmd shell instance.
[ "Creates", "a", "new", "shell", "on", "the", "remote", "Windows", "server", "associated", "with", "this", "connection", "." ]
a5afd4755bd5a3e0672f6a6014448476f0631909
https://github.com/WinRb/WinRM/blob/a5afd4755bd5a3e0672f6a6014448476f0631909/lib/winrm/connection.rb#L38-L49
train
WinRb/WinRM
lib/winrm/connection.rb
WinRM.Connection.run_wql
def run_wql(wql, namespace = 'root/cimv2/*', &block) query = WinRM::WSMV::WqlQuery.new(transport, @connection_opts, wql, namespace) query.process_response(transport.send_request(query.build), &block) end
ruby
def run_wql(wql, namespace = 'root/cimv2/*', &block) query = WinRM::WSMV::WqlQuery.new(transport, @connection_opts, wql, namespace) query.process_response(transport.send_request(query.build), &block) end
[ "def", "run_wql", "(", "wql", ",", "namespace", "=", "'root/cimv2/*'", ",", "&", "block", ")", "query", "=", "WinRM", "::", "WSMV", "::", "WqlQuery", ".", "new", "(", "transport", ",", "@connection_opts", ",", "wql", ",", "namespace", ")", "query", ".", ...
Executes a WQL query against the WinRM connection @param wql [String] The wql query @param namespace [String] namespace for query - default is root/cimv2/* @return [Hash] Hash representation of wql query response (Hash is empty if a block is given) @yeild [type, item] Yields the time name and item for every item
[ "Executes", "a", "WQL", "query", "against", "the", "WinRM", "connection" ]
a5afd4755bd5a3e0672f6a6014448476f0631909
https://github.com/WinRb/WinRM/blob/a5afd4755bd5a3e0672f6a6014448476f0631909/lib/winrm/connection.rb#L56-L59
train
honeybadger-io/honeybadger-ruby
lib/honeybadger/config.rb
Honeybadger.Config.includes_token?
def includes_token?(obj, value) return false unless obj.kind_of?(Array) obj.map(&:to_sym).include?(value.to_sym) end
ruby
def includes_token?(obj, value) return false unless obj.kind_of?(Array) obj.map(&:to_sym).include?(value.to_sym) end
[ "def", "includes_token?", "(", "obj", ",", "value", ")", "return", "false", "unless", "obj", ".", "kind_of?", "(", "Array", ")", "obj", ".", "map", "(", ":to_sym", ")", ".", "include?", "(", "value", ".", "to_sym", ")", "end" ]
Takes an Array and a value and returns true if the value exists in the array in String or Symbol form, otherwise false.
[ "Takes", "an", "Array", "and", "a", "value", "and", "returns", "true", "if", "the", "value", "exists", "in", "the", "array", "in", "String", "or", "Symbol", "form", "otherwise", "false", "." ]
dc4af07c347814c2c8a71778c5bcd4d6979b4638
https://github.com/honeybadger-io/honeybadger-ruby/blob/dc4af07c347814c2c8a71778c5bcd4d6979b4638/lib/honeybadger/config.rb#L378-L381
train
honeybadger-io/honeybadger-ruby
lib/honeybadger/notice.rb
Honeybadger.Notice.ignore_by_class?
def ignore_by_class?(ignored_class = nil) @ignore_by_class ||= Proc.new do |ignored_class| case error_class when (ignored_class.respond_to?(:name) ? ignored_class.name : ignored_class) true else exception && ignored_class.is_a?(Class) && exception.class < ignored_class ...
ruby
def ignore_by_class?(ignored_class = nil) @ignore_by_class ||= Proc.new do |ignored_class| case error_class when (ignored_class.respond_to?(:name) ? ignored_class.name : ignored_class) true else exception && ignored_class.is_a?(Class) && exception.class < ignored_class ...
[ "def", "ignore_by_class?", "(", "ignored_class", "=", "nil", ")", "@ignore_by_class", "||=", "Proc", ".", "new", "do", "|", "ignored_class", "|", "case", "error_class", "when", "(", "ignored_class", ".", "respond_to?", "(", ":name", ")", "?", "ignored_class", ...
Determines if error class should be ignored. ignored_class_name - The name of the ignored class. May be a string or regexp (optional). Returns true or false.
[ "Determines", "if", "error", "class", "should", "be", "ignored", "." ]
dc4af07c347814c2c8a71778c5bcd4d6979b4638
https://github.com/honeybadger-io/honeybadger-ruby/blob/dc4af07c347814c2c8a71778c5bcd4d6979b4638/lib/honeybadger/notice.rb#L305-L316
train
honeybadger-io/honeybadger-ruby
lib/honeybadger/notice.rb
Honeybadger.Notice.construct_request_hash
def construct_request_hash request = { url: url, component: component, action: action, params: params, session: session, cgi_data: cgi_data, sanitizer: request_sanitizer } request.delete_if {|k,v| config.excluded_request_keys.include?(k) } ...
ruby
def construct_request_hash request = { url: url, component: component, action: action, params: params, session: session, cgi_data: cgi_data, sanitizer: request_sanitizer } request.delete_if {|k,v| config.excluded_request_keys.include?(k) } ...
[ "def", "construct_request_hash", "request", "=", "{", "url", ":", "url", ",", "component", ":", "component", ",", "action", ":", "action", ",", "params", ":", "params", ",", "session", ":", "session", ",", "cgi_data", ":", "cgi_data", ",", "sanitizer", ":"...
Construct the request data. Returns Hash request data.
[ "Construct", "the", "request", "data", "." ]
dc4af07c347814c2c8a71778c5bcd4d6979b4638
https://github.com/honeybadger-io/honeybadger-ruby/blob/dc4af07c347814c2c8a71778c5bcd4d6979b4638/lib/honeybadger/notice.rb#L331-L343
train
honeybadger-io/honeybadger-ruby
lib/honeybadger/notice.rb
Honeybadger.Notice.exception_context
def exception_context(exception) # This extra check exists because the exception itself is not expected to # convert to a hash. object = exception if exception.respond_to?(:to_honeybadger_context) object ||= {}.freeze Context(object) end
ruby
def exception_context(exception) # This extra check exists because the exception itself is not expected to # convert to a hash. object = exception if exception.respond_to?(:to_honeybadger_context) object ||= {}.freeze Context(object) end
[ "def", "exception_context", "(", "exception", ")", "# This extra check exists because the exception itself is not expected to", "# convert to a hash.", "object", "=", "exception", "if", "exception", ".", "respond_to?", "(", ":to_honeybadger_context", ")", "object", "||=", "{", ...
Get optional context from exception. Returns the Hash context.
[ "Get", "optional", "context", "from", "exception", "." ]
dc4af07c347814c2c8a71778c5bcd4d6979b4638
https://github.com/honeybadger-io/honeybadger-ruby/blob/dc4af07c347814c2c8a71778c5bcd4d6979b4638/lib/honeybadger/notice.rb#L348-L355
train
honeybadger-io/honeybadger-ruby
lib/honeybadger/notice.rb
Honeybadger.Notice.parse_backtrace
def parse_backtrace(backtrace) Backtrace.parse( backtrace, filters: construct_backtrace_filters(opts), config: config, source_radius: config[:'exceptions.source_radius'] ).to_a end
ruby
def parse_backtrace(backtrace) Backtrace.parse( backtrace, filters: construct_backtrace_filters(opts), config: config, source_radius: config[:'exceptions.source_radius'] ).to_a end
[ "def", "parse_backtrace", "(", "backtrace", ")", "Backtrace", ".", "parse", "(", "backtrace", ",", "filters", ":", "construct_backtrace_filters", "(", "opts", ")", ",", "config", ":", "config", ",", "source_radius", ":", "config", "[", ":'", "'", "]", ")", ...
Parse Backtrace from exception backtrace. backtrace - The Array backtrace from exception. Returns the Backtrace.
[ "Parse", "Backtrace", "from", "exception", "backtrace", "." ]
dc4af07c347814c2c8a71778c5bcd4d6979b4638
https://github.com/honeybadger-io/honeybadger-ruby/blob/dc4af07c347814c2c8a71778c5bcd4d6979b4638/lib/honeybadger/notice.rb#L443-L450
train
honeybadger-io/honeybadger-ruby
lib/honeybadger/notice.rb
Honeybadger.Notice.exception_cause
def exception_cause(exception) e = exception if e.respond_to?(:cause) && e.cause && e.cause.is_a?(Exception) e.cause elsif e.respond_to?(:original_exception) && e.original_exception && e.original_exception.is_a?(Exception) e.original_exception elsif e.respond_to?(:continued_excep...
ruby
def exception_cause(exception) e = exception if e.respond_to?(:cause) && e.cause && e.cause.is_a?(Exception) e.cause elsif e.respond_to?(:original_exception) && e.original_exception && e.original_exception.is_a?(Exception) e.original_exception elsif e.respond_to?(:continued_excep...
[ "def", "exception_cause", "(", "exception", ")", "e", "=", "exception", "if", "e", ".", "respond_to?", "(", ":cause", ")", "&&", "e", ".", "cause", "&&", "e", ".", "cause", ".", "is_a?", "(", "Exception", ")", "e", ".", "cause", "elsif", "e", ".", ...
Fetch cause from exception. exception - Exception to fetch cause from. Returns the Exception cause.
[ "Fetch", "cause", "from", "exception", "." ]
dc4af07c347814c2c8a71778c5bcd4d6979b4638
https://github.com/honeybadger-io/honeybadger-ruby/blob/dc4af07c347814c2c8a71778c5bcd4d6979b4638/lib/honeybadger/notice.rb#L468-L477
train
honeybadger-io/honeybadger-ruby
lib/honeybadger/notice.rb
Honeybadger.Notice.unwrap_causes
def unwrap_causes(cause) causes, c, i = [], cause, 0 while c && i < MAX_EXCEPTION_CAUSES causes << { class: c.class.name, message: c.message, backtrace: parse_backtrace(c.backtrace || caller) } i += 1 c = exception_cause(c) end caus...
ruby
def unwrap_causes(cause) causes, c, i = [], cause, 0 while c && i < MAX_EXCEPTION_CAUSES causes << { class: c.class.name, message: c.message, backtrace: parse_backtrace(c.backtrace || caller) } i += 1 c = exception_cause(c) end caus...
[ "def", "unwrap_causes", "(", "cause", ")", "causes", ",", "c", ",", "i", "=", "[", "]", ",", "cause", ",", "0", "while", "c", "&&", "i", "<", "MAX_EXCEPTION_CAUSES", "causes", "<<", "{", "class", ":", "c", ".", "class", ".", "name", ",", "message",...
Create a list of causes. cause - The first cause to unwrap. Returns Array causes (in Hash payload format).
[ "Create", "a", "list", "of", "causes", "." ]
dc4af07c347814c2c8a71778c5bcd4d6979b4638
https://github.com/honeybadger-io/honeybadger-ruby/blob/dc4af07c347814c2c8a71778c5bcd4d6979b4638/lib/honeybadger/notice.rb#L484-L498
train
honeybadger-io/honeybadger-ruby
lib/honeybadger/worker.rb
Honeybadger.Worker.flush
def flush mutex.synchronize do if thread && thread.alive? queue.push(marker) marker.wait(mutex) end end end
ruby
def flush mutex.synchronize do if thread && thread.alive? queue.push(marker) marker.wait(mutex) end end end
[ "def", "flush", "mutex", ".", "synchronize", "do", "if", "thread", "&&", "thread", ".", "alive?", "queue", ".", "push", "(", "marker", ")", "marker", ".", "wait", "(", "mutex", ")", "end", "end", "end" ]
Blocks until queue is processed up to this point in time.
[ "Blocks", "until", "queue", "is", "processed", "up", "to", "this", "point", "in", "time", "." ]
dc4af07c347814c2c8a71778c5bcd4d6979b4638
https://github.com/honeybadger-io/honeybadger-ruby/blob/dc4af07c347814c2c8a71778c5bcd4d6979b4638/lib/honeybadger/worker.rb#L96-L103
train
honeybadger-io/honeybadger-ruby
lib/honeybadger/agent.rb
Honeybadger.Agent.notify
def notify(exception_or_opts, opts = {}) if exception_or_opts.is_a?(Exception) opts[:exception] = exception_or_opts elsif exception_or_opts.respond_to?(:to_hash) opts.merge!(exception_or_opts.to_hash) else opts[:error_message] = exception_or_opts.to_s end validate_...
ruby
def notify(exception_or_opts, opts = {}) if exception_or_opts.is_a?(Exception) opts[:exception] = exception_or_opts elsif exception_or_opts.respond_to?(:to_hash) opts.merge!(exception_or_opts.to_hash) else opts[:error_message] = exception_or_opts.to_s end validate_...
[ "def", "notify", "(", "exception_or_opts", ",", "opts", "=", "{", "}", ")", "if", "exception_or_opts", ".", "is_a?", "(", "Exception", ")", "opts", "[", ":exception", "]", "=", "exception_or_opts", "elsif", "exception_or_opts", ".", "respond_to?", "(", ":to_ha...
Sends an exception to Honeybadger. Does not report ignored exceptions by default. @example # With an exception: begin fail 'oops' rescue => exception Honeybadger.notify(exception, context: { my_data: 'value' }) # => '-1dfb92ae-9b01-42e9-9c13-31205b70744a' end # Custom notificati...
[ "Sends", "an", "exception", "to", "Honeybadger", ".", "Does", "not", "report", "ignored", "exceptions", "by", "default", "." ]
dc4af07c347814c2c8a71778c5bcd4d6979b4638
https://github.com/honeybadger-io/honeybadger-ruby/blob/dc4af07c347814c2c8a71778c5bcd4d6979b4638/lib/honeybadger/agent.rb#L112-L157
train
honeybadger-io/honeybadger-ruby
lib/honeybadger/agent.rb
Honeybadger.Agent.check_in
def check_in(id) # this is to allow check ins even if a url is passed check_in_id = id.to_s.strip.gsub(/\/$/, '').split('/').last response = backend.check_in(check_in_id) response.success? end
ruby
def check_in(id) # this is to allow check ins even if a url is passed check_in_id = id.to_s.strip.gsub(/\/$/, '').split('/').last response = backend.check_in(check_in_id) response.success? end
[ "def", "check_in", "(", "id", ")", "# this is to allow check ins even if a url is passed", "check_in_id", "=", "id", ".", "to_s", ".", "strip", ".", "gsub", "(", "/", "\\/", "/", ",", "''", ")", ".", "split", "(", "'/'", ")", ".", "last", "response", "=", ...
Perform a synchronous check_in. @example Honeybadger.check_in('1MqIo1') @param [String] id The unique check in id (e.g. '1MqIo1') or the check in url. @return [Boolean] true if the check in was successful and false otherwise.
[ "Perform", "a", "synchronous", "check_in", "." ]
dc4af07c347814c2c8a71778c5bcd4d6979b4638
https://github.com/honeybadger-io/honeybadger-ruby/blob/dc4af07c347814c2c8a71778c5bcd4d6979b4638/lib/honeybadger/agent.rb#L168-L173
train
honeybadger-io/honeybadger-ruby
lib/honeybadger/backtrace.rb
Honeybadger.Backtrace.to_ary
def to_ary lines.take(1000).map { |l| { :number => l.filtered_number, :file => l.filtered_file, :method => l.filtered_method, :source => l.source } } end
ruby
def to_ary lines.take(1000).map { |l| { :number => l.filtered_number, :file => l.filtered_file, :method => l.filtered_method, :source => l.source } } end
[ "def", "to_ary", "lines", ".", "take", "(", "1000", ")", ".", "map", "{", "|", "l", "|", "{", ":number", "=>", "l", ".", "filtered_number", ",", ":file", "=>", "l", ".", "filtered_file", ",", ":method", "=>", "l", ".", "filtered_method", ",", ":sourc...
Convert Backtrace to arry. Returns array containing backtrace lines.
[ "Convert", "Backtrace", "to", "arry", "." ]
dc4af07c347814c2c8a71778c5bcd4d6979b4638
https://github.com/honeybadger-io/honeybadger-ruby/blob/dc4af07c347814c2c8a71778c5bcd4d6979b4638/lib/honeybadger/backtrace.rb#L134-L136
train
looker-open-source/gzr
lib/gzr/command.rb
Gzr.Command.keys_to_keep
def keys_to_keep(operation) o = @sdk.operations[operation] begin say_error "Operation #{operation} not found" return [] end unless o parameters = o[:info][:parameters].select { |p| p[:in] == "body" && p[:schema] } say_warning "Expecting exactly one body parameter with a s...
ruby
def keys_to_keep(operation) o = @sdk.operations[operation] begin say_error "Operation #{operation} not found" return [] end unless o parameters = o[:info][:parameters].select { |p| p[:in] == "body" && p[:schema] } say_warning "Expecting exactly one body parameter with a s...
[ "def", "keys_to_keep", "(", "operation", ")", "o", "=", "@sdk", ".", "operations", "[", "operation", "]", "begin", "say_error", "\"Operation #{operation} not found\"", "return", "[", "]", "end", "unless", "o", "parameters", "=", "o", "[", ":info", "]", "[", ...
This method accepts the name of an sdk operation, then finds the parameter for that operation in the data structures from the swagger.json file. The parameter is a json object. Some of the attributes of the json object are read-only, and some are read-write. A few are write-only. The list of read-write and write-onl...
[ "This", "method", "accepts", "the", "name", "of", "an", "sdk", "operation", "then", "finds", "the", "parameter", "for", "that", "operation", "in", "the", "data", "structures", "from", "the", "swagger", ".", "json", "file", ".", "The", "parameter", "is", "a...
96dd5edc9cdc6f8d053f517805b9637ff8417378
https://github.com/looker-open-source/gzr/blob/96dd5edc9cdc6f8d053f517805b9637ff8417378/lib/gzr/command.rb#L132-L144
train
looker-open-source/gzr
lib/gzr/command.rb
Gzr.Command.render_csv
def render_csv(t) io = StringIO.new io.puts ( t.header.collect do |v| v ? "\"#{v.to_s.gsub(/"/, '""')}\"" : "" end.join(',') ) unless @options[:plain] t.each do |row| next if row === t.header io.puts ( row.collect do |v| v ? "\"#{v....
ruby
def render_csv(t) io = StringIO.new io.puts ( t.header.collect do |v| v ? "\"#{v.to_s.gsub(/"/, '""')}\"" : "" end.join(',') ) unless @options[:plain] t.each do |row| next if row === t.header io.puts ( row.collect do |v| v ? "\"#{v....
[ "def", "render_csv", "(", "t", ")", "io", "=", "StringIO", ".", "new", "io", ".", "puts", "(", "t", ".", "header", ".", "collect", "do", "|", "v", "|", "v", "?", "\"\\\"#{v.to_s.gsub(/\"/, '\"\"')}\\\"\"", ":", "\"\"", "end", ".", "join", "(", "','", ...
The tty-table gem is normally used to output tabular data. This method accepts a Table object as used by the tty-table gem, and generates CSV output. It returns a string with crlf encoding
[ "The", "tty", "-", "table", "gem", "is", "normally", "used", "to", "output", "tabular", "data", ".", "This", "method", "accepts", "a", "Table", "object", "as", "used", "by", "the", "tty", "-", "table", "gem", "and", "generates", "CSV", "output", ".", "...
96dd5edc9cdc6f8d053f517805b9637ff8417378
https://github.com/looker-open-source/gzr/blob/96dd5edc9cdc6f8d053f517805b9637ff8417378/lib/gzr/command.rb#L151-L168
train
looker-open-source/gzr
lib/gzr/command.rb
Gzr.Command.field_names
def field_names(opt_fields) fields = [] token_stack = [] last_token = false tokens = opt_fields.split /(\(|,|\))/ tokens << nil tokens.each do |t| if t.nil? then fields << (token_stack + [last_token]).join('.') if last_token elsif t.empty? then nex...
ruby
def field_names(opt_fields) fields = [] token_stack = [] last_token = false tokens = opt_fields.split /(\(|,|\))/ tokens << nil tokens.each do |t| if t.nil? then fields << (token_stack + [last_token]).join('.') if last_token elsif t.empty? then nex...
[ "def", "field_names", "(", "opt_fields", ")", "fields", "=", "[", "]", "token_stack", "=", "[", "]", "last_token", "=", "false", "tokens", "=", "opt_fields", ".", "split", "/", "\\(", "\\)", "/", "tokens", "<<", "nil", "tokens", ".", "each", "do", "|",...
This method accepts a string containing a list of fields. The fields can be nested in a format like... 'a,b,c(d,e(f,g)),h' representing a structure like { a: "val", b: "val", c: { d: "val", e: { f: "val", g: "val" } }, h: "val" } That string will get parsed and yiel...
[ "This", "method", "accepts", "a", "string", "containing", "a", "list", "of", "fields", ".", "The", "fields", "can", "be", "nested", "in", "a", "format", "like", "..." ]
96dd5edc9cdc6f8d053f517805b9637ff8417378
https://github.com/looker-open-source/gzr/blob/96dd5edc9cdc6f8d053f517805b9637ff8417378/lib/gzr/command.rb#L195-L219
train
traject/traject
lib/traject/macros/marc21_semantics.rb
Traject::Macros.Marc21Semantics.oclcnum
def oclcnum(extract_fields = "035a") extractor = MarcExtractor.new(extract_fields, :separator => nil) lambda do |record, accumulator| list = extractor.extract(record).collect! do |o| Marc21Semantics.oclcnum_extract(o) end.compact accumulator.concat list.uniq if list ...
ruby
def oclcnum(extract_fields = "035a") extractor = MarcExtractor.new(extract_fields, :separator => nil) lambda do |record, accumulator| list = extractor.extract(record).collect! do |o| Marc21Semantics.oclcnum_extract(o) end.compact accumulator.concat list.uniq if list ...
[ "def", "oclcnum", "(", "extract_fields", "=", "\"035a\"", ")", "extractor", "=", "MarcExtractor", ".", "new", "(", "extract_fields", ",", ":separator", "=>", "nil", ")", "lambda", "do", "|", "record", ",", "accumulator", "|", "list", "=", "extractor", ".", ...
Extract OCLC numbers from, by default 035a's by known prefixes, then stripped just the num, and de-dup.
[ "Extract", "OCLC", "numbers", "from", "by", "default", "035a", "s", "by", "known", "prefixes", "then", "stripped", "just", "the", "num", "and", "de", "-", "dup", "." ]
fcb17711fe7a0590e72ecbd39fd3c61d77689f24
https://github.com/traject/traject/blob/fcb17711fe7a0590e72ecbd39fd3c61d77689f24/lib/traject/macros/marc21_semantics.rb#L18-L28
train
traject/traject
lib/traject/macros/marc21_semantics.rb
Traject::Macros.Marc21Semantics.marc_sortable_title
def marc_sortable_title lambda do |record, accumulator| st = Marc21Semantics.get_sortable_title(record) accumulator << st if st end end
ruby
def marc_sortable_title lambda do |record, accumulator| st = Marc21Semantics.get_sortable_title(record) accumulator << st if st end end
[ "def", "marc_sortable_title", "lambda", "do", "|", "record", ",", "accumulator", "|", "st", "=", "Marc21Semantics", ".", "get_sortable_title", "(", "record", ")", "accumulator", "<<", "st", "if", "st", "end", "end" ]
245 a and b, with non-filing characters stripped off
[ "245", "a", "and", "b", "with", "non", "-", "filing", "characters", "stripped", "off" ]
fcb17711fe7a0590e72ecbd39fd3c61d77689f24
https://github.com/traject/traject/blob/fcb17711fe7a0590e72ecbd39fd3c61d77689f24/lib/traject/macros/marc21_semantics.rb#L92-L97
train
traject/traject
lib/traject/macros/marc21_semantics.rb
Traject::Macros.Marc21Semantics.marc_publication_date
def marc_publication_date(options = {}) estimate_tolerance = options[:estimate_tolerance] || 15 min_year = options[:min_year] || 500 max_year = options[:max_year] || (Time.new.year + 6) lambda do |record, accumulator| date = Marc21Semantics.publication_date(record...
ruby
def marc_publication_date(options = {}) estimate_tolerance = options[:estimate_tolerance] || 15 min_year = options[:min_year] || 500 max_year = options[:max_year] || (Time.new.year + 6) lambda do |record, accumulator| date = Marc21Semantics.publication_date(record...
[ "def", "marc_publication_date", "(", "options", "=", "{", "}", ")", "estimate_tolerance", "=", "options", "[", ":estimate_tolerance", "]", "||", "15", "min_year", "=", "options", "[", ":min_year", "]", "||", "500", "max_year", "=", "options", "[", ":max_year",...
An opinionated algorithm for getting a SINGLE publication date out of marc * Prefers using 008, but will resort to 260c * If 008 represents a date range, will take the midpoint of the range, only if range is smaller than estimate_tolerance, default 15 years. * Ignores dates below min_year (default 500) or abov...
[ "An", "opinionated", "algorithm", "for", "getting", "a", "SINGLE", "publication", "date", "out", "of", "marc" ]
fcb17711fe7a0590e72ecbd39fd3c61d77689f24
https://github.com/traject/traject/blob/fcb17711fe7a0590e72ecbd39fd3c61d77689f24/lib/traject/macros/marc21_semantics.rb#L310-L319
train
traject/traject
lib/traject/macros/marc21_semantics.rb
Traject::Macros.Marc21Semantics.marc_geo_facet
def marc_geo_facet(options = {}) marc_geo_map = Traject::TranslationMap.new("marc_geographic") a_fields_spec = options[:geo_a_fields] || "651a:691a" z_fields_spec = options[:geo_z_fields] || "600:610:611:630:648:650:654:655:656:690:651:691" extractor_043a = MarcExtractor.new("043a", :sepa...
ruby
def marc_geo_facet(options = {}) marc_geo_map = Traject::TranslationMap.new("marc_geographic") a_fields_spec = options[:geo_a_fields] || "651a:691a" z_fields_spec = options[:geo_z_fields] || "600:610:611:630:648:650:654:655:656:690:651:691" extractor_043a = MarcExtractor.new("043a", :sepa...
[ "def", "marc_geo_facet", "(", "options", "=", "{", "}", ")", "marc_geo_map", "=", "Traject", "::", "TranslationMap", ".", "new", "(", "\"marc_geographic\"", ")", "a_fields_spec", "=", "options", "[", ":geo_a_fields", "]", "||", "\"651a:691a\"", "z_fields_spec", ...
An opinionated method of making a geographic facet out of BOTH 048 marc codes, AND geo subdivisions in 6xx LCSH subjects. The LCSH geo subdivisions are further normalized: * geo qualifiers in $z fields into parens, so "Germany -- Berlin" becomes "Berlin (Germany)" (to be consistent with how same areas are writte...
[ "An", "opinionated", "method", "of", "making", "a", "geographic", "facet", "out", "of", "BOTH", "048", "marc", "codes", "AND", "geo", "subdivisions", "in", "6xx", "LCSH", "subjects", "." ]
fcb17711fe7a0590e72ecbd39fd3c61d77689f24
https://github.com/traject/traject/blob/fcb17711fe7a0590e72ecbd39fd3c61d77689f24/lib/traject/macros/marc21_semantics.rb#L431-L478
train
traject/traject
lib/traject/macros/marc21_semantics.rb
Traject::Macros.Marc21Semantics.marc_lcsh_formatted
def marc_lcsh_formatted(options = {}) spec = options[:spec] || "600:610:611:630:648:650:651:654:662" subd_separator = options[:subdivison_separator] || " — " other_separator = options[:other_separator] || " " extractor = MarcExtractor.new(spec) return lambda do |record,...
ruby
def marc_lcsh_formatted(options = {}) spec = options[:spec] || "600:610:611:630:648:650:651:654:662" subd_separator = options[:subdivison_separator] || " — " other_separator = options[:other_separator] || " " extractor = MarcExtractor.new(spec) return lambda do |record,...
[ "def", "marc_lcsh_formatted", "(", "options", "=", "{", "}", ")", "spec", "=", "options", "[", ":spec", "]", "||", "\"600:610:611:630:648:650:651:654:662\"", "subd_separator", "=", "options", "[", ":subdivison_separator", "]", "||", "\" — \"", "other_separator", "="...
Extracts LCSH-carrying fields, and formatting them as a pre-coordinated LCSH string, for instance suitable for including in a facet. You can supply your own list of fields as a spec, but for significant customization you probably just want to write your own method in terms of the Marc21Semantics.assemble_lcsh met...
[ "Extracts", "LCSH", "-", "carrying", "fields", "and", "formatting", "them", "as", "a", "pre", "-", "coordinated", "LCSH", "string", "for", "instance", "suitable", "for", "including", "in", "a", "facet", "." ]
fcb17711fe7a0590e72ecbd39fd3c61d77689f24
https://github.com/traject/traject/blob/fcb17711fe7a0590e72ecbd39fd3c61d77689f24/lib/traject/macros/marc21_semantics.rb#L527-L540
train
traject/traject
lib/traject/translation_map.rb
Traject.TranslationMap.translate_array
def translate_array(array) array.each_with_object([]) do |input_element, output_array| output_element = self.map(input_element) if output_element.kind_of? Array output_array.concat output_element elsif ! output_element.nil? output_array << output_element end ...
ruby
def translate_array(array) array.each_with_object([]) do |input_element, output_array| output_element = self.map(input_element) if output_element.kind_of? Array output_array.concat output_element elsif ! output_element.nil? output_array << output_element end ...
[ "def", "translate_array", "(", "array", ")", "array", ".", "each_with_object", "(", "[", "]", ")", "do", "|", "input_element", ",", "output_array", "|", "output_element", "=", "self", ".", "map", "(", "input_element", ")", "if", "output_element", ".", "kind_...
Run every element of an array through this translation map, return the resulting array. If translation map returns nil, original element will be missing from output. If an input maps to an array, each element of the array will be flattened into the output. If an input maps to nil, it will cause the input element...
[ "Run", "every", "element", "of", "an", "array", "through", "this", "translation", "map", "return", "the", "resulting", "array", ".", "If", "translation", "map", "returns", "nil", "original", "element", "will", "be", "missing", "from", "output", "." ]
fcb17711fe7a0590e72ecbd39fd3c61d77689f24
https://github.com/traject/traject/blob/fcb17711fe7a0590e72ecbd39fd3c61d77689f24/lib/traject/translation_map.rb#L217-L226
train
traject/traject
lib/traject/translation_map.rb
Traject.TranslationMap.merge
def merge(other_map) default = other_map.default || self.default TranslationMap.new(self.to_hash.merge(other_map.to_hash), :default => default) end
ruby
def merge(other_map) default = other_map.default || self.default TranslationMap.new(self.to_hash.merge(other_map.to_hash), :default => default) end
[ "def", "merge", "(", "other_map", ")", "default", "=", "other_map", ".", "default", "||", "self", ".", "default", "TranslationMap", ".", "new", "(", "self", ".", "to_hash", ".", "merge", "(", "other_map", ".", "to_hash", ")", ",", ":default", "=>", "defa...
Return a new TranslationMap that results from merging argument on top of self. Can be useful for taking an existing translation map, but merging a few overrides on top. merged_map = TranslationMap.new(something).merge TranslationMap.new(else) #... merged_map.translate_array(something) # etc If a def...
[ "Return", "a", "new", "TranslationMap", "that", "results", "from", "merging", "argument", "on", "top", "of", "self", ".", "Can", "be", "useful", "for", "taking", "an", "existing", "translation", "map", "but", "merging", "a", "few", "overrides", "on", "top", ...
fcb17711fe7a0590e72ecbd39fd3c61d77689f24
https://github.com/traject/traject/blob/fcb17711fe7a0590e72ecbd39fd3c61d77689f24/lib/traject/translation_map.rb#L245-L248
train
traject/traject
lib/traject/macros/marc21.rb
Traject::Macros.Marc21.extract_all_marc_values
def extract_all_marc_values(options = {}) unless (options.keys - EXTRACT_ALL_MARC_VALID_OPTIONS).empty? raise RuntimeError.new("Illegal/Unknown argument '#{(options.keys - EXTRACT_ALL_MARC_VALID_OPTIONS).join(', ')}' in extract_all_marc at #{Traject::Util.extract_caller_location(caller.first)}") end...
ruby
def extract_all_marc_values(options = {}) unless (options.keys - EXTRACT_ALL_MARC_VALID_OPTIONS).empty? raise RuntimeError.new("Illegal/Unknown argument '#{(options.keys - EXTRACT_ALL_MARC_VALID_OPTIONS).join(', ')}' in extract_all_marc at #{Traject::Util.extract_caller_location(caller.first)}") end...
[ "def", "extract_all_marc_values", "(", "options", "=", "{", "}", ")", "unless", "(", "options", ".", "keys", "-", "EXTRACT_ALL_MARC_VALID_OPTIONS", ")", ".", "empty?", "raise", "RuntimeError", ".", "new", "(", "\"Illegal/Unknown argument '#{(options.keys - EXTRACT_ALL_M...
Takes the whole record, by default from tags 100 to 899 inclusive, all subfields, and adds them to output. Subfields in a record are all joined by space by default. options [:from] default '100', only tags >= lexicographically [:to] default '899', only tags <= lexicographically [:separator] how to join subfiel...
[ "Takes", "the", "whole", "record", "by", "default", "from", "tags", "100", "to", "899", "inclusive", "all", "subfields", "and", "adds", "them", "to", "output", ".", "Subfields", "in", "a", "record", "are", "all", "joined", "by", "space", "by", "default", ...
fcb17711fe7a0590e72ecbd39fd3c61d77689f24
https://github.com/traject/traject/blob/fcb17711fe7a0590e72ecbd39fd3c61d77689f24/lib/traject/macros/marc21.rb#L213-L237
train
traject/traject
lib/traject/oai_pmh_nokogiri_reader.rb
Traject.OaiPmhNokogiriReader.http_client
def http_client @http_client ||= begin # timeout setting on http.rb seems to be a mess. # https://github.com/httprb/http/issues/488 client = HTTP.timeout(:global, write: timeout / 3, connect: timeout / 3, read: timeout / 3) if settings["oai_pmh.try_gzip"] client = client...
ruby
def http_client @http_client ||= begin # timeout setting on http.rb seems to be a mess. # https://github.com/httprb/http/issues/488 client = HTTP.timeout(:global, write: timeout / 3, connect: timeout / 3, read: timeout / 3) if settings["oai_pmh.try_gzip"] client = client...
[ "def", "http_client", "@http_client", "||=", "begin", "# timeout setting on http.rb seems to be a mess.", "# https://github.com/httprb/http/issues/488", "client", "=", "HTTP", ".", "timeout", "(", ":global", ",", "write", ":", "timeout", "/", "3", ",", "connect", ":", "...
re-use an http-client for subsequent requests, to get http.rb's persistent connection re-use Note this means this is NOT thread safe, which is fine for now, but we'd have to do something different if we tried to multi-thread reading multiple files or something. @returns [HTTP::Client] from http.rb gem
[ "re", "-", "use", "an", "http", "-", "client", "for", "subsequent", "requests", "to", "get", "http", ".", "rb", "s", "persistent", "connection", "re", "-", "use", "Note", "this", "means", "this", "is", "NOT", "thread", "safe", "which", "is", "fine", "f...
fcb17711fe7a0590e72ecbd39fd3c61d77689f24
https://github.com/traject/traject/blob/fcb17711fe7a0590e72ecbd39fd3c61d77689f24/lib/traject/oai_pmh_nokogiri_reader.rb#L116-L133
train
zurb/inky-rb
lib/inky/component_factory.rb
Inky.ComponentFactory._transform_columns
def _transform_columns(component, inner) col_count = component.parent.elements.size small_val = component.attr('small') large_val = component.attr('large') small_size = small_val || column_count large_size = large_val || small_val || (column_count / col_count).to_i classes = _comb...
ruby
def _transform_columns(component, inner) col_count = component.parent.elements.size small_val = component.attr('small') large_val = component.attr('large') small_size = small_val || column_count large_size = large_val || small_val || (column_count / col_count).to_i classes = _comb...
[ "def", "_transform_columns", "(", "component", ",", "inner", ")", "col_count", "=", "component", ".", "parent", ".", "elements", ".", "size", "small_val", "=", "component", ".", "attr", "(", "'small'", ")", "large_val", "=", "component", ".", "attr", "(", ...
in inky.js this is factored out into makeClumn. TBD if we need that here.
[ "in", "inky", ".", "js", "this", "is", "factored", "out", "into", "makeClumn", ".", "TBD", "if", "we", "need", "that", "here", "." ]
208ade8b9fa95afae0e81b8cd0bb23ab96371e5b
https://github.com/zurb/inky-rb/blob/208ade8b9fa95afae0e81b8cd0bb23ab96371e5b/lib/inky/component_factory.rb#L82-L100
train
gollum/gollum-lib
lib/gollum-lib/committer.rb
Gollum.Committer.index
def index @index ||= begin idx = @wiki.repo.index if (tree = options[:tree]) idx.read_tree(tree) elsif (parent = parents.first) idx.read_tree(parent.tree.id) end idx end end
ruby
def index @index ||= begin idx = @wiki.repo.index if (tree = options[:tree]) idx.read_tree(tree) elsif (parent = parents.first) idx.read_tree(parent.tree.id) end idx end end
[ "def", "index", "@index", "||=", "begin", "idx", "=", "@wiki", ".", "repo", ".", "index", "if", "(", "tree", "=", "options", "[", ":tree", "]", ")", "idx", ".", "read_tree", "(", "tree", ")", "elsif", "(", "parent", "=", "parents", ".", "first", ")...
Initializes the Committer. wiki - The Gollum::Wiki instance that is being updated. options - The commit Hash details: :message - The String commit message. :name - The String author full name. :email - The String email address. :parent - Optional Gollum::G...
[ "Initializes", "the", "Committer", "." ]
e811f79cb569f1bf0711947d49105db60421e2c1
https://github.com/gollum/gollum-lib/blob/e811f79cb569f1bf0711947d49105db60421e2c1/lib/gollum-lib/committer.rb#L39-L49
train
gollum/gollum-lib
lib/gollum-lib/committer.rb
Gollum.Committer.add_to_index
def add_to_index(dir, name, format, data, allow_same_ext = false) # spaces must be dashes dir.gsub!(' ', '-') name.gsub!(' ', '-') path = @wiki.page_file_name(name, format) dir = '/' if dir.strip.empty? fullpath = ::File.join(*[dir, path]) fullpath = fullpath[1..-1] if full...
ruby
def add_to_index(dir, name, format, data, allow_same_ext = false) # spaces must be dashes dir.gsub!(' ', '-') name.gsub!(' ', '-') path = @wiki.page_file_name(name, format) dir = '/' if dir.strip.empty? fullpath = ::File.join(*[dir, path]) fullpath = fullpath[1..-1] if full...
[ "def", "add_to_index", "(", "dir", ",", "name", ",", "format", ",", "data", ",", "allow_same_ext", "=", "false", ")", "# spaces must be dashes", "dir", ".", "gsub!", "(", "' '", ",", "'-'", ")", "name", ".", "gsub!", "(", "' '", ",", "'-'", ")", "path"...
Adds a page to the given Index. dir - The String subdirectory of the Gollum::Page without any prefix or suffix slashes (e.g. "foo/bar"). name - The String Gollum::Page filename_stripped. format - The Symbol Gollum::Page format. data - The String wiki data to store in the tree map. allow_same_ext ...
[ "Adds", "a", "page", "to", "the", "given", "Index", "." ]
e811f79cb569f1bf0711947d49105db60421e2c1
https://github.com/gollum/gollum-lib/blob/e811f79cb569f1bf0711947d49105db60421e2c1/lib/gollum-lib/committer.rb#L88-L130
train
gollum/gollum-lib
lib/gollum-lib/committer.rb
Gollum.Committer.commit
def commit sha1 = index.commit(@options[:message], parents, actor, nil, @wiki.ref) @callbacks.each do |cb| cb.call(self, sha1) end sha1 end
ruby
def commit sha1 = index.commit(@options[:message], parents, actor, nil, @wiki.ref) @callbacks.each do |cb| cb.call(self, sha1) end sha1 end
[ "def", "commit", "sha1", "=", "index", ".", "commit", "(", "@options", "[", ":message", "]", ",", "parents", ",", "actor", ",", "nil", ",", "@wiki", ".", "ref", ")", "@callbacks", ".", "each", "do", "|", "cb", "|", "cb", ".", "call", "(", "self", ...
Writes the commit to Git and runs the after_commit callbacks. Returns the String SHA1 of the new commit.
[ "Writes", "the", "commit", "to", "Git", "and", "runs", "the", "after_commit", "callbacks", "." ]
e811f79cb569f1bf0711947d49105db60421e2c1
https://github.com/gollum/gollum-lib/blob/e811f79cb569f1bf0711947d49105db60421e2c1/lib/gollum-lib/committer.rb#L169-L175
train
gollum/gollum-lib
lib/gollum-lib/committer.rb
Gollum.Committer.file_path_scheduled_for_deletion?
def file_path_scheduled_for_deletion?(map, path) parts = path.split('/') if parts.size == 1 deletions = map.keys.select { |k| !map[k] } deletions.any? { |d| d == parts.first } else part = parts.shift if (rest = map[part]) file_path_scheduled_for_deletion?(rest...
ruby
def file_path_scheduled_for_deletion?(map, path) parts = path.split('/') if parts.size == 1 deletions = map.keys.select { |k| !map[k] } deletions.any? { |d| d == parts.first } else part = parts.shift if (rest = map[part]) file_path_scheduled_for_deletion?(rest...
[ "def", "file_path_scheduled_for_deletion?", "(", "map", ",", "path", ")", "parts", "=", "path", ".", "split", "(", "'/'", ")", "if", "parts", ".", "size", "==", "1", "deletions", "=", "map", ".", "keys", ".", "select", "{", "|", "k", "|", "!", "map",...
Determine if a given file is scheduled to be deleted in the next commit for the given Index. map - The Hash map: key - The String directory or filename. val - The Hash submap or the String contents of the file. path - The String path of the file including extension. Returns the Boolean respons...
[ "Determine", "if", "a", "given", "file", "is", "scheduled", "to", "be", "deleted", "in", "the", "next", "commit", "for", "the", "given", "Index", "." ]
e811f79cb569f1bf0711947d49105db60421e2c1
https://github.com/gollum/gollum-lib/blob/e811f79cb569f1bf0711947d49105db60421e2c1/lib/gollum-lib/committer.rb#L222-L235
train
gollum/gollum-lib
lib/gollum-lib/committer.rb
Gollum.Committer.method_missing
def method_missing(name, *args) args.map! { |item| item.respond_to?(:force_encoding) ? item.force_encoding('ascii-8bit') : item } index.send(name, *args) end
ruby
def method_missing(name, *args) args.map! { |item| item.respond_to?(:force_encoding) ? item.force_encoding('ascii-8bit') : item } index.send(name, *args) end
[ "def", "method_missing", "(", "name", ",", "*", "args", ")", "args", ".", "map!", "{", "|", "item", "|", "item", ".", "respond_to?", "(", ":force_encoding", ")", "?", "item", ".", "force_encoding", "(", "'ascii-8bit'", ")", ":", "item", "}", "index", "...
Proxies methods t
[ "Proxies", "methods", "t" ]
e811f79cb569f1bf0711947d49105db60421e2c1
https://github.com/gollum/gollum-lib/blob/e811f79cb569f1bf0711947d49105db60421e2c1/lib/gollum-lib/committer.rb#L238-L241
train
gollum/gollum-lib
lib/gollum-lib/file.rb
Gollum.File.find
def find(name, version, try_on_disk = false) checked = name.downcase map = @wiki.tree_map_for(version) commit = version.is_a?(Gollum::Git::Commit) ? version : @wiki.commit_for(version) if (result = map.detect { |entry| entry.path.downcase == checked }) @path = name @vers...
ruby
def find(name, version, try_on_disk = false) checked = name.downcase map = @wiki.tree_map_for(version) commit = version.is_a?(Gollum::Git::Commit) ? version : @wiki.commit_for(version) if (result = map.detect { |entry| entry.path.downcase == checked }) @path = name @vers...
[ "def", "find", "(", "name", ",", "version", ",", "try_on_disk", "=", "false", ")", "checked", "=", "name", ".", "downcase", "map", "=", "@wiki", ".", "tree_map_for", "(", "version", ")", "commit", "=", "version", ".", "is_a?", "(", "Gollum", "::", "Git...
Find a file in the given Gollum repo. name - The full String path. version - The String version ID to find. try_on_disk - If true, try to return just a reference to a file that exists on the disk. Returns a Gollum::File or nil if the file could not be found. Note that if you specify try_on_disk...
[ "Find", "a", "file", "in", "the", "given", "Gollum", "repo", "." ]
e811f79cb569f1bf0711947d49105db60421e2c1
https://github.com/gollum/gollum-lib/blob/e811f79cb569f1bf0711947d49105db60421e2c1/lib/gollum-lib/file.rb#L138-L155
train
gollum/gollum-lib
lib/gollum-lib/blob_entry.rb
Gollum.BlobEntry.page
def page(wiki, commit) blob = self.blob(wiki.repo) page = wiki.page_class.new(wiki).populate(blob, self.dir) page.version = commit page end
ruby
def page(wiki, commit) blob = self.blob(wiki.repo) page = wiki.page_class.new(wiki).populate(blob, self.dir) page.version = commit page end
[ "def", "page", "(", "wiki", ",", "commit", ")", "blob", "=", "self", ".", "blob", "(", "wiki", ".", "repo", ")", "page", "=", "wiki", ".", "page_class", ".", "new", "(", "wiki", ")", ".", "populate", "(", "blob", ",", "self", ".", "dir", ")", "...
Gets a Page instance for this blob. wiki - Gollum::Wiki instance for the Gollum::Page Returns a Gollum::Page instance.
[ "Gets", "a", "Page", "instance", "for", "this", "blob", "." ]
e811f79cb569f1bf0711947d49105db60421e2c1
https://github.com/gollum/gollum-lib/blob/e811f79cb569f1bf0711947d49105db60421e2c1/lib/gollum-lib/blob_entry.rb#L49-L54
train
gollum/gollum-lib
lib/gollum-lib/blob_entry.rb
Gollum.BlobEntry.file
def file(wiki, commit) blob = self.blob(wiki.repo) file = wiki.file_class.new(wiki).populate(blob, self.dir) file.version = commit file end
ruby
def file(wiki, commit) blob = self.blob(wiki.repo) file = wiki.file_class.new(wiki).populate(blob, self.dir) file.version = commit file end
[ "def", "file", "(", "wiki", ",", "commit", ")", "blob", "=", "self", ".", "blob", "(", "wiki", ".", "repo", ")", "file", "=", "wiki", ".", "file_class", ".", "new", "(", "wiki", ")", ".", "populate", "(", "blob", ",", "self", ".", "dir", ")", "...
Gets a File instance for this blob. wiki - Gollum::Wiki instance for the Gollum::File Returns a Gollum::File instance.
[ "Gets", "a", "File", "instance", "for", "this", "blob", "." ]
e811f79cb569f1bf0711947d49105db60421e2c1
https://github.com/gollum/gollum-lib/blob/e811f79cb569f1bf0711947d49105db60421e2c1/lib/gollum-lib/blob_entry.rb#L61-L66
train
gollum/gollum-lib
lib/gollum-lib/markup.rb
Gollum.Markup.render_default
def render_default(data, format=:markdown, name='render_default.md') # set instance vars so we're able to render data without a wiki or page. @format = format @name = name chain = [:Metadata, :PlainText, :Emoji, :TOC, :RemoteCode, :Code, :Sanitize, :WSD, :Tags, :Render] filter_chain = ...
ruby
def render_default(data, format=:markdown, name='render_default.md') # set instance vars so we're able to render data without a wiki or page. @format = format @name = name chain = [:Metadata, :PlainText, :Emoji, :TOC, :RemoteCode, :Code, :Sanitize, :WSD, :Tags, :Render] filter_chain = ...
[ "def", "render_default", "(", "data", ",", "format", "=", ":markdown", ",", "name", "=", "'render_default.md'", ")", "# set instance vars so we're able to render data without a wiki or page.", "@format", "=", "format", "@name", "=", "name", "chain", "=", "[", ":Metadata...
Render data using default chain in the target format. data - the data to render format - format to use as a symbol name - name using the extension of the format Returns the processed data
[ "Render", "data", "using", "default", "chain", "in", "the", "target", "format", "." ]
e811f79cb569f1bf0711947d49105db60421e2c1
https://github.com/gollum/gollum-lib/blob/e811f79cb569f1bf0711947d49105db60421e2c1/lib/gollum-lib/markup.rb#L97-L109
train
gollum/gollum-lib
lib/gollum-lib/markup.rb
Gollum.Markup.process_chain
def process_chain(data, filter_chain) # First we extract the data through the chain... filter_chain.each do |filter| data = filter.extract(data) end # Then we process the data through the chain *backwards* filter_chain.reverse.each do |filter| data = filter.process(data) ...
ruby
def process_chain(data, filter_chain) # First we extract the data through the chain... filter_chain.each do |filter| data = filter.extract(data) end # Then we process the data through the chain *backwards* filter_chain.reverse.each do |filter| data = filter.process(data) ...
[ "def", "process_chain", "(", "data", ",", "filter_chain", ")", "# First we extract the data through the chain...", "filter_chain", ".", "each", "do", "|", "filter", "|", "data", "=", "filter", ".", "extract", "(", "data", ")", "end", "# Then we process the data throug...
Process the filter chain data - the data to send through the chain filter_chain - the chain to process Returns the formatted data
[ "Process", "the", "filter", "chain" ]
e811f79cb569f1bf0711947d49105db60421e2c1
https://github.com/gollum/gollum-lib/blob/e811f79cb569f1bf0711947d49105db60421e2c1/lib/gollum-lib/markup.rb#L117-L134
train
gollum/gollum-lib
lib/gollum-lib/markup.rb
Gollum.Markup.render
def render(no_follow = false, encoding = nil, include_levels = 10) @sanitize = no_follow ? @wiki.history_sanitizer : @wiki.sanitizer @encoding = encoding @include_levels = include_levels data = @data.dup filter_chain = @wiki.filter_chain.map do |r| ...
ruby
def render(no_follow = false, encoding = nil, include_levels = 10) @sanitize = no_follow ? @wiki.history_sanitizer : @wiki.sanitizer @encoding = encoding @include_levels = include_levels data = @data.dup filter_chain = @wiki.filter_chain.map do |r| ...
[ "def", "render", "(", "no_follow", "=", "false", ",", "encoding", "=", "nil", ",", "include_levels", "=", "10", ")", "@sanitize", "=", "no_follow", "?", "@wiki", ".", "history_sanitizer", ":", "@wiki", ".", "sanitizer", "@encoding", "=", "encoding", "@includ...
Render the content with Gollum wiki syntax on top of the file's own markup language. no_follow - Boolean that determines if rel="nofollow" is added to all <a> tags. encoding - Encoding Constant or String. Returns the formatted String content.
[ "Render", "the", "content", "with", "Gollum", "wiki", "syntax", "on", "top", "of", "the", "file", "s", "own", "markup", "language", "." ]
e811f79cb569f1bf0711947d49105db60421e2c1
https://github.com/gollum/gollum-lib/blob/e811f79cb569f1bf0711947d49105db60421e2c1/lib/gollum-lib/markup.rb#L144-L165
train
gollum/gollum-lib
lib/gollum-lib/markup.rb
Gollum.Markup.find_file
def find_file(name, version=@version) if name =~ /^\// @wiki.file(name[1..-1], version) else path = @dir == '.' ? name : ::File.join(@dir, name) @wiki.file(path, version) end end
ruby
def find_file(name, version=@version) if name =~ /^\// @wiki.file(name[1..-1], version) else path = @dir == '.' ? name : ::File.join(@dir, name) @wiki.file(path, version) end end
[ "def", "find_file", "(", "name", ",", "version", "=", "@version", ")", "if", "name", "=~", "/", "\\/", "/", "@wiki", ".", "file", "(", "name", "[", "1", "..", "-", "1", "]", ",", "version", ")", "else", "path", "=", "@dir", "==", "'.'", "?", "n...
Find the given file in the repo. name - The String absolute or relative path of the file. Returns the Gollum::File or nil if none was found.
[ "Find", "the", "given", "file", "in", "the", "repo", "." ]
e811f79cb569f1bf0711947d49105db60421e2c1
https://github.com/gollum/gollum-lib/blob/e811f79cb569f1bf0711947d49105db60421e2c1/lib/gollum-lib/markup.rb#L172-L179
train
gollum/gollum-lib
lib/gollum-lib/wiki.rb
Gollum.Wiki.remove_filter
def remove_filter(name) unless name.is_a? Symbol raise ArgumentError, "Invalid filter name #{name.inspect} (must be a symbol)" end unless @filter_chain.delete(name) raise ArgumentError, "#{name.inspect} not found in filter chain" end end
ruby
def remove_filter(name) unless name.is_a? Symbol raise ArgumentError, "Invalid filter name #{name.inspect} (must be a symbol)" end unless @filter_chain.delete(name) raise ArgumentError, "#{name.inspect} not found in filter chain" end end
[ "def", "remove_filter", "(", "name", ")", "unless", "name", ".", "is_a?", "Symbol", "raise", "ArgumentError", ",", "\"Invalid filter name #{name.inspect} (must be a symbol)\"", "end", "unless", "@filter_chain", ".", "delete", "(", "name", ")", "raise", "ArgumentError", ...
Remove the named filter from the filter chain. Returns nothing. Raises `ArgumentError` if the named filter doesn't exist in the chain.
[ "Remove", "the", "named", "filter", "from", "the", "filter", "chain", "." ]
e811f79cb569f1bf0711947d49105db60421e2c1
https://github.com/gollum/gollum-lib/blob/e811f79cb569f1bf0711947d49105db60421e2c1/lib/gollum-lib/wiki.rb#L775-L785
train
gollum/gollum-lib
lib/gollum-lib/wiki.rb
Gollum.Wiki.tree_list
def tree_list(ref) if (sha = @access.ref_to_sha(ref)) commit = @access.commit(sha) tree_map_for(sha).inject([]) do |list, entry| next list unless @page_class.valid_page_name?(entry.name) list << entry.page(self, commit) end else [] end end
ruby
def tree_list(ref) if (sha = @access.ref_to_sha(ref)) commit = @access.commit(sha) tree_map_for(sha).inject([]) do |list, entry| next list unless @page_class.valid_page_name?(entry.name) list << entry.page(self, commit) end else [] end end
[ "def", "tree_list", "(", "ref", ")", "if", "(", "sha", "=", "@access", ".", "ref_to_sha", "(", "ref", ")", ")", "commit", "=", "@access", ".", "commit", "(", "sha", ")", "tree_map_for", "(", "sha", ")", ".", "inject", "(", "[", "]", ")", "do", "|...
Fill an array with a list of pages. ref - A String ref that is either a commit SHA or references one. Returns a flat Array of Gollum::Page instances.
[ "Fill", "an", "array", "with", "a", "list", "of", "pages", "." ]
e811f79cb569f1bf0711947d49105db60421e2c1
https://github.com/gollum/gollum-lib/blob/e811f79cb569f1bf0711947d49105db60421e2c1/lib/gollum-lib/wiki.rb#L859-L869
train
gollum/gollum-lib
lib/gollum-lib/wiki.rb
Gollum.Wiki.file_list
def file_list(ref) if (sha = @access.ref_to_sha(ref)) commit = @access.commit(sha) tree_map_for(sha).inject([]) do |list, entry| next list if entry.name.start_with?('_') next list if @page_class.valid_page_name?(entry.name) list << entry.file(self, commit) end...
ruby
def file_list(ref) if (sha = @access.ref_to_sha(ref)) commit = @access.commit(sha) tree_map_for(sha).inject([]) do |list, entry| next list if entry.name.start_with?('_') next list if @page_class.valid_page_name?(entry.name) list << entry.file(self, commit) end...
[ "def", "file_list", "(", "ref", ")", "if", "(", "sha", "=", "@access", ".", "ref_to_sha", "(", "ref", ")", ")", "commit", "=", "@access", ".", "commit", "(", "sha", ")", "tree_map_for", "(", "sha", ")", ".", "inject", "(", "[", "]", ")", "do", "|...
Fill an array with a list of files. ref - A String ref that is either a commit SHA or references one. Returns a flat Array of Gollum::File instances.
[ "Fill", "an", "array", "with", "a", "list", "of", "files", "." ]
e811f79cb569f1bf0711947d49105db60421e2c1
https://github.com/gollum/gollum-lib/blob/e811f79cb569f1bf0711947d49105db60421e2c1/lib/gollum-lib/wiki.rb#L876-L887
train
gollum/gollum-lib
lib/gollum-lib/wiki.rb
Gollum.Wiki.tree_map_for
def tree_map_for(ref, ignore_page_file_dir=false) if ignore_page_file_dir && !@page_file_dir.nil? @root_access ||= GitAccess.new(path, nil, @repo_is_bare) @root_access.tree(ref) else @access.tree(ref) end rescue Gollum::Git::NoSuchShaFound [] end
ruby
def tree_map_for(ref, ignore_page_file_dir=false) if ignore_page_file_dir && !@page_file_dir.nil? @root_access ||= GitAccess.new(path, nil, @repo_is_bare) @root_access.tree(ref) else @access.tree(ref) end rescue Gollum::Git::NoSuchShaFound [] end
[ "def", "tree_map_for", "(", "ref", ",", "ignore_page_file_dir", "=", "false", ")", "if", "ignore_page_file_dir", "&&", "!", "@page_file_dir", ".", "nil?", "@root_access", "||=", "GitAccess", ".", "new", "(", "path", ",", "nil", ",", "@repo_is_bare", ")", "@roo...
Finds a full listing of files and their blob SHA for a given ref. Each listing is cached based on its actual commit SHA. ref - A String ref that is either a commit SHA or references one. ignore_page_file_dir - Boolean, if true, searches all files within the git repo, regardless of dir/subdir Returns an Array of ...
[ "Finds", "a", "full", "listing", "of", "files", "and", "their", "blob", "SHA", "for", "a", "given", "ref", ".", "Each", "listing", "is", "cached", "based", "on", "its", "actual", "commit", "SHA", "." ]
e811f79cb569f1bf0711947d49105db60421e2c1
https://github.com/gollum/gollum-lib/blob/e811f79cb569f1bf0711947d49105db60421e2c1/lib/gollum-lib/wiki.rb#L951-L960
train
gollum/gollum-lib
lib/gollum-lib/git_access.rb
Gollum.GitAccess.get_cache
def get_cache(name, key) cache = instance_variable_get("@#{name}_map") value = cache[key] if value.nil? && block_given? set_cache(name, key, value = yield) end value == :_nil ? nil : value end
ruby
def get_cache(name, key) cache = instance_variable_get("@#{name}_map") value = cache[key] if value.nil? && block_given? set_cache(name, key, value = yield) end value == :_nil ? nil : value end
[ "def", "get_cache", "(", "name", ",", "key", ")", "cache", "=", "instance_variable_get", "(", "\"@#{name}_map\"", ")", "value", "=", "cache", "[", "key", "]", "if", "value", ".", "nil?", "&&", "block_given?", "set_cache", "(", "name", ",", "key", ",", "v...
Attempts to get the given data from a cache. If it doesn't exist, it'll pass the results of the yielded block to the cache for future accesses. name - The cache prefix used in building the full cache key. key - The unique cache key suffix, usually a String Git SHA. Yields a block to pass to the cache. Returns ...
[ "Attempts", "to", "get", "the", "given", "data", "from", "a", "cache", ".", "If", "it", "doesn", "t", "exist", "it", "ll", "pass", "the", "results", "of", "the", "yielded", "block", "to", "the", "cache", "for", "future", "accesses", "." ]
e811f79cb569f1bf0711947d49105db60421e2c1
https://github.com/gollum/gollum-lib/blob/e811f79cb569f1bf0711947d49105db60421e2c1/lib/gollum-lib/git_access.rb#L201-L208
train
gollum/gollum-lib
lib/gollum-lib/git_access.rb
Gollum.GitAccess.parse_tree_line
def parse_tree_line(line) mode, _type, sha, size, *name = line.split(/\s+/) BlobEntry.new(sha, name.join(' '), size.to_i, mode.to_i(8)) end
ruby
def parse_tree_line(line) mode, _type, sha, size, *name = line.split(/\s+/) BlobEntry.new(sha, name.join(' '), size.to_i, mode.to_i(8)) end
[ "def", "parse_tree_line", "(", "line", ")", "mode", ",", "_type", ",", "sha", ",", "size", ",", "*", "name", "=", "line", ".", "split", "(", "/", "\\s", "/", ")", "BlobEntry", ".", "new", "(", "sha", ",", "name", ".", "join", "(", "' '", ")", "...
Parses a line of output from the `ls-tree` command. line - A String line of output: "100644 blob 839c2291b30495b9a882c17d08254d3c90d8fb53 Home.md" Returns an Array of BlobEntry instances.
[ "Parses", "a", "line", "of", "output", "from", "the", "ls", "-", "tree", "command", "." ]
e811f79cb569f1bf0711947d49105db60421e2c1
https://github.com/gollum/gollum-lib/blob/e811f79cb569f1bf0711947d49105db60421e2c1/lib/gollum-lib/git_access.rb#L228-L231
train
gollum/gollum-lib
lib/gollum-lib/page.rb
Gollum.Page.find
def find(name, version, dir = nil, exact = false) map = @wiki.tree_map_for(version.to_s) if (page = find_page_in_tree(map, name, dir, exact)) page.version = version.is_a?(Gollum::Git::Commit) ? version : @wiki.commit_for(version) page.historical = page.version.to_s == version....
ruby
def find(name, version, dir = nil, exact = false) map = @wiki.tree_map_for(version.to_s) if (page = find_page_in_tree(map, name, dir, exact)) page.version = version.is_a?(Gollum::Git::Commit) ? version : @wiki.commit_for(version) page.historical = page.version.to_s == version....
[ "def", "find", "(", "name", ",", "version", ",", "dir", "=", "nil", ",", "exact", "=", "false", ")", "map", "=", "@wiki", ".", "tree_map_for", "(", "version", ".", "to_s", ")", "if", "(", "page", "=", "find_page_in_tree", "(", "map", ",", "name", "...
Find a page in the given Gollum repo. name - The human or canonical String page name to find. version - The String version ID to find. Returns a Gollum::Page or nil if the page could not be found.
[ "Find", "a", "page", "in", "the", "given", "Gollum", "repo", "." ]
e811f79cb569f1bf0711947d49105db60421e2c1
https://github.com/gollum/gollum-lib/blob/e811f79cb569f1bf0711947d49105db60421e2c1/lib/gollum-lib/page.rb#L392-L401
train
gollum/gollum-lib
lib/gollum-lib/page.rb
Gollum.Page.find_page_in_tree
def find_page_in_tree(map, name, checked_dir = nil, exact = false) return nil if !map || name.to_s.empty? checked_dir = BlobEntry.normalize_dir(checked_dir) checked_dir = '' if exact && checked_dir.nil? name = ::File.join(checked_dir, name) if checked_dir map.each do |entry| ...
ruby
def find_page_in_tree(map, name, checked_dir = nil, exact = false) return nil if !map || name.to_s.empty? checked_dir = BlobEntry.normalize_dir(checked_dir) checked_dir = '' if exact && checked_dir.nil? name = ::File.join(checked_dir, name) if checked_dir map.each do |entry| ...
[ "def", "find_page_in_tree", "(", "map", ",", "name", ",", "checked_dir", "=", "nil", ",", "exact", "=", "false", ")", "return", "nil", "if", "!", "map", "||", "name", ".", "to_s", ".", "empty?", "checked_dir", "=", "BlobEntry", ".", "normalize_dir", "(",...
Find a page in a given tree. map - The Array tree map from Wiki#tree_map. name - The canonical String page name. checked_dir - Optional String of the directory a matching page needs to be in. The string should Returns a Gollum::Page or nil if the page could not be found.
[ "Find", "a", "page", "in", "a", "given", "tree", "." ]
e811f79cb569f1bf0711947d49105db60421e2c1
https://github.com/gollum/gollum-lib/blob/e811f79cb569f1bf0711947d49105db60421e2c1/lib/gollum-lib/page.rb#L411-L426
train
gollum/gollum-lib
lib/gollum-lib/page.rb
Gollum.Page.tree_path
def tree_path(treemap, tree) if (ptree = treemap[tree]) tree_path(treemap, ptree) + '/' + tree.name else '' end end
ruby
def tree_path(treemap, tree) if (ptree = treemap[tree]) tree_path(treemap, ptree) + '/' + tree.name else '' end end
[ "def", "tree_path", "(", "treemap", ",", "tree", ")", "if", "(", "ptree", "=", "treemap", "[", "tree", "]", ")", "tree_path", "(", "treemap", ",", "ptree", ")", "+", "'/'", "+", "tree", ".", "name", "else", "''", "end", "end" ]
The full directory path for the given tree. treemap - The Hash treemap containing parentage information. tree - The Gollum::Git::Tree for which to compute the path. Returns the String path.
[ "The", "full", "directory", "path", "for", "the", "given", "tree", "." ]
e811f79cb569f1bf0711947d49105db60421e2c1
https://github.com/gollum/gollum-lib/blob/e811f79cb569f1bf0711947d49105db60421e2c1/lib/gollum-lib/page.rb#L446-L452
train
gollum/gollum-lib
lib/gollum-lib/page.rb
Gollum.Page.page_match
def page_match(name, path) if (match = self.class.valid_filename?(path)) @wiki.ws_subs.each do |sub| return true if Page.cname(name).downcase == Page.cname(match, sub).downcase end end false end
ruby
def page_match(name, path) if (match = self.class.valid_filename?(path)) @wiki.ws_subs.each do |sub| return true if Page.cname(name).downcase == Page.cname(match, sub).downcase end end false end
[ "def", "page_match", "(", "name", ",", "path", ")", "if", "(", "match", "=", "self", ".", "class", ".", "valid_filename?", "(", "path", ")", ")", "@wiki", ".", "ws_subs", ".", "each", "do", "|", "sub", "|", "return", "true", "if", "Page", ".", "cna...
Compare the canonicalized versions of the two names. name - The human or canonical String page name. path - the String path on disk (including file extension). Returns a Boolean.
[ "Compare", "the", "canonicalized", "versions", "of", "the", "two", "names", "." ]
e811f79cb569f1bf0711947d49105db60421e2c1
https://github.com/gollum/gollum-lib/blob/e811f79cb569f1bf0711947d49105db60421e2c1/lib/gollum-lib/page.rb#L460-L467
train
lessonly/scim_rails
app/controllers/concerns/scim_rails/response.rb
ScimRails.Response.find_value
def find_value(user, object) case object when Hash object.each.with_object({}) do |(key, value), hash| hash[key] = find_value(user, value) end when Array object.map do |value| find_value(user, value) end when Symbol user.public_send(obj...
ruby
def find_value(user, object) case object when Hash object.each.with_object({}) do |(key, value), hash| hash[key] = find_value(user, value) end when Array object.map do |value| find_value(user, value) end when Symbol user.public_send(obj...
[ "def", "find_value", "(", "user", ",", "object", ")", "case", "object", "when", "Hash", "object", ".", "each", ".", "with_object", "(", "{", "}", ")", "do", "|", "(", "key", ",", "value", ")", ",", "hash", "|", "hash", "[", "key", "]", "=", "find...
`find_value` is a recursive method that takes a "user" and a "user schema" and replaces any symbols in the schema with the corresponding value from the user. Given a schema with symbols, `find_value` will search through the object for the symbols, send those symbols to the model, and replace the symbol with the re...
[ "find_value", "is", "a", "recursive", "method", "that", "takes", "a", "user", "and", "a", "user", "schema", "and", "replaces", "any", "symbols", "in", "the", "schema", "with", "the", "corresponding", "value", "from", "the", "user", ".", "Given", "a", "sche...
085e0aae5da72d719f8d42b6785710bd97b0a8a4
https://github.com/lessonly/scim_rails/blob/085e0aae5da72d719f8d42b6785710bd97b0a8a4/app/controllers/concerns/scim_rails/response.rb#L64-L79
train
lessonly/scim_rails
app/controllers/scim_rails/scim_users_controller.rb
ScimRails.ScimUsersController.path_for
def path_for(attribute, object = ScimRails.config.mutable_user_attributes_schema, path = []) at_path = path.empty? ? object : object.dig(*path) return path if at_path == attribute case at_path when Hash at_path.each do |key, value| found_path = path_for(attribute, object, [*pa...
ruby
def path_for(attribute, object = ScimRails.config.mutable_user_attributes_schema, path = []) at_path = path.empty? ? object : object.dig(*path) return path if at_path == attribute case at_path when Hash at_path.each do |key, value| found_path = path_for(attribute, object, [*pa...
[ "def", "path_for", "(", "attribute", ",", "object", "=", "ScimRails", ".", "config", ".", "mutable_user_attributes_schema", ",", "path", "=", "[", "]", ")", "at_path", "=", "path", ".", "empty?", "?", "object", ":", "object", ".", "dig", "(", "path", ")"...
`path_for` is a recursive method used to find the "path" for `.dig` to take when looking for a given attribute in the params. Example: `path_for(:name)` should return an array that looks like [:names, 0, :givenName]. `.dig` can then use that path against the params to translate the :name attribute to "John".
[ "path_for", "is", "a", "recursive", "method", "used", "to", "find", "the", "path", "for", ".", "dig", "to", "take", "when", "looking", "for", "a", "given", "attribute", "in", "the", "params", "." ]
085e0aae5da72d719f8d42b6785710bd97b0a8a4
https://github.com/lessonly/scim_rails/blob/085e0aae5da72d719f8d42b6785710bd97b0a8a4/app/controllers/scim_rails/scim_users_controller.rb#L81-L99
train
jondkinney/docusign_rest
lib/docusign_rest/client.rb
DocusignRest.Client.send_envelope
def send_envelope(envelope_id) content_type = { 'Content-Type' => 'application/json' } post_body = { status: 'sent' }.to_json uri = build_uri("/accounts/#{acct_id}/envelopes/#{envelope_id}") http = initialize_net_http_ssl(uri) request = Net::HTTP::Put.new(uri.request_uri, ...
ruby
def send_envelope(envelope_id) content_type = { 'Content-Type' => 'application/json' } post_body = { status: 'sent' }.to_json uri = build_uri("/accounts/#{acct_id}/envelopes/#{envelope_id}") http = initialize_net_http_ssl(uri) request = Net::HTTP::Put.new(uri.request_uri, ...
[ "def", "send_envelope", "(", "envelope_id", ")", "content_type", "=", "{", "'Content-Type'", "=>", "'application/json'", "}", "post_body", "=", "{", "status", ":", "'sent'", "}", ".", "to_json", "uri", "=", "build_uri", "(", "\"/accounts/#{acct_id}/envelopes/#{envel...
Public marks an envelope as sent envelope_id - ID of the envelope which you want to send Returns the response (success or failure).
[ "Public", "marks", "an", "envelope", "as", "sent" ]
f93eaff7b649336ef54fe5310c4c00d74531e5e1
https://github.com/jondkinney/docusign_rest/blob/f93eaff7b649336ef54fe5310c4c00d74531e5e1/lib/docusign_rest/client.rb#L1009-L1024
train
jondkinney/docusign_rest
lib/docusign_rest/client.rb
DocusignRest.Client.get_recipient_view
def get_recipient_view(options={}) content_type = { 'Content-Type' => 'application/json' } content_type.merge(options[:headers]) if options[:headers] post_body = { authenticationMethod: 'email', clientUserId: options[:client_id] || options[:email], email: ...
ruby
def get_recipient_view(options={}) content_type = { 'Content-Type' => 'application/json' } content_type.merge(options[:headers]) if options[:headers] post_body = { authenticationMethod: 'email', clientUserId: options[:client_id] || options[:email], email: ...
[ "def", "get_recipient_view", "(", "options", "=", "{", "}", ")", "content_type", "=", "{", "'Content-Type'", "=>", "'application/json'", "}", "content_type", ".", "merge", "(", "options", "[", ":headers", "]", ")", "if", "options", "[", ":headers", "]", "pos...
Public returns the URL for embedded signing envelope_id - the ID of the envelope you wish to use for embedded signing name - the name of the signer email - the email of the recipient return_url - the URL you want the user to be directed to after he or she completes the document signing...
[ "Public", "returns", "the", "URL", "for", "embedded", "signing" ]
f93eaff7b649336ef54fe5310c4c00d74531e5e1
https://github.com/jondkinney/docusign_rest/blob/f93eaff7b649336ef54fe5310c4c00d74531e5e1/lib/docusign_rest/client.rb#L1091-L1113
train
jondkinney/docusign_rest
lib/docusign_rest/client.rb
DocusignRest.Client.get_envelope_recipients
def get_envelope_recipients(options={}) content_type = { 'Content-Type' => 'application/json' } content_type.merge(options[:headers]) if options[:headers] include_tabs = options[:include_tabs] || false include_extended = options[:include_extended] || false uri = build_uri("/accounts/#{acc...
ruby
def get_envelope_recipients(options={}) content_type = { 'Content-Type' => 'application/json' } content_type.merge(options[:headers]) if options[:headers] include_tabs = options[:include_tabs] || false include_extended = options[:include_extended] || false uri = build_uri("/accounts/#{acc...
[ "def", "get_envelope_recipients", "(", "options", "=", "{", "}", ")", "content_type", "=", "{", "'Content-Type'", "=>", "'application/json'", "}", "content_type", ".", "merge", "(", "options", "[", ":headers", "]", ")", "if", "options", "[", ":headers", "]", ...
Public returns the envelope recipients for a given envelope include_tabs - boolean, determines if the tabs for each signer will be returned in the response, defaults to false. envelope_id - ID of the envelope for which you want to retrieve the signer info headers - optional has...
[ "Public", "returns", "the", "envelope", "recipients", "for", "a", "given", "envelope" ]
f93eaff7b649336ef54fe5310c4c00d74531e5e1
https://github.com/jondkinney/docusign_rest/blob/f93eaff7b649336ef54fe5310c4c00d74531e5e1/lib/docusign_rest/client.rb#L1180-L1193
train
jondkinney/docusign_rest
lib/docusign_rest/client.rb
DocusignRest.Client.get_page_image
def get_page_image(options={}) envelope_id = options[:envelope_id] document_id = options[:document_id] page_number = options[:page_number] uri = build_uri("/accounts/#{acct_id}/envelopes/#{envelope_id}/documents/#{document_id}/pages/#{page_number}/page_image") http = initialize_net_h...
ruby
def get_page_image(options={}) envelope_id = options[:envelope_id] document_id = options[:document_id] page_number = options[:page_number] uri = build_uri("/accounts/#{acct_id}/envelopes/#{envelope_id}/documents/#{document_id}/pages/#{page_number}/page_image") http = initialize_net_h...
[ "def", "get_page_image", "(", "options", "=", "{", "}", ")", "envelope_id", "=", "options", "[", ":envelope_id", "]", "document_id", "=", "options", "[", ":document_id", "]", "page_number", "=", "options", "[", ":page_number", "]", "uri", "=", "build_uri", "...
Public retrieves a png of a page of a document in an envelope envelope_id - ID of the envelope from which the doc will be retrieved document_id - ID of the document to retrieve page_number - page number to retrieve Returns the png as a bytestream
[ "Public", "retrieves", "a", "png", "of", "a", "page", "of", "a", "document", "in", "an", "envelope" ]
f93eaff7b649336ef54fe5310c4c00d74531e5e1
https://github.com/jondkinney/docusign_rest/blob/f93eaff7b649336ef54fe5310c4c00d74531e5e1/lib/docusign_rest/client.rb#L1250-L1262
train
jondkinney/docusign_rest
lib/docusign_rest/client.rb
DocusignRest.Client.get_document_from_envelope
def get_document_from_envelope(options={}) content_type = { 'Content-Type' => 'application/json' } content_type.merge(options[:headers]) if options[:headers] uri = build_uri("/accounts/#{acct_id}/envelopes/#{options[:envelope_id]}/documents/#{options[:document_id]}") http = initialize_net_http...
ruby
def get_document_from_envelope(options={}) content_type = { 'Content-Type' => 'application/json' } content_type.merge(options[:headers]) if options[:headers] uri = build_uri("/accounts/#{acct_id}/envelopes/#{options[:envelope_id]}/documents/#{options[:document_id]}") http = initialize_net_http...
[ "def", "get_document_from_envelope", "(", "options", "=", "{", "}", ")", "content_type", "=", "{", "'Content-Type'", "=>", "'application/json'", "}", "content_type", ".", "merge", "(", "options", "[", ":headers", "]", ")", "if", "options", "[", ":headers", "]"...
Public retrieves the attached file from a given envelope envelope_id - ID of the envelope from which the doc will be retrieved document_id - ID of the document to retrieve local_save_path - Local absolute path to save the doc to including the filename itself headers - Option...
[ "Public", "retrieves", "the", "attached", "file", "from", "a", "given", "envelope" ]
f93eaff7b649336ef54fe5310c4c00d74531e5e1
https://github.com/jondkinney/docusign_rest/blob/f93eaff7b649336ef54fe5310c4c00d74531e5e1/lib/docusign_rest/client.rb#L1283-L1303
train
jondkinney/docusign_rest
lib/docusign_rest/client.rb
DocusignRest.Client.delete_envelope_recipient
def delete_envelope_recipient(options={}) content_type = {'Content-Type' => 'application/json'} content_type.merge(options[:headers]) if options[:headers] uri = build_uri("/accounts/#{@acct_id}/envelopes/#{options[:envelope_id]}/recipients") post_body = "{ \"signers\" : [{\"recipientId\...
ruby
def delete_envelope_recipient(options={}) content_type = {'Content-Type' => 'application/json'} content_type.merge(options[:headers]) if options[:headers] uri = build_uri("/accounts/#{@acct_id}/envelopes/#{options[:envelope_id]}/recipients") post_body = "{ \"signers\" : [{\"recipientId\...
[ "def", "delete_envelope_recipient", "(", "options", "=", "{", "}", ")", "content_type", "=", "{", "'Content-Type'", "=>", "'application/json'", "}", "content_type", ".", "merge", "(", "options", "[", ":headers", "]", ")", "if", "options", "[", ":headers", "]",...
Public deletes a recipient for a given envelope envelope_id - ID of the envelope for which you want to retrieve the signer info recipient_id - ID of the recipient to delete Returns a hash of recipients with an error code for any recipients that were not successfully deleted.
[ "Public", "deletes", "a", "recipient", "for", "a", "given", "envelope" ]
f93eaff7b649336ef54fe5310c4c00d74531e5e1
https://github.com/jondkinney/docusign_rest/blob/f93eaff7b649336ef54fe5310c4c00d74531e5e1/lib/docusign_rest/client.rb#L1596-L1612
train
jondkinney/docusign_rest
lib/docusign_rest/client.rb
DocusignRest.Client.void_envelope
def void_envelope(options = {}) content_type = { 'Content-Type' => 'application/json' } content_type.merge(options[:headers]) if options[:headers] post_body = { "status" =>"voided", "voidedReason" => options[:voided_reason] || "No reason provided." }.to_json uri = bui...
ruby
def void_envelope(options = {}) content_type = { 'Content-Type' => 'application/json' } content_type.merge(options[:headers]) if options[:headers] post_body = { "status" =>"voided", "voidedReason" => options[:voided_reason] || "No reason provided." }.to_json uri = bui...
[ "def", "void_envelope", "(", "options", "=", "{", "}", ")", "content_type", "=", "{", "'Content-Type'", "=>", "'application/json'", "}", "content_type", ".", "merge", "(", "options", "[", ":headers", "]", ")", "if", "options", "[", ":headers", "]", "post_bod...
Public voids an in-process envelope envelope_id - ID of the envelope to be voided voided_reason - Optional reason for the envelope being voided Returns the response (success or failure).
[ "Public", "voids", "an", "in", "-", "process", "envelope" ]
f93eaff7b649336ef54fe5310c4c00d74531e5e1
https://github.com/jondkinney/docusign_rest/blob/f93eaff7b649336ef54fe5310c4c00d74531e5e1/lib/docusign_rest/client.rb#L1621-L1638
train
cryptape/ruby-ethereum
lib/ethereum/block.rb
Ethereum.Block.validate_uncles
def validate_uncles return false if Utils.keccak256_rlp(uncles) != uncles_hash return false if uncles.size > config[:max_uncles] uncles.each do |uncle| raise InvalidUncles, "Cannot find uncle prevhash in db" unless db.include?(uncle.prevhash) if uncle.number == number logger...
ruby
def validate_uncles return false if Utils.keccak256_rlp(uncles) != uncles_hash return false if uncles.size > config[:max_uncles] uncles.each do |uncle| raise InvalidUncles, "Cannot find uncle prevhash in db" unless db.include?(uncle.prevhash) if uncle.number == number logger...
[ "def", "validate_uncles", "return", "false", "if", "Utils", ".", "keccak256_rlp", "(", "uncles", ")", "!=", "uncles_hash", "return", "false", "if", "uncles", ".", "size", ">", "config", "[", ":max_uncles", "]", "uncles", ".", "each", "do", "|", "uncle", "|...
Validate the uncles of this block.
[ "Validate", "the", "uncles", "of", "this", "block", "." ]
763f8651085ba145355a290da716884c7625a941
https://github.com/cryptape/ruby-ethereum/blob/763f8651085ba145355a290da716884c7625a941/lib/ethereum/block.rb#L351-L398
train
cryptape/ruby-ethereum
lib/ethereum/block.rb
Ethereum.Block.add_transaction_to_list
def add_transaction_to_list(tx) k = RLP.encode @transaction_count @transactions[k] = RLP.encode(tx) r = mk_transaction_receipt tx @receipts[k] = RLP.encode(r) self.bloom |= r.bloom @transaction_count += 1 end
ruby
def add_transaction_to_list(tx) k = RLP.encode @transaction_count @transactions[k] = RLP.encode(tx) r = mk_transaction_receipt tx @receipts[k] = RLP.encode(r) self.bloom |= r.bloom @transaction_count += 1 end
[ "def", "add_transaction_to_list", "(", "tx", ")", "k", "=", "RLP", ".", "encode", "@transaction_count", "@transactions", "[", "k", "]", "=", "RLP", ".", "encode", "(", "tx", ")", "r", "=", "mk_transaction_receipt", "tx", "@receipts", "[", "k", "]", "=", ...
Add a transaction to the transaction trie. Note that this does not execute anything, i.e. the state is not updated.
[ "Add", "a", "transaction", "to", "the", "transaction", "trie", "." ]
763f8651085ba145355a290da716884c7625a941
https://github.com/cryptape/ruby-ethereum/blob/763f8651085ba145355a290da716884c7625a941/lib/ethereum/block.rb#L418-L427
train
cryptape/ruby-ethereum
lib/ethereum/block.rb
Ethereum.Block.get_transaction
def get_transaction(num) index = RLP.encode num tx = @transactions.get index raise IndexError, "Transaction does not exist" if tx == Trie::BLANK_NODE RLP.decode tx, sedes: Transaction end
ruby
def get_transaction(num) index = RLP.encode num tx = @transactions.get index raise IndexError, "Transaction does not exist" if tx == Trie::BLANK_NODE RLP.decode tx, sedes: Transaction end
[ "def", "get_transaction", "(", "num", ")", "index", "=", "RLP", ".", "encode", "num", "tx", "=", "@transactions", ".", "get", "index", "raise", "IndexError", ",", "\"Transaction does not exist\"", "if", "tx", "==", "Trie", "::", "BLANK_NODE", "RLP", ".", "de...
Get the `num`th transaction in this block. @raise [IndexError] if the transaction does not exist
[ "Get", "the", "num", "th", "transaction", "in", "this", "block", "." ]
763f8651085ba145355a290da716884c7625a941
https://github.com/cryptape/ruby-ethereum/blob/763f8651085ba145355a290da716884c7625a941/lib/ethereum/block.rb#L537-L543
train
cryptape/ruby-ethereum
lib/ethereum/block.rb
Ethereum.Block.finalize
def finalize delta = @config[:block_reward] + @config[:nephew_reward] * uncles.size delta_balance coinbase, delta self.ether_delta += delta uncles.each do |uncle| r = @config[:block_reward] * (@config[:uncle_depth_penalty_factor] + uncle.number - number) / @config[:uncle_depth_penalty_...
ruby
def finalize delta = @config[:block_reward] + @config[:nephew_reward] * uncles.size delta_balance coinbase, delta self.ether_delta += delta uncles.each do |uncle| r = @config[:block_reward] * (@config[:uncle_depth_penalty_factor] + uncle.number - number) / @config[:uncle_depth_penalty_...
[ "def", "finalize", "delta", "=", "@config", "[", ":block_reward", "]", "+", "@config", "[", ":nephew_reward", "]", "*", "uncles", ".", "size", "delta_balance", "coinbase", ",", "delta", "self", ".", "ether_delta", "+=", "delta", "uncles", ".", "each", "do", ...
Apply rewards and commit.
[ "Apply", "rewards", "and", "commit", "." ]
763f8651085ba145355a290da716884c7625a941
https://github.com/cryptape/ruby-ethereum/blob/763f8651085ba145355a290da716884c7625a941/lib/ethereum/block.rb#L579-L593
train
cryptape/ruby-ethereum
lib/ethereum/block.rb
Ethereum.Block.to_h
def to_h(with_state: false, full_transactions: false, with_storage_roots: false, with_uncles: false) b = { header: header.to_h } txlist = [] get_transactions.each_with_index do |tx, i| receipt_rlp = @receipts[RLP.encode(i)] receipt = RLP.decode receipt_rlp, sedes: Receipt txjs...
ruby
def to_h(with_state: false, full_transactions: false, with_storage_roots: false, with_uncles: false) b = { header: header.to_h } txlist = [] get_transactions.each_with_index do |tx, i| receipt_rlp = @receipts[RLP.encode(i)] receipt = RLP.decode receipt_rlp, sedes: Receipt txjs...
[ "def", "to_h", "(", "with_state", ":", "false", ",", "full_transactions", ":", "false", ",", "with_storage_roots", ":", "false", ",", "with_uncles", ":", "false", ")", "b", "=", "{", "header", ":", "header", ".", "to_h", "}", "txlist", "=", "[", "]", "...
Serialize the block to a readable hash. @param with_state [Bool] include state for all accounts @param full_transactions [Bool] include serialized transactions (hashes otherwise) @param with_storage_roots [Bool] if account states are included also include their storage roots @param with_uncles [Bool] include...
[ "Serialize", "the", "block", "to", "a", "readable", "hash", "." ]
763f8651085ba145355a290da716884c7625a941
https://github.com/cryptape/ruby-ethereum/blob/763f8651085ba145355a290da716884c7625a941/lib/ethereum/block.rb#L607-L641
train
cryptape/ruby-ethereum
lib/ethereum/block.rb
Ethereum.Block.get_parent
def get_parent raise UnknownParentError, "Genesis block has no parent" if number == 0 Block.find env, prevhash rescue KeyError raise UnknownParentError, Utils.encode_hex(prevhash) end
ruby
def get_parent raise UnknownParentError, "Genesis block has no parent" if number == 0 Block.find env, prevhash rescue KeyError raise UnknownParentError, Utils.encode_hex(prevhash) end
[ "def", "get_parent", "raise", "UnknownParentError", ",", "\"Genesis block has no parent\"", "if", "number", "==", "0", "Block", ".", "find", "env", ",", "prevhash", "rescue", "KeyError", "raise", "UnknownParentError", ",", "Utils", ".", "encode_hex", "(", "prevhash"...
Get the parent of this block.
[ "Get", "the", "parent", "of", "this", "block", "." ]
763f8651085ba145355a290da716884c7625a941
https://github.com/cryptape/ruby-ethereum/blob/763f8651085ba145355a290da716884c7625a941/lib/ethereum/block.rb#L667-L672
train
cryptape/ruby-ethereum
lib/ethereum/block.rb
Ethereum.Block.chain_difficulty
def chain_difficulty return difficulty if genesis? k = "difficulty:#{Utils.encode_hex(full_hash)}" return Utils.decode_int(db.get(k)) if db.has_key?(k) o = difficulty + get_parent.chain_difficulty @state.db.put_temporarily k, Utils.encode_int(o) o end
ruby
def chain_difficulty return difficulty if genesis? k = "difficulty:#{Utils.encode_hex(full_hash)}" return Utils.decode_int(db.get(k)) if db.has_key?(k) o = difficulty + get_parent.chain_difficulty @state.db.put_temporarily k, Utils.encode_int(o) o end
[ "def", "chain_difficulty", "return", "difficulty", "if", "genesis?", "k", "=", "\"difficulty:#{Utils.encode_hex(full_hash)}\"", "return", "Utils", ".", "decode_int", "(", "db", ".", "get", "(", "k", ")", ")", "if", "db", ".", "has_key?", "(", "k", ")", "o", ...
Get the summarized difficulty. If the summarized difficulty is not stored in the database, it will be calculated recursively and put int the database.
[ "Get", "the", "summarized", "difficulty", "." ]
763f8651085ba145355a290da716884c7625a941
https://github.com/cryptape/ruby-ethereum/blob/763f8651085ba145355a290da716884c7625a941/lib/ethereum/block.rb#L680-L689
train
cryptape/ruby-ethereum
lib/ethereum/block.rb
Ethereum.Block.account_is_empty
def account_is_empty(address) get_balance(address) == 0 && get_code(address) == Constant::BYTE_EMPTY && get_nonce(address) == 0 end
ruby
def account_is_empty(address) get_balance(address) == 0 && get_code(address) == Constant::BYTE_EMPTY && get_nonce(address) == 0 end
[ "def", "account_is_empty", "(", "address", ")", "get_balance", "(", "address", ")", "==", "0", "&&", "get_code", "(", "address", ")", "==", "Constant", "::", "BYTE_EMPTY", "&&", "get_nonce", "(", "address", ")", "==", "0", "end" ]
Returns true when the account is either empty or non-exist.
[ "Returns", "true", "when", "the", "account", "is", "either", "empty", "or", "non", "-", "exist", "." ]
763f8651085ba145355a290da716884c7625a941
https://github.com/cryptape/ruby-ethereum/blob/763f8651085ba145355a290da716884c7625a941/lib/ethereum/block.rb#L741-L743
train
cryptape/ruby-ethereum
lib/ethereum/block.rb
Ethereum.Block.snapshot
def snapshot { state: @state.root_hash, gas: gas_used, txs: @transactions, txcount: @transaction_count, refunds: refunds, suicides: suicides, suicides_size: suicides.size, logs: logs, logs_size: logs.size, journal: @journal, # pointer to refe...
ruby
def snapshot { state: @state.root_hash, gas: gas_used, txs: @transactions, txcount: @transaction_count, refunds: refunds, suicides: suicides, suicides_size: suicides.size, logs: logs, logs_size: logs.size, journal: @journal, # pointer to refe...
[ "def", "snapshot", "{", "state", ":", "@state", ".", "root_hash", ",", "gas", ":", "gas_used", ",", "txs", ":", "@transactions", ",", "txcount", ":", "@transaction_count", ",", "refunds", ":", "refunds", ",", "suicides", ":", "suicides", ",", "suicides_size"...
Make a snapshot of the current state to enable later reverting.
[ "Make", "a", "snapshot", "of", "the", "current", "state", "to", "enable", "later", "reverting", "." ]
763f8651085ba145355a290da716884c7625a941
https://github.com/cryptape/ruby-ethereum/blob/763f8651085ba145355a290da716884c7625a941/lib/ethereum/block.rb#L779-L793
train
cryptape/ruby-ethereum
lib/ethereum/block.rb
Ethereum.Block.revert
def revert(mysnapshot) logger.debug "REVERTING" @journal = mysnapshot[:journal] # if @journal changed after snapshot while @journal.size > mysnapshot[:journal_size] cache, index, prev, post = @journal.pop logger.debug "revert journal", cache: cache, index: index, prev: prev, pos...
ruby
def revert(mysnapshot) logger.debug "REVERTING" @journal = mysnapshot[:journal] # if @journal changed after snapshot while @journal.size > mysnapshot[:journal_size] cache, index, prev, post = @journal.pop logger.debug "revert journal", cache: cache, index: index, prev: prev, pos...
[ "def", "revert", "(", "mysnapshot", ")", "logger", ".", "debug", "\"REVERTING\"", "@journal", "=", "mysnapshot", "[", ":journal", "]", "# if @journal changed after snapshot", "while", "@journal", ".", "size", ">", "mysnapshot", "[", ":journal_size", "]", "cache", ...
Revert to a previously made snapshot. Reverting is for example neccessary when a contract runs out of gas during execution.
[ "Revert", "to", "a", "previously", "made", "snapshot", "." ]
763f8651085ba145355a290da716884c7625a941
https://github.com/cryptape/ruby-ethereum/blob/763f8651085ba145355a290da716884c7625a941/lib/ethereum/block.rb#L801-L832
train
cryptape/ruby-ethereum
lib/ethereum/block.rb
Ethereum.Block.get_receipt
def get_receipt(num) index = RLP.encode num receipt = @receipts[index] if receipt == Trie::BLANK_NODE raise IndexError, "Receipt does not exist" else RLP.decode receipt, sedes: Receipt end end
ruby
def get_receipt(num) index = RLP.encode num receipt = @receipts[index] if receipt == Trie::BLANK_NODE raise IndexError, "Receipt does not exist" else RLP.decode receipt, sedes: Receipt end end
[ "def", "get_receipt", "(", "num", ")", "index", "=", "RLP", ".", "encode", "num", "receipt", "=", "@receipts", "[", "index", "]", "if", "receipt", "==", "Trie", "::", "BLANK_NODE", "raise", "IndexError", ",", "\"Receipt does not exist\"", "else", "RLP", ".",...
Get the receipt of the `num`th transaction. @raise [IndexError] if receipt at index is not found @return [Receipt]
[ "Get", "the", "receipt", "of", "the", "num", "th", "transaction", "." ]
763f8651085ba145355a290da716884c7625a941
https://github.com/cryptape/ruby-ethereum/blob/763f8651085ba145355a290da716884c7625a941/lib/ethereum/block.rb#L841-L850
train
cryptape/ruby-ethereum
lib/ethereum/block.rb
Ethereum.Block.get_receipts
def get_receipts receipts = [] i = 0 loop do begin receipts.push get_receipt(i) i += 1 rescue IndexError return receipts end end end
ruby
def get_receipts receipts = [] i = 0 loop do begin receipts.push get_receipt(i) i += 1 rescue IndexError return receipts end end end
[ "def", "get_receipts", "receipts", "=", "[", "]", "i", "=", "0", "loop", "do", "begin", "receipts", ".", "push", "get_receipt", "(", "i", ")", "i", "+=", "1", "rescue", "IndexError", "return", "receipts", "end", "end", "end" ]
Build a list of all receipts in this block.
[ "Build", "a", "list", "of", "all", "receipts", "in", "this", "block", "." ]
763f8651085ba145355a290da716884c7625a941
https://github.com/cryptape/ruby-ethereum/blob/763f8651085ba145355a290da716884c7625a941/lib/ethereum/block.rb#L855-L866
train
cryptape/ruby-ethereum
lib/ethereum/block.rb
Ethereum.Block.transfer_value
def transfer_value(from, to, value) raise ArgumentError, "value must be greater or equal than zero" unless value >= 0 delta_balance(from, -value) && delta_balance(to, value) end
ruby
def transfer_value(from, to, value) raise ArgumentError, "value must be greater or equal than zero" unless value >= 0 delta_balance(from, -value) && delta_balance(to, value) end
[ "def", "transfer_value", "(", "from", ",", "to", ",", "value", ")", "raise", "ArgumentError", ",", "\"value must be greater or equal than zero\"", "unless", "value", ">=", "0", "delta_balance", "(", "from", ",", "-", "value", ")", "&&", "delta_balance", "(", "to...
Transfer a value between two account balance. @param from [String] the address of the sending account (binary or hex string) @param to [String] the address of the receiving account (binary or hex string) @param value [Integer] the (positive) value to send @return [Bool] `true` if successful, otherwise `fals...
[ "Transfer", "a", "value", "between", "two", "account", "balance", "." ]
763f8651085ba145355a290da716884c7625a941
https://github.com/cryptape/ruby-ethereum/blob/763f8651085ba145355a290da716884c7625a941/lib/ethereum/block.rb#L952-L955
train
cryptape/ruby-ethereum
lib/ethereum/block.rb
Ethereum.Block.get_storage
def get_storage(address) storage_root = get_account_item address, :storage SecureTrie.new PruningTrie.new(db, storage_root) end
ruby
def get_storage(address) storage_root = get_account_item address, :storage SecureTrie.new PruningTrie.new(db, storage_root) end
[ "def", "get_storage", "(", "address", ")", "storage_root", "=", "get_account_item", "address", ",", ":storage", "SecureTrie", ".", "new", "PruningTrie", ".", "new", "(", "db", ",", "storage_root", ")", "end" ]
Get the trie holding an account's storage. @param address [String] the address of the account (binary or hex string) @return [Trie] the storage trie of account
[ "Get", "the", "trie", "holding", "an", "account", "s", "storage", "." ]
763f8651085ba145355a290da716884c7625a941
https://github.com/cryptape/ruby-ethereum/blob/763f8651085ba145355a290da716884c7625a941/lib/ethereum/block.rb#L987-L990
train
cryptape/ruby-ethereum
lib/ethereum/block.rb
Ethereum.Block.get_storage_data
def get_storage_data(address, index) address = Utils.normalize_address address cache = @caches["storage:#{address}"] return cache[index] if cache && cache.has_key?(index) key = Utils.zpad Utils.coerce_to_bytes(index), 32 value = get_storage(address)[key] value.true? ? RLP.decode(v...
ruby
def get_storage_data(address, index) address = Utils.normalize_address address cache = @caches["storage:#{address}"] return cache[index] if cache && cache.has_key?(index) key = Utils.zpad Utils.coerce_to_bytes(index), 32 value = get_storage(address)[key] value.true? ? RLP.decode(v...
[ "def", "get_storage_data", "(", "address", ",", "index", ")", "address", "=", "Utils", ".", "normalize_address", "address", "cache", "=", "@caches", "[", "\"storage:#{address}\"", "]", "return", "cache", "[", "index", "]", "if", "cache", "&&", "cache", ".", ...
Get a specific item in the storage of an account. @param address [String] the address of the account (binary or hex string) @param index [Integer] the index of the requested item in the storage @return [Integer] the value at storage index
[ "Get", "a", "specific", "item", "in", "the", "storage", "of", "an", "account", "." ]
763f8651085ba145355a290da716884c7625a941
https://github.com/cryptape/ruby-ethereum/blob/763f8651085ba145355a290da716884c7625a941/lib/ethereum/block.rb#L1009-L1019
train
cryptape/ruby-ethereum
lib/ethereum/block.rb
Ethereum.Block.set_storage_data
def set_storage_data(address, index, value) address = Utils.normalize_address address cache_key = "storage:#{address}" unless @caches.has_key?(cache_key) @caches[cache_key] = {} set_and_journal :all, address, true end set_and_journal cache_key, index, value end
ruby
def set_storage_data(address, index, value) address = Utils.normalize_address address cache_key = "storage:#{address}" unless @caches.has_key?(cache_key) @caches[cache_key] = {} set_and_journal :all, address, true end set_and_journal cache_key, index, value end
[ "def", "set_storage_data", "(", "address", ",", "index", ",", "value", ")", "address", "=", "Utils", ".", "normalize_address", "address", "cache_key", "=", "\"storage:#{address}\"", "unless", "@caches", ".", "has_key?", "(", "cache_key", ")", "@caches", "[", "ca...
Set a specific item in the storage of an account. @param address [String] the address of the account (binary or hex string) @param index [Integer] the index of the requested item in the storage @param value [Integer] the new value of the item
[ "Set", "a", "specific", "item", "in", "the", "storage", "of", "an", "account", "." ]
763f8651085ba145355a290da716884c7625a941
https://github.com/cryptape/ruby-ethereum/blob/763f8651085ba145355a290da716884c7625a941/lib/ethereum/block.rb#L1028-L1038
train
cryptape/ruby-ethereum
lib/ethereum/block.rb
Ethereum.Block.account_to_dict
def account_to_dict(address, with_storage_root: false, with_storage: true) address = Utils.normalize_address address # if there are uncommited account changes the current storage root is # meaningless raise ArgumentError, "cannot include storage root with uncommited account changes" if with_sto...
ruby
def account_to_dict(address, with_storage_root: false, with_storage: true) address = Utils.normalize_address address # if there are uncommited account changes the current storage root is # meaningless raise ArgumentError, "cannot include storage root with uncommited account changes" if with_sto...
[ "def", "account_to_dict", "(", "address", ",", "with_storage_root", ":", "false", ",", "with_storage", ":", "true", ")", "address", "=", "Utils", ".", "normalize_address", "address", "# if there are uncommited account changes the current storage root is", "# meaningless", "...
Serialize an account to a hash with human readable entries. @param address [String] the account address @param with_storage_root [Bool] include the account's storage root @param with_storage [Bool] include the whole account's storage @return [Hash] hash represent the account
[ "Serialize", "an", "account", "to", "a", "hash", "with", "human", "readable", "entries", "." ]
763f8651085ba145355a290da716884c7625a941
https://github.com/cryptape/ruby-ethereum/blob/763f8651085ba145355a290da716884c7625a941/lib/ethereum/block.rb#L1060-L1099
train
cryptape/ruby-ethereum
lib/ethereum/block.rb
Ethereum.Block.get_ancestor_list
def get_ancestor_list(n) raise ArgumentError, "n must be greater or equal than zero" unless n >= 0 return [] if n == 0 || number == 0 parent = get_parent [parent] + parent.get_ancestor_list(n-1) end
ruby
def get_ancestor_list(n) raise ArgumentError, "n must be greater or equal than zero" unless n >= 0 return [] if n == 0 || number == 0 parent = get_parent [parent] + parent.get_ancestor_list(n-1) end
[ "def", "get_ancestor_list", "(", "n", ")", "raise", "ArgumentError", ",", "\"n must be greater or equal than zero\"", "unless", "n", ">=", "0", "return", "[", "]", "if", "n", "==", "0", "||", "number", "==", "0", "parent", "=", "get_parent", "[", "parent", "...
Return `n` ancestors of this block. @return [Array] array of ancestors in format of `[parent, parent.parent, ...]
[ "Return", "n", "ancestors", "of", "this", "block", "." ]
763f8651085ba145355a290da716884c7625a941
https://github.com/cryptape/ruby-ethereum/blob/763f8651085ba145355a290da716884c7625a941/lib/ethereum/block.rb#L1106-L1112
train
cryptape/ruby-ethereum
lib/ethereum/block.rb
Ethereum.Block.validate_fields
def validate_fields l = Block.serialize self RLP.decode(RLP.encode(l)) == l end
ruby
def validate_fields l = Block.serialize self RLP.decode(RLP.encode(l)) == l end
[ "def", "validate_fields", "l", "=", "Block", ".", "serialize", "self", "RLP", ".", "decode", "(", "RLP", ".", "encode", "(", "l", ")", ")", "==", "l", "end" ]
Check that the values of all fields are well formed. Serialize and deserialize and check that the values didn't change.
[ "Check", "that", "the", "values", "of", "all", "fields", "are", "well", "formed", "." ]
763f8651085ba145355a290da716884c7625a941
https://github.com/cryptape/ruby-ethereum/blob/763f8651085ba145355a290da716884c7625a941/lib/ethereum/block.rb#L1289-L1292
train
cryptape/ruby-ethereum
lib/ethereum/block.rb
Ethereum.Block.delta_account_item
def delta_account_item(address, param, value) new_value = get_account_item(address, param) + value return false if new_value < 0 set_account_item(address, param, new_value % 2**256) true end
ruby
def delta_account_item(address, param, value) new_value = get_account_item(address, param) + value return false if new_value < 0 set_account_item(address, param, new_value % 2**256) true end
[ "def", "delta_account_item", "(", "address", ",", "param", ",", "value", ")", "new_value", "=", "get_account_item", "(", "address", ",", "param", ")", "+", "value", "return", "false", "if", "new_value", "<", "0", "set_account_item", "(", "address", ",", "par...
Add a value to an account item. If the resulting value would be negative, it is left unchanged and `false` is returned. @param address [String] the address of the account (binary or hex string) @param param [Symbol] the parameter to increase or decrease (`:nonce`, `:balance`, `:storage`, or `:code`) @param va...
[ "Add", "a", "value", "to", "an", "account", "item", "." ]
763f8651085ba145355a290da716884c7625a941
https://github.com/cryptape/ruby-ethereum/blob/763f8651085ba145355a290da716884c7625a941/lib/ethereum/block.rb#L1307-L1313
train
cryptape/ruby-ethereum
lib/ethereum/block.rb
Ethereum.Block.get_account_item
def get_account_item(address, param) address = Utils.normalize_address address, allow_blank: true return @caches[param][address] if @caches[param].has_key?(address) account = get_account address v = account.send param @caches[param][address] = v v end
ruby
def get_account_item(address, param) address = Utils.normalize_address address, allow_blank: true return @caches[param][address] if @caches[param].has_key?(address) account = get_account address v = account.send param @caches[param][address] = v v end
[ "def", "get_account_item", "(", "address", ",", "param", ")", "address", "=", "Utils", ".", "normalize_address", "address", ",", "allow_blank", ":", "true", "return", "@caches", "[", "param", "]", "[", "address", "]", "if", "@caches", "[", "param", "]", "....
Get a specific parameter of a specific account. @param address [String] the address of the account (binary or hex string) @param param [Symbol] the requested parameter (`:nonce`, `:balance`, `:storage` or `:code`) @return [Object] the value
[ "Get", "a", "specific", "parameter", "of", "a", "specific", "account", "." ]
763f8651085ba145355a290da716884c7625a941
https://github.com/cryptape/ruby-ethereum/blob/763f8651085ba145355a290da716884c7625a941/lib/ethereum/block.rb#L1324-L1332
train
cryptape/ruby-ethereum
lib/ethereum/block.rb
Ethereum.Block.set_account_item
def set_account_item(address, param, value) raise ArgumentError, "invalid address: #{address}" unless address.size == 20 || address.size == 40 address = Utils.decode_hex(address) if address.size == 40 set_and_journal(param, address, value) set_and_journal(:all, address, true) end
ruby
def set_account_item(address, param, value) raise ArgumentError, "invalid address: #{address}" unless address.size == 20 || address.size == 40 address = Utils.decode_hex(address) if address.size == 40 set_and_journal(param, address, value) set_and_journal(:all, address, true) end
[ "def", "set_account_item", "(", "address", ",", "param", ",", "value", ")", "raise", "ArgumentError", ",", "\"invalid address: #{address}\"", "unless", "address", ".", "size", "==", "20", "||", "address", ".", "size", "==", "40", "address", "=", "Utils", ".", ...
Set a specific parameter of a specific account. @param address [String] the address of the account (binary or hex string) @param param [Symbol] the requested parameter (`:nonce`, `:balance`, `:storage` or `:code`) @param value [Object] the new value
[ "Set", "a", "specific", "parameter", "of", "a", "specific", "account", "." ]
763f8651085ba145355a290da716884c7625a941
https://github.com/cryptape/ruby-ethereum/blob/763f8651085ba145355a290da716884c7625a941/lib/ethereum/block.rb#L1342-L1348
train
cryptape/ruby-ethereum
lib/ethereum/block.rb
Ethereum.Block.get_account
def get_account(address) address = Utils.normalize_address address, allow_blank: true rlpdata = @state[address] if rlpdata == Trie::BLANK_NODE Account.build_blank db, config[:account_initial_nonce] else RLP.decode(rlpdata, sedes: Account, db: db).tap do |acct| acct.mak...
ruby
def get_account(address) address = Utils.normalize_address address, allow_blank: true rlpdata = @state[address] if rlpdata == Trie::BLANK_NODE Account.build_blank db, config[:account_initial_nonce] else RLP.decode(rlpdata, sedes: Account, db: db).tap do |acct| acct.mak...
[ "def", "get_account", "(", "address", ")", "address", "=", "Utils", ".", "normalize_address", "address", ",", "allow_blank", ":", "true", "rlpdata", "=", "@state", "[", "address", "]", "if", "rlpdata", "==", "Trie", "::", "BLANK_NODE", "Account", ".", "build...
Get the account with the given address. Note that this method ignores cached account items.
[ "Get", "the", "account", "with", "the", "given", "address", "." ]
763f8651085ba145355a290da716884c7625a941
https://github.com/cryptape/ruby-ethereum/blob/763f8651085ba145355a290da716884c7625a941/lib/ethereum/block.rb#L1355-L1367
train
cryptape/ruby-ethereum
lib/ethereum/transaction.rb
Ethereum.Transaction.sign
def sign(key) raise InvalidTransaction, "Zero privkey cannot sign" if [0, '', Constant::PRIVKEY_ZERO, Constant::PRIVKEY_ZERO_HEX].include?(key) rawhash = Utils.keccak256 signing_data(:sign) key = PrivateKey.new(key).encode(:bin) vrs = Secp256k1.recoverable_sign rawhash, key self.v = enco...
ruby
def sign(key) raise InvalidTransaction, "Zero privkey cannot sign" if [0, '', Constant::PRIVKEY_ZERO, Constant::PRIVKEY_ZERO_HEX].include?(key) rawhash = Utils.keccak256 signing_data(:sign) key = PrivateKey.new(key).encode(:bin) vrs = Secp256k1.recoverable_sign rawhash, key self.v = enco...
[ "def", "sign", "(", "key", ")", "raise", "InvalidTransaction", ",", "\"Zero privkey cannot sign\"", "if", "[", "0", ",", "''", ",", "Constant", "::", "PRIVKEY_ZERO", ",", "Constant", "::", "PRIVKEY_ZERO_HEX", "]", ".", "include?", "(", "key", ")", "rawhash", ...
Sign this transaction with a private key. A potentially already existing signature would be override.
[ "Sign", "this", "transaction", "with", "a", "private", "key", "." ]
763f8651085ba145355a290da716884c7625a941
https://github.com/cryptape/ruby-ethereum/blob/763f8651085ba145355a290da716884c7625a941/lib/ethereum/transaction.rb#L105-L119
train
cryptape/ruby-ethereum
lib/ethereum/transaction.rb
Ethereum.Transaction.creates
def creates Utils.mk_contract_address(sender, nonce) if [Address::BLANK, Address::ZERO].include?(to) end
ruby
def creates Utils.mk_contract_address(sender, nonce) if [Address::BLANK, Address::ZERO].include?(to) end
[ "def", "creates", "Utils", ".", "mk_contract_address", "(", "sender", ",", "nonce", ")", "if", "[", "Address", "::", "BLANK", ",", "Address", "::", "ZERO", "]", ".", "include?", "(", "to", ")", "end" ]
returns the address of a contract created by this tx
[ "returns", "the", "address", "of", "a", "contract", "created", "by", "this", "tx" ]
763f8651085ba145355a290da716884c7625a941
https://github.com/cryptape/ruby-ethereum/blob/763f8651085ba145355a290da716884c7625a941/lib/ethereum/transaction.rb#L174-L176
train
cryptape/ruby-ethereum
lib/ethereum/miner.rb
Ethereum.Miner.mine
def mine(rounds=1000, start_nonce=0) blk = @block bin_nonce, mixhash = _mine(blk.number, blk.difficulty, blk.mining_hash, start_nonce, rounds) if bin_nonce.true? blk.mixhash = mixhash blk.nonce = bin_nonce return blk end end
ruby
def mine(rounds=1000, start_nonce=0) blk = @block bin_nonce, mixhash = _mine(blk.number, blk.difficulty, blk.mining_hash, start_nonce, rounds) if bin_nonce.true? blk.mixhash = mixhash blk.nonce = bin_nonce return blk end end
[ "def", "mine", "(", "rounds", "=", "1000", ",", "start_nonce", "=", "0", ")", "blk", "=", "@block", "bin_nonce", ",", "mixhash", "=", "_mine", "(", "blk", ".", "number", ",", "blk", ".", "difficulty", ",", "blk", ".", "mining_hash", ",", "start_nonce",...
Mines on the current head. Stores received transactions. The process of finalising a block involves four stages: 1. validate (or, if mining, determine) uncles; 2. validate (or, if mining, determine) transactions; 3. apply rewards; 4. verify (or, if mining, compute a valid) state and nonce.
[ "Mines", "on", "the", "current", "head", ".", "Stores", "received", "transactions", "." ]
763f8651085ba145355a290da716884c7625a941
https://github.com/cryptape/ruby-ethereum/blob/763f8651085ba145355a290da716884c7625a941/lib/ethereum/miner.rb#L43-L52
train
cryptape/ruby-ethereum
lib/ethereum/trie.rb
Ethereum.Trie.root_hash
def root_hash # TODO: can I memoize computation below? return BLANK_ROOT if @root_node == BLANK_NODE raise InvalidNode, "invalid root node" unless @root_node.instance_of?(Array) val = FastRLP.encode @root_node key = Utils.keccak256 val @db.put key, val SPV.grabbing @root_nod...
ruby
def root_hash # TODO: can I memoize computation below? return BLANK_ROOT if @root_node == BLANK_NODE raise InvalidNode, "invalid root node" unless @root_node.instance_of?(Array) val = FastRLP.encode @root_node key = Utils.keccak256 val @db.put key, val SPV.grabbing @root_nod...
[ "def", "root_hash", "# TODO: can I memoize computation below?", "return", "BLANK_ROOT", "if", "@root_node", "==", "BLANK_NODE", "raise", "InvalidNode", ",", "\"invalid root node\"", "unless", "@root_node", ".", "instance_of?", "(", "Array", ")", "val", "=", "FastRLP", "...
It presents a hash like interface. @param db [Object] key value database @param root_hash [String] blank or trie node in form of [key, value] or [v0, v1, .. v15, v] @return empty or 32 bytes string
[ "It", "presents", "a", "hash", "like", "interface", "." ]
763f8651085ba145355a290da716884c7625a941
https://github.com/cryptape/ruby-ethereum/blob/763f8651085ba145355a290da716884c7625a941/lib/ethereum/trie.rb#L45-L58
train