id int32 0 24.9k | repo stringlengths 5 58 | path stringlengths 9 168 | func_name stringlengths 9 130 | original_string stringlengths 66 10.5k | language stringclasses 1
value | code stringlengths 66 10.5k | code_tokens list | docstring stringlengths 8 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 94 266 |
|---|---|---|---|---|---|---|---|---|---|---|---|
3,500 | larrytheliquid/dataflow | dataflow/port.rb | Dataflow.Port.send | def send value
LOCK.synchronize do
unify @end.head, value
unify @end.tail, Stream.new
@end = @end.tail
end
end | ruby | def send value
LOCK.synchronize do
unify @end.head, value
unify @end.tail, Stream.new
@end = @end.tail
end
end | [
"def",
"send",
"value",
"LOCK",
".",
"synchronize",
"do",
"unify",
"@end",
".",
"head",
",",
"value",
"unify",
"@end",
".",
"tail",
",",
"Stream",
".",
"new",
"@end",
"=",
"@end",
".",
"tail",
"end",
"end"
] | Create a stream object, bind it to the input variable
Instance variables are necessary because @end is state
This needs to be synchronized because it uses @end as state | [
"Create",
"a",
"stream",
"object",
"bind",
"it",
"to",
"the",
"input",
"variable",
"Instance",
"variables",
"are",
"necessary",
"because"
] | c856552bbc0fc9e64b2b13a08239cba985874eaf | https://github.com/larrytheliquid/dataflow/blob/c856552bbc0fc9e64b2b13a08239cba985874eaf/dataflow/port.rb#L45-L51 |
3,501 | ballantyne/weibo | lib/weibo/request.rb | Weibo.Request.make_mash_with_consistent_hash | def make_mash_with_consistent_hash(obj)
m = Hashie::Mash.new(obj)
def m.hash
inspect.hash
end
return m
end | ruby | def make_mash_with_consistent_hash(obj)
m = Hashie::Mash.new(obj)
def m.hash
inspect.hash
end
return m
end | [
"def",
"make_mash_with_consistent_hash",
"(",
"obj",
")",
"m",
"=",
"Hashie",
"::",
"Mash",
".",
"new",
"(",
"obj",
")",
"def",
"m",
".",
"hash",
"inspect",
".",
"hash",
"end",
"return",
"m",
"end"
] | Lame workaround for the fact that mash doesn't hash correctly | [
"Lame",
"workaround",
"for",
"the",
"fact",
"that",
"mash",
"doesn",
"t",
"hash",
"correctly"
] | f3ebbf4d706e158cf81d9ffe4a6ed700db7210bc | https://github.com/ballantyne/weibo/blob/f3ebbf4d706e158cf81d9ffe4a6ed700db7210bc/lib/weibo/request.rb#L109-L115 |
3,502 | ronin-ruby/ronin-support | lib/ronin/wordlist.rb | Ronin.Wordlist.each_word | def each_word(&block)
return enum_for(__method__) unless block
if @path
File.open(@path) do |file|
file.each_line do |line|
yield line.chomp
end
end
elsif @words
@words.each(&block)
end
end | ruby | def each_word(&block)
return enum_for(__method__) unless block
if @path
File.open(@path) do |file|
file.each_line do |line|
yield line.chomp
end
end
elsif @words
@words.each(&block)
end
end | [
"def",
"each_word",
"(",
"&",
"block",
")",
"return",
"enum_for",
"(",
"__method__",
")",
"unless",
"block",
"if",
"@path",
"File",
".",
"open",
"(",
"@path",
")",
"do",
"|",
"file",
"|",
"file",
".",
"each_line",
"do",
"|",
"line",
"|",
"yield",
"li... | Iterates over each word in the list.
@yield [word]
The given block will be passed each word.
@yieldparam [String] word
A word from the list.
@return [Enumerator]
If no block is given, an Enumerator will be returned.
@raise [RuntimeError]
{#path} or {#words} must be set.
@api public | [
"Iterates",
"over",
"each",
"word",
"in",
"the",
"list",
"."
] | bc2af0e75098c13133789118245cb185f8c6b4c9 | https://github.com/ronin-ruby/ronin-support/blob/bc2af0e75098c13133789118245cb185f8c6b4c9/lib/ronin/wordlist.rb#L197-L209 |
3,503 | ronin-ruby/ronin-support | lib/ronin/wordlist.rb | Ronin.Wordlist.each | def each(&block)
return enum_for(__method__) unless block
mutator = unless @mutations.empty?
Fuzzing::Mutator.new(@mutations)
end
each_word do |word|
yield word
if mutator
# perform additional mutations
mutator.each(word,&block)
... | ruby | def each(&block)
return enum_for(__method__) unless block
mutator = unless @mutations.empty?
Fuzzing::Mutator.new(@mutations)
end
each_word do |word|
yield word
if mutator
# perform additional mutations
mutator.each(word,&block)
... | [
"def",
"each",
"(",
"&",
"block",
")",
"return",
"enum_for",
"(",
"__method__",
")",
"unless",
"block",
"mutator",
"=",
"unless",
"@mutations",
".",
"empty?",
"Fuzzing",
"::",
"Mutator",
".",
"new",
"(",
"@mutations",
")",
"end",
"each_word",
"do",
"|",
... | Iterates over each word, and each mutation, from the list.
@yield [word]
The given block will be passed each word.
@yieldparam [String] word
A word from the list.
@return [Enumerator]
If no block is given, an Enumerator will be returned.
@api public | [
"Iterates",
"over",
"each",
"word",
"and",
"each",
"mutation",
"from",
"the",
"list",
"."
] | bc2af0e75098c13133789118245cb185f8c6b4c9 | https://github.com/ronin-ruby/ronin-support/blob/bc2af0e75098c13133789118245cb185f8c6b4c9/lib/ronin/wordlist.rb#L225-L240 |
3,504 | ronin-ruby/ronin-support | lib/ronin/wordlist.rb | Ronin.Wordlist.save | def save(path)
File.open(path,'w') do |file|
each { |word| file.puts word }
end
return self
end | ruby | def save(path)
File.open(path,'w') do |file|
each { |word| file.puts word }
end
return self
end | [
"def",
"save",
"(",
"path",
")",
"File",
".",
"open",
"(",
"path",
",",
"'w'",
")",
"do",
"|",
"file",
"|",
"each",
"{",
"|",
"word",
"|",
"file",
".",
"puts",
"word",
"}",
"end",
"return",
"self",
"end"
] | Saves the words to a new file.
@param [String] path
The path to the new wordlist file.
@return [Wordlist]
The wordlist object.
@see #each
@since 0.5.0
@api public | [
"Saves",
"the",
"words",
"to",
"a",
"new",
"file",
"."
] | bc2af0e75098c13133789118245cb185f8c6b4c9 | https://github.com/ronin-ruby/ronin-support/blob/bc2af0e75098c13133789118245cb185f8c6b4c9/lib/ronin/wordlist.rb#L278-L284 |
3,505 | integrallis/stripe_saas | app/controllers/stripe_saas/subscriptions_controller.rb | StripeSaas.SubscriptionsController.load_owner | def load_owner
unless params[:owner_id].nil?
if current_owner.present?
# we need to try and look this owner up via the find method so that we're
# taking advantage of any override of the find method that would be provided
# by older versions of friendly_id. (support for newe... | ruby | def load_owner
unless params[:owner_id].nil?
if current_owner.present?
# we need to try and look this owner up via the find method so that we're
# taking advantage of any override of the find method that would be provided
# by older versions of friendly_id. (support for newe... | [
"def",
"load_owner",
"unless",
"params",
"[",
":owner_id",
"]",
".",
"nil?",
"if",
"current_owner",
".",
"present?",
"# we need to try and look this owner up via the find method so that we're",
"# taking advantage of any override of the find method that would be provided",
"# by older ... | subscription.subscription_owner | [
"subscription",
".",
"subscription_owner"
] | 130acf9ea66e3dd96dedba193327d1e79443e868 | https://github.com/integrallis/stripe_saas/blob/130acf9ea66e3dd96dedba193327d1e79443e868/app/controllers/stripe_saas/subscriptions_controller.rb#L18-L56 |
3,506 | vangberg/librevox | lib/librevox/commands.rb | Librevox.Commands.originate | def originate url, args={}, &block
extension = args.delete(:extension)
dialplan = args.delete(:dialplan)
context = args.delete(:context)
vars = args.map {|k,v| "#{k}=#{v}"}.join(",")
arg_string = "{#{vars}}" +
[url, extension, dialplan, context].compact.join(" ")
comman... | ruby | def originate url, args={}, &block
extension = args.delete(:extension)
dialplan = args.delete(:dialplan)
context = args.delete(:context)
vars = args.map {|k,v| "#{k}=#{v}"}.join(",")
arg_string = "{#{vars}}" +
[url, extension, dialplan, context].compact.join(" ")
comman... | [
"def",
"originate",
"url",
",",
"args",
"=",
"{",
"}",
",",
"&",
"block",
"extension",
"=",
"args",
".",
"delete",
"(",
":extension",
")",
"dialplan",
"=",
"args",
".",
"delete",
"(",
":dialplan",
")",
"context",
"=",
"args",
".",
"delete",
"(",
":co... | Access the hash table that comes with FreeSWITCH.
@example
socket.hash :insert, :realm, :key, "value"
socket.hash :select, :realm, :key
socket.hash :delete, :realm, :key
Originate a new call.
@example Minimum options
socket.originate 'sofia/user/coltrane', :extension => "1234"
@example With :dialplan an... | [
"Access",
"the",
"hash",
"table",
"that",
"comes",
"with",
"FreeSWITCH",
"."
] | b894e6c4857ce768fdb961444f197b43d985b5e2 | https://github.com/vangberg/librevox/blob/b894e6c4857ce768fdb961444f197b43d985b5e2/lib/librevox/commands.rb#L37-L47 |
3,507 | flyerhzm/code_analyzer | lib/code_analyzer/checker.rb | CodeAnalyzer.Checker.add_warning | def add_warning(message, filename = @node.file, line_number = @node.line_number)
warnings << Warning.new(filename: filename, line_number: line_number, message: message)
end | ruby | def add_warning(message, filename = @node.file, line_number = @node.line_number)
warnings << Warning.new(filename: filename, line_number: line_number, message: message)
end | [
"def",
"add_warning",
"(",
"message",
",",
"filename",
"=",
"@node",
".",
"file",
",",
"line_number",
"=",
"@node",
".",
"line_number",
")",
"warnings",
"<<",
"Warning",
".",
"new",
"(",
"filename",
":",
"filename",
",",
"line_number",
":",
"line_number",
... | add an warning.
@param [String] message, is the warning message
@param [String] filename, is the filename of source code
@param [Integer] line_number, is the line number of the source code which is reviewing | [
"add",
"an",
"warning",
"."
] | f4d63ae835574b3e48a3154df3e0ce83457502bd | https://github.com/flyerhzm/code_analyzer/blob/f4d63ae835574b3e48a3154df3e0ce83457502bd/lib/code_analyzer/checker.rb#L54-L56 |
3,508 | mbj/morpher | lib/morpher/type_lookup.rb | Morpher.TypeLookup.call | def call(object)
current = target = object.class
while current != Object
if registry.key?(current)
return registry.fetch(current)
end
current = current.superclass
end
fail TypeNotFoundError, target
end | ruby | def call(object)
current = target = object.class
while current != Object
if registry.key?(current)
return registry.fetch(current)
end
current = current.superclass
end
fail TypeNotFoundError, target
end | [
"def",
"call",
"(",
"object",
")",
"current",
"=",
"target",
"=",
"object",
".",
"class",
"while",
"current",
"!=",
"Object",
"if",
"registry",
".",
"key?",
"(",
"current",
")",
"return",
"registry",
".",
"fetch",
"(",
"current",
")",
"end",
"current",
... | TypeNotFoundError
Perform type lookup
@param [Object] object
@return [Object]
if found
@raise [TypeNotFoundError]
otherwise
@api private | [
"TypeNotFoundError",
"Perform",
"type",
"lookup"
] | c9f9f720933835e09acfe6100bb20e8bd3c01915 | https://github.com/mbj/morpher/blob/c9f9f720933835e09acfe6100bb20e8bd3c01915/lib/morpher/type_lookup.rb#L38-L48 |
3,509 | ballantyne/weibo | lib/weibo.rb | Hashie.Mash.rubyify_keys! | def rubyify_keys!
keys.each{|k|
v = delete(k)
new_key = k.to_s.underscore
self[new_key] = v
v.rubyify_keys! if v.is_a?(Hash)
v.each{|p| p.rubyify_keys! if p.is_a?(Hash)} if v.is_a?(Array)
}
self
end | ruby | def rubyify_keys!
keys.each{|k|
v = delete(k)
new_key = k.to_s.underscore
self[new_key] = v
v.rubyify_keys! if v.is_a?(Hash)
v.each{|p| p.rubyify_keys! if p.is_a?(Hash)} if v.is_a?(Array)
}
self
end | [
"def",
"rubyify_keys!",
"keys",
".",
"each",
"{",
"|",
"k",
"|",
"v",
"=",
"delete",
"(",
"k",
")",
"new_key",
"=",
"k",
".",
"to_s",
".",
"underscore",
"self",
"[",
"new_key",
"]",
"=",
"v",
"v",
".",
"rubyify_keys!",
"if",
"v",
".",
"is_a?",
"(... | Converts all of the keys to strings, optionally formatting key name | [
"Converts",
"all",
"of",
"the",
"keys",
"to",
"strings",
"optionally",
"formatting",
"key",
"name"
] | f3ebbf4d706e158cf81d9ffe4a6ed700db7210bc | https://github.com/ballantyne/weibo/blob/f3ebbf4d706e158cf81d9ffe4a6ed700db7210bc/lib/weibo.rb#L44-L53 |
3,510 | michael-emmi/bam-bam-boogieman | lib/bpl/passes/security/cost_modeling.rb | Bpl.CostModeling.get_annotation_value | def get_annotation_value annotationStmt
raise "annotation should have one argument" unless annotationStmt.arguments.length == 1
return annotationStmt.arguments.first.to_s
end | ruby | def get_annotation_value annotationStmt
raise "annotation should have one argument" unless annotationStmt.arguments.length == 1
return annotationStmt.arguments.first.to_s
end | [
"def",
"get_annotation_value",
"annotationStmt",
"raise",
"\"annotation should have one argument\"",
"unless",
"annotationStmt",
".",
"arguments",
".",
"length",
"==",
"1",
"return",
"annotationStmt",
".",
"arguments",
".",
"first",
".",
"to_s",
"end"
] | the annotation should have one argument, and we just want whatever it is | [
"the",
"annotation",
"should",
"have",
"one",
"argument",
"and",
"we",
"just",
"want",
"whatever",
"it",
"is"
] | d42037d919e6cc67fcfa7c5ad143f7e2027522d2 | https://github.com/michael-emmi/bam-bam-boogieman/blob/d42037d919e6cc67fcfa7c5ad143f7e2027522d2/lib/bpl/passes/security/cost_modeling.rb#L54-L57 |
3,511 | michael-emmi/bam-bam-boogieman | lib/bpl/passes/security/cost_modeling.rb | Bpl.CostModeling.cost_of | def cost_of block
assumes = block.select{ |s| s.is_a?(AssumeStatement)}
cost = assumes.inject(0) do |acc, stmt|
if values = stmt.get_attribute(:'smack.InstTimingCost.Int64')
acc += values.first.show.to_i
end
acc
end
return cost
end | ruby | def cost_of block
assumes = block.select{ |s| s.is_a?(AssumeStatement)}
cost = assumes.inject(0) do |acc, stmt|
if values = stmt.get_attribute(:'smack.InstTimingCost.Int64')
acc += values.first.show.to_i
end
acc
end
return cost
end | [
"def",
"cost_of",
"block",
"assumes",
"=",
"block",
".",
"select",
"{",
"|",
"s",
"|",
"s",
".",
"is_a?",
"(",
"AssumeStatement",
")",
"}",
"cost",
"=",
"assumes",
".",
"inject",
"(",
"0",
")",
"do",
"|",
"acc",
",",
"stmt",
"|",
"if",
"values",
... | Iterates over timing annotations of a block and sums them up. | [
"Iterates",
"over",
"timing",
"annotations",
"of",
"a",
"block",
"and",
"sums",
"them",
"up",
"."
] | d42037d919e6cc67fcfa7c5ad143f7e2027522d2 | https://github.com/michael-emmi/bam-bam-boogieman/blob/d42037d919e6cc67fcfa7c5ad143f7e2027522d2/lib/bpl/passes/security/cost_modeling.rb#L76-L86 |
3,512 | michael-emmi/bam-bam-boogieman | lib/bpl/passes/security/cost_modeling.rb | Bpl.CostModeling.extract_branches | def extract_branches blocks
branches = []
blocks.each do |block|
block.each do |stmt|
case stmt
when GotoStatement
next if stmt.identifiers.length < 2
unless stmt.identifiers.length == 2
fail "Unexpected goto statement: #{stmt}"
... | ruby | def extract_branches blocks
branches = []
blocks.each do |block|
block.each do |stmt|
case stmt
when GotoStatement
next if stmt.identifiers.length < 2
unless stmt.identifiers.length == 2
fail "Unexpected goto statement: #{stmt}"
... | [
"def",
"extract_branches",
"blocks",
"branches",
"=",
"[",
"]",
"blocks",
".",
"each",
"do",
"|",
"block",
"|",
"block",
".",
"each",
"do",
"|",
"stmt",
"|",
"case",
"stmt",
"when",
"GotoStatement",
"next",
"if",
"stmt",
".",
"identifiers",
".",
"length"... | Given a set of blocks, returns 'GotoStatement's of branches | [
"Given",
"a",
"set",
"of",
"blocks",
"returns",
"GotoStatement",
"s",
"of",
"branches"
] | d42037d919e6cc67fcfa7c5ad143f7e2027522d2 | https://github.com/michael-emmi/bam-bam-boogieman/blob/d42037d919e6cc67fcfa7c5ad143f7e2027522d2/lib/bpl/passes/security/cost_modeling.rb#L130-L152 |
3,513 | arbox/wlapi | lib/wlapi/api.rb | WLAPI.API.wordforms | def wordforms(word, limit = 10)
check_params(word, limit)
# note, it is the only service which requires 'Word', not 'Wort'
arg1 = ['Word', word]
arg2 = ['Limit', limit]
answer = query(@cl_Wordforms, arg1, arg2)
get_answer(answer)
end | ruby | def wordforms(word, limit = 10)
check_params(word, limit)
# note, it is the only service which requires 'Word', not 'Wort'
arg1 = ['Word', word]
arg2 = ['Limit', limit]
answer = query(@cl_Wordforms, arg1, arg2)
get_answer(answer)
end | [
"def",
"wordforms",
"(",
"word",
",",
"limit",
"=",
"10",
")",
"check_params",
"(",
"word",
",",
"limit",
")",
"# note, it is the only service which requires 'Word', not 'Wort'",
"arg1",
"=",
"[",
"'Word'",
",",
"word",
"]",
"arg2",
"=",
"[",
"'Limit'",
",",
"... | Two parameter methods.
Returns all other word forms of the same lemma for a given word form.
api.wordforms("Auto") => ["Auto", "Autos"]
@return [Array] a list | [
"Two",
"parameter",
"methods",
"."
] | 8a5b1b1bbfa58826107daeeae409e4e22b1c5236 | https://github.com/arbox/wlapi/blob/8a5b1b1bbfa58826107daeeae409e4e22b1c5236/lib/wlapi/api.rb#L134-L143 |
3,514 | arbox/wlapi | lib/wlapi/api.rb | WLAPI.API.right_collocation_finder | def right_collocation_finder(word, pos, limit = 10)
check_params(word, pos, limit)
arg1 = ['Wort', word]
arg2 = ['Wortart', pos]
arg3 = ['Limit', limit]
answer = query(@cl_RightCollocationFinder, arg1, arg2, arg3)
get_answer(answer)
end | ruby | def right_collocation_finder(word, pos, limit = 10)
check_params(word, pos, limit)
arg1 = ['Wort', word]
arg2 = ['Wortart', pos]
arg3 = ['Limit', limit]
answer = query(@cl_RightCollocationFinder, arg1, arg2, arg3)
get_answer(answer)
end | [
"def",
"right_collocation_finder",
"(",
"word",
",",
"pos",
",",
"limit",
"=",
"10",
")",
"check_params",
"(",
"word",
",",
"pos",
",",
"limit",
")",
"arg1",
"=",
"[",
"'Wort'",
",",
"word",
"]",
"arg2",
"=",
"[",
"'Wortart'",
",",
"pos",
"]",
"arg3"... | Three parameter methods.
Attempts to find linguistic collocations that occur to the right
of the given input word.
The parameter 'Wortart' accepts four values 'A, V, N, S'
which stand for adjective, verb, noun and stopword respectively.
The parameter restricts the type of words found.
It returns an array:
api... | [
"Three",
"parameter",
"methods",
"."
] | 8a5b1b1bbfa58826107daeeae409e4e22b1c5236 | https://github.com/arbox/wlapi/blob/8a5b1b1bbfa58826107daeeae409e4e22b1c5236/lib/wlapi/api.rb#L281-L290 |
3,515 | arbox/wlapi | lib/wlapi/api.rb | WLAPI.API.cooccurrences | def cooccurrences(word, sign, limit = 10)
check_params(word, sign, limit)
arg1 = ['Wort', word]
arg2 = ['Mindestsignifikanz', sign]
arg3 = ['Limit', limit]
answer = query(@cl_Cooccurrences, arg1, arg2, arg3)
get_answer(answer)
end | ruby | def cooccurrences(word, sign, limit = 10)
check_params(word, sign, limit)
arg1 = ['Wort', word]
arg2 = ['Mindestsignifikanz', sign]
arg3 = ['Limit', limit]
answer = query(@cl_Cooccurrences, arg1, arg2, arg3)
get_answer(answer)
end | [
"def",
"cooccurrences",
"(",
"word",
",",
"sign",
",",
"limit",
"=",
"10",
")",
"check_params",
"(",
"word",
",",
"sign",
",",
"limit",
")",
"arg1",
"=",
"[",
"'Wort'",
",",
"word",
"]",
"arg2",
"=",
"[",
"'Mindestsignifikanz'",
",",
"sign",
"]",
"ar... | Returns statistically significant co-occurrences of the input word. | [
"Returns",
"statistically",
"significant",
"co",
"-",
"occurrences",
"of",
"the",
"input",
"word",
"."
] | 8a5b1b1bbfa58826107daeeae409e4e22b1c5236 | https://github.com/arbox/wlapi/blob/8a5b1b1bbfa58826107daeeae409e4e22b1c5236/lib/wlapi/api.rb#L312-L321 |
3,516 | arbox/wlapi | lib/wlapi/api.rb | WLAPI.API.get_answer | def get_answer(doc, mod='')
result = []
# The path seems to be weird, because the namespaces change incrementally
# in the output, so I don't want to treat it here.
# A modifier needed because synonyms service provides duplicate values.
XPath.each(doc, "//result/*/*#{mod}") do |el|
... | ruby | def get_answer(doc, mod='')
result = []
# The path seems to be weird, because the namespaces change incrementally
# in the output, so I don't want to treat it here.
# A modifier needed because synonyms service provides duplicate values.
XPath.each(doc, "//result/*/*#{mod}") do |el|
... | [
"def",
"get_answer",
"(",
"doc",
",",
"mod",
"=",
"''",
")",
"result",
"=",
"[",
"]",
"# The path seems to be weird, because the namespaces change incrementally",
"# in the output, so I don't want to treat it here.",
"# A modifier needed because synonyms service provides duplicate valu... | This method extracts valuable data from the XML structure
of the soap response. It returns an array with extracted xml text nodes
or nil, if the service provided no answer. | [
"This",
"method",
"extracts",
"valuable",
"data",
"from",
"the",
"XML",
"structure",
"of",
"the",
"soap",
"response",
".",
"It",
"returns",
"an",
"array",
"with",
"extracted",
"xml",
"text",
"nodes",
"or",
"nil",
"if",
"the",
"service",
"provided",
"no",
"... | 8a5b1b1bbfa58826107daeeae409e4e22b1c5236 | https://github.com/arbox/wlapi/blob/8a5b1b1bbfa58826107daeeae409e4e22b1c5236/lib/wlapi/api.rb#L421-L432 |
3,517 | souche/aliyun-ons-ruby-sdk | lib/ons/producer.rb | Ons.Producer.send_message | def send_message(topic, tag, body, key = '')
@producer.send_message(topic, tag, body, key)
end | ruby | def send_message(topic, tag, body, key = '')
@producer.send_message(topic, tag, body, key)
end | [
"def",
"send_message",
"(",
"topic",
",",
"tag",
",",
"body",
",",
"key",
"=",
"''",
")",
"@producer",
".",
"send_message",
"(",
"topic",
",",
"tag",
",",
"body",
",",
"key",
")",
"end"
] | Create a new aliyun ONS Producer instance.
@param access_key [String] the access key to aliyun ONS
@param secret_key [String] the secret key to aliyun ONS
@param producer_id [String] the producer ID
@param options [Hash{String, Symbol => String}]
@option options [String] :namesrv_addr the nameserver used to fetch... | [
"Create",
"a",
"new",
"aliyun",
"ONS",
"Producer",
"instance",
"."
] | 00d16d5fe4dc55929036544a7667c463694f6b1f | https://github.com/souche/aliyun-ons-ruby-sdk/blob/00d16d5fe4dc55929036544a7667c463694f6b1f/lib/ons/producer.rb#L39-L41 |
3,518 | souche/aliyun-ons-ruby-sdk | lib/ons/producer.rb | Ons.Producer.send_timer_message | def send_timer_message(topic, tag, body, timer, key = '')
@producer.send_timer_message(topic, tag, body, timer.to_i * 1000, key)
end | ruby | def send_timer_message(topic, tag, body, timer, key = '')
@producer.send_timer_message(topic, tag, body, timer.to_i * 1000, key)
end | [
"def",
"send_timer_message",
"(",
"topic",
",",
"tag",
",",
"body",
",",
"timer",
",",
"key",
"=",
"''",
")",
"@producer",
".",
"send_timer_message",
"(",
"topic",
",",
"tag",
",",
"body",
",",
"timer",
".",
"to_i",
"*",
"1000",
",",
"key",
")",
"end... | Send a timer message.
@example send 'Hello, World!' message at 30 seconds later
producer.send_timer_message('TopicTestMQ', 'tagA', 'Hello, World!', Time.now + 30)
@see #send_message
@param topic [String] the message topic
@param tag [String] the message tag
@param body [String] the message body
@param timer... | [
"Send",
"a",
"timer",
"message",
"."
] | 00d16d5fe4dc55929036544a7667c463694f6b1f | https://github.com/souche/aliyun-ons-ruby-sdk/blob/00d16d5fe4dc55929036544a7667c463694f6b1f/lib/ons/producer.rb#L56-L58 |
3,519 | woodruffw/ruby-mpv | lib/mpv/client.rb | MPV.Client.distribute_results! | def distribute_results!
response = JSON.parse(@socket.readline)
if response["event"]
@event_queue << response
else
@result_queue << response
end
rescue StandardError
@alive = false
Thread.exit
end | ruby | def distribute_results!
response = JSON.parse(@socket.readline)
if response["event"]
@event_queue << response
else
@result_queue << response
end
rescue StandardError
@alive = false
Thread.exit
end | [
"def",
"distribute_results!",
"response",
"=",
"JSON",
".",
"parse",
"(",
"@socket",
".",
"readline",
")",
"if",
"response",
"[",
"\"event\"",
"]",
"@event_queue",
"<<",
"response",
"else",
"@result_queue",
"<<",
"response",
"end",
"rescue",
"StandardError",
"@a... | Distributes results to the event and result queues.
@api private | [
"Distributes",
"results",
"to",
"the",
"event",
"and",
"result",
"queues",
"."
] | af813337aaf64f25b48e562de2176dec1b381aab | https://github.com/woodruffw/ruby-mpv/blob/af813337aaf64f25b48e562de2176dec1b381aab/lib/mpv/client.rb#L120-L131 |
3,520 | woodruffw/ruby-mpv | lib/mpv/client.rb | MPV.Client.dispatch_events! | def dispatch_events!
loop do
event = @event_queue.pop
callbacks.each do |callback|
Thread.new do
callback.call event
end
end
end
end | ruby | def dispatch_events!
loop do
event = @event_queue.pop
callbacks.each do |callback|
Thread.new do
callback.call event
end
end
end
end | [
"def",
"dispatch_events!",
"loop",
"do",
"event",
"=",
"@event_queue",
".",
"pop",
"callbacks",
".",
"each",
"do",
"|",
"callback",
"|",
"Thread",
".",
"new",
"do",
"callback",
".",
"call",
"event",
"end",
"end",
"end",
"end"
] | Takes events from the event queue and dispatches them to callbacks.
@api private | [
"Takes",
"events",
"from",
"the",
"event",
"queue",
"and",
"dispatches",
"them",
"to",
"callbacks",
"."
] | af813337aaf64f25b48e562de2176dec1b381aab | https://github.com/woodruffw/ruby-mpv/blob/af813337aaf64f25b48e562de2176dec1b381aab/lib/mpv/client.rb#L135-L145 |
3,521 | puppetlabs/beaker-google | lib/beaker/hypervisor/google_compute.rb | Beaker.GoogleCompute.find_google_ssh_public_key | def find_google_ssh_public_key
keyfile = ENV.fetch('BEAKER_gce_ssh_public_key', File.join(ENV['HOME'], '.ssh', 'google_compute_engine.pub'))
if @options[:gce_ssh_public_key] && !File.exist?(keyfile)
keyfile = @options[:gce_ssh_public_key]
end
raise("Could not find GCE Public SSH Key at... | ruby | def find_google_ssh_public_key
keyfile = ENV.fetch('BEAKER_gce_ssh_public_key', File.join(ENV['HOME'], '.ssh', 'google_compute_engine.pub'))
if @options[:gce_ssh_public_key] && !File.exist?(keyfile)
keyfile = @options[:gce_ssh_public_key]
end
raise("Could not find GCE Public SSH Key at... | [
"def",
"find_google_ssh_public_key",
"keyfile",
"=",
"ENV",
".",
"fetch",
"(",
"'BEAKER_gce_ssh_public_key'",
",",
"File",
".",
"join",
"(",
"ENV",
"[",
"'HOME'",
"]",
",",
"'.ssh'",
",",
"'google_compute_engine.pub'",
")",
")",
"if",
"@options",
"[",
":gce_ssh_... | Do some reasonable sleuthing on the SSH public key for GCE | [
"Do",
"some",
"reasonable",
"sleuthing",
"on",
"the",
"SSH",
"public",
"key",
"for",
"GCE"
] | 3d7927f718447547293559d4631e26fcbdbf78e3 | https://github.com/puppetlabs/beaker-google/blob/3d7927f718447547293559d4631e26fcbdbf78e3/lib/beaker/hypervisor/google_compute.rb#L14-L24 |
3,522 | puppetlabs/beaker-google | lib/beaker/hypervisor/google_compute.rb | Beaker.GoogleCompute.provision | def provision
attempts = @options[:timeout].to_i / SLEEPWAIT
start = Time.now
test_group_identifier = "beaker-#{start.to_i}-"
# get machineType resource, used by all instances
machineType = @gce_helper.get_machineType(start, attempts)
# set firewall to open pe ports
network ... | ruby | def provision
attempts = @options[:timeout].to_i / SLEEPWAIT
start = Time.now
test_group_identifier = "beaker-#{start.to_i}-"
# get machineType resource, used by all instances
machineType = @gce_helper.get_machineType(start, attempts)
# set firewall to open pe ports
network ... | [
"def",
"provision",
"attempts",
"=",
"@options",
"[",
":timeout",
"]",
".",
"to_i",
"/",
"SLEEPWAIT",
"start",
"=",
"Time",
".",
"now",
"test_group_identifier",
"=",
"\"beaker-#{start.to_i}-\"",
"# get machineType resource, used by all instances",
"machineType",
"=",
"@... | Create a new instance of the Google Compute Engine hypervisor object
@param [<Host>] google_hosts The Array of google hosts to provision, may
ONLY be of platforms /centos-*/, /debian-*/, /rhel-*/, /suse-*/. Only
supports the Google Compute provided templates.
@param [Hash{Symbol=>String}] options The options hash... | [
"Create",
"a",
"new",
"instance",
"of",
"the",
"Google",
"Compute",
"Engine",
"hypervisor",
"object"
] | 3d7927f718447547293559d4631e26fcbdbf78e3 | https://github.com/puppetlabs/beaker-google/blob/3d7927f718447547293559d4631e26fcbdbf78e3/lib/beaker/hypervisor/google_compute.rb#L72-L137 |
3,523 | puppetlabs/beaker-google | lib/beaker/hypervisor/google_compute.rb | Beaker.GoogleCompute.cleanup | def cleanup()
attempts = @options[:timeout].to_i / SLEEPWAIT
start = Time.now
@gce_helper.delete_firewall(@firewall, start, attempts)
@hosts.each do |host|
@gce_helper.delete_instance(host['vmhostname'], start, attempts)
@logger.debug("Deleted Google Compute instance #{host['vm... | ruby | def cleanup()
attempts = @options[:timeout].to_i / SLEEPWAIT
start = Time.now
@gce_helper.delete_firewall(@firewall, start, attempts)
@hosts.each do |host|
@gce_helper.delete_instance(host['vmhostname'], start, attempts)
@logger.debug("Deleted Google Compute instance #{host['vm... | [
"def",
"cleanup",
"(",
")",
"attempts",
"=",
"@options",
"[",
":timeout",
"]",
".",
"to_i",
"/",
"SLEEPWAIT",
"start",
"=",
"Time",
".",
"now",
"@gce_helper",
".",
"delete_firewall",
"(",
"@firewall",
",",
"start",
",",
"attempts",
")",
"@hosts",
".",
"e... | Shutdown and destroy virtual machines in the Google Compute Engine,
including their associated disks and firewall rules | [
"Shutdown",
"and",
"destroy",
"virtual",
"machines",
"in",
"the",
"Google",
"Compute",
"Engine",
"including",
"their",
"associated",
"disks",
"and",
"firewall",
"rules"
] | 3d7927f718447547293559d4631e26fcbdbf78e3 | https://github.com/puppetlabs/beaker-google/blob/3d7927f718447547293559d4631e26fcbdbf78e3/lib/beaker/hypervisor/google_compute.rb#L141-L154 |
3,524 | russ/country_code_select | lib/country_code_select/instance_tag.rb | CountryCodeSelect.InstanceTag.country_code_select | def country_code_select(priority_countries, options)
selected = object.send(@method_name)
countries = ""
if priority_countries
countries += options_for_select(priority_countries, selected)
countries += "<option value=\"\" disabled=\"disabled\">-------------</option>\n"
elsif options[:include_bla... | ruby | def country_code_select(priority_countries, options)
selected = object.send(@method_name)
countries = ""
if priority_countries
countries += options_for_select(priority_countries, selected)
countries += "<option value=\"\" disabled=\"disabled\">-------------</option>\n"
elsif options[:include_bla... | [
"def",
"country_code_select",
"(",
"priority_countries",
",",
"options",
")",
"selected",
"=",
"object",
".",
"send",
"(",
"@method_name",
")",
"countries",
"=",
"\"\"",
"if",
"priority_countries",
"countries",
"+=",
"options_for_select",
"(",
"priority_countries",
... | Adapted from Rails country_select. Just uses country codes instead of full names. | [
"Adapted",
"from",
"Rails",
"country_select",
".",
"Just",
"uses",
"country",
"codes",
"instead",
"of",
"full",
"names",
"."
] | c1975db2f0b55129bd207ddcd3cb294fa4a5ec5d | https://github.com/russ/country_code_select/blob/c1975db2f0b55129bd207ddcd3cb294fa4a5ec5d/lib/country_code_select/instance_tag.rb#L10-L24 |
3,525 | adonespitogo/unsakini | app/controllers/unsakini/boards_controller.rb | Unsakini.BoardsController.index | def index
admin = true
shared = false
admin = params[:is_admin] == 'true' if params[:admin]
shared = params[:shared] == 'true' if params[:shared]
result = @user.user_boards.shared(shared)
result = result.admin if admin
paginate json: result, per_page: 10
end | ruby | def index
admin = true
shared = false
admin = params[:is_admin] == 'true' if params[:admin]
shared = params[:shared] == 'true' if params[:shared]
result = @user.user_boards.shared(shared)
result = result.admin if admin
paginate json: result, per_page: 10
end | [
"def",
"index",
"admin",
"=",
"true",
"shared",
"=",
"false",
"admin",
"=",
"params",
"[",
":is_admin",
"]",
"==",
"'true'",
"if",
"params",
"[",
":admin",
"]",
"shared",
"=",
"params",
"[",
":shared",
"]",
"==",
"'true'",
"if",
"params",
"[",
":shared... | Returns boards belonging to current user
`GET /api/boards` | [
"Returns",
"boards",
"belonging",
"to",
"current",
"user"
] | 3e77e8e374a605961023e77a5c374734415b9f9d | https://github.com/adonespitogo/unsakini/blob/3e77e8e374a605961023e77a5c374734415b9f9d/app/controllers/unsakini/boards_controller.rb#L17-L25 |
3,526 | adonespitogo/unsakini | app/controllers/unsakini/boards_controller.rb | Unsakini.BoardsController.create | def create
@user_board = UserBoard.new(
name: params[:board][:name],
user_id: @user.id,
encrypted_password: params[:encrypted_password],
is_admin: true
)
if @user_board.save
render json: @user_board, status: :created
else
render json: @user_board.e... | ruby | def create
@user_board = UserBoard.new(
name: params[:board][:name],
user_id: @user.id,
encrypted_password: params[:encrypted_password],
is_admin: true
)
if @user_board.save
render json: @user_board, status: :created
else
render json: @user_board.e... | [
"def",
"create",
"@user_board",
"=",
"UserBoard",
".",
"new",
"(",
"name",
":",
"params",
"[",
":board",
"]",
"[",
":name",
"]",
",",
"user_id",
":",
"@user",
".",
"id",
",",
"encrypted_password",
":",
"params",
"[",
":encrypted_password",
"]",
",",
"is_... | Creates board belonging to current user.
`POST /api/boards` | [
"Creates",
"board",
"belonging",
"to",
"current",
"user",
"."
] | 3e77e8e374a605961023e77a5c374734415b9f9d | https://github.com/adonespitogo/unsakini/blob/3e77e8e374a605961023e77a5c374734415b9f9d/app/controllers/unsakini/boards_controller.rb#L31-L44 |
3,527 | adonespitogo/unsakini | app/controllers/unsakini/boards_controller.rb | Unsakini.BoardsController.update | def update
if @user_board.update(name: params[:board][:name], encrypted_password: params[:encrypted_password])
render json: @user_board
else
errors = @board.errors.full_messages.concat @user_board.errors.full_messages
render json: errors, status: 422
end
end | ruby | def update
if @user_board.update(name: params[:board][:name], encrypted_password: params[:encrypted_password])
render json: @user_board
else
errors = @board.errors.full_messages.concat @user_board.errors.full_messages
render json: errors, status: 422
end
end | [
"def",
"update",
"if",
"@user_board",
".",
"update",
"(",
"name",
":",
"params",
"[",
":board",
"]",
"[",
":name",
"]",
",",
"encrypted_password",
":",
"params",
"[",
":encrypted_password",
"]",
")",
"render",
"json",
":",
"@user_board",
"else",
"errors",
... | Updates a single board.
`PUT /api/boards/:id` | [
"Updates",
"a",
"single",
"board",
"."
] | 3e77e8e374a605961023e77a5c374734415b9f9d | https://github.com/adonespitogo/unsakini/blob/3e77e8e374a605961023e77a5c374734415b9f9d/app/controllers/unsakini/boards_controller.rb#L57-L64 |
3,528 | tevren/biffbot | lib/biffbot/base.rb | Biffbot.Base.generate_url | def generate_url url, token, type, version
case type
when 'analyze'
url = "http://api.diffbot.com/v3/#{type}?token=#{token}&url=#{url}"
when 'custom'
url = "http://api.diffbot.com/v3/#{options[:api_name]}?token=#{token}&url=#{url}"
when 'article', 'image', 'product'
url =... | ruby | def generate_url url, token, type, version
case type
when 'analyze'
url = "http://api.diffbot.com/v3/#{type}?token=#{token}&url=#{url}"
when 'custom'
url = "http://api.diffbot.com/v3/#{options[:api_name]}?token=#{token}&url=#{url}"
when 'article', 'image', 'product'
url =... | [
"def",
"generate_url",
"url",
",",
"token",
",",
"type",
",",
"version",
"case",
"type",
"when",
"'analyze'",
"url",
"=",
"\"http://api.diffbot.com/v3/#{type}?token=#{token}&url=#{url}\"",
"when",
"'custom'",
"url",
"=",
"\"http://api.diffbot.com/v3/#{options[:api_name]}?toke... | generate an url consisting of your api key and the endpoint you'd like to use
@param url [String] The url to pass to diffbot
@param token [String] Diffbot API token
@param type [String] API to use
@return [String] a formatted url with your api key, endpoint and input url | [
"generate",
"an",
"url",
"consisting",
"of",
"your",
"api",
"key",
"and",
"the",
"endpoint",
"you",
"d",
"like",
"to",
"use"
] | bf1f2aad39c2d5d9ba917f31ff6220f68581e8a3 | https://github.com/tevren/biffbot/blob/bf1f2aad39c2d5d9ba917f31ff6220f68581e8a3/lib/biffbot/base.rb#L28-L39 |
3,529 | tevren/biffbot | lib/biffbot/base.rb | Biffbot.Base.parse_options | def parse_options options = {}, request = ''
options.each do |opt, value|
case opt
when :timeout, :paging, :mode
request += "&#{opt}=#{value}"
when :callback, :stats
request += "&#{opt}"
when :fields
request += "&#{opt}=" + value.join(',') if value.is_... | ruby | def parse_options options = {}, request = ''
options.each do |opt, value|
case opt
when :timeout, :paging, :mode
request += "&#{opt}=#{value}"
when :callback, :stats
request += "&#{opt}"
when :fields
request += "&#{opt}=" + value.join(',') if value.is_... | [
"def",
"parse_options",
"options",
"=",
"{",
"}",
",",
"request",
"=",
"''",
"options",
".",
"each",
"do",
"|",
"opt",
",",
"value",
"|",
"case",
"opt",
"when",
":timeout",
",",
":paging",
",",
":mode",
"request",
"+=",
"\"&#{opt}=#{value}\"",
"when",
":... | add the options hash to your input url
@param options [Hash] An hash of options
@param request [String] The url to append options to
@return [String] a formatted url with options merged into the input url | [
"add",
"the",
"options",
"hash",
"to",
"your",
"input",
"url"
] | bf1f2aad39c2d5d9ba917f31ff6220f68581e8a3 | https://github.com/tevren/biffbot/blob/bf1f2aad39c2d5d9ba917f31ff6220f68581e8a3/lib/biffbot/base.rb#L46-L58 |
3,530 | melborne/colorable | lib/colorable/color.rb | Colorable.Color.info | def info
{
name: name,
rgb: rgb,
hsb: hsb,
hex: hex,
mode: mode,
dark: dark?
}
end | ruby | def info
{
name: name,
rgb: rgb,
hsb: hsb,
hex: hex,
mode: mode,
dark: dark?
}
end | [
"def",
"info",
"{",
"name",
":",
"name",
",",
"rgb",
":",
"rgb",
",",
"hsb",
":",
"hsb",
",",
"hex",
":",
"hex",
",",
"mode",
":",
"mode",
",",
"dark",
":",
"dark?",
"}",
"end"
] | Returns information of the color object | [
"Returns",
"information",
"of",
"the",
"color",
"object"
] | 1787059652aa4b85e7f879c16a7b6a36e6b90e59 | https://github.com/melborne/colorable/blob/1787059652aa4b85e7f879c16a7b6a36e6b90e59/lib/colorable/color.rb#L40-L49 |
3,531 | melborne/colorable | lib/colorable/color.rb | Colorable.Color.next | def next(n=1)
@@colorset[mode] ||= Colorable::Colorset.new(order: mode)
idx = @@colorset[mode].find_index(self)
@@colorset[mode].at(idx+n).tap{|c| c.mode = mode } if idx
end | ruby | def next(n=1)
@@colorset[mode] ||= Colorable::Colorset.new(order: mode)
idx = @@colorset[mode].find_index(self)
@@colorset[mode].at(idx+n).tap{|c| c.mode = mode } if idx
end | [
"def",
"next",
"(",
"n",
"=",
"1",
")",
"@@colorset",
"[",
"mode",
"]",
"||=",
"Colorable",
"::",
"Colorset",
".",
"new",
"(",
"order",
":",
"mode",
")",
"idx",
"=",
"@@colorset",
"[",
"mode",
"]",
".",
"find_index",
"(",
"self",
")",
"@@colorset",
... | Returns a next color object in X11 colors.
The color sequence is determined by its color mode. | [
"Returns",
"a",
"next",
"color",
"object",
"in",
"X11",
"colors",
".",
"The",
"color",
"sequence",
"is",
"determined",
"by",
"its",
"color",
"mode",
"."
] | 1787059652aa4b85e7f879c16a7b6a36e6b90e59 | https://github.com/melborne/colorable/blob/1787059652aa4b85e7f879c16a7b6a36e6b90e59/lib/colorable/color.rb#L103-L107 |
3,532 | flyerhzm/code_analyzer | lib/code_analyzer/checking_visitor/plain.rb | CodeAnalyzer::CheckingVisitor.Plain.check | def check(filename, content)
@checkers.each do |checker|
checker.check(filename, content) if checker.parse_file?(filename)
end
end | ruby | def check(filename, content)
@checkers.each do |checker|
checker.check(filename, content) if checker.parse_file?(filename)
end
end | [
"def",
"check",
"(",
"filename",
",",
"content",
")",
"@checkers",
".",
"each",
"do",
"|",
"checker",
"|",
"checker",
".",
"check",
"(",
"filename",
",",
"content",
")",
"if",
"checker",
".",
"parse_file?",
"(",
"filename",
")",
"end",
"end"
] | check the ruby plain code.
@param [String] filename is the filename of ruby code.
@param [String] content is the content of ruby file. | [
"check",
"the",
"ruby",
"plain",
"code",
"."
] | f4d63ae835574b3e48a3154df3e0ce83457502bd | https://github.com/flyerhzm/code_analyzer/blob/f4d63ae835574b3e48a3154df3e0ce83457502bd/lib/code_analyzer/checking_visitor/plain.rb#L9-L13 |
3,533 | adonespitogo/unsakini | app/controllers/concerns/unsakini/post_owner_controller_concern.rb | Unsakini.PostOwnerControllerConcern.ensure_post | def ensure_post
post_id = params[:post_id] || params[:id]
board_id = params[:board_id]
result = has_post_access(board_id, post_id)
status = result[:status]
@post = result[:post]
head status if status != :ok
end | ruby | def ensure_post
post_id = params[:post_id] || params[:id]
board_id = params[:board_id]
result = has_post_access(board_id, post_id)
status = result[:status]
@post = result[:post]
head status if status != :ok
end | [
"def",
"ensure_post",
"post_id",
"=",
"params",
"[",
":post_id",
"]",
"||",
"params",
"[",
":id",
"]",
"board_id",
"=",
"params",
"[",
":board_id",
"]",
"result",
"=",
"has_post_access",
"(",
"board_id",
",",
"post_id",
")",
"status",
"=",
"result",
"[",
... | Ensures user is owner of the post and sets the `@post` variable in the controllers | [
"Ensures",
"user",
"is",
"owner",
"of",
"the",
"post",
"and",
"sets",
"the"
] | 3e77e8e374a605961023e77a5c374734415b9f9d | https://github.com/adonespitogo/unsakini/blob/3e77e8e374a605961023e77a5c374734415b9f9d/app/controllers/concerns/unsakini/post_owner_controller_concern.rb#L7-L14 |
3,534 | adonespitogo/unsakini | app/controllers/concerns/unsakini/post_owner_controller_concern.rb | Unsakini.PostOwnerControllerConcern.has_post_access | def has_post_access(board_id, post_id)
post = Unsakini::Post.where(id: post_id, board_id: board_id)
.joins("LEFT JOIN #{UserBoard.table_name} ON #{UserBoard.table_name}.board_id = #{Post.table_name}.board_id")
.where("#{UserBoard.table_name}.user_id = ?", @user.id)
.first
if post.nil?
... | ruby | def has_post_access(board_id, post_id)
post = Unsakini::Post.where(id: post_id, board_id: board_id)
.joins("LEFT JOIN #{UserBoard.table_name} ON #{UserBoard.table_name}.board_id = #{Post.table_name}.board_id")
.where("#{UserBoard.table_name}.user_id = ?", @user.id)
.first
if post.nil?
... | [
"def",
"has_post_access",
"(",
"board_id",
",",
"post_id",
")",
"post",
"=",
"Unsakini",
"::",
"Post",
".",
"where",
"(",
"id",
":",
"post_id",
",",
"board_id",
":",
"board_id",
")",
".",
"joins",
"(",
"\"LEFT JOIN #{UserBoard.table_name} ON #{UserBoard.table_name... | Validate if user has access to the post in the board
@param board_id [Integer] board id
@param post_id [Integer] post id | [
"Validate",
"if",
"user",
"has",
"access",
"to",
"the",
"post",
"in",
"the",
"board"
] | 3e77e8e374a605961023e77a5c374734415b9f9d | https://github.com/adonespitogo/unsakini/blob/3e77e8e374a605961023e77a5c374734415b9f9d/app/controllers/concerns/unsakini/post_owner_controller_concern.rb#L20-L30 |
3,535 | wearefine/maximus | lib/maximus/statistics/stylestats.rb | Maximus.Stylestats.compile_scss | def compile_scss
puts "\nCompiling assets for stylestats...".color(:blue)
if is_rails?
# Get rake tasks
Rails.application.load_tasks unless @config.is_dev?
compile_scss_rails
else
load_compass
compile_scss
end
end | ruby | def compile_scss
puts "\nCompiling assets for stylestats...".color(:blue)
if is_rails?
# Get rake tasks
Rails.application.load_tasks unless @config.is_dev?
compile_scss_rails
else
load_compass
compile_scss
end
end | [
"def",
"compile_scss",
"puts",
"\"\\nCompiling assets for stylestats...\"",
".",
"color",
"(",
":blue",
")",
"if",
"is_rails?",
"# Get rake tasks",
"Rails",
".",
"application",
".",
"load_tasks",
"unless",
"@config",
".",
"is_dev?",
"compile_scss_rails",
"else",
"load_c... | Find all CSS files or compile.
Uses sprockets if Rails; Sass engine otherwise.
Compass is supported
@return [#compile_scss_rails, #compile_scss, Array] CSS files | [
"Find",
"all",
"CSS",
"files",
"or",
"compile",
"."
] | d3a6ad1826694c98a5e6a5a3175b78e69aac7945 | https://github.com/wearefine/maximus/blob/d3a6ad1826694c98a5e6a5a3175b78e69aac7945/lib/maximus/statistics/stylestats.rb#L40-L53 |
3,536 | wearefine/maximus | lib/maximus/statistics/stylestats.rb | Maximus.Stylestats.load_compass | def load_compass
if Gem::Specification::find_all_by_name('compass').any?
require 'compass'
Compass.sass_engine_options[:load_paths].each do |path|
Sass.load_paths << path
end
end
end | ruby | def load_compass
if Gem::Specification::find_all_by_name('compass').any?
require 'compass'
Compass.sass_engine_options[:load_paths].each do |path|
Sass.load_paths << path
end
end
end | [
"def",
"load_compass",
"if",
"Gem",
"::",
"Specification",
"::",
"find_all_by_name",
"(",
"'compass'",
")",
".",
"any?",
"require",
"'compass'",
"Compass",
".",
"sass_engine_options",
"[",
":load_paths",
"]",
".",
"each",
"do",
"|",
"path",
"|",
"Sass",
".",
... | Load Compass paths if the gem exists
@see find_css_files
@since 0.1.5 | [
"Load",
"Compass",
"paths",
"if",
"the",
"gem",
"exists"
] | d3a6ad1826694c98a5e6a5a3175b78e69aac7945 | https://github.com/wearefine/maximus/blob/d3a6ad1826694c98a5e6a5a3175b78e69aac7945/lib/maximus/statistics/stylestats.rb#L58-L65 |
3,537 | wearefine/maximus | lib/maximus/statistics/stylestats.rb | Maximus.Stylestats.load_scss_load_paths | def load_scss_load_paths
Dir.glob(@path).select { |d| File.directory? d}.each do |directory|
Sass.load_paths << directory
end
end | ruby | def load_scss_load_paths
Dir.glob(@path).select { |d| File.directory? d}.each do |directory|
Sass.load_paths << directory
end
end | [
"def",
"load_scss_load_paths",
"Dir",
".",
"glob",
"(",
"@path",
")",
".",
"select",
"{",
"|",
"d",
"|",
"File",
".",
"directory?",
"d",
"}",
".",
"each",
"do",
"|",
"directory",
"|",
"Sass",
".",
"load_paths",
"<<",
"directory",
"end",
"end"
] | Add directories to load paths
@todo This function is here in case older versions of SCSS will need it
because there shouldn't be a need to load paths, but there might be a need
in older versions of SCSS, which should be tested (although the SCSSLint)
dependency may dictate our scss version
@since 0.1.5 | [
"Add",
"directories",
"to",
"load",
"paths"
] | d3a6ad1826694c98a5e6a5a3175b78e69aac7945 | https://github.com/wearefine/maximus/blob/d3a6ad1826694c98a5e6a5a3175b78e69aac7945/lib/maximus/statistics/stylestats.rb#L73-L77 |
3,538 | wearefine/maximus | lib/maximus/statistics/stylestats.rb | Maximus.Stylestats.compile_scss_normal | def compile_scss_normal
Dir["#{@path}.scss"].select { |f| File.file? f }.each do |file|
next if File.basename(file).chr == '_'
scss_file = File.open(file, 'rb') { |f| f.read }
output_file = File.open( file.split('.').reverse.drop(1).reverse.join('.'), "w" )
output_file <... | ruby | def compile_scss_normal
Dir["#{@path}.scss"].select { |f| File.file? f }.each do |file|
next if File.basename(file).chr == '_'
scss_file = File.open(file, 'rb') { |f| f.read }
output_file = File.open( file.split('.').reverse.drop(1).reverse.join('.'), "w" )
output_file <... | [
"def",
"compile_scss_normal",
"Dir",
"[",
"\"#{@path}.scss\"",
"]",
".",
"select",
"{",
"|",
"f",
"|",
"File",
".",
"file?",
"f",
"}",
".",
"each",
"do",
"|",
"file",
"|",
"next",
"if",
"File",
".",
"basename",
"(",
"file",
")",
".",
"chr",
"==",
"... | Turn scss files into css files
Skips if the file starts with an underscore
@see find_css_files
@since 0.1.5 | [
"Turn",
"scss",
"files",
"into",
"css",
"files",
"Skips",
"if",
"the",
"file",
"starts",
"with",
"an",
"underscore"
] | d3a6ad1826694c98a5e6a5a3175b78e69aac7945 | https://github.com/wearefine/maximus/blob/d3a6ad1826694c98a5e6a5a3175b78e69aac7945/lib/maximus/statistics/stylestats.rb#L98-L107 |
3,539 | wearefine/maximus | lib/maximus/statistics/stylestats.rb | Maximus.Stylestats.find_css | def find_css(path = @path)
Dir.glob(path).select { |f| File.file? f }.map { |file| file }
end | ruby | def find_css(path = @path)
Dir.glob(path).select { |f| File.file? f }.map { |file| file }
end | [
"def",
"find_css",
"(",
"path",
"=",
"@path",
")",
"Dir",
".",
"glob",
"(",
"path",
")",
".",
"select",
"{",
"|",
"f",
"|",
"File",
".",
"file?",
"f",
"}",
".",
"map",
"{",
"|",
"file",
"|",
"file",
"}",
"end"
] | Find all css files
@param path [String] globbed file path
@return [Array] paths to compiled CSS files | [
"Find",
"all",
"css",
"files"
] | d3a6ad1826694c98a5e6a5a3175b78e69aac7945 | https://github.com/wearefine/maximus/blob/d3a6ad1826694c98a5e6a5a3175b78e69aac7945/lib/maximus/statistics/stylestats.rb#L128-L130 |
3,540 | adonespitogo/unsakini | app/controllers/unsakini/posts_controller.rb | Unsakini.PostsController.create | def create
@post = Post.new(params.permit(:title, :content, :board_id))
@post.user = @user
if (@post.save)
render json: @post, status: :created
else
render json: @post.errors, status: 422
end
end | ruby | def create
@post = Post.new(params.permit(:title, :content, :board_id))
@post.user = @user
if (@post.save)
render json: @post, status: :created
else
render json: @post.errors, status: 422
end
end | [
"def",
"create",
"@post",
"=",
"Post",
".",
"new",
"(",
"params",
".",
"permit",
"(",
":title",
",",
":content",
",",
":board_id",
")",
")",
"@post",
".",
"user",
"=",
"@user",
"if",
"(",
"@post",
".",
"save",
")",
"render",
"json",
":",
"@post",
"... | Creates a single post belonging to the board
`POST /api/boards/:board_id/posts/` | [
"Creates",
"a",
"single",
"post",
"belonging",
"to",
"the",
"board"
] | 3e77e8e374a605961023e77a5c374734415b9f9d | https://github.com/adonespitogo/unsakini/blob/3e77e8e374a605961023e77a5c374734415b9f9d/app/controllers/unsakini/posts_controller.rb#L30-L38 |
3,541 | adonespitogo/unsakini | app/models/concerns/unsakini/encryptable_model_concern.rb | Unsakini.EncryptableModelConcern.encrypt | def encrypt(value)
return value if is_empty_val(value)
c = cipher.encrypt
c.key = Digest::SHA256.digest(cipher_key)
c.iv = iv = c.random_iv
Base64.encode64(iv) + Base64.encode64(c.update(value.to_s) + c.final)
end | ruby | def encrypt(value)
return value if is_empty_val(value)
c = cipher.encrypt
c.key = Digest::SHA256.digest(cipher_key)
c.iv = iv = c.random_iv
Base64.encode64(iv) + Base64.encode64(c.update(value.to_s) + c.final)
end | [
"def",
"encrypt",
"(",
"value",
")",
"return",
"value",
"if",
"is_empty_val",
"(",
"value",
")",
"c",
"=",
"cipher",
".",
"encrypt",
"c",
".",
"key",
"=",
"Digest",
"::",
"SHA256",
".",
"digest",
"(",
"cipher_key",
")",
"c",
".",
"iv",
"=",
"iv",
"... | Encrypts model attribute value | [
"Encrypts",
"model",
"attribute",
"value"
] | 3e77e8e374a605961023e77a5c374734415b9f9d | https://github.com/adonespitogo/unsakini/blob/3e77e8e374a605961023e77a5c374734415b9f9d/app/models/concerns/unsakini/encryptable_model_concern.rb#L79-L85 |
3,542 | adonespitogo/unsakini | app/models/concerns/unsakini/encryptable_model_concern.rb | Unsakini.EncryptableModelConcern.decrypt | def decrypt(value)
return value if is_empty_val(value)
c = cipher.decrypt
c.key = Digest::SHA256.digest(cipher_key)
c.iv = Base64.decode64 value.slice!(0,25)
c.update(Base64.decode64(value.to_s)) + c.final
end | ruby | def decrypt(value)
return value if is_empty_val(value)
c = cipher.decrypt
c.key = Digest::SHA256.digest(cipher_key)
c.iv = Base64.decode64 value.slice!(0,25)
c.update(Base64.decode64(value.to_s)) + c.final
end | [
"def",
"decrypt",
"(",
"value",
")",
"return",
"value",
"if",
"is_empty_val",
"(",
"value",
")",
"c",
"=",
"cipher",
".",
"decrypt",
"c",
".",
"key",
"=",
"Digest",
"::",
"SHA256",
".",
"digest",
"(",
"cipher_key",
")",
"c",
".",
"iv",
"=",
"Base64",... | Decrypts model attribute value | [
"Decrypts",
"model",
"attribute",
"value"
] | 3e77e8e374a605961023e77a5c374734415b9f9d | https://github.com/adonespitogo/unsakini/blob/3e77e8e374a605961023e77a5c374734415b9f9d/app/models/concerns/unsakini/encryptable_model_concern.rb#L88-L94 |
3,543 | michaeledgar/ripper-plus | lib/ripper-plus/transformer.rb | RipperPlus.Transformer.transform | def transform(root, opts={})
new_copy = opts[:in_place] ? root : clone_sexp(root)
scope_stack = ScopeStack.new
transform_tree(new_copy, scope_stack)
new_copy
end | ruby | def transform(root, opts={})
new_copy = opts[:in_place] ? root : clone_sexp(root)
scope_stack = ScopeStack.new
transform_tree(new_copy, scope_stack)
new_copy
end | [
"def",
"transform",
"(",
"root",
",",
"opts",
"=",
"{",
"}",
")",
"new_copy",
"=",
"opts",
"[",
":in_place",
"]",
"?",
"root",
":",
"clone_sexp",
"(",
"root",
")",
"scope_stack",
"=",
"ScopeStack",
".",
"new",
"transform_tree",
"(",
"new_copy",
",",
"s... | Transforms the given AST into a RipperPlus AST. | [
"Transforms",
"the",
"given",
"AST",
"into",
"a",
"RipperPlus",
"AST",
"."
] | bfe2cf4fc866cfa9f5cc70e61589a8fd9af9f87e | https://github.com/michaeledgar/ripper-plus/blob/bfe2cf4fc866cfa9f5cc70e61589a8fd9af9f87e/lib/ripper-plus/transformer.rb#L52-L57 |
3,544 | michaeledgar/ripper-plus | lib/ripper-plus/transformer.rb | RipperPlus.Transformer.add_variables_from_node | def add_variables_from_node(lhs, scope_stack, allow_duplicates=true)
case lhs[0]
when :@ident
scope_stack.add_variable(lhs[1], allow_duplicates)
when :const_path_field, :@const, :top_const_field
if scope_stack.in_method?
raise DynamicConstantError.new
end
when A... | ruby | def add_variables_from_node(lhs, scope_stack, allow_duplicates=true)
case lhs[0]
when :@ident
scope_stack.add_variable(lhs[1], allow_duplicates)
when :const_path_field, :@const, :top_const_field
if scope_stack.in_method?
raise DynamicConstantError.new
end
when A... | [
"def",
"add_variables_from_node",
"(",
"lhs",
",",
"scope_stack",
",",
"allow_duplicates",
"=",
"true",
")",
"case",
"lhs",
"[",
"0",
"]",
"when",
":@ident",
"scope_stack",
".",
"add_variable",
"(",
"lhs",
"[",
"1",
"]",
",",
"allow_duplicates",
")",
"when",... | Adds variables to the given scope stack from the given node. Allows
nodes from parameter lists, left-hand-sides, block argument lists, and
so on. | [
"Adds",
"variables",
"to",
"the",
"given",
"scope",
"stack",
"from",
"the",
"given",
"node",
".",
"Allows",
"nodes",
"from",
"parameter",
"lists",
"left",
"-",
"hand",
"-",
"sides",
"block",
"argument",
"lists",
"and",
"so",
"on",
"."
] | bfe2cf4fc866cfa9f5cc70e61589a8fd9af9f87e | https://github.com/michaeledgar/ripper-plus/blob/bfe2cf4fc866cfa9f5cc70e61589a8fd9af9f87e/lib/ripper-plus/transformer.rb#L210-L234 |
3,545 | michaeledgar/ripper-plus | lib/ripper-plus/transformer.rb | RipperPlus.Transformer.transform_in_order | def transform_in_order(tree, scope_stack)
# some nodes have no type: include the first element in this case
range = Symbol === tree[0] ? 1..-1 : 0..-1
tree[range].each do |subtree|
# obviously don't transform literals or token locations
if Array === subtree && !(Fixnum === subtree[0])
... | ruby | def transform_in_order(tree, scope_stack)
# some nodes have no type: include the first element in this case
range = Symbol === tree[0] ? 1..-1 : 0..-1
tree[range].each do |subtree|
# obviously don't transform literals or token locations
if Array === subtree && !(Fixnum === subtree[0])
... | [
"def",
"transform_in_order",
"(",
"tree",
",",
"scope_stack",
")",
"# some nodes have no type: include the first element in this case",
"range",
"=",
"Symbol",
"===",
"tree",
"[",
"0",
"]",
"?",
"1",
"..",
"-",
"1",
":",
"0",
"..",
"-",
"1",
"tree",
"[",
"rang... | If this node's subtrees are ordered as they are lexically, as most are,
transform each subtree in order. | [
"If",
"this",
"node",
"s",
"subtrees",
"are",
"ordered",
"as",
"they",
"are",
"lexically",
"as",
"most",
"are",
"transform",
"each",
"subtree",
"in",
"order",
"."
] | bfe2cf4fc866cfa9f5cc70e61589a8fd9af9f87e | https://github.com/michaeledgar/ripper-plus/blob/bfe2cf4fc866cfa9f5cc70e61589a8fd9af9f87e/lib/ripper-plus/transformer.rb#L238-L247 |
3,546 | michaeledgar/ripper-plus | lib/ripper-plus/transformer.rb | RipperPlus.Transformer.transform_params | def transform_params(param_node, scope_stack)
param_node = param_node[1] if param_node[0] == :paren
if param_node
positional_1, optional, rest, positional_2, block = param_node[1..5]
add_variable_list(positional_1, scope_stack, false) if positional_1
if optional
optional.ea... | ruby | def transform_params(param_node, scope_stack)
param_node = param_node[1] if param_node[0] == :paren
if param_node
positional_1, optional, rest, positional_2, block = param_node[1..5]
add_variable_list(positional_1, scope_stack, false) if positional_1
if optional
optional.ea... | [
"def",
"transform_params",
"(",
"param_node",
",",
"scope_stack",
")",
"param_node",
"=",
"param_node",
"[",
"1",
"]",
"if",
"param_node",
"[",
"0",
"]",
"==",
":paren",
"if",
"param_node",
"positional_1",
",",
"optional",
",",
"rest",
",",
"positional_2",
"... | Transforms a parameter list, and adds the new variables to current scope.
Used by both block args and method args. | [
"Transforms",
"a",
"parameter",
"list",
"and",
"adds",
"the",
"new",
"variables",
"to",
"current",
"scope",
".",
"Used",
"by",
"both",
"block",
"args",
"and",
"method",
"args",
"."
] | bfe2cf4fc866cfa9f5cc70e61589a8fd9af9f87e | https://github.com/michaeledgar/ripper-plus/blob/bfe2cf4fc866cfa9f5cc70e61589a8fd9af9f87e/lib/ripper-plus/transformer.rb#L251-L269 |
3,547 | jondot/version_bumper | lib/bumper/version.rb | Bumper.Version.bump_patch_tag | def bump_patch_tag tag
@v[:build] = '0' unless build.nil?
if patch_tag.nil?
@v[:patch] = patch.succ
return @v[:patch_tag] = tag
elsif patch_tag.start_with? tag
# ensure tag ends with number
if patch_tag !~ %r{\d+$}
@v[:patch_tag] = patch_tag + '1' # required f... | ruby | def bump_patch_tag tag
@v[:build] = '0' unless build.nil?
if patch_tag.nil?
@v[:patch] = patch.succ
return @v[:patch_tag] = tag
elsif patch_tag.start_with? tag
# ensure tag ends with number
if patch_tag !~ %r{\d+$}
@v[:patch_tag] = patch_tag + '1' # required f... | [
"def",
"bump_patch_tag",
"tag",
"@v",
"[",
":build",
"]",
"=",
"'0'",
"unless",
"build",
".",
"nil?",
"if",
"patch_tag",
".",
"nil?",
"@v",
"[",
":patch",
"]",
"=",
"patch",
".",
"succ",
"return",
"@v",
"[",
":patch_tag",
"]",
"=",
"tag",
"elsif",
"p... | patch tags go from alpha, alpha2, alpha3, etc. | [
"patch",
"tags",
"go",
"from",
"alpha",
"alpha2",
"alpha3",
"etc",
"."
] | 250977316e3bf2079f1a660e03e28ee98256ddc0 | https://github.com/jondot/version_bumper/blob/250977316e3bf2079f1a660e03e28ee98256ddc0/lib/bumper/version.rb#L58-L73 |
3,548 | mbj/morpher | lib/morpher/printer.rb | Morpher.Printer.visit | def visit(name)
child = object.public_send(name)
child_label(name)
visit_child(child)
end | ruby | def visit(name)
child = object.public_send(name)
child_label(name)
visit_child(child)
end | [
"def",
"visit",
"(",
"name",
")",
"child",
"=",
"object",
".",
"public_send",
"(",
"name",
")",
"child_label",
"(",
"name",
")",
"visit_child",
"(",
"child",
")",
"end"
] | Visit a child by name
@param [Symbol] name
the attribute name of the child to visit
@return [undefined]
@api private | [
"Visit",
"a",
"child",
"by",
"name"
] | c9f9f720933835e09acfe6100bb20e8bd3c01915 | https://github.com/mbj/morpher/blob/c9f9f720933835e09acfe6100bb20e8bd3c01915/lib/morpher/printer.rb#L71-L75 |
3,549 | mbj/morpher | lib/morpher/printer.rb | Morpher.Printer.visit_many | def visit_many(name)
children = object.public_send(name)
child_label(name)
children.each do |child|
visit_child(child)
end
end | ruby | def visit_many(name)
children = object.public_send(name)
child_label(name)
children.each do |child|
visit_child(child)
end
end | [
"def",
"visit_many",
"(",
"name",
")",
"children",
"=",
"object",
".",
"public_send",
"(",
"name",
")",
"child_label",
"(",
"name",
")",
"children",
".",
"each",
"do",
"|",
"child",
"|",
"visit_child",
"(",
"child",
")",
"end",
"end"
] | Visit many children
@param [Symbol] name
the name of the collection attribute with children to visit
@return [undefined]
@api private | [
"Visit",
"many",
"children"
] | c9f9f720933835e09acfe6100bb20e8bd3c01915 | https://github.com/mbj/morpher/blob/c9f9f720933835e09acfe6100bb20e8bd3c01915/lib/morpher/printer.rb#L86-L92 |
3,550 | mbj/morpher | lib/morpher/printer.rb | Morpher.Printer.indent | def indent(&block)
printer = new(object, output, indent_level.succ)
printer.instance_eval(&block)
end | ruby | def indent(&block)
printer = new(object, output, indent_level.succ)
printer.instance_eval(&block)
end | [
"def",
"indent",
"(",
"&",
"block",
")",
"printer",
"=",
"new",
"(",
"object",
",",
"output",
",",
"indent_level",
".",
"succ",
")",
"printer",
".",
"instance_eval",
"(",
"block",
")",
"end"
] | Call block inside indented context
@return [undefined]
@api private | [
"Call",
"block",
"inside",
"indented",
"context"
] | c9f9f720933835e09acfe6100bb20e8bd3c01915 | https://github.com/mbj/morpher/blob/c9f9f720933835e09acfe6100bb20e8bd3c01915/lib/morpher/printer.rb#L203-L206 |
3,551 | ronin-ruby/ronin-support | lib/ronin/fuzzing/fuzzing.rb | Ronin.Fuzzing.bad_strings | def bad_strings(&block)
yield ''
chars = [
'A', 'a', '1', '<', '>', '"', "'", '/', "\\", '?', '=', 'a=', '&',
'.', ',', '(', ')', ']', '[', '%', '*', '-', '+', '{', '}',
"\x14", "\xfe", "\xff"
]
chars.each do |c|
LONG_LENGTHS.each { |length| yield c * leng... | ruby | def bad_strings(&block)
yield ''
chars = [
'A', 'a', '1', '<', '>', '"', "'", '/', "\\", '?', '=', 'a=', '&',
'.', ',', '(', ')', ']', '[', '%', '*', '-', '+', '{', '}',
"\x14", "\xfe", "\xff"
]
chars.each do |c|
LONG_LENGTHS.each { |length| yield c * leng... | [
"def",
"bad_strings",
"(",
"&",
"block",
")",
"yield",
"''",
"chars",
"=",
"[",
"'A'",
",",
"'a'",
",",
"'1'",
",",
"'<'",
",",
"'>'",
",",
"'\"'",
",",
"\"'\"",
",",
"'/'",
",",
"\"\\\\\"",
",",
"'?'",
",",
"'='",
",",
"'a='",
",",
"'&'",
",",... | Various bad-strings.
@yield [string]
The given block will be passed each bad-string.
@yieldparam [String] string
A bad-string containing known control characters, deliminators
or null-bytes (see {NULL_BYTES}), of varying length
(see {SHORT_LENGTHS} and {LONG_LENGTHS}). | [
"Various",
"bad",
"-",
"strings",
"."
] | bc2af0e75098c13133789118245cb185f8c6b4c9 | https://github.com/ronin-ruby/ronin-support/blob/bc2af0e75098c13133789118245cb185f8c6b4c9/lib/ronin/fuzzing/fuzzing.rb#L87-L117 |
3,552 | ronin-ruby/ronin-support | lib/ronin/fuzzing/fuzzing.rb | Ronin.Fuzzing.bit_fields | def bit_fields(&block)
("\x00".."\xff").each do |c|
yield c
yield c << c # x2
yield c << c # x4
yield c << c # x8
end
end | ruby | def bit_fields(&block)
("\x00".."\xff").each do |c|
yield c
yield c << c # x2
yield c << c # x4
yield c << c # x8
end
end | [
"def",
"bit_fields",
"(",
"&",
"block",
")",
"(",
"\"\\x00\"",
"..",
"\"\\xff\"",
")",
".",
"each",
"do",
"|",
"c",
"|",
"yield",
"c",
"yield",
"c",
"<<",
"c",
"# x2",
"yield",
"c",
"<<",
"c",
"# x4",
"yield",
"c",
"<<",
"c",
"# x8",
"end",
"end"... | The range of bit-fields.
@yield [bitfield]
The given block will be passed each bit-field.
@yieldparam [String] bitfield
A bit-field (8bit - 64bit). | [
"The",
"range",
"of",
"bit",
"-",
"fields",
"."
] | bc2af0e75098c13133789118245cb185f8c6b4c9 | https://github.com/ronin-ruby/ronin-support/blob/bc2af0e75098c13133789118245cb185f8c6b4c9/lib/ronin/fuzzing/fuzzing.rb#L176-L183 |
3,553 | ronin-ruby/ronin-support | lib/ronin/fuzzing/fuzzing.rb | Ronin.Fuzzing.signed_bit_fields | def signed_bit_fields(&block)
("\x80".."\xff").each do |c|
yield c
yield c << c # x2
yield c << c # x4
yield c << c # x8
end
end | ruby | def signed_bit_fields(&block)
("\x80".."\xff").each do |c|
yield c
yield c << c # x2
yield c << c # x4
yield c << c # x8
end
end | [
"def",
"signed_bit_fields",
"(",
"&",
"block",
")",
"(",
"\"\\x80\"",
"..",
"\"\\xff\"",
")",
".",
"each",
"do",
"|",
"c",
"|",
"yield",
"c",
"yield",
"c",
"<<",
"c",
"# x2",
"yield",
"c",
"<<",
"c",
"# x4",
"yield",
"c",
"<<",
"c",
"# x8",
"end",
... | The range of signed bit-fields.
@yield [bitfield]
The given block will be passed each bit-field.
@yieldparam [String] bitfield
A signed bit-field (8bit - 64bit). | [
"The",
"range",
"of",
"signed",
"bit",
"-",
"fields",
"."
] | bc2af0e75098c13133789118245cb185f8c6b4c9 | https://github.com/ronin-ruby/ronin-support/blob/bc2af0e75098c13133789118245cb185f8c6b4c9/lib/ronin/fuzzing/fuzzing.rb#L194-L201 |
3,554 | wearefine/maximus | lib/maximus/statistics/phantomas.rb | Maximus.Phantomas.result | def result
return if @settings[:phantomas].blank?
node_module_exists('phantomjs', 'brew install')
node_module_exists('phantomas')
@path = @settings[:paths] if @path.blank?
@domain = @config.domain
# Phantomas doesn't actually skip the skip-modules defined in the config BUT here's... | ruby | def result
return if @settings[:phantomas].blank?
node_module_exists('phantomjs', 'brew install')
node_module_exists('phantomas')
@path = @settings[:paths] if @path.blank?
@domain = @config.domain
# Phantomas doesn't actually skip the skip-modules defined in the config BUT here's... | [
"def",
"result",
"return",
"if",
"@settings",
"[",
":phantomas",
"]",
".",
"blank?",
"node_module_exists",
"(",
"'phantomjs'",
",",
"'brew install'",
")",
"node_module_exists",
"(",
"'phantomas'",
")",
"@path",
"=",
"@settings",
"[",
":paths",
"]",
"if",
"@path"... | Run phantomas through the command line
@see Statistic#initialize | [
"Run",
"phantomas",
"through",
"the",
"command",
"line"
] | d3a6ad1826694c98a5e6a5a3175b78e69aac7945 | https://github.com/wearefine/maximus/blob/d3a6ad1826694c98a5e6a5a3175b78e69aac7945/lib/maximus/statistics/phantomas.rb#L8-L24 |
3,555 | chrislee35/snort-rule | lib/snort/rule.rb | Snort.Rule.to_s | def to_s(options_only=false)
rule = ""
if @comments
rule += @comments
end
if not @enabled
rule += "#"
end
rule += [@action, @proto, @src, @sport, @dir, @dst, @dport].join(" ") unless options_only
if @options.any?
rule += " (" unless options_only
... | ruby | def to_s(options_only=false)
rule = ""
if @comments
rule += @comments
end
if not @enabled
rule += "#"
end
rule += [@action, @proto, @src, @sport, @dir, @dst, @dport].join(" ") unless options_only
if @options.any?
rule += " (" unless options_only
... | [
"def",
"to_s",
"(",
"options_only",
"=",
"false",
")",
"rule",
"=",
"\"\"",
"if",
"@comments",
"rule",
"+=",
"@comments",
"end",
"if",
"not",
"@enabled",
"rule",
"+=",
"\"#\"",
"end",
"rule",
"+=",
"[",
"@action",
",",
"@proto",
",",
"@src",
",",
"@spo... | Initializes the Rule
@param [Hash] kwargs The options to initialize the Rule with
@option kwargs [String] :enabled true or false
@option kwargs [String] :action The action
@option kwargs [String] :proto The protocol
@option kwargs [String] :src The source IP
@option kwargs [String] :sport The source Port
@option... | [
"Initializes",
"the",
"Rule"
] | b817c467186ea6644886cc79992b75b92add9feb | https://github.com/chrislee35/snort-rule/blob/b817c467186ea6644886cc79992b75b92add9feb/lib/snort/rule.rb#L53-L68 |
3,556 | wearefine/maximus | lib/maximus/statistics/wraith.rb | Maximus.Wraith.wraith_parse | def wraith_parse(browser)
Dir.glob("#{@config.working_dir}/maximus_wraith_#{browser}/**/*").select { |f| File.file? f }.each do |file|
extension = File.extname(file)
next unless extension == '.png' || extension == '.txt'
orig_label = File.dirname(file).split('/').last
p... | ruby | def wraith_parse(browser)
Dir.glob("#{@config.working_dir}/maximus_wraith_#{browser}/**/*").select { |f| File.file? f }.each do |file|
extension = File.extname(file)
next unless extension == '.png' || extension == '.txt'
orig_label = File.dirname(file).split('/').last
p... | [
"def",
"wraith_parse",
"(",
"browser",
")",
"Dir",
".",
"glob",
"(",
"\"#{@config.working_dir}/maximus_wraith_#{browser}/**/*\"",
")",
".",
"select",
"{",
"|",
"f",
"|",
"File",
".",
"file?",
"f",
"}",
".",
"each",
"do",
"|",
"file",
"|",
"extension",
"=",
... | Get a diff percentage of all changes by label and screensize
@example { :statistics => { "/" => { :browser=>"phantomjs", :name=>"home", :percent_changed=>{ 1024=>2.1, 1280=>1.8, 767=>3.4 } } } }
@param browser [String] headless browser used to generate the gallery
@return [Hash] { path: { browser, path_label, perce... | [
"Get",
"a",
"diff",
"percentage",
"of",
"all",
"changes",
"by",
"label",
"and",
"screensize"
] | d3a6ad1826694c98a5e6a5a3175b78e69aac7945 | https://github.com/wearefine/maximus/blob/d3a6ad1826694c98a5e6a5a3175b78e69aac7945/lib/maximus/statistics/wraith.rb#L47-L72 |
3,557 | wearefine/maximus | lib/maximus/statistics/wraith.rb | Maximus.Wraith.wraith_percentage | def wraith_percentage(file, browser_output)
file_object = File.open(file, 'rb')
browser_output[:percent_changed] ||= {}
browser_output[:percent_changed][File.basename(file).split('_')[0].to_i] = file_object.read.to_f
file_object.close
browser_output
end | ruby | def wraith_percentage(file, browser_output)
file_object = File.open(file, 'rb')
browser_output[:percent_changed] ||= {}
browser_output[:percent_changed][File.basename(file).split('_')[0].to_i] = file_object.read.to_f
file_object.close
browser_output
end | [
"def",
"wraith_percentage",
"(",
"file",
",",
"browser_output",
")",
"file_object",
"=",
"File",
".",
"open",
"(",
"file",
",",
"'rb'",
")",
"browser_output",
"[",
":percent_changed",
"]",
"||=",
"{",
"}",
"browser_output",
"[",
":percent_changed",
"]",
"[",
... | Grab the percentage change from previous snapshots
@since 0.1.5
@param file [String]
@param browser_output [Hash]
@return [Hash] | [
"Grab",
"the",
"percentage",
"change",
"from",
"previous",
"snapshots"
] | d3a6ad1826694c98a5e6a5a3175b78e69aac7945 | https://github.com/wearefine/maximus/blob/d3a6ad1826694c98a5e6a5a3175b78e69aac7945/lib/maximus/statistics/wraith.rb#L79-L87 |
3,558 | souche/aliyun-ons-ruby-sdk | lib/ons/consumer.rb | Ons.Consumer.subscribe | def subscribe(topic, expression, handler = nil)
@consumer.subscribe(topic, expression, handler || Proc.new)
self
end | ruby | def subscribe(topic, expression, handler = nil)
@consumer.subscribe(topic, expression, handler || Proc.new)
self
end | [
"def",
"subscribe",
"(",
"topic",
",",
"expression",
",",
"handler",
"=",
"nil",
")",
"@consumer",
".",
"subscribe",
"(",
"topic",
",",
"expression",
",",
"handler",
"||",
"Proc",
".",
"new",
")",
"self",
"end"
] | Create a new aliyun ONS Consumer instance.
@param access_key [String] the access key to aliyun ONS
@param secret_key [String] the secret key to aliyun ONS
@param consumer_id [String] the consumer ID
@param options [Hash{String, Symbol => String}]
@option options [String] :namesrv_addr the nameserver used to fetch... | [
"Create",
"a",
"new",
"aliyun",
"ONS",
"Consumer",
"instance",
"."
] | 00d16d5fe4dc55929036544a7667c463694f6b1f | https://github.com/souche/aliyun-ons-ruby-sdk/blob/00d16d5fe4dc55929036544a7667c463694f6b1f/lib/ons/consumer.rb#L45-L48 |
3,559 | pwnall/webkit_remote | lib/webkit_remote/rpc.rb | WebkitRemote.Rpc.call | def call(method, params = nil)
request_id = @next_id
@next_id += 1
request = {
jsonrpc: '2.0',
id: request_id,
method: method,
}
request[:params] = params if params
request_json = JSON.dump request
@web_socket.send_frame request_json
loop do
result = receive_mess... | ruby | def call(method, params = nil)
request_id = @next_id
@next_id += 1
request = {
jsonrpc: '2.0',
id: request_id,
method: method,
}
request[:params] = params if params
request_json = JSON.dump request
@web_socket.send_frame request_json
loop do
result = receive_mess... | [
"def",
"call",
"(",
"method",
",",
"params",
"=",
"nil",
")",
"request_id",
"=",
"@next_id",
"@next_id",
"+=",
"1",
"request",
"=",
"{",
"jsonrpc",
":",
"'2.0'",
",",
"id",
":",
"request_id",
",",
"method",
":",
"method",
",",
"}",
"request",
"[",
":... | Connects to the remote debugging server in a Webkit tab.
@param [Hash] opts info on the tab to connect to
@option opts [WebkitRemote::Tab] tab reference to the tab whose debugger
server this RPC client connects to
Remote debugging RPC call.
See the following URL for implemented calls.
https://developers... | [
"Connects",
"to",
"the",
"remote",
"debugging",
"server",
"in",
"a",
"Webkit",
"tab",
"."
] | f38ac7e882726ff00e5c56898d06d91340f8179e | https://github.com/pwnall/webkit_remote/blob/f38ac7e882726ff00e5c56898d06d91340f8179e/lib/webkit_remote/rpc.rb#L34-L50 |
3,560 | pwnall/webkit_remote | lib/webkit_remote/rpc.rb | WebkitRemote.Rpc.receive_message | def receive_message(expected_id)
json = @web_socket.recv_frame
begin
data = JSON.parse json
rescue JSONError
close
raise RuntimeError, 'Invalid JSON received'
end
if data['id']
# RPC result.
if data['id'] != expected_id
close
raise RuntimeError, 'Out of ... | ruby | def receive_message(expected_id)
json = @web_socket.recv_frame
begin
data = JSON.parse json
rescue JSONError
close
raise RuntimeError, 'Invalid JSON received'
end
if data['id']
# RPC result.
if data['id'] != expected_id
close
raise RuntimeError, 'Out of ... | [
"def",
"receive_message",
"(",
"expected_id",
")",
"json",
"=",
"@web_socket",
".",
"recv_frame",
"begin",
"data",
"=",
"JSON",
".",
"parse",
"json",
"rescue",
"JSONError",
"close",
"raise",
"RuntimeError",
",",
"'Invalid JSON received'",
"end",
"if",
"data",
"[... | Blocks until a WebKit message is received, then parses it.
RPC notifications are added to the @events array.
@param [Integer, nil] expected_id if a RPC response is expected, this
argument has the response id; otherwise, the argument should be nil
@return [Hash<String, Object>, nil] a Hash containing the RPC r... | [
"Blocks",
"until",
"a",
"WebKit",
"message",
"is",
"received",
"then",
"parses",
"it",
"."
] | f38ac7e882726ff00e5c56898d06d91340f8179e | https://github.com/pwnall/webkit_remote/blob/f38ac7e882726ff00e5c56898d06d91340f8179e/lib/webkit_remote/rpc.rb#L99-L128 |
3,561 | ImpressCMS/vagrant-impressbox | lib/vagrant-impressbox/command.rb | Impressbox.Command.selected_yaml_file | def selected_yaml_file
p = current_impressbox_provisioner
if p.nil? || p.config.nil? || p.config.file.nil? ||
!(p.config.file.is_a?(String) && p.config.file.chop.length > 0)
return 'config.yaml'
end
p.config.file
end | ruby | def selected_yaml_file
p = current_impressbox_provisioner
if p.nil? || p.config.nil? || p.config.file.nil? ||
!(p.config.file.is_a?(String) && p.config.file.chop.length > 0)
return 'config.yaml'
end
p.config.file
end | [
"def",
"selected_yaml_file",
"p",
"=",
"current_impressbox_provisioner",
"if",
"p",
".",
"nil?",
"||",
"p",
".",
"config",
".",
"nil?",
"||",
"p",
".",
"config",
".",
"file",
".",
"nil?",
"||",
"!",
"(",
"p",
".",
"config",
".",
"file",
".",
"is_a?",
... | Gets yaml file from current vagrantfile
@return [String] | [
"Gets",
"yaml",
"file",
"from",
"current",
"vagrantfile"
] | 78dcd119a15ea6fbfd1f28c1e78f1cbf371bc6a2 | https://github.com/ImpressCMS/vagrant-impressbox/blob/78dcd119a15ea6fbfd1f28c1e78f1cbf371bc6a2/lib/vagrant-impressbox/command.rb#L73-L80 |
3,562 | ImpressCMS/vagrant-impressbox | lib/vagrant-impressbox/command.rb | Impressbox.Command.current_impressbox_provisioner | def current_impressbox_provisioner
@env.vagrantfile.config.vm.provisioners.each do |provisioner|
next unless provisioner.type == :impressbox
return provisioner
end
nil
end | ruby | def current_impressbox_provisioner
@env.vagrantfile.config.vm.provisioners.each do |provisioner|
next unless provisioner.type == :impressbox
return provisioner
end
nil
end | [
"def",
"current_impressbox_provisioner",
"@env",
".",
"vagrantfile",
".",
"config",
".",
"vm",
".",
"provisioners",
".",
"each",
"do",
"|",
"provisioner",
"|",
"next",
"unless",
"provisioner",
".",
"type",
"==",
":impressbox",
"return",
"provisioner",
"end",
"ni... | Gets current provisioner with impressbox type
@return [::VagrantPlugins::Kernel_V2::VagrantConfigProvisioner,nil] | [
"Gets",
"current",
"provisioner",
"with",
"impressbox",
"type"
] | 78dcd119a15ea6fbfd1f28c1e78f1cbf371bc6a2 | https://github.com/ImpressCMS/vagrant-impressbox/blob/78dcd119a15ea6fbfd1f28c1e78f1cbf371bc6a2/lib/vagrant-impressbox/command.rb#L85-L91 |
3,563 | ImpressCMS/vagrant-impressbox | lib/vagrant-impressbox/command.rb | Impressbox.Command.update_name | def update_name(options)
if options.key?(:name) && options[:name].is_a?(String) && options[:name].length > 0
return
end
hostname = if options.key?(:hostname) then
options[:hostname]
else
@args.default_values[:hostname]
end... | ruby | def update_name(options)
if options.key?(:name) && options[:name].is_a?(String) && options[:name].length > 0
return
end
hostname = if options.key?(:hostname) then
options[:hostname]
else
@args.default_values[:hostname]
end... | [
"def",
"update_name",
"(",
"options",
")",
"if",
"options",
".",
"key?",
"(",
":name",
")",
"&&",
"options",
"[",
":name",
"]",
".",
"is_a?",
"(",
"String",
")",
"&&",
"options",
"[",
":name",
"]",
".",
"length",
">",
"0",
"return",
"end",
"hostname"... | Updates name param in options hash
@param options [Hash] Input/output hash | [
"Updates",
"name",
"param",
"in",
"options",
"hash"
] | 78dcd119a15ea6fbfd1f28c1e78f1cbf371bc6a2 | https://github.com/ImpressCMS/vagrant-impressbox/blob/78dcd119a15ea6fbfd1f28c1e78f1cbf371bc6a2/lib/vagrant-impressbox/command.rb#L108-L119 |
3,564 | ImpressCMS/vagrant-impressbox | lib/vagrant-impressbox/command.rb | Impressbox.Command.write_result_msg | def write_result_msg(result)
msg = if result then
I18n.t 'config.recreated'
else
I18n.t 'config.updated'
end
@env.ui.info msg
end | ruby | def write_result_msg(result)
msg = if result then
I18n.t 'config.recreated'
else
I18n.t 'config.updated'
end
@env.ui.info msg
end | [
"def",
"write_result_msg",
"(",
"result",
")",
"msg",
"=",
"if",
"result",
"then",
"I18n",
".",
"t",
"'config.recreated'",
"else",
"I18n",
".",
"t",
"'config.updated'",
"end",
"@env",
".",
"ui",
".",
"info",
"msg",
"end"
] | Writes message for action result
@param result [Boolean] | [
"Writes",
"message",
"for",
"action",
"result"
] | 78dcd119a15ea6fbfd1f28c1e78f1cbf371bc6a2 | https://github.com/ImpressCMS/vagrant-impressbox/blob/78dcd119a15ea6fbfd1f28c1e78f1cbf371bc6a2/lib/vagrant-impressbox/command.rb#L124-L131 |
3,565 | ImpressCMS/vagrant-impressbox | lib/vagrant-impressbox/command.rb | Impressbox.Command.quick_make_file | def quick_make_file(local_file, tpl_file)
current_file = local_file(local_file)
template_file = @template.real_path(tpl_file)
@template.make_file(
template_file,
current_file,
@args.all.dup,
make_data_files_array(current_file),
method(:update_latest_options)
... | ruby | def quick_make_file(local_file, tpl_file)
current_file = local_file(local_file)
template_file = @template.real_path(tpl_file)
@template.make_file(
template_file,
current_file,
@args.all.dup,
make_data_files_array(current_file),
method(:update_latest_options)
... | [
"def",
"quick_make_file",
"(",
"local_file",
",",
"tpl_file",
")",
"current_file",
"=",
"local_file",
"(",
"local_file",
")",
"template_file",
"=",
"@template",
".",
"real_path",
"(",
"tpl_file",
")",
"@template",
".",
"make_file",
"(",
"template_file",
",",
"cu... | Renders and safes file
@param local_file [String] Local filename
@param tpl_file [String] Template filename | [
"Renders",
"and",
"safes",
"file"
] | 78dcd119a15ea6fbfd1f28c1e78f1cbf371bc6a2 | https://github.com/ImpressCMS/vagrant-impressbox/blob/78dcd119a15ea6fbfd1f28c1e78f1cbf371bc6a2/lib/vagrant-impressbox/command.rb#L144-L154 |
3,566 | ImpressCMS/vagrant-impressbox | lib/vagrant-impressbox/command.rb | Impressbox.Command.make_data_files_array | def make_data_files_array(current_file)
data_files = [
ConfigData.real_path('default.yml')
]
unless use_template_filename.nil?
data_files.push use_template_filename
end
unless must_recreate
data_files.push current_file
end
data_files
end | ruby | def make_data_files_array(current_file)
data_files = [
ConfigData.real_path('default.yml')
]
unless use_template_filename.nil?
data_files.push use_template_filename
end
unless must_recreate
data_files.push current_file
end
data_files
end | [
"def",
"make_data_files_array",
"(",
"current_file",
")",
"data_files",
"=",
"[",
"ConfigData",
".",
"real_path",
"(",
"'default.yml'",
")",
"]",
"unless",
"use_template_filename",
".",
"nil?",
"data_files",
".",
"push",
"use_template_filename",
"end",
"unless",
"mu... | Makes data files array
@param current_file [String] Current file name
@return [Array] | [
"Makes",
"data",
"files",
"array"
] | 78dcd119a15ea6fbfd1f28c1e78f1cbf371bc6a2 | https://github.com/ImpressCMS/vagrant-impressbox/blob/78dcd119a15ea6fbfd1f28c1e78f1cbf371bc6a2/lib/vagrant-impressbox/command.rb#L161-L172 |
3,567 | 9kSoftware/plaid_rails | app/controllers/plaid_rails/accounts_controller.rb | PlaidRails.AccountsController.new | def new
client = Plaid::Client.new(env: PlaidRails.env,
client_id: PlaidRails.client_id,
secret: PlaidRails.secret,
public_key: PlaidRails.public_key)
response = client.accounts.get(account_params["access_token"])
@plaid_accounts = response.accounts
end | ruby | def new
client = Plaid::Client.new(env: PlaidRails.env,
client_id: PlaidRails.client_id,
secret: PlaidRails.secret,
public_key: PlaidRails.public_key)
response = client.accounts.get(account_params["access_token"])
@plaid_accounts = response.accounts
end | [
"def",
"new",
"client",
"=",
"Plaid",
"::",
"Client",
".",
"new",
"(",
"env",
":",
"PlaidRails",
".",
"env",
",",
"client_id",
":",
"PlaidRails",
".",
"client_id",
",",
"secret",
":",
"PlaidRails",
".",
"secret",
",",
"public_key",
":",
"PlaidRails",
"."... | display list of accounts for authenticated user | [
"display",
"list",
"of",
"accounts",
"for",
"authenticated",
"user"
] | abad75600c26c20a29d5fa3df80d52487a4e72cc | https://github.com/9kSoftware/plaid_rails/blob/abad75600c26c20a29d5fa3df80d52487a4e72cc/app/controllers/plaid_rails/accounts_controller.rb#L11-L20 |
3,568 | hoanganhhanoi/dhcp_parser | lib/dhcp_parser.rb | DHCPParser.Conf.subnets | def subnets
subnet = []
index = 0
while index < @datas.count
index += 1
subnet << DHCPParser::Conf.get_subnet(@datas["net#{index}"])
end
return subnet
end | ruby | def subnets
subnet = []
index = 0
while index < @datas.count
index += 1
subnet << DHCPParser::Conf.get_subnet(@datas["net#{index}"])
end
return subnet
end | [
"def",
"subnets",
"subnet",
"=",
"[",
"]",
"index",
"=",
"0",
"while",
"index",
"<",
"@datas",
".",
"count",
"index",
"+=",
"1",
"subnet",
"<<",
"DHCPParser",
"::",
"Conf",
".",
"get_subnet",
"(",
"@datas",
"[",
"\"net#{index}\"",
"]",
")",
"end",
"ret... | Get list subnet | [
"Get",
"list",
"subnet"
] | baa59aab7b519117c162d323104fb6e56d7fd4fc | https://github.com/hoanganhhanoi/dhcp_parser/blob/baa59aab7b519117c162d323104fb6e56d7fd4fc/lib/dhcp_parser.rb#L254-L262 |
3,569 | hoanganhhanoi/dhcp_parser | lib/dhcp_parser.rb | DHCPParser.Conf.netmasks | def netmasks
netmask = []
index = 0
while index < @datas.count
index += 1
netmask << DHCPParser::Conf.get_netmask(@datas["net#{index}"])
end
return netmask
end | ruby | def netmasks
netmask = []
index = 0
while index < @datas.count
index += 1
netmask << DHCPParser::Conf.get_netmask(@datas["net#{index}"])
end
return netmask
end | [
"def",
"netmasks",
"netmask",
"=",
"[",
"]",
"index",
"=",
"0",
"while",
"index",
"<",
"@datas",
".",
"count",
"index",
"+=",
"1",
"netmask",
"<<",
"DHCPParser",
"::",
"Conf",
".",
"get_netmask",
"(",
"@datas",
"[",
"\"net#{index}\"",
"]",
")",
"end",
... | Get list netmask | [
"Get",
"list",
"netmask"
] | baa59aab7b519117c162d323104fb6e56d7fd4fc | https://github.com/hoanganhhanoi/dhcp_parser/blob/baa59aab7b519117c162d323104fb6e56d7fd4fc/lib/dhcp_parser.rb#L265-L273 |
3,570 | hoanganhhanoi/dhcp_parser | lib/dhcp_parser.rb | DHCPParser.Conf.options | def options
option = []
index = 0
while index < @datas.count
index += 1
option << DHCPParser::Conf.get_list_option(@datas["net#{index}"])
end
return option
end | ruby | def options
option = []
index = 0
while index < @datas.count
index += 1
option << DHCPParser::Conf.get_list_option(@datas["net#{index}"])
end
return option
end | [
"def",
"options",
"option",
"=",
"[",
"]",
"index",
"=",
"0",
"while",
"index",
"<",
"@datas",
".",
"count",
"index",
"+=",
"1",
"option",
"<<",
"DHCPParser",
"::",
"Conf",
".",
"get_list_option",
"(",
"@datas",
"[",
"\"net#{index}\"",
"]",
")",
"end",
... | Get list option | [
"Get",
"list",
"option"
] | baa59aab7b519117c162d323104fb6e56d7fd4fc | https://github.com/hoanganhhanoi/dhcp_parser/blob/baa59aab7b519117c162d323104fb6e56d7fd4fc/lib/dhcp_parser.rb#L276-L284 |
3,571 | hoanganhhanoi/dhcp_parser | lib/dhcp_parser.rb | DHCPParser.Conf.authoritative | def authoritative
authori = []
index = 0
while index < @datas.count
index += 1
authori << DHCPParser::Conf.get_authoritative(@datas["net#{index}"])
end
return authori
end | ruby | def authoritative
authori = []
index = 0
while index < @datas.count
index += 1
authori << DHCPParser::Conf.get_authoritative(@datas["net#{index}"])
end
return authori
end | [
"def",
"authoritative",
"authori",
"=",
"[",
"]",
"index",
"=",
"0",
"while",
"index",
"<",
"@datas",
".",
"count",
"index",
"+=",
"1",
"authori",
"<<",
"DHCPParser",
"::",
"Conf",
".",
"get_authoritative",
"(",
"@datas",
"[",
"\"net#{index}\"",
"]",
")",
... | Get value authoritative | [
"Get",
"value",
"authoritative"
] | baa59aab7b519117c162d323104fb6e56d7fd4fc | https://github.com/hoanganhhanoi/dhcp_parser/blob/baa59aab7b519117c162d323104fb6e56d7fd4fc/lib/dhcp_parser.rb#L287-L295 |
3,572 | hoanganhhanoi/dhcp_parser | lib/dhcp_parser.rb | DHCPParser.Conf.net | def net
i = 0
while i < @datas.count
i += 1
new_net = Net.new
new_net.subnet = DHCPParser::Conf.get_subnet(@datas["net#{i}"])
new_net.netmask = DHCPParser::Conf.get_netmask(@datas["net#{i}"])
list_option = DHCPParser::Conf.get_list_option(@datas["net#{i}"], true)
... | ruby | def net
i = 0
while i < @datas.count
i += 1
new_net = Net.new
new_net.subnet = DHCPParser::Conf.get_subnet(@datas["net#{i}"])
new_net.netmask = DHCPParser::Conf.get_netmask(@datas["net#{i}"])
list_option = DHCPParser::Conf.get_list_option(@datas["net#{i}"], true)
... | [
"def",
"net",
"i",
"=",
"0",
"while",
"i",
"<",
"@datas",
".",
"count",
"i",
"+=",
"1",
"new_net",
"=",
"Net",
".",
"new",
"new_net",
".",
"subnet",
"=",
"DHCPParser",
"::",
"Conf",
".",
"get_subnet",
"(",
"@datas",
"[",
"\"net#{i}\"",
"]",
")",
"n... | Set data in object | [
"Set",
"data",
"in",
"object"
] | baa59aab7b519117c162d323104fb6e56d7fd4fc | https://github.com/hoanganhhanoi/dhcp_parser/blob/baa59aab7b519117c162d323104fb6e56d7fd4fc/lib/dhcp_parser.rb#L361-L391 |
3,573 | printercu/rails_stuff | lib/rails_stuff/resources_controller.rb | RailsStuff.ResourcesController.resources_controller | def resources_controller(**options)
ResourcesController.inject(self, **options)
self.after_save_action = options[:after_save_action] || after_save_action
resource_belongs_to(*options[:belongs_to]) if options[:belongs_to]
if options[:source_relation]
protected define_method(:source_rela... | ruby | def resources_controller(**options)
ResourcesController.inject(self, **options)
self.after_save_action = options[:after_save_action] || after_save_action
resource_belongs_to(*options[:belongs_to]) if options[:belongs_to]
if options[:source_relation]
protected define_method(:source_rela... | [
"def",
"resources_controller",
"(",
"**",
"options",
")",
"ResourcesController",
".",
"inject",
"(",
"self",
",",
"**",
"options",
")",
"self",
".",
"after_save_action",
"=",
"options",
"[",
":after_save_action",
"]",
"||",
"after_save_action",
"resource_belongs_to"... | Setups basic actions and helpers in resources controller.
#### Options
- `sti` - include STI helpers
- `kaminari` - include Kaminari helpers
- `after_save_action` - action to use for `after_save_url`
- `source_relation` - override `source_relation` | [
"Setups",
"basic",
"actions",
"and",
"helpers",
"in",
"resources",
"controller",
"."
] | b3d72daaae6426c8166205f6a7438a89768e8347 | https://github.com/printercu/rails_stuff/blob/b3d72daaae6426c8166205f6a7438a89768e8347/lib/rails_stuff/resources_controller.rb#L41-L50 |
3,574 | stevenchanin/strava-api | lib/strava-api/segments.rb | StravaApi.Segments.segments | def segments(name)
result = call("segments", "segments", {:name => name})
result["segments"].collect {|item| Segment.new(self, item)}
end | ruby | def segments(name)
result = call("segments", "segments", {:name => name})
result["segments"].collect {|item| Segment.new(self, item)}
end | [
"def",
"segments",
"(",
"name",
")",
"result",
"=",
"call",
"(",
"\"segments\"",
",",
"\"segments\"",
",",
"{",
":name",
"=>",
"name",
"}",
")",
"result",
"[",
"\"segments\"",
"]",
".",
"collect",
"{",
"|",
"item",
"|",
"Segment",
".",
"new",
"(",
"s... | returns all segments, don't need an offset | [
"returns",
"all",
"segments",
"don",
"t",
"need",
"an",
"offset"
] | a185fee415d606357a462fbeb5cc8de9f6130cdf | https://github.com/stevenchanin/strava-api/blob/a185fee415d606357a462fbeb5cc8de9f6130cdf/lib/strava-api/segments.rb#L4-L8 |
3,575 | blambeau/rack-robustness | lib/rack/robustness.rb | Rack.Robustness.call | def call(env)
dup.call!(env)
rescue => ex
catch_all ? last_resort(ex) : raise(ex)
end | ruby | def call(env)
dup.call!(env)
rescue => ex
catch_all ? last_resort(ex) : raise(ex)
end | [
"def",
"call",
"(",
"env",
")",
"dup",
".",
"call!",
"(",
"env",
")",
"rescue",
"=>",
"ex",
"catch_all",
"?",
"last_resort",
"(",
"ex",
")",
":",
"raise",
"(",
"ex",
")",
"end"
] | Rack's call | [
"Rack",
"s",
"call"
] | c0b9e4fdbb882f786a9306279e73c27761683868 | https://github.com/blambeau/rack-robustness/blob/c0b9e4fdbb882f786a9306279e73c27761683868/lib/rack/robustness.rb#L94-L98 |
3,576 | freayd/osrm | lib/osrm/configuration.rb | OSRM.Configuration.ensure_cache_version | def ensure_cache_version
return unless cache
cache_version = cache[cache_key('version')]
minimum_version = '0.4.0'
if cache_version &&
Gem::Version.new(cache_version) < Gem::Version.new(minimum_version)
@data[:cache] = nil
raise "OSRM API error: Incompatible cache versi... | ruby | def ensure_cache_version
return unless cache
cache_version = cache[cache_key('version')]
minimum_version = '0.4.0'
if cache_version &&
Gem::Version.new(cache_version) < Gem::Version.new(minimum_version)
@data[:cache] = nil
raise "OSRM API error: Incompatible cache versi... | [
"def",
"ensure_cache_version",
"return",
"unless",
"cache",
"cache_version",
"=",
"cache",
"[",
"cache_key",
"(",
"'version'",
")",
"]",
"minimum_version",
"=",
"'0.4.0'",
"if",
"cache_version",
"&&",
"Gem",
"::",
"Version",
".",
"new",
"(",
"cache_version",
")"... | Raise an exception if the cache isn't compatible with the current library version | [
"Raise",
"an",
"exception",
"if",
"the",
"cache",
"isn",
"t",
"compatible",
"with",
"the",
"current",
"library",
"version"
] | 607595db144c62518b083e3ad234b0b916feb3fc | https://github.com/freayd/osrm/blob/607595db144c62518b083e3ad234b0b916feb3fc/lib/osrm/configuration.rb#L105-L116 |
3,577 | cblavier/jobbr | app/models/jobbr/job.rb | Jobbr.Job.cap_runs! | def cap_runs!
runs_count = self.runs.count
if runs_count > max_run_per_job
runs.sort_by(:started_at, order: 'ALPHA ASC', limit: [0, runs_count - max_run_per_job]).each do |run|
if run.status == :failed || run.status == :success
run.delete
end
end
end
... | ruby | def cap_runs!
runs_count = self.runs.count
if runs_count > max_run_per_job
runs.sort_by(:started_at, order: 'ALPHA ASC', limit: [0, runs_count - max_run_per_job]).each do |run|
if run.status == :failed || run.status == :success
run.delete
end
end
end
... | [
"def",
"cap_runs!",
"runs_count",
"=",
"self",
".",
"runs",
".",
"count",
"if",
"runs_count",
">",
"max_run_per_job",
"runs",
".",
"sort_by",
"(",
":started_at",
",",
"order",
":",
"'ALPHA ASC'",
",",
"limit",
":",
"[",
"0",
",",
"runs_count",
"-",
"max_ru... | prevents Run collection to grow beyond max_run_per_job | [
"prevents",
"Run",
"collection",
"to",
"grow",
"beyond",
"max_run_per_job"
] | 2fbfa14f5fe1b942e69333e34ea0a086ad052b38 | https://github.com/cblavier/jobbr/blob/2fbfa14f5fe1b942e69333e34ea0a086ad052b38/app/models/jobbr/job.rb#L156-L165 |
3,578 | pwnall/webkit_remote | lib/webkit_remote/browser.rb | WebkitRemote.Browser.tabs | def tabs
http_response = @http.request Net::HTTP::Get.new('/json')
tabs = JSON.parse(http_response.body).map do |json_tab|
title = json_tab['title']
url = json_tab['url']
debug_url = json_tab['webSocketDebuggerUrl']
Tab.new self, debug_url, title: title, url: url
end
# HACK(pwnal... | ruby | def tabs
http_response = @http.request Net::HTTP::Get.new('/json')
tabs = JSON.parse(http_response.body).map do |json_tab|
title = json_tab['title']
url = json_tab['url']
debug_url = json_tab['webSocketDebuggerUrl']
Tab.new self, debug_url, title: title, url: url
end
# HACK(pwnal... | [
"def",
"tabs",
"http_response",
"=",
"@http",
".",
"request",
"Net",
"::",
"HTTP",
"::",
"Get",
".",
"new",
"(",
"'/json'",
")",
"tabs",
"=",
"JSON",
".",
"parse",
"(",
"http_response",
".",
"body",
")",
".",
"map",
"do",
"|",
"json_tab",
"|",
"title... | Retrieves the tabs that are currently open in the browser.
These tabs can be used to start debugging.
@return [Array<WebkitRemote::Browser::Tab>] the open tabs | [
"Retrieves",
"the",
"tabs",
"that",
"are",
"currently",
"open",
"in",
"the",
"browser",
"."
] | f38ac7e882726ff00e5c56898d06d91340f8179e | https://github.com/pwnall/webkit_remote/blob/f38ac7e882726ff00e5c56898d06d91340f8179e/lib/webkit_remote/browser.rb#L61-L73 |
3,579 | stevenchanin/strava-api | lib/strava-api/clubs.rb | StravaApi.Clubs.clubs | def clubs(name)
raise StravaApi::CommandError if name.blank?
name = name.strip
raise StravaApi::CommandError if name.empty?
result = call("clubs", "clubs", {:name => name})
result["clubs"].collect {|item| Club.new(self, item)}
end | ruby | def clubs(name)
raise StravaApi::CommandError if name.blank?
name = name.strip
raise StravaApi::CommandError if name.empty?
result = call("clubs", "clubs", {:name => name})
result["clubs"].collect {|item| Club.new(self, item)}
end | [
"def",
"clubs",
"(",
"name",
")",
"raise",
"StravaApi",
"::",
"CommandError",
"if",
"name",
".",
"blank?",
"name",
"=",
"name",
".",
"strip",
"raise",
"StravaApi",
"::",
"CommandError",
"if",
"name",
".",
"empty?",
"result",
"=",
"call",
"(",
"\"clubs\"",
... | returns all clubs, don't need an offset | [
"returns",
"all",
"clubs",
"don",
"t",
"need",
"an",
"offset"
] | a185fee415d606357a462fbeb5cc8de9f6130cdf | https://github.com/stevenchanin/strava-api/blob/a185fee415d606357a462fbeb5cc8de9f6130cdf/lib/strava-api/clubs.rb#L4-L13 |
3,580 | stevenchanin/strava-api | lib/strava-api/clubs.rb | StravaApi.Clubs.club_members | def club_members(id)
result = call("clubs/#{id}/members", "members", {})
result["members"].collect {|item| Member.new(self, item)}
end | ruby | def club_members(id)
result = call("clubs/#{id}/members", "members", {})
result["members"].collect {|item| Member.new(self, item)}
end | [
"def",
"club_members",
"(",
"id",
")",
"result",
"=",
"call",
"(",
"\"clubs/#{id}/members\"",
",",
"\"members\"",
",",
"{",
"}",
")",
"result",
"[",
"\"members\"",
"]",
".",
"collect",
"{",
"|",
"item",
"|",
"Member",
".",
"new",
"(",
"self",
",",
"ite... | returns all members, don't need an offset | [
"returns",
"all",
"members",
"don",
"t",
"need",
"an",
"offset"
] | a185fee415d606357a462fbeb5cc8de9f6130cdf | https://github.com/stevenchanin/strava-api/blob/a185fee415d606357a462fbeb5cc8de9f6130cdf/lib/strava-api/clubs.rb#L22-L26 |
3,581 | printercu/rails_stuff | lib/rails_stuff/params_parser.rb | RailsStuff.ParamsParser.parse | def parse(val, *args, &block)
parse_not_blank(val, *args, &block)
rescue => e # rubocop:disable Lint/RescueWithoutErrorClass
raise Error.new(e.message, val), nil, e.backtrace
end | ruby | def parse(val, *args, &block)
parse_not_blank(val, *args, &block)
rescue => e # rubocop:disable Lint/RescueWithoutErrorClass
raise Error.new(e.message, val), nil, e.backtrace
end | [
"def",
"parse",
"(",
"val",
",",
"*",
"args",
",",
"&",
"block",
")",
"parse_not_blank",
"(",
"val",
",",
"args",
",",
"block",
")",
"rescue",
"=>",
"e",
"# rubocop:disable Lint/RescueWithoutErrorClass",
"raise",
"Error",
".",
"new",
"(",
"e",
".",
"messag... | Parses value with specified block. Reraises occured error with Error. | [
"Parses",
"value",
"with",
"specified",
"block",
".",
"Reraises",
"occured",
"error",
"with",
"Error",
"."
] | b3d72daaae6426c8166205f6a7438a89768e8347 | https://github.com/printercu/rails_stuff/blob/b3d72daaae6426c8166205f6a7438a89768e8347/lib/rails_stuff/params_parser.rb#L47-L51 |
3,582 | printercu/rails_stuff | lib/rails_stuff/params_parser.rb | RailsStuff.ParamsParser.parse_array | def parse_array(array, *args, &block)
return unless array.is_a?(Array)
parse(array) { array.map { |val| parse_not_blank(val, *args, &block) } }
end | ruby | def parse_array(array, *args, &block)
return unless array.is_a?(Array)
parse(array) { array.map { |val| parse_not_blank(val, *args, &block) } }
end | [
"def",
"parse_array",
"(",
"array",
",",
"*",
"args",
",",
"&",
"block",
")",
"return",
"unless",
"array",
".",
"is_a?",
"(",
"Array",
")",
"parse",
"(",
"array",
")",
"{",
"array",
".",
"map",
"{",
"|",
"val",
"|",
"parse_not_blank",
"(",
"val",
"... | Parses each value in array with specified block.
Returns `nil` if `val` is not an array. | [
"Parses",
"each",
"value",
"in",
"array",
"with",
"specified",
"block",
".",
"Returns",
"nil",
"if",
"val",
"is",
"not",
"an",
"array",
"."
] | b3d72daaae6426c8166205f6a7438a89768e8347 | https://github.com/printercu/rails_stuff/blob/b3d72daaae6426c8166205f6a7438a89768e8347/lib/rails_stuff/params_parser.rb#L55-L58 |
3,583 | dadooda/rails_dt | lib/dt/instance.rb | DT.Instance.rails_logger | def rails_logger
if instance_variable_defined?(k = :@rails_logger)
instance_variable_get(k)
else
instance_variable_set(k, conf.rails && conf.rails.logger)
end
end | ruby | def rails_logger
if instance_variable_defined?(k = :@rails_logger)
instance_variable_get(k)
else
instance_variable_set(k, conf.rails && conf.rails.logger)
end
end | [
"def",
"rails_logger",
"if",
"instance_variable_defined?",
"(",
"k",
"=",
":@rails_logger",
")",
"instance_variable_get",
"(",
"k",
")",
"else",
"instance_variable_set",
"(",
"k",
",",
"conf",
".",
"rails",
"&&",
"conf",
".",
"rails",
".",
"logger",
")",
"end"... | An object to use as log in Rails mode.
@return [ActiveSupport::Logger] Default is <tt>conf.rails.logger</tt>. | [
"An",
"object",
"to",
"use",
"as",
"log",
"in",
"Rails",
"mode",
"."
] | a421b678b0041ef7c2af62f516b71df77403bf2b | https://github.com/dadooda/rails_dt/blob/a421b678b0041ef7c2af62f516b71df77403bf2b/lib/dt/instance.rb#L51-L57 |
3,584 | printercu/rails_stuff | lib/rails_stuff/require_nested.rb | RailsStuff.RequireNested.require_nested | def require_nested(dir = 0)
dir = caller_locations(dir + 1, 1)[0].path.sub(/\.rb$/, '') if dir.is_a?(Integer)
Dir["#{dir}/*.rb"].each { |file| require_dependency file }
end | ruby | def require_nested(dir = 0)
dir = caller_locations(dir + 1, 1)[0].path.sub(/\.rb$/, '') if dir.is_a?(Integer)
Dir["#{dir}/*.rb"].each { |file| require_dependency file }
end | [
"def",
"require_nested",
"(",
"dir",
"=",
"0",
")",
"dir",
"=",
"caller_locations",
"(",
"dir",
"+",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"path",
".",
"sub",
"(",
"/",
"\\.",
"/",
",",
"''",
")",
"if",
"dir",
".",
"is_a?",
"(",
"Integer",
... | Requires nested modules with `require_dependency`.
Pass custom directory to require its content.
By default uses caller's filename with stripped `.rb` extension from. | [
"Requires",
"nested",
"modules",
"with",
"require_dependency",
".",
"Pass",
"custom",
"directory",
"to",
"require",
"its",
"content",
".",
"By",
"default",
"uses",
"caller",
"s",
"filename",
"with",
"stripped",
".",
"rb",
"extension",
"from",
"."
] | b3d72daaae6426c8166205f6a7438a89768e8347 | https://github.com/printercu/rails_stuff/blob/b3d72daaae6426c8166205f6a7438a89768e8347/lib/rails_stuff/require_nested.rb#L17-L20 |
3,585 | stevenchanin/strava-api | lib/strava-api/rides.rb | StravaApi.Rides.ride_efforts | def ride_efforts(id)
result = call("rides/#{id}/efforts", "efforts", {})
result["efforts"].collect {|effort| Effort.new(self, effort)}
end | ruby | def ride_efforts(id)
result = call("rides/#{id}/efforts", "efforts", {})
result["efforts"].collect {|effort| Effort.new(self, effort)}
end | [
"def",
"ride_efforts",
"(",
"id",
")",
"result",
"=",
"call",
"(",
"\"rides/#{id}/efforts\"",
",",
"\"efforts\"",
",",
"{",
"}",
")",
"result",
"[",
"\"efforts\"",
"]",
".",
"collect",
"{",
"|",
"effort",
"|",
"Effort",
".",
"new",
"(",
"self",
",",
"e... | returns all efforts, don't need an offset | [
"returns",
"all",
"efforts",
"don",
"t",
"need",
"an",
"offset"
] | a185fee415d606357a462fbeb5cc8de9f6130cdf | https://github.com/stevenchanin/strava-api/blob/a185fee415d606357a462fbeb5cc8de9f6130cdf/lib/strava-api/rides.rb#L33-L37 |
3,586 | blackwinter/wadl | lib/wadl/xml_representation.rb | WADL.XMLRepresentation.each_by_param | def each_by_param(param_name)
REXML::XPath.each(self, lookup_param(param_name).path) { |e| yield e }
end | ruby | def each_by_param(param_name)
REXML::XPath.each(self, lookup_param(param_name).path) { |e| yield e }
end | [
"def",
"each_by_param",
"(",
"param_name",
")",
"REXML",
"::",
"XPath",
".",
"each",
"(",
"self",
",",
"lookup_param",
"(",
"param_name",
")",
".",
"path",
")",
"{",
"|",
"e",
"|",
"yield",
"e",
"}",
"end"
] | Yields up each XML element for the given Param object. | [
"Yields",
"up",
"each",
"XML",
"element",
"for",
"the",
"given",
"Param",
"object",
"."
] | 0e99d512f8b8627cb5e13a9e793d89c6af32066e | https://github.com/blackwinter/wadl/blob/0e99d512f8b8627cb5e13a9e793d89c6af32066e/lib/wadl/xml_representation.rb#L52-L54 |
3,587 | blackwinter/wadl | lib/wadl/param.rb | WADL.Param.format | def format(value, name = nil, style = nil)
name ||= self.name
style ||= self.style
value = fixed if fixed
value ||= default if default
unless value
if required?
raise ArgumentError, %Q{No value provided for required param "#{name}"!}
else
return '' # ... | ruby | def format(value, name = nil, style = nil)
name ||= self.name
style ||= self.style
value = fixed if fixed
value ||= default if default
unless value
if required?
raise ArgumentError, %Q{No value provided for required param "#{name}"!}
else
return '' # ... | [
"def",
"format",
"(",
"value",
",",
"name",
"=",
"nil",
",",
"style",
"=",
"nil",
")",
"name",
"||=",
"self",
".",
"name",
"style",
"||=",
"self",
".",
"style",
"value",
"=",
"fixed",
"if",
"fixed",
"value",
"||=",
"default",
"if",
"default",
"unless... | Validates and formats a proposed value for this parameter. Returns
the formatted value. Raises an ArgumentError if the value
is invalid.
The 'name' and 'style' arguments are used in conjunction with the
default Param object. | [
"Validates",
"and",
"formats",
"a",
"proposed",
"value",
"for",
"this",
"parameter",
".",
"Returns",
"the",
"formatted",
"value",
".",
"Raises",
"an",
"ArgumentError",
"if",
"the",
"value",
"is",
"invalid",
"."
] | 0e99d512f8b8627cb5e13a9e793d89c6af32066e | https://github.com/blackwinter/wadl/blob/0e99d512f8b8627cb5e13a9e793d89c6af32066e/lib/wadl/param.rb#L76-L128 |
3,588 | 9kSoftware/plaid_rails | app/models/plaid_rails/account.rb | PlaidRails.Account.delete_updated_token | def delete_updated_token
# change all matching tokens on update
accounts = PlaidRails::Account.where(access_token: my_token)
if accounts.size > 0
delete_connect
end
end | ruby | def delete_updated_token
# change all matching tokens on update
accounts = PlaidRails::Account.where(access_token: my_token)
if accounts.size > 0
delete_connect
end
end | [
"def",
"delete_updated_token",
"# change all matching tokens on update",
"accounts",
"=",
"PlaidRails",
"::",
"Account",
".",
"where",
"(",
"access_token",
":",
"my_token",
")",
"if",
"accounts",
".",
"size",
">",
"0",
"delete_connect",
"end",
"end"
] | delete token from Plaid if there are no more accounts for this token | [
"delete",
"token",
"from",
"Plaid",
"if",
"there",
"are",
"no",
"more",
"accounts",
"for",
"this",
"token"
] | abad75600c26c20a29d5fa3df80d52487a4e72cc | https://github.com/9kSoftware/plaid_rails/blob/abad75600c26c20a29d5fa3df80d52487a4e72cc/app/models/plaid_rails/account.rb#L15-L21 |
3,589 | 9kSoftware/plaid_rails | app/models/plaid_rails/account.rb | PlaidRails.Account.delete_connect | def delete_connect
begin
Rails.logger.info "Deleting Plaid User with token #{token_last_8}"
client = Plaid::Client.new(env: PlaidRails.env,
client_id: PlaidRails.client_id,
secret: PlaidRails.secret,
public_key: PlaidRails.public_key)
client.item.re... | ruby | def delete_connect
begin
Rails.logger.info "Deleting Plaid User with token #{token_last_8}"
client = Plaid::Client.new(env: PlaidRails.env,
client_id: PlaidRails.client_id,
secret: PlaidRails.secret,
public_key: PlaidRails.public_key)
client.item.re... | [
"def",
"delete_connect",
"begin",
"Rails",
".",
"logger",
".",
"info",
"\"Deleting Plaid User with token #{token_last_8}\"",
"client",
"=",
"Plaid",
"::",
"Client",
".",
"new",
"(",
"env",
":",
"PlaidRails",
".",
"env",
",",
"client_id",
":",
"PlaidRails",
".",
... | delete Plaid user | [
"delete",
"Plaid",
"user"
] | abad75600c26c20a29d5fa3df80d52487a4e72cc | https://github.com/9kSoftware/plaid_rails/blob/abad75600c26c20a29d5fa3df80d52487a4e72cc/app/models/plaid_rails/account.rb#L24-L38 |
3,590 | printercu/rails_stuff | lib/rails_stuff/types_tracker.rb | RailsStuff.TypesTracker.register_type | def register_type(*args)
if types_list.respond_to?(:add)
types_list.add self, *args
else
types_list << self
end
if types_tracker_base.respond_to?(:scope) &&
!types_tracker_base.respond_to?(model_name.element)
type_name = name
types_tracker_base.scope mod... | ruby | def register_type(*args)
if types_list.respond_to?(:add)
types_list.add self, *args
else
types_list << self
end
if types_tracker_base.respond_to?(:scope) &&
!types_tracker_base.respond_to?(model_name.element)
type_name = name
types_tracker_base.scope mod... | [
"def",
"register_type",
"(",
"*",
"args",
")",
"if",
"types_list",
".",
"respond_to?",
"(",
":add",
")",
"types_list",
".",
"add",
"self",
",",
"args",
"else",
"types_list",
"<<",
"self",
"end",
"if",
"types_tracker_base",
".",
"respond_to?",
"(",
":scope",
... | Add `self` to `types_list`. Defines scope for ActiveRecord models. | [
"Add",
"self",
"to",
"types_list",
".",
"Defines",
"scope",
"for",
"ActiveRecord",
"models",
"."
] | b3d72daaae6426c8166205f6a7438a89768e8347 | https://github.com/printercu/rails_stuff/blob/b3d72daaae6426c8166205f6a7438a89768e8347/lib/rails_stuff/types_tracker.rb#L26-L37 |
3,591 | printercu/rails_stuff | lib/rails_stuff/redis_storage.rb | RailsStuff.RedisStorage.get | def get(id)
return unless id
with_redis { |redis| redis.get(redis_key_for(id)).try { |data| load(data) } }
end | ruby | def get(id)
return unless id
with_redis { |redis| redis.get(redis_key_for(id)).try { |data| load(data) } }
end | [
"def",
"get",
"(",
"id",
")",
"return",
"unless",
"id",
"with_redis",
"{",
"|",
"redis",
"|",
"redis",
".",
"get",
"(",
"redis_key_for",
"(",
"id",
")",
")",
".",
"try",
"{",
"|",
"data",
"|",
"load",
"(",
"data",
")",
"}",
"}",
"end"
] | Reads value from redis. | [
"Reads",
"value",
"from",
"redis",
"."
] | b3d72daaae6426c8166205f6a7438a89768e8347 | https://github.com/printercu/rails_stuff/blob/b3d72daaae6426c8166205f6a7438a89768e8347/lib/rails_stuff/redis_storage.rb#L107-L110 |
3,592 | printercu/rails_stuff | lib/rails_stuff/redis_storage.rb | RailsStuff.RedisStorage.delete | def delete(id)
return true unless id
with_redis { |redis| redis.del(redis_key_for(id)) }
true
end | ruby | def delete(id)
return true unless id
with_redis { |redis| redis.del(redis_key_for(id)) }
true
end | [
"def",
"delete",
"(",
"id",
")",
"return",
"true",
"unless",
"id",
"with_redis",
"{",
"|",
"redis",
"|",
"redis",
".",
"del",
"(",
"redis_key_for",
"(",
"id",
")",
")",
"}",
"true",
"end"
] | Remove record from redis. | [
"Remove",
"record",
"from",
"redis",
"."
] | b3d72daaae6426c8166205f6a7438a89768e8347 | https://github.com/printercu/rails_stuff/blob/b3d72daaae6426c8166205f6a7438a89768e8347/lib/rails_stuff/redis_storage.rb#L113-L117 |
3,593 | pitluga/keepassx | lib/keepassx/database.rb | Keepassx.Database.add_group | def add_group(opts)
raise ArgumentError, "Expected Hash or Keepassx::Group, got #{opts.class}" unless valid_group?(opts)
if opts.is_a?(Keepassx::Group)
# Assign parent group
parent = opts.parent
index = last_sibling_index(parent) + 1
@groups.insert(index, opts)
# I... | ruby | def add_group(opts)
raise ArgumentError, "Expected Hash or Keepassx::Group, got #{opts.class}" unless valid_group?(opts)
if opts.is_a?(Keepassx::Group)
# Assign parent group
parent = opts.parent
index = last_sibling_index(parent) + 1
@groups.insert(index, opts)
# I... | [
"def",
"add_group",
"(",
"opts",
")",
"raise",
"ArgumentError",
",",
"\"Expected Hash or Keepassx::Group, got #{opts.class}\"",
"unless",
"valid_group?",
"(",
"opts",
")",
"if",
"opts",
".",
"is_a?",
"(",
"Keepassx",
"::",
"Group",
")",
"# Assign parent group",
"paren... | Add new group to database.
@param opts [Hash] Options that will be passed to Keepassx::Group#new.
@return [Keepassx::Group]
rubocop:disable Metrics/MethodLength | [
"Add",
"new",
"group",
"to",
"database",
"."
] | a00fd5b71e6a8c742e272fdee456bfbe03b5adec | https://github.com/pitluga/keepassx/blob/a00fd5b71e6a8c742e272fdee456bfbe03b5adec/lib/keepassx/database.rb#L32-L60 |
3,594 | pitluga/keepassx | lib/keepassx/database.rb | Keepassx.Database.next_group_id | def next_group_id
if @groups.empty?
# Start each time from 1 to make sure groups get the same id's for the
# same input data
1
else
id = @groups.last.id
loop do
id += 1
break id if @groups.find { |g| g.id == id }.nil?
en... | ruby | def next_group_id
if @groups.empty?
# Start each time from 1 to make sure groups get the same id's for the
# same input data
1
else
id = @groups.last.id
loop do
id += 1
break id if @groups.find { |g| g.id == id }.nil?
en... | [
"def",
"next_group_id",
"if",
"@groups",
".",
"empty?",
"# Start each time from 1 to make sure groups get the same id's for the",
"# same input data",
"1",
"else",
"id",
"=",
"@groups",
".",
"last",
".",
"id",
"loop",
"do",
"id",
"+=",
"1",
"break",
"id",
"if",
"@gr... | Get next group ID number.
@return [Fixnum] | [
"Get",
"next",
"group",
"ID",
"number",
"."
] | a00fd5b71e6a8c742e272fdee456bfbe03b5adec | https://github.com/pitluga/keepassx/blob/a00fd5b71e6a8c742e272fdee456bfbe03b5adec/lib/keepassx/database.rb#L131-L143 |
3,595 | pitluga/keepassx | lib/keepassx/database.rb | Keepassx.Database.last_sibling_index | def last_sibling_index(parent)
return -1 if groups.empty?
if parent.nil?
parent_index = 0
sibling_level = 1
else
parent_index = groups.find_index(parent)
sibling_level = parent.level + 1
end
raise "Could not find group #{parent.name}" i... | ruby | def last_sibling_index(parent)
return -1 if groups.empty?
if parent.nil?
parent_index = 0
sibling_level = 1
else
parent_index = groups.find_index(parent)
sibling_level = parent.level + 1
end
raise "Could not find group #{parent.name}" i... | [
"def",
"last_sibling_index",
"(",
"parent",
")",
"return",
"-",
"1",
"if",
"groups",
".",
"empty?",
"if",
"parent",
".",
"nil?",
"parent_index",
"=",
"0",
"sibling_level",
"=",
"1",
"else",
"parent_index",
"=",
"groups",
".",
"find_index",
"(",
"parent",
"... | Retrieves last sibling index
@param parent [Keepassx::Group] Last sibling group.
@return [Integer] index Group index. | [
"Retrieves",
"last",
"sibling",
"index"
] | a00fd5b71e6a8c742e272fdee456bfbe03b5adec | https://github.com/pitluga/keepassx/blob/a00fd5b71e6a8c742e272fdee456bfbe03b5adec/lib/keepassx/database.rb#L150-L166 |
3,596 | blackwinter/wadl | lib/wadl/resource.rb | WADL.Resource.address | def address(working_address = nil)
working_address &&= working_address.deep_copy
working_address ||= if parent.respond_to?(:base)
address = Address.new
address.path_fragments << parent.base
address
else
parent.address.deep_copy
end
working_address.path_fra... | ruby | def address(working_address = nil)
working_address &&= working_address.deep_copy
working_address ||= if parent.respond_to?(:base)
address = Address.new
address.path_fragments << parent.base
address
else
parent.address.deep_copy
end
working_address.path_fra... | [
"def",
"address",
"(",
"working_address",
"=",
"nil",
")",
"working_address",
"&&=",
"working_address",
".",
"deep_copy",
"working_address",
"||=",
"if",
"parent",
".",
"respond_to?",
"(",
":base",
")",
"address",
"=",
"Address",
".",
"new",
"address",
".",
"p... | Returns an Address object refering to this resource | [
"Returns",
"an",
"Address",
"object",
"refering",
"to",
"this",
"resource"
] | 0e99d512f8b8627cb5e13a9e793d89c6af32066e | https://github.com/blackwinter/wadl/blob/0e99d512f8b8627cb5e13a9e793d89c6af32066e/lib/wadl/resource.rb#L82-L122 |
3,597 | blackwinter/wadl | lib/wadl/representation_format.rb | WADL.RepresentationFormat.% | def %(values)
unless is_form_representation?
raise "wadl can't instantiate a representation of type #{mediaType}"
end
representation = []
params.each { |param|
name = param.name
if param.fixed
p_values = [param.fixed]
elsif p_values = values[name] || ... | ruby | def %(values)
unless is_form_representation?
raise "wadl can't instantiate a representation of type #{mediaType}"
end
representation = []
params.each { |param|
name = param.name
if param.fixed
p_values = [param.fixed]
elsif p_values = values[name] || ... | [
"def",
"%",
"(",
"values",
")",
"unless",
"is_form_representation?",
"raise",
"\"wadl can't instantiate a representation of type #{mediaType}\"",
"end",
"representation",
"=",
"[",
"]",
"params",
".",
"each",
"{",
"|",
"param",
"|",
"name",
"=",
"param",
".",
"name"... | Creates a representation by plugging a set of parameters
into a representation format. | [
"Creates",
"a",
"representation",
"by",
"plugging",
"a",
"set",
"of",
"parameters",
"into",
"a",
"representation",
"format",
"."
] | 0e99d512f8b8627cb5e13a9e793d89c6af32066e | https://github.com/blackwinter/wadl/blob/0e99d512f8b8627cb5e13a9e793d89c6af32066e/lib/wadl/representation_format.rb#L48-L70 |
3,598 | josephholsten/rets4r | lib/rets4r/client.rb | RETS4R.Client.login | def login(username, password) #:yields: login_results
@request_struct.username = username
@request_struct.password = password
# We are required to set the Accept header to this by the RETS 1.5 specification.
set_header('Accept', '*/*')
response = request(@urls.login)
# Parse respo... | ruby | def login(username, password) #:yields: login_results
@request_struct.username = username
@request_struct.password = password
# We are required to set the Accept header to this by the RETS 1.5 specification.
set_header('Accept', '*/*')
response = request(@urls.login)
# Parse respo... | [
"def",
"login",
"(",
"username",
",",
"password",
")",
"#:yields: login_results",
"@request_struct",
".",
"username",
"=",
"username",
"@request_struct",
".",
"password",
"=",
"password",
"# We are required to set the Accept header to this by the RETS 1.5 specification.",
"set_... | RETS Transaction Methods
Most of these transaction methods mirror the RETS specification methods, so if you are
unsure what they mean, you should check the RETS specification. The latest version can be
found at http://www.rets.org
Attempts to log into the server using the provided username and password.
If call... | [
"RETS",
"Transaction",
"Methods"
] | ced066582823d2d0cdd2012d36a6898dbe9edb85 | https://github.com/josephholsten/rets4r/blob/ced066582823d2d0cdd2012d36a6898dbe9edb85/lib/rets4r/client.rb#L176-L223 |
3,599 | josephholsten/rets4r | lib/rets4r/client.rb | RETS4R.Client.get_metadata | def get_metadata(type = 'METADATA-SYSTEM', id = '*')
xml = download_metadata(type, id)
result = @response_parser.parse_metadata(xml, @format)
# TODO: fix test to like this
# result = ResponseDocument.safe_parse(xml).validate!.to_rexml
if block_given?
yield result
else
... | ruby | def get_metadata(type = 'METADATA-SYSTEM', id = '*')
xml = download_metadata(type, id)
result = @response_parser.parse_metadata(xml, @format)
# TODO: fix test to like this
# result = ResponseDocument.safe_parse(xml).validate!.to_rexml
if block_given?
yield result
else
... | [
"def",
"get_metadata",
"(",
"type",
"=",
"'METADATA-SYSTEM'",
",",
"id",
"=",
"'*'",
")",
"xml",
"=",
"download_metadata",
"(",
"type",
",",
"id",
")",
"result",
"=",
"@response_parser",
".",
"parse_metadata",
"(",
"xml",
",",
"@format",
")",
"# TODO: fix te... | Requests Metadata from the server. An optional type and id can be specified to request
subsets of the Metadata. Please see the RETS specification for more details on this.
The format variable tells the server which format to return the Metadata in. Unless you
need the raw metadata in a specified format, you really s... | [
"Requests",
"Metadata",
"from",
"the",
"server",
".",
"An",
"optional",
"type",
"and",
"id",
"can",
"be",
"specified",
"to",
"request",
"subsets",
"of",
"the",
"Metadata",
".",
"Please",
"see",
"the",
"RETS",
"specification",
"for",
"more",
"details",
"on",
... | ced066582823d2d0cdd2012d36a6898dbe9edb85 | https://github.com/josephholsten/rets4r/blob/ced066582823d2d0cdd2012d36a6898dbe9edb85/lib/rets4r/client.rb#L241-L253 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.