repo
stringlengths
5
67
path
stringlengths
4
218
func_name
stringlengths
0
151
original_string
stringlengths
52
373k
language
stringclasses
6 values
code
stringlengths
52
373k
code_tokens
listlengths
10
512
docstring
stringlengths
3
47.2k
docstring_tokens
listlengths
3
234
sha
stringlengths
40
40
url
stringlengths
85
339
partition
stringclasses
3 values
ianwhite/resources_controller
lib/resources_controller.rb
ResourcesController.InstanceMethods.load_enclosing_resources
def load_enclosing_resources namespace_segments.each {|segment| update_name_prefix("#{segment}_") } specifications.each_with_index do |spec, idx| case spec when '*' then load_wildcards_from(idx) when /^\?(.*)/ then load_wildcard($1) else load_enclosing_resource_from_spe...
ruby
def load_enclosing_resources namespace_segments.each {|segment| update_name_prefix("#{segment}_") } specifications.each_with_index do |spec, idx| case spec when '*' then load_wildcards_from(idx) when /^\?(.*)/ then load_wildcard($1) else load_enclosing_resource_from_spe...
[ "def", "load_enclosing_resources", "namespace_segments", ".", "each", "{", "|", "segment", "|", "update_name_prefix", "(", "\"#{segment}_\"", ")", "}", "specifications", ".", "each_with_index", "do", "|", "spec", ",", "idx", "|", "case", "spec", "when", "'*'", "...
this is the before_action that loads all specified and wildcard resources
[ "this", "is", "the", "before_action", "that", "loads", "all", "specified", "and", "wildcard", "resources" ]
14e76843ccf7d22a6da5da6db81681397c4838c5
https://github.com/ianwhite/resources_controller/blob/14e76843ccf7d22a6da5da6db81681397c4838c5/lib/resources_controller.rb#L662-L671
train
ianwhite/resources_controller
lib/resources_controller.rb
ResourcesController.InstanceMethods.load_wildcards_from
def load_wildcards_from(start) specs = specifications.slice(start..-1) encls = nesting_segments.slice(enclosing_resources.size..-1) if spec = specs.find {|s| s.is_a?(Specification)} spec_seg = encls.index({:segment => spec.segment, :singleton => spec.singleton?}) or ResourcesController.raise_...
ruby
def load_wildcards_from(start) specs = specifications.slice(start..-1) encls = nesting_segments.slice(enclosing_resources.size..-1) if spec = specs.find {|s| s.is_a?(Specification)} spec_seg = encls.index({:segment => spec.segment, :singleton => spec.singleton?}) or ResourcesController.raise_...
[ "def", "load_wildcards_from", "(", "start", ")", "specs", "=", "specifications", ".", "slice", "(", "start", "..", "-", "1", ")", "encls", "=", "nesting_segments", ".", "slice", "(", "enclosing_resources", ".", "size", "..", "-", "1", ")", "if", "spec", ...
loads a series of wildcard resources, from the specified specification idx To do this, we need to figure out where the next specified resource is and how many single wildcards are prior to that. What is left over from the current route enclosing names will be the number of wildcards we need to load
[ "loads", "a", "series", "of", "wildcard", "resources", "from", "the", "specified", "specification", "idx" ]
14e76843ccf7d22a6da5da6db81681397c4838c5
https://github.com/ianwhite/resources_controller/blob/14e76843ccf7d22a6da5da6db81681397c4838c5/lib/resources_controller.rb#L697-L709
train
ianwhite/resources_controller
lib/resources_controller.rb
ResourcesController.ResourceService.destroy
def destroy(*args) resource = find(*args) if enclosing_resource service.destroy(*args) resource else resource.destroy end end
ruby
def destroy(*args) resource = find(*args) if enclosing_resource service.destroy(*args) resource else resource.destroy end end
[ "def", "destroy", "(", "*", "args", ")", "resource", "=", "find", "(", "*", "args", ")", "if", "enclosing_resource", "service", ".", "destroy", "(", "*", "args", ")", "resource", "else", "resource", ".", "destroy", "end", "end" ]
find the resource If we have a resource service, we call destroy on it with the reosurce id, so that any callbacks can be triggered Otherwise, just call destroy on the resource
[ "find", "the", "resource", "If", "we", "have", "a", "resource", "service", "we", "call", "destroy", "on", "it", "with", "the", "reosurce", "id", "so", "that", "any", "callbacks", "can", "be", "triggered", "Otherwise", "just", "call", "destroy", "on", "the"...
14e76843ccf7d22a6da5da6db81681397c4838c5
https://github.com/ianwhite/resources_controller/blob/14e76843ccf7d22a6da5da6db81681397c4838c5/lib/resources_controller.rb#L762-L770
train
ideonetwork/lato-core
app/models/lato_core/superuser/entity_helpers.rb
LatoCore.Superuser::EntityHelpers.get_permission_name
def get_permission_name permission = CONFIGS[:lato_core][:superusers_permissions].values.select{|x| x[:value] === self.permission} return permission[0][:title] if permission && !permission.empty? end
ruby
def get_permission_name permission = CONFIGS[:lato_core][:superusers_permissions].values.select{|x| x[:value] === self.permission} return permission[0][:title] if permission && !permission.empty? end
[ "def", "get_permission_name", "permission", "=", "CONFIGS", "[", ":lato_core", "]", "[", ":superusers_permissions", "]", ".", "values", ".", "select", "{", "|", "x", "|", "x", "[", ":value", "]", "===", "self", ".", "permission", "}", "return", "permission",...
This function return the permission name for the user.
[ "This", "function", "return", "the", "permission", "name", "for", "the", "user", "." ]
c01fa585725c8e9992f25d8a7bd4ba2d0bfca08c
https://github.com/ideonetwork/lato-core/blob/c01fa585725c8e9992f25d8a7bd4ba2d0bfca08c/app/models/lato_core/superuser/entity_helpers.rb#L12-L15
train
Sharparam/chatrix
lib/chatrix/matrix.rb
Chatrix.Matrix.sync
def sync(filter: nil, since: nil, full_state: false, set_presence: true, timeout: 30_000) options = { full_state: full_state } options[:since] = since if since options[:set_presence] = 'offline' unless set_presence options[:timeout] = timeout if timeout options[:filter] = par...
ruby
def sync(filter: nil, since: nil, full_state: false, set_presence: true, timeout: 30_000) options = { full_state: full_state } options[:since] = since if since options[:set_presence] = 'offline' unless set_presence options[:timeout] = timeout if timeout options[:filter] = par...
[ "def", "sync", "(", "filter", ":", "nil", ",", "since", ":", "nil", ",", "full_state", ":", "false", ",", "set_presence", ":", "true", ",", "timeout", ":", "30_000", ")", "options", "=", "{", "full_state", ":", "full_state", "}", "options", "[", ":sinc...
Synchronize with the latest state on the server. For initial sync, call this method with the `since` parameter set to `nil`. @param filter [String,Hash] The ID of a filter to use, or provided directly as a hash. @param since [String,nil] A point in time to continue sync from. Will retrieve a snapshot of the...
[ "Synchronize", "with", "the", "latest", "state", "on", "the", "server", "." ]
6f2e9cf3a614ba7e8a9960f7d9b97092c0ce1e34
https://github.com/Sharparam/chatrix/blob/6f2e9cf3a614ba7e8a9960f7d9b97092c0ce1e34/lib/chatrix/matrix.rb#L134-L144
train
Sharparam/chatrix
lib/chatrix/matrix.rb
Chatrix.Matrix.search
def search(from: nil, options: {}) make_request( :post, '/search', params: { next_batch: from }, content: options ).parsed_response end
ruby
def search(from: nil, options: {}) make_request( :post, '/search', params: { next_batch: from }, content: options ).parsed_response end
[ "def", "search", "(", "from", ":", "nil", ",", "options", ":", "{", "}", ")", "make_request", "(", ":post", ",", "'/search'", ",", "params", ":", "{", "next_batch", ":", "from", "}", ",", "content", ":", "options", ")", ".", "parsed_response", "end" ]
Performs a full text search on the server. @param from [String] Where to return events from, if given. This can be obtained from previous calls to {#search}. @param options [Hash] Search options, see the official documentation for details on how to structure this. @return [Hash] the search results.
[ "Performs", "a", "full", "text", "search", "on", "the", "server", "." ]
6f2e9cf3a614ba7e8a9960f7d9b97092c0ce1e34
https://github.com/Sharparam/chatrix/blob/6f2e9cf3a614ba7e8a9960f7d9b97092c0ce1e34/lib/chatrix/matrix.rb#L168-L172
train
Sharparam/chatrix
lib/chatrix/matrix.rb
Chatrix.Matrix.make_request
def make_request(method, path, opts = {}, &block) path = (opts[:base] || @base_uri) + URI.encode(path) options = make_options opts[:params], opts[:content], opts[:headers] parse_response METHODS[method].call(path, options, &block) end
ruby
def make_request(method, path, opts = {}, &block) path = (opts[:base] || @base_uri) + URI.encode(path) options = make_options opts[:params], opts[:content], opts[:headers] parse_response METHODS[method].call(path, options, &block) end
[ "def", "make_request", "(", "method", ",", "path", ",", "opts", "=", "{", "}", ",", "&", "block", ")", "path", "=", "(", "opts", "[", ":base", "]", "||", "@base_uri", ")", "+", "URI", ".", "encode", "(", "path", ")", "options", "=", "make_options",...
Helper method for performing requests to the homeserver. @param method [Symbol] HTTP request method to use. Use only symbols available as keys in {METHODS}. @param path [String] The API path to query, relative to the base API path, eg. `/login`. @param opts [Hash] Additional request options. @option opts [H...
[ "Helper", "method", "for", "performing", "requests", "to", "the", "homeserver", "." ]
6f2e9cf3a614ba7e8a9960f7d9b97092c0ce1e34
https://github.com/Sharparam/chatrix/blob/6f2e9cf3a614ba7e8a9960f7d9b97092c0ce1e34/lib/chatrix/matrix.rb#L201-L206
train
Sharparam/chatrix
lib/chatrix/matrix.rb
Chatrix.Matrix.make_options
def make_options(params, content, headers = {}) { headers: headers }.tap do |o| o[:query] = @access_token ? { access_token: @access_token } : {} o[:query].merge!(params) if params.is_a? Hash o.merge! make_body content end end
ruby
def make_options(params, content, headers = {}) { headers: headers }.tap do |o| o[:query] = @access_token ? { access_token: @access_token } : {} o[:query].merge!(params) if params.is_a? Hash o.merge! make_body content end end
[ "def", "make_options", "(", "params", ",", "content", ",", "headers", "=", "{", "}", ")", "{", "headers", ":", "headers", "}", ".", "tap", "do", "|", "o", "|", "o", "[", ":query", "]", "=", "@access_token", "?", "{", "access_token", ":", "@access_tok...
Create an options Hash to pass to a server request. This method embeds the {#access_token access_token} into the query parameters. @param params [Hash{String=>String},nil] Query parameters to add to the options hash. @param content [Hash,#read,nil] Request content. Can be a hash, stream, or `nil`. @return ...
[ "Create", "an", "options", "Hash", "to", "pass", "to", "a", "server", "request", "." ]
6f2e9cf3a614ba7e8a9960f7d9b97092c0ce1e34
https://github.com/Sharparam/chatrix/blob/6f2e9cf3a614ba7e8a9960f7d9b97092c0ce1e34/lib/chatrix/matrix.rb#L220-L226
train
Sharparam/chatrix
lib/chatrix/matrix.rb
Chatrix.Matrix.make_body
def make_body(content) key = content.respond_to?(:read) ? :body_stream : :body value = content.is_a?(Hash) ? content.to_json : content { key => value } end
ruby
def make_body(content) key = content.respond_to?(:read) ? :body_stream : :body value = content.is_a?(Hash) ? content.to_json : content { key => value } end
[ "def", "make_body", "(", "content", ")", "key", "=", "content", ".", "respond_to?", "(", ":read", ")", "?", ":body_stream", ":", ":body", "value", "=", "content", ".", "is_a?", "(", "Hash", ")", "?", "content", ".", "to_json", ":", "content", "{", "key...
Create a hash with body content based on the type of `content`. @param content [Hash,#read,Object] Some kind of content to put into the request body. Can be a Hash, stream object, or other kind of object. @return [Hash{Symbol => Object}] A hash with the relevant body key and value.
[ "Create", "a", "hash", "with", "body", "content", "based", "on", "the", "type", "of", "content", "." ]
6f2e9cf3a614ba7e8a9960f7d9b97092c0ce1e34
https://github.com/Sharparam/chatrix/blob/6f2e9cf3a614ba7e8a9960f7d9b97092c0ce1e34/lib/chatrix/matrix.rb#L234-L238
train
Sharparam/chatrix
lib/chatrix/matrix.rb
Chatrix.Matrix.parse_response
def parse_response(response) case response.code when 200 # OK response else handler = ERROR_HANDLERS[response.code] raise handler.first.new(response.parsed_response), handler.last end end
ruby
def parse_response(response) case response.code when 200 # OK response else handler = ERROR_HANDLERS[response.code] raise handler.first.new(response.parsed_response), handler.last end end
[ "def", "parse_response", "(", "response", ")", "case", "response", ".", "code", "when", "200", "response", "else", "handler", "=", "ERROR_HANDLERS", "[", "response", ".", "code", "]", "raise", "handler", ".", "first", ".", "new", "(", "response", ".", "par...
Parses a HTTParty Response object and returns it if it was successful. @param response [HTTParty::Response] The response object to parse. @return [HTTParty::Response] The same response object that was passed in, if the request was successful. @raise [RequestError] If a `400` response code was returned from the ...
[ "Parses", "a", "HTTParty", "Response", "object", "and", "returns", "it", "if", "it", "was", "successful", "." ]
6f2e9cf3a614ba7e8a9960f7d9b97092c0ce1e34
https://github.com/Sharparam/chatrix/blob/6f2e9cf3a614ba7e8a9960f7d9b97092c0ce1e34/lib/chatrix/matrix.rb#L258-L266
train
Sharparam/chatrix
lib/chatrix/matrix.rb
Chatrix.Matrix.parse_filter
def parse_filter(filter) filter.is_a?(Hash) ? URI.encode(filter.to_json) : filter end
ruby
def parse_filter(filter) filter.is_a?(Hash) ? URI.encode(filter.to_json) : filter end
[ "def", "parse_filter", "(", "filter", ")", "filter", ".", "is_a?", "(", "Hash", ")", "?", "URI", ".", "encode", "(", "filter", ".", "to_json", ")", ":", "filter", "end" ]
Parses a filter object for use in a query string. @param filter [String,Hash] The filter object to parse. @return [String] Query-friendly filter object. Or the `filter` parameter as-is if it failed to parse.
[ "Parses", "a", "filter", "object", "for", "use", "in", "a", "query", "string", "." ]
6f2e9cf3a614ba7e8a9960f7d9b97092c0ce1e34
https://github.com/Sharparam/chatrix/blob/6f2e9cf3a614ba7e8a9960f7d9b97092c0ce1e34/lib/chatrix/matrix.rb#L272-L274
train
picatz/command_lion
lib/command_lion/app.rb
CommandLion.App.command
def command(index, &block) if index.is_a? Command cmd = index else cmd = Command.new cmd.index= index cmd.instance_eval(&block) end @commands = {} unless @commands @flags = [] unless @flags if cmd.flags? @flags << cmd.flags.short if cmd.flags.s...
ruby
def command(index, &block) if index.is_a? Command cmd = index else cmd = Command.new cmd.index= index cmd.instance_eval(&block) end @commands = {} unless @commands @flags = [] unless @flags if cmd.flags? @flags << cmd.flags.short if cmd.flags.s...
[ "def", "command", "(", "index", ",", "&", "block", ")", "if", "index", ".", "is_a?", "Command", "cmd", "=", "index", "else", "cmd", "=", "Command", ".", "new", "cmd", ".", "index", "=", "index", "cmd", ".", "instance_eval", "(", "&", "block", ")", ...
An application usually has multiple commands. == Example app = CommandLion::App.build # meta information command :example1 do # more code end command :example2 do # more code end end app.commands.map(&:name) # => [:example1, :example2]
[ "An", "application", "usually", "has", "multiple", "commands", "." ]
a101056a72c481e30a23c159e836e7b532c9b004
https://github.com/picatz/command_lion/blob/a101056a72c481e30a23c159e836e7b532c9b004/lib/command_lion/app.rb#L160-L191
train
picatz/command_lion
lib/command_lion/app.rb
CommandLion.App.parse
def parse @commands.each do |_, cmd| if cmd.flags? # or for the || seems to not do what I want it to do... next unless argv_index = ARGV.index(cmd.flags.short) || ARGV.index(cmd.flags.long) else next unless argv_index = ARGV.index(cmd.index.to_s) end c...
ruby
def parse @commands.each do |_, cmd| if cmd.flags? # or for the || seems to not do what I want it to do... next unless argv_index = ARGV.index(cmd.flags.short) || ARGV.index(cmd.flags.long) else next unless argv_index = ARGV.index(cmd.index.to_s) end c...
[ "def", "parse", "@commands", ".", "each", "do", "|", "_", ",", "cmd", "|", "if", "cmd", ".", "flags?", "next", "unless", "argv_index", "=", "ARGV", ".", "index", "(", "cmd", ".", "flags", ".", "short", ")", "||", "ARGV", ".", "index", "(", "cmd", ...
Parse arguments off of ARGV. @TODO Re-visit this.
[ "Parse", "arguments", "off", "of", "ARGV", "." ]
a101056a72c481e30a23c159e836e7b532c9b004
https://github.com/picatz/command_lion/blob/a101056a72c481e30a23c159e836e7b532c9b004/lib/command_lion/app.rb#L221-L242
train
picatz/command_lion
lib/command_lion/app.rb
CommandLion.App.parse_cmd
def parse_cmd(cmd, flags) if cmd.flags? args = Raw.arguments_to(cmd.flags.short, flags) if args.nil? || args.empty? args = Raw.arguments_to(cmd.flags.long, flags) end else args = Raw.arguments_to(cmd.index.to_s, flags) end unless cmd.type.to_s =~ /stdin/...
ruby
def parse_cmd(cmd, flags) if cmd.flags? args = Raw.arguments_to(cmd.flags.short, flags) if args.nil? || args.empty? args = Raw.arguments_to(cmd.flags.long, flags) end else args = Raw.arguments_to(cmd.index.to_s, flags) end unless cmd.type.to_s =~ /stdin/...
[ "def", "parse_cmd", "(", "cmd", ",", "flags", ")", "if", "cmd", ".", "flags?", "args", "=", "Raw", ".", "arguments_to", "(", "cmd", ".", "flags", ".", "short", ",", "flags", ")", "if", "args", ".", "nil?", "||", "args", ".", "empty?", "args", "=", ...
Parse a given command with its given flags. @TODO Re-visit this.
[ "Parse", "a", "given", "command", "with", "its", "given", "flags", "." ]
a101056a72c481e30a23c159e836e7b532c9b004
https://github.com/picatz/command_lion/blob/a101056a72c481e30a23c159e836e7b532c9b004/lib/command_lion/app.rb#L246-L327
train
thinkerbot/configurable
lib/configurable/config_hash.rb
Configurable.ConfigHash.[]=
def []=(key, value) if config = configs[key] config.set(receiver, value) else store[key] = value end end
ruby
def []=(key, value) if config = configs[key] config.set(receiver, value) else store[key] = value end end
[ "def", "[]=", "(", "key", ",", "value", ")", "if", "config", "=", "configs", "[", "key", "]", "config", ".", "set", "(", "receiver", ",", "value", ")", "else", "store", "[", "key", "]", "=", "value", "end", "end" ]
Stores a value for the key, either on the receiver or in the store.
[ "Stores", "a", "value", "for", "the", "key", "either", "on", "the", "receiver", "or", "in", "the", "store", "." ]
43c611f767f14194827b1fe31bc72c8bdf54efdf
https://github.com/thinkerbot/configurable/blob/43c611f767f14194827b1fe31bc72c8bdf54efdf/lib/configurable/config_hash.rb#L82-L88
train
thinkerbot/configurable
lib/configurable/config_hash.rb
Configurable.ConfigHash.merge!
def merge!(another) configs = self.configs another.each_pair do |key, value| if config = configs[key] config.set(receiver, value) else store[key] = value end end self end
ruby
def merge!(another) configs = self.configs another.each_pair do |key, value| if config = configs[key] config.set(receiver, value) else store[key] = value end end self end
[ "def", "merge!", "(", "another", ")", "configs", "=", "self", ".", "configs", "another", ".", "each_pair", "do", "|", "key", ",", "value", "|", "if", "config", "=", "configs", "[", "key", "]", "config", ".", "set", "(", "receiver", ",", "value", ")",...
Merges another with self.
[ "Merges", "another", "with", "self", "." ]
43c611f767f14194827b1fe31bc72c8bdf54efdf
https://github.com/thinkerbot/configurable/blob/43c611f767f14194827b1fe31bc72c8bdf54efdf/lib/configurable/config_hash.rb#L101-L111
train
thinkerbot/configurable
lib/configurable/config_hash.rb
Configurable.ConfigHash.each_pair
def each_pair # :yields: key, value configs.each_pair do |key, config| yield(key, config.get(receiver)) end store.each_pair do |key, value| yield(key, value) end end
ruby
def each_pair # :yields: key, value configs.each_pair do |key, config| yield(key, config.get(receiver)) end store.each_pair do |key, value| yield(key, value) end end
[ "def", "each_pair", "configs", ".", "each_pair", "do", "|", "key", ",", "config", "|", "yield", "(", "key", ",", "config", ".", "get", "(", "receiver", ")", ")", "end", "store", ".", "each_pair", "do", "|", "key", ",", "value", "|", "yield", "(", "...
Calls block once for each key-value pair stored in self.
[ "Calls", "block", "once", "for", "each", "key", "-", "value", "pair", "stored", "in", "self", "." ]
43c611f767f14194827b1fe31bc72c8bdf54efdf
https://github.com/thinkerbot/configurable/blob/43c611f767f14194827b1fe31bc72c8bdf54efdf/lib/configurable/config_hash.rb#L114-L122
train
thinkerbot/configurable
lib/configurable/config_hash.rb
Configurable.ConfigHash.to_hash
def to_hash hash = {} each_pair do |key, value| if value.kind_of?(ConfigHash) value = value.to_hash end hash[key] = value end hash end
ruby
def to_hash hash = {} each_pair do |key, value| if value.kind_of?(ConfigHash) value = value.to_hash end hash[key] = value end hash end
[ "def", "to_hash", "hash", "=", "{", "}", "each_pair", "do", "|", "key", ",", "value", "|", "if", "value", ".", "kind_of?", "(", "ConfigHash", ")", "value", "=", "value", ".", "to_hash", "end", "hash", "[", "key", "]", "=", "value", "end", "hash", "...
Equal if the to_hash values of self and another are equal. Returns self as a hash. Any ConfigHash values are recursively hashified, to account for nesting.
[ "Equal", "if", "the", "to_hash", "values", "of", "self", "and", "another", "are", "equal", ".", "Returns", "self", "as", "a", "hash", ".", "Any", "ConfigHash", "values", "are", "recursively", "hashified", "to", "account", "for", "nesting", "." ]
43c611f767f14194827b1fe31bc72c8bdf54efdf
https://github.com/thinkerbot/configurable/blob/43c611f767f14194827b1fe31bc72c8bdf54efdf/lib/configurable/config_hash.rb#L131-L141
train
scepticulous/crypto-toolbox
lib/crypto-toolbox/ciphers/aes.rb
Ciphers.Aes.decipher_ecb
def decipher_ecb(key,input,strip_padding: true) plain = decipher_ecb_blockwise(CryptBuffer(key),CryptBuffer(input).chunks_of(@block_size_bytes)).to_crypt_buffer strip_padding ? plain.strip_padding : plain end
ruby
def decipher_ecb(key,input,strip_padding: true) plain = decipher_ecb_blockwise(CryptBuffer(key),CryptBuffer(input).chunks_of(@block_size_bytes)).to_crypt_buffer strip_padding ? plain.strip_padding : plain end
[ "def", "decipher_ecb", "(", "key", ",", "input", ",", "strip_padding", ":", "true", ")", "plain", "=", "decipher_ecb_blockwise", "(", "CryptBuffer", "(", "key", ")", ",", "CryptBuffer", "(", "input", ")", ".", "chunks_of", "(", "@block_size_bytes", ")", ")",...
NOTE convert ECB encryption to AES gem or both to openssl
[ "NOTE", "convert", "ECB", "encryption", "to", "AES", "gem", "or", "both", "to", "openssl" ]
cdbe371109e497db2c2af5c1fe0f359612f44816
https://github.com/scepticulous/crypto-toolbox/blob/cdbe371109e497db2c2af5c1fe0f359612f44816/lib/crypto-toolbox/ciphers/aes.rb#L12-L15
train
scepticulous/crypto-toolbox
lib/crypto-toolbox/ciphers/aes.rb
Ciphers.Aes.unicipher_cbc
def unicipher_cbc(direction,key_str,input_buf,iv) method="#{direction.to_s}_cbc_block" blocks = input_buf.chunks_of(@block_size_bytes) iv ||= blocks.shift.str key = CryptBuffer(key_str).hex prev_block=iv.to_crypt_buffer strings = blocks.map.with_index do |block,i| ...
ruby
def unicipher_cbc(direction,key_str,input_buf,iv) method="#{direction.to_s}_cbc_block" blocks = input_buf.chunks_of(@block_size_bytes) iv ||= blocks.shift.str key = CryptBuffer(key_str).hex prev_block=iv.to_crypt_buffer strings = blocks.map.with_index do |block,i| ...
[ "def", "unicipher_cbc", "(", "direction", ",", "key_str", ",", "input_buf", ",", "iv", ")", "method", "=", "\"#{direction.to_s}_cbc_block\"", "blocks", "=", "input_buf", ".", "chunks_of", "(", "@block_size_bytes", ")", "iv", "||=", "blocks", ".", "shift", ".", ...
this method is used for encipher and decipher since most of the code is identical only the value of the previous block and the internal ecb method differs
[ "this", "method", "is", "used", "for", "encipher", "and", "decipher", "since", "most", "of", "the", "code", "is", "identical", "only", "the", "value", "of", "the", "previous", "block", "and", "the", "internal", "ecb", "method", "differs" ]
cdbe371109e497db2c2af5c1fe0f359612f44816
https://github.com/scepticulous/crypto-toolbox/blob/cdbe371109e497db2c2af5c1fe0f359612f44816/lib/crypto-toolbox/ciphers/aes.rb#L68-L89
train
Birdie0/qna_maker
lib/qna_maker/endpoints/generate_answer.rb
QnAMaker.Client.generate_answer
def generate_answer(question, top = 1) response = @http.post( "#{BASE_URL}/#{@knowledgebase_id}/generateAnswer", json: { question: question, top: top } ) case response.code when 200 response.parse['answers'].map do |answer| Answer.new( answer['answe...
ruby
def generate_answer(question, top = 1) response = @http.post( "#{BASE_URL}/#{@knowledgebase_id}/generateAnswer", json: { question: question, top: top } ) case response.code when 200 response.parse['answers'].map do |answer| Answer.new( answer['answe...
[ "def", "generate_answer", "(", "question", ",", "top", "=", "1", ")", "response", "=", "@http", ".", "post", "(", "\"#{BASE_URL}/#{@knowledgebase_id}/generateAnswer\"", ",", "json", ":", "{", "question", ":", "question", ",", "top", ":", "top", "}", ")", "ca...
Returns the list of answers for the given question sorted in descending order of ranking score. @param [String] question user question to be queried against your knowledge base. @param [Integer] top number of ranked results you want in the output. @return [Array<Answer>] list of answers for the user query sort...
[ "Returns", "the", "list", "of", "answers", "for", "the", "given", "question", "sorted", "in", "descending", "order", "of", "ranking", "score", "." ]
5ac204ede100355352438b8ff4fe30ad84d9257b
https://github.com/Birdie0/qna_maker/blob/5ac204ede100355352438b8ff4fe30ad84d9257b/lib/qna_maker/endpoints/generate_answer.rb#L14-L44
train
ideonetwork/lato-core
lib/lato_core/helpers/cells.rb
LatoCore.Helper::Cells.cell
def cell(*names) # define variables names_list = names.first.to_s.start_with?('Lato') ? names[1..-1] : names cell_class = names.first.to_s.start_with?('Lato') ? "#{names.first}::" : 'LatoCore::' # return correct cell names_list.each do |name| cell_class = "#{cell_class}#{name.capit...
ruby
def cell(*names) # define variables names_list = names.first.to_s.start_with?('Lato') ? names[1..-1] : names cell_class = names.first.to_s.start_with?('Lato') ? "#{names.first}::" : 'LatoCore::' # return correct cell names_list.each do |name| cell_class = "#{cell_class}#{name.capit...
[ "def", "cell", "(", "*", "names", ")", "names_list", "=", "names", ".", "first", ".", "to_s", ".", "start_with?", "(", "'Lato'", ")", "?", "names", "[", "1", "..", "-", "1", "]", ":", "names", "cell_class", "=", "names", ".", "first", ".", "to_s", ...
This helper is used to create a new cell with a pretty format.
[ "This", "helper", "is", "used", "to", "create", "a", "new", "cell", "with", "a", "pretty", "format", "." ]
c01fa585725c8e9992f25d8a7bd4ba2d0bfca08c
https://github.com/ideonetwork/lato-core/blob/c01fa585725c8e9992f25d8a7bd4ba2d0bfca08c/lib/lato_core/helpers/cells.rb#L7-L16
train
sergey-koba-mobidev/boxroom-engine
app/controllers/boxroom/folders_controller.rb
Boxroom.FoldersController.require_delete_permission
def require_delete_permission unless @folder.is_root? || boxroom_current_user.can_delete(@folder) redirect_to @folder.parent, :alert => t(:no_permissions_for_this_type, :method => t(:delete), :type => t(:this_folder)) else require_delete_permissions_for(@folder.children) end end
ruby
def require_delete_permission unless @folder.is_root? || boxroom_current_user.can_delete(@folder) redirect_to @folder.parent, :alert => t(:no_permissions_for_this_type, :method => t(:delete), :type => t(:this_folder)) else require_delete_permissions_for(@folder.children) end end
[ "def", "require_delete_permission", "unless", "@folder", ".", "is_root?", "||", "boxroom_current_user", ".", "can_delete", "(", "@folder", ")", "redirect_to", "@folder", ".", "parent", ",", ":alert", "=>", "t", "(", ":no_permissions_for_this_type", ",", ":method", "...
Overrides require_delete_permission in ApplicationController
[ "Overrides", "require_delete_permission", "in", "ApplicationController" ]
ce7a6b3fc6a1e5c36021429c0d337fab71993427
https://github.com/sergey-koba-mobidev/boxroom-engine/blob/ce7a6b3fc6a1e5c36021429c0d337fab71993427/app/controllers/boxroom/folders_controller.rb#L76-L82
train
dolzenko/reflexive
lib/reflexive/routing_helpers.rb
Reflexive.RoutingHelpers.method_call_path
def method_call_path(method_call_tag) # r method_call_tag.values_at(:name, :receiver) name, receiver, scope = method_call_tag.values_at(:name, :receiver, :scope) scope = scope.join("::") if receiver == :class scope = "Kernel" if scope.empty? new_method_path(scope, :class, name) ...
ruby
def method_call_path(method_call_tag) # r method_call_tag.values_at(:name, :receiver) name, receiver, scope = method_call_tag.values_at(:name, :receiver, :scope) scope = scope.join("::") if receiver == :class scope = "Kernel" if scope.empty? new_method_path(scope, :class, name) ...
[ "def", "method_call_path", "(", "method_call_tag", ")", "name", ",", "receiver", ",", "scope", "=", "method_call_tag", ".", "values_at", "(", ":name", ",", ":receiver", ",", ":scope", ")", "scope", "=", "scope", ".", "join", "(", "\"::\"", ")", "if", "rece...
method_call_tag is the scanner event tag emitted by ReflexiveRipper
[ "method_call_tag", "is", "the", "scanner", "event", "tag", "emitted", "by", "ReflexiveRipper" ]
04a58ba2f45c15e2815b7ca04a78a5b6b89a52b9
https://github.com/dolzenko/reflexive/blob/04a58ba2f45c15e2815b7ca04a78a5b6b89a52b9/lib/reflexive/routing_helpers.rb#L6-L27
train
amoghe/rb_tuntap
lib/rb_tuntap.rb
RbTunTap.Device.validate_address!
def validate_address!(addr) ip = IPAddr.new(addr) unless ip.ipv4? raise NotImplementedError, 'Only IPv4 is supported by this library' end if addr.include?('/') raise ArgumentError, 'Please specify a host IP address (without mask)' end addr.to_s end
ruby
def validate_address!(addr) ip = IPAddr.new(addr) unless ip.ipv4? raise NotImplementedError, 'Only IPv4 is supported by this library' end if addr.include?('/') raise ArgumentError, 'Please specify a host IP address (without mask)' end addr.to_s end
[ "def", "validate_address!", "(", "addr", ")", "ip", "=", "IPAddr", ".", "new", "(", "addr", ")", "unless", "ip", ".", "ipv4?", "raise", "NotImplementedError", ",", "'Only IPv4 is supported by this library'", "end", "if", "addr", ".", "include?", "(", "'/'", ")...
Validate that the given string is a valid IP address. @raises ArgumentError, NotImplementedError
[ "Validate", "that", "the", "given", "string", "is", "a", "valid", "IP", "address", "." ]
6eaed110049ea75ec7131bbdc62b49afd9e19489
https://github.com/amoghe/rb_tuntap/blob/6eaed110049ea75ec7131bbdc62b49afd9e19489/lib/rb_tuntap.rb#L90-L102
train
ArchimediaZerogroup/KonoUtils
lib/kono_utils/search_attribute.rb
KonoUtils.SearchAttribute.cast_value
def cast_value(value) return value if value.blank? return value if form_options.is_a? Proc return field_options[:cast].call(value) if field_options[:cast].is_a? Proc case form_options[:as] when :bs_datetimepicker if value.is_a? String DateTime.parse(value) ...
ruby
def cast_value(value) return value if value.blank? return value if form_options.is_a? Proc return field_options[:cast].call(value) if field_options[:cast].is_a? Proc case form_options[:as] when :bs_datetimepicker if value.is_a? String DateTime.parse(value) ...
[ "def", "cast_value", "(", "value", ")", "return", "value", "if", "value", ".", "blank?", "return", "value", "if", "form_options", ".", "is_a?", "Proc", "return", "field_options", "[", ":cast", "]", ".", "call", "(", "value", ")", "if", "field_options", "["...
Esegue un casting dei valori rispetto al tipo di campo da utilizzare per formtastic
[ "Esegue", "un", "casting", "dei", "valori", "rispetto", "al", "tipo", "di", "campo", "da", "utilizzare", "per", "formtastic" ]
a255a30b65e4e0f01cd6236d991da4fd13c64fc6
https://github.com/ArchimediaZerogroup/KonoUtils/blob/a255a30b65e4e0f01cd6236d991da4fd13c64fc6/lib/kono_utils/search_attribute.rb#L30-L55
train
CDLUC3/resync-client
lib/resync/client.rb
Resync.Client.get
def get(uri) uri = Resync::XML.to_uri(uri) @helper.fetch(uri: uri) end
ruby
def get(uri) uri = Resync::XML.to_uri(uri) @helper.fetch(uri: uri) end
[ "def", "get", "(", "uri", ")", "uri", "=", "Resync", "::", "XML", ".", "to_uri", "(", "uri", ")", "@helper", ".", "fetch", "(", "uri", ":", "uri", ")", "end" ]
Gets the content of the specified URI as a string. @param uri [URI, String] the URI to download @return [String] the content of the URI
[ "Gets", "the", "content", "of", "the", "specified", "URI", "as", "a", "string", "." ]
e621c9d0c8b8de436923359d6ad36f74c89bb2c2
https://github.com/CDLUC3/resync-client/blob/e621c9d0c8b8de436923359d6ad36f74c89bb2c2/lib/resync/client.rb#L36-L39
train
CDLUC3/resync-client
lib/resync/client.rb
Resync.Client.download_to_temp_file
def download_to_temp_file(uri) uri = Resync::XML.to_uri(uri) @helper.fetch_to_file(uri: uri) end
ruby
def download_to_temp_file(uri) uri = Resync::XML.to_uri(uri) @helper.fetch_to_file(uri: uri) end
[ "def", "download_to_temp_file", "(", "uri", ")", "uri", "=", "Resync", "::", "XML", ".", "to_uri", "(", "uri", ")", "@helper", ".", "fetch_to_file", "(", "uri", ":", "uri", ")", "end" ]
Gets the content of the specified URI and saves it to a temporary file. @param uri [URI, String] the URI to download @return [String] the path to the downloaded file
[ "Gets", "the", "content", "of", "the", "specified", "URI", "and", "saves", "it", "to", "a", "temporary", "file", "." ]
e621c9d0c8b8de436923359d6ad36f74c89bb2c2
https://github.com/CDLUC3/resync-client/blob/e621c9d0c8b8de436923359d6ad36f74c89bb2c2/lib/resync/client.rb#L44-L47
train
CDLUC3/resync-client
lib/resync/client.rb
Resync.Client.download_to_file
def download_to_file(uri:, path:) uri = Resync::XML.to_uri(uri) @helper.fetch_to_file(path: path, uri: uri) end
ruby
def download_to_file(uri:, path:) uri = Resync::XML.to_uri(uri) @helper.fetch_to_file(path: path, uri: uri) end
[ "def", "download_to_file", "(", "uri", ":", ",", "path", ":", ")", "uri", "=", "Resync", "::", "XML", ".", "to_uri", "(", "uri", ")", "@helper", ".", "fetch_to_file", "(", "path", ":", "path", ",", "uri", ":", "uri", ")", "end" ]
Gets the content of the specified URI and saves it to the specified file, overwriting it if it exists. @param uri [URI, String] the URI to download @param path [String] the path to save the download to @return [String] the path to the downloaded file
[ "Gets", "the", "content", "of", "the", "specified", "URI", "and", "saves", "it", "to", "the", "specified", "file", "overwriting", "it", "if", "it", "exists", "." ]
e621c9d0c8b8de436923359d6ad36f74c89bb2c2
https://github.com/CDLUC3/resync-client/blob/e621c9d0c8b8de436923359d6ad36f74c89bb2c2/lib/resync/client.rb#L54-L57
train
ideonetwork/lato-core
lib/lato_core/interfaces/modules.rb
LatoCore.Interface::Modules.core__get_modules_list
def core__get_modules_list all_gems = core__get_application_gems.keys lato_gems = [] # check every gem all_gems.each do |name| lato_gems.push(name) if name.start_with? 'lato' end # return result lato_gems end
ruby
def core__get_modules_list all_gems = core__get_application_gems.keys lato_gems = [] # check every gem all_gems.each do |name| lato_gems.push(name) if name.start_with? 'lato' end # return result lato_gems end
[ "def", "core__get_modules_list", "all_gems", "=", "core__get_application_gems", ".", "keys", "lato_gems", "=", "[", "]", "all_gems", ".", "each", "do", "|", "name", "|", "lato_gems", ".", "push", "(", "name", ")", "if", "name", ".", "start_with?", "'lato'", ...
This function returns the list of lato modules installed on main application.
[ "This", "function", "returns", "the", "list", "of", "lato", "modules", "installed", "on", "main", "application", "." ]
c01fa585725c8e9992f25d8a7bd4ba2d0bfca08c
https://github.com/ideonetwork/lato-core/blob/c01fa585725c8e9992f25d8a7bd4ba2d0bfca08c/lib/lato_core/interfaces/modules.rb#L15-L24
train
ideonetwork/lato-core
lib/lato_core/interfaces/modules.rb
LatoCore.Interface::Modules.core__get_module_languages
def core__get_module_languages(module_name) default_languages = core__get_module_default_languages(module_name) application_languages = core__get_module_application_languages(module_name) return default_languages unless application_languages default_languages.each do |key, value| applic...
ruby
def core__get_module_languages(module_name) default_languages = core__get_module_default_languages(module_name) application_languages = core__get_module_application_languages(module_name) return default_languages unless application_languages default_languages.each do |key, value| applic...
[ "def", "core__get_module_languages", "(", "module_name", ")", "default_languages", "=", "core__get_module_default_languages", "(", "module_name", ")", "application_languages", "=", "core__get_module_application_languages", "(", "module_name", ")", "return", "default_languages", ...
This function load languages for a specific module. This config are generated from the merge of application languages for the module and default languages of the module.
[ "This", "function", "load", "languages", "for", "a", "specific", "module", ".", "This", "config", "are", "generated", "from", "the", "merge", "of", "application", "languages", "for", "the", "module", "and", "default", "languages", "of", "the", "module", "." ]
c01fa585725c8e9992f25d8a7bd4ba2d0bfca08c
https://github.com/ideonetwork/lato-core/blob/c01fa585725c8e9992f25d8a7bd4ba2d0bfca08c/lib/lato_core/interfaces/modules.rb#L42-L52
train
ideonetwork/lato-core
lib/lato_core/interfaces/modules.rb
LatoCore.Interface::Modules.core__get_module_configs
def core__get_module_configs module_name default_config = core__get_module_default_configs(module_name) application_config = core__get_module_application_configs(module_name) return default_config unless application_config default_config.each do |key, value| application_config[key] = va...
ruby
def core__get_module_configs module_name default_config = core__get_module_default_configs(module_name) application_config = core__get_module_application_configs(module_name) return default_config unless application_config default_config.each do |key, value| application_config[key] = va...
[ "def", "core__get_module_configs", "module_name", "default_config", "=", "core__get_module_default_configs", "(", "module_name", ")", "application_config", "=", "core__get_module_application_configs", "(", "module_name", ")", "return", "default_config", "unless", "application_con...
This function load configs for a specific module. This configs are generated from the merge of application configs for the module and default configs of the module.
[ "This", "function", "load", "configs", "for", "a", "specific", "module", ".", "This", "configs", "are", "generated", "from", "the", "merge", "of", "application", "configs", "for", "the", "module", "and", "default", "configs", "of", "the", "module", "." ]
c01fa585725c8e9992f25d8a7bd4ba2d0bfca08c
https://github.com/ideonetwork/lato-core/blob/c01fa585725c8e9992f25d8a7bd4ba2d0bfca08c/lib/lato_core/interfaces/modules.rb#L83-L93
train
sinefunc/lunar
lib/lunar/index.rb
Lunar.Index.text
def text(att, value) clear_text_field(att) Scoring.new(value).scores.each do |word, score| metaphone = Lunar.metaphone(word) nest[att][metaphone].zadd(score, id) metaphones[id][att].sadd(metaphone) end fields[TEXT].sadd(att) end
ruby
def text(att, value) clear_text_field(att) Scoring.new(value).scores.each do |word, score| metaphone = Lunar.metaphone(word) nest[att][metaphone].zadd(score, id) metaphones[id][att].sadd(metaphone) end fields[TEXT].sadd(att) end
[ "def", "text", "(", "att", ",", "value", ")", "clear_text_field", "(", "att", ")", "Scoring", ".", "new", "(", "value", ")", ".", "scores", ".", "each", "do", "|", "word", ",", "score", "|", "metaphone", "=", "Lunar", ".", "metaphone", "(", "word", ...
Indexes all the metaphone equivalents of the words in value except for words included in Stopwords. @example Lunar.index :Gadget do |i| i.id 1001 i.text :title, "apple macbook pro" end # Executes the ff: in redis: # ZADD Lunar:Gadget:title:APL 1 1001 # ZADD Lunar:Gadget:title:MKBK 1 1...
[ "Indexes", "all", "the", "metaphone", "equivalents", "of", "the", "words", "in", "value", "except", "for", "words", "included", "in", "Stopwords", "." ]
efc58f392dd75e771d313eef6cd4ada0d1ac02ff
https://github.com/sinefunc/lunar/blob/efc58f392dd75e771d313eef6cd4ada0d1ac02ff/lib/lunar/index.rb#L105-L116
train
sinefunc/lunar
lib/lunar/index.rb
Lunar.Index.number
def number(att, value, purge = true) if value.kind_of?(Enumerable) clear_number_field(att) value.each { |v| number(att, v, false) } and return end clear_number_field(att) if purge numbers[att].zadd(value, id) numbers[att][value].zadd(1, id) numbers[id][att]....
ruby
def number(att, value, purge = true) if value.kind_of?(Enumerable) clear_number_field(att) value.each { |v| number(att, v, false) } and return end clear_number_field(att) if purge numbers[att].zadd(value, id) numbers[att][value].zadd(1, id) numbers[id][att]....
[ "def", "number", "(", "att", ",", "value", ",", "purge", "=", "true", ")", "if", "value", ".", "kind_of?", "(", "Enumerable", ")", "clear_number_field", "(", "att", ")", "value", ".", "each", "{", "|", "v", "|", "number", "(", "att", ",", "v", ",",...
Adds a numeric index for `att` with `value`. @example Lunar.index :Gadget do |i| i.id 1001 i.number :price, 200 end # Executes the ff: in redis: # ZADD Lunar:Gadget:price 200 @param [Symbol] att the field name in your document. @param [Numeric] value the numeric value of `att`. @retur...
[ "Adds", "a", "numeric", "index", "for", "att", "with", "value", "." ]
efc58f392dd75e771d313eef6cd4ada0d1ac02ff
https://github.com/sinefunc/lunar/blob/efc58f392dd75e771d313eef6cd4ada0d1ac02ff/lib/lunar/index.rb#L135-L149
train
sinefunc/lunar
lib/lunar/index.rb
Lunar.Index.sortable
def sortable(att, value) sortables[id][att].set(value) fields[SORTABLES].sadd att end
ruby
def sortable(att, value) sortables[id][att].set(value) fields[SORTABLES].sadd att end
[ "def", "sortable", "(", "att", ",", "value", ")", "sortables", "[", "id", "]", "[", "att", "]", ".", "set", "(", "value", ")", "fields", "[", "SORTABLES", "]", ".", "sadd", "att", "end" ]
Adds a sortable index for `att` with `value`. @example class Gadget def self.[](id) # find the gadget using id here end end Lunar.index Gadget do |i| i.id 1001 i.text 'apple macbook pro' i.sortable :votes, 50 end Lunar.index Gadget do |i| i.id 1002 i.text 'a...
[ "Adds", "a", "sortable", "index", "for", "att", "with", "value", "." ]
efc58f392dd75e771d313eef6cd4ada0d1ac02ff
https://github.com/sinefunc/lunar/blob/efc58f392dd75e771d313eef6cd4ada0d1ac02ff/lib/lunar/index.rb#L184-L188
train
snusnu/substation
lib/substation/request.rb
Substation.Request.to_request
def to_request(new_input = Undefined) new_input.equal?(Undefined) ? self : self.class.new(name, env, new_input) end
ruby
def to_request(new_input = Undefined) new_input.equal?(Undefined) ? self : self.class.new(name, env, new_input) end
[ "def", "to_request", "(", "new_input", "=", "Undefined", ")", "new_input", ".", "equal?", "(", "Undefined", ")", "?", "self", ":", "self", ".", "class", ".", "new", "(", "name", ",", "env", ",", "new_input", ")", "end" ]
Return self or a new instance with +input+ @param [Object] input the input for the new instance @return [self] if +input+ is {Undefined} @return [Request] a new instance with +input+ @api private
[ "Return", "self", "or", "a", "new", "instance", "with", "+", "input", "+" ]
fabf062a3640f5e82dae68597f0709b63f6b9027
https://github.com/snusnu/substation/blob/fabf062a3640f5e82dae68597f0709b63f6b9027/lib/substation/request.rb#L81-L83
train
ideonetwork/lato-core
lib/lato_core/interfaces/token.rb
LatoCore.Interface::Token.core__encode_token
def core__encode_token exp, payload exp = 1.day.from_now unless exp payload[:exp] = exp.to_i JWT.encode(payload, Rails.application.secrets.secret_key_base, 'HS256') end
ruby
def core__encode_token exp, payload exp = 1.day.from_now unless exp payload[:exp] = exp.to_i JWT.encode(payload, Rails.application.secrets.secret_key_base, 'HS256') end
[ "def", "core__encode_token", "exp", ",", "payload", "exp", "=", "1", ".", "day", ".", "from_now", "unless", "exp", "payload", "[", ":exp", "]", "=", "exp", ".", "to_i", "JWT", ".", "encode", "(", "payload", ",", "Rails", ".", "application", ".", "secre...
This functon return a token with encrypted payload information.
[ "This", "functon", "return", "a", "token", "with", "encrypted", "payload", "information", "." ]
c01fa585725c8e9992f25d8a7bd4ba2d0bfca08c
https://github.com/ideonetwork/lato-core/blob/c01fa585725c8e9992f25d8a7bd4ba2d0bfca08c/lib/lato_core/interfaces/token.rb#L8-L12
train
ideonetwork/lato-core
lib/lato_core/interfaces/token.rb
LatoCore.Interface::Token.core__decode_token
def core__decode_token token begin body = JWT.decode(token, Rails.application.secrets.secret_key_base, true, algorithm: 'HS256')[0] return HashWithIndifferentAccess.new body rescue => exception return nil end end
ruby
def core__decode_token token begin body = JWT.decode(token, Rails.application.secrets.secret_key_base, true, algorithm: 'HS256')[0] return HashWithIndifferentAccess.new body rescue => exception return nil end end
[ "def", "core__decode_token", "token", "begin", "body", "=", "JWT", ".", "decode", "(", "token", ",", "Rails", ".", "application", ".", "secrets", ".", "secret_key_base", ",", "true", ",", "algorithm", ":", "'HS256'", ")", "[", "0", "]", "return", "HashWith...
This function return the payload of a token.
[ "This", "function", "return", "the", "payload", "of", "a", "token", "." ]
c01fa585725c8e9992f25d8a7bd4ba2d0bfca08c
https://github.com/ideonetwork/lato-core/blob/c01fa585725c8e9992f25d8a7bd4ba2d0bfca08c/lib/lato_core/interfaces/token.rb#L15-L23
train
threez/marilyn-rpc
lib/marilyn-rpc/client.rb
MarilynRPC.NativeClient.authenticate
def authenticate(username, password, method = :plain) execute(MarilynRPC::Service::AUTHENTICATION_PATH, "authenticate_#{method}".to_sym, [username, password]) end
ruby
def authenticate(username, password, method = :plain) execute(MarilynRPC::Service::AUTHENTICATION_PATH, "authenticate_#{method}".to_sym, [username, password]) end
[ "def", "authenticate", "(", "username", ",", "password", ",", "method", "=", ":plain", ")", "execute", "(", "MarilynRPC", "::", "Service", "::", "AUTHENTICATION_PATH", ",", "\"authenticate_#{method}\"", ".", "to_sym", ",", "[", "username", ",", "password", "]", ...
authenicate the client to call methods that require authentication @param [String] username the username of the client @param [String] password the password of the client @param [Symbol] method the method to use for authentication, currently only plain is supported. So make sure you are using a secure socket.
[ "authenicate", "the", "client", "to", "call", "methods", "that", "require", "authentication" ]
e75b46b7dfe5040f4a5022b23702b5a29cf4844f
https://github.com/threez/marilyn-rpc/blob/e75b46b7dfe5040f4a5022b23702b5a29cf4844f/lib/marilyn-rpc/client.rb#L74-L77
train
threez/marilyn-rpc
lib/marilyn-rpc/client.rb
MarilynRPC.NativeClient.execute
def execute(path, method, args) thread = Thread.current tag = "#{Time.now.to_f}:#{thread.object_id}" @semaphore.synchronize { # since this client can't multiplex, we set the tag to nil @socket.write(MarilynRPC::MailFactory.build_call(tag, path, method, args)) # ...
ruby
def execute(path, method, args) thread = Thread.current tag = "#{Time.now.to_f}:#{thread.object_id}" @semaphore.synchronize { # since this client can't multiplex, we set the tag to nil @socket.write(MarilynRPC::MailFactory.build_call(tag, path, method, args)) # ...
[ "def", "execute", "(", "path", ",", "method", ",", "args", ")", "thread", "=", "Thread", ".", "current", "tag", "=", "\"#{Time.now.to_f}:#{thread.object_id}\"", "@semaphore", ".", "synchronize", "{", "@socket", ".", "write", "(", "MarilynRPC", "::", "MailFactory...
Executes a client call blocking. To issue an async call one needs to have start separate threads. THe Native client uses then multiplexing to avoid the other threads blocking. @api private @param [Object] path the path to identifiy the service @param [Symbol, String] method the method name to call on the service ...
[ "Executes", "a", "client", "call", "blocking", ".", "To", "issue", "an", "async", "call", "one", "needs", "to", "have", "start", "separate", "threads", ".", "THe", "Native", "client", "uses", "then", "multiplexing", "to", "avoid", "the", "other", "threads", ...
e75b46b7dfe5040f4a5022b23702b5a29cf4844f
https://github.com/threez/marilyn-rpc/blob/e75b46b7dfe5040f4a5022b23702b5a29cf4844f/lib/marilyn-rpc/client.rb#L130-L161
train
brianmichel/BadFruit
lib/badfruit/Movies/movies.rb
BadFruit.Movies.search_by_name
def search_by_name(name, page_limit=1, page=1) if page_limit > 50 page_limit = MAX_PAGE_LIMIT #current limitation of the rotten tomatos API end results_json = @badfruit.search_movies(name, page_limit, page) if results_json.nil? return [] else return @badfruit.parse...
ruby
def search_by_name(name, page_limit=1, page=1) if page_limit > 50 page_limit = MAX_PAGE_LIMIT #current limitation of the rotten tomatos API end results_json = @badfruit.search_movies(name, page_limit, page) if results_json.nil? return [] else return @badfruit.parse...
[ "def", "search_by_name", "(", "name", ",", "page_limit", "=", "1", ",", "page", "=", "1", ")", "if", "page_limit", ">", "50", "page_limit", "=", "MAX_PAGE_LIMIT", "end", "results_json", "=", "@badfruit", ".", "search_movies", "(", "name", ",", "page_limit", ...
Initialize a wrapper around the Rotten Tomatoes API specific to movies. Search for a movie by name. @param [String] name The name of the movie to search for. @param [Integer] page_limit The number of results to return for API response page. (Defaults to 1) @param [Integer] page The page offset to request from th...
[ "Initialize", "a", "wrapper", "around", "the", "Rotten", "Tomatoes", "API", "specific", "to", "movies", "." ]
dab9c28d4bcd79d64829239abf6a816bbbcc73a6
https://github.com/brianmichel/BadFruit/blob/dab9c28d4bcd79d64829239abf6a816bbbcc73a6/lib/badfruit/Movies/movies.rb#L25-L36
train
brianmichel/BadFruit
lib/badfruit/Movies/movies.rb
BadFruit.Movies.search_by_id
def search_by_id(movie_id) movie = @badfruit.get_movie_info(movie_id, "main") raise 'Movie not found' if movie.nil? || movie.empty? @badfruit.parse_movie_array(JSON.parse(movie)) end
ruby
def search_by_id(movie_id) movie = @badfruit.get_movie_info(movie_id, "main") raise 'Movie not found' if movie.nil? || movie.empty? @badfruit.parse_movie_array(JSON.parse(movie)) end
[ "def", "search_by_id", "(", "movie_id", ")", "movie", "=", "@badfruit", ".", "get_movie_info", "(", "movie_id", ",", "\"main\"", ")", "raise", "'Movie not found'", "if", "movie", ".", "nil?", "||", "movie", ".", "empty?", "@badfruit", ".", "parse_movie_array", ...
search by id Search for a movie by Rotten Tomatoes id. @param [String] movie_id The id of the movie to search for. @return [BadFruit::Movie] A movie object from the response data.
[ "search", "by", "id" ]
dab9c28d4bcd79d64829239abf6a816bbbcc73a6
https://github.com/brianmichel/BadFruit/blob/dab9c28d4bcd79d64829239abf6a816bbbcc73a6/lib/badfruit/Movies/movies.rb#L47-L51
train
brianmichel/BadFruit
lib/badfruit/Movies/movies.rb
BadFruit.Movies.search_by_alias
def search_by_alias(alias_id, type='imdb') movie = @badfruit.get_movie_alias_info(alias_id, type) json = JSON.parse(movie) raise 'Movie not found' if !json['error'].nil? @badfruit.parse_movie_array(json) end
ruby
def search_by_alias(alias_id, type='imdb') movie = @badfruit.get_movie_alias_info(alias_id, type) json = JSON.parse(movie) raise 'Movie not found' if !json['error'].nil? @badfruit.parse_movie_array(json) end
[ "def", "search_by_alias", "(", "alias_id", ",", "type", "=", "'imdb'", ")", "movie", "=", "@badfruit", ".", "get_movie_alias_info", "(", "alias_id", ",", "type", ")", "json", "=", "JSON", ".", "parse", "(", "movie", ")", "raise", "'Movie not found'", "if", ...
Search for a movie by way of a 3rd party id. @param [String] alias_id The alias id of the movie. @param [String] type The type of alias id that is being provided. (Defaults to 'imdb') @return [BadFruit::Movie] A movie object representing the 3rd party id. @note Currently only 'imdb' as a type is supported.
[ "Search", "for", "a", "movie", "by", "way", "of", "a", "3rd", "party", "id", "." ]
dab9c28d4bcd79d64829239abf6a816bbbcc73a6
https://github.com/brianmichel/BadFruit/blob/dab9c28d4bcd79d64829239abf6a816bbbcc73a6/lib/badfruit/Movies/movies.rb#L62-L67
train
onesky/one_sky-ruby
lib/one_sky/translation.rb
OneSky.Translation.dashify_string_hash
def dashify_string_hash(string_hash) output = Hash.new string_hash.each do |key, value| dashed = key.to_s.gsub("_", "-").to_sym output[dashed] = value end output end
ruby
def dashify_string_hash(string_hash) output = Hash.new string_hash.each do |key, value| dashed = key.to_s.gsub("_", "-").to_sym output[dashed] = value end output end
[ "def", "dashify_string_hash", "(", "string_hash", ")", "output", "=", "Hash", ".", "new", "string_hash", ".", "each", "do", "|", "key", ",", "value", "|", "dashed", "=", "key", ".", "to_s", ".", "gsub", "(", "\"_\"", ",", "\"-\"", ")", ".", "to_sym", ...
convert to "string-key" not "string_key"
[ "convert", "to", "string", "-", "key", "not", "string_key" ]
cc1ae294073086b7aab66340416062aaee59a160
https://github.com/onesky/one_sky-ruby/blob/cc1ae294073086b7aab66340416062aaee59a160/lib/one_sky/translation.rb#L131-L138
train
sunlightlabs/ruby-sunlight
lib/sunlight/legislator.rb
Sunlight.Legislator.committees
def committees url = Sunlight::Base.construct_url("committees.allForLegislator", {:bioguide_id => self.bioguide_id}) if (result = Sunlight::Base.get_json_data(url)) committees = [] result["response"]["committees"].each do |committee| committees << Sunlight::Committee.new(commi...
ruby
def committees url = Sunlight::Base.construct_url("committees.allForLegislator", {:bioguide_id => self.bioguide_id}) if (result = Sunlight::Base.get_json_data(url)) committees = [] result["response"]["committees"].each do |committee| committees << Sunlight::Committee.new(commi...
[ "def", "committees", "url", "=", "Sunlight", "::", "Base", ".", "construct_url", "(", "\"committees.allForLegislator\"", ",", "{", ":bioguide_id", "=>", "self", ".", "bioguide_id", "}", ")", "if", "(", "result", "=", "Sunlight", "::", "Base", ".", "get_json_da...
Get the committees the Legislator sits on Returns: An array of Committee objects, each possibly having its own subarray of subcommittees
[ "Get", "the", "committees", "the", "Legislator", "sits", "on" ]
239063ccf26fadaf64d650fd3c22bcc734cc3394
https://github.com/sunlightlabs/ruby-sunlight/blob/239063ccf26fadaf64d650fd3c22bcc734cc3394/lib/sunlight/legislator.rb#L32-L44
train
seejohnrun/console_tweet
lib/console_tweet/cli.rb
ConsoleTweet.CLI.get_access_token
def get_access_token @client = TwitterOAuth::Client.new(:consumer_key => ConsumerKey, :consumer_secret => ConsumerSecret) request_token = @client.request_token # ask the user to visit the auth url puts "To authenticate your client, visit the URL: #{request_token.authorize_url}" open_link r...
ruby
def get_access_token @client = TwitterOAuth::Client.new(:consumer_key => ConsumerKey, :consumer_secret => ConsumerSecret) request_token = @client.request_token # ask the user to visit the auth url puts "To authenticate your client, visit the URL: #{request_token.authorize_url}" open_link r...
[ "def", "get_access_token", "@client", "=", "TwitterOAuth", "::", "Client", ".", "new", "(", ":consumer_key", "=>", "ConsumerKey", ",", ":consumer_secret", "=>", "ConsumerSecret", ")", "request_token", "=", "@client", ".", "request_token", "puts", "\"To authenticate yo...
Prompt the user for a PIN using a request token, and see if we can successfully authenticate them
[ "Prompt", "the", "user", "for", "a", "PIN", "using", "a", "request", "token", "and", "see", "if", "we", "can", "successfully", "authenticate", "them" ]
6920bb0ead3060ac52eb968bc0df3c21b72e1ff6
https://github.com/seejohnrun/console_tweet/blob/6920bb0ead3060ac52eb968bc0df3c21b72e1ff6/lib/console_tweet/cli.rb#L46-L59
train
seejohnrun/console_tweet
lib/console_tweet/cli.rb
ConsoleTweet.CLI.timeline
def timeline(*args) load_default_token return failtown("Unauthorized, re-run setup!") unless @client && @client.authorized? # Only send since_id to @client if it's not nil home_timeline = since_id ? @client.home_timeline(:since_id => since_id) : @client.home_timeline if home_timeline.any? ...
ruby
def timeline(*args) load_default_token return failtown("Unauthorized, re-run setup!") unless @client && @client.authorized? # Only send since_id to @client if it's not nil home_timeline = since_id ? @client.home_timeline(:since_id => since_id) : @client.home_timeline if home_timeline.any? ...
[ "def", "timeline", "(", "*", "args", ")", "load_default_token", "return", "failtown", "(", "\"Unauthorized, re-run setup!\"", ")", "unless", "@client", "&&", "@client", ".", "authorized?", "home_timeline", "=", "since_id", "?", "@client", ".", "home_timeline", "(", ...
Display the user's timeline
[ "Display", "the", "user", "s", "timeline" ]
6920bb0ead3060ac52eb968bc0df3c21b72e1ff6
https://github.com/seejohnrun/console_tweet/blob/6920bb0ead3060ac52eb968bc0df3c21b72e1ff6/lib/console_tweet/cli.rb#L62-L72
train
seejohnrun/console_tweet
lib/console_tweet/cli.rb
ConsoleTweet.CLI.tweet
def tweet(*args) load_default_token # get it from them directly tweet_text = args.join(' ').strip # or let them append / or pipe tweet_text += (tweet_text.empty? ? '' : ' ') + STDIN.read unless STDIN.tty? # or let them get prompted for it if tweet_text.empty? print 'Twe...
ruby
def tweet(*args) load_default_token # get it from them directly tweet_text = args.join(' ').strip # or let them append / or pipe tweet_text += (tweet_text.empty? ? '' : ' ') + STDIN.read unless STDIN.tty? # or let them get prompted for it if tweet_text.empty? print 'Twe...
[ "def", "tweet", "(", "*", "args", ")", "load_default_token", "tweet_text", "=", "args", ".", "join", "(", "' '", ")", ".", "strip", "tweet_text", "+=", "(", "tweet_text", ".", "empty?", "?", "''", ":", "' '", ")", "+", "STDIN", ".", "read", "unless", ...
Send a tweet for the user
[ "Send", "a", "tweet", "for", "the", "user" ]
6920bb0ead3060ac52eb968bc0df3c21b72e1ff6
https://github.com/seejohnrun/console_tweet/blob/6920bb0ead3060ac52eb968bc0df3c21b72e1ff6/lib/console_tweet/cli.rb#L75-L92
train
seejohnrun/console_tweet
lib/console_tweet/cli.rb
ConsoleTweet.CLI.show
def show(args) # If we have no user to get, use the timeline instead return timeline(args) if args.nil? || args.count == 0 target_user = args[0] # Get the timeline and print the tweets if we don't get an error load_default_token # for private tweets res = @client.user_timeline(:scree...
ruby
def show(args) # If we have no user to get, use the timeline instead return timeline(args) if args.nil? || args.count == 0 target_user = args[0] # Get the timeline and print the tweets if we don't get an error load_default_token # for private tweets res = @client.user_timeline(:scree...
[ "def", "show", "(", "args", ")", "return", "timeline", "(", "args", ")", "if", "args", ".", "nil?", "||", "args", ".", "count", "==", "0", "target_user", "=", "args", "[", "0", "]", "load_default_token", "res", "=", "@client", ".", "user_timeline", "("...
Get 20 most recent statuses of user, or specified user
[ "Get", "20", "most", "recent", "statuses", "of", "user", "or", "specified", "user" ]
6920bb0ead3060ac52eb968bc0df3c21b72e1ff6
https://github.com/seejohnrun/console_tweet/blob/6920bb0ead3060ac52eb968bc0df3c21b72e1ff6/lib/console_tweet/cli.rb#L95-L104
train
seejohnrun/console_tweet
lib/console_tweet/cli.rb
ConsoleTweet.CLI.status
def status(*args) load_default_token return failtown("Unauthorized, re-run setup!") unless @client && @client.authorized? user = @client.info status = user['status'] puts "#{user['name']} (at #{status['created_at']}) #{status['text']}" unless status.nil? end
ruby
def status(*args) load_default_token return failtown("Unauthorized, re-run setup!") unless @client && @client.authorized? user = @client.info status = user['status'] puts "#{user['name']} (at #{status['created_at']}) #{status['text']}" unless status.nil? end
[ "def", "status", "(", "*", "args", ")", "load_default_token", "return", "failtown", "(", "\"Unauthorized, re-run setup!\"", ")", "unless", "@client", "&&", "@client", ".", "authorized?", "user", "=", "@client", ".", "info", "status", "=", "user", "[", "'status'"...
Get the user's most recent status
[ "Get", "the", "user", "s", "most", "recent", "status" ]
6920bb0ead3060ac52eb968bc0df3c21b72e1ff6
https://github.com/seejohnrun/console_tweet/blob/6920bb0ead3060ac52eb968bc0df3c21b72e1ff6/lib/console_tweet/cli.rb#L107-L113
train
seejohnrun/console_tweet
lib/console_tweet/cli.rb
ConsoleTweet.CLI.setup
def setup(*args) # Keep trying to get the access token until @access_token = self.get_access_token print "Try again? [Y/n] " return false if self.class.get_input.downcase == 'n' end # When we finally get it, record it in a dotfile tokens = {:default => { :token => @access_t...
ruby
def setup(*args) # Keep trying to get the access token until @access_token = self.get_access_token print "Try again? [Y/n] " return false if self.class.get_input.downcase == 'n' end # When we finally get it, record it in a dotfile tokens = {:default => { :token => @access_t...
[ "def", "setup", "(", "*", "args", ")", "until", "@access_token", "=", "self", ".", "get_access_token", "print", "\"Try again? [Y/n] \"", "return", "false", "if", "self", ".", "class", ".", "get_input", ".", "downcase", "==", "'n'", "end", "tokens", "=", "{",...
Get the access token for the user and save it
[ "Get", "the", "access", "token", "for", "the", "user", "and", "save", "it" ]
6920bb0ead3060ac52eb968bc0df3c21b72e1ff6
https://github.com/seejohnrun/console_tweet/blob/6920bb0ead3060ac52eb968bc0df3c21b72e1ff6/lib/console_tweet/cli.rb#L116-L125
train
seejohnrun/console_tweet
lib/console_tweet/cli.rb
ConsoleTweet.CLI.replies
def replies(*args) load_default_token return failtown("Unauthorized, re-run setup!") unless @client && @client.authorized? # Only send since_id_replies to @client if it's not nil mentions = since_id_replies ? @client.mentions(:since_id => since_id_replies) : @client.mentions if mentions.an...
ruby
def replies(*args) load_default_token return failtown("Unauthorized, re-run setup!") unless @client && @client.authorized? # Only send since_id_replies to @client if it's not nil mentions = since_id_replies ? @client.mentions(:since_id => since_id_replies) : @client.mentions if mentions.an...
[ "def", "replies", "(", "*", "args", ")", "load_default_token", "return", "failtown", "(", "\"Unauthorized, re-run setup!\"", ")", "unless", "@client", "&&", "@client", ".", "authorized?", "mentions", "=", "since_id_replies", "?", "@client", ".", "mentions", "(", "...
Returns the 20 most recent @replies / mentions
[ "Returns", "the", "20", "most", "recent" ]
6920bb0ead3060ac52eb968bc0df3c21b72e1ff6
https://github.com/seejohnrun/console_tweet/blob/6920bb0ead3060ac52eb968bc0df3c21b72e1ff6/lib/console_tweet/cli.rb#L128-L138
train
seejohnrun/console_tweet
lib/console_tweet/cli.rb
ConsoleTweet.CLI.help
def help(*args) puts "#{NameColor}console-tweet#{DefaultColor} by John Crepezzi <john.crepezzi@gmail.com>" puts 'http://github.com/seejohnrun/console-tweet' puts puts "#{CommandColor}twitter#{DefaultColor} View your timeline, since last view" puts "#{CommandColor}twitter setup#{DefaultColo...
ruby
def help(*args) puts "#{NameColor}console-tweet#{DefaultColor} by John Crepezzi <john.crepezzi@gmail.com>" puts 'http://github.com/seejohnrun/console-tweet' puts puts "#{CommandColor}twitter#{DefaultColor} View your timeline, since last view" puts "#{CommandColor}twitter setup#{DefaultColo...
[ "def", "help", "(", "*", "args", ")", "puts", "\"#{NameColor}console-tweet#{DefaultColor} by John Crepezzi <john.crepezzi@gmail.com>\"", "puts", "'http://github.com/seejohnrun/console-tweet'", "puts", "puts", "\"#{CommandColor}twitter#{DefaultColor} View your timeline, since last view\"", ...
Display help section
[ "Display", "help", "section" ]
6920bb0ead3060ac52eb968bc0df3c21b72e1ff6
https://github.com/seejohnrun/console_tweet/blob/6920bb0ead3060ac52eb968bc0df3c21b72e1ff6/lib/console_tweet/cli.rb#L141-L151
train
ubcsanskrit/sanscript.rb
lib/sanscript/benchmark.rb
Sanscript.Benchmark.detect!
def detect!(time = 2, warmup = 1) ::Benchmark.ips do |x| x.config(time: time, warmup: warmup) TEST_STRINGS_FLAT.each do |scheme, string| x.report("Detect #{scheme}") do Sanscript::Detect.detect_scheme(string) end end x.compare! end true ...
ruby
def detect!(time = 2, warmup = 1) ::Benchmark.ips do |x| x.config(time: time, warmup: warmup) TEST_STRINGS_FLAT.each do |scheme, string| x.report("Detect #{scheme}") do Sanscript::Detect.detect_scheme(string) end end x.compare! end true ...
[ "def", "detect!", "(", "time", "=", "2", ",", "warmup", "=", "1", ")", "::", "Benchmark", ".", "ips", "do", "|", "x", "|", "x", ".", "config", "(", "time", ":", "time", ",", "warmup", ":", "warmup", ")", "TEST_STRINGS_FLAT", ".", "each", "do", "|...
Runs benchmark-ips test on detection methods.
[ "Runs", "benchmark", "-", "ips", "test", "on", "detection", "methods", "." ]
0e50c4a856599a7b13c9f0cbc281206245859c71
https://github.com/ubcsanskrit/sanscript.rb/blob/0e50c4a856599a7b13c9f0cbc281206245859c71/lib/sanscript/benchmark.rb#L51-L62
train
ubcsanskrit/sanscript.rb
lib/sanscript/benchmark.rb
Sanscript.Benchmark.transliterate_roman!
def transliterate_roman!(time = 2, warmup = 1) ::Benchmark.ips do |x| x.config(time: time, warmup: warmup) TEST_STRINGS[:roman].to_a.product(TEST_STRINGS_FLAT.keys).each do |(ak, av), bk| next if ak == bk x.report("#{ak} => #{bk}") do Sanscript.transliterate(av, ak,...
ruby
def transliterate_roman!(time = 2, warmup = 1) ::Benchmark.ips do |x| x.config(time: time, warmup: warmup) TEST_STRINGS[:roman].to_a.product(TEST_STRINGS_FLAT.keys).each do |(ak, av), bk| next if ak == bk x.report("#{ak} => #{bk}") do Sanscript.transliterate(av, ak,...
[ "def", "transliterate_roman!", "(", "time", "=", "2", ",", "warmup", "=", "1", ")", "::", "Benchmark", ".", "ips", "do", "|", "x", "|", "x", ".", "config", "(", "time", ":", "time", ",", "warmup", ":", "warmup", ")", "TEST_STRINGS", "[", ":roman", ...
Runs benchmark-ips test on roman-source transliteration methods.
[ "Runs", "benchmark", "-", "ips", "test", "on", "roman", "-", "source", "transliteration", "methods", "." ]
0e50c4a856599a7b13c9f0cbc281206245859c71
https://github.com/ubcsanskrit/sanscript.rb/blob/0e50c4a856599a7b13c9f0cbc281206245859c71/lib/sanscript/benchmark.rb#L65-L77
train
mastahyeti/ifdef
lib/ifdef/logic_processor.rb
Ifdef.LogicProcessor.on_or
def on_or(node) a, b = node.children.map { |c| @truth.fetch(c, process(c)) } if a == :true || b == :true :true elsif a == :false && b == :false :false else nil end end
ruby
def on_or(node) a, b = node.children.map { |c| @truth.fetch(c, process(c)) } if a == :true || b == :true :true elsif a == :false && b == :false :false else nil end end
[ "def", "on_or", "(", "node", ")", "a", ",", "b", "=", "node", ".", "children", ".", "map", "{", "|", "c", "|", "@truth", ".", "fetch", "(", "c", ",", "process", "(", "c", ")", ")", "}", "if", "a", "==", ":true", "||", "b", "==", ":true", ":...
Handle the `||` statement. node - the node to evaluate. Returns :true if either side is known to be true, :false if both sides are known to be false, and nil otherwise.
[ "Handle", "the", "||", "statement", "." ]
ad19060782b0fb9bf6c345272739b3bf4bd349f6
https://github.com/mastahyeti/ifdef/blob/ad19060782b0fb9bf6c345272739b3bf4bd349f6/lib/ifdef/logic_processor.rb#L33-L43
train
mastahyeti/ifdef
lib/ifdef/logic_processor.rb
Ifdef.LogicProcessor.on_send
def on_send(node) _target, _method, _args = node.children if _method == :! case @truth.fetch(_target, process(_target)) when :true :false when :false :true else nil end else nil end end
ruby
def on_send(node) _target, _method, _args = node.children if _method == :! case @truth.fetch(_target, process(_target)) when :true :false when :false :true else nil end else nil end end
[ "def", "on_send", "(", "node", ")", "_target", ",", "_method", ",", "_args", "=", "node", ".", "children", "if", "_method", "==", ":!", "case", "@truth", ".", "fetch", "(", "_target", ",", "process", "(", "_target", ")", ")", "when", ":true", ":false",...
Handles the `!` statement. node - the node to evaluate. Returns the inverse of the child expression.
[ "Handles", "the", "!", "statement", "." ]
ad19060782b0fb9bf6c345272739b3bf4bd349f6
https://github.com/mastahyeti/ifdef/blob/ad19060782b0fb9bf6c345272739b3bf4bd349f6/lib/ifdef/logic_processor.rb#L69-L84
train
mastahyeti/ifdef
lib/ifdef/logic_processor.rb
Ifdef.LogicProcessor.on_begin
def on_begin(node) child, other_children = *node.children # Not sure if this can happen in an `if` statement raise LogicError if other_children case @truth.fetch(child, process(child)) when :true :true when :false :false else nil end end
ruby
def on_begin(node) child, other_children = *node.children # Not sure if this can happen in an `if` statement raise LogicError if other_children case @truth.fetch(child, process(child)) when :true :true when :false :false else nil end end
[ "def", "on_begin", "(", "node", ")", "child", ",", "other_children", "=", "*", "node", ".", "children", "raise", "LogicError", "if", "other_children", "case", "@truth", ".", "fetch", "(", "child", ",", "process", "(", "child", ")", ")", "when", ":true", ...
Handle logic statements explicitly wrapped in parenthesis. node - the node to evaluate. Returns the result of the statement within the parenthesis.
[ "Handle", "logic", "statements", "explicitly", "wrapped", "in", "parenthesis", "." ]
ad19060782b0fb9bf6c345272739b3bf4bd349f6
https://github.com/mastahyeti/ifdef/blob/ad19060782b0fb9bf6c345272739b3bf4bd349f6/lib/ifdef/logic_processor.rb#L91-L105
train
postmodern/deployml
lib/deployml/environment.rb
DeploYML.Environment.remote_shell
def remote_shell(&block) each_dest.map do |dest| shell = if dest.scheme == 'file' LocalShell else RemoteShell end shell.new(dest,self,&block) end end
ruby
def remote_shell(&block) each_dest.map do |dest| shell = if dest.scheme == 'file' LocalShell else RemoteShell end shell.new(dest,self,&block) end end
[ "def", "remote_shell", "(", "&", "block", ")", "each_dest", ".", "map", "do", "|", "dest", "|", "shell", "=", "if", "dest", ".", "scheme", "==", "'file'", "LocalShell", "else", "RemoteShell", "end", "shell", ".", "new", "(", "dest", ",", "self", ",", ...
Creates a remote shell with the destination server. @yield [shell] If a block is given, it will be passed the new remote shell. @yieldparam [LocalShell, RemoteShell] shell The remote shell. @return [Array<RemoteShell, LocalShell>] The remote shell. If the destination is a local `file://` URI, a local ...
[ "Creates", "a", "remote", "shell", "with", "the", "destination", "server", "." ]
4369d4ea719e41f0dc3aa6496e6422ad476b0dda
https://github.com/postmodern/deployml/blob/4369d4ea719e41f0dc3aa6496e6422ad476b0dda/lib/deployml/environment.rb#L94-L104
train
postmodern/deployml
lib/deployml/environment.rb
DeploYML.Environment.exec
def exec(command) remote_shell do |shell| shell.cd(shell.uri.path) shell.exec(command) end return true end
ruby
def exec(command) remote_shell do |shell| shell.cd(shell.uri.path) shell.exec(command) end return true end
[ "def", "exec", "(", "command", ")", "remote_shell", "do", "|", "shell", "|", "shell", ".", "cd", "(", "shell", ".", "uri", ".", "path", ")", "shell", ".", "exec", "(", "command", ")", "end", "return", "true", "end" ]
Runs a command on the destination server, in the destination directory. @return [true] @since 0.3.0
[ "Runs", "a", "command", "on", "the", "destination", "server", "in", "the", "destination", "directory", "." ]
4369d4ea719e41f0dc3aa6496e6422ad476b0dda
https://github.com/postmodern/deployml/blob/4369d4ea719e41f0dc3aa6496e6422ad476b0dda/lib/deployml/environment.rb#L114-L121
train
postmodern/deployml
lib/deployml/environment.rb
DeploYML.Environment.rake
def rake(task,*arguments) remote_shell do |shell| shell.cd(shell.uri.path) shell.rake(task,*arguments) end return true end
ruby
def rake(task,*arguments) remote_shell do |shell| shell.cd(shell.uri.path) shell.rake(task,*arguments) end return true end
[ "def", "rake", "(", "task", ",", "*", "arguments", ")", "remote_shell", "do", "|", "shell", "|", "shell", ".", "cd", "(", "shell", ".", "uri", ".", "path", ")", "shell", ".", "rake", "(", "task", ",", "*", "arguments", ")", "end", "return", "true",...
Executes a Rake task on the destination server, in the destination directory. @return [true] @since 0.3.0
[ "Executes", "a", "Rake", "task", "on", "the", "destination", "server", "in", "the", "destination", "directory", "." ]
4369d4ea719e41f0dc3aa6496e6422ad476b0dda
https://github.com/postmodern/deployml/blob/4369d4ea719e41f0dc3aa6496e6422ad476b0dda/lib/deployml/environment.rb#L131-L138
train
postmodern/deployml
lib/deployml/environment.rb
DeploYML.Environment.ssh
def ssh(*arguments) each_dest do |dest| RemoteShell.new(dest).ssh(*arguments) end return true end
ruby
def ssh(*arguments) each_dest do |dest| RemoteShell.new(dest).ssh(*arguments) end return true end
[ "def", "ssh", "(", "*", "arguments", ")", "each_dest", "do", "|", "dest", "|", "RemoteShell", ".", "new", "(", "dest", ")", ".", "ssh", "(", "*", "arguments", ")", "end", "return", "true", "end" ]
Starts an SSH session with the destination server. @param [Array] arguments Additional arguments to pass to SSH. @return [true] @since 0.3.0
[ "Starts", "an", "SSH", "session", "with", "the", "destination", "server", "." ]
4369d4ea719e41f0dc3aa6496e6422ad476b0dda
https://github.com/postmodern/deployml/blob/4369d4ea719e41f0dc3aa6496e6422ad476b0dda/lib/deployml/environment.rb#L150-L156
train
postmodern/deployml
lib/deployml/environment.rb
DeploYML.Environment.setup
def setup(shell) shell.status "Cloning #{@source} ..." shell.run 'git', 'clone', '--depth', 1, @source, shell.uri.path shell.status "Cloned #{@source}." end
ruby
def setup(shell) shell.status "Cloning #{@source} ..." shell.run 'git', 'clone', '--depth', 1, @source, shell.uri.path shell.status "Cloned #{@source}." end
[ "def", "setup", "(", "shell", ")", "shell", ".", "status", "\"Cloning #{@source} ...\"", "shell", ".", "run", "'git'", ",", "'clone'", ",", "'--depth'", ",", "1", ",", "@source", ",", "shell", ".", "uri", ".", "path", "shell", ".", "status", "\"Cloned #{@s...
Sets up the deployment repository for the project. @param [Shell] shell The remote shell to execute commands through. @since 0.3.0
[ "Sets", "up", "the", "deployment", "repository", "for", "the", "project", "." ]
4369d4ea719e41f0dc3aa6496e6422ad476b0dda
https://github.com/postmodern/deployml/blob/4369d4ea719e41f0dc3aa6496e6422ad476b0dda/lib/deployml/environment.rb#L166-L172
train
postmodern/deployml
lib/deployml/environment.rb
DeploYML.Environment.update
def update(shell) shell.status "Updating ..." shell.run 'git', 'reset', '--hard', 'HEAD' shell.run 'git', 'pull', '-f' shell.status "Updated." end
ruby
def update(shell) shell.status "Updating ..." shell.run 'git', 'reset', '--hard', 'HEAD' shell.run 'git', 'pull', '-f' shell.status "Updated." end
[ "def", "update", "(", "shell", ")", "shell", ".", "status", "\"Updating ...\"", "shell", ".", "run", "'git'", ",", "'reset'", ",", "'--hard'", ",", "'HEAD'", "shell", ".", "run", "'git'", ",", "'pull'", ",", "'-f'", "shell", ".", "status", "\"Updated.\"", ...
Updates the deployed repository for the project. @param [Shell] shell The remote shell to execute commands through. @since 0.3.0
[ "Updates", "the", "deployed", "repository", "for", "the", "project", "." ]
4369d4ea719e41f0dc3aa6496e6422ad476b0dda
https://github.com/postmodern/deployml/blob/4369d4ea719e41f0dc3aa6496e6422ad476b0dda/lib/deployml/environment.rb#L182-L189
train
postmodern/deployml
lib/deployml/environment.rb
DeploYML.Environment.invoke_task
def invoke_task(task,shell) unless TASKS.include?(task) raise("invalid task: #{task}") end if @before.has_key?(task) @before[task].each { |command| shell.exec(command) } end send(task,shell) if respond_to?(task) if @after.has_key?(task) @after[task].each { ...
ruby
def invoke_task(task,shell) unless TASKS.include?(task) raise("invalid task: #{task}") end if @before.has_key?(task) @before[task].each { |command| shell.exec(command) } end send(task,shell) if respond_to?(task) if @after.has_key?(task) @after[task].each { ...
[ "def", "invoke_task", "(", "task", ",", "shell", ")", "unless", "TASKS", ".", "include?", "(", "task", ")", "raise", "(", "\"invalid task: #{task}\"", ")", "end", "if", "@before", ".", "has_key?", "(", "task", ")", "@before", "[", "task", "]", ".", "each...
Invokes a task. @param [Symbol] task The name of the task to run. @param [Shell] shell The shell to run the task in. @raise [RuntimeError] The task name was not known. @since 0.5.0
[ "Invokes", "a", "task", "." ]
4369d4ea719e41f0dc3aa6496e6422ad476b0dda
https://github.com/postmodern/deployml/blob/4369d4ea719e41f0dc3aa6496e6422ad476b0dda/lib/deployml/environment.rb#L326-L340
train
postmodern/deployml
lib/deployml/environment.rb
DeploYML.Environment.invoke
def invoke(tasks) remote_shell do |shell| # setup the deployment repository invoke_task(:setup,shell) if tasks.include?(:setup) # cd into the deployment repository shell.cd(shell.uri.path) # update the deployment repository invoke_task(:update,shell) if tasks.incl...
ruby
def invoke(tasks) remote_shell do |shell| # setup the deployment repository invoke_task(:setup,shell) if tasks.include?(:setup) # cd into the deployment repository shell.cd(shell.uri.path) # update the deployment repository invoke_task(:update,shell) if tasks.incl...
[ "def", "invoke", "(", "tasks", ")", "remote_shell", "do", "|", "shell", "|", "invoke_task", "(", ":setup", ",", "shell", ")", "if", "tasks", ".", "include?", "(", ":setup", ")", "shell", ".", "cd", "(", "shell", ".", "uri", ".", "path", ")", "invoke_...
Deploys the project. @param [Array<Symbol>] tasks The tasks to run during the deployment. @return [true] Indicates that the tasks were successfully completed. @since 0.4.0
[ "Deploys", "the", "project", "." ]
4369d4ea719e41f0dc3aa6496e6422ad476b0dda
https://github.com/postmodern/deployml/blob/4369d4ea719e41f0dc3aa6496e6422ad476b0dda/lib/deployml/environment.rb#L353-L381
train
postmodern/deployml
lib/deployml/environment.rb
DeploYML.Environment.load_framework!
def load_framework! if @orm unless FRAMEWORKS.has_key?(@framework) raise(UnknownFramework,"Unknown framework #{@framework}",caller) end extend FRAMEWORKS[@framework] initialize_framework if respond_to?(:initialize_framework) end end
ruby
def load_framework! if @orm unless FRAMEWORKS.has_key?(@framework) raise(UnknownFramework,"Unknown framework #{@framework}",caller) end extend FRAMEWORKS[@framework] initialize_framework if respond_to?(:initialize_framework) end end
[ "def", "load_framework!", "if", "@orm", "unless", "FRAMEWORKS", ".", "has_key?", "(", "@framework", ")", "raise", "(", "UnknownFramework", ",", "\"Unknown framework #{@framework}\"", ",", "caller", ")", "end", "extend", "FRAMEWORKS", "[", "@framework", "]", "initial...
Loads the framework configuration. @since 0.3.0
[ "Loads", "the", "framework", "configuration", "." ]
4369d4ea719e41f0dc3aa6496e6422ad476b0dda
https://github.com/postmodern/deployml/blob/4369d4ea719e41f0dc3aa6496e6422ad476b0dda/lib/deployml/environment.rb#L510-L520
train
postmodern/deployml
lib/deployml/environment.rb
DeploYML.Environment.load_server!
def load_server! if @server_name unless SERVERS.has_key?(@server_name) raise(UnknownServer,"Unknown server name #{@server_name}",caller) end extend SERVERS[@server_name] initialize_server if respond_to?(:initialize_server) end end
ruby
def load_server! if @server_name unless SERVERS.has_key?(@server_name) raise(UnknownServer,"Unknown server name #{@server_name}",caller) end extend SERVERS[@server_name] initialize_server if respond_to?(:initialize_server) end end
[ "def", "load_server!", "if", "@server_name", "unless", "SERVERS", ".", "has_key?", "(", "@server_name", ")", "raise", "(", "UnknownServer", ",", "\"Unknown server name #{@server_name}\"", ",", "caller", ")", "end", "extend", "SERVERS", "[", "@server_name", "]", "ini...
Loads the server configuration. @raise [UnknownServer] @since 0.3.0
[ "Loads", "the", "server", "configuration", "." ]
4369d4ea719e41f0dc3aa6496e6422ad476b0dda
https://github.com/postmodern/deployml/blob/4369d4ea719e41f0dc3aa6496e6422ad476b0dda/lib/deployml/environment.rb#L529-L539
train
ideonetwork/lato-core
lib/lato_core/interfaces/authentication.rb
LatoCore.Interface::Authentication.core__create_superuser_session
def core__create_superuser_session(superuser, lifetime) token = core__encode_token(lifetime, superuser_id: superuser.id) session[:lato_core__superuser_session_token] = token end
ruby
def core__create_superuser_session(superuser, lifetime) token = core__encode_token(lifetime, superuser_id: superuser.id) session[:lato_core__superuser_session_token] = token end
[ "def", "core__create_superuser_session", "(", "superuser", ",", "lifetime", ")", "token", "=", "core__encode_token", "(", "lifetime", ",", "superuser_id", ":", "superuser", ".", "id", ")", "session", "[", ":lato_core__superuser_session_token", "]", "=", "token", "en...
This function set a cookie to create the superuser session.
[ "This", "function", "set", "a", "cookie", "to", "create", "the", "superuser", "session", "." ]
c01fa585725c8e9992f25d8a7bd4ba2d0bfca08c
https://github.com/ideonetwork/lato-core/blob/c01fa585725c8e9992f25d8a7bd4ba2d0bfca08c/lib/lato_core/interfaces/authentication.rb#L9-L12
train
ideonetwork/lato-core
lib/lato_core/interfaces/authentication.rb
LatoCore.Interface::Authentication.core__manage_superuser_session
def core__manage_superuser_session(permission = nil) decoded_token = core__decode_token(session[:lato_core__superuser_session_token]) if decoded_token @core__current_superuser = LatoCore::Superuser.find_by(id: decoded_token[:superuser_id]) unless @core__current_superuser core__des...
ruby
def core__manage_superuser_session(permission = nil) decoded_token = core__decode_token(session[:lato_core__superuser_session_token]) if decoded_token @core__current_superuser = LatoCore::Superuser.find_by(id: decoded_token[:superuser_id]) unless @core__current_superuser core__des...
[ "def", "core__manage_superuser_session", "(", "permission", "=", "nil", ")", "decoded_token", "=", "core__decode_token", "(", "session", "[", ":lato_core__superuser_session_token", "]", ")", "if", "decoded_token", "@core__current_superuser", "=", "LatoCore", "::", "Superu...
This function check the session for a superuser and set the variable @core__current_superuser. If session is not valid the user should be redirect to login path.
[ "This", "function", "check", "the", "session", "for", "a", "superuser", "and", "set", "the", "variable" ]
c01fa585725c8e9992f25d8a7bd4ba2d0bfca08c
https://github.com/ideonetwork/lato-core/blob/c01fa585725c8e9992f25d8a7bd4ba2d0bfca08c/lib/lato_core/interfaces/authentication.rb#L28-L45
train
leshill/mongodoc
lib/mongo_doc/matchers.rb
MongoDoc.Matchers.matcher
def matcher(key, value) if value.is_a?(Hash) name = "Mongoid::Matchers::#{value.keys.first.gsub("$", "").camelize}" return name.constantize.new(send(key)) end Mongoid::Matchers::Default.new(send(key)) end
ruby
def matcher(key, value) if value.is_a?(Hash) name = "Mongoid::Matchers::#{value.keys.first.gsub("$", "").camelize}" return name.constantize.new(send(key)) end Mongoid::Matchers::Default.new(send(key)) end
[ "def", "matcher", "(", "key", ",", "value", ")", "if", "value", ".", "is_a?", "(", "Hash", ")", "name", "=", "\"Mongoid::Matchers::#{value.keys.first.gsub(\"$\", \"\").camelize}\"", "return", "name", ".", "constantize", ".", "new", "(", "send", "(", "key", ")", ...
Get the matcher for the supplied key and value. Will determine the class name from the key.
[ "Get", "the", "matcher", "for", "the", "supplied", "key", "and", "value", ".", "Will", "determine", "the", "class", "name", "from", "the", "key", "." ]
fb2a4ec456d4c4ae1eb92e117dc73f55951fc3b4
https://github.com/leshill/mongodoc/blob/fb2a4ec456d4c4ae1eb92e117dc73f55951fc3b4/lib/mongo_doc/matchers.rb#L27-L33
train
Sharparam/chatrix
lib/chatrix/user.rb
Chatrix.User.process_power_level
def process_power_level(room, level) membership = (@memberships[room] ||= {}) membership[:power] = level broadcast(:power_level, self, room, level) end
ruby
def process_power_level(room, level) membership = (@memberships[room] ||= {}) membership[:power] = level broadcast(:power_level, self, room, level) end
[ "def", "process_power_level", "(", "room", ",", "level", ")", "membership", "=", "(", "@memberships", "[", "room", "]", "||=", "{", "}", ")", "membership", "[", ":power", "]", "=", "level", "broadcast", "(", ":power_level", ",", "self", ",", "room", ",",...
Process a power level update in a room. @param room [Room] The room where the level updated. @param level [Fixnum] The new power level.
[ "Process", "a", "power", "level", "update", "in", "a", "room", "." ]
6f2e9cf3a614ba7e8a9960f7d9b97092c0ce1e34
https://github.com/Sharparam/chatrix/blob/6f2e9cf3a614ba7e8a9960f7d9b97092c0ce1e34/lib/chatrix/user.rb#L73-L77
train
Sharparam/chatrix
lib/chatrix/user.rb
Chatrix.User.process_invite
def process_invite(room, sender, event) # Return early if we're already part of this room membership = (@memberships[room] ||= {}) return if membership[:type] == :join process_member_event room, event broadcast(:invited, self, room, sender) end
ruby
def process_invite(room, sender, event) # Return early if we're already part of this room membership = (@memberships[room] ||= {}) return if membership[:type] == :join process_member_event room, event broadcast(:invited, self, room, sender) end
[ "def", "process_invite", "(", "room", ",", "sender", ",", "event", ")", "membership", "=", "(", "@memberships", "[", "room", "]", "||=", "{", "}", ")", "return", "if", "membership", "[", ":type", "]", "==", ":join", "process_member_event", "room", ",", "...
Process an invite to a room. @param room [Room] The room the user was invited to. @param sender [User] The user who sent the invite. @param event [Hash] Event data.
[ "Process", "an", "invite", "to", "a", "room", "." ]
6f2e9cf3a614ba7e8a9960f7d9b97092c0ce1e34
https://github.com/Sharparam/chatrix/blob/6f2e9cf3a614ba7e8a9960f7d9b97092c0ce1e34/lib/chatrix/user.rb#L83-L89
train
Sharparam/chatrix
lib/chatrix/user.rb
Chatrix.User.update
def update(data) update_avatar(data['avatar_url']) if data.key? 'avatar_url' update_displayname(data['displayname']) if data.key? 'displayname' end
ruby
def update(data) update_avatar(data['avatar_url']) if data.key? 'avatar_url' update_displayname(data['displayname']) if data.key? 'displayname' end
[ "def", "update", "(", "data", ")", "update_avatar", "(", "data", "[", "'avatar_url'", "]", ")", "if", "data", ".", "key?", "'avatar_url'", "update_displayname", "(", "data", "[", "'displayname'", "]", ")", "if", "data", ".", "key?", "'displayname'", "end" ]
Updates metadata for this user. @param data [Hash{String=>String}] User metadata.
[ "Updates", "metadata", "for", "this", "user", "." ]
6f2e9cf3a614ba7e8a9960f7d9b97092c0ce1e34
https://github.com/Sharparam/chatrix/blob/6f2e9cf3a614ba7e8a9960f7d9b97092c0ce1e34/lib/chatrix/user.rb#L102-L105
train
kunishi/algebra-ruby2
lib/algebra/algebraic-system.rb
Algebra.AlgebraCreator.wedge
def wedge(otype) # =:= tensor if superior?(otype) self elsif otype.respond_to?(:superior?) && otype.superior?(self) otype else raise "wedge: unknown pair (#{self}) .wedge (#{otype})" end end
ruby
def wedge(otype) # =:= tensor if superior?(otype) self elsif otype.respond_to?(:superior?) && otype.superior?(self) otype else raise "wedge: unknown pair (#{self}) .wedge (#{otype})" end end
[ "def", "wedge", "(", "otype", ")", "if", "superior?", "(", "otype", ")", "self", "elsif", "otype", ".", "respond_to?", "(", ":superior?", ")", "&&", "otype", ".", "superior?", "(", "self", ")", "otype", "else", "raise", "\"wedge: unknown pair (#{self}) .wedge ...
Needed in the type conversion of MatrixAlgebra
[ "Needed", "in", "the", "type", "conversion", "of", "MatrixAlgebra" ]
8976fbaac14933d3206324c845b879bf67fa0cf7
https://github.com/kunishi/algebra-ruby2/blob/8976fbaac14933d3206324c845b879bf67fa0cf7/lib/algebra/algebraic-system.rb#L28-L36
train
Birdie0/qna_maker
lib/qna_maker/endpoints/delete_kb.rb
QnAMaker.Client.delete_kb
def delete_kb response = @http.delete( "#{BASE_URL}/#{knowledgebase_id}" ) case response.code when 204 nil when 400 raise BadArgumentError, response.parse['error']['message'].join(' ') when 401 raise UnauthorizedError, response.parse['error']['message...
ruby
def delete_kb response = @http.delete( "#{BASE_URL}/#{knowledgebase_id}" ) case response.code when 204 nil when 400 raise BadArgumentError, response.parse['error']['message'].join(' ') when 401 raise UnauthorizedError, response.parse['error']['message...
[ "def", "delete_kb", "response", "=", "@http", ".", "delete", "(", "\"#{BASE_URL}/#{knowledgebase_id}\"", ")", "case", "response", ".", "code", "when", "204", "nil", "when", "400", "raise", "BadArgumentError", ",", "response", ".", "parse", "[", "'error'", "]", ...
Deletes the current knowledge base and all data associated with it. @return [nil] on success
[ "Deletes", "the", "current", "knowledge", "base", "and", "all", "data", "associated", "with", "it", "." ]
5ac204ede100355352438b8ff4fe30ad84d9257b
https://github.com/Birdie0/qna_maker/blob/5ac204ede100355352438b8ff4fe30ad84d9257b/lib/qna_maker/endpoints/delete_kb.rb#L8-L29
train
iaintshine/ruby-spanmanager
lib/spanmanager/tracer.rb
SpanManager.Tracer.start_span
def start_span(operation_name, child_of: active_span, **args) span = @tracer.start_span(operation_name, child_of: child_of, **args) @managed_span_source.make_active(span) end
ruby
def start_span(operation_name, child_of: active_span, **args) span = @tracer.start_span(operation_name, child_of: child_of, **args) @managed_span_source.make_active(span) end
[ "def", "start_span", "(", "operation_name", ",", "child_of", ":", "active_span", ",", "**", "args", ")", "span", "=", "@tracer", ".", "start_span", "(", "operation_name", ",", "child_of", ":", "child_of", ",", "**", "args", ")", "@managed_span_source", ".", ...
Starts a new active span. @param operation_name [String] The operation name for the Span @param child_of [SpanContext, Span] SpanContext that acts as a parent to the newly-started Span. If default argument is used then the currently active span becomes an implicit parent of a newly-started span. @...
[ "Starts", "a", "new", "active", "span", "." ]
95f14b13269f35eacef88d61fa82dac90adde3be
https://github.com/iaintshine/ruby-spanmanager/blob/95f14b13269f35eacef88d61fa82dac90adde3be/lib/spanmanager/tracer.rb#L42-L45
train
jwagener/oauth-active-resource
lib/oauth_active_resource/connection.rb
OAuthActiveResource.Connection.handle_response
def handle_response(response) return super(response) rescue ActiveResource::ClientError => exc begin # ugly code to insert the error_message into response error_message = "#{format.decode response.body}" if not error_message.nil? or error_message == "" exc.response.inst...
ruby
def handle_response(response) return super(response) rescue ActiveResource::ClientError => exc begin # ugly code to insert the error_message into response error_message = "#{format.decode response.body}" if not error_message.nil? or error_message == "" exc.response.inst...
[ "def", "handle_response", "(", "response", ")", "return", "super", "(", "response", ")", "rescue", "ActiveResource", "::", "ClientError", "=>", "exc", "begin", "error_message", "=", "\"#{format.decode response.body}\"", "if", "not", "error_message", ".", "nil?", "or...
make handle_response public and add error message from body if possible
[ "make", "handle_response", "public", "and", "add", "error", "message", "from", "body", "if", "possible" ]
fc5fc1e1a9fda157c1fc6d792a9cdf2491b59676
https://github.com/jwagener/oauth-active-resource/blob/fc5fc1e1a9fda157c1fc6d792a9cdf2491b59676/lib/oauth_active_resource/connection.rb#L14-L28
train
wordjelly/Auth
app/models/auth/concerns/shopping/product_concern.rb
Auth::Concerns::Shopping::ProductConcern.ClassMethods.add_to_previous_rolling_n_minutes
def add_to_previous_rolling_n_minutes(minutes,origin_epoch,cycle_to_add) ## get all the minutes less than that. rolling_n_minutes_less_than_that = minutes.keys.select{|c| c < origin_epoch} end_min = rolling_n_minutes_less_than_that.size < Auth.configuration.rolling_minutes ? rolling_n_minutes_less_than_th...
ruby
def add_to_previous_rolling_n_minutes(minutes,origin_epoch,cycle_to_add) ## get all the minutes less than that. rolling_n_minutes_less_than_that = minutes.keys.select{|c| c < origin_epoch} end_min = rolling_n_minutes_less_than_that.size < Auth.configuration.rolling_minutes ? rolling_n_minutes_less_than_th...
[ "def", "add_to_previous_rolling_n_minutes", "(", "minutes", ",", "origin_epoch", ",", "cycle_to_add", ")", "rolling_n_minutes_less_than_that", "=", "minutes", ".", "keys", ".", "select", "{", "|", "c", "|", "c", "<", "origin_epoch", "}", "end_min", "=", "rolling_n...
so we have completed the rolling n minutes.
[ "so", "we", "have", "completed", "the", "rolling", "n", "minutes", "." ]
e1b6697a13c845f57b3cc83bfb79059a09541f47
https://github.com/wordjelly/Auth/blob/e1b6697a13c845f57b3cc83bfb79059a09541f47/app/models/auth/concerns/shopping/product_concern.rb#L121-L135
train
arman000/delorean_lang
lib/delorean/engine.rb
Delorean.Engine.parse_check_defined_node
def parse_check_defined_node(name, flag) isdef = node_defined?(name) if isdef != flag isdef ? err(RedefinedError, "#{name} already defined") : err(UndefinedError, "#{name} not defined yet") end end
ruby
def parse_check_defined_node(name, flag) isdef = node_defined?(name) if isdef != flag isdef ? err(RedefinedError, "#{name} already defined") : err(UndefinedError, "#{name} not defined yet") end end
[ "def", "parse_check_defined_node", "(", "name", ",", "flag", ")", "isdef", "=", "node_defined?", "(", "name", ")", "if", "isdef", "!=", "flag", "isdef", "?", "err", "(", "RedefinedError", ",", "\"#{name} already defined\"", ")", ":", "err", "(", "UndefinedErro...
Check to see if node with given name is defined. flag tells the method about our expectation. flag=true means that we make sure that name is defined. flag=false is the opposite.
[ "Check", "to", "see", "if", "node", "with", "given", "name", "is", "defined", ".", "flag", "tells", "the", "method", "about", "our", "expectation", ".", "flag", "=", "true", "means", "that", "we", "make", "sure", "that", "name", "is", "defined", ".", "...
25ef95238a1e15d5640afa468bd300c80fc68298
https://github.com/arman000/delorean_lang/blob/25ef95238a1e15d5640afa468bd300c80fc68298/lib/delorean/engine.rb#L81-L88
train
arman000/delorean_lang
lib/delorean/engine.rb
Delorean.Engine.parse_call_attr
def parse_call_attr(node_name, attr_name) return [] if comp_set.member?(attr_name) # get the class associated with node klass = @pm.module_eval(node_name) # puts attr_name, "#{attr_name}#{POST}".to_sym, klass.methods.inspect begin klass.send("#{attr_name}#{POST}".to_sym, []) ...
ruby
def parse_call_attr(node_name, attr_name) return [] if comp_set.member?(attr_name) # get the class associated with node klass = @pm.module_eval(node_name) # puts attr_name, "#{attr_name}#{POST}".to_sym, klass.methods.inspect begin klass.send("#{attr_name}#{POST}".to_sym, []) ...
[ "def", "parse_call_attr", "(", "node_name", ",", "attr_name", ")", "return", "[", "]", "if", "comp_set", ".", "member?", "(", "attr_name", ")", "klass", "=", "@pm", ".", "module_eval", "(", "node_name", ")", "begin", "klass", ".", "send", "(", "\"#{attr_na...
Parse-time check to see if attr is available. If not, error is raised.
[ "Parse", "-", "time", "check", "to", "see", "if", "attr", "is", "available", ".", "If", "not", "error", "is", "raised", "." ]
25ef95238a1e15d5640afa468bd300c80fc68298
https://github.com/arman000/delorean_lang/blob/25ef95238a1e15d5640afa468bd300c80fc68298/lib/delorean/engine.rb#L118-L131
train
arman000/delorean_lang
lib/delorean/engine.rb
Delorean.Engine.parse_define_attr
def parse_define_attr(name, spec) err(ParseError, "Can't define '#{name}' outside a node") unless @last_node err(RedefinedError, "Can't redefine '#{name}' in node #{@last_node}") if @node_attrs[@last_node].member? name @node_attrs[@last_node] << name checks = spec.map do |a| ...
ruby
def parse_define_attr(name, spec) err(ParseError, "Can't define '#{name}' outside a node") unless @last_node err(RedefinedError, "Can't redefine '#{name}' in node #{@last_node}") if @node_attrs[@last_node].member? name @node_attrs[@last_node] << name checks = spec.map do |a| ...
[ "def", "parse_define_attr", "(", "name", ",", "spec", ")", "err", "(", "ParseError", ",", "\"Can't define '#{name}' outside a node\"", ")", "unless", "@last_node", "err", "(", "RedefinedError", ",", "\"Can't redefine '#{name}' in node #{@last_node}\"", ")", "if", "@node_a...
parse-time attr definition
[ "parse", "-", "time", "attr", "definition" ]
25ef95238a1e15d5640afa468bd300c80fc68298
https://github.com/arman000/delorean_lang/blob/25ef95238a1e15d5640afa468bd300c80fc68298/lib/delorean/engine.rb#L154-L180
train
arman000/delorean_lang
lib/delorean/engine.rb
Delorean.Engine.enumerate_params_by_node
def enumerate_params_by_node(node) attrs = enumerate_attrs_by_node(node) Set.new(attrs.select { |a| @param_set.include?(a) }) end
ruby
def enumerate_params_by_node(node) attrs = enumerate_attrs_by_node(node) Set.new(attrs.select { |a| @param_set.include?(a) }) end
[ "def", "enumerate_params_by_node", "(", "node", ")", "attrs", "=", "enumerate_attrs_by_node", "(", "node", ")", "Set", ".", "new", "(", "attrs", ".", "select", "{", "|", "a", "|", "@param_set", ".", "include?", "(", "a", ")", "}", ")", "end" ]
enumerate params by a single node
[ "enumerate", "params", "by", "a", "single", "node" ]
25ef95238a1e15d5640afa468bd300c80fc68298
https://github.com/arman000/delorean_lang/blob/25ef95238a1e15d5640afa468bd300c80fc68298/lib/delorean/engine.rb#L358-L361
train
siyegen/instrumentable
lib/instrumentable.rb
Instrumentable.ClassMethods.class_instrument_method
def class_instrument_method(klass, method_to_instrument, event_name, payload={}) class << klass; self; end.class_eval do Instrumentality.begin(self, method_to_instrument, event_name, payload) end end
ruby
def class_instrument_method(klass, method_to_instrument, event_name, payload={}) class << klass; self; end.class_eval do Instrumentality.begin(self, method_to_instrument, event_name, payload) end end
[ "def", "class_instrument_method", "(", "klass", ",", "method_to_instrument", ",", "event_name", ",", "payload", "=", "{", "}", ")", "class", "<<", "klass", ";", "self", ";", "end", ".", "class_eval", "do", "Instrumentality", ".", "begin", "(", "self", ",", ...
Class implementation of +instrument_method+
[ "Class", "implementation", "of", "+", "instrument_method", "+" ]
9180a4661980e88f283dc8c424847f89fbeff2ae
https://github.com/siyegen/instrumentable/blob/9180a4661980e88f283dc8c424847f89fbeff2ae/lib/instrumentable.rb#L63-L67
train
code-and-effect/effective_regions
app/models/effective/region.rb
Effective.Region.snippet_objects
def snippet_objects(locals = {}) locals = {} unless locals.kind_of?(Hash) @snippet_objects ||= snippets.map do |key, snippet| # Key here is 'snippet_1' if snippet['class_name'] klass = "Effective::Snippets::#{snippet['class_name'].classify}".safe_constantize klass.new(snippet.me...
ruby
def snippet_objects(locals = {}) locals = {} unless locals.kind_of?(Hash) @snippet_objects ||= snippets.map do |key, snippet| # Key here is 'snippet_1' if snippet['class_name'] klass = "Effective::Snippets::#{snippet['class_name'].classify}".safe_constantize klass.new(snippet.me...
[ "def", "snippet_objects", "(", "locals", "=", "{", "}", ")", "locals", "=", "{", "}", "unless", "locals", ".", "kind_of?", "(", "Hash", ")", "@snippet_objects", "||=", "snippets", ".", "map", "do", "|", "key", ",", "snippet", "|", "if", "snippet", "[",...
Hash of the Snippets objectified Returns a Hash of {'snippet_1' => CurrentUserInfo.new(snippets[:key]['options'])}
[ "Hash", "of", "the", "Snippets", "objectified" ]
c24fc30b5012420b81e7d156fd712590f23b9d0c
https://github.com/code-and-effect/effective_regions/blob/c24fc30b5012420b81e7d156fd712590f23b9d0c/app/models/effective/region.rb#L28-L36
train
blahah/biopsy
lib/biopsy/optimisers/tabu_search.rb
Biopsy.Distribution.draw
def draw r = @dist.rng.to_i raise "drawn number must be an integer" unless r.is_a? Integer # keep the value inside the allowed range r = 0 - r if r < 0 if r >= @range.size diff = 1 + r - @range.size r = @range.size - diff end @range[r] end
ruby
def draw r = @dist.rng.to_i raise "drawn number must be an integer" unless r.is_a? Integer # keep the value inside the allowed range r = 0 - r if r < 0 if r >= @range.size diff = 1 + r - @range.size r = @range.size - diff end @range[r] end
[ "def", "draw", "r", "=", "@dist", ".", "rng", ".", "to_i", "raise", "\"drawn number must be an integer\"", "unless", "r", ".", "is_a?", "Integer", "r", "=", "0", "-", "r", "if", "r", "<", "0", "if", "r", ">=", "@range", ".", "size", "diff", "=", "1",...
draw from the distribution
[ "draw", "from", "the", "distribution" ]
e46f3d1c75de4da2ec47a377f7e4f0e16a8e03d2
https://github.com/blahah/biopsy/blob/e46f3d1c75de4da2ec47a377f7e4f0e16a8e03d2/lib/biopsy/optimisers/tabu_search.rb#L69-L79
train
blahah/biopsy
lib/biopsy/optimisers/tabu_search.rb
Biopsy.Hood.generate_neighbour
def generate_neighbour n = 0 begin if n >= 100 # taking too long to generate a neighbour, # loosen the neighbourhood structure so we explore further # debug("loosening distributions") @distributions.each do |param, dist| dist.loosen end ...
ruby
def generate_neighbour n = 0 begin if n >= 100 # taking too long to generate a neighbour, # loosen the neighbourhood structure so we explore further # debug("loosening distributions") @distributions.each do |param, dist| dist.loosen end ...
[ "def", "generate_neighbour", "n", "=", "0", "begin", "if", "n", ">=", "100", "@distributions", ".", "each", "do", "|", "param", ",", "dist", "|", "dist", ".", "loosen", "end", "end", "neighbour", "=", "Hash", "[", "@distributions", ".", "map", "{", "|"...
generate a single neighbour
[ "generate", "a", "single", "neighbour" ]
e46f3d1c75de4da2ec47a377f7e4f0e16a8e03d2
https://github.com/blahah/biopsy/blob/e46f3d1c75de4da2ec47a377f7e4f0e16a8e03d2/lib/biopsy/optimisers/tabu_search.rb#L107-L124
train
blahah/biopsy
lib/biopsy/optimisers/tabu_search.rb
Biopsy.TabuSearch.update_neighbourhood_structure
def update_neighbourhood_structure self.update_recent_scores best = self.backtrack_or_continue unless @distributions.empty? @standard_deviations = Hash[@distributions.map { |k, d| [k, d.sd] }] end best[:parameters].each_pair do |param, value| self.update_distribution(param,...
ruby
def update_neighbourhood_structure self.update_recent_scores best = self.backtrack_or_continue unless @distributions.empty? @standard_deviations = Hash[@distributions.map { |k, d| [k, d.sd] }] end best[:parameters].each_pair do |param, value| self.update_distribution(param,...
[ "def", "update_neighbourhood_structure", "self", ".", "update_recent_scores", "best", "=", "self", ".", "backtrack_or_continue", "unless", "@distributions", ".", "empty?", "@standard_deviations", "=", "Hash", "[", "@distributions", ".", "map", "{", "|", "k", ",", "d...
update the neighbourhood structure by adjusting the probability distributions according to total performance of each parameter
[ "update", "the", "neighbourhood", "structure", "by", "adjusting", "the", "probability", "distributions", "according", "to", "total", "performance", "of", "each", "parameter" ]
e46f3d1c75de4da2ec47a377f7e4f0e16a8e03d2
https://github.com/blahah/biopsy/blob/e46f3d1c75de4da2ec47a377f7e4f0e16a8e03d2/lib/biopsy/optimisers/tabu_search.rb#L310-L319
train
blahah/biopsy
lib/biopsy/optimisers/tabu_search.rb
Biopsy.TabuSearch.backtrack_or_continue
def backtrack_or_continue best = nil if (@iterations_since_best / @backtracks) >= @backtrack_cutoff * @max_hood_size self.backtrack best = @best else best = @current_hood.best self.adjust_distributions_using_gradient end if best[:parameters].nil? # t...
ruby
def backtrack_or_continue best = nil if (@iterations_since_best / @backtracks) >= @backtrack_cutoff * @max_hood_size self.backtrack best = @best else best = @current_hood.best self.adjust_distributions_using_gradient end if best[:parameters].nil? # t...
[ "def", "backtrack_or_continue", "best", "=", "nil", "if", "(", "@iterations_since_best", "/", "@backtracks", ")", ">=", "@backtrack_cutoff", "*", "@max_hood_size", "self", ".", "backtrack", "best", "=", "@best", "else", "best", "=", "@current_hood", ".", "best", ...
return the correct 'best' location to form a new neighbourhood around deciding whether to continue progressing from the current location or to backtrack to a previous good location to explore further
[ "return", "the", "correct", "best", "location", "to", "form", "a", "new", "neighbourhood", "around", "deciding", "whether", "to", "continue", "progressing", "from", "the", "current", "location", "or", "to", "backtrack", "to", "a", "previous", "good", "location",...
e46f3d1c75de4da2ec47a377f7e4f0e16a8e03d2
https://github.com/blahah/biopsy/blob/e46f3d1c75de4da2ec47a377f7e4f0e16a8e03d2/lib/biopsy/optimisers/tabu_search.rb#L341-L355
train
blahah/biopsy
lib/biopsy/optimisers/tabu_search.rb
Biopsy.TabuSearch.adjust_distributions_using_gradient
def adjust_distributions_using_gradient return if @recent_scores.length < 3 vx = (1..@recent_scores.length).to_a.to_numeric vy = @recent_scores.reverse.to_numeric r = Statsample::Regression::Simple.new_from_vectors(vx,vy) slope = r.b if slope > 0 @distributions.each_pair { |k...
ruby
def adjust_distributions_using_gradient return if @recent_scores.length < 3 vx = (1..@recent_scores.length).to_a.to_numeric vy = @recent_scores.reverse.to_numeric r = Statsample::Regression::Simple.new_from_vectors(vx,vy) slope = r.b if slope > 0 @distributions.each_pair { |k...
[ "def", "adjust_distributions_using_gradient", "return", "if", "@recent_scores", ".", "length", "<", "3", "vx", "=", "(", "1", "..", "@recent_scores", ".", "length", ")", ".", "to_a", ".", "to_numeric", "vy", "=", "@recent_scores", ".", "reverse", ".", "to_nume...
use the gradient of recent best scores to update the distributions
[ "use", "the", "gradient", "of", "recent", "best", "scores", "to", "update", "the", "distributions" ]
e46f3d1c75de4da2ec47a377f7e4f0e16a8e03d2
https://github.com/blahah/biopsy/blob/e46f3d1c75de4da2ec47a377f7e4f0e16a8e03d2/lib/biopsy/optimisers/tabu_search.rb#L369-L380
train
blahah/biopsy
lib/biopsy/optimisers/tabu_search.rb
Biopsy.TabuSearch.finished?
def finished? return false unless @threads.all? do |t| t.recent_scores.size == @jump_cutoff end probabilities = self.recent_scores_combination_test n_significant = 0 probabilities.each do |mann_u, levene| if mann_u <= @adjusted_alpha && levene <= @convergence_alpha ...
ruby
def finished? return false unless @threads.all? do |t| t.recent_scores.size == @jump_cutoff end probabilities = self.recent_scores_combination_test n_significant = 0 probabilities.each do |mann_u, levene| if mann_u <= @adjusted_alpha && levene <= @convergence_alpha ...
[ "def", "finished?", "return", "false", "unless", "@threads", ".", "all?", "do", "|", "t", "|", "t", ".", "recent_scores", ".", "size", "==", "@jump_cutoff", "end", "probabilities", "=", "self", ".", "recent_scores_combination_test", "n_significant", "=", "0", ...
check termination conditions and return true if met
[ "check", "termination", "conditions", "and", "return", "true", "if", "met" ]
e46f3d1c75de4da2ec47a377f7e4f0e16a8e03d2
https://github.com/blahah/biopsy/blob/e46f3d1c75de4da2ec47a377f7e4f0e16a8e03d2/lib/biopsy/optimisers/tabu_search.rb#L403-L415
train
lautis/sweet_notifications
lib/sweet_notifications/railtie.rb
SweetNotifications.Railtie.initialize_rails
def initialize_rails(name, log_subscriber, controller_runtime) log_subscriber.attach_to name.to_sym ActiveSupport.on_load(:action_controller) do include controller_runtime end end
ruby
def initialize_rails(name, log_subscriber, controller_runtime) log_subscriber.attach_to name.to_sym ActiveSupport.on_load(:action_controller) do include controller_runtime end end
[ "def", "initialize_rails", "(", "name", ",", "log_subscriber", ",", "controller_runtime", ")", "log_subscriber", ".", "attach_to", "name", ".", "to_sym", "ActiveSupport", ".", "on_load", "(", ":action_controller", ")", "do", "include", "controller_runtime", "end", "...
Attach LogSubscriber and ControllerRuntime to a notifications namespace @param name [Symbol] Notifications namespace @param log_subscriber [LogSubscriber] subscriber to be attached @param controller_runtime [Module] mixin that logs runtime
[ "Attach", "LogSubscriber", "and", "ControllerRuntime", "to", "a", "notifications", "namespace" ]
fcd137a1b474d24e1bc86619d116fc32caba8c19
https://github.com/lautis/sweet_notifications/blob/fcd137a1b474d24e1bc86619d116fc32caba8c19/lib/sweet_notifications/railtie.rb#L12-L17
train
lautis/sweet_notifications
lib/sweet_notifications/railtie.rb
SweetNotifications.Railtie.railtie
def railtie(name, log_subscriber, controller_runtime) Class.new(Rails::Railtie) do railtie_name name initializer "#{name}.notifications" do SweetNotifications::Railtie.initialize_rails(name, log_subscriber, ...
ruby
def railtie(name, log_subscriber, controller_runtime) Class.new(Rails::Railtie) do railtie_name name initializer "#{name}.notifications" do SweetNotifications::Railtie.initialize_rails(name, log_subscriber, ...
[ "def", "railtie", "(", "name", ",", "log_subscriber", ",", "controller_runtime", ")", "Class", ".", "new", "(", "Rails", "::", "Railtie", ")", "do", "railtie_name", "name", "initializer", "\"#{name}.notifications\"", "do", "SweetNotifications", "::", "Railtie", "....
Create a Railtie for LogSubscriber and ControllerRuntime mixin @param name [Symbol] Notifications namespace @param log_subscriber [LogSubscriber] subscriber to be attached @param controller_runtime [Module] mixin that logs runtime @return [Rails::Railtie] Rails initializer
[ "Create", "a", "Railtie", "for", "LogSubscriber", "and", "ControllerRuntime", "mixin" ]
fcd137a1b474d24e1bc86619d116fc32caba8c19
https://github.com/lautis/sweet_notifications/blob/fcd137a1b474d24e1bc86619d116fc32caba8c19/lib/sweet_notifications/railtie.rb#L25-L34
train
sinefunc/lunar
lib/lunar/result_set.rb
Lunar.ResultSet.sort
def sort(opts = {}) return [] if not distkey opts[:by] = sortables[opts[:by]] if opts[:by] if opts[:start] && opts[:limit] opts[:limit] = [opts[:start], opts[:limit]] end objects(distkey.sort(opts)) end
ruby
def sort(opts = {}) return [] if not distkey opts[:by] = sortables[opts[:by]] if opts[:by] if opts[:start] && opts[:limit] opts[:limit] = [opts[:start], opts[:limit]] end objects(distkey.sort(opts)) end
[ "def", "sort", "(", "opts", "=", "{", "}", ")", "return", "[", "]", "if", "not", "distkey", "opts", "[", ":by", "]", "=", "sortables", "[", "opts", "[", ":by", "]", "]", "if", "opts", "[", ":by", "]", "if", "opts", "[", ":start", "]", "&&", "...
Gives the ability to sort the search results via a `sortable` field in your index. @example Lunar.index Gadget do |i| i.id 1001 i.text :title, "Apple Macbook Pro" i.sortable :votes, 10 end Lunar.index Gadget do |i| i.id 1002 i.text :title, "Apple iPad" i.sortable :votes, 50 ...
[ "Gives", "the", "ability", "to", "sort", "the", "search", "results", "via", "a", "sortable", "field", "in", "your", "index", "." ]
efc58f392dd75e771d313eef6cd4ada0d1ac02ff
https://github.com/sinefunc/lunar/blob/efc58f392dd75e771d313eef6cd4ada0d1ac02ff/lib/lunar/result_set.rb#L90-L100
train
scepticulous/crypto-toolbox
lib/crypto-toolbox/crypt_buffer/concerns/padding.rb
CryptBufferConcern.Padding.padding
def padding last = bytes.last subset = subset_padding if subset.all?{|e| e == last } self.class.new(subset) else self.class.new([]) end end
ruby
def padding last = bytes.last subset = subset_padding if subset.all?{|e| e == last } self.class.new(subset) else self.class.new([]) end end
[ "def", "padding", "last", "=", "bytes", ".", "last", "subset", "=", "subset_padding", "if", "subset", ".", "all?", "{", "|", "e", "|", "e", "==", "last", "}", "self", ".", "class", ".", "new", "(", "subset", ")", "else", "self", ".", "class", ".", ...
Return any existing padding
[ "Return", "any", "existing", "padding" ]
cdbe371109e497db2c2af5c1fe0f359612f44816
https://github.com/scepticulous/crypto-toolbox/blob/cdbe371109e497db2c2af5c1fe0f359612f44816/lib/crypto-toolbox/crypt_buffer/concerns/padding.rb#L16-L25
train
scepticulous/crypto-toolbox
lib/crypto-toolbox/crypt_buffer/concerns/padding.rb
CryptBufferConcern.Padding.strip_padding
def strip_padding subset = bytes if padding? pad = padding len = pad.length subset = bytes[0,bytes.length - len] end self.class.new(subset) end
ruby
def strip_padding subset = bytes if padding? pad = padding len = pad.length subset = bytes[0,bytes.length - len] end self.class.new(subset) end
[ "def", "strip_padding", "subset", "=", "bytes", "if", "padding?", "pad", "=", "padding", "len", "=", "pad", ".", "length", "subset", "=", "bytes", "[", "0", ",", "bytes", ".", "length", "-", "len", "]", "end", "self", ".", "class", ".", "new", "(", ...
Strip the existing padding if present
[ "Strip", "the", "existing", "padding", "if", "present" ]
cdbe371109e497db2c2af5c1fe0f359612f44816
https://github.com/scepticulous/crypto-toolbox/blob/cdbe371109e497db2c2af5c1fe0f359612f44816/lib/crypto-toolbox/crypt_buffer/concerns/padding.rb#L28-L37
train
thinkerbot/configurable
lib/configurable/conversions.rb
Configurable.Conversions.to_parser
def to_parser(*args, &block) parser = ConfigParser.new(*args, &block) traverse do |nesting, config| next if config[:hidden] == true || nesting.any? {|nest| nest[:hidden] == true } nest_keys = nesting.collect {|nest| nest.key } long, short = nesting.collect {|nest| nest.nam...
ruby
def to_parser(*args, &block) parser = ConfigParser.new(*args, &block) traverse do |nesting, config| next if config[:hidden] == true || nesting.any? {|nest| nest[:hidden] == true } nest_keys = nesting.collect {|nest| nest.key } long, short = nesting.collect {|nest| nest.nam...
[ "def", "to_parser", "(", "*", "args", ",", "&", "block", ")", "parser", "=", "ConfigParser", ".", "new", "(", "*", "args", ",", "&", "block", ")", "traverse", "do", "|", "nesting", ",", "config", "|", "next", "if", "config", "[", ":hidden", "]", "=...
Initializes and returns a ConfigParser generated using the configs for self. Arguments given to parser are passed to the ConfigParser initializer.
[ "Initializes", "and", "returns", "a", "ConfigParser", "generated", "using", "the", "configs", "for", "self", ".", "Arguments", "given", "to", "parser", "are", "passed", "to", "the", "ConfigParser", "initializer", "." ]
43c611f767f14194827b1fe31bc72c8bdf54efdf
https://github.com/thinkerbot/configurable/blob/43c611f767f14194827b1fe31bc72c8bdf54efdf/lib/configurable/conversions.rb#L14-L41
train
thinkerbot/configurable
lib/configurable/conversions.rb
Configurable.Conversions.to_default
def to_default default = {} each_pair do |key, config| default[key] = config.default end default end
ruby
def to_default default = {} each_pair do |key, config| default[key] = config.default end default end
[ "def", "to_default", "default", "=", "{", "}", "each_pair", "do", "|", "key", ",", "config", "|", "default", "[", "key", "]", "=", "config", ".", "default", "end", "default", "end" ]
Returns a hash of the default values for each config in self.
[ "Returns", "a", "hash", "of", "the", "default", "values", "for", "each", "config", "in", "self", "." ]
43c611f767f14194827b1fe31bc72c8bdf54efdf
https://github.com/thinkerbot/configurable/blob/43c611f767f14194827b1fe31bc72c8bdf54efdf/lib/configurable/conversions.rb#L44-L50
train
thinkerbot/configurable
lib/configurable/conversions.rb
Configurable.Conversions.traverse
def traverse(nesting=[], &block) each_value do |config| if config.type.kind_of?(NestType) nesting.push config configs = config.type.configurable.class.configs configs.traverse(nesting, &block) nesting.pop else yield(nesting, config) end ...
ruby
def traverse(nesting=[], &block) each_value do |config| if config.type.kind_of?(NestType) nesting.push config configs = config.type.configurable.class.configs configs.traverse(nesting, &block) nesting.pop else yield(nesting, config) end ...
[ "def", "traverse", "(", "nesting", "=", "[", "]", ",", "&", "block", ")", "each_value", "do", "|", "config", "|", "if", "config", ".", "type", ".", "kind_of?", "(", "NestType", ")", "nesting", ".", "push", "config", "configs", "=", "config", ".", "ty...
Yields each config in configs to the block with nesting, after appened self to nesting.
[ "Yields", "each", "config", "in", "configs", "to", "the", "block", "with", "nesting", "after", "appened", "self", "to", "nesting", "." ]
43c611f767f14194827b1fe31bc72c8bdf54efdf
https://github.com/thinkerbot/configurable/blob/43c611f767f14194827b1fe31bc72c8bdf54efdf/lib/configurable/conversions.rb#L78-L89
train
ArchimediaZerogroup/KonoUtils
lib/kono_utils/tmp_file.rb
KonoUtils.TmpFile.clean_tmpdir
def clean_tmpdir self.root_dir.each do |d| if d != '..' and d!='.' if d.to_i < Time.now.to_i-TIME_LIMIT FileUtils.rm_rf(File.join(self.root_dir.path, d)) end end end end
ruby
def clean_tmpdir self.root_dir.each do |d| if d != '..' and d!='.' if d.to_i < Time.now.to_i-TIME_LIMIT FileUtils.rm_rf(File.join(self.root_dir.path, d)) end end end end
[ "def", "clean_tmpdir", "self", ".", "root_dir", ".", "each", "do", "|", "d", "|", "if", "d", "!=", "'..'", "and", "d!", "=", "'.'", "if", "d", ".", "to_i", "<", "Time", ".", "now", ".", "to_i", "-", "TIME_LIMIT", "FileUtils", ".", "rm_rf", "(", "...
Clean the directory
[ "Clean", "the", "directory" ]
a255a30b65e4e0f01cd6236d991da4fd13c64fc6
https://github.com/ArchimediaZerogroup/KonoUtils/blob/a255a30b65e4e0f01cd6236d991da4fd13c64fc6/lib/kono_utils/tmp_file.rb#L70-L78
train