repo stringlengths 5 58 | path stringlengths 9 168 | func_name stringlengths 9 130 | original_string stringlengths 66 10.5k | language stringclasses 1
value | code stringlengths 66 10.5k | code_tokens list | docstring stringlengths 8 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 94 266 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
flori/bullshit | lib/bullshit.rb | Bullshit.Clock.analysis | def analysis
@analysis ||= Hash.new do |h, time|
time = time.to_sym
times = @times[time]
h[time] = MoreMath::Sequence.new(times)
end
end | ruby | def analysis
@analysis ||= Hash.new do |h, time|
time = time.to_sym
times = @times[time]
h[time] = MoreMath::Sequence.new(times)
end
end | [
"def",
"analysis",
"@analysis",
"||=",
"Hash",
".",
"new",
"do",
"|",
"h",
",",
"time",
"|",
"time",
"=",
"time",
".",
"to_sym",
"times",
"=",
"@times",
"[",
"time",
"]",
"h",
"[",
"time",
"]",
"=",
"MoreMath",
"::",
"Sequence",
".",
"new",
"(",
... | Returns a Hash of Sequence object for all of TIMES's time keys. | [
"Returns",
"a",
"Hash",
"of",
"Sequence",
"object",
"for",
"all",
"of",
"TIMES",
"s",
"time",
"keys",
"."
] | dc5d078bfb82d42bb6bafd9248972c20f52ae40c | https://github.com/flori/bullshit/blob/dc5d078bfb82d42bb6bafd9248972c20f52ae40c/lib/bullshit.rb#L181-L187 | train |
flori/bullshit | lib/bullshit.rb | Bullshit.Clock.cover? | def cover?(other)
time = self.case.compare_time.to_sym
analysis[time].cover?(other.analysis[time], self.case.covering.alpha_level.abs)
end | ruby | def cover?(other)
time = self.case.compare_time.to_sym
analysis[time].cover?(other.analysis[time], self.case.covering.alpha_level.abs)
end | [
"def",
"cover?",
"(",
"other",
")",
"time",
"=",
"self",
".",
"case",
".",
"compare_time",
".",
"to_sym",
"analysis",
"[",
"time",
"]",
".",
"cover?",
"(",
"other",
".",
"analysis",
"[",
"time",
"]",
",",
"self",
".",
"case",
".",
"covering",
".",
... | Return true, if other's mean value is indistinguishable from this
object's mean after filtering out the noise from the measurements with a
Welch's t-Test. This mean's that differences in the mean of both clocks
might not inidicate a real performance difference and may be caused by
chance. | [
"Return",
"true",
"if",
"other",
"s",
"mean",
"value",
"is",
"indistinguishable",
"from",
"this",
"object",
"s",
"mean",
"after",
"filtering",
"out",
"the",
"noise",
"from",
"the",
"measurements",
"with",
"a",
"Welch",
"s",
"t",
"-",
"Test",
".",
"This",
... | dc5d078bfb82d42bb6bafd9248972c20f52ae40c | https://github.com/flori/bullshit/blob/dc5d078bfb82d42bb6bafd9248972c20f52ae40c/lib/bullshit.rb#L194-L197 | train |
flori/bullshit | lib/bullshit.rb | Bullshit.Clock.to_a | def to_a
if @repeat >= 1
(::Bullshit::Clock::ALL_COLUMNS).map do |t|
analysis[t].elements
end.transpose
else
[]
end
end | ruby | def to_a
if @repeat >= 1
(::Bullshit::Clock::ALL_COLUMNS).map do |t|
analysis[t].elements
end.transpose
else
[]
end
end | [
"def",
"to_a",
"if",
"@repeat",
">=",
"1",
"(",
"::",
"Bullshit",
"::",
"Clock",
"::",
"ALL_COLUMNS",
")",
".",
"map",
"do",
"|",
"t",
"|",
"analysis",
"[",
"t",
"]",
".",
"elements",
"end",
".",
"transpose",
"else",
"[",
"]",
"end",
"end"
] | Returns the measurements as an array of arrays. | [
"Returns",
"the",
"measurements",
"as",
"an",
"array",
"of",
"arrays",
"."
] | dc5d078bfb82d42bb6bafd9248972c20f52ae40c | https://github.com/flori/bullshit/blob/dc5d078bfb82d42bb6bafd9248972c20f52ae40c/lib/bullshit.rb#L205-L213 | train |
flori/bullshit | lib/bullshit.rb | Bullshit.Clock.take_time | def take_time
@time, times = Time.now, Process.times
user_time = times.utime + times.cutime # user time of this process and its children
system_time = times.stime + times.cstime # system time of this process and its children
total_time = user_time + system_time # total time of this proc... | ruby | def take_time
@time, times = Time.now, Process.times
user_time = times.utime + times.cutime # user time of this process and its children
system_time = times.stime + times.cstime # system time of this process and its children
total_time = user_time + system_time # total time of this proc... | [
"def",
"take_time",
"@time",
",",
"times",
"=",
"Time",
".",
"now",
",",
"Process",
".",
"times",
"user_time",
"=",
"times",
".",
"utime",
"+",
"times",
".",
"cutime",
"# user time of this process and its children",
"system_time",
"=",
"times",
".",
"stime",
"... | Takes the times an returns an array, consisting of the times in the order
of enumerated in the TIMES constant. | [
"Takes",
"the",
"times",
"an",
"returns",
"an",
"array",
"consisting",
"of",
"the",
"times",
"in",
"the",
"order",
"of",
"enumerated",
"in",
"the",
"TIMES",
"constant",
"."
] | dc5d078bfb82d42bb6bafd9248972c20f52ae40c | https://github.com/flori/bullshit/blob/dc5d078bfb82d42bb6bafd9248972c20f52ae40c/lib/bullshit.rb#L217-L223 | train |
flori/bullshit | lib/bullshit.rb | Bullshit.Clock.measure | def measure
before = take_time
yield
after = take_time
@repeat += 1
@times[:repeat] << @repeat
@times[:scatter] << @scatter
bs = self.case.batch_size.abs
if bs and bs > 1
TIMES.each_with_index { |t, i| @times[t] << (after[i] - before[i]) / bs }
else
... | ruby | def measure
before = take_time
yield
after = take_time
@repeat += 1
@times[:repeat] << @repeat
@times[:scatter] << @scatter
bs = self.case.batch_size.abs
if bs and bs > 1
TIMES.each_with_index { |t, i| @times[t] << (after[i] - before[i]) / bs }
else
... | [
"def",
"measure",
"before",
"=",
"take_time",
"yield",
"after",
"=",
"take_time",
"@repeat",
"+=",
"1",
"@times",
"[",
":repeat",
"]",
"<<",
"@repeat",
"@times",
"[",
":scatter",
"]",
"<<",
"@scatter",
"bs",
"=",
"self",
".",
"case",
".",
"batch_size",
"... | Take a single measurement. This method should be called with the code to
benchmark in a block. | [
"Take",
"a",
"single",
"measurement",
".",
"This",
"method",
"should",
"be",
"called",
"with",
"the",
"code",
"to",
"benchmark",
"in",
"a",
"block",
"."
] | dc5d078bfb82d42bb6bafd9248972c20f52ae40c | https://github.com/flori/bullshit/blob/dc5d078bfb82d42bb6bafd9248972c20f52ae40c/lib/bullshit.rb#L232-L246 | train |
flori/bullshit | lib/bullshit.rb | Bullshit.Clock.detect_autocorrelation | def detect_autocorrelation(time)
analysis[time.to_sym].detect_autocorrelation(
self.case.autocorrelation.max_lags.to_i,
self.case.autocorrelation.alpha_level.abs)
end | ruby | def detect_autocorrelation(time)
analysis[time.to_sym].detect_autocorrelation(
self.case.autocorrelation.max_lags.to_i,
self.case.autocorrelation.alpha_level.abs)
end | [
"def",
"detect_autocorrelation",
"(",
"time",
")",
"analysis",
"[",
"time",
".",
"to_sym",
"]",
".",
"detect_autocorrelation",
"(",
"self",
".",
"case",
".",
"autocorrelation",
".",
"max_lags",
".",
"to_i",
",",
"self",
".",
"case",
".",
"autocorrelation",
"... | Returns the q value for the Ljung-Box statistic of this +time+'s
analysis.detect_autocorrelation method. | [
"Returns",
"the",
"q",
"value",
"for",
"the",
"Ljung",
"-",
"Box",
"statistic",
"of",
"this",
"+",
"time",
"+",
"s",
"analysis",
".",
"detect_autocorrelation",
"method",
"."
] | dc5d078bfb82d42bb6bafd9248972c20f52ae40c | https://github.com/flori/bullshit/blob/dc5d078bfb82d42bb6bafd9248972c20f52ae40c/lib/bullshit.rb#L282-L286 | train |
flori/bullshit | lib/bullshit.rb | Bullshit.Clock.autocorrelation_plot | def autocorrelation_plot(time)
r = autocorrelation time
start = @times[:repeat].first
ende = (start + r.size)
(start...ende).to_a.zip(r)
end | ruby | def autocorrelation_plot(time)
r = autocorrelation time
start = @times[:repeat].first
ende = (start + r.size)
(start...ende).to_a.zip(r)
end | [
"def",
"autocorrelation_plot",
"(",
"time",
")",
"r",
"=",
"autocorrelation",
"time",
"start",
"=",
"@times",
"[",
":repeat",
"]",
".",
"first",
"ende",
"=",
"(",
"start",
"+",
"r",
".",
"size",
")",
"(",
"start",
"...",
"ende",
")",
".",
"to_a",
"."... | Returns the arrays for the autocorrelation plot, the first array for the
numbers of lag measured, the second for the autocorrelation value. | [
"Returns",
"the",
"arrays",
"for",
"the",
"autocorrelation",
"plot",
"the",
"first",
"array",
"for",
"the",
"numbers",
"of",
"lag",
"measured",
"the",
"second",
"for",
"the",
"autocorrelation",
"value",
"."
] | dc5d078bfb82d42bb6bafd9248972c20f52ae40c | https://github.com/flori/bullshit/blob/dc5d078bfb82d42bb6bafd9248972c20f52ae40c/lib/bullshit.rb#L365-L370 | train |
flori/bullshit | lib/bullshit.rb | Bullshit.Clock.truncate_data | def truncate_data(offset)
for t in ALL_COLUMNS
times = @times[t]
@times[t] = @times[t][offset, times.size]
@repeat = @times[t].size
end
@analysis = nil
self
end | ruby | def truncate_data(offset)
for t in ALL_COLUMNS
times = @times[t]
@times[t] = @times[t][offset, times.size]
@repeat = @times[t].size
end
@analysis = nil
self
end | [
"def",
"truncate_data",
"(",
"offset",
")",
"for",
"t",
"in",
"ALL_COLUMNS",
"times",
"=",
"@times",
"[",
"t",
"]",
"@times",
"[",
"t",
"]",
"=",
"@times",
"[",
"t",
"]",
"[",
"offset",
",",
"times",
".",
"size",
"]",
"@repeat",
"=",
"@times",
"[",... | Truncate the measurements stored in this clock starting from the integer
+offset+. | [
"Truncate",
"the",
"measurements",
"stored",
"in",
"this",
"clock",
"starting",
"from",
"the",
"integer",
"+",
"offset",
"+",
"."
] | dc5d078bfb82d42bb6bafd9248972c20f52ae40c | https://github.com/flori/bullshit/blob/dc5d078bfb82d42bb6bafd9248972c20f52ae40c/lib/bullshit.rb#L379-L387 | train |
flori/bullshit | lib/bullshit.rb | Bullshit.Clock.find_truncation_offset | def find_truncation_offset
truncation = self.case.truncate_data
slope_angle = self.case.truncate_data.slope_angle.abs
time = self.case.compare_time.to_sym
ms = analysis[time].elements.reverse
offset = ms.size - 1
@slopes = []
ModuleFunctions.array_window(ms, truncation.window_s... | ruby | def find_truncation_offset
truncation = self.case.truncate_data
slope_angle = self.case.truncate_data.slope_angle.abs
time = self.case.compare_time.to_sym
ms = analysis[time].elements.reverse
offset = ms.size - 1
@slopes = []
ModuleFunctions.array_window(ms, truncation.window_s... | [
"def",
"find_truncation_offset",
"truncation",
"=",
"self",
".",
"case",
".",
"truncate_data",
"slope_angle",
"=",
"self",
".",
"case",
".",
"truncate_data",
".",
"slope_angle",
".",
"abs",
"time",
"=",
"self",
".",
"case",
".",
"compare_time",
".",
"to_sym",
... | Find an offset from the start of the measurements in this clock to
truncate the initial data until a stable state has been reached and
return it as an integer. | [
"Find",
"an",
"offset",
"from",
"the",
"start",
"of",
"the",
"measurements",
"in",
"this",
"clock",
"to",
"truncate",
"the",
"initial",
"data",
"until",
"a",
"stable",
"state",
"has",
"been",
"reached",
"and",
"return",
"it",
"as",
"an",
"integer",
"."
] | dc5d078bfb82d42bb6bafd9248972c20f52ae40c | https://github.com/flori/bullshit/blob/dc5d078bfb82d42bb6bafd9248972c20f52ae40c/lib/bullshit.rb#L392-L407 | train |
flori/bullshit | lib/bullshit.rb | Bullshit.CaseMethod.load | def load(fp = file_path)
self.clock = self.case.class.clock.new self
$DEBUG and warn "Loading '#{fp}' into clock."
File.open(fp, 'r') do |f|
f.each do |line|
line.chomp!
line =~ /^\s*#/ and next
clock << line.split(/\t/)
end
end
self
rescue... | ruby | def load(fp = file_path)
self.clock = self.case.class.clock.new self
$DEBUG and warn "Loading '#{fp}' into clock."
File.open(fp, 'r') do |f|
f.each do |line|
line.chomp!
line =~ /^\s*#/ and next
clock << line.split(/\t/)
end
end
self
rescue... | [
"def",
"load",
"(",
"fp",
"=",
"file_path",
")",
"self",
".",
"clock",
"=",
"self",
".",
"case",
".",
"class",
".",
"clock",
".",
"new",
"self",
"$DEBUG",
"and",
"warn",
"\"Loading '#{fp}' into clock.\"",
"File",
".",
"open",
"(",
"fp",
",",
"'r'",
")"... | Load the data of file +fp+ into this clock. | [
"Load",
"the",
"data",
"of",
"file",
"+",
"fp",
"+",
"into",
"this",
"clock",
"."
] | dc5d078bfb82d42bb6bafd9248972c20f52ae40c | https://github.com/flori/bullshit/blob/dc5d078bfb82d42bb6bafd9248972c20f52ae40c/lib/bullshit.rb#L481-L493 | train |
flori/bullshit | lib/bullshit.rb | Bullshit.Case.longest_name | def longest_name
bmethods.empty? and return 0
bmethods.map { |x| x.short_name.size }.max
end | ruby | def longest_name
bmethods.empty? and return 0
bmethods.map { |x| x.short_name.size }.max
end | [
"def",
"longest_name",
"bmethods",
".",
"empty?",
"and",
"return",
"0",
"bmethods",
".",
"map",
"{",
"|",
"x",
"|",
"x",
".",
"short_name",
".",
"size",
"}",
".",
"max",
"end"
] | Return the length of the longest_name of all these methods' names. | [
"Return",
"the",
"length",
"of",
"the",
"longest_name",
"of",
"all",
"these",
"methods",
"names",
"."
] | dc5d078bfb82d42bb6bafd9248972c20f52ae40c | https://github.com/flori/bullshit/blob/dc5d078bfb82d42bb6bafd9248972c20f52ae40c/lib/bullshit.rb#L745-L748 | train |
flori/bullshit | lib/bullshit.rb | Bullshit.Case.pre_run | def pre_run(bc_method)
setup_name = bc_method.setup_name
if respond_to? setup_name
$DEBUG and warn "Calling #{setup_name}."
__send__(setup_name)
end
self.class.output.puts "#{bc_method.long_name}:"
end | ruby | def pre_run(bc_method)
setup_name = bc_method.setup_name
if respond_to? setup_name
$DEBUG and warn "Calling #{setup_name}."
__send__(setup_name)
end
self.class.output.puts "#{bc_method.long_name}:"
end | [
"def",
"pre_run",
"(",
"bc_method",
")",
"setup_name",
"=",
"bc_method",
".",
"setup_name",
"if",
"respond_to?",
"setup_name",
"$DEBUG",
"and",
"warn",
"\"Calling #{setup_name}.\"",
"__send__",
"(",
"setup_name",
")",
"end",
"self",
".",
"class",
".",
"output",
... | Output before +bc_method+ is run. | [
"Output",
"before",
"+",
"bc_method",
"+",
"is",
"run",
"."
] | dc5d078bfb82d42bb6bafd9248972c20f52ae40c | https://github.com/flori/bullshit/blob/dc5d078bfb82d42bb6bafd9248972c20f52ae40c/lib/bullshit.rb#L885-L892 | train |
flori/bullshit | lib/bullshit.rb | Bullshit.Case.run_method | def run_method(bc_method)
pre_run bc_method
clock = self.class.clock.__send__(self.class.clock_method, bc_method) do
__send__(bc_method.name)
end
bc_method.clock = clock
post_run bc_method
clock
end | ruby | def run_method(bc_method)
pre_run bc_method
clock = self.class.clock.__send__(self.class.clock_method, bc_method) do
__send__(bc_method.name)
end
bc_method.clock = clock
post_run bc_method
clock
end | [
"def",
"run_method",
"(",
"bc_method",
")",
"pre_run",
"bc_method",
"clock",
"=",
"self",
".",
"class",
".",
"clock",
".",
"__send__",
"(",
"self",
".",
"class",
".",
"clock_method",
",",
"bc_method",
")",
"do",
"__send__",
"(",
"bc_method",
".",
"name",
... | Run only pre_run and post_run methods. Yield to the block, if one was
given. | [
"Run",
"only",
"pre_run",
"and",
"post_run",
"methods",
".",
"Yield",
"to",
"the",
"block",
"if",
"one",
"was",
"given",
"."
] | dc5d078bfb82d42bb6bafd9248972c20f52ae40c | https://github.com/flori/bullshit/blob/dc5d078bfb82d42bb6bafd9248972c20f52ae40c/lib/bullshit.rb#L896-L904 | train |
flori/bullshit | lib/bullshit.rb | Bullshit.Case.post_run | def post_run(bc_method)
teardown_name = bc_method.teardown_name
if respond_to? teardown_name
$DEBUG and warn "Calling #{teardown_name}."
__send__(bc_method.teardown_name)
end
end | ruby | def post_run(bc_method)
teardown_name = bc_method.teardown_name
if respond_to? teardown_name
$DEBUG and warn "Calling #{teardown_name}."
__send__(bc_method.teardown_name)
end
end | [
"def",
"post_run",
"(",
"bc_method",
")",
"teardown_name",
"=",
"bc_method",
".",
"teardown_name",
"if",
"respond_to?",
"teardown_name",
"$DEBUG",
"and",
"warn",
"\"Calling #{teardown_name}.\"",
"__send__",
"(",
"bc_method",
".",
"teardown_name",
")",
"end",
"end"
] | Output after +bc_method+ is run. | [
"Output",
"after",
"+",
"bc_method",
"+",
"is",
"run",
"."
] | dc5d078bfb82d42bb6bafd9248972c20f52ae40c | https://github.com/flori/bullshit/blob/dc5d078bfb82d42bb6bafd9248972c20f52ae40c/lib/bullshit.rb#L913-L919 | train |
flori/bullshit | lib/bullshit.rb | Bullshit.Comparison.output_filename | def output_filename(name)
path = File.expand_path(name, output_dir)
output File.new(path, 'a+')
end | ruby | def output_filename(name)
path = File.expand_path(name, output_dir)
output File.new(path, 'a+')
end | [
"def",
"output_filename",
"(",
"name",
")",
"path",
"=",
"File",
".",
"expand_path",
"(",
"name",
",",
"output_dir",
")",
"output",
"File",
".",
"new",
"(",
"path",
",",
"'a+'",
")",
"end"
] | Output results to the file named +name+. | [
"Output",
"results",
"to",
"the",
"file",
"named",
"+",
"name",
"+",
"."
] | dc5d078bfb82d42bb6bafd9248972c20f52ae40c | https://github.com/flori/bullshit/blob/dc5d078bfb82d42bb6bafd9248972c20f52ae40c/lib/bullshit.rb#L1162-L1165 | train |
SebastianSzturo/inaho | lib/inaho/dictionary.rb | Inaho.Dictionary.validate | def validate
errors = []
schema_path = File.expand_path("../../../vendor/AppleDictionarySchema.rng", __FILE__)
schema = Nokogiri::XML::RelaxNG(File.open(schema_path))
schema.validate(Nokogiri::XML(self.to_xml)).each do |error|
errors << error
end
if errors.size > 0
... | ruby | def validate
errors = []
schema_path = File.expand_path("../../../vendor/AppleDictionarySchema.rng", __FILE__)
schema = Nokogiri::XML::RelaxNG(File.open(schema_path))
schema.validate(Nokogiri::XML(self.to_xml)).each do |error|
errors << error
end
if errors.size > 0
... | [
"def",
"validate",
"errors",
"=",
"[",
"]",
"schema_path",
"=",
"File",
".",
"expand_path",
"(",
"\"../../../vendor/AppleDictionarySchema.rng\"",
",",
"__FILE__",
")",
"schema",
"=",
"Nokogiri",
"::",
"XML",
"::",
"RelaxNG",
"(",
"File",
".",
"open",
"(",
"sch... | Validate Dictionary xml with Apple's RelaxNG schema.
Returns true if xml is valid.
Returns List of Nokogiri::XML::SyntaxError objects if xml is not valid. | [
"Validate",
"Dictionary",
"xml",
"with",
"Apple",
"s",
"RelaxNG",
"schema",
"."
] | e3664bc59aa90197258d715a9032c18f82b84ebd | https://github.com/SebastianSzturo/inaho/blob/e3664bc59aa90197258d715a9032c18f82b84ebd/lib/inaho/dictionary.rb#L33-L47 | train |
SebastianSzturo/inaho | lib/inaho/dictionary.rb | Inaho.Dictionary.to_xml | def to_xml
xml = ""
xml << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
xml << "<d:dictionary xmlns=\"http://www.w3.org/1999/xhtml\" "
xml << "xmlns:d=\"http://www.apple.com/DTDs/DictionaryService-1.0.rng\">\n"
@entries.each do |entry|
next if entry.to_xml.nil?
xml << en... | ruby | def to_xml
xml = ""
xml << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
xml << "<d:dictionary xmlns=\"http://www.w3.org/1999/xhtml\" "
xml << "xmlns:d=\"http://www.apple.com/DTDs/DictionaryService-1.0.rng\">\n"
@entries.each do |entry|
next if entry.to_xml.nil?
xml << en... | [
"def",
"to_xml",
"xml",
"=",
"\"\"",
"xml",
"<<",
"\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\\n\"",
"xml",
"<<",
"\"<d:dictionary xmlns=\\\"http://www.w3.org/1999/xhtml\\\" \"",
"xml",
"<<",
"\"xmlns:d=\\\"http://www.apple.com/DTDs/DictionaryService-1.0.rng\\\">\\n\"",
"@entri... | Generates xml for Dictionary and Entry objects.
Returns String. | [
"Generates",
"xml",
"for",
"Dictionary",
"and",
"Entry",
"objects",
"."
] | e3664bc59aa90197258d715a9032c18f82b84ebd | https://github.com/SebastianSzturo/inaho/blob/e3664bc59aa90197258d715a9032c18f82b84ebd/lib/inaho/dictionary.rb#L52-L65 | train |
wilddima/stribog | lib/stribog/create_hash.rb | Stribog.CreateHash.return_hash | def return_hash(final_vector)
case digest_length
when 512
create_digest(final_vector)
when 256
create_digest(vector_from_array(final_vector[0..31]))
else
raise ArgumentError,
"digest length must be equal to 256 or 512, not #{digest_length}"
end
end | ruby | def return_hash(final_vector)
case digest_length
when 512
create_digest(final_vector)
when 256
create_digest(vector_from_array(final_vector[0..31]))
else
raise ArgumentError,
"digest length must be equal to 256 or 512, not #{digest_length}"
end
end | [
"def",
"return_hash",
"(",
"final_vector",
")",
"case",
"digest_length",
"when",
"512",
"create_digest",
"(",
"final_vector",
")",
"when",
"256",
"create_digest",
"(",
"vector_from_array",
"(",
"final_vector",
"[",
"0",
"..",
"31",
"]",
")",
")",
"else",
"rais... | Method, which return digest, dependent on them length | [
"Method",
"which",
"return",
"digest",
"dependent",
"on",
"them",
"length"
] | 696e0d4f18f5c210a0fa9e20af49bbb55c29ad72 | https://github.com/wilddima/stribog/blob/696e0d4f18f5c210a0fa9e20af49bbb55c29ad72/lib/stribog/create_hash.rb#L58-L68 | train |
robertwahler/repo_manager | lib/repo_manager/actions/base_action.rb | RepoManager.BaseAction.parse_options | def parse_options(parser_configuration = {})
raise_on_invalid_option = parser_configuration.has_key?(:raise_on_invalid_option) ? parser_configuration[:raise_on_invalid_option] : true
parse_base_options = parser_configuration.has_key?(:parse_base_options) ? parser_configuration[:parse_base_options] : true
... | ruby | def parse_options(parser_configuration = {})
raise_on_invalid_option = parser_configuration.has_key?(:raise_on_invalid_option) ? parser_configuration[:raise_on_invalid_option] : true
parse_base_options = parser_configuration.has_key?(:parse_base_options) ? parser_configuration[:parse_base_options] : true
... | [
"def",
"parse_options",
"(",
"parser_configuration",
"=",
"{",
"}",
")",
"raise_on_invalid_option",
"=",
"parser_configuration",
".",
"has_key?",
"(",
":raise_on_invalid_option",
")",
"?",
"parser_configuration",
"[",
":raise_on_invalid_option",
"]",
":",
"true",
"parse... | Parse generic action options for all decendant actions
@return [OptionParser] for use by decendant actions | [
"Parse",
"generic",
"action",
"options",
"for",
"all",
"decendant",
"actions"
] | d945f1cb6ac48b5689b633fcc029fd77c6a02d09 | https://github.com/robertwahler/repo_manager/blob/d945f1cb6ac48b5689b633fcc029fd77c6a02d09/lib/repo_manager/actions/base_action.rb#L47-L136 | train |
robertwahler/repo_manager | lib/repo_manager/actions/base_action.rb | RepoManager.BaseAction.asset_options | def asset_options
# include all base action options
result = options.deep_clone
# anything left on the command line should be filters as all options have
# been consumed, for pass through options, filters must be ignored by overwritting them
filters = args.dup
filters += result[:fil... | ruby | def asset_options
# include all base action options
result = options.deep_clone
# anything left on the command line should be filters as all options have
# been consumed, for pass through options, filters must be ignored by overwritting them
filters = args.dup
filters += result[:fil... | [
"def",
"asset_options",
"# include all base action options",
"result",
"=",
"options",
".",
"deep_clone",
"# anything left on the command line should be filters as all options have",
"# been consumed, for pass through options, filters must be ignored by overwritting them",
"filters",
"=",
"a... | asset options separated from assets to make it easier to override assets | [
"asset",
"options",
"separated",
"from",
"assets",
"to",
"make",
"it",
"easier",
"to",
"override",
"assets"
] | d945f1cb6ac48b5689b633fcc029fd77c6a02d09 | https://github.com/robertwahler/repo_manager/blob/d945f1cb6ac48b5689b633fcc029fd77c6a02d09/lib/repo_manager/actions/base_action.rb#L185-L206 | train |
robertwahler/repo_manager | lib/repo_manager/actions/base_action.rb | RepoManager.BaseAction.render | def render(view_options=configuration)
logger.debug "rendering"
result = ""
if template
logger.debug "rendering with template : #{template}"
view = AppView.new(items, view_options)
view.template = template
result = view.render
else
items.each_with_index do... | ruby | def render(view_options=configuration)
logger.debug "rendering"
result = ""
if template
logger.debug "rendering with template : #{template}"
view = AppView.new(items, view_options)
view.template = template
result = view.render
else
items.each_with_index do... | [
"def",
"render",
"(",
"view_options",
"=",
"configuration",
")",
"logger",
".",
"debug",
"\"rendering\"",
"result",
"=",
"\"\"",
"if",
"template",
"logger",
".",
"debug",
"\"rendering with template : #{template}\"",
"view",
"=",
"AppView",
".",
"new",
"(",
"items"... | Render items result to a string
@return [String] suitable for displaying on STDOUT or writing to a file | [
"Render",
"items",
"result",
"to",
"a",
"string"
] | d945f1cb6ac48b5689b633fcc029fd77c6a02d09 | https://github.com/robertwahler/repo_manager/blob/d945f1cb6ac48b5689b633fcc029fd77c6a02d09/lib/repo_manager/actions/base_action.rb#L218-L238 | train |
Yellowen/site_framework | lib/site_framework/middleware.rb | SiteFramework.Middleware.call | def call(env)
# Create a method called domain which will return the current domain
# name
Rails.application.send :define_singleton_method, 'domain_name' do
env['SERVER_NAME']
end
# Create `fetch_domain` method on `Rails.application`
# only if it didn't already define.
... | ruby | def call(env)
# Create a method called domain which will return the current domain
# name
Rails.application.send :define_singleton_method, 'domain_name' do
env['SERVER_NAME']
end
# Create `fetch_domain` method on `Rails.application`
# only if it didn't already define.
... | [
"def",
"call",
"(",
"env",
")",
"# Create a method called domain which will return the current domain",
"# name",
"Rails",
".",
"application",
".",
"send",
":define_singleton_method",
",",
"'domain_name'",
"do",
"env",
"[",
"'SERVER_NAME'",
"]",
"end",
"# Create `fetch_doma... | Middleware initializer method which gets the `app` from previous
middleware | [
"Middleware",
"initializer",
"method",
"which",
"gets",
"the",
"app",
"from",
"previous",
"middleware"
] | d4b1067c37c09c802aa4e1d5588ffdd3631f6395 | https://github.com/Yellowen/site_framework/blob/d4b1067c37c09c802aa4e1d5588ffdd3631f6395/lib/site_framework/middleware.rb#L13-L42 | train |
janlelis/fresh | lib/ripl/fresh.rb | Ripl.Fresh.loop_eval | def loop_eval(input)
if input == ''
@command_mode = :system and return
end
case @command_mode
when :system # generate ruby code to execute the command
if !@result_storage
ruby_command_code = "_ = system '#{ input }'\n"
else
temp_file = "/tmp/ripl-fres... | ruby | def loop_eval(input)
if input == ''
@command_mode = :system and return
end
case @command_mode
when :system # generate ruby code to execute the command
if !@result_storage
ruby_command_code = "_ = system '#{ input }'\n"
else
temp_file = "/tmp/ripl-fres... | [
"def",
"loop_eval",
"(",
"input",
")",
"if",
"input",
"==",
"''",
"@command_mode",
"=",
":system",
"and",
"return",
"end",
"case",
"@command_mode",
"when",
":system",
"# generate ruby code to execute the command",
"if",
"!",
"@result_storage",
"ruby_command_code",
"="... | get result (depending on @command_mode) | [
"get",
"result",
"(",
"depending",
"on"
] | 5bd2417232cf035f28b8ee16c212da162f2770a5 | https://github.com/janlelis/fresh/blob/5bd2417232cf035f28b8ee16c212da162f2770a5/lib/ripl/fresh.rb#L60-L105 | train |
fcheung/corefoundation | lib/corefoundation/data.rb | CF.Data.to_s | def to_s
ptr = CF.CFDataGetBytePtr(self)
if CF::String::HAS_ENCODING
ptr.read_string(CF.CFDataGetLength(self)).force_encoding(Encoding::ASCII_8BIT)
else
ptr.read_string(CF.CFDataGetLength(self))
end
end | ruby | def to_s
ptr = CF.CFDataGetBytePtr(self)
if CF::String::HAS_ENCODING
ptr.read_string(CF.CFDataGetLength(self)).force_encoding(Encoding::ASCII_8BIT)
else
ptr.read_string(CF.CFDataGetLength(self))
end
end | [
"def",
"to_s",
"ptr",
"=",
"CF",
".",
"CFDataGetBytePtr",
"(",
"self",
")",
"if",
"CF",
"::",
"String",
"::",
"HAS_ENCODING",
"ptr",
".",
"read_string",
"(",
"CF",
".",
"CFDataGetLength",
"(",
"self",
")",
")",
".",
"force_encoding",
"(",
"Encoding",
"::... | Creates a ruby string from the wrapped data. The encoding will always be ASCII_8BIT
@return [String] | [
"Creates",
"a",
"ruby",
"string",
"from",
"the",
"wrapped",
"data",
".",
"The",
"encoding",
"will",
"always",
"be",
"ASCII_8BIT"
] | a5c766359e74f873902d916e9fb051ec7fdedbb9 | https://github.com/fcheung/corefoundation/blob/a5c766359e74f873902d916e9fb051ec7fdedbb9/lib/corefoundation/data.rb#L24-L31 | train |
rakeoe/rakeoe | lib/rakeoe/toolchain.rb | RakeOE.Toolchain.set_build_vars | def set_build_vars
warning_flags = ' -W -Wall'
if 'release' == @config.release
optimization_flags = " #{@config.optimization_release} -DRELEASE"
else
optimization_flags = " #{@config.optimization_dbg} -g"
end
# we could make these also arrays of source directories ...
@settings['APP... | ruby | def set_build_vars
warning_flags = ' -W -Wall'
if 'release' == @config.release
optimization_flags = " #{@config.optimization_release} -DRELEASE"
else
optimization_flags = " #{@config.optimization_dbg} -g"
end
# we could make these also arrays of source directories ...
@settings['APP... | [
"def",
"set_build_vars",
"warning_flags",
"=",
"' -W -Wall'",
"if",
"'release'",
"==",
"@config",
".",
"release",
"optimization_flags",
"=",
"\" #{@config.optimization_release} -DRELEASE\"",
"else",
"optimization_flags",
"=",
"\" #{@config.optimization_dbg} -g\"",
"end",
"# we ... | Set common build variables | [
"Set",
"common",
"build",
"variables"
] | af7713fb238058509a34103829e37a62873c4ecb | https://github.com/rakeoe/rakeoe/blob/af7713fb238058509a34103829e37a62873c4ecb/lib/rakeoe/toolchain.rb#L188-L220 | train |
rakeoe/rakeoe | lib/rakeoe/toolchain.rb | RakeOE.Toolchain.reduce_libs_to_bare_minimum | def reduce_libs_to_bare_minimum(libs)
rv = libs.clone
lib_entries = RakeOE::PrjFileCache.get_lib_entries(libs)
lib_entries.each_pair do |lib, entry|
rv.delete(lib) unless RakeOE::PrjFileCache.project_entry_buildable?(entry, @target)
end
rv
end | ruby | def reduce_libs_to_bare_minimum(libs)
rv = libs.clone
lib_entries = RakeOE::PrjFileCache.get_lib_entries(libs)
lib_entries.each_pair do |lib, entry|
rv.delete(lib) unless RakeOE::PrjFileCache.project_entry_buildable?(entry, @target)
end
rv
end | [
"def",
"reduce_libs_to_bare_minimum",
"(",
"libs",
")",
"rv",
"=",
"libs",
".",
"clone",
"lib_entries",
"=",
"RakeOE",
"::",
"PrjFileCache",
".",
"get_lib_entries",
"(",
"libs",
")",
"lib_entries",
".",
"each_pair",
"do",
"|",
"lib",
",",
"entry",
"|",
"rv",... | Reduces the given list of libraries to bare minimum, i.e.
the minimum needed for actual platform
@libs list of libraries
@return reduced list of libraries | [
"Reduces",
"the",
"given",
"list",
"of",
"libraries",
"to",
"bare",
"minimum",
"i",
".",
"e",
".",
"the",
"minimum",
"needed",
"for",
"actual",
"platform"
] | af7713fb238058509a34103829e37a62873c4ecb | https://github.com/rakeoe/rakeoe/blob/af7713fb238058509a34103829e37a62873c4ecb/lib/rakeoe/toolchain.rb#L322-L329 | train |
rakeoe/rakeoe | lib/rakeoe/toolchain.rb | RakeOE.Toolchain.libs_for_binary | def libs_for_binary(a_binary, visited=[])
return [] if visited.include?(a_binary)
visited << a_binary
pre = Rake::Task[a_binary].prerequisites
rv = []
pre.each do |p|
next if (File.extname(p) != '.a') && (File.extname(p) != '.so')
next if p =~ /\-app\.a/
rv << File.basename(p).gs... | ruby | def libs_for_binary(a_binary, visited=[])
return [] if visited.include?(a_binary)
visited << a_binary
pre = Rake::Task[a_binary].prerequisites
rv = []
pre.each do |p|
next if (File.extname(p) != '.a') && (File.extname(p) != '.so')
next if p =~ /\-app\.a/
rv << File.basename(p).gs... | [
"def",
"libs_for_binary",
"(",
"a_binary",
",",
"visited",
"=",
"[",
"]",
")",
"return",
"[",
"]",
"if",
"visited",
".",
"include?",
"(",
"a_binary",
")",
"visited",
"<<",
"a_binary",
"pre",
"=",
"Rake",
"::",
"Task",
"[",
"a_binary",
"]",
".",
"prereq... | Return array of library prerequisites for given file | [
"Return",
"array",
"of",
"library",
"prerequisites",
"for",
"given",
"file"
] | af7713fb238058509a34103829e37a62873c4ecb | https://github.com/rakeoe/rakeoe/blob/af7713fb238058509a34103829e37a62873c4ecb/lib/rakeoe/toolchain.rb#L333-L348 | train |
rakeoe/rakeoe | lib/rakeoe/toolchain.rb | RakeOE.Toolchain.obj | def obj(params = {})
extension = File.extname(params[:source])
object = params[:object]
source = params[:source]
incs = compiler_incs_for(params[:includes]) + " #{@settings['LIB_INC']}"
case
when cpp_source_extensions.include?(extension)
flags = @settings['CXXFLAGS'] + ' ' ... | ruby | def obj(params = {})
extension = File.extname(params[:source])
object = params[:object]
source = params[:source]
incs = compiler_incs_for(params[:includes]) + " #{@settings['LIB_INC']}"
case
when cpp_source_extensions.include?(extension)
flags = @settings['CXXFLAGS'] + ' ' ... | [
"def",
"obj",
"(",
"params",
"=",
"{",
"}",
")",
"extension",
"=",
"File",
".",
"extname",
"(",
"params",
"[",
":source",
"]",
")",
"object",
"=",
"params",
"[",
":object",
"]",
"source",
"=",
"params",
"[",
":source",
"]",
"incs",
"=",
"compiler_inc... | Creates compilation object
@param [Hash] params
@option params [String] :source source filename with path
@option params [String] :object object filename path
@option params [Hash] :settings project specific settings
@option params [Array] :includes include paths used | [
"Creates",
"compilation",
"object"
] | af7713fb238058509a34103829e37a62873c4ecb | https://github.com/rakeoe/rakeoe/blob/af7713fb238058509a34103829e37a62873c4ecb/lib/rakeoe/toolchain.rb#L403-L423 | train |
fogonthedowns/rubychem | lib/rubychem/equation.rb | RubyChem.Equation.solve_equivalent_fractions | def solve_equivalent_fractions
last = 0
array = Array.new
@reduced_row_echelon_form.each do |x|
array = last.gcdlcm(x.last.denominator)
last = x.last.denominator
end
array.max
end | ruby | def solve_equivalent_fractions
last = 0
array = Array.new
@reduced_row_echelon_form.each do |x|
array = last.gcdlcm(x.last.denominator)
last = x.last.denominator
end
array.max
end | [
"def",
"solve_equivalent_fractions",
"last",
"=",
"0",
"array",
"=",
"Array",
".",
"new",
"@reduced_row_echelon_form",
".",
"each",
"do",
"|",
"x",
"|",
"array",
"=",
"last",
".",
"gcdlcm",
"(",
"x",
".",
"last",
".",
"denominator",
")",
"last",
"=",
"x"... | from the reduced row echelon form we are left with a set
of equivalent fractions to transform into a whole number
we do this by using the gcdlcm method | [
"from",
"the",
"reduced",
"row",
"echelon",
"form",
"we",
"are",
"left",
"with",
"a",
"set",
"of",
"equivalent",
"fractions",
"to",
"transform",
"into",
"a",
"whole",
"number",
"we",
"do",
"this",
"by",
"using",
"the",
"gcdlcm",
"method"
] | 7750e29465538b7c67f5a41a5cae6b7f74a7faac | https://github.com/fogonthedowns/rubychem/blob/7750e29465538b7c67f5a41a5cae6b7f74a7faac/lib/rubychem/equation.rb#L158-L166 | train |
fogonthedowns/rubychem | lib/rubychem/equation.rb | RubyChem.Equation.apply_solved_equivalent_fractions_to_fraction | def apply_solved_equivalent_fractions_to_fraction
int = self.solve_equivalent_fractions
answer = []
@reduced_row_echelon_form.each do |row|
answer << row.last * int
end
answer << int
count = 0
@balanced = Hash.new
@left_system_of_equations.each do |x,v|
an... | ruby | def apply_solved_equivalent_fractions_to_fraction
int = self.solve_equivalent_fractions
answer = []
@reduced_row_echelon_form.each do |row|
answer << row.last * int
end
answer << int
count = 0
@balanced = Hash.new
@left_system_of_equations.each do |x,v|
an... | [
"def",
"apply_solved_equivalent_fractions_to_fraction",
"int",
"=",
"self",
".",
"solve_equivalent_fractions",
"answer",
"=",
"[",
"]",
"@reduced_row_echelon_form",
".",
"each",
"do",
"|",
"row",
"|",
"answer",
"<<",
"row",
".",
"last",
"*",
"int",
"end",
"answer"... | Now that we have the whole number from solve_equivalent_fractions
we must apply that to each of the fractions to solve for the
balanced equation | [
"Now",
"that",
"we",
"have",
"the",
"whole",
"number",
"from",
"solve_equivalent_fractions",
"we",
"must",
"apply",
"that",
"to",
"each",
"of",
"the",
"fractions",
"to",
"solve",
"for",
"the",
"balanced",
"equation"
] | 7750e29465538b7c67f5a41a5cae6b7f74a7faac | https://github.com/fogonthedowns/rubychem/blob/7750e29465538b7c67f5a41a5cae6b7f74a7faac/lib/rubychem/equation.rb#L172-L194 | train |
fogonthedowns/rubychem | lib/rubychem/equation.rb | RubyChem.Equation.reduced_row_echelon_form | def reduced_row_echelon_form(ary)
lead = 0
rows = ary.size
cols = ary[0].size
rary = convert_to_rational(ary) # use rational arithmetic
catch :done do
rows.times do |r|
throw :done if cols <= lead
i = r
while rary[i][lead] == 0
i += 1
... | ruby | def reduced_row_echelon_form(ary)
lead = 0
rows = ary.size
cols = ary[0].size
rary = convert_to_rational(ary) # use rational arithmetic
catch :done do
rows.times do |r|
throw :done if cols <= lead
i = r
while rary[i][lead] == 0
i += 1
... | [
"def",
"reduced_row_echelon_form",
"(",
"ary",
")",
"lead",
"=",
"0",
"rows",
"=",
"ary",
".",
"size",
"cols",
"=",
"ary",
"[",
"0",
"]",
".",
"size",
"rary",
"=",
"convert_to_rational",
"(",
"ary",
")",
"# use rational arithmetic",
"catch",
":done",
"do",... | returns an 2-D array where each element is a Rational | [
"returns",
"an",
"2",
"-",
"D",
"array",
"where",
"each",
"element",
"is",
"a",
"Rational"
] | 7750e29465538b7c67f5a41a5cae6b7f74a7faac | https://github.com/fogonthedowns/rubychem/blob/7750e29465538b7c67f5a41a5cae6b7f74a7faac/lib/rubychem/equation.rb#L207-L239 | train |
wvanbergen/http_status_exceptions | lib/http_status_exceptions.rb | HTTPStatus.ControllerAddition.http_status_exception | def http_status_exception(exception)
@exception = exception
render_options = {:template => exception.template, :status => exception.status}
render_options[:layout] = exception.template_layout if exception.template_layout
render(render_options)
rescue ActionView::MissingTemplate
head(ex... | ruby | def http_status_exception(exception)
@exception = exception
render_options = {:template => exception.template, :status => exception.status}
render_options[:layout] = exception.template_layout if exception.template_layout
render(render_options)
rescue ActionView::MissingTemplate
head(ex... | [
"def",
"http_status_exception",
"(",
"exception",
")",
"@exception",
"=",
"exception",
"render_options",
"=",
"{",
":template",
"=>",
"exception",
".",
"template",
",",
":status",
"=>",
"exception",
".",
"status",
"}",
"render_options",
"[",
":layout",
"]",
"=",... | The default handler for raised HTTP status exceptions. It will render a
template if available, or respond with an empty response with the HTTP
status corresponding to the exception.
You can override this method in your <tt>ApplicationController</tt> to
handle the exceptions yourself.
<tt>exception</tt>:: The HTT... | [
"The",
"default",
"handler",
"for",
"raised",
"HTTP",
"status",
"exceptions",
".",
"It",
"will",
"render",
"a",
"template",
"if",
"available",
"or",
"respond",
"with",
"an",
"empty",
"response",
"with",
"the",
"HTTP",
"status",
"corresponding",
"to",
"the",
... | 8b88105f4784d03cb16cb4d36efb161394d02a2d | https://github.com/wvanbergen/http_status_exceptions/blob/8b88105f4784d03cb16cb4d36efb161394d02a2d/lib/http_status_exceptions.rb#L138-L145 | train |
rocky/rbx-trepanning | app/eventbuffer.rb | Trace.EventBuffer.append | def append(event, frame, arg)
item = EventStruct.new(event, arg, frame)
@pos = self.succ_pos
@marks.shift if @marks[0] == @pos
@buf[@pos] = item
@size += 1 unless @maxsize && @size == @maxsize
end | ruby | def append(event, frame, arg)
item = EventStruct.new(event, arg, frame)
@pos = self.succ_pos
@marks.shift if @marks[0] == @pos
@buf[@pos] = item
@size += 1 unless @maxsize && @size == @maxsize
end | [
"def",
"append",
"(",
"event",
",",
"frame",
",",
"arg",
")",
"item",
"=",
"EventStruct",
".",
"new",
"(",
"event",
",",
"arg",
",",
"frame",
")",
"@pos",
"=",
"self",
".",
"succ_pos",
"@marks",
".",
"shift",
"if",
"@marks",
"[",
"0",
"]",
"==",
... | Add a new event dropping off old events if that was declared
marks are also dropped if buffer has a limit. | [
"Add",
"a",
"new",
"event",
"dropping",
"off",
"old",
"events",
"if",
"that",
"was",
"declared",
"marks",
"are",
"also",
"dropped",
"if",
"buffer",
"has",
"a",
"limit",
"."
] | 192e5d3b8236f0c1094f7ba3a6b5d2c42ed43fc1 | https://github.com/rocky/rbx-trepanning/blob/192e5d3b8236f0c1094f7ba3a6b5d2c42ed43fc1/app/eventbuffer.rb#L25-L31 | train |
ivanzotov/constructor | pages/app/models/constructor_pages/template.rb | ConstructorPages.Template.check_code_name | def check_code_name(cname)
[cname.pluralize, cname.singularize].each {|name|
return false if root.descendants.map{|t| t.code_name unless t.code_name == cname}.include?(name)}
true
end | ruby | def check_code_name(cname)
[cname.pluralize, cname.singularize].each {|name|
return false if root.descendants.map{|t| t.code_name unless t.code_name == cname}.include?(name)}
true
end | [
"def",
"check_code_name",
"(",
"cname",
")",
"[",
"cname",
".",
"pluralize",
",",
"cname",
".",
"singularize",
"]",
".",
"each",
"{",
"|",
"name",
"|",
"return",
"false",
"if",
"root",
".",
"descendants",
".",
"map",
"{",
"|",
"t",
"|",
"t",
".",
"... | Check if there is code_name in same branch | [
"Check",
"if",
"there",
"is",
"code_name",
"in",
"same",
"branch"
] | 1d52fb5b642200a6993f5a630e6934bccbcbf4e8 | https://github.com/ivanzotov/constructor/blob/1d52fb5b642200a6993f5a630e6934bccbcbf4e8/pages/app/models/constructor_pages/template.rb#L39-L43 | train |
aelogica/express_templates | lib/express_templates/renderer.rb | ExpressTemplates.Renderer.render | def render context=nil, template_or_src=nil, &block
compiled_template = compile(template_or_src, &block)
context.instance_eval compiled_template
end | ruby | def render context=nil, template_or_src=nil, &block
compiled_template = compile(template_or_src, &block)
context.instance_eval compiled_template
end | [
"def",
"render",
"context",
"=",
"nil",
",",
"template_or_src",
"=",
"nil",
",",
"&",
"block",
"compiled_template",
"=",
"compile",
"(",
"template_or_src",
",",
"block",
")",
"context",
".",
"instance_eval",
"compiled_template",
"end"
] | render accepts source or block, evaluates the resulting string of ruby in the context provided | [
"render",
"accepts",
"source",
"or",
"block",
"evaluates",
"the",
"resulting",
"string",
"of",
"ruby",
"in",
"the",
"context",
"provided"
] | d5d447357e737c9220ca0025feb9e6f8f6249b5b | https://github.com/aelogica/express_templates/blob/d5d447357e737c9220ca0025feb9e6f8f6249b5b/lib/express_templates/renderer.rb#L4-L7 | train |
robertwahler/repo_manager | lib/repo_manager/settings.rb | RepoManager.Settings.configure | def configure(options)
# config file default options
configuration = {
:options => {
:verbose => false,
:color => 'AUTO',
:short => false,
:unmodified => 'HIDE',
... | ruby | def configure(options)
# config file default options
configuration = {
:options => {
:verbose => false,
:color => 'AUTO',
:short => false,
:unmodified => 'HIDE',
... | [
"def",
"configure",
"(",
"options",
")",
"# config file default options",
"configuration",
"=",
"{",
":options",
"=>",
"{",
":verbose",
"=>",
"false",
",",
":color",
"=>",
"'AUTO'",
",",
":short",
"=>",
"false",
",",
":unmodified",
"=>",
"'HIDE'",
",",
":match... | read options from YAML config | [
"read",
"options",
"from",
"YAML",
"config"
] | d945f1cb6ac48b5689b633fcc029fd77c6a02d09 | https://github.com/robertwahler/repo_manager/blob/d945f1cb6ac48b5689b633fcc029fd77c6a02d09/lib/repo_manager/settings.rb#L38-L94 | train |
eprothro/cassie | lib/cassie/statements/execution/batched_fetching.rb | Cassie::Statements::Execution.BatchedFetching.fetch_in_batches | def fetch_in_batches(opts={})
opts[:batch_size] ||= 1000
# spawn the new query as soon as the enumerable is created
# rather than waiting until the firt iteration is executed.
# The client could mutate the object between these moments,
# however we don't want to spawn twice if a block isn... | ruby | def fetch_in_batches(opts={})
opts[:batch_size] ||= 1000
# spawn the new query as soon as the enumerable is created
# rather than waiting until the firt iteration is executed.
# The client could mutate the object between these moments,
# however we don't want to spawn twice if a block isn... | [
"def",
"fetch_in_batches",
"(",
"opts",
"=",
"{",
"}",
")",
"opts",
"[",
":batch_size",
"]",
"||=",
"1000",
"# spawn the new query as soon as the enumerable is created",
"# rather than waiting until the firt iteration is executed.",
"# The client could mutate the object between these... | Yields each batch of records that was found by the options as an array.
If you do not provide a block to find_in_batches, it will return an Enumerator for chaining with other methods.
query.fetch_in_batches do |records|
puts "max score in group: #{records.max{ |a, b| a.score <=> b.score }}"
end
"max score ... | [
"Yields",
"each",
"batch",
"of",
"records",
"that",
"was",
"found",
"by",
"the",
"options",
"as",
"an",
"array",
"."
] | 63e71d12d3549882147e715e427a16fd8e0aa210 | https://github.com/eprothro/cassie/blob/63e71d12d3549882147e715e427a16fd8e0aa210/lib/cassie/statements/execution/batched_fetching.rb#L50-L81 | train |
tmobaird/GuideboxWrapper | lib/GuideboxWrapper/guidebox_movie.rb | GuideboxWrapper.GuideboxMovie.search_for | def search_for(name)
url = build_query(name)
url += '/fuzzy/web'
data = @client.query(url)
sleep(1)
data["results"]
end | ruby | def search_for(name)
url = build_query(name)
url += '/fuzzy/web'
data = @client.query(url)
sleep(1)
data["results"]
end | [
"def",
"search_for",
"(",
"name",
")",
"url",
"=",
"build_query",
"(",
"name",
")",
"url",
"+=",
"'/fuzzy/web'",
"data",
"=",
"@client",
".",
"query",
"(",
"url",
")",
"sleep",
"(",
"1",
")",
"data",
"[",
"\"results\"",
"]",
"end"
] | Search for show | [
"Search",
"for",
"show"
] | 431d541141c21620b640dcffee6cf23b3d5ca616 | https://github.com/tmobaird/GuideboxWrapper/blob/431d541141c21620b640dcffee6cf23b3d5ca616/lib/GuideboxWrapper/guidebox_movie.rb#L8-L14 | train |
pwnieexpress/snapi | lib/snapi/argument.rb | Snapi.Argument.valid_input? | def valid_input?(input)
case @attributes[:type]
when :boolean
[true,false].include?(input)
when :enum
raise MissingValuesError unless @attributes[:values]
raise InvalidValuesError unless @attributes[:values].class == Array
@attributes[:values].include?(input)
when... | ruby | def valid_input?(input)
case @attributes[:type]
when :boolean
[true,false].include?(input)
when :enum
raise MissingValuesError unless @attributes[:values]
raise InvalidValuesError unless @attributes[:values].class == Array
@attributes[:values].include?(input)
when... | [
"def",
"valid_input?",
"(",
"input",
")",
"case",
"@attributes",
"[",
":type",
"]",
"when",
":boolean",
"[",
"true",
",",
"false",
"]",
".",
"include?",
"(",
"input",
")",
"when",
":enum",
"raise",
"MissingValuesError",
"unless",
"@attributes",
"[",
":values... | Check if a value provided will suffice for the way
this argument is defined.
@param input, Just about anything...
@returns Boolean. true if valid | [
"Check",
"if",
"a",
"value",
"provided",
"will",
"suffice",
"for",
"the",
"way",
"this",
"argument",
"is",
"defined",
"."
] | 3c2a6fe454721945e4e58b8b496d3c20ada55df7 | https://github.com/pwnieexpress/snapi/blob/3c2a6fe454721945e4e58b8b496d3c20ada55df7/lib/snapi/argument.rb#L139-L159 | train |
eprothro/cassie | lib/cassie/statements/execution/fetching.rb | Cassie::Statements::Execution.Fetching.fetch | def fetch(args={})
args.each do |k, v|
setter = "#{k}="
send(setter, v) if respond_to? setter
end
execute
result
end | ruby | def fetch(args={})
args.each do |k, v|
setter = "#{k}="
send(setter, v) if respond_to? setter
end
execute
result
end | [
"def",
"fetch",
"(",
"args",
"=",
"{",
"}",
")",
"args",
".",
"each",
"do",
"|",
"k",
",",
"v",
"|",
"setter",
"=",
"\"#{k}=\"",
"send",
"(",
"setter",
",",
"v",
")",
"if",
"respond_to?",
"setter",
"end",
"execute",
"result",
"end"
] | Returns array of rows or empty array
query.fetch(id: 1)
=> [{id: 1, name: 'eprothro'}] | [
"Returns",
"array",
"of",
"rows",
"or",
"empty",
"array"
] | 63e71d12d3549882147e715e427a16fd8e0aa210 | https://github.com/eprothro/cassie/blob/63e71d12d3549882147e715e427a16fd8e0aa210/lib/cassie/statements/execution/fetching.rb#L19-L27 | train |
fcheung/corefoundation | lib/corefoundation/base.rb | CF.Base.inspect | def inspect
cf = CF::String.new(CF.CFCopyDescription(self))
cf.to_s.tap {cf.release}
end | ruby | def inspect
cf = CF::String.new(CF.CFCopyDescription(self))
cf.to_s.tap {cf.release}
end | [
"def",
"inspect",
"cf",
"=",
"CF",
"::",
"String",
".",
"new",
"(",
"CF",
".",
"CFCopyDescription",
"(",
"self",
")",
")",
"cf",
".",
"to_s",
".",
"tap",
"{",
"cf",
".",
"release",
"}",
"end"
] | Returns a ruby string containing the output of CFCopyDescription for the wrapped object
@return [String] | [
"Returns",
"a",
"ruby",
"string",
"containing",
"the",
"output",
"of",
"CFCopyDescription",
"for",
"the",
"wrapped",
"object"
] | a5c766359e74f873902d916e9fb051ec7fdedbb9 | https://github.com/fcheung/corefoundation/blob/a5c766359e74f873902d916e9fb051ec7fdedbb9/lib/corefoundation/base.rb#L146-L149 | train |
fcheung/corefoundation | lib/corefoundation/base.rb | CF.Base.equals? | def equals?(other)
if other.is_a?(CF::Base)
@ptr.address == other.to_ptr.address
else
false
end
end | ruby | def equals?(other)
if other.is_a?(CF::Base)
@ptr.address == other.to_ptr.address
else
false
end
end | [
"def",
"equals?",
"(",
"other",
")",
"if",
"other",
".",
"is_a?",
"(",
"CF",
"::",
"Base",
")",
"@ptr",
".",
"address",
"==",
"other",
".",
"to_ptr",
".",
"address",
"else",
"false",
"end",
"end"
] | Uses CFHash to return a hash code
@return [Integer]
eql? (and ==) are implemented using CFEqual
equals? is defined as returning true if the wrapped pointer is the same | [
"Uses",
"CFHash",
"to",
"return",
"a",
"hash",
"code"
] | a5c766359e74f873902d916e9fb051ec7fdedbb9 | https://github.com/fcheung/corefoundation/blob/a5c766359e74f873902d916e9fb051ec7fdedbb9/lib/corefoundation/base.rb#L172-L178 | train |
bachya/cliutils | lib/cliutils/pretty_io.rb | CLIUtils.PrettyIO.color_chart | def color_chart
[0, 1, 4, 5, 7].each do |attr|
puts '----------------------------------------------------------------'
puts "ESC[#{attr};Foreground;Background"
30.upto(37) do |fg|
40.upto(47) do |bg|
print "\033[#{attr};#{fg};#{bg}m #{fg};#{bg} "
end
... | ruby | def color_chart
[0, 1, 4, 5, 7].each do |attr|
puts '----------------------------------------------------------------'
puts "ESC[#{attr};Foreground;Background"
30.upto(37) do |fg|
40.upto(47) do |bg|
print "\033[#{attr};#{fg};#{bg}m #{fg};#{bg} "
end
... | [
"def",
"color_chart",
"[",
"0",
",",
"1",
",",
"4",
",",
"5",
",",
"7",
"]",
".",
"each",
"do",
"|",
"attr",
"|",
"puts",
"'----------------------------------------------------------------'",
"puts",
"\"ESC[#{attr};Foreground;Background\"",
"30",
".",
"upto",
"(",... | Displays a chart of all the possible ANSI foreground
and background color combinations.
@return [void] | [
"Displays",
"a",
"chart",
"of",
"all",
"the",
"possible",
"ANSI",
"foreground",
"and",
"background",
"color",
"combinations",
"."
] | af5280bcadf7196922ab1bb7285787149cadbb9d | https://github.com/bachya/cliutils/blob/af5280bcadf7196922ab1bb7285787149cadbb9d/lib/cliutils/pretty_io.rb#L28-L39 | train |
lml/lev | lib/lev/handler.rb | Lev.Handler.validate_paramified_params | def validate_paramified_params
self.class.paramify_methods.each do |method|
params = send(method)
transfer_errors_from(params, TermMapper.scope(params.group)) if !params.valid?
end
end | ruby | def validate_paramified_params
self.class.paramify_methods.each do |method|
params = send(method)
transfer_errors_from(params, TermMapper.scope(params.group)) if !params.valid?
end
end | [
"def",
"validate_paramified_params",
"self",
".",
"class",
".",
"paramify_methods",
".",
"each",
"do",
"|",
"method",
"|",
"params",
"=",
"send",
"(",
"method",
")",
"transfer_errors_from",
"(",
"params",
",",
"TermMapper",
".",
"scope",
"(",
"params",
".",
... | Helper method to validate paramified params and to transfer any errors
into the handler. | [
"Helper",
"method",
"to",
"validate",
"paramified",
"params",
"and",
"to",
"transfer",
"any",
"errors",
"into",
"the",
"handler",
"."
] | ce39ac122796974dafb24ee61428540dacf34371 | https://github.com/lml/lev/blob/ce39ac122796974dafb24ee61428540dacf34371/lib/lev/handler.rb#L222-L227 | train |
GenieBelt/gb-dispatch | lib/gb_dispatch/queue.rb | GBDispatch.Queue.perform_after | def perform_after(time, block=nil)
task = Concurrent::ScheduledTask.new(time) do
block = ->(){ yield } unless block
self.async.perform_now block
end
task.execute
task
end | ruby | def perform_after(time, block=nil)
task = Concurrent::ScheduledTask.new(time) do
block = ->(){ yield } unless block
self.async.perform_now block
end
task.execute
task
end | [
"def",
"perform_after",
"(",
"time",
",",
"block",
"=",
"nil",
")",
"task",
"=",
"Concurrent",
"::",
"ScheduledTask",
".",
"new",
"(",
"time",
")",
"do",
"block",
"=",
"->",
"(",
")",
"{",
"yield",
"}",
"unless",
"block",
"self",
".",
"async",
".",
... | Perform block after given period
@param time [Fixnum]
@param block [Proc]
@yield if there is no block given it yield without param.
@return [Concurrent::ScheduledTask] | [
"Perform",
"block",
"after",
"given",
"period"
] | 6ee932de9b397b96c82271478db1bf5933449e94 | https://github.com/GenieBelt/gb-dispatch/blob/6ee932de9b397b96c82271478db1bf5933449e94/lib/gb_dispatch/queue.rb#L57-L64 | train |
ktemkin/ruby-ise | lib/ise/preference_file.rb | ISE.PreferenceFile.set_by_path | def set_by_path(path, value, target=@ini)
#Split the path into its components.
keys = path.split('/')
#Traverse the path, creating any "folders" necessary along the way.
until keys.one?
target[keys.first] = {} unless target[keys.first].is_a?(Hash)
target = target[keys.shift]
... | ruby | def set_by_path(path, value, target=@ini)
#Split the path into its components.
keys = path.split('/')
#Traverse the path, creating any "folders" necessary along the way.
until keys.one?
target[keys.first] = {} unless target[keys.first].is_a?(Hash)
target = target[keys.shift]
... | [
"def",
"set_by_path",
"(",
"path",
",",
"value",
",",
"target",
"=",
"@ini",
")",
"#Split the path into its components.",
"keys",
"=",
"path",
".",
"split",
"(",
"'/'",
")",
"#Traverse the path, creating any \"folders\" necessary along the way.",
"until",
"keys",
".",
... | Sets the value of a key in a hash-of-hashes via a unix-style path.
path: The path to the target key, in a unix-style path structure. See example below.
value: The value to put into the key.
target: The hash to operate on. If target isn't provided, we work with the base INI.
Example:
set_by_path('foo/bar/tab',... | [
"Sets",
"the",
"value",
"of",
"a",
"key",
"in",
"a",
"hash",
"-",
"of",
"-",
"hashes",
"via",
"a",
"unix",
"-",
"style",
"path",
"."
] | db34c9bac5f9986ee4d2750e314dac4b6f139a24 | https://github.com/ktemkin/ruby-ise/blob/db34c9bac5f9986ee4d2750e314dac4b6f139a24/lib/ise/preference_file.rb#L46-L60 | train |
ktemkin/ruby-ise | lib/ise/preference_file.rb | ISE.PreferenceFile.get_by_path | def get_by_path(path, target=@ini)
#Split the path into its components...
keys = path.split('/')
#And traverse the hasn until we've fully navigated the path.
target = target[keys.shift] until keys.empty?
#Returns the final value.
target
end | ruby | def get_by_path(path, target=@ini)
#Split the path into its components...
keys = path.split('/')
#And traverse the hasn until we've fully navigated the path.
target = target[keys.shift] until keys.empty?
#Returns the final value.
target
end | [
"def",
"get_by_path",
"(",
"path",
",",
"target",
"=",
"@ini",
")",
"#Split the path into its components...",
"keys",
"=",
"path",
".",
"split",
"(",
"'/'",
")",
"#And traverse the hasn until we've fully navigated the path.",
"target",
"=",
"target",
"[",
"keys",
".",... | Gets the value of a key in a hash-of-hashes via a unix-style path.
path: The path to the target key, in a unix-style path structure. See example below.
target: The hash to operate on. If target isn't provided, we work with the base INI.
Example:
set_by_path('foo/bar/tab', 3, a) would set
a[foo][bar][tab] = ... | [
"Gets",
"the",
"value",
"of",
"a",
"key",
"in",
"a",
"hash",
"-",
"of",
"-",
"hashes",
"via",
"a",
"unix",
"-",
"style",
"path",
"."
] | db34c9bac5f9986ee4d2750e314dac4b6f139a24 | https://github.com/ktemkin/ruby-ise/blob/db34c9bac5f9986ee4d2750e314dac4b6f139a24/lib/ise/preference_file.rb#L74-L85 | train |
ktemkin/ruby-ise | lib/ise/preference_file.rb | ISE.PreferenceFile.process_property | def process_property(property, value)
value.chomp!
#If either the property or value are empty (or contain invalid whitespace),
#abort.
return if property.empty? and value.empty?
return if value.sub!(%r/\\\s*\z/, '')
#Strip any leading/trailing characters.
property.stri... | ruby | def process_property(property, value)
value.chomp!
#If either the property or value are empty (or contain invalid whitespace),
#abort.
return if property.empty? and value.empty?
return if value.sub!(%r/\\\s*\z/, '')
#Strip any leading/trailing characters.
property.stri... | [
"def",
"process_property",
"(",
"property",
",",
"value",
")",
"value",
".",
"chomp!",
"#If either the property or value are empty (or contain invalid whitespace),",
"#abort.",
"return",
"if",
"property",
".",
"empty?",
"and",
"value",
".",
"empty?",
"return",
"if",
"va... | Processes a given name-value pair, adding them
to the current INI database.
Code taken from the 'inifile' gem. | [
"Processes",
"a",
"given",
"name",
"-",
"value",
"pair",
"adding",
"them",
"to",
"the",
"current",
"INI",
"database",
"."
] | db34c9bac5f9986ee4d2750e314dac4b6f139a24 | https://github.com/ktemkin/ruby-ise/blob/db34c9bac5f9986ee4d2750e314dac4b6f139a24/lib/ise/preference_file.rb#L93-L119 | train |
Falkor/falkorlib | lib/falkorlib/git/base.rb | FalkorLib.Git.init? | def init?(path = Dir.pwd)
begin
MiniGit.new(path)
rescue Exception
return false
end
true
end | ruby | def init?(path = Dir.pwd)
begin
MiniGit.new(path)
rescue Exception
return false
end
true
end | [
"def",
"init?",
"(",
"path",
"=",
"Dir",
".",
"pwd",
")",
"begin",
"MiniGit",
".",
"new",
"(",
"path",
")",
"rescue",
"Exception",
"return",
"false",
"end",
"true",
"end"
] | Check if a git directory has been initialized | [
"Check",
"if",
"a",
"git",
"directory",
"has",
"been",
"initialized"
] | 1a6d732e8fd5550efb7c98a87ee97fcd2e051858 | https://github.com/Falkor/falkorlib/blob/1a6d732e8fd5550efb7c98a87ee97fcd2e051858/lib/falkorlib/git/base.rb#L40-L47 | train |
Falkor/falkorlib | lib/falkorlib/git/base.rb | FalkorLib.Git.commits? | def commits?(path)
res = false
Dir.chdir(path) do
_stdout, _stderr, exit_status = Open3.capture3( "git rev-parse HEAD" )
res = (exit_status.to_i.zero?)
end
res
end | ruby | def commits?(path)
res = false
Dir.chdir(path) do
_stdout, _stderr, exit_status = Open3.capture3( "git rev-parse HEAD" )
res = (exit_status.to_i.zero?)
end
res
end | [
"def",
"commits?",
"(",
"path",
")",
"res",
"=",
"false",
"Dir",
".",
"chdir",
"(",
"path",
")",
"do",
"_stdout",
",",
"_stderr",
",",
"exit_status",
"=",
"Open3",
".",
"capture3",
"(",
"\"git rev-parse HEAD\"",
")",
"res",
"=",
"(",
"exit_status",
".",
... | Check if the repositories already holds some commits | [
"Check",
"if",
"the",
"repositories",
"already",
"holds",
"some",
"commits"
] | 1a6d732e8fd5550efb7c98a87ee97fcd2e051858 | https://github.com/Falkor/falkorlib/blob/1a6d732e8fd5550efb7c98a87ee97fcd2e051858/lib/falkorlib/git/base.rb#L50-L57 | train |
Falkor/falkorlib | lib/falkorlib/git/base.rb | FalkorLib.Git.command? | def command?(cmd)
cg = MiniGit::Capturing.new
cmd_list = cg.help :a => true
# typical run:
# usage: git [--version] [--help] [-C <path>] [-c name=value]
# [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
# [-p|--paginate|--no-pager] [--no-replace-... | ruby | def command?(cmd)
cg = MiniGit::Capturing.new
cmd_list = cg.help :a => true
# typical run:
# usage: git [--version] [--help] [-C <path>] [-c name=value]
# [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
# [-p|--paginate|--no-pager] [--no-replace-... | [
"def",
"command?",
"(",
"cmd",
")",
"cg",
"=",
"MiniGit",
"::",
"Capturing",
".",
"new",
"cmd_list",
"=",
"cg",
".",
"help",
":a",
"=>",
"true",
"# typical run:",
"# usage: git [--version] [--help] [-C <path>] [-c name=value]",
"# [--exec-path[=<path>]] [--html... | Check the availability of a given git command | [
"Check",
"the",
"availability",
"of",
"a",
"given",
"git",
"command"
] | 1a6d732e8fd5550efb7c98a87ee97fcd2e051858 | https://github.com/Falkor/falkorlib/blob/1a6d732e8fd5550efb7c98a87ee97fcd2e051858/lib/falkorlib/git/base.rb#L60-L86 | train |
Falkor/falkorlib | lib/falkorlib/git/base.rb | FalkorLib.Git.init | def init(path = Dir.pwd, _options = {})
# FIXME: for travis test: ensure the global git configurations
# 'user.email' and 'user.name' are set
[ 'user.name', 'user.email' ].each do |userconf|
next unless MiniGit[userconf].nil?
warn "The Git global configuration '#{userconf}' is not set ... | ruby | def init(path = Dir.pwd, _options = {})
# FIXME: for travis test: ensure the global git configurations
# 'user.email' and 'user.name' are set
[ 'user.name', 'user.email' ].each do |userconf|
next unless MiniGit[userconf].nil?
warn "The Git global configuration '#{userconf}' is not set ... | [
"def",
"init",
"(",
"path",
"=",
"Dir",
".",
"pwd",
",",
"_options",
"=",
"{",
"}",
")",
"# FIXME: for travis test: ensure the global git configurations",
"# 'user.email' and 'user.name' are set",
"[",
"'user.name'",
",",
"'user.email'",
"]",
".",
"each",
"do",
"|",
... | Initialize a git repository | [
"Initialize",
"a",
"git",
"repository"
] | 1a6d732e8fd5550efb7c98a87ee97fcd2e051858 | https://github.com/Falkor/falkorlib/blob/1a6d732e8fd5550efb7c98a87ee97fcd2e051858/lib/falkorlib/git/base.rb#L91-L117 | train |
Falkor/falkorlib | lib/falkorlib/git/base.rb | FalkorLib.Git.create_branch | def create_branch(branch, path = Dir.pwd)
#ap method(__method__).parameters.map { |arg| arg[1] }
g = MiniGit.new(path)
error "not yet any commit performed -- You shall do one" unless commits?(path)
g.branch branch.to_s
end | ruby | def create_branch(branch, path = Dir.pwd)
#ap method(__method__).parameters.map { |arg| arg[1] }
g = MiniGit.new(path)
error "not yet any commit performed -- You shall do one" unless commits?(path)
g.branch branch.to_s
end | [
"def",
"create_branch",
"(",
"branch",
",",
"path",
"=",
"Dir",
".",
"pwd",
")",
"#ap method(__method__).parameters.map { |arg| arg[1] }",
"g",
"=",
"MiniGit",
".",
"new",
"(",
"path",
")",
"error",
"\"not yet any commit performed -- You shall do one\"",
"unless",
"comm... | Create a new branch | [
"Create",
"a",
"new",
"branch"
] | 1a6d732e8fd5550efb7c98a87ee97fcd2e051858 | https://github.com/Falkor/falkorlib/blob/1a6d732e8fd5550efb7c98a87ee97fcd2e051858/lib/falkorlib/git/base.rb#L132-L137 | train |
Falkor/falkorlib | lib/falkorlib/git/base.rb | FalkorLib.Git.delete_branch | def delete_branch(branch, path = Dir.pwd, opts = { :force => false })
g = MiniGit.new(path)
error "'#{branch}' is not a valid existing branch" unless list_branch(path).include?( branch )
g.branch ((opts[:force]) ? :D : :d) => branch.to_s
end | ruby | def delete_branch(branch, path = Dir.pwd, opts = { :force => false })
g = MiniGit.new(path)
error "'#{branch}' is not a valid existing branch" unless list_branch(path).include?( branch )
g.branch ((opts[:force]) ? :D : :d) => branch.to_s
end | [
"def",
"delete_branch",
"(",
"branch",
",",
"path",
"=",
"Dir",
".",
"pwd",
",",
"opts",
"=",
"{",
":force",
"=>",
"false",
"}",
")",
"g",
"=",
"MiniGit",
".",
"new",
"(",
"path",
")",
"error",
"\"'#{branch}' is not a valid existing branch\"",
"unless",
"l... | Delete a branch. | [
"Delete",
"a",
"branch",
"."
] | 1a6d732e8fd5550efb7c98a87ee97fcd2e051858 | https://github.com/Falkor/falkorlib/blob/1a6d732e8fd5550efb7c98a87ee97fcd2e051858/lib/falkorlib/git/base.rb#L140-L144 | train |
Falkor/falkorlib | lib/falkorlib/git/base.rb | FalkorLib.Git.grab | def grab(branch, path = Dir.pwd, remote = 'origin')
exit_status = 1
error "no branch provided" if branch.nil?
#remotes = FalkorLib::Git.remotes(path)
branches = FalkorLib::Git.list_branch(path)
if branches.include? "remotes/#{remote}/#{branch}"
info "Grab the branch '#{remote}/#{b... | ruby | def grab(branch, path = Dir.pwd, remote = 'origin')
exit_status = 1
error "no branch provided" if branch.nil?
#remotes = FalkorLib::Git.remotes(path)
branches = FalkorLib::Git.list_branch(path)
if branches.include? "remotes/#{remote}/#{branch}"
info "Grab the branch '#{remote}/#{b... | [
"def",
"grab",
"(",
"branch",
",",
"path",
"=",
"Dir",
".",
"pwd",
",",
"remote",
"=",
"'origin'",
")",
"exit_status",
"=",
"1",
"error",
"\"no branch provided\"",
"if",
"branch",
".",
"nil?",
"#remotes = FalkorLib::Git.remotes(path)",
"branches",
"=",
"FalkorL... | Grab a remote branch | [
"Grab",
"a",
"remote",
"branch"
] | 1a6d732e8fd5550efb7c98a87ee97fcd2e051858 | https://github.com/Falkor/falkorlib/blob/1a6d732e8fd5550efb7c98a87ee97fcd2e051858/lib/falkorlib/git/base.rb#L199-L211 | train |
Falkor/falkorlib | lib/falkorlib/git/base.rb | FalkorLib.Git.publish | def publish(branch, path = Dir.pwd, remote = 'origin')
exit_status = 1
error "no branch provided" if branch.nil?
#remotes = FalkorLib::Git.remotes(path)
branches = FalkorLib::Git.list_branch(path)
Dir.chdir(FalkorLib::Git.rootdir( path ) ) do
if branches.include? "remotes/#{remote... | ruby | def publish(branch, path = Dir.pwd, remote = 'origin')
exit_status = 1
error "no branch provided" if branch.nil?
#remotes = FalkorLib::Git.remotes(path)
branches = FalkorLib::Git.list_branch(path)
Dir.chdir(FalkorLib::Git.rootdir( path ) ) do
if branches.include? "remotes/#{remote... | [
"def",
"publish",
"(",
"branch",
",",
"path",
"=",
"Dir",
".",
"pwd",
",",
"remote",
"=",
"'origin'",
")",
"exit_status",
"=",
"1",
"error",
"\"no branch provided\"",
"if",
"branch",
".",
"nil?",
"#remotes = FalkorLib::Git.remotes(path)",
"branches",
"=",
"Falk... | Publish a branch on the remote | [
"Publish",
"a",
"branch",
"on",
"the",
"remote"
] | 1a6d732e8fd5550efb7c98a87ee97fcd2e051858 | https://github.com/Falkor/falkorlib/blob/1a6d732e8fd5550efb7c98a87ee97fcd2e051858/lib/falkorlib/git/base.rb#L214-L232 | train |
Falkor/falkorlib | lib/falkorlib/git/base.rb | FalkorLib.Git.list_files | def list_files(path = Dir.pwd)
g = MiniGit.new(path)
g.capturing.ls_files.split
end | ruby | def list_files(path = Dir.pwd)
g = MiniGit.new(path)
g.capturing.ls_files.split
end | [
"def",
"list_files",
"(",
"path",
"=",
"Dir",
".",
"pwd",
")",
"g",
"=",
"MiniGit",
".",
"new",
"(",
"path",
")",
"g",
".",
"capturing",
".",
"ls_files",
".",
"split",
"end"
] | List the files currently under version | [
"List",
"the",
"files",
"currently",
"under",
"version"
] | 1a6d732e8fd5550efb7c98a87ee97fcd2e051858 | https://github.com/Falkor/falkorlib/blob/1a6d732e8fd5550efb7c98a87ee97fcd2e051858/lib/falkorlib/git/base.rb#L235-L238 | train |
Falkor/falkorlib | lib/falkorlib/git/base.rb | FalkorLib.Git.last_tag_commit | def last_tag_commit(path = Dir.pwd)
res = ""
g = MiniGit.new(path)
unless (g.capturing.tag :list => true).empty?
# git rev-list --tags --max-count=1
res = (g.capturing.rev_list :tags => true, :max_count => 1).chomp
end
res
end | ruby | def last_tag_commit(path = Dir.pwd)
res = ""
g = MiniGit.new(path)
unless (g.capturing.tag :list => true).empty?
# git rev-list --tags --max-count=1
res = (g.capturing.rev_list :tags => true, :max_count => 1).chomp
end
res
end | [
"def",
"last_tag_commit",
"(",
"path",
"=",
"Dir",
".",
"pwd",
")",
"res",
"=",
"\"\"",
"g",
"=",
"MiniGit",
".",
"new",
"(",
"path",
")",
"unless",
"(",
"g",
".",
"capturing",
".",
"tag",
":list",
"=>",
"true",
")",
".",
"empty?",
"# git rev-list --... | list_tag
Get the last tag commit, or nil if no tag can be found | [
"list_tag",
"Get",
"the",
"last",
"tag",
"commit",
"or",
"nil",
"if",
"no",
"tag",
"can",
"be",
"found"
] | 1a6d732e8fd5550efb7c98a87ee97fcd2e051858 | https://github.com/Falkor/falkorlib/blob/1a6d732e8fd5550efb7c98a87ee97fcd2e051858/lib/falkorlib/git/base.rb#L282-L290 | train |
Falkor/falkorlib | lib/falkorlib/git/base.rb | FalkorLib.Git.remotes | def remotes(path = Dir.pwd)
g = MiniGit.new(path)
g.capturing.remote.split
end | ruby | def remotes(path = Dir.pwd)
g = MiniGit.new(path)
g.capturing.remote.split
end | [
"def",
"remotes",
"(",
"path",
"=",
"Dir",
".",
"pwd",
")",
"g",
"=",
"MiniGit",
".",
"new",
"(",
"path",
")",
"g",
".",
"capturing",
".",
"remote",
".",
"split",
"end"
] | tag
List of Git remotes | [
"tag",
"List",
"of",
"Git",
"remotes"
] | 1a6d732e8fd5550efb7c98a87ee97fcd2e051858 | https://github.com/Falkor/falkorlib/blob/1a6d732e8fd5550efb7c98a87ee97fcd2e051858/lib/falkorlib/git/base.rb#L303-L306 | train |
Falkor/falkorlib | lib/falkorlib/git/base.rb | FalkorLib.Git.subtree_init? | def subtree_init?(path = Dir.pwd)
res = true
FalkorLib.config.git[:subtrees].keys.each do |dir|
res &&= File.directory?(File.join(path, dir))
end
res
end | ruby | def subtree_init?(path = Dir.pwd)
res = true
FalkorLib.config.git[:subtrees].keys.each do |dir|
res &&= File.directory?(File.join(path, dir))
end
res
end | [
"def",
"subtree_init?",
"(",
"path",
"=",
"Dir",
".",
"pwd",
")",
"res",
"=",
"true",
"FalkorLib",
".",
"config",
".",
"git",
"[",
":subtrees",
"]",
".",
"keys",
".",
"each",
"do",
"|",
"dir",
"|",
"res",
"&&=",
"File",
".",
"directory?",
"(",
"Fil... | Check if the subtrees have been initialized.
Actually based on a naive check of sub-directory existence | [
"Check",
"if",
"the",
"subtrees",
"have",
"been",
"initialized",
".",
"Actually",
"based",
"on",
"a",
"naive",
"check",
"of",
"sub",
"-",
"directory",
"existence"
] | 1a6d732e8fd5550efb7c98a87ee97fcd2e051858 | https://github.com/Falkor/falkorlib/blob/1a6d732e8fd5550efb7c98a87ee97fcd2e051858/lib/falkorlib/git/base.rb#L414-L420 | train |
Falkor/falkorlib | lib/falkorlib/git/base.rb | FalkorLib.Git.subtree_up | def subtree_up(path = Dir.pwd)
error "Unable to pull subtree(s): Dirty Git repository" if FalkorLib::Git.dirty?( path )
exit_status = 0
git_root_dir = rootdir(path)
Dir.chdir(git_root_dir) do
FalkorLib.config.git[:subtrees].each do |dir, conf|
next if conf[:url].nil?
... | ruby | def subtree_up(path = Dir.pwd)
error "Unable to pull subtree(s): Dirty Git repository" if FalkorLib::Git.dirty?( path )
exit_status = 0
git_root_dir = rootdir(path)
Dir.chdir(git_root_dir) do
FalkorLib.config.git[:subtrees].each do |dir, conf|
next if conf[:url].nil?
... | [
"def",
"subtree_up",
"(",
"path",
"=",
"Dir",
".",
"pwd",
")",
"error",
"\"Unable to pull subtree(s): Dirty Git repository\"",
"if",
"FalkorLib",
"::",
"Git",
".",
"dirty?",
"(",
"path",
")",
"exit_status",
"=",
"0",
"git_root_dir",
"=",
"rootdir",
"(",
"path",
... | Pull the latest changes, assuming the git repository is not dirty | [
"Pull",
"the",
"latest",
"changes",
"assuming",
"the",
"git",
"repository",
"is",
"not",
"dirty"
] | 1a6d732e8fd5550efb7c98a87ee97fcd2e051858 | https://github.com/Falkor/falkorlib/blob/1a6d732e8fd5550efb7c98a87ee97fcd2e051858/lib/falkorlib/git/base.rb#L449-L471 | train |
devs-ruby/devs | lib/devs/schedulers/calendar_queue.rb | DEVS.CalendarQueue.local_init | def local_init(bucket_count, bucket_width, start_priority)
@width = bucket_width
old = @buckets
@buckets = if @cached_buckets == nil
Array.new(bucket_count) { [] }
else
n = @cached_buckets.size
if bucket_count < n
# shrink the array
@cached_buckets.sli... | ruby | def local_init(bucket_count, bucket_width, start_priority)
@width = bucket_width
old = @buckets
@buckets = if @cached_buckets == nil
Array.new(bucket_count) { [] }
else
n = @cached_buckets.size
if bucket_count < n
# shrink the array
@cached_buckets.sli... | [
"def",
"local_init",
"(",
"bucket_count",
",",
"bucket_width",
",",
"start_priority",
")",
"@width",
"=",
"bucket_width",
"old",
"=",
"@buckets",
"@buckets",
"=",
"if",
"@cached_buckets",
"==",
"nil",
"Array",
".",
"new",
"(",
"bucket_count",
")",
"{",
"[",
... | Initializes a bucket array within | [
"Initializes",
"a",
"bucket",
"array",
"within"
] | 767212b3825068a82ada4ddaabe0a4e3a8144817 | https://github.com/devs-ruby/devs/blob/767212b3825068a82ada4ddaabe0a4e3a8144817/lib/devs/schedulers/calendar_queue.rb#L231-L257 | train |
devs-ruby/devs | lib/devs/schedulers/calendar_queue.rb | DEVS.CalendarQueue.resize | def resize(new_size)
return unless @resize_enabled
bucket_width = new_width # find new bucket width
local_init(new_size, bucket_width, @last_priority)
i = 0
while i < @cached_buckets.size
bucket = @cached_buckets[i]
@size -= bucket.size
while obj = bucket.pop
... | ruby | def resize(new_size)
return unless @resize_enabled
bucket_width = new_width # find new bucket width
local_init(new_size, bucket_width, @last_priority)
i = 0
while i < @cached_buckets.size
bucket = @cached_buckets[i]
@size -= bucket.size
while obj = bucket.pop
... | [
"def",
"resize",
"(",
"new_size",
")",
"return",
"unless",
"@resize_enabled",
"bucket_width",
"=",
"new_width",
"# find new bucket width",
"local_init",
"(",
"new_size",
",",
"bucket_width",
",",
"@last_priority",
")",
"i",
"=",
"0",
"while",
"i",
"<",
"@cached_bu... | Resize buckets to new_size. | [
"Resize",
"buckets",
"to",
"new_size",
"."
] | 767212b3825068a82ada4ddaabe0a4e3a8144817 | https://github.com/devs-ruby/devs/blob/767212b3825068a82ada4ddaabe0a4e3a8144817/lib/devs/schedulers/calendar_queue.rb#L260-L275 | train |
devs-ruby/devs | lib/devs/schedulers/calendar_queue.rb | DEVS.CalendarQueue.new_width | def new_width
# decides how many queue elements to sample
return 1.0 if @size < 2
n = if @size <= 5
@size
else
5 + (@size / 10).to_i
end
n = 25 if n > 25
# record variables
tmp_last_bucket = @last_bucket
tmp_last_priority = @last_priority
tmp_... | ruby | def new_width
# decides how many queue elements to sample
return 1.0 if @size < 2
n = if @size <= 5
@size
else
5 + (@size / 10).to_i
end
n = 25 if n > 25
# record variables
tmp_last_bucket = @last_bucket
tmp_last_priority = @last_priority
tmp_... | [
"def",
"new_width",
"# decides how many queue elements to sample",
"return",
"1.0",
"if",
"@size",
"<",
"2",
"n",
"=",
"if",
"@size",
"<=",
"5",
"@size",
"else",
"5",
"+",
"(",
"@size",
"/",
"10",
")",
".",
"to_i",
"end",
"n",
"=",
"25",
"if",
"n",
">"... | Calculates the width to use for buckets | [
"Calculates",
"the",
"width",
"to",
"use",
"for",
"buckets"
] | 767212b3825068a82ada4ddaabe0a4e3a8144817 | https://github.com/devs-ruby/devs/blob/767212b3825068a82ada4ddaabe0a4e3a8144817/lib/devs/schedulers/calendar_queue.rb#L278-L344 | train |
devs-ruby/devs | lib/devs/simulation.rb | DEVS.Simulation.transition_stats | def transition_stats
if done?
@transition_stats ||= (
stats = {}
hierarchy = @processor.children.dup
i = 0
while i < hierarchy.size
child = hierarchy[i]
if child.model.coupled?
hierarchy.concat(child.children)
else
... | ruby | def transition_stats
if done?
@transition_stats ||= (
stats = {}
hierarchy = @processor.children.dup
i = 0
while i < hierarchy.size
child = hierarchy[i]
if child.model.coupled?
hierarchy.concat(child.children)
else
... | [
"def",
"transition_stats",
"if",
"done?",
"@transition_stats",
"||=",
"(",
"stats",
"=",
"{",
"}",
"hierarchy",
"=",
"@processor",
".",
"children",
".",
"dup",
"i",
"=",
"0",
"while",
"i",
"<",
"hierarchy",
".",
"size",
"child",
"=",
"hierarchy",
"[",
"i... | Returns the number of transitions per model along with the total
@return [Hash<Symbol, Fixnum>] | [
"Returns",
"the",
"number",
"of",
"transitions",
"per",
"model",
"along",
"with",
"the",
"total"
] | 767212b3825068a82ada4ddaabe0a4e3a8144817 | https://github.com/devs-ruby/devs/blob/767212b3825068a82ada4ddaabe0a4e3a8144817/lib/devs/simulation.rb#L163-L184 | train |
robertwahler/repo_manager | lib/repo_manager/views/base_view.rb | RepoManager.BaseView.partial | def partial(filename)
filename = partial_path(filename)
raise "unable to find partial file: #{filename}" unless File.exists?(filename)
contents = File.open(filename, "rb") {|f| f.read}
# TODO: detect template EOL and match it to the partial's EOL
# force unix eol
contents.gsub!(/\r\n... | ruby | def partial(filename)
filename = partial_path(filename)
raise "unable to find partial file: #{filename}" unless File.exists?(filename)
contents = File.open(filename, "rb") {|f| f.read}
# TODO: detect template EOL and match it to the partial's EOL
# force unix eol
contents.gsub!(/\r\n... | [
"def",
"partial",
"(",
"filename",
")",
"filename",
"=",
"partial_path",
"(",
"filename",
")",
"raise",
"\"unable to find partial file: #{filename}\"",
"unless",
"File",
".",
"exists?",
"(",
"filename",
")",
"contents",
"=",
"File",
".",
"open",
"(",
"filename",
... | render a partial
filename: unless absolute, it will be relative to the main template
@example slim escapes HTML, use '=='
head
== render 'mystyle.css'
@return [String] of non-escaped textual content | [
"render",
"a",
"partial"
] | d945f1cb6ac48b5689b633fcc029fd77c6a02d09 | https://github.com/robertwahler/repo_manager/blob/d945f1cb6ac48b5689b633fcc029fd77c6a02d09/lib/repo_manager/views/base_view.rb#L86-L94 | train |
robertwahler/repo_manager | lib/repo_manager/views/base_view.rb | RepoManager.BaseView.partial_path | def partial_path(filename)
return filename if filename.nil? || Pathname.new(filename).absolute?
# try relative to template
if template
base_folder = File.dirname(template)
filename = File.expand_path(File.join(base_folder, filename))
return filename if File.exists?(filename)
... | ruby | def partial_path(filename)
return filename if filename.nil? || Pathname.new(filename).absolute?
# try relative to template
if template
base_folder = File.dirname(template)
filename = File.expand_path(File.join(base_folder, filename))
return filename if File.exists?(filename)
... | [
"def",
"partial_path",
"(",
"filename",
")",
"return",
"filename",
"if",
"filename",
".",
"nil?",
"||",
"Pathname",
".",
"new",
"(",
"filename",
")",
".",
"absolute?",
"# try relative to template",
"if",
"template",
"base_folder",
"=",
"File",
".",
"dirname",
... | full expanded path to the given partial | [
"full",
"expanded",
"path",
"to",
"the",
"given",
"partial"
] | d945f1cb6ac48b5689b633fcc029fd77c6a02d09 | https://github.com/robertwahler/repo_manager/blob/d945f1cb6ac48b5689b633fcc029fd77c6a02d09/lib/repo_manager/views/base_view.rb#L118-L134 | train |
abarrak/network-client | lib/network/client.rb | Network.Client.set_logger | def set_logger
@logger = if block_given?
yield
elsif defined?(Rails)
Rails.logger
else
logger = Logger.new(STDOUT)
logger.level = Logger::DEBUG
logger
end
end | ruby | def set_logger
@logger = if block_given?
yield
elsif defined?(Rails)
Rails.logger
else
logger = Logger.new(STDOUT)
logger.level = Logger::DEBUG
logger
end
end | [
"def",
"set_logger",
"@logger",
"=",
"if",
"block_given?",
"yield",
"elsif",
"defined?",
"(",
"Rails",
")",
"Rails",
".",
"logger",
"else",
"logger",
"=",
"Logger",
".",
"new",
"(",
"STDOUT",
")",
"logger",
".",
"level",
"=",
"Logger",
"::",
"DEBUG",
"lo... | Sets the client logger object.
Execution is yielded to passed +block+ to set, customize, and returning a logger instance.
== Returns:
+logger+ instance variable. | [
"Sets",
"the",
"client",
"logger",
"object",
".",
"Execution",
"is",
"yielded",
"to",
"passed",
"+",
"block",
"+",
"to",
"set",
"customize",
"and",
"returning",
"a",
"logger",
"instance",
"."
] | 4cf898be318bb4df056f82d405ba9ce09d3f59ac | https://github.com/abarrak/network-client/blob/4cf898be318bb4df056f82d405ba9ce09d3f59ac/lib/network/client.rb#L168-L178 | train |
pwnieexpress/snapi | lib/snapi/validator.rb | Snapi.Validator.valid_input? | def valid_input?(key,string)
raise InvalidFormatError unless valid_regex_format?(key)
boolarray = validation_regex[key].map do |regxp|
(string =~ regxp) == 0 ? true : false
end
return true if boolarray.include?(true)
false
end | ruby | def valid_input?(key,string)
raise InvalidFormatError unless valid_regex_format?(key)
boolarray = validation_regex[key].map do |regxp|
(string =~ regxp) == 0 ? true : false
end
return true if boolarray.include?(true)
false
end | [
"def",
"valid_input?",
"(",
"key",
",",
"string",
")",
"raise",
"InvalidFormatError",
"unless",
"valid_regex_format?",
"(",
"key",
")",
"boolarray",
"=",
"validation_regex",
"[",
"key",
"]",
".",
"map",
"do",
"|",
"regxp",
"|",
"(",
"string",
"=~",
"regxp",
... | Core method of the module which attempts to check if a provided
string matches any of the regex's as identified by the key
@params key, Symbol key which maps to one of the keys in the validation_regex method below
@params string, String to check
@returns Boolean, true if string checks out | [
"Core",
"method",
"of",
"the",
"module",
"which",
"attempts",
"to",
"check",
"if",
"a",
"provided",
"string",
"matches",
"any",
"of",
"the",
"regex",
"s",
"as",
"identified",
"by",
"the",
"key"
] | 3c2a6fe454721945e4e58b8b496d3c20ada55df7 | https://github.com/pwnieexpress/snapi/blob/3c2a6fe454721945e4e58b8b496d3c20ada55df7/lib/snapi/validator.rb#L14-L23 | train |
pwnieexpress/snapi | lib/snapi/validator.rb | Snapi.Validator.validation_regex | def validation_regex
{
:address => [HOSTNAME_REGEX, DOMAIN_REGEX, IP_V4_REGEX, IP_V6_REGEX],
:anything => [/.*/],
:bool => [TRUEFALSE_REGEX],
:command => [SIMPLE_COMMAND_REGEX],
:gsm_adapter => [ADAPTER_REGEX],
... | ruby | def validation_regex
{
:address => [HOSTNAME_REGEX, DOMAIN_REGEX, IP_V4_REGEX, IP_V6_REGEX],
:anything => [/.*/],
:bool => [TRUEFALSE_REGEX],
:command => [SIMPLE_COMMAND_REGEX],
:gsm_adapter => [ADAPTER_REGEX],
... | [
"def",
"validation_regex",
"{",
":address",
"=>",
"[",
"HOSTNAME_REGEX",
",",
"DOMAIN_REGEX",
",",
"IP_V4_REGEX",
",",
"IP_V6_REGEX",
"]",
",",
":anything",
"=>",
"[",
"/",
"/",
"]",
",",
":bool",
"=>",
"[",
"TRUEFALSE_REGEX",
"]",
",",
":command",
"=>",
"... | A helper dictionary which returns and array of valid Regexp patterns
in exchange for a valid key
@returns Hash, dictionary of symbols and Regexp arrays | [
"A",
"helper",
"dictionary",
"which",
"returns",
"and",
"array",
"of",
"valid",
"Regexp",
"patterns",
"in",
"exchange",
"for",
"a",
"valid",
"key"
] | 3c2a6fe454721945e4e58b8b496d3c20ada55df7 | https://github.com/pwnieexpress/snapi/blob/3c2a6fe454721945e4e58b8b496d3c20ada55df7/lib/snapi/validator.rb#L45-L64 | train |
robertwahler/repo_manager | lib/repo_manager/tasks/task_manager.rb | RepoManager.TaskManager.load_tasks | def load_tasks
return if @loaded
# By convention, the '*_helper.rb' files are helpers and need to be loaded first. Load
# them into the Thor::Sandbox namespace
Dir.glob( File.join(File.dirname(__FILE__), '**', '*.rb') ).each do |task|
if task.match(/_helper\.rb$/)
#logger.deb... | ruby | def load_tasks
return if @loaded
# By convention, the '*_helper.rb' files are helpers and need to be loaded first. Load
# them into the Thor::Sandbox namespace
Dir.glob( File.join(File.dirname(__FILE__), '**', '*.rb') ).each do |task|
if task.match(/_helper\.rb$/)
#logger.deb... | [
"def",
"load_tasks",
"return",
"if",
"@loaded",
"# By convention, the '*_helper.rb' files are helpers and need to be loaded first. Load",
"# them into the Thor::Sandbox namespace",
"Dir",
".",
"glob",
"(",
"File",
".",
"join",
"(",
"File",
".",
"dirname",
"(",
"__FILE__",
")"... | load all the tasks in this gem plus the user's own repo_manager task folder
NOTE: doesn't load any default tasks or non-RepoManager tasks | [
"load",
"all",
"the",
"tasks",
"in",
"this",
"gem",
"plus",
"the",
"user",
"s",
"own",
"repo_manager",
"task",
"folder"
] | d945f1cb6ac48b5689b633fcc029fd77c6a02d09 | https://github.com/robertwahler/repo_manager/blob/d945f1cb6ac48b5689b633fcc029fd77c6a02d09/lib/repo_manager/tasks/task_manager.rb#L72-L99 | train |
robertwahler/repo_manager | lib/repo_manager/tasks/task_manager.rb | RepoManager.TaskManager.task_help | def task_help(name)
load_tasks
klass, task = find_by_namespace(name)
# set '$thor_runner' to true to display full namespace
$thor_runner = true
klass.task_help(shell , task)
end | ruby | def task_help(name)
load_tasks
klass, task = find_by_namespace(name)
# set '$thor_runner' to true to display full namespace
$thor_runner = true
klass.task_help(shell , task)
end | [
"def",
"task_help",
"(",
"name",
")",
"load_tasks",
"klass",
",",
"task",
"=",
"find_by_namespace",
"(",
"name",
")",
"# set '$thor_runner' to true to display full namespace",
"$thor_runner",
"=",
"true",
"klass",
".",
"task_help",
"(",
"shell",
",",
"task",
")",
... | display help for the given task | [
"display",
"help",
"for",
"the",
"given",
"task"
] | d945f1cb6ac48b5689b633fcc029fd77c6a02d09 | https://github.com/robertwahler/repo_manager/blob/d945f1cb6ac48b5689b633fcc029fd77c6a02d09/lib/repo_manager/tasks/task_manager.rb#L135-L144 | train |
robertwahler/repo_manager | lib/repo_manager/tasks/task_manager.rb | RepoManager.TaskManager.list_tasks | def list_tasks
load_tasks
# set '$thor_runner' to true to display full namespace
$thor_runner = true
list = [] #Thor.printable_tasks(all = true, subcommand = true)
Thor::Base.subclasses.each do |klass|
list += klass.printable_tasks(false) unless klass == Thor
end
list... | ruby | def list_tasks
load_tasks
# set '$thor_runner' to true to display full namespace
$thor_runner = true
list = [] #Thor.printable_tasks(all = true, subcommand = true)
Thor::Base.subclasses.each do |klass|
list += klass.printable_tasks(false) unless klass == Thor
end
list... | [
"def",
"list_tasks",
"load_tasks",
"# set '$thor_runner' to true to display full namespace",
"$thor_runner",
"=",
"true",
"list",
"=",
"[",
"]",
"#Thor.printable_tasks(all = true, subcommand = true)",
"Thor",
"::",
"Base",
".",
"subclasses",
".",
"each",
"do",
"|",
"klass",... | display a list of tasks for user display | [
"display",
"a",
"list",
"of",
"tasks",
"for",
"user",
"display"
] | d945f1cb6ac48b5689b633fcc029fd77c6a02d09 | https://github.com/robertwahler/repo_manager/blob/d945f1cb6ac48b5689b633fcc029fd77c6a02d09/lib/repo_manager/tasks/task_manager.rb#L147-L163 | train |
robertwahler/repo_manager | lib/repo_manager/tasks/task_manager.rb | RepoManager.TaskManager.list_bare_tasks | def list_bare_tasks
load_tasks
Thor::Base.subclasses.each do |klass|
unless klass == Thor
klass.tasks.each do |t|
puts "#{klass.namespace}:#{t[0]}"
end
end
end
end | ruby | def list_bare_tasks
load_tasks
Thor::Base.subclasses.each do |klass|
unless klass == Thor
klass.tasks.each do |t|
puts "#{klass.namespace}:#{t[0]}"
end
end
end
end | [
"def",
"list_bare_tasks",
"load_tasks",
"Thor",
"::",
"Base",
".",
"subclasses",
".",
"each",
"do",
"|",
"klass",
"|",
"unless",
"klass",
"==",
"Thor",
"klass",
".",
"tasks",
".",
"each",
"do",
"|",
"t",
"|",
"puts",
"\"#{klass.namespace}:#{t[0]}\"",
"end",
... | display a list of tasks for CLI completion | [
"display",
"a",
"list",
"of",
"tasks",
"for",
"CLI",
"completion"
] | d945f1cb6ac48b5689b633fcc029fd77c6a02d09 | https://github.com/robertwahler/repo_manager/blob/d945f1cb6ac48b5689b633fcc029fd77c6a02d09/lib/repo_manager/tasks/task_manager.rb#L166-L176 | train |
tmobaird/GuideboxWrapper | lib/GuideboxWrapper/guidebox_tv.rb | GuideboxWrapper.GuideboxTv.search_for_by_provider | def search_for_by_provider(name, provider)
url = build_query(name)
url += '/fuzzy/' + provider + "/web"
data = @client.query(url)
data["results"]
end | ruby | def search_for_by_provider(name, provider)
url = build_query(name)
url += '/fuzzy/' + provider + "/web"
data = @client.query(url)
data["results"]
end | [
"def",
"search_for_by_provider",
"(",
"name",
",",
"provider",
")",
"url",
"=",
"build_query",
"(",
"name",
")",
"url",
"+=",
"'/fuzzy/'",
"+",
"provider",
"+",
"\"/web\"",
"data",
"=",
"@client",
".",
"query",
"(",
"url",
")",
"data",
"[",
"\"results\"",
... | Search by provider | [
"Search",
"by",
"provider"
] | 431d541141c21620b640dcffee6cf23b3d5ca616 | https://github.com/tmobaird/GuideboxWrapper/blob/431d541141c21620b640dcffee6cf23b3d5ca616/lib/GuideboxWrapper/guidebox_tv.rb#L17-L22 | train |
tmobaird/GuideboxWrapper | lib/GuideboxWrapper/guidebox_tv.rb | GuideboxWrapper.GuideboxTv.search_by_db_id | def search_by_db_id(id, type)
url = @base_url
url += "/search/id/"
case type
when "tvdb"
url += "tvdb/"
url += id.to_s
when "themoviedb"
url += "themoviedb/"
url += id.to_s
when "imdb"
url += "imdb/"
url += id
else
puts "T... | ruby | def search_by_db_id(id, type)
url = @base_url
url += "/search/id/"
case type
when "tvdb"
url += "tvdb/"
url += id.to_s
when "themoviedb"
url += "themoviedb/"
url += id.to_s
when "imdb"
url += "imdb/"
url += id
else
puts "T... | [
"def",
"search_by_db_id",
"(",
"id",
",",
"type",
")",
"url",
"=",
"@base_url",
"url",
"+=",
"\"/search/id/\"",
"case",
"type",
"when",
"\"tvdb\"",
"url",
"+=",
"\"tvdb/\"",
"url",
"+=",
"id",
".",
"to_s",
"when",
"\"themoviedb\"",
"url",
"+=",
"\"themoviedb... | Search for show by external db id | [
"Search",
"for",
"show",
"by",
"external",
"db",
"id"
] | 431d541141c21620b640dcffee6cf23b3d5ca616 | https://github.com/tmobaird/GuideboxWrapper/blob/431d541141c21620b640dcffee6cf23b3d5ca616/lib/GuideboxWrapper/guidebox_tv.rb#L25-L43 | train |
tmobaird/GuideboxWrapper | lib/GuideboxWrapper/guidebox_tv.rb | GuideboxWrapper.GuideboxTv.show_information | def show_information(name)
id = self.search_for(name).first["id"]
url = @base_url
url += "/show/" + id.to_s
@client.query(url)
end | ruby | def show_information(name)
id = self.search_for(name).first["id"]
url = @base_url
url += "/show/" + id.to_s
@client.query(url)
end | [
"def",
"show_information",
"(",
"name",
")",
"id",
"=",
"self",
".",
"search_for",
"(",
"name",
")",
".",
"first",
"[",
"\"id\"",
"]",
"url",
"=",
"@base_url",
"url",
"+=",
"\"/show/\"",
"+",
"id",
".",
"to_s",
"@client",
".",
"query",
"(",
"url",
")... | Get all tv show info | [
"Get",
"all",
"tv",
"show",
"info"
] | 431d541141c21620b640dcffee6cf23b3d5ca616 | https://github.com/tmobaird/GuideboxWrapper/blob/431d541141c21620b640dcffee6cf23b3d5ca616/lib/GuideboxWrapper/guidebox_tv.rb#L66-L71 | train |
devs-ruby/devs | lib/devs/coordinator.rb | DEVS.Coordinator.min_time_next | def min_time_next
tn = DEVS::INFINITY
if (obj = @scheduler.peek)
tn = obj.time_next
end
tn
end | ruby | def min_time_next
tn = DEVS::INFINITY
if (obj = @scheduler.peek)
tn = obj.time_next
end
tn
end | [
"def",
"min_time_next",
"tn",
"=",
"DEVS",
"::",
"INFINITY",
"if",
"(",
"obj",
"=",
"@scheduler",
".",
"peek",
")",
"tn",
"=",
"obj",
".",
"time_next",
"end",
"tn",
"end"
] | Returns the minimum time next in all children
@return [Numeric] the min time next | [
"Returns",
"the",
"minimum",
"time",
"next",
"in",
"all",
"children"
] | 767212b3825068a82ada4ddaabe0a4e3a8144817 | https://github.com/devs-ruby/devs/blob/767212b3825068a82ada4ddaabe0a4e3a8144817/lib/devs/coordinator.rb#L53-L59 | train |
devs-ruby/devs | lib/devs/coordinator.rb | DEVS.Coordinator.max_time_last | def max_time_last
max = 0
i = 0
while i < @children.size
tl = @children[i].time_last
max = tl if tl > max
i += 1
end
max
end | ruby | def max_time_last
max = 0
i = 0
while i < @children.size
tl = @children[i].time_last
max = tl if tl > max
i += 1
end
max
end | [
"def",
"max_time_last",
"max",
"=",
"0",
"i",
"=",
"0",
"while",
"i",
"<",
"@children",
".",
"size",
"tl",
"=",
"@children",
"[",
"i",
"]",
".",
"time_last",
"max",
"=",
"tl",
"if",
"tl",
">",
"max",
"i",
"+=",
"1",
"end",
"max",
"end"
] | Returns the maximum time last in all children
@return [Numeric] the max time last | [
"Returns",
"the",
"maximum",
"time",
"last",
"in",
"all",
"children"
] | 767212b3825068a82ada4ddaabe0a4e3a8144817 | https://github.com/devs-ruby/devs/blob/767212b3825068a82ada4ddaabe0a4e3a8144817/lib/devs/coordinator.rb#L64-L73 | train |
mynyml/rack-accept-media-types | lib/rack/accept_media_types.rb | Rack.AcceptMediaTypes.order | def order(types) #:nodoc:
types.map {|type| AcceptMediaType.new(type) }.reverse.sort.reverse.select {|type| type.valid? }.map {|type| type.range }
end | ruby | def order(types) #:nodoc:
types.map {|type| AcceptMediaType.new(type) }.reverse.sort.reverse.select {|type| type.valid? }.map {|type| type.range }
end | [
"def",
"order",
"(",
"types",
")",
"#:nodoc:",
"types",
".",
"map",
"{",
"|",
"type",
"|",
"AcceptMediaType",
".",
"new",
"(",
"type",
")",
"}",
".",
"reverse",
".",
"sort",
".",
"reverse",
".",
"select",
"{",
"|",
"type",
"|",
"type",
".",
"valid?... | Order media types by quality values, remove invalid types, and return media ranges. | [
"Order",
"media",
"types",
"by",
"quality",
"values",
"remove",
"invalid",
"types",
"and",
"return",
"media",
"ranges",
"."
] | 3d0f38882a466cc72043fd6f6e735b7f255e4b0d | https://github.com/mynyml/rack-accept-media-types/blob/3d0f38882a466cc72043fd6f6e735b7f255e4b0d/lib/rack/accept_media_types.rb#L80-L82 | train |
lml/lev | lib/lev/better_active_model_errors.rb | Lev.BetterActiveModelErrors.set | def set(key, value)
types[key.to_sym] = (value == [] ? [] : (value.is_a?(Symbol) ? value : nil))
messages[key.to_sym] = value
end | ruby | def set(key, value)
types[key.to_sym] = (value == [] ? [] : (value.is_a?(Symbol) ? value : nil))
messages[key.to_sym] = value
end | [
"def",
"set",
"(",
"key",
",",
"value",
")",
"types",
"[",
"key",
".",
"to_sym",
"]",
"=",
"(",
"value",
"==",
"[",
"]",
"?",
"[",
"]",
":",
"(",
"value",
".",
"is_a?",
"(",
"Symbol",
")",
"?",
"value",
":",
"nil",
")",
")",
"messages",
"[",
... | Set messages for +key+ to +value+ | [
"Set",
"messages",
"for",
"+",
"key",
"+",
"to",
"+",
"value",
"+"
] | ce39ac122796974dafb24ee61428540dacf34371 | https://github.com/lml/lev/blob/ce39ac122796974dafb24ee61428540dacf34371/lib/lev/better_active_model_errors.rb#L122-L125 | train |
lml/lev | lib/lev/better_active_model_errors.rb | Lev.BetterActiveModelErrors.delete | def delete(key)
key = key.to_sym
types.delete(key)
messages.delete(key)
end | ruby | def delete(key)
key = key.to_sym
types.delete(key)
messages.delete(key)
end | [
"def",
"delete",
"(",
"key",
")",
"key",
"=",
"key",
".",
"to_sym",
"types",
".",
"delete",
"(",
"key",
")",
"messages",
".",
"delete",
"(",
"key",
")",
"end"
] | Delete messages for +key+ | [
"Delete",
"messages",
"for",
"+",
"key",
"+"
] | ce39ac122796974dafb24ee61428540dacf34371 | https://github.com/lml/lev/blob/ce39ac122796974dafb24ee61428540dacf34371/lib/lev/better_active_model_errors.rb#L128-L132 | train |
lml/lev | lib/lev/better_active_model_errors.rb | Lev.BetterActiveModelErrors.empty? | def empty?
all? { |k, v| v && v.empty? && !v.is_a?(String) }
end | ruby | def empty?
all? { |k, v| v && v.empty? && !v.is_a?(String) }
end | [
"def",
"empty?",
"all?",
"{",
"|",
"k",
",",
"v",
"|",
"v",
"&&",
"v",
".",
"empty?",
"&&",
"!",
"v",
".",
"is_a?",
"(",
"String",
")",
"}",
"end"
] | Returns true if no errors are found, false otherwise.
If the error message is a string it can be empty. | [
"Returns",
"true",
"if",
"no",
"errors",
"are",
"found",
"false",
"otherwise",
".",
"If",
"the",
"error",
"message",
"is",
"a",
"string",
"it",
"can",
"be",
"empty",
"."
] | ce39ac122796974dafb24ee61428540dacf34371 | https://github.com/lml/lev/blob/ce39ac122796974dafb24ee61428540dacf34371/lib/lev/better_active_model_errors.rb#L219-L221 | train |
lml/lev | lib/lev/better_active_model_errors.rb | Lev.BetterActiveModelErrors.add_on_empty | def add_on_empty(attributes, options = {})
[attributes].flatten.each do |attribute|
value = @base.send(:read_attribute_for_validation, attribute)
is_empty = value.respond_to?(:empty?) ? value.empty? : false
add(attribute, :empty, options) if value.nil? || is_empty
end
end | ruby | def add_on_empty(attributes, options = {})
[attributes].flatten.each do |attribute|
value = @base.send(:read_attribute_for_validation, attribute)
is_empty = value.respond_to?(:empty?) ? value.empty? : false
add(attribute, :empty, options) if value.nil? || is_empty
end
end | [
"def",
"add_on_empty",
"(",
"attributes",
",",
"options",
"=",
"{",
"}",
")",
"[",
"attributes",
"]",
".",
"flatten",
".",
"each",
"do",
"|",
"attribute",
"|",
"value",
"=",
"@base",
".",
"send",
"(",
":read_attribute_for_validation",
",",
"attribute",
")"... | Will add an error message to each of the attributes in +attributes+ that is empty. | [
"Will",
"add",
"an",
"error",
"message",
"to",
"each",
"of",
"the",
"attributes",
"in",
"+",
"attributes",
"+",
"that",
"is",
"empty",
"."
] | ce39ac122796974dafb24ee61428540dacf34371 | https://github.com/lml/lev/blob/ce39ac122796974dafb24ee61428540dacf34371/lib/lev/better_active_model_errors.rb#L269-L275 | train |
chills42/guard-inch | lib/guard/inch.rb | Guard.Inch.start | def start
message = 'Guard::Inch is running'
message << ' in pedantic mode' if options[:pedantic]
message << ' and inspecting private fields' if options[:private]
::Guard::UI.info message
run_all if options[:all_on_start]
end | ruby | def start
message = 'Guard::Inch is running'
message << ' in pedantic mode' if options[:pedantic]
message << ' and inspecting private fields' if options[:private]
::Guard::UI.info message
run_all if options[:all_on_start]
end | [
"def",
"start",
"message",
"=",
"'Guard::Inch is running'",
"message",
"<<",
"' in pedantic mode'",
"if",
"options",
"[",
":pedantic",
"]",
"message",
"<<",
"' and inspecting private fields'",
"if",
"options",
"[",
":private",
"]",
"::",
"Guard",
"::",
"UI",
".",
... | configure a new instance of the plugin
@param [Hash] options the guard plugin options
On start, display a message and optionally run the documentation lint | [
"configure",
"a",
"new",
"instance",
"of",
"the",
"plugin"
] | 5f8427996797e5c2100b7a1abb36fedf696b725c | https://github.com/chills42/guard-inch/blob/5f8427996797e5c2100b7a1abb36fedf696b725c/lib/guard/inch.rb#L19-L25 | train |
ivanzotov/constructor | pages/app/models/constructor_pages/page.rb | ConstructorPages.Page.update_fields_values | def update_fields_values(params)
params || return
fields.each {|f| f.find_or_create_type_object(self).tap {|t| t || next
params[f.code_name.to_sym].tap {|v| v && t.value = v}
t.save }}
end | ruby | def update_fields_values(params)
params || return
fields.each {|f| f.find_or_create_type_object(self).tap {|t| t || next
params[f.code_name.to_sym].tap {|v| v && t.value = v}
t.save }}
end | [
"def",
"update_fields_values",
"(",
"params",
")",
"params",
"||",
"return",
"fields",
".",
"each",
"{",
"|",
"f",
"|",
"f",
".",
"find_or_create_type_object",
"(",
"self",
")",
".",
"tap",
"{",
"|",
"t",
"|",
"t",
"||",
"next",
"params",
"[",
"f",
"... | Update all fields values with given params.
@param params should looks like <tt>{price: 500, content: 'Hello'}</tt> | [
"Update",
"all",
"fields",
"values",
"with",
"given",
"params",
"."
] | 1d52fb5b642200a6993f5a630e6934bccbcbf4e8 | https://github.com/ivanzotov/constructor/blob/1d52fb5b642200a6993f5a630e6934bccbcbf4e8/pages/app/models/constructor_pages/page.rb#L133-L139 | train |
ivanzotov/constructor | pages/app/models/constructor_pages/page.rb | ConstructorPages.Page.find_page_in_branch | def find_page_in_branch(cname)
Template.find_by(code_name: cname.singularize).tap {|t| t || return
(descendants.where(template_id: t.id) if cname == cname.pluralize).tap {|r| r ||= []
return r.empty? ? ancestors.find_by(template_id: t.id) : r}}
end | ruby | def find_page_in_branch(cname)
Template.find_by(code_name: cname.singularize).tap {|t| t || return
(descendants.where(template_id: t.id) if cname == cname.pluralize).tap {|r| r ||= []
return r.empty? ? ancestors.find_by(template_id: t.id) : r}}
end | [
"def",
"find_page_in_branch",
"(",
"cname",
")",
"Template",
".",
"find_by",
"(",
"code_name",
":",
"cname",
".",
"singularize",
")",
".",
"tap",
"{",
"|",
"t",
"|",
"t",
"||",
"return",
"(",
"descendants",
".",
"where",
"(",
"template_id",
":",
"t",
"... | Search page by template code_name in same branch of pages and templates.
It allows to call page.category.brand.series.model etc.
Return one page if founded in ancestors,
and return array of pages if founded in descendants
It determines if code_name is singular or nor
@param cname template code name | [
"Search",
"page",
"by",
"template",
"code_name",
"in",
"same",
"branch",
"of",
"pages",
"and",
"templates",
".",
"It",
"allows",
"to",
"call",
"page",
".",
"category",
".",
"brand",
".",
"series",
".",
"model",
"etc",
"."
] | 1d52fb5b642200a6993f5a630e6934bccbcbf4e8 | https://github.com/ivanzotov/constructor/blob/1d52fb5b642200a6993f5a630e6934bccbcbf4e8/pages/app/models/constructor_pages/page.rb#L155-L159 | train |
ivanzotov/constructor | pages/app/models/constructor_pages/page.rb | ConstructorPages.Page.as_json | def as_json(options = {})
{name: self.name, title: self.title}.merge(options).tap do |options|
fields.each {|f| options.merge!({f.code_name.to_sym => f.get_value_for(self)})}
end
end | ruby | def as_json(options = {})
{name: self.name, title: self.title}.merge(options).tap do |options|
fields.each {|f| options.merge!({f.code_name.to_sym => f.get_value_for(self)})}
end
end | [
"def",
"as_json",
"(",
"options",
"=",
"{",
"}",
")",
"{",
"name",
":",
"self",
".",
"name",
",",
"title",
":",
"self",
".",
"title",
"}",
".",
"merge",
"(",
"options",
")",
".",
"tap",
"do",
"|",
"options",
"|",
"fields",
".",
"each",
"{",
"|"... | Returns page hash attributes with fields.
Default attributes are name and title. Options param allows to add more.
@param options default merge name and title page attributes | [
"Returns",
"page",
"hash",
"attributes",
"with",
"fields",
"."
] | 1d52fb5b642200a6993f5a630e6934bccbcbf4e8 | https://github.com/ivanzotov/constructor/blob/1d52fb5b642200a6993f5a630e6934bccbcbf4e8/pages/app/models/constructor_pages/page.rb#L177-L181 | train |
stve/tophat | lib/tophat/meta.rb | TopHat.MetaHelper.meta_tag | def meta_tag(options, open=false, escape=true)
tag(:meta, options, open, escape)
end | ruby | def meta_tag(options, open=false, escape=true)
tag(:meta, options, open, escape)
end | [
"def",
"meta_tag",
"(",
"options",
",",
"open",
"=",
"false",
",",
"escape",
"=",
"true",
")",
"tag",
"(",
":meta",
",",
"options",
",",
"open",
",",
"escape",
")",
"end"
] | Meta Tag helper | [
"Meta",
"Tag",
"helper"
] | c49a7ec029604f0fa2b64af29a72fb07f317f242 | https://github.com/stve/tophat/blob/c49a7ec029604f0fa2b64af29a72fb07f317f242/lib/tophat/meta.rb#L5-L7 | train |
postmodern/ffi-bit_masks | lib/ffi/bit_masks.rb | FFI.BitMasks.bit_mask | def bit_mask(name,flags,type=:uint)
bit_mask = BitMask.new(flags,type)
typedef(bit_mask,name)
return bit_mask
end | ruby | def bit_mask(name,flags,type=:uint)
bit_mask = BitMask.new(flags,type)
typedef(bit_mask,name)
return bit_mask
end | [
"def",
"bit_mask",
"(",
"name",
",",
"flags",
",",
"type",
"=",
":uint",
")",
"bit_mask",
"=",
"BitMask",
".",
"new",
"(",
"flags",
",",
"type",
")",
"typedef",
"(",
"bit_mask",
",",
"name",
")",
"return",
"bit_mask",
"end"
] | Defines a new bitmask.
@param [Symbol] name
The name of the bitmask.
@param [Hash{Symbol => Integer}] flags
The flags and their masks.
@param [Symbol] type
The underlying type.
@return [BitMask]
The new bitmask. | [
"Defines",
"a",
"new",
"bitmask",
"."
] | dc34c2f99f9cc9a5629de8ccee87a97a182e0fa8 | https://github.com/postmodern/ffi-bit_masks/blob/dc34c2f99f9cc9a5629de8ccee87a97a182e0fa8/lib/ffi/bit_masks.rb#L24-L29 | train |
eprothro/cassie | lib/cassie/schema/migrator.rb | Cassie::Schema.Migrator.build_up_commands | def build_up_commands
local_versions.select{ |v| v > current_version && v <= target_version }
.map{ |v| ApplyCommand.new(v) }
end | ruby | def build_up_commands
local_versions.select{ |v| v > current_version && v <= target_version }
.map{ |v| ApplyCommand.new(v) }
end | [
"def",
"build_up_commands",
"local_versions",
".",
"select",
"{",
"|",
"v",
"|",
"v",
">",
"current_version",
"&&",
"v",
"<=",
"target_version",
"}",
".",
"map",
"{",
"|",
"v",
"|",
"ApplyCommand",
".",
"new",
"(",
"v",
")",
"}",
"end"
] | install all local versions since current
a (current) | b | c | d (target) | e | [
"install",
"all",
"local",
"versions",
"since",
"current"
] | 63e71d12d3549882147e715e427a16fd8e0aa210 | https://github.com/eprothro/cassie/blob/63e71d12d3549882147e715e427a16fd8e0aa210/lib/cassie/schema/migrator.rb#L73-L76 | train |
eprothro/cassie | lib/cassie/schema/migrator.rb | Cassie::Schema.Migrator.build_down_commands | def build_down_commands
rollbacks = rollback_versions.map{ |v| RollbackCommand.new(v) }
missing = missing_versions_before(rollbacks.last.version).map{ |v| ApplyCommand.new(v) }
rollbacks + missing
end | ruby | def build_down_commands
rollbacks = rollback_versions.map{ |v| RollbackCommand.new(v) }
missing = missing_versions_before(rollbacks.last.version).map{ |v| ApplyCommand.new(v) }
rollbacks + missing
end | [
"def",
"build_down_commands",
"rollbacks",
"=",
"rollback_versions",
".",
"map",
"{",
"|",
"v",
"|",
"RollbackCommand",
".",
"new",
"(",
"v",
")",
"}",
"missing",
"=",
"missing_versions_before",
"(",
"rollbacks",
".",
"last",
".",
"version",
")",
".",
"map",... | rollback all versions applied past the target
and apply missing versions to get to target
0 | a (target) (not applied) | b | c | d (current) | e | [
"rollback",
"all",
"versions",
"applied",
"past",
"the",
"target",
"and",
"apply",
"missing",
"versions",
"to",
"get",
"to",
"target"
] | 63e71d12d3549882147e715e427a16fd8e0aa210 | https://github.com/eprothro/cassie/blob/63e71d12d3549882147e715e427a16fd8e0aa210/lib/cassie/schema/migrator.rb#L82-L86 | train |
eprothro/cassie | lib/cassie/schema/migrator.rb | Cassie::Schema.Migrator.missing_versions_before | def missing_versions_before(last_rollback)
return [] unless last_rollback
rollback_index = applied_versions.index(last_rollback)
stop = if rollback_index == applied_versions.length - 1
# rolled back to oldest version, a rollback
# would put us in a versionless state.
# Any ve... | ruby | def missing_versions_before(last_rollback)
return [] unless last_rollback
rollback_index = applied_versions.index(last_rollback)
stop = if rollback_index == applied_versions.length - 1
# rolled back to oldest version, a rollback
# would put us in a versionless state.
# Any ve... | [
"def",
"missing_versions_before",
"(",
"last_rollback",
")",
"return",
"[",
"]",
"unless",
"last_rollback",
"rollback_index",
"=",
"applied_versions",
".",
"index",
"(",
"last_rollback",
")",
"stop",
"=",
"if",
"rollback_index",
"==",
"applied_versions",
".",
"lengt... | versions that are not applied yet
but need to get applied
to get up the target version
| 0 (stop) | a (target) | b | c | [
"versions",
"that",
"are",
"not",
"applied",
"yet",
"but",
"need",
"to",
"get",
"applied",
"to",
"get",
"up",
"the",
"target",
"version"
] | 63e71d12d3549882147e715e427a16fd8e0aa210 | https://github.com/eprothro/cassie/blob/63e71d12d3549882147e715e427a16fd8e0aa210/lib/cassie/schema/migrator.rb#L99-L116 | train |
nulldef/ciesta | lib/ciesta/class_methods.rb | Ciesta.ClassMethods.field | def field(name, **options)
name = name.to_sym
definitions[name] = options
proxy.instance_eval do
define_method(name) { fields[name] }
define_method("#{name}=") { |value| fields[name] = value }
end
end | ruby | def field(name, **options)
name = name.to_sym
definitions[name] = options
proxy.instance_eval do
define_method(name) { fields[name] }
define_method("#{name}=") { |value| fields[name] = value }
end
end | [
"def",
"field",
"(",
"name",
",",
"**",
"options",
")",
"name",
"=",
"name",
".",
"to_sym",
"definitions",
"[",
"name",
"]",
"=",
"options",
"proxy",
".",
"instance_eval",
"do",
"define_method",
"(",
"name",
")",
"{",
"fields",
"[",
"name",
"]",
"}",
... | Declare new form field
@param [Symbol] name Field name
@param [Hash] options Options
@option (see Ciesta::Field) | [
"Declare",
"new",
"form",
"field"
] | 07352988e687c0778fce8cae001fc2876480da32 | https://github.com/nulldef/ciesta/blob/07352988e687c0778fce8cae001fc2876480da32/lib/ciesta/class_methods.rb#L10-L17 | train |
CDLUC3/resync | lib/resync/shared/base_change_list.rb | Resync.BaseChangeList.changes | def changes(of_type: nil, in_range: nil)
resources.select do |r|
is_of_type = of_type ? r.change == of_type : true
is_in_range = in_range ? in_range.cover?(r.modified_time) : true
is_of_type && is_in_range
end
end | ruby | def changes(of_type: nil, in_range: nil)
resources.select do |r|
is_of_type = of_type ? r.change == of_type : true
is_in_range = in_range ? in_range.cover?(r.modified_time) : true
is_of_type && is_in_range
end
end | [
"def",
"changes",
"(",
"of_type",
":",
"nil",
",",
"in_range",
":",
"nil",
")",
"resources",
".",
"select",
"do",
"|",
"r",
"|",
"is_of_type",
"=",
"of_type",
"?",
"r",
".",
"change",
"==",
"of_type",
":",
"true",
"is_in_range",
"=",
"in_range",
"?",
... | Filters the list of changes by change type, modification time, or both.
@param of_type [Types::Change] the change type
@param in_range [Range<Time>] the range of modification times
@return [Array<Resource>] the matching changes, or all changes
if neither +of_type+ nor +in_range+ is specified. | [
"Filters",
"the",
"list",
"of",
"changes",
"by",
"change",
"type",
"modification",
"time",
"or",
"both",
"."
] | f59a1f77f3c378180ee9ebcc42b325372f1e7a31 | https://github.com/CDLUC3/resync/blob/f59a1f77f3c378180ee9ebcc42b325372f1e7a31/lib/resync/shared/base_change_list.rb#L11-L17 | train |
ohler55/opee | lib/opee/actor.rb | Opee.Actor.on_idle | def on_idle(op, *args)
@idle_mutex.synchronize {
@idle.insert(0, Act.new(op, args))
}
@loop.wakeup() if RUNNING == @state
end | ruby | def on_idle(op, *args)
@idle_mutex.synchronize {
@idle.insert(0, Act.new(op, args))
}
@loop.wakeup() if RUNNING == @state
end | [
"def",
"on_idle",
"(",
"op",
",",
"*",
"args",
")",
"@idle_mutex",
".",
"synchronize",
"{",
"@idle",
".",
"insert",
"(",
"0",
",",
"Act",
".",
"new",
"(",
"op",
",",
"args",
")",
")",
"}",
"@loop",
".",
"wakeup",
"(",
")",
"if",
"RUNNING",
"==",
... | Queues an operation and arguments to be called when the Actor is has no
other requests to process.
@param [Symbol] op method to queue for the Actor
@param [Array] args arguments to the op method | [
"Queues",
"an",
"operation",
"and",
"arguments",
"to",
"be",
"called",
"when",
"the",
"Actor",
"is",
"has",
"no",
"other",
"requests",
"to",
"process",
"."
] | 09d947affeddc0501f61b928050fbde1838ed57a | https://github.com/ohler55/opee/blob/09d947affeddc0501f61b928050fbde1838ed57a/lib/opee/actor.rb#L153-L158 | train |
ohler55/opee | lib/opee/actor.rb | Opee.Actor.method_missing | def method_missing(m, *args, &blk)
raise NoMethodError.new("undefined method '#{m}' for #{self.class}", m, args) unless respond_to?(m, true)
ask(m, *args)
end | ruby | def method_missing(m, *args, &blk)
raise NoMethodError.new("undefined method '#{m}' for #{self.class}", m, args) unless respond_to?(m, true)
ask(m, *args)
end | [
"def",
"method_missing",
"(",
"m",
",",
"*",
"args",
",",
"&",
"blk",
")",
"raise",
"NoMethodError",
".",
"new",
"(",
"\"undefined method '#{m}' for #{self.class}\"",
",",
"m",
",",
"args",
")",
"unless",
"respond_to?",
"(",
"m",
",",
"true",
")",
"ask",
"... | When an attempt is made to call a private method of the Actor it is
places on the processing queue. Other methods cause a NoMethodError to
be raised as it normally would.
@param [Symbol] m method to queue for the Actor
@param [Array] args arguments to the op method
@param [Proc] blk ignored | [
"When",
"an",
"attempt",
"is",
"made",
"to",
"call",
"a",
"private",
"method",
"of",
"the",
"Actor",
"it",
"is",
"places",
"on",
"the",
"processing",
"queue",
".",
"Other",
"methods",
"cause",
"a",
"NoMethodError",
"to",
"be",
"raised",
"as",
"it",
"norm... | 09d947affeddc0501f61b928050fbde1838ed57a | https://github.com/ohler55/opee/blob/09d947affeddc0501f61b928050fbde1838ed57a/lib/opee/actor.rb#L177-L180 | train |
fulldecent/structured-acceptance-test | implementations/ruby/lib/stat.rb | StatModule.Stat.findings= | def findings=(findings)
raise TypeException unless findings.is_a?(Array)
findings.each { |item|
raise TypeException unless item.is_a?(StatModule::Finding)
raise DuplicateElementException if @findings.include?(item)
@findings.push(item)
}
end | ruby | def findings=(findings)
raise TypeException unless findings.is_a?(Array)
findings.each { |item|
raise TypeException unless item.is_a?(StatModule::Finding)
raise DuplicateElementException if @findings.include?(item)
@findings.push(item)
}
end | [
"def",
"findings",
"=",
"(",
"findings",
")",
"raise",
"TypeException",
"unless",
"findings",
".",
"is_a?",
"(",
"Array",
")",
"findings",
".",
"each",
"{",
"|",
"item",
"|",
"raise",
"TypeException",
"unless",
"item",
".",
"is_a?",
"(",
"StatModule",
"::"... | Initialize new Stat object
Params:
+process+:: StatModule::Process, required
+hash+:: Hash, can be null
Set array of findings
Params:
+findings+:: Array of StatModule::Finding | [
"Initialize",
"new",
"Stat",
"object"
] | 9766f4863a8bcfdf6ac50a7aa36cce0314481118 | https://github.com/fulldecent/structured-acceptance-test/blob/9766f4863a8bcfdf6ac50a7aa36cce0314481118/implementations/ruby/lib/stat.rb#L43-L50 | train |
fulldecent/structured-acceptance-test | implementations/ruby/lib/stat.rb | StatModule.Stat.print_header | def print_header
@finding_print_index = 0
hash = {}
hash['statVersion'] = @statVersion
hash['process'] = @process
hash['findings'] = []
result = hash.to_json
result = result[0..result.length - 3]
puts(result)
puts
$stdout.flush
end | ruby | def print_header
@finding_print_index = 0
hash = {}
hash['statVersion'] = @statVersion
hash['process'] = @process
hash['findings'] = []
result = hash.to_json
result = result[0..result.length - 3]
puts(result)
puts
$stdout.flush
end | [
"def",
"print_header",
"@finding_print_index",
"=",
"0",
"hash",
"=",
"{",
"}",
"hash",
"[",
"'statVersion'",
"]",
"=",
"@statVersion",
"hash",
"[",
"'process'",
"]",
"=",
"@process",
"hash",
"[",
"'findings'",
"]",
"=",
"[",
"]",
"result",
"=",
"hash",
... | Prints header of STAT object in json format
Header contains statVersion, process and optional array of findings | [
"Prints",
"header",
"of",
"STAT",
"object",
"in",
"json",
"format",
"Header",
"contains",
"statVersion",
"process",
"and",
"optional",
"array",
"of",
"findings"
] | 9766f4863a8bcfdf6ac50a7aa36cce0314481118 | https://github.com/fulldecent/structured-acceptance-test/blob/9766f4863a8bcfdf6ac50a7aa36cce0314481118/implementations/ruby/lib/stat.rb#L77-L88 | train |
fulldecent/structured-acceptance-test | implementations/ruby/lib/stat.rb | StatModule.Stat.print_finding | def print_finding
if @finding_print_index < @findings.length
result = @findings[@finding_print_index].to_json
result += ',' unless @finding_print_index >= @findings.length - 1
puts result
puts
$stdout.flush
@finding_print_index += 1
else
raise IndexOut... | ruby | def print_finding
if @finding_print_index < @findings.length
result = @findings[@finding_print_index].to_json
result += ',' unless @finding_print_index >= @findings.length - 1
puts result
puts
$stdout.flush
@finding_print_index += 1
else
raise IndexOut... | [
"def",
"print_finding",
"if",
"@finding_print_index",
"<",
"@findings",
".",
"length",
"result",
"=",
"@findings",
"[",
"@finding_print_index",
"]",
".",
"to_json",
"result",
"+=",
"','",
"unless",
"@finding_print_index",
">=",
"@findings",
".",
"length",
"-",
"1"... | Prints one finding in json format. | [
"Prints",
"one",
"finding",
"in",
"json",
"format",
"."
] | 9766f4863a8bcfdf6ac50a7aa36cce0314481118 | https://github.com/fulldecent/structured-acceptance-test/blob/9766f4863a8bcfdf6ac50a7aa36cce0314481118/implementations/ruby/lib/stat.rb#L92-L103 | train |
Subsets and Splits
SQL Console for semeru/code-text-ruby
Retrieves 20,000 non-null code samples labeled as Ruby, providing a basic overview of the dataset but without deeper analysis.