id int32 0 24.9k | repo stringlengths 5 58 | path stringlengths 9 168 | func_name stringlengths 9 130 | original_string stringlengths 66 10.5k | language stringclasses 1
value | code stringlengths 66 10.5k | code_tokens list | docstring stringlengths 8 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 94 266 |
|---|---|---|---|---|---|---|---|---|---|---|---|
9,200 | elifoster/fishbans-rb | lib/block_engine.rb | Fishbans.BlockEngine.get_block | def get_block(id, metadata = nil, size = 42)
url = "http://blocks.fishbans.com/#{id}"
url += "-#{metadata}" unless metadata.nil?
url += "/#{size}" if size != 42
response = get(url, false)
ChunkyPNG::Image.from_blob(response.body)
end | ruby | def get_block(id, metadata = nil, size = 42)
url = "http://blocks.fishbans.com/#{id}"
url += "-#{metadata}" unless metadata.nil?
url += "/#{size}" if size != 42
response = get(url, false)
ChunkyPNG::Image.from_blob(response.body)
end | [
"def",
"get_block",
"(",
"id",
",",
"metadata",
"=",
"nil",
",",
"size",
"=",
"42",
")",
"url",
"=",
"\"http://blocks.fishbans.com/#{id}\"",
"url",
"+=",
"\"-#{metadata}\"",
"unless",
"metadata",
".",
"nil?",
"url",
"+=",
"\"/#{size}\"",
"if",
"size",
"!=",
... | Gets a block image by its ID and Metadata. Unfortunately it uses the old
block IDs rather than the new ones, so you have to memorize those
pesky integers.
@param id [Integer] The (outdated) block ID number.
@param metadata [Integer] The metadata, if any, for the block.
@param size [Fixnum] The size of the imag... | [
"Gets",
"a",
"block",
"image",
"by",
"its",
"ID",
"and",
"Metadata",
".",
"Unfortunately",
"it",
"uses",
"the",
"old",
"block",
"IDs",
"rather",
"than",
"the",
"new",
"ones",
"so",
"you",
"have",
"to",
"memorize",
"those",
"pesky",
"integers",
"."
] | 652016694176ade8767ac6a3b4dea2dc631be747 | https://github.com/elifoster/fishbans-rb/blob/652016694176ade8767ac6a3b4dea2dc631be747/lib/block_engine.rb#L14-L20 |
9,201 | elifoster/fishbans-rb | lib/block_engine.rb | Fishbans.BlockEngine.get_monster | def get_monster(id, three = false, size = 42)
id = id.to_s
url = 'http://blocks.fishbans.com'
url += "/#{id}" if id =~ /^m/
url += "/m#{id}" if id !~ /^m/
url += '-3d' if three
url += "/#{size}" if size != 42
response = get(url, false)
ChunkyPNG::Image.from_blob(response.... | ruby | def get_monster(id, three = false, size = 42)
id = id.to_s
url = 'http://blocks.fishbans.com'
url += "/#{id}" if id =~ /^m/
url += "/m#{id}" if id !~ /^m/
url += '-3d' if three
url += "/#{size}" if size != 42
response = get(url, false)
ChunkyPNG::Image.from_blob(response.... | [
"def",
"get_monster",
"(",
"id",
",",
"three",
"=",
"false",
",",
"size",
"=",
"42",
")",
"id",
"=",
"id",
".",
"to_s",
"url",
"=",
"'http://blocks.fishbans.com'",
"url",
"+=",
"\"/#{id}\"",
"if",
"id",
"=~",
"/",
"/",
"url",
"+=",
"\"/m#{id}\"",
"if",... | Gets the monster image by its ID.
@param id [Any] The string ID. It will automatically prefix it with "m" if
that is omitted. It doesn't matter what type it is: String or Fixnum,
because it will automatically convert it to a String.
@param three [Boolean] Whether to get a three-dimensional monster image.
The... | [
"Gets",
"the",
"monster",
"image",
"by",
"its",
"ID",
"."
] | 652016694176ade8767ac6a3b4dea2dc631be747 | https://github.com/elifoster/fishbans-rb/blob/652016694176ade8767ac6a3b4dea2dc631be747/lib/block_engine.rb#L33-L42 |
9,202 | wparad/Osiris | lib/osiris/zip_file_generator.rb | Osiris.ZipFileGenerator.write | def write(inputDir, outputFile)
entries = Dir.entries(inputDir); entries.delete("."); entries.delete("..")
io = Zip::File.open(outputFile, Zip::File::CREATE);
writeEntries(entries, "", io, inputDir)
io.close();
end | ruby | def write(inputDir, outputFile)
entries = Dir.entries(inputDir); entries.delete("."); entries.delete("..")
io = Zip::File.open(outputFile, Zip::File::CREATE);
writeEntries(entries, "", io, inputDir)
io.close();
end | [
"def",
"write",
"(",
"inputDir",
",",
"outputFile",
")",
"entries",
"=",
"Dir",
".",
"entries",
"(",
"inputDir",
")",
";",
"entries",
".",
"delete",
"(",
"\".\"",
")",
";",
"entries",
".",
"delete",
"(",
"\"..\"",
")",
"io",
"=",
"Zip",
"::",
"File",... | Initialize with the directory to zip and the location of the output archive.
Zip the input directory. | [
"Initialize",
"with",
"the",
"directory",
"to",
"zip",
"and",
"the",
"location",
"of",
"the",
"output",
"archive",
".",
"Zip",
"the",
"input",
"directory",
"."
] | efa61f3353674a01e813d9557016bd610277f7de | https://github.com/wparad/Osiris/blob/efa61f3353674a01e813d9557016bd610277f7de/lib/osiris/zip_file_generator.rb#L20-L26 |
9,203 | pwnall/file_blobs_rails | lib/file_blobs_rails/active_record_fixture_set_extensions.rb | FileBlobs.ActiveRecordFixtureSetExtensions.file_blob_id | def file_blob_id(path)
file_path = Rails.root.join('test/fixtures'.freeze).join(path)
blob_contents = File.binread file_path
# This needs to be kept in sync with blob_model.rb.
Base64.urlsafe_encode64(Digest::SHA256.digest(blob_contents)).inspect
end | ruby | def file_blob_id(path)
file_path = Rails.root.join('test/fixtures'.freeze).join(path)
blob_contents = File.binread file_path
# This needs to be kept in sync with blob_model.rb.
Base64.urlsafe_encode64(Digest::SHA256.digest(blob_contents)).inspect
end | [
"def",
"file_blob_id",
"(",
"path",
")",
"file_path",
"=",
"Rails",
".",
"root",
".",
"join",
"(",
"'test/fixtures'",
".",
"freeze",
")",
".",
"join",
"(",
"path",
")",
"blob_contents",
"=",
"File",
".",
"binread",
"file_path",
"# This needs to be kept in sync... | Computes the ID assigned to a blob.
@param [String] path the path of the file whose contents is used in the
fixture, relative to the Rails application's test/fixtures directory
@return [String] the ID used to represent the blob contents | [
"Computes",
"the",
"ID",
"assigned",
"to",
"a",
"blob",
"."
] | 688d43ec8547856f3572b0e6716e6faeff56345b | https://github.com/pwnall/file_blobs_rails/blob/688d43ec8547856f3572b0e6716e6faeff56345b/lib/file_blobs_rails/active_record_fixture_set_extensions.rb#L14-L20 |
9,204 | pwnall/file_blobs_rails | lib/file_blobs_rails/active_record_fixture_set_extensions.rb | FileBlobs.ActiveRecordFixtureSetExtensions.file_blob_data | def file_blob_data(path, options = {})
# The line with base64 data must be indented further than the current line.
indent = ' ' * ((options[:indent] || 2) + 2)
file_path = Rails.root.join('test/fixtures'.freeze).join(path)
blob_contents = File.binread file_path
base64_data = Base64.encode64 blob_co... | ruby | def file_blob_data(path, options = {})
# The line with base64 data must be indented further than the current line.
indent = ' ' * ((options[:indent] || 2) + 2)
file_path = Rails.root.join('test/fixtures'.freeze).join(path)
blob_contents = File.binread file_path
base64_data = Base64.encode64 blob_co... | [
"def",
"file_blob_data",
"(",
"path",
",",
"options",
"=",
"{",
"}",
")",
"# The line with base64 data must be indented further than the current line.",
"indent",
"=",
"' '",
"*",
"(",
"(",
"options",
"[",
":indent",
"]",
"||",
"2",
")",
"+",
"2",
")",
"file_pat... | The contents of a blob, in a YAML-friendly format.
@param [String] path the path of the file whose contents is used in the
fixture, relative to the Rails application's test/fixtures directory
@param [Hash] options optionally specify the current indentation level
@option options [Integer] indent the number of spa... | [
"The",
"contents",
"of",
"a",
"blob",
"in",
"a",
"YAML",
"-",
"friendly",
"format",
"."
] | 688d43ec8547856f3572b0e6716e6faeff56345b | https://github.com/pwnall/file_blobs_rails/blob/688d43ec8547856f3572b0e6716e6faeff56345b/lib/file_blobs_rails/active_record_fixture_set_extensions.rb#L30-L41 |
9,205 | pwnall/file_blobs_rails | lib/file_blobs_rails/active_record_fixture_set_extensions.rb | FileBlobs.ActiveRecordFixtureSetExtensions.file_blob_size | def file_blob_size(path)
file_path = Rails.root.join('test/fixtures'.freeze).join(path)
File.stat(file_path).size
end | ruby | def file_blob_size(path)
file_path = Rails.root.join('test/fixtures'.freeze).join(path)
File.stat(file_path).size
end | [
"def",
"file_blob_size",
"(",
"path",
")",
"file_path",
"=",
"Rails",
".",
"root",
".",
"join",
"(",
"'test/fixtures'",
".",
"freeze",
")",
".",
"join",
"(",
"path",
")",
"File",
".",
"stat",
"(",
"file_path",
")",
".",
"size",
"end"
] | The number of bytes in a file.
@param [String] path the path of the file whose contents is used in the
fixture, relative to the Rails application's test/fixtures directory
@return [Integer] the nubmer of bytes in the file | [
"The",
"number",
"of",
"bytes",
"in",
"a",
"file",
"."
] | 688d43ec8547856f3572b0e6716e6faeff56345b | https://github.com/pwnall/file_blobs_rails/blob/688d43ec8547856f3572b0e6716e6faeff56345b/lib/file_blobs_rails/active_record_fixture_set_extensions.rb#L48-L51 |
9,206 | thriventures/storage_room_gem | lib/storage_room/embeddeds/file.rb | StorageRoom.File.set_with_filename | def set_with_filename(path)
return if path.blank?
self.filename = ::File.basename(path)
self.content_type = ::MIME::Types.type_for(path).first.content_type
self.data = ::Base64.encode64(::File.read(path))
end | ruby | def set_with_filename(path)
return if path.blank?
self.filename = ::File.basename(path)
self.content_type = ::MIME::Types.type_for(path).first.content_type
self.data = ::Base64.encode64(::File.read(path))
end | [
"def",
"set_with_filename",
"(",
"path",
")",
"return",
"if",
"path",
".",
"blank?",
"self",
".",
"filename",
"=",
"::",
"File",
".",
"basename",
"(",
"path",
")",
"self",
".",
"content_type",
"=",
"::",
"MIME",
"::",
"Types",
".",
"type_for",
"(",
"pa... | Sets the filename, content_type and data attributes from a local filename so that a File can be uploaded through the API | [
"Sets",
"the",
"filename",
"content_type",
"and",
"data",
"attributes",
"from",
"a",
"local",
"filename",
"so",
"that",
"a",
"File",
"can",
"be",
"uploaded",
"through",
"the",
"API"
] | cadf132b865ff82f7b09fadfec1d294a714c6728 | https://github.com/thriventures/storage_room_gem/blob/cadf132b865ff82f7b09fadfec1d294a714c6728/lib/storage_room/embeddeds/file.rb#L20-L26 |
9,207 | thriventures/storage_room_gem | lib/storage_room/embeddeds/file.rb | StorageRoom.File.download_to_directory | def download_to_directory(path)
Dir.mkdir(path) unless ::File.directory?(path)
download_file(self[:@url], ::File.join(path, local_filename))
true
end | ruby | def download_to_directory(path)
Dir.mkdir(path) unless ::File.directory?(path)
download_file(self[:@url], ::File.join(path, local_filename))
true
end | [
"def",
"download_to_directory",
"(",
"path",
")",
"Dir",
".",
"mkdir",
"(",
"path",
")",
"unless",
"::",
"File",
".",
"directory?",
"(",
"path",
")",
"download_file",
"(",
"self",
"[",
":@url",
"]",
",",
"::",
"File",
".",
"join",
"(",
"path",
",",
"... | Download the file to the local disk | [
"Download",
"the",
"file",
"to",
"the",
"local",
"disk"
] | cadf132b865ff82f7b09fadfec1d294a714c6728 | https://github.com/thriventures/storage_room_gem/blob/cadf132b865ff82f7b09fadfec1d294a714c6728/lib/storage_room/embeddeds/file.rb#L34-L38 |
9,208 | sanichi/icu_tournament | lib/icu_tournament/tournament_spx.rb | ICU.Player.to_sp_text | def to_sp_text(rounds, columns, formats)
values = columns.inject([]) do |vals,col|
val = send(col).to_s
val.sub!(/\.0/, '') if col == :points
vals << val
end
(1..rounds).each do |r|
result = find_result(r)
values << (result ? result.to_sp_text : " : ")
end... | ruby | def to_sp_text(rounds, columns, formats)
values = columns.inject([]) do |vals,col|
val = send(col).to_s
val.sub!(/\.0/, '') if col == :points
vals << val
end
(1..rounds).each do |r|
result = find_result(r)
values << (result ? result.to_sp_text : " : ")
end... | [
"def",
"to_sp_text",
"(",
"rounds",
",",
"columns",
",",
"formats",
")",
"values",
"=",
"columns",
".",
"inject",
"(",
"[",
"]",
")",
"do",
"|",
"vals",
",",
"col",
"|",
"val",
"=",
"send",
"(",
"col",
")",
".",
"to_s",
"val",
".",
"sub!",
"(",
... | Format a player's record as it would appear in an SP export file. | [
"Format",
"a",
"player",
"s",
"record",
"as",
"it",
"would",
"appear",
"in",
"an",
"SP",
"export",
"file",
"."
] | badd2940189feaeb9f0edb4b4e07ff6b2548bd3d | https://github.com/sanichi/icu_tournament/blob/badd2940189feaeb9f0edb4b4e07ff6b2548bd3d/lib/icu_tournament/tournament_spx.rb#L364-L375 |
9,209 | evansagge/numeric_array | lib/numeric_array.rb | NumericArray.InstanceMethods.variance | def variance(sample = false)
a = numerify
avg = a.average
sum = a.inject(0) { |sum, value| sum + (value - avg) ** 2}
(1 / (a.length.to_f - (sample ? 1 : 0)) * sum)
end | ruby | def variance(sample = false)
a = numerify
avg = a.average
sum = a.inject(0) { |sum, value| sum + (value - avg) ** 2}
(1 / (a.length.to_f - (sample ? 1 : 0)) * sum)
end | [
"def",
"variance",
"(",
"sample",
"=",
"false",
")",
"a",
"=",
"numerify",
"avg",
"=",
"a",
".",
"average",
"sum",
"=",
"a",
".",
"inject",
"(",
"0",
")",
"{",
"|",
"sum",
",",
"value",
"|",
"sum",
"+",
"(",
"value",
"-",
"avg",
")",
"**",
"2... | variance of an array of numbers | [
"variance",
"of",
"an",
"array",
"of",
"numbers"
] | f5cbdd0c658631d42540f9251480e0d38ebb493a | https://github.com/evansagge/numeric_array/blob/f5cbdd0c658631d42540f9251480e0d38ebb493a/lib/numeric_array.rb#L25-L30 |
9,210 | irvingwashington/gem_footprint_analyzer | lib/gem_footprint_analyzer/cli.rb | GemFootprintAnalyzer.CLI.run | def run(args = ARGV)
opts.parse!(args)
if !analyze_gemfile? && args.empty?
puts opts.parser
exit 1
end
print_requires(options, args)
end | ruby | def run(args = ARGV)
opts.parse!(args)
if !analyze_gemfile? && args.empty?
puts opts.parser
exit 1
end
print_requires(options, args)
end | [
"def",
"run",
"(",
"args",
"=",
"ARGV",
")",
"opts",
".",
"parse!",
"(",
"args",
")",
"if",
"!",
"analyze_gemfile?",
"&&",
"args",
".",
"empty?",
"puts",
"opts",
".",
"parser",
"exit",
"1",
"end",
"print_requires",
"(",
"options",
",",
"args",
")",
"... | Sets default options, to be overwritten by option parser down the road
@param args [Array<String>] runs the analyzer with parsed args taken as options
@return [void] | [
"Sets",
"default",
"options",
"to",
"be",
"overwritten",
"by",
"option",
"parser",
"down",
"the",
"road"
] | 19a8892f6baaeb16b1b166144c4f73852396220c | https://github.com/irvingwashington/gem_footprint_analyzer/blob/19a8892f6baaeb16b1b166144c4f73852396220c/lib/gem_footprint_analyzer/cli.rb#L19-L28 |
9,211 | gr4y/streambot | lib/streambot/tracker.rb | StreamBot.Tracker.start | def start
keywords = self.params["keywords"]
@thread = Thread.new do
@client.filter_by_keywords(keywords) do |status|
if retweet?(status)
before_retweet.trigger(status)
@retweet.retweet(status["id"])
after_retweet.trigger(status)
end
e... | ruby | def start
keywords = self.params["keywords"]
@thread = Thread.new do
@client.filter_by_keywords(keywords) do |status|
if retweet?(status)
before_retweet.trigger(status)
@retweet.retweet(status["id"])
after_retweet.trigger(status)
end
e... | [
"def",
"start",
"keywords",
"=",
"self",
".",
"params",
"[",
"\"keywords\"",
"]",
"@thread",
"=",
"Thread",
".",
"new",
"do",
"@client",
".",
"filter_by_keywords",
"(",
"keywords",
")",
"do",
"|",
"status",
"|",
"if",
"retweet?",
"(",
"status",
")",
"bef... | initializes the tracker
start the tracker | [
"initializes",
"the",
"tracker",
"start",
"the",
"tracker"
] | 3f454b62ea0c1e9eb29a3c7bf0d17f3caf14b375 | https://github.com/gr4y/streambot/blob/3f454b62ea0c1e9eb29a3c7bf0d17f3caf14b375/lib/streambot/tracker.rb#L22-L34 |
9,212 | gr4y/streambot | lib/streambot/tracker.rb | StreamBot.Tracker.load_filters | def load_filters
filters_config = self.params["filters_config" ]
if !filters_config.nil? && File.exists?(filters_config)
begin
YAML::load_file(filters_config)
rescue
on_error.trigger($!, $@)
end
end
end | ruby | def load_filters
filters_config = self.params["filters_config" ]
if !filters_config.nil? && File.exists?(filters_config)
begin
YAML::load_file(filters_config)
rescue
on_error.trigger($!, $@)
end
end
end | [
"def",
"load_filters",
"filters_config",
"=",
"self",
".",
"params",
"[",
"\"filters_config\"",
"]",
"if",
"!",
"filters_config",
".",
"nil?",
"&&",
"File",
".",
"exists?",
"(",
"filters_config",
")",
"begin",
"YAML",
"::",
"load_file",
"(",
"filters_config",
... | load the YAML file that is specified in the params | [
"load",
"the",
"YAML",
"file",
"that",
"is",
"specified",
"in",
"the",
"params"
] | 3f454b62ea0c1e9eb29a3c7bf0d17f3caf14b375 | https://github.com/gr4y/streambot/blob/3f454b62ea0c1e9eb29a3c7bf0d17f3caf14b375/lib/streambot/tracker.rb#L49-L58 |
9,213 | gr4y/streambot | lib/streambot/tracker.rb | StreamBot.Tracker.retweet? | def retweet?(status)
filters = load_filters
retweet = true
if !filters.nil?
filters.each_pair do |path, value|
array = []
array << value
array.flatten.each do |filter_value|
path_value = StreamBot::ArrayPath.get_path(status, path)
if path_v... | ruby | def retweet?(status)
filters = load_filters
retweet = true
if !filters.nil?
filters.each_pair do |path, value|
array = []
array << value
array.flatten.each do |filter_value|
path_value = StreamBot::ArrayPath.get_path(status, path)
if path_v... | [
"def",
"retweet?",
"(",
"status",
")",
"filters",
"=",
"load_filters",
"retweet",
"=",
"true",
"if",
"!",
"filters",
".",
"nil?",
"filters",
".",
"each_pair",
"do",
"|",
"path",
",",
"value",
"|",
"array",
"=",
"[",
"]",
"array",
"<<",
"value",
"array"... | decide if the status is retweetable | [
"decide",
"if",
"the",
"status",
"is",
"retweetable"
] | 3f454b62ea0c1e9eb29a3c7bf0d17f3caf14b375 | https://github.com/gr4y/streambot/blob/3f454b62ea0c1e9eb29a3c7bf0d17f3caf14b375/lib/streambot/tracker.rb#L61-L78 |
9,214 | jeffa/html-autotag-ruby | lib/HTML/AutoTag.rb | HTML.AutoTag.tag | def tag( params )
# TODO: make these method args if possible
tag = params['tag']
attr = params['attr']
cdata = params['cdata']
unless attr.kind_of?( HTML::AutoAttr )
attr = HTML::AutoAttr.new( attr, @sorted )
end
#... | ruby | def tag( params )
# TODO: make these method args if possible
tag = params['tag']
attr = params['attr']
cdata = params['cdata']
unless attr.kind_of?( HTML::AutoAttr )
attr = HTML::AutoAttr.new( attr, @sorted )
end
#... | [
"def",
"tag",
"(",
"params",
")",
"# TODO: make these method args if possible",
"tag",
"=",
"params",
"[",
"'tag'",
"]",
"attr",
"=",
"params",
"[",
"'attr'",
"]",
"cdata",
"=",
"params",
"[",
"'cdata'",
"]",
"unless",
"attr",
".",
"kind_of?",
"(",
"HTML",
... | Defaults to empty string which produces no encoding. | [
"Defaults",
"to",
"empty",
"string",
"which",
"produces",
"no",
"encoding",
"."
] | 994103cb2c73e0477077fc041e12c81b7ed6326c | https://github.com/jeffa/html-autotag-ruby/blob/994103cb2c73e0477077fc041e12c81b7ed6326c/lib/HTML/AutoTag.rb#L23-L75 |
9,215 | ashrafuzzaman/chartify | lib/chartify/chart_base.rb | Chartify.ChartBase.darken_color | def darken_color(hex_color, amount=0.4)
hex_color = hex_color.gsub('#', '')
rgb = hex_color.scan(/../).map { |color| color.hex }
rgb[0] = (rgb[0].to_i * amount).round
rgb[1] = (rgb[1].to_i * amount).round
rgb[2] = (rgb[2].to_i * amount).round
"#%02x%02x%02x" % rgb
end | ruby | def darken_color(hex_color, amount=0.4)
hex_color = hex_color.gsub('#', '')
rgb = hex_color.scan(/../).map { |color| color.hex }
rgb[0] = (rgb[0].to_i * amount).round
rgb[1] = (rgb[1].to_i * amount).round
rgb[2] = (rgb[2].to_i * amount).round
"#%02x%02x%02x" % rgb
end | [
"def",
"darken_color",
"(",
"hex_color",
",",
"amount",
"=",
"0.4",
")",
"hex_color",
"=",
"hex_color",
".",
"gsub",
"(",
"'#'",
",",
"''",
")",
"rgb",
"=",
"hex_color",
".",
"scan",
"(",
"/",
"/",
")",
".",
"map",
"{",
"|",
"color",
"|",
"color",
... | Amount should be a decimal between 0 and 1. Lower means darker | [
"Amount",
"should",
"be",
"a",
"decimal",
"between",
"0",
"and",
"1",
".",
"Lower",
"means",
"darker"
] | f791ffb20c10417619bec0afa7a355d9e5e499b6 | https://github.com/ashrafuzzaman/chartify/blob/f791ffb20c10417619bec0afa7a355d9e5e499b6/lib/chartify/chart_base.rb#L99-L106 |
9,216 | ashrafuzzaman/chartify | lib/chartify/chart_base.rb | Chartify.ChartBase.lighten_color | def lighten_color(hex_color, amount=0.6)
hex_color = hex_color.gsub('#', '')
rgb = hex_color.scan(/../).map { |color| color.hex }
rgb[0] = [(rgb[0].to_i + 255 * amount).round, 255].min
rgb[1] = [(rgb[1].to_i + 255 * amount).round, 255].min
rgb[2] = [(rgb[2].to_i + 255 * amount).round, 255]... | ruby | def lighten_color(hex_color, amount=0.6)
hex_color = hex_color.gsub('#', '')
rgb = hex_color.scan(/../).map { |color| color.hex }
rgb[0] = [(rgb[0].to_i + 255 * amount).round, 255].min
rgb[1] = [(rgb[1].to_i + 255 * amount).round, 255].min
rgb[2] = [(rgb[2].to_i + 255 * amount).round, 255]... | [
"def",
"lighten_color",
"(",
"hex_color",
",",
"amount",
"=",
"0.6",
")",
"hex_color",
"=",
"hex_color",
".",
"gsub",
"(",
"'#'",
",",
"''",
")",
"rgb",
"=",
"hex_color",
".",
"scan",
"(",
"/",
"/",
")",
".",
"map",
"{",
"|",
"color",
"|",
"color",... | Amount should be a decimal between 0 and 1. Higher means lighter | [
"Amount",
"should",
"be",
"a",
"decimal",
"between",
"0",
"and",
"1",
".",
"Higher",
"means",
"lighter"
] | f791ffb20c10417619bec0afa7a355d9e5e499b6 | https://github.com/ashrafuzzaman/chartify/blob/f791ffb20c10417619bec0afa7a355d9e5e499b6/lib/chartify/chart_base.rb#L109-L116 |
9,217 | jasonayre/trax_model | lib/trax/model.rb | Trax.Model.reverse_assign_attributes | def reverse_assign_attributes(attributes_hash)
attributes_to_assign = attributes_hash.keys.reject{|_attribute_name| attribute_present?(_attribute_name) }
assign_attributes(attributes_hash.slice(attributes_to_assign))
end | ruby | def reverse_assign_attributes(attributes_hash)
attributes_to_assign = attributes_hash.keys.reject{|_attribute_name| attribute_present?(_attribute_name) }
assign_attributes(attributes_hash.slice(attributes_to_assign))
end | [
"def",
"reverse_assign_attributes",
"(",
"attributes_hash",
")",
"attributes_to_assign",
"=",
"attributes_hash",
".",
"keys",
".",
"reject",
"{",
"|",
"_attribute_name",
"|",
"attribute_present?",
"(",
"_attribute_name",
")",
"}",
"assign_attributes",
"(",
"attributes_h... | like reverse merge, only assigns attributes which have not yet been assigned | [
"like",
"reverse",
"merge",
"only",
"assigns",
"attributes",
"which",
"have",
"not",
"yet",
"been",
"assigned"
] | 5e9b7b12f575a06306882440c147b70cca263d5c | https://github.com/jasonayre/trax_model/blob/5e9b7b12f575a06306882440c147b70cca263d5c/lib/trax/model.rb#L50-L54 |
9,218 | mkulumadzi/mediawiki-keiki | lib/mediawiki-keiki/query.rb | MediaWiki.Query.pages | def pages
result_map = map_query_to_results
query_result["query"]["pages"].each do |key, value|
page_title = value["title"]
original_query = find_result_map_match_for_title(result_map, page_title)
@page_hash[original_query] = MediaWiki::Page.new(value)
end
@page_hash
end | ruby | def pages
result_map = map_query_to_results
query_result["query"]["pages"].each do |key, value|
page_title = value["title"]
original_query = find_result_map_match_for_title(result_map, page_title)
@page_hash[original_query] = MediaWiki::Page.new(value)
end
@page_hash
end | [
"def",
"pages",
"result_map",
"=",
"map_query_to_results",
"query_result",
"[",
"\"query\"",
"]",
"[",
"\"pages\"",
"]",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"page_title",
"=",
"value",
"[",
"\"title\"",
"]",
"original_query",
"=",
"find_result_ma... | Returns a hash filled with Pages | [
"Returns",
"a",
"hash",
"filled",
"with",
"Pages"
] | 849338f643543f3a432d209f0413346d513c1e81 | https://github.com/mkulumadzi/mediawiki-keiki/blob/849338f643543f3a432d209f0413346d513c1e81/lib/mediawiki-keiki/query.rb#L32-L45 |
9,219 | mkulumadzi/mediawiki-keiki | lib/mediawiki-keiki/query.rb | MediaWiki.Query.map_query_to_results | def map_query_to_results
#Initalize map
result_map = initialize_map
# Apply the normalization to the result map
normalized = get_query_map("normalized")
if normalized
result_map = get_normalizations_for(result_map, normalized)
end
# Apply the redirects to the result map
redirects = get_qu... | ruby | def map_query_to_results
#Initalize map
result_map = initialize_map
# Apply the normalization to the result map
normalized = get_query_map("normalized")
if normalized
result_map = get_normalizations_for(result_map, normalized)
end
# Apply the redirects to the result map
redirects = get_qu... | [
"def",
"map_query_to_results",
"#Initalize map",
"result_map",
"=",
"initialize_map",
"# Apply the normalization to the result map",
"normalized",
"=",
"get_query_map",
"(",
"\"normalized\"",
")",
"if",
"normalized",
"result_map",
"=",
"get_normalizations_for",
"(",
"result_map... | Maps original query to results | [
"Maps",
"original",
"query",
"to",
"results"
] | 849338f643543f3a432d209f0413346d513c1e81 | https://github.com/mkulumadzi/mediawiki-keiki/blob/849338f643543f3a432d209f0413346d513c1e81/lib/mediawiki-keiki/query.rb#L70-L89 |
9,220 | alexdean/where_was_i | lib/where_was_i/track.rb | WhereWasI.Track.add_point | def add_point(lat:, lon:, elevation:, time:)
time = Time.parse(time) if ! time.is_a?(Time)
current = [lat, lon, elevation]
if @start_time.nil? || time < @start_time
@start_time = time
@start_location = current
end
if @end_time.nil? || time > @end_time
@end_... | ruby | def add_point(lat:, lon:, elevation:, time:)
time = Time.parse(time) if ! time.is_a?(Time)
current = [lat, lon, elevation]
if @start_time.nil? || time < @start_time
@start_time = time
@start_location = current
end
if @end_time.nil? || time > @end_time
@end_... | [
"def",
"add_point",
"(",
"lat",
":",
",",
"lon",
":",
",",
"elevation",
":",
",",
"time",
":",
")",
"time",
"=",
"Time",
".",
"parse",
"(",
"time",
")",
"if",
"!",
"time",
".",
"is_a?",
"(",
"Time",
")",
"current",
"=",
"[",
"lat",
",",
"lon",
... | add a point to the track
@param [Float] lat latitude
@param [Float] lon longitude
@param [Float] elevation elevation
@param [Time] time time at the given location | [
"add",
"a",
"point",
"to",
"the",
"track"
] | 10d1381d6e0b1a85de65678a540d4dbc6041321d | https://github.com/alexdean/where_was_i/blob/10d1381d6e0b1a85de65678a540d4dbc6041321d/lib/where_was_i/track.rb#L34-L52 |
9,221 | alexdean/where_was_i | lib/where_was_i/track.rb | WhereWasI.Track.in_time_range? | def in_time_range?(time)
time = Time.parse(time) if ! time.is_a?(Time)
time_range.cover?(time)
end | ruby | def in_time_range?(time)
time = Time.parse(time) if ! time.is_a?(Time)
time_range.cover?(time)
end | [
"def",
"in_time_range?",
"(",
"time",
")",
"time",
"=",
"Time",
".",
"parse",
"(",
"time",
")",
"if",
"!",
"time",
".",
"is_a?",
"(",
"Time",
")",
"time_range",
".",
"cover?",
"(",
"time",
")",
"end"
] | is the supplied time covered by this track?
@param time [Time]
@return Boolean | [
"is",
"the",
"supplied",
"time",
"covered",
"by",
"this",
"track?"
] | 10d1381d6e0b1a85de65678a540d4dbc6041321d | https://github.com/alexdean/where_was_i/blob/10d1381d6e0b1a85de65678a540d4dbc6041321d/lib/where_was_i/track.rb#L65-L68 |
9,222 | alexdean/where_was_i | lib/where_was_i/track.rb | WhereWasI.Track.at | def at(time)
if time.is_a?(String)
time = Time.parse(time)
end
if time.is_a?(Integer)
time = Time.at(time)
end
raise ArgumentError, "time must be a Time,String, or Fixnum" if ! time.is_a?(Time)
return nil if ! in_time_range?(time)
@interp ||= Interpolate::Poin... | ruby | def at(time)
if time.is_a?(String)
time = Time.parse(time)
end
if time.is_a?(Integer)
time = Time.at(time)
end
raise ArgumentError, "time must be a Time,String, or Fixnum" if ! time.is_a?(Time)
return nil if ! in_time_range?(time)
@interp ||= Interpolate::Poin... | [
"def",
"at",
"(",
"time",
")",
"if",
"time",
".",
"is_a?",
"(",
"String",
")",
"time",
"=",
"Time",
".",
"parse",
"(",
"time",
")",
"end",
"if",
"time",
".",
"is_a?",
"(",
"Integer",
")",
"time",
"=",
"Time",
".",
"at",
"(",
"time",
")",
"end",... | return the interpolated location for the given time
or nil if time is outside the track's start..end
@example
track.at(time) => {lat:48, lon:98, elevation: 2100}
@param time [String,Time,Fixnum]
@return [Hash,nil] | [
"return",
"the",
"interpolated",
"location",
"for",
"the",
"given",
"time",
"or",
"nil",
"if",
"time",
"is",
"outside",
"the",
"track",
"s",
"start",
"..",
"end"
] | 10d1381d6e0b1a85de65678a540d4dbc6041321d | https://github.com/alexdean/where_was_i/blob/10d1381d6e0b1a85de65678a540d4dbc6041321d/lib/where_was_i/track.rb#L77-L92 |
9,223 | rike422/loose-leaf | rakelib/task_helpers.rb | LooseLeaf.TaskHelpers.sh_in_dir | def sh_in_dir(dir, shell_commands)
shell_commands = [shell_commands] if shell_commands.is_a?(String)
shell_commands.each { |shell_command| sh %(cd #{dir} && #{shell_command.strip}) }
end | ruby | def sh_in_dir(dir, shell_commands)
shell_commands = [shell_commands] if shell_commands.is_a?(String)
shell_commands.each { |shell_command| sh %(cd #{dir} && #{shell_command.strip}) }
end | [
"def",
"sh_in_dir",
"(",
"dir",
",",
"shell_commands",
")",
"shell_commands",
"=",
"[",
"shell_commands",
"]",
"if",
"shell_commands",
".",
"is_a?",
"(",
"String",
")",
"shell_commands",
".",
"each",
"{",
"|",
"shell_command",
"|",
"sh",
"%(cd #{dir} && #{shell_... | Executes a string or an array of strings in a shell in the given directory | [
"Executes",
"a",
"string",
"or",
"an",
"array",
"of",
"strings",
"in",
"a",
"shell",
"in",
"the",
"given",
"directory"
] | ea3cb93667f83e5f4abb3c7879fc0220157aeb81 | https://github.com/rike422/loose-leaf/blob/ea3cb93667f83e5f4abb3c7879fc0220157aeb81/rakelib/task_helpers.rb#L22-L25 |
9,224 | zdavatz/odba | lib/odba/cache.rb | ODBA.Cache.create_deferred_indices | def create_deferred_indices(drop_existing = false)
@deferred_indices.each { |definition|
name = definition.index_name
if(drop_existing && self.indices.include?(name))
drop_index(name)
end
unless(self.indices.include?(name))
index = create_index(definition)
... | ruby | def create_deferred_indices(drop_existing = false)
@deferred_indices.each { |definition|
name = definition.index_name
if(drop_existing && self.indices.include?(name))
drop_index(name)
end
unless(self.indices.include?(name))
index = create_index(definition)
... | [
"def",
"create_deferred_indices",
"(",
"drop_existing",
"=",
"false",
")",
"@deferred_indices",
".",
"each",
"{",
"|",
"definition",
"|",
"name",
"=",
"definition",
".",
"index_name",
"if",
"(",
"drop_existing",
"&&",
"self",
".",
"indices",
".",
"include?",
"... | Creates or recreates automatically defined indices | [
"Creates",
"or",
"recreates",
"automatically",
"defined",
"indices"
] | 40a4f3a07abdc6d41d627338848ca8cb1dd52294 | https://github.com/zdavatz/odba/blob/40a4f3a07abdc6d41d627338848ca8cb1dd52294/lib/odba/cache.rb#L130-L143 |
9,225 | zdavatz/odba | lib/odba/cache.rb | ODBA.Cache.create_index | def create_index(index_definition, origin_module=Object)
transaction {
klass = if(index_definition.fulltext)
FulltextIndex
elsif(index_definition.resolve_search_term.is_a?(Hash))
ConditionIndex
else
Index
end
index = klass.new(index_definition, origin_module... | ruby | def create_index(index_definition, origin_module=Object)
transaction {
klass = if(index_definition.fulltext)
FulltextIndex
elsif(index_definition.resolve_search_term.is_a?(Hash))
ConditionIndex
else
Index
end
index = klass.new(index_definition, origin_module... | [
"def",
"create_index",
"(",
"index_definition",
",",
"origin_module",
"=",
"Object",
")",
"transaction",
"{",
"klass",
"=",
"if",
"(",
"index_definition",
".",
"fulltext",
")",
"FulltextIndex",
"elsif",
"(",
"index_definition",
".",
"resolve_search_term",
".",
"is... | Creates a new index according to IndexDefinition | [
"Creates",
"a",
"new",
"index",
"according",
"to",
"IndexDefinition"
] | 40a4f3a07abdc6d41d627338848ca8cb1dd52294 | https://github.com/zdavatz/odba/blob/40a4f3a07abdc6d41d627338848ca8cb1dd52294/lib/odba/cache.rb#L145-L159 |
9,226 | zdavatz/odba | lib/odba/cache.rb | ODBA.Cache.delete | def delete(odba_object)
odba_id = odba_object.odba_id
name = odba_object.odba_name
odba_object.odba_notify_observers(:delete, odba_id, odba_object.object_id)
rows = ODBA.storage.retrieve_connected_objects(odba_id)
rows.each { |row|
id = row.first
# Self-Referencing objects don't have to be ... | ruby | def delete(odba_object)
odba_id = odba_object.odba_id
name = odba_object.odba_name
odba_object.odba_notify_observers(:delete, odba_id, odba_object.object_id)
rows = ODBA.storage.retrieve_connected_objects(odba_id)
rows.each { |row|
id = row.first
# Self-Referencing objects don't have to be ... | [
"def",
"delete",
"(",
"odba_object",
")",
"odba_id",
"=",
"odba_object",
".",
"odba_id",
"name",
"=",
"odba_object",
".",
"odba_name",
"odba_object",
".",
"odba_notify_observers",
"(",
":delete",
",",
"odba_id",
",",
"odba_object",
".",
"object_id",
")",
"rows",... | Permanently deletes _object_ from the database and deconnects all connected
Persistables | [
"Permanently",
"deletes",
"_object_",
"from",
"the",
"database",
"and",
"deconnects",
"all",
"connected",
"Persistables"
] | 40a4f3a07abdc6d41d627338848ca8cb1dd52294 | https://github.com/zdavatz/odba/blob/40a4f3a07abdc6d41d627338848ca8cb1dd52294/lib/odba/cache.rb#L162-L185 |
9,227 | zdavatz/odba | lib/odba/cache.rb | ODBA.Cache.drop_index | def drop_index(index_name)
transaction {
ODBA.storage.drop_index(index_name)
self.delete(self.indices[index_name])
}
end | ruby | def drop_index(index_name)
transaction {
ODBA.storage.drop_index(index_name)
self.delete(self.indices[index_name])
}
end | [
"def",
"drop_index",
"(",
"index_name",
")",
"transaction",
"{",
"ODBA",
".",
"storage",
".",
"drop_index",
"(",
"index_name",
")",
"self",
".",
"delete",
"(",
"self",
".",
"indices",
"[",
"index_name",
"]",
")",
"}",
"end"
] | Permanently deletes the index named _index_name_ | [
"Permanently",
"deletes",
"the",
"index",
"named",
"_index_name_"
] | 40a4f3a07abdc6d41d627338848ca8cb1dd52294 | https://github.com/zdavatz/odba/blob/40a4f3a07abdc6d41d627338848ca8cb1dd52294/lib/odba/cache.rb#L199-L204 |
9,228 | zdavatz/odba | lib/odba/cache.rb | ODBA.Cache.next_id | def next_id
if @file_lock
dbname = ODBA.storage.instance_variable_get('@dbi').dbi_args.first.split(/:/).last
id = new_id(dbname, ODBA.storage)
else
id = ODBA.storage.next_id
end
@peers.each do |peer|
peer.reserve_next_id id rescue DRb::DRbError
end
id
... | ruby | def next_id
if @file_lock
dbname = ODBA.storage.instance_variable_get('@dbi').dbi_args.first.split(/:/).last
id = new_id(dbname, ODBA.storage)
else
id = ODBA.storage.next_id
end
@peers.each do |peer|
peer.reserve_next_id id rescue DRb::DRbError
end
id
... | [
"def",
"next_id",
"if",
"@file_lock",
"dbname",
"=",
"ODBA",
".",
"storage",
".",
"instance_variable_get",
"(",
"'@dbi'",
")",
".",
"dbi_args",
".",
"first",
".",
"split",
"(",
"/",
"/",
")",
".",
"last",
"id",
"=",
"new_id",
"(",
"dbname",
",",
"ODBA"... | Returns the next valid odba_id | [
"Returns",
"the",
"next",
"valid",
"odba_id"
] | 40a4f3a07abdc6d41d627338848ca8cb1dd52294 | https://github.com/zdavatz/odba/blob/40a4f3a07abdc6d41d627338848ca8cb1dd52294/lib/odba/cache.rb#L401-L414 |
9,229 | zdavatz/odba | lib/odba/cache.rb | ODBA.Cache.retrieve_from_index | def retrieve_from_index(index_name, search_term, meta=nil)
index = indices.fetch(index_name)
ids = index.fetch_ids(search_term, meta)
if meta.respond_to?(:error_limit) && (limit = meta.error_limit) \
&& (size = ids.size) > limit.to_i
error = OdbaResultLimitError.new
error.limit = lim... | ruby | def retrieve_from_index(index_name, search_term, meta=nil)
index = indices.fetch(index_name)
ids = index.fetch_ids(search_term, meta)
if meta.respond_to?(:error_limit) && (limit = meta.error_limit) \
&& (size = ids.size) > limit.to_i
error = OdbaResultLimitError.new
error.limit = lim... | [
"def",
"retrieve_from_index",
"(",
"index_name",
",",
"search_term",
",",
"meta",
"=",
"nil",
")",
"index",
"=",
"indices",
".",
"fetch",
"(",
"index_name",
")",
"ids",
"=",
"index",
".",
"fetch_ids",
"(",
"search_term",
",",
"meta",
")",
"if",
"meta",
"... | Find objects in an index | [
"Find",
"objects",
"in",
"an",
"index"
] | 40a4f3a07abdc6d41d627338848ca8cb1dd52294 | https://github.com/zdavatz/odba/blob/40a4f3a07abdc6d41d627338848ca8cb1dd52294/lib/odba/cache.rb#L457-L471 |
9,230 | zdavatz/odba | lib/odba/cache.rb | ODBA.Cache.store | def store(object)
odba_id = object.odba_id
name = object.odba_name
object.odba_notify_observers(:store, odba_id, object.object_id)
if(ids = Thread.current[:txids])
ids.unshift([odba_id,name])
end
## get target_ids before anything else
target_ids = object.odba_target_ids
changes = st... | ruby | def store(object)
odba_id = object.odba_id
name = object.odba_name
object.odba_notify_observers(:store, odba_id, object.object_id)
if(ids = Thread.current[:txids])
ids.unshift([odba_id,name])
end
## get target_ids before anything else
target_ids = object.odba_target_ids
changes = st... | [
"def",
"store",
"(",
"object",
")",
"odba_id",
"=",
"object",
".",
"odba_id",
"name",
"=",
"object",
".",
"odba_name",
"object",
".",
"odba_notify_observers",
"(",
":store",
",",
"odba_id",
",",
"object",
".",
"object_id",
")",
"if",
"(",
"ids",
"=",
"Th... | Store a Persistable _object_ in the database | [
"Store",
"a",
"Persistable",
"_object_",
"in",
"the",
"database"
] | 40a4f3a07abdc6d41d627338848ca8cb1dd52294 | https://github.com/zdavatz/odba/blob/40a4f3a07abdc6d41d627338848ca8cb1dd52294/lib/odba/cache.rb#L500-L521 |
9,231 | timotheeguerin/i18n_admin_utils | app/helpers/i18n_admin_utils/application_helper.rb | I18nAdminUtils.ApplicationHelper.translation_missing_icon | def translation_missing_icon(translation)
missing_translations = translation.missing_translations
color_id = (missing_translations.size.to_f/translation.translations.size.to_f*5).ceil-1
if missing_translations.size == 0
content_tag 'span', '', :class => 'glyphicon glyphicon-ok greentext',
... | ruby | def translation_missing_icon(translation)
missing_translations = translation.missing_translations
color_id = (missing_translations.size.to_f/translation.translations.size.to_f*5).ceil-1
if missing_translations.size == 0
content_tag 'span', '', :class => 'glyphicon glyphicon-ok greentext',
... | [
"def",
"translation_missing_icon",
"(",
"translation",
")",
"missing_translations",
"=",
"translation",
".",
"missing_translations",
"color_id",
"=",
"(",
"missing_translations",
".",
"size",
".",
"to_f",
"/",
"translation",
".",
"translations",
".",
"size",
".",
"t... | Show the number of translation missing with colorization | [
"Show",
"the",
"number",
"of",
"translation",
"missing",
"with",
"colorization"
] | c45c10e9707f3b876b8b37d120d77e46b25e1783 | https://github.com/timotheeguerin/i18n_admin_utils/blob/c45c10e9707f3b876b8b37d120d77e46b25e1783/app/helpers/i18n_admin_utils/application_helper.rb#L5-L15 |
9,232 | cbrumelle/blueprintr | lib/blueprint-css/lib/blueprint/namespace.rb | Blueprint.Namespace.add_namespace | def add_namespace(html, namespace)
html.gsub!(/(class=")([a-zA-Z0-9\-_ ]*)(")/) do |m|
classes = m.to_s.split('"')[1].split(' ')
classes.map! { |c| c = namespace + c }
'class="' + classes.join(' ') + '"'
end
html
end | ruby | def add_namespace(html, namespace)
html.gsub!(/(class=")([a-zA-Z0-9\-_ ]*)(")/) do |m|
classes = m.to_s.split('"')[1].split(' ')
classes.map! { |c| c = namespace + c }
'class="' + classes.join(' ') + '"'
end
html
end | [
"def",
"add_namespace",
"(",
"html",
",",
"namespace",
")",
"html",
".",
"gsub!",
"(",
"/",
"\\-",
"/",
")",
"do",
"|",
"m",
"|",
"classes",
"=",
"m",
".",
"to_s",
".",
"split",
"(",
"'\"'",
")",
"[",
"1",
"]",
".",
"split",
"(",
"' '",
")",
... | Read html to string, remove namespace if any,
set the new namespace, and update the test file.
adds namespace to BP classes in a html file | [
"Read",
"html",
"to",
"string",
"remove",
"namespace",
"if",
"any",
"set",
"the",
"new",
"namespace",
"and",
"update",
"the",
"test",
"file",
".",
"adds",
"namespace",
"to",
"BP",
"classes",
"in",
"a",
"html",
"file"
] | b414436f614a8d97d77b47b588ddcf3f5e61b6bd | https://github.com/cbrumelle/blueprintr/blob/b414436f614a8d97d77b47b588ddcf3f5e61b6bd/lib/blueprint-css/lib/blueprint/namespace.rb#L14-L21 |
9,233 | johnwunder/stix_schema_spy | lib/stix_schema_spy/models/simple_type.rb | StixSchemaSpy.SimpleType.enumeration_values | def enumeration_values
enumeration = @xml.xpath('./xs:restriction/xs:enumeration', {'xs' => 'http://www.w3.org/2001/XMLSchema'})
if enumeration.length > 0
return enumeration.map {|elem| [elem.attributes['value'].value, elem.xpath('./xs:annotation/xs:documentation', {'xs' => 'http://www.w3.org/2001/X... | ruby | def enumeration_values
enumeration = @xml.xpath('./xs:restriction/xs:enumeration', {'xs' => 'http://www.w3.org/2001/XMLSchema'})
if enumeration.length > 0
return enumeration.map {|elem| [elem.attributes['value'].value, elem.xpath('./xs:annotation/xs:documentation', {'xs' => 'http://www.w3.org/2001/X... | [
"def",
"enumeration_values",
"enumeration",
"=",
"@xml",
".",
"xpath",
"(",
"'./xs:restriction/xs:enumeration'",
",",
"{",
"'xs'",
"=>",
"'http://www.w3.org/2001/XMLSchema'",
"}",
")",
"if",
"enumeration",
".",
"length",
">",
"0",
"return",
"enumeration",
".",
"map"... | Returns the list of values for this enumeration | [
"Returns",
"the",
"list",
"of",
"values",
"for",
"this",
"enumeration"
] | 2d551c6854d749eb330340e69f73baee1c4b52d3 | https://github.com/johnwunder/stix_schema_spy/blob/2d551c6854d749eb330340e69f73baee1c4b52d3/lib/stix_schema_spy/models/simple_type.rb#L16-L23 |
9,234 | ideonetwork/lato-blog | lib/lato_blog/interfaces/categories.rb | LatoBlog.Interface::Categories.blog__create_default_category | def blog__create_default_category
category_parent = LatoBlog::CategoryParent.find_by(meta_default: true)
return if category_parent
category_parent = LatoBlog::CategoryParent.new(meta_default: true)
throw 'Impossible to create default category parent' unless category_parent.save
languages... | ruby | def blog__create_default_category
category_parent = LatoBlog::CategoryParent.find_by(meta_default: true)
return if category_parent
category_parent = LatoBlog::CategoryParent.new(meta_default: true)
throw 'Impossible to create default category parent' unless category_parent.save
languages... | [
"def",
"blog__create_default_category",
"category_parent",
"=",
"LatoBlog",
"::",
"CategoryParent",
".",
"find_by",
"(",
"meta_default",
":",
"true",
")",
"return",
"if",
"category_parent",
"category_parent",
"=",
"LatoBlog",
"::",
"CategoryParent",
".",
"new",
"(",
... | This function create the default category if it not exists. | [
"This",
"function",
"create",
"the",
"default",
"category",
"if",
"it",
"not",
"exists",
"."
] | a0d92de299a0e285851743b9d4a902f611187cba | https://github.com/ideonetwork/lato-blog/blob/a0d92de299a0e285851743b9d4a902f611187cba/lib/lato_blog/interfaces/categories.rb#L7-L25 |
9,235 | ideonetwork/lato-blog | lib/lato_blog/interfaces/categories.rb | LatoBlog.Interface::Categories.blog__clean_category_parents | def blog__clean_category_parents
category_parents = LatoBlog::CategoryParent.all
category_parents.map { |cp| cp.destroy if cp.categories.empty? }
end | ruby | def blog__clean_category_parents
category_parents = LatoBlog::CategoryParent.all
category_parents.map { |cp| cp.destroy if cp.categories.empty? }
end | [
"def",
"blog__clean_category_parents",
"category_parents",
"=",
"LatoBlog",
"::",
"CategoryParent",
".",
"all",
"category_parents",
".",
"map",
"{",
"|",
"cp",
"|",
"cp",
".",
"destroy",
"if",
"cp",
".",
"categories",
".",
"empty?",
"}",
"end"
] | This function cleans all old category parents without any child. | [
"This",
"function",
"cleans",
"all",
"old",
"category",
"parents",
"without",
"any",
"child",
"."
] | a0d92de299a0e285851743b9d4a902f611187cba | https://github.com/ideonetwork/lato-blog/blob/a0d92de299a0e285851743b9d4a902f611187cba/lib/lato_blog/interfaces/categories.rb#L28-L31 |
9,236 | ideonetwork/lato-blog | lib/lato_blog/interfaces/categories.rb | LatoBlog.Interface::Categories.blog__get_categories | def blog__get_categories(
order: nil,
language: nil,
search: nil,
page: nil,
per_page: nil
)
categories = LatoBlog::Category.all
# apply filters
order = order && order == 'ASC' ? 'ASC' : 'DESC'
categories = _categories_filter_by_order(categories, order)
c... | ruby | def blog__get_categories(
order: nil,
language: nil,
search: nil,
page: nil,
per_page: nil
)
categories = LatoBlog::Category.all
# apply filters
order = order && order == 'ASC' ? 'ASC' : 'DESC'
categories = _categories_filter_by_order(categories, order)
c... | [
"def",
"blog__get_categories",
"(",
"order",
":",
"nil",
",",
"language",
":",
"nil",
",",
"search",
":",
"nil",
",",
"page",
":",
"nil",
",",
"per_page",
":",
"nil",
")",
"categories",
"=",
"LatoBlog",
"::",
"Category",
".",
"all",
"# apply filters",
"o... | This function returns an object with the list of categories with some filters. | [
"This",
"function",
"returns",
"an",
"object",
"with",
"the",
"list",
"of",
"categories",
"with",
"some",
"filters",
"."
] | a0d92de299a0e285851743b9d4a902f611187cba | https://github.com/ideonetwork/lato-blog/blob/a0d92de299a0e285851743b9d4a902f611187cba/lib/lato_blog/interfaces/categories.rb#L34-L68 |
9,237 | davidbarral/sugarfree-config | lib/sugarfree-config/config.rb | SugarfreeConfig.Config.fetch_config | def fetch_config
Rails.logger.debug "Loading #{@file}::#{@env}" if Object.const_defined?('Rails') && Rails.logger.present?
YAML::load_file(@file)[@env.to_s]
end | ruby | def fetch_config
Rails.logger.debug "Loading #{@file}::#{@env}" if Object.const_defined?('Rails') && Rails.logger.present?
YAML::load_file(@file)[@env.to_s]
end | [
"def",
"fetch_config",
"Rails",
".",
"logger",
".",
"debug",
"\"Loading #{@file}::#{@env}\"",
"if",
"Object",
".",
"const_defined?",
"(",
"'Rails'",
")",
"&&",
"Rails",
".",
"logger",
".",
"present?",
"YAML",
"::",
"load_file",
"(",
"@file",
")",
"[",
"@env",
... | Fetch the config from the file | [
"Fetch",
"the",
"config",
"from",
"the",
"file"
] | 76b590627d50cd50b237c21fdf8ea3022ebbdf42 | https://github.com/davidbarral/sugarfree-config/blob/76b590627d50cd50b237c21fdf8ea3022ebbdf42/lib/sugarfree-config/config.rb#L47-L50 |
9,238 | davidbarral/sugarfree-config | lib/sugarfree-config/config.rb | SugarfreeConfig.Config.default_options | def default_options
if Object.const_defined?('Rails')
{
:file => Rails.root.join('config', 'config.yml'),
:reload => Rails.env.development?,
:env => Rails.env
}
else
{
:file => File.expand_path("config.yml"),
... | ruby | def default_options
if Object.const_defined?('Rails')
{
:file => Rails.root.join('config', 'config.yml'),
:reload => Rails.env.development?,
:env => Rails.env
}
else
{
:file => File.expand_path("config.yml"),
... | [
"def",
"default_options",
"if",
"Object",
".",
"const_defined?",
"(",
"'Rails'",
")",
"{",
":file",
"=>",
"Rails",
".",
"root",
".",
"join",
"(",
"'config'",
",",
"'config.yml'",
")",
",",
":reload",
"=>",
"Rails",
".",
"env",
".",
"development?",
",",
"... | Default configuration options for Rails and non Rails applications | [
"Default",
"configuration",
"options",
"for",
"Rails",
"and",
"non",
"Rails",
"applications"
] | 76b590627d50cd50b237c21fdf8ea3022ebbdf42 | https://github.com/davidbarral/sugarfree-config/blob/76b590627d50cd50b237c21fdf8ea3022ebbdf42/lib/sugarfree-config/config.rb#L55-L69 |
9,239 | davidbarral/sugarfree-config | lib/sugarfree-config/config.rb | SugarfreeConfig.ConfigIterator.next | def next
if (value = @scoped_config[@path_elements.last]).nil?
raise ConfigKeyException.new(@path_elements)
elsif value.is_a?(Hash)
@scoped_config = value
self
else
value
end
end | ruby | def next
if (value = @scoped_config[@path_elements.last]).nil?
raise ConfigKeyException.new(@path_elements)
elsif value.is_a?(Hash)
@scoped_config = value
self
else
value
end
end | [
"def",
"next",
"if",
"(",
"value",
"=",
"@scoped_config",
"[",
"@path_elements",
".",
"last",
"]",
")",
".",
"nil?",
"raise",
"ConfigKeyException",
".",
"new",
"(",
"@path_elements",
")",
"elsif",
"value",
".",
"is_a?",
"(",
"Hash",
")",
"@scoped_config",
... | Iterate to the next element in the path
Algorithm:
1. Get the last element of the key path
2. Try to find it in the scoped config
3. If not present raise an error
4. If present and is a hash we are not in a config leaf, so the scoped
config is reset to this new value and self is returned
5. If present and is... | [
"Iterate",
"to",
"the",
"next",
"element",
"in",
"the",
"path"
] | 76b590627d50cd50b237c21fdf8ea3022ebbdf42 | https://github.com/davidbarral/sugarfree-config/blob/76b590627d50cd50b237c21fdf8ea3022ebbdf42/lib/sugarfree-config/config.rb#L117-L126 |
9,240 | heelhook/class-proxy | lib/classproxy/classproxy.rb | ClassProxy.ClassMethods.proxy_methods | def proxy_methods(*methods)
@_methods ||= {}
methods.each do |method|
if method.is_a? Symbol
# If given a symbol, store as a method to overwrite and use the default loader
proxy_method method
elsif method.is_a? Hash
# If its a hash it will include methods to ov... | ruby | def proxy_methods(*methods)
@_methods ||= {}
methods.each do |method|
if method.is_a? Symbol
# If given a symbol, store as a method to overwrite and use the default loader
proxy_method method
elsif method.is_a? Hash
# If its a hash it will include methods to ov... | [
"def",
"proxy_methods",
"(",
"*",
"methods",
")",
"@_methods",
"||=",
"{",
"}",
"methods",
".",
"each",
"do",
"|",
"method",
"|",
"if",
"method",
".",
"is_a?",
"Symbol",
"# If given a symbol, store as a method to overwrite and use the default loader",
"proxy_method",
... | Establish attributes to proxy along with an alternative proc of how
the attribute should be loaded
@example Load method using uppercase
class GithubUser
include ClassProxy
fallback_fetch { |args| Octokit.user(args[:login]) }
after_fallback_fetch { |obj| self.name = obj.name; self.login = obj.login... | [
"Establish",
"attributes",
"to",
"proxy",
"along",
"with",
"an",
"alternative",
"proc",
"of",
"how",
"the",
"attribute",
"should",
"be",
"loaded"
] | df69405274133a359aa65e393205c61d47dd5362 | https://github.com/heelhook/class-proxy/blob/df69405274133a359aa65e393205c61d47dd5362/lib/classproxy/classproxy.rb#L63-L75 |
9,241 | heelhook/class-proxy | lib/classproxy/classproxy.rb | ClassProxy.ClassMethods.fetch | def fetch(args, options={})
@primary_fetch.is_a?(Proc) ? @primary_fetch[args] : (raise NotFound)
rescue NotFound
return nil if options[:skip_fallback]
run_fallback(args)
end | ruby | def fetch(args, options={})
@primary_fetch.is_a?(Proc) ? @primary_fetch[args] : (raise NotFound)
rescue NotFound
return nil if options[:skip_fallback]
run_fallback(args)
end | [
"def",
"fetch",
"(",
"args",
",",
"options",
"=",
"{",
"}",
")",
"@primary_fetch",
".",
"is_a?",
"(",
"Proc",
")",
"?",
"@primary_fetch",
"[",
"args",
"]",
":",
"(",
"raise",
"NotFound",
")",
"rescue",
"NotFound",
"return",
"nil",
"if",
"options",
"[",... | Method to find a record using a hash as the criteria
@example
class GithubUser
include MongoMapper::Document
include ClassProxy
primary_fetch { |args| where(args).first or (raise NotFound) }
fallback_fetch { |args| Octokit.user(args[:login]) }
end
GithubUser.fetch(login: 'heelhook') # ... | [
"Method",
"to",
"find",
"a",
"record",
"using",
"a",
"hash",
"as",
"the",
"criteria"
] | df69405274133a359aa65e393205c61d47dd5362 | https://github.com/heelhook/class-proxy/blob/df69405274133a359aa65e393205c61d47dd5362/lib/classproxy/classproxy.rb#L93-L99 |
9,242 | dominikh/weechat-ruby | lib/weechat/plugin.rb | Weechat.Plugin.unload | def unload(force = false)
if name == "ruby" and !force
Weechat.puts "Won't unload the ruby plugin unless you force it."
false
else
Weechat.exec("/plugin unload #{name}")
true
end
end | ruby | def unload(force = false)
if name == "ruby" and !force
Weechat.puts "Won't unload the ruby plugin unless you force it."
false
else
Weechat.exec("/plugin unload #{name}")
true
end
end | [
"def",
"unload",
"(",
"force",
"=",
"false",
")",
"if",
"name",
"==",
"\"ruby\"",
"and",
"!",
"force",
"Weechat",
".",
"puts",
"\"Won't unload the ruby plugin unless you force it.\"",
"false",
"else",
"Weechat",
".",
"exec",
"(",
"\"/plugin unload #{name}\"",
")",
... | Unloads the plugin.
@param [Boolean] force If the plugin to be unloaded is "ruby",
+force+ has to be true.
@return [Boolean] true if we attempted to unload the plugin | [
"Unloads",
"the",
"plugin",
"."
] | b3bbe37e5c0cc0a41e9107a23b7cfbb39c0e59eb | https://github.com/dominikh/weechat-ruby/blob/b3bbe37e5c0cc0a41e9107a23b7cfbb39c0e59eb/lib/weechat/plugin.rb#L70-L78 |
9,243 | dominikh/weechat-ruby | lib/weechat/plugin.rb | Weechat.Plugin.scripts | def scripts
scripts = []
Infolist.parse("#{name}_script").each do |script|
scripts << Script.new(script[:pointer], self)
end
scripts
end | ruby | def scripts
scripts = []
Infolist.parse("#{name}_script").each do |script|
scripts << Script.new(script[:pointer], self)
end
scripts
end | [
"def",
"scripts",
"scripts",
"=",
"[",
"]",
"Infolist",
".",
"parse",
"(",
"\"#{name}_script\"",
")",
".",
"each",
"do",
"|",
"script",
"|",
"scripts",
"<<",
"Script",
".",
"new",
"(",
"script",
"[",
":pointer",
"]",
",",
"self",
")",
"end",
"scripts",... | Returns an array of all scripts loaded by this plugin.
@return [Array<Script>] | [
"Returns",
"an",
"array",
"of",
"all",
"scripts",
"loaded",
"by",
"this",
"plugin",
"."
] | b3bbe37e5c0cc0a41e9107a23b7cfbb39c0e59eb | https://github.com/dominikh/weechat-ruby/blob/b3bbe37e5c0cc0a41e9107a23b7cfbb39c0e59eb/lib/weechat/plugin.rb#L95-L101 |
9,244 | whyarkadas/http_ping | lib/HttpPing/wmi.rb | HttpPing.HttpPing::WMI.ping | def ping(host = @host, options = {})
super(host)
lhost = Socket.gethostname
cs = "winmgmts:{impersonationLevel=impersonate}!//#{lhost}/root/cimv2"
wmi = WIN32OLE.connect(cs)
query = "select * from win32_pingstatus where address = '#{host}'"
unless options.empty?
options.e... | ruby | def ping(host = @host, options = {})
super(host)
lhost = Socket.gethostname
cs = "winmgmts:{impersonationLevel=impersonate}!//#{lhost}/root/cimv2"
wmi = WIN32OLE.connect(cs)
query = "select * from win32_pingstatus where address = '#{host}'"
unless options.empty?
options.e... | [
"def",
"ping",
"(",
"host",
"=",
"@host",
",",
"options",
"=",
"{",
"}",
")",
"super",
"(",
"host",
")",
"lhost",
"=",
"Socket",
".",
"gethostname",
"cs",
"=",
"\"winmgmts:{impersonationLevel=impersonate}!//#{lhost}/root/cimv2\"",
"wmi",
"=",
"WIN32OLE",
".",
... | Unlike the ping method for other Ping subclasses, this version returns
a PingStatus struct which contains various bits of information about
the results of the ping itself, such as response time.
In addition, this version allows you to pass certain options that are
then passed on to the underlying WQL query. See th... | [
"Unlike",
"the",
"ping",
"method",
"for",
"other",
"Ping",
"subclasses",
"this",
"version",
"returns",
"a",
"PingStatus",
"struct",
"which",
"contains",
"various",
"bits",
"of",
"information",
"about",
"the",
"results",
"of",
"the",
"ping",
"itself",
"such",
"... | 0a30dc5e10c56494d10ab270c64d76e085770bf8 | https://github.com/whyarkadas/http_ping/blob/0a30dc5e10c56494d10ab270c64d76e085770bf8/lib/HttpPing/wmi.rb#L60-L110 |
9,245 | caruby/core | lib/caruby/database/sql_executor.rb | CaRuby.SQLExecutor.query | def query(sql, *args, &block)
fetched = nil
execute do |dbh|
result = dbh.execute(sql, *args)
if block_given? then
result.each(&block)
else
fetched = result.fetch(:all)
end
result.finish
end
fetched
end | ruby | def query(sql, *args, &block)
fetched = nil
execute do |dbh|
result = dbh.execute(sql, *args)
if block_given? then
result.each(&block)
else
fetched = result.fetch(:all)
end
result.finish
end
fetched
end | [
"def",
"query",
"(",
"sql",
",",
"*",
"args",
",",
"&",
"block",
")",
"fetched",
"=",
"nil",
"execute",
"do",
"|",
"dbh",
"|",
"result",
"=",
"dbh",
".",
"execute",
"(",
"sql",
",",
"args",
")",
"if",
"block_given?",
"then",
"result",
".",
"each",
... | Runs the given query.
@param [String] sql the SQL to execute
@param [Array] args the SQL bindings
@yield [row] operate on the result
@yield [Array] the result row
@return [Array] the query result | [
"Runs",
"the",
"given",
"query",
"."
] | a682dc57c6fa31aef765cdd206ed3d4b4c289c60 | https://github.com/caruby/core/blob/a682dc57c6fa31aef765cdd206ed3d4b4c289c60/lib/caruby/database/sql_executor.rb#L100-L112 |
9,246 | caruby/core | lib/caruby/database/sql_executor.rb | CaRuby.SQLExecutor.transact | def transact(sql=nil, *args)
# Work-around for rcbi nil substitution.
if sql then
sql, *args = replace_nil_binds(sql, args)
transact { |dbh| dbh.execute(sql, *args) }
elsif block_given? then
execute { |dbh| dbh.transaction { yield dbh } }
else
raise ArgumentError.... | ruby | def transact(sql=nil, *args)
# Work-around for rcbi nil substitution.
if sql then
sql, *args = replace_nil_binds(sql, args)
transact { |dbh| dbh.execute(sql, *args) }
elsif block_given? then
execute { |dbh| dbh.transaction { yield dbh } }
else
raise ArgumentError.... | [
"def",
"transact",
"(",
"sql",
"=",
"nil",
",",
"*",
"args",
")",
"# Work-around for rcbi nil substitution.",
"if",
"sql",
"then",
"sql",
",",
"*",
"args",
"=",
"replace_nil_binds",
"(",
"sql",
",",
"args",
")",
"transact",
"{",
"|",
"dbh",
"|",
"dbh",
"... | Runs the given SQL or block in a transaction. If SQL is provided, then that
SQL is executed. Otherwise, the block is called.
@quirk RDBI RDBI converts nil args to 12. Work-around this bug by embedding
+NULL+ in the SQL instead.
@param [String] sql the SQL to execute
@param [Array] args the SQL bindings
@yield... | [
"Runs",
"the",
"given",
"SQL",
"or",
"block",
"in",
"a",
"transaction",
".",
"If",
"SQL",
"is",
"provided",
"then",
"that",
"SQL",
"is",
"executed",
".",
"Otherwise",
"the",
"block",
"is",
"called",
"."
] | a682dc57c6fa31aef765cdd206ed3d4b4c289c60 | https://github.com/caruby/core/blob/a682dc57c6fa31aef765cdd206ed3d4b4c289c60/lib/caruby/database/sql_executor.rb#L124-L134 |
9,247 | caruby/core | lib/caruby/database/sql_executor.rb | CaRuby.SQLExecutor.replace_nil_binds | def replace_nil_binds(sql, args)
nils = []
args.each_with_index { |value, i| nils << i if value.nil? }
unless nils.empty? then
logger.debug { "SQL executor working around RDBI bug by eliminating the nil arguments #{nils.to_series} for the SQL:\n#{sql}..." }
# Quoted ? is too much of a ... | ruby | def replace_nil_binds(sql, args)
nils = []
args.each_with_index { |value, i| nils << i if value.nil? }
unless nils.empty? then
logger.debug { "SQL executor working around RDBI bug by eliminating the nil arguments #{nils.to_series} for the SQL:\n#{sql}..." }
# Quoted ? is too much of a ... | [
"def",
"replace_nil_binds",
"(",
"sql",
",",
"args",
")",
"nils",
"=",
"[",
"]",
"args",
".",
"each_with_index",
"{",
"|",
"value",
",",
"i",
"|",
"nils",
"<<",
"i",
"if",
"value",
".",
"nil?",
"}",
"unless",
"nils",
".",
"empty?",
"then",
"logger",
... | Replaces nil arguments with a +NULL+ literal in the given SQL.
@param (see #transact)
@return [Array] the (possibly modified) SQL followed by the non-nil arguments | [
"Replaces",
"nil",
"arguments",
"with",
"a",
"+",
"NULL",
"+",
"literal",
"in",
"the",
"given",
"SQL",
"."
] | a682dc57c6fa31aef765cdd206ed3d4b4c289c60 | https://github.com/caruby/core/blob/a682dc57c6fa31aef765cdd206ed3d4b4c289c60/lib/caruby/database/sql_executor.rb#L146-L172 |
9,248 | minch/buoy_data | lib/buoy_data/noaa_station.rb | BuoyData.NoaaStation.current_reading | def current_reading(doc)
reading = {}
xpath = "//table/caption[@class='titleDataHeader']["
xpath += "contains(text(),'Conditions')"
xpath += " and "
xpath += "not(contains(text(),'Solar Radiation'))"
xpath += "]"
# Get the reading timestamp
source_updated_at = reading_t... | ruby | def current_reading(doc)
reading = {}
xpath = "//table/caption[@class='titleDataHeader']["
xpath += "contains(text(),'Conditions')"
xpath += " and "
xpath += "not(contains(text(),'Solar Radiation'))"
xpath += "]"
# Get the reading timestamp
source_updated_at = reading_t... | [
"def",
"current_reading",
"(",
"doc",
")",
"reading",
"=",
"{",
"}",
"xpath",
"=",
"\"//table/caption[@class='titleDataHeader'][\"",
"xpath",
"+=",
"\"contains(text(),'Conditions')\"",
"xpath",
"+=",
"\" and \"",
"xpath",
"+=",
"\"not(contains(text(),'Solar Radiation'))\"",
... | Reding from the 'Conditions at..as of..' table | [
"Reding",
"from",
"the",
"Conditions",
"at",
"..",
"as",
"of",
"..",
"table"
] | 6f1e36828ed6df1cb2610d09cc046118291dbe55 | https://github.com/minch/buoy_data/blob/6f1e36828ed6df1cb2610d09cc046118291dbe55/lib/buoy_data/noaa_station.rb#L73-L98 |
9,249 | m-31/vcenter_lib | lib/vcenter_lib/vm_converter.rb | VcenterLib.VmConverter.facts | def facts
logger.debug "get complete data of all VMs in all datacenters: begin"
result = Hash[vm_mos_to_h(@vcenter.vms).map do |h|
[h['name'], Hash[h.map { |k, v| [k.tr('.', '_'), v] }]]
end]
logger.debug "get complete data of all VMs in all datacenters: end"
result
end | ruby | def facts
logger.debug "get complete data of all VMs in all datacenters: begin"
result = Hash[vm_mos_to_h(@vcenter.vms).map do |h|
[h['name'], Hash[h.map { |k, v| [k.tr('.', '_'), v] }]]
end]
logger.debug "get complete data of all VMs in all datacenters: end"
result
end | [
"def",
"facts",
"logger",
".",
"debug",
"\"get complete data of all VMs in all datacenters: begin\"",
"result",
"=",
"Hash",
"[",
"vm_mos_to_h",
"(",
"@vcenter",
".",
"vms",
")",
".",
"map",
"do",
"|",
"h",
"|",
"[",
"h",
"[",
"'name'",
"]",
",",
"Hash",
"["... | get all vms and their facts as hash with vm.name as key | [
"get",
"all",
"vms",
"and",
"their",
"facts",
"as",
"hash",
"with",
"vm",
".",
"name",
"as",
"key"
] | 28ed325c73a1faaa5347919006d5a63c1bef6588 | https://github.com/m-31/vcenter_lib/blob/28ed325c73a1faaa5347919006d5a63c1bef6588/lib/vcenter_lib/vm_converter.rb#L54-L61 |
9,250 | ludocracy/Duxml | lib/duxml/doc/element.rb | Duxml.ElementGuts.traverse | def traverse(node=nil, &block)
return self.to_enum unless block_given?
node_stack = [node || self]
until node_stack.empty?
current = node_stack.shift
if current
yield current
node_stack = node_stack.insert(0, *current.nodes) if current.respond_to?(:nodes)
en... | ruby | def traverse(node=nil, &block)
return self.to_enum unless block_given?
node_stack = [node || self]
until node_stack.empty?
current = node_stack.shift
if current
yield current
node_stack = node_stack.insert(0, *current.nodes) if current.respond_to?(:nodes)
en... | [
"def",
"traverse",
"(",
"node",
"=",
"nil",
",",
"&",
"block",
")",
"return",
"self",
".",
"to_enum",
"unless",
"block_given?",
"node_stack",
"=",
"[",
"node",
"||",
"self",
"]",
"until",
"node_stack",
".",
"empty?",
"current",
"=",
"node_stack",
".",
"s... | pre-order traverse through this node and all of its descendants
@param &block [block] code to execute for each yielded node | [
"pre",
"-",
"order",
"traverse",
"through",
"this",
"node",
"and",
"all",
"of",
"its",
"descendants"
] | b7d16c0bd27195825620091dfa60e21712221720 | https://github.com/ludocracy/Duxml/blob/b7d16c0bd27195825620091dfa60e21712221720/lib/duxml/doc/element.rb#L215-L226 |
9,251 | sheax0r/ruby-cloudpassage | lib/cloudpassage/base.rb | Cloudpassage.Base.method_missing | def method_missing(sym, *args, &block)
if (data && data[sym])
data[sym]
else
super(sym, *args, &block)
end
end | ruby | def method_missing(sym, *args, &block)
if (data && data[sym])
data[sym]
else
super(sym, *args, &block)
end
end | [
"def",
"method_missing",
"(",
"sym",
",",
"*",
"args",
",",
"&",
"block",
")",
"if",
"(",
"data",
"&&",
"data",
"[",
"sym",
"]",
")",
"data",
"[",
"sym",
"]",
"else",
"super",
"(",
"sym",
",",
"args",
",",
"block",
")",
"end",
"end"
] | If method is missing, try to pass through to underlying data hash. | [
"If",
"method",
"is",
"missing",
"try",
"to",
"pass",
"through",
"to",
"underlying",
"data",
"hash",
"."
] | b70d24d0d5f91d92ae8532ed11c087ee9130f6dc | https://github.com/sheax0r/ruby-cloudpassage/blob/b70d24d0d5f91d92ae8532ed11c087ee9130f6dc/lib/cloudpassage/base.rb#L42-L48 |
9,252 | bradfeehan/derelict | lib/derelict/instance.rb | Derelict.Instance.validate! | def validate!
logger.debug "Starting validation for #{description}"
raise NotFound.new path unless File.exists? path
raise NonDirectory.new path unless File.directory? path
raise MissingBinary.new vagrant unless File.exists? vagrant
raise MissingBinary.new vagrant unless File.executable? v... | ruby | def validate!
logger.debug "Starting validation for #{description}"
raise NotFound.new path unless File.exists? path
raise NonDirectory.new path unless File.directory? path
raise MissingBinary.new vagrant unless File.exists? vagrant
raise MissingBinary.new vagrant unless File.executable? v... | [
"def",
"validate!",
"logger",
".",
"debug",
"\"Starting validation for #{description}\"",
"raise",
"NotFound",
".",
"new",
"path",
"unless",
"File",
".",
"exists?",
"path",
"raise",
"NonDirectory",
".",
"new",
"path",
"unless",
"File",
".",
"directory?",
"path",
"... | Initialize an instance for a particular directory
* path: The path to the Vagrant installation folder (optional,
defaults to DEFAULT_PATH)
Validates the data used for this instance
Raises exceptions on failure:
* +Derelict::Instance::NotFound+ if the instance is not found
* +Derelict::Instance:... | [
"Initialize",
"an",
"instance",
"for",
"a",
"particular",
"directory"
] | c9d70f04562280a34083dd060b0e4099e6f32d8d | https://github.com/bradfeehan/derelict/blob/c9d70f04562280a34083dd060b0e4099e6f32d8d/lib/derelict/instance.rb#L39-L47 |
9,253 | bradfeehan/derelict | lib/derelict/instance.rb | Derelict.Instance.version | def version
logger.info "Determining Vagrant version for #{description}"
output = execute!("--version").stdout
Derelict::Parser::Version.new(output).version
end | ruby | def version
logger.info "Determining Vagrant version for #{description}"
output = execute!("--version").stdout
Derelict::Parser::Version.new(output).version
end | [
"def",
"version",
"logger",
".",
"info",
"\"Determining Vagrant version for #{description}\"",
"output",
"=",
"execute!",
"(",
"\"--version\"",
")",
".",
"stdout",
"Derelict",
"::",
"Parser",
"::",
"Version",
".",
"new",
"(",
"output",
")",
".",
"version",
"end"
] | Determines the version of this Vagrant instance | [
"Determines",
"the",
"version",
"of",
"this",
"Vagrant",
"instance"
] | c9d70f04562280a34083dd060b0e4099e6f32d8d | https://github.com/bradfeehan/derelict/blob/c9d70f04562280a34083dd060b0e4099e6f32d8d/lib/derelict/instance.rb#L50-L54 |
9,254 | bradfeehan/derelict | lib/derelict/instance.rb | Derelict.Instance.execute | def execute(subcommand, *arguments, &block)
options = arguments.last.is_a?(Hash) ? arguments.pop : Hash.new
command = command(subcommand, *arguments)
command = "sudo -- #{command}" if options.delete(:sudo)
logger.debug "Executing #{command} using #{description}"
Executer.execute command, o... | ruby | def execute(subcommand, *arguments, &block)
options = arguments.last.is_a?(Hash) ? arguments.pop : Hash.new
command = command(subcommand, *arguments)
command = "sudo -- #{command}" if options.delete(:sudo)
logger.debug "Executing #{command} using #{description}"
Executer.execute command, o... | [
"def",
"execute",
"(",
"subcommand",
",",
"*",
"arguments",
",",
"&",
"block",
")",
"options",
"=",
"arguments",
".",
"last",
".",
"is_a?",
"(",
"Hash",
")",
"?",
"arguments",
".",
"pop",
":",
"Hash",
".",
"new",
"command",
"=",
"command",
"(",
"subc... | Executes a Vagrant subcommand using this instance
* subcommand: Vagrant subcommand to run (:up, :status, etc.)
* arguments: Arguments to pass to the subcommand (optional)
* options: If the last argument is a Hash, it will be used
as a hash of options. A list of valid options is
... | [
"Executes",
"a",
"Vagrant",
"subcommand",
"using",
"this",
"instance"
] | c9d70f04562280a34083dd060b0e4099e6f32d8d | https://github.com/bradfeehan/derelict/blob/c9d70f04562280a34083dd060b0e4099e6f32d8d/lib/derelict/instance.rb#L70-L76 |
9,255 | bradfeehan/derelict | lib/derelict/instance.rb | Derelict.Instance.command | def command(subcommand, *arguments)
args = [vagrant, subcommand.to_s, arguments].flatten
args.map {|a| Shellwords.escape a }.join(' ').tap do |command|
logger.debug "Generated command '#{command}' from " +
"subcommand '#{subcommand.to_s}' with arguments " +
arguments.in... | ruby | def command(subcommand, *arguments)
args = [vagrant, subcommand.to_s, arguments].flatten
args.map {|a| Shellwords.escape a }.join(' ').tap do |command|
logger.debug "Generated command '#{command}' from " +
"subcommand '#{subcommand.to_s}' with arguments " +
arguments.in... | [
"def",
"command",
"(",
"subcommand",
",",
"*",
"arguments",
")",
"args",
"=",
"[",
"vagrant",
",",
"subcommand",
".",
"to_s",
",",
"arguments",
"]",
".",
"flatten",
"args",
".",
"map",
"{",
"|",
"a",
"|",
"Shellwords",
".",
"escape",
"a",
"}",
".",
... | Constructs the command to execute a Vagrant subcommand
* subcommand: Vagrant subcommand to run (:up, :status, etc.)
* arguments: Arguments to pass to the subcommand (optional) | [
"Constructs",
"the",
"command",
"to",
"execute",
"a",
"Vagrant",
"subcommand"
] | c9d70f04562280a34083dd060b0e4099e6f32d8d | https://github.com/bradfeehan/derelict/blob/c9d70f04562280a34083dd060b0e4099e6f32d8d/lib/derelict/instance.rb#L138-L145 |
9,256 | redding/deas | lib/deas/show_exceptions.rb | Deas.ShowExceptions.call! | def call!(env)
status, headers, body = @app.call(env)
if error = env['deas.error']
error_body = Body.new(error)
headers['Content-Length'] = error_body.size.to_s
headers['Content-Type'] = error_body.mime_type.to_s
body = [error_body.content]
end
[status, headers... | ruby | def call!(env)
status, headers, body = @app.call(env)
if error = env['deas.error']
error_body = Body.new(error)
headers['Content-Length'] = error_body.size.to_s
headers['Content-Type'] = error_body.mime_type.to_s
body = [error_body.content]
end
[status, headers... | [
"def",
"call!",
"(",
"env",
")",
"status",
",",
"headers",
",",
"body",
"=",
"@app",
".",
"call",
"(",
"env",
")",
"if",
"error",
"=",
"env",
"[",
"'deas.error'",
"]",
"error_body",
"=",
"Body",
".",
"new",
"(",
"error",
")",
"headers",
"[",
"'Cont... | The real Rack call interface. | [
"The",
"real",
"Rack",
"call",
"interface",
"."
] | 865dbfa210a10f974552c2b92325306d98755283 | https://github.com/redding/deas/blob/865dbfa210a10f974552c2b92325306d98755283/lib/deas/show_exceptions.rb#L24-L34 |
9,257 | ChaseLEngel/HelpDeskAPI | lib/helpdeskapi.rb | HelpDeskAPI.Client.sign_in | def sign_in
# Contact sign in page to set cookies.
begin
sign_in_res = RestClient.get(Endpoints::SIGN_IN)
rescue RestClient::ExceptionWithResponse => error
fail HelpDeskAPI::Exceptions.SignInError, "Error contacting #{Endpoints::SIGN_IN}: #{error}"
end
# Parse authenticity... | ruby | def sign_in
# Contact sign in page to set cookies.
begin
sign_in_res = RestClient.get(Endpoints::SIGN_IN)
rescue RestClient::ExceptionWithResponse => error
fail HelpDeskAPI::Exceptions.SignInError, "Error contacting #{Endpoints::SIGN_IN}: #{error}"
end
# Parse authenticity... | [
"def",
"sign_in",
"# Contact sign in page to set cookies.",
"begin",
"sign_in_res",
"=",
"RestClient",
".",
"get",
"(",
"Endpoints",
"::",
"SIGN_IN",
")",
"rescue",
"RestClient",
"::",
"ExceptionWithResponse",
"=>",
"error",
"fail",
"HelpDeskAPI",
"::",
"Exceptions",
... | Authenicate user and set cookies.
This will be called automatically on endpoint request. | [
"Authenicate",
"user",
"and",
"set",
"cookies",
".",
"This",
"will",
"be",
"called",
"automatically",
"on",
"endpoint",
"request",
"."
] | d243cced2bb121d30b06e4fed7f02da0d333783a | https://github.com/ChaseLEngel/HelpDeskAPI/blob/d243cced2bb121d30b06e4fed7f02da0d333783a/lib/helpdeskapi.rb#L27-L66 |
9,258 | celldee/ffi-rxs | lib/ffi-rxs/message.rb | XS.Message.copy_in_bytes | def copy_in_bytes bytes, len
data_buffer = LibC.malloc len
# writes the exact number of bytes, no null byte to terminate string
data_buffer.write_string bytes, len
# use libC to call free on the data buffer; earlier versions used an
# FFI::Function here that called back into Ruby, but Rub... | ruby | def copy_in_bytes bytes, len
data_buffer = LibC.malloc len
# writes the exact number of bytes, no null byte to terminate string
data_buffer.write_string bytes, len
# use libC to call free on the data buffer; earlier versions used an
# FFI::Function here that called back into Ruby, but Rub... | [
"def",
"copy_in_bytes",
"bytes",
",",
"len",
"data_buffer",
"=",
"LibC",
".",
"malloc",
"len",
"# writes the exact number of bytes, no null byte to terminate string",
"data_buffer",
".",
"write_string",
"bytes",
",",
"len",
"# use libC to call free on the data buffer; earlier ver... | Makes a copy of +len+ bytes from the ruby string +bytes+. Library
handles deallocation of the native memory buffer.
Can only be initialized via #copy_in_string or #copy_in_bytes once.
@param bytes
@param length | [
"Makes",
"a",
"copy",
"of",
"+",
"len",
"+",
"bytes",
"from",
"the",
"ruby",
"string",
"+",
"bytes",
"+",
".",
"Library",
"handles",
"deallocation",
"of",
"the",
"native",
"memory",
"buffer",
"."
] | 95378f3a5e5b5b3f1f726a9a1620f41ab4ee7f0e | https://github.com/celldee/ffi-rxs/blob/95378f3a5e5b5b3f1f726a9a1620f41ab4ee7f0e/lib/ffi-rxs/message.rb#L135-L144 |
9,259 | mediasp/confuse | lib/confuse/config.rb | Confuse.Config.check | def check
@definition.namespaces.each do |(namespace, ns)|
ns.items.each do |key, _|
lookup(namespace, key)
end
end
end | ruby | def check
@definition.namespaces.each do |(namespace, ns)|
ns.items.each do |key, _|
lookup(namespace, key)
end
end
end | [
"def",
"check",
"@definition",
".",
"namespaces",
".",
"each",
"do",
"|",
"(",
"namespace",
",",
"ns",
")",
"|",
"ns",
".",
"items",
".",
"each",
"do",
"|",
"key",
",",
"_",
"|",
"lookup",
"(",
"namespace",
",",
"key",
")",
"end",
"end",
"end"
] | check items have a value. Will raise Undefined error if a required item
has no value. | [
"check",
"items",
"have",
"a",
"value",
".",
"Will",
"raise",
"Undefined",
"error",
"if",
"a",
"required",
"item",
"has",
"no",
"value",
"."
] | 7e0e976d9461cd794b222305a24fa44946d6a9d3 | https://github.com/mediasp/confuse/blob/7e0e976d9461cd794b222305a24fa44946d6a9d3/lib/confuse/config.rb#L35-L41 |
9,260 | mccraigmccraig/rsxml | lib/rsxml/util.rb | Rsxml.Util.check_opts | def check_opts(constraints, opts)
opts ||= {}
opts.each{|k,v| raise "opt not permitted: #{k.inspect}" if !constraints.has_key?(k)}
Hash[constraints.map do |k,constraint|
if opts.has_key?(k)
v = opts[k]
if constraint.is_a?(Array)
raise "unknow... | ruby | def check_opts(constraints, opts)
opts ||= {}
opts.each{|k,v| raise "opt not permitted: #{k.inspect}" if !constraints.has_key?(k)}
Hash[constraints.map do |k,constraint|
if opts.has_key?(k)
v = opts[k]
if constraint.is_a?(Array)
raise "unknow... | [
"def",
"check_opts",
"(",
"constraints",
",",
"opts",
")",
"opts",
"||=",
"{",
"}",
"opts",
".",
"each",
"{",
"|",
"k",
",",
"v",
"|",
"raise",
"\"opt not permitted: #{k.inspect}\"",
"if",
"!",
"constraints",
".",
"has_key?",
"(",
"k",
")",
"}",
"Hash",
... | simple option checking, with value constraints and sub-hash checking | [
"simple",
"option",
"checking",
"with",
"value",
"constraints",
"and",
"sub",
"-",
"hash",
"checking"
] | 3699c186f01be476a5942d64cd5c39f4d6bbe175 | https://github.com/mccraigmccraig/rsxml/blob/3699c186f01be476a5942d64cd5c39f4d6bbe175/lib/rsxml/util.rb#L6-L23 |
9,261 | justfalter/align | lib/align/pairwise_algorithm.rb | Align.PairwiseAlgorithm.max4 | def max4(a,b,c,d)
x = a >= b ? a : b
y = c >= d ? c : d
(x >= y) ? x : y
end | ruby | def max4(a,b,c,d)
x = a >= b ? a : b
y = c >= d ? c : d
(x >= y) ? x : y
end | [
"def",
"max4",
"(",
"a",
",",
"b",
",",
"c",
",",
"d",
")",
"x",
"=",
"a",
">=",
"b",
"?",
"a",
":",
"b",
"y",
"=",
"c",
">=",
"d",
"?",
"c",
":",
"d",
"(",
"x",
">=",
"y",
")",
"?",
"x",
":",
"y",
"end"
] | Returns the max of 4 integers | [
"Returns",
"the",
"max",
"of",
"4",
"integers"
] | e95ac63253e99ee18d66c1e7d9695f5eb80036cf | https://github.com/justfalter/align/blob/e95ac63253e99ee18d66c1e7d9695f5eb80036cf/lib/align/pairwise_algorithm.rb#L24-L28 |
9,262 | yohoushi/multiforecast-client | lib/multiforecast/client.rb | MultiForecast.Client.get_complex | def get_complex(path)
client(path).get_complex(service_name(path), section_name(path), graph_name(path)).tap do |graph|
graph['base_uri'] = client(path).base_uri
graph['path'] = path
end
end | ruby | def get_complex(path)
client(path).get_complex(service_name(path), section_name(path), graph_name(path)).tap do |graph|
graph['base_uri'] = client(path).base_uri
graph['path'] = path
end
end | [
"def",
"get_complex",
"(",
"path",
")",
"client",
"(",
"path",
")",
".",
"get_complex",
"(",
"service_name",
"(",
"path",
")",
",",
"section_name",
"(",
"path",
")",
",",
"graph_name",
"(",
"path",
")",
")",
".",
"tap",
"do",
"|",
"graph",
"|",
"grap... | Get a complex graph
@param [String] path
@return [Hash] the graph property
@example
{"number"=>0,
"complex"=>true,
"created_at"=>"2013/05/20 15:08:28",
"service_name"=>"app name",
"section_name"=>"host name",
"id"=>18,
"graph_name"=>"complex graph test",
"data"=>
[{"gmode"=>"gauge", "stack"=>false... | [
"Get",
"a",
"complex",
"graph"
] | 0c25f60f9930aeb8837061df025ddbfd8677e74e | https://github.com/yohoushi/multiforecast-client/blob/0c25f60f9930aeb8837061df025ddbfd8677e74e/lib/multiforecast/client.rb#L257-L262 |
9,263 | yohoushi/multiforecast-client | lib/multiforecast/client.rb | MultiForecast.Client.delete_complex | def delete_complex(path)
client(path).delete_complex(service_name(path), section_name(path), graph_name(path))
end | ruby | def delete_complex(path)
client(path).delete_complex(service_name(path), section_name(path), graph_name(path))
end | [
"def",
"delete_complex",
"(",
"path",
")",
"client",
"(",
"path",
")",
".",
"delete_complex",
"(",
"service_name",
"(",
"path",
")",
",",
"section_name",
"(",
"path",
")",
",",
"graph_name",
"(",
"path",
")",
")",
"end"
] | Delete a complex graph
@param [String] path
@return [Hash] error response
@example
{"error"=>0} #=> Success
{"error"=>1} #=> Error | [
"Delete",
"a",
"complex",
"graph"
] | 0c25f60f9930aeb8837061df025ddbfd8677e74e | https://github.com/yohoushi/multiforecast-client/blob/0c25f60f9930aeb8837061df025ddbfd8677e74e/lib/multiforecast/client.rb#L271-L273 |
9,264 | fenton-project/fenton_shell | lib/fenton_shell/certificate.rb | FentonShell.Certificate.certificate_create | def certificate_create(global_options, options)
result = Excon.post(
"#{global_options[:fenton_server_url]}/certificates.json",
body: certificate_json(options),
headers: { 'Content-Type' => 'application/json' }
)
write_client_certificate(
public_key_cert_location(optio... | ruby | def certificate_create(global_options, options)
result = Excon.post(
"#{global_options[:fenton_server_url]}/certificates.json",
body: certificate_json(options),
headers: { 'Content-Type' => 'application/json' }
)
write_client_certificate(
public_key_cert_location(optio... | [
"def",
"certificate_create",
"(",
"global_options",
",",
"options",
")",
"result",
"=",
"Excon",
".",
"post",
"(",
"\"#{global_options[:fenton_server_url]}/certificates.json\"",
",",
"body",
":",
"certificate_json",
"(",
"options",
")",
",",
"headers",
":",
"{",
"'C... | Sends a post request with json from the command line certificate
@param global_options [Hash] global command line options
@param options [Hash] json fields to send to fenton server
@return [Fixnum] http status code
@return [String] message back from fenton server | [
"Sends",
"a",
"post",
"request",
"with",
"json",
"from",
"the",
"command",
"line",
"certificate"
] | 6e1d76186fa7ee7a3be141afad9361e3a3e0ec91 | https://github.com/fenton-project/fenton_shell/blob/6e1d76186fa7ee7a3be141afad9361e3a3e0ec91/lib/fenton_shell/certificate.rb#L34-L47 |
9,265 | klacointe/has_media | lib/has_media.rb | HasMedia.ClassMethods.set_relations | def set_relations(context, relation)
@contexts ||= {}
@contexts[relation] ||= []
@media_relation_set ||= []
if @contexts[relation].include?(context)
raise Exception.new("You should NOT use same context identifier for several has_one or has_many relation to media")
end
@contex... | ruby | def set_relations(context, relation)
@contexts ||= {}
@contexts[relation] ||= []
@media_relation_set ||= []
if @contexts[relation].include?(context)
raise Exception.new("You should NOT use same context identifier for several has_one or has_many relation to media")
end
@contex... | [
"def",
"set_relations",
"(",
"context",
",",
"relation",
")",
"@contexts",
"||=",
"{",
"}",
"@contexts",
"[",
"relation",
"]",
"||=",
"[",
"]",
"@media_relation_set",
"||=",
"[",
"]",
"if",
"@contexts",
"[",
"relation",
"]",
".",
"include?",
"(",
"context"... | set_relations
add relation on medium if not exists
Also check if a class has a duplicate context
@param [String] context
@param [String] relation type, one of :has_many, :has_one | [
"set_relations",
"add",
"relation",
"on",
"medium",
"if",
"not",
"exists",
"Also",
"check",
"if",
"a",
"class",
"has",
"a",
"duplicate",
"context"
] | a886d36a914d8244f3761455458b9d0226fa22d5 | https://github.com/klacointe/has_media/blob/a886d36a914d8244f3761455458b9d0226fa22d5/lib/has_media.rb#L199-L211 |
9,266 | jellymann/someapi | lib/someapi.rb | Some.API.method_missing | def method_missing meth, *args, &block
meth_s = meth.to_s
if @method && meth_s =~ API_REGEX
if meth_s.end_with?('!')
# `foo! bar' is syntactic sugar for `foo.! bar'
self[meth_s[0...-1]].!(args[0] || {})
else
# chain the method name onto URL path
self... | ruby | def method_missing meth, *args, &block
meth_s = meth.to_s
if @method && meth_s =~ API_REGEX
if meth_s.end_with?('!')
# `foo! bar' is syntactic sugar for `foo.! bar'
self[meth_s[0...-1]].!(args[0] || {})
else
# chain the method name onto URL path
self... | [
"def",
"method_missing",
"meth",
",",
"*",
"args",
",",
"&",
"block",
"meth_s",
"=",
"meth",
".",
"to_s",
"if",
"@method",
"&&",
"meth_s",
"=~",
"API_REGEX",
"if",
"meth_s",
".",
"end_with?",
"(",
"'!'",
")",
"# `foo! bar' is syntactic sugar for `foo.! bar'",
... | this is where the fun begins... | [
"this",
"is",
"where",
"the",
"fun",
"begins",
"..."
] | 77fc6e72612d30b7da6de0f4b60d971de78667a9 | https://github.com/jellymann/someapi/blob/77fc6e72612d30b7da6de0f4b60d971de78667a9/lib/someapi.rb#L81-L96 |
9,267 | victorgama/xcellus | lib/xcellus.rb | Xcellus.Instance.save | def save(path)
unless path.kind_of? String
raise ArgumentError, 'save expects a string path'
end
Xcellus::_save(@handle, path)
end | ruby | def save(path)
unless path.kind_of? String
raise ArgumentError, 'save expects a string path'
end
Xcellus::_save(@handle, path)
end | [
"def",
"save",
"(",
"path",
")",
"unless",
"path",
".",
"kind_of?",
"String",
"raise",
"ArgumentError",
",",
"'save expects a string path'",
"end",
"Xcellus",
"::",
"_save",
"(",
"@handle",
",",
"path",
")",
"end"
] | Saves the current modifications to the provided path. | [
"Saves",
"the",
"current",
"modifications",
"to",
"the",
"provided",
"path",
"."
] | 6d0ef725ae173a05385e68ca44558d49b12ee1cb | https://github.com/victorgama/xcellus/blob/6d0ef725ae173a05385e68ca44558d49b12ee1cb/lib/xcellus.rb#L116-L122 |
9,268 | samsao/danger-samsao | lib/samsao/helpers.rb | Samsao.Helpers.changelog_modified? | def changelog_modified?(*changelogs)
changelogs = config.changelogs if changelogs.nil? || changelogs.empty?
changelogs.any? { |changelog| git.modified_files.include?(changelog) }
end | ruby | def changelog_modified?(*changelogs)
changelogs = config.changelogs if changelogs.nil? || changelogs.empty?
changelogs.any? { |changelog| git.modified_files.include?(changelog) }
end | [
"def",
"changelog_modified?",
"(",
"*",
"changelogs",
")",
"changelogs",
"=",
"config",
".",
"changelogs",
"if",
"changelogs",
".",
"nil?",
"||",
"changelogs",
".",
"empty?",
"changelogs",
".",
"any?",
"{",
"|",
"changelog",
"|",
"git",
".",
"modified_files",
... | Check if any changelog were modified. When the helper receives nothing,
changelogs defined by the config are used.
@return [Bool] True
If any changelogs were modified in this commit | [
"Check",
"if",
"any",
"changelog",
"were",
"modified",
".",
"When",
"the",
"helper",
"receives",
"nothing",
"changelogs",
"defined",
"by",
"the",
"config",
"are",
"used",
"."
] | 59a9d6d87e6c58d5c6aadc96fae99555f7ea297b | https://github.com/samsao/danger-samsao/blob/59a9d6d87e6c58d5c6aadc96fae99555f7ea297b/lib/samsao/helpers.rb#L12-L16 |
9,269 | samsao/danger-samsao | lib/samsao/helpers.rb | Samsao.Helpers.has_app_changes? | def has_app_changes?(*sources)
sources = config.sources if sources.nil? || sources.empty?
sources.any? do |source|
pattern = Samsao::Regexp.from_matcher(source, when_string_pattern_prefix_with: '^')
modified_file?(pattern)
end
end | ruby | def has_app_changes?(*sources)
sources = config.sources if sources.nil? || sources.empty?
sources.any? do |source|
pattern = Samsao::Regexp.from_matcher(source, when_string_pattern_prefix_with: '^')
modified_file?(pattern)
end
end | [
"def",
"has_app_changes?",
"(",
"*",
"sources",
")",
"sources",
"=",
"config",
".",
"sources",
"if",
"sources",
".",
"nil?",
"||",
"sources",
".",
"empty?",
"sources",
".",
"any?",
"do",
"|",
"source",
"|",
"pattern",
"=",
"Samsao",
"::",
"Regexp",
".",
... | Return true if any source files are in the git modified files list.
@return [Bool] | [
"Return",
"true",
"if",
"any",
"source",
"files",
"are",
"in",
"the",
"git",
"modified",
"files",
"list",
"."
] | 59a9d6d87e6c58d5c6aadc96fae99555f7ea297b | https://github.com/samsao/danger-samsao/blob/59a9d6d87e6c58d5c6aadc96fae99555f7ea297b/lib/samsao/helpers.rb#L63-L71 |
9,270 | samsao/danger-samsao | lib/samsao/helpers.rb | Samsao.Helpers.truncate | def truncate(input, max = 30)
return input if input.nil? || input.length <= max
input[0..max - 1].gsub(/\s\w+\s*$/, '...')
end | ruby | def truncate(input, max = 30)
return input if input.nil? || input.length <= max
input[0..max - 1].gsub(/\s\w+\s*$/, '...')
end | [
"def",
"truncate",
"(",
"input",
",",
"max",
"=",
"30",
")",
"return",
"input",
"if",
"input",
".",
"nil?",
"||",
"input",
".",
"length",
"<=",
"max",
"input",
"[",
"0",
"..",
"max",
"-",
"1",
"]",
".",
"gsub",
"(",
"/",
"\\s",
"\\w",
"\\s",
"/... | Truncate the string received.
@param [String] input
The string to truncate
@param [Number] max (Default: 30)
The max size of the truncated string
@return [String] | [
"Truncate",
"the",
"string",
"received",
"."
] | 59a9d6d87e6c58d5c6aadc96fae99555f7ea297b | https://github.com/samsao/danger-samsao/blob/59a9d6d87e6c58d5c6aadc96fae99555f7ea297b/lib/samsao/helpers.rb#L109-L113 |
9,271 | hannesg/multi_git | lib/multi_git/ref.rb | MultiGit.Ref.resolve | def resolve
@leaf ||= begin
ref = self
loop do
break ref unless ref.target.kind_of? MultiGit::Ref
ref = ref.target
end
end
end | ruby | def resolve
@leaf ||= begin
ref = self
loop do
break ref unless ref.target.kind_of? MultiGit::Ref
ref = ref.target
end
end
end | [
"def",
"resolve",
"@leaf",
"||=",
"begin",
"ref",
"=",
"self",
"loop",
"do",
"break",
"ref",
"unless",
"ref",
".",
"target",
".",
"kind_of?",
"MultiGit",
"::",
"Ref",
"ref",
"=",
"ref",
".",
"target",
"end",
"end",
"end"
] | Resolves symbolic references and returns the final reference.
@return [MultGit::Ref] | [
"Resolves",
"symbolic",
"references",
"and",
"returns",
"the",
"final",
"reference",
"."
] | cb82e66be7d27c3b630610ce3f1385b30811f139 | https://github.com/hannesg/multi_git/blob/cb82e66be7d27c3b630610ce3f1385b30811f139/lib/multi_git/ref.rb#L278-L286 |
9,272 | hannesg/multi_git | lib/multi_git/ref.rb | MultiGit.Ref.commit | def commit(options = {}, &block)
resolve.update(options.fetch(:lock, :optimistic)) do |current|
Commit::Builder.new(current, &block)
end
return reload
end | ruby | def commit(options = {}, &block)
resolve.update(options.fetch(:lock, :optimistic)) do |current|
Commit::Builder.new(current, &block)
end
return reload
end | [
"def",
"commit",
"(",
"options",
"=",
"{",
"}",
",",
"&",
"block",
")",
"resolve",
".",
"update",
"(",
"options",
".",
"fetch",
"(",
":lock",
",",
":optimistic",
")",
")",
"do",
"|",
"current",
"|",
"Commit",
"::",
"Builder",
".",
"new",
"(",
"curr... | Shorthand method to directly create a commit and update the given ref.
@example
# setup:
dir = `mktemp -d`
repository = MultiGit.open(dir, init: true)
# insert a commit:
repository.head.commit do
tree['a_file'] = 'some_content'
end
# check result:
repository.head['a_file'].content #=> eql 'some_co... | [
"Shorthand",
"method",
"to",
"directly",
"create",
"a",
"commit",
"and",
"update",
"the",
"given",
"ref",
"."
] | cb82e66be7d27c3b630610ce3f1385b30811f139 | https://github.com/hannesg/multi_git/blob/cb82e66be7d27c3b630610ce3f1385b30811f139/lib/multi_git/ref.rb#L404-L409 |
9,273 | pwnall/authpwn_rails | lib/authpwn_rails/session.rb | Authpwn.ControllerInstanceMethods.set_session_current_user | def set_session_current_user(user)
self.current_user = user
# Try to reuse existing sessions.
if session[:authpwn_suid]
token = Tokens::SessionUid.with_code(session[:authpwn_suid]).first
if token
if token.user == user
token.touch
return user
else
tok... | ruby | def set_session_current_user(user)
self.current_user = user
# Try to reuse existing sessions.
if session[:authpwn_suid]
token = Tokens::SessionUid.with_code(session[:authpwn_suid]).first
if token
if token.user == user
token.touch
return user
else
tok... | [
"def",
"set_session_current_user",
"(",
"user",
")",
"self",
".",
"current_user",
"=",
"user",
"# Try to reuse existing sessions.",
"if",
"session",
"[",
":authpwn_suid",
"]",
"token",
"=",
"Tokens",
"::",
"SessionUid",
".",
"with_code",
"(",
"session",
"[",
":aut... | Sets up the session so that it will authenticate the given user. | [
"Sets",
"up",
"the",
"session",
"so",
"that",
"it",
"will",
"authenticate",
"the",
"given",
"user",
"."
] | de3bd612a00025e8dc8296a73abe3acba948db17 | https://github.com/pwnall/authpwn_rails/blob/de3bd612a00025e8dc8296a73abe3acba948db17/lib/authpwn_rails/session.rb#L41-L61 |
9,274 | pwnall/authpwn_rails | lib/authpwn_rails/session.rb | Authpwn.ControllerInstanceMethods.authenticate_using_session | def authenticate_using_session
return if current_user
session_uid = session[:authpwn_suid]
user = session_uid && Tokens::SessionUid.authenticate(session_uid)
self.current_user = user if user && !user.instance_of?(Symbol)
end | ruby | def authenticate_using_session
return if current_user
session_uid = session[:authpwn_suid]
user = session_uid && Tokens::SessionUid.authenticate(session_uid)
self.current_user = user if user && !user.instance_of?(Symbol)
end | [
"def",
"authenticate_using_session",
"return",
"if",
"current_user",
"session_uid",
"=",
"session",
"[",
":authpwn_suid",
"]",
"user",
"=",
"session_uid",
"&&",
"Tokens",
"::",
"SessionUid",
".",
"authenticate",
"(",
"session_uid",
")",
"self",
".",
"current_user",
... | The before_action that implements authenticates_using_session.
If your ApplicationController contains authenticates_using_session, you
can opt out in individual controllers using skip_before_action.
skip_before_action :authenticate_using_session | [
"The",
"before_action",
"that",
"implements",
"authenticates_using_session",
"."
] | de3bd612a00025e8dc8296a73abe3acba948db17 | https://github.com/pwnall/authpwn_rails/blob/de3bd612a00025e8dc8296a73abe3acba948db17/lib/authpwn_rails/session.rb#L69-L74 |
9,275 | vjoel/tkar | lib/tkar/canvas.rb | Tkar.Canvas.del | def del tkar_id
tkaroid = @objects[tkar_id]
if tkaroid
if @follow_id == tkar_id
follow nil
end
delete tkaroid.tag
@objects.delete tkar_id
@changed.delete tkar_id
get_objects_by_layer(tkaroid.layer).delete tkaroid
end
end | ruby | def del tkar_id
tkaroid = @objects[tkar_id]
if tkaroid
if @follow_id == tkar_id
follow nil
end
delete tkaroid.tag
@objects.delete tkar_id
@changed.delete tkar_id
get_objects_by_layer(tkaroid.layer).delete tkaroid
end
end | [
"def",
"del",
"tkar_id",
"tkaroid",
"=",
"@objects",
"[",
"tkar_id",
"]",
"if",
"tkaroid",
"if",
"@follow_id",
"==",
"tkar_id",
"follow",
"nil",
"end",
"delete",
"tkaroid",
".",
"tag",
"@objects",
".",
"delete",
"tkar_id",
"@changed",
".",
"delete",
"tkar_id... | Not "delete"! That already exists in tk. | [
"Not",
"delete",
"!",
"That",
"already",
"exists",
"in",
"tk",
"."
] | 4c446bdcc028c0ec2fb858ea882717bd9908d9d0 | https://github.com/vjoel/tkar/blob/4c446bdcc028c0ec2fb858ea882717bd9908d9d0/lib/tkar/canvas.rb#L193-L204 |
9,276 | ryanuber/ruby-aptly | lib/aptly/repo.rb | Aptly.Repo.add | def add path, kwargs={}
remove_files = kwargs.arg :remove_files, false
cmd = 'aptly repo add'
cmd += ' -remove-files' if remove_files
cmd += " #{@name.quote} #{path}"
Aptly::runcmd cmd
end | ruby | def add path, kwargs={}
remove_files = kwargs.arg :remove_files, false
cmd = 'aptly repo add'
cmd += ' -remove-files' if remove_files
cmd += " #{@name.quote} #{path}"
Aptly::runcmd cmd
end | [
"def",
"add",
"path",
",",
"kwargs",
"=",
"{",
"}",
"remove_files",
"=",
"kwargs",
".",
"arg",
":remove_files",
",",
"false",
"cmd",
"=",
"'aptly repo add'",
"cmd",
"+=",
"' -remove-files'",
"if",
"remove_files",
"cmd",
"+=",
"\" #{@name.quote} #{path}\"",
"Aptl... | Add debian packages to a repo
== Parameters:
path::
The path to the file or directory source
remove_files::
When true, deletes source after import | [
"Add",
"debian",
"packages",
"to",
"a",
"repo"
] | 9581c38da30119d6a61b7ddac6334ab17fc67164 | https://github.com/ryanuber/ruby-aptly/blob/9581c38da30119d6a61b7ddac6334ab17fc67164/lib/aptly/repo.rb#L125-L133 |
9,277 | ryanuber/ruby-aptly | lib/aptly/repo.rb | Aptly.Repo.import | def import from_mirror, kwargs={}
deps = kwargs.arg :deps, false
packages = kwargs.arg :packages, []
if packages.length == 0
raise AptlyError.new '1 or more packages are required'
end
cmd = 'aptly repo import'
cmd += ' -with-deps' if deps
cmd += " #{from_mirror.quote}... | ruby | def import from_mirror, kwargs={}
deps = kwargs.arg :deps, false
packages = kwargs.arg :packages, []
if packages.length == 0
raise AptlyError.new '1 or more packages are required'
end
cmd = 'aptly repo import'
cmd += ' -with-deps' if deps
cmd += " #{from_mirror.quote}... | [
"def",
"import",
"from_mirror",
",",
"kwargs",
"=",
"{",
"}",
"deps",
"=",
"kwargs",
".",
"arg",
":deps",
",",
"false",
"packages",
"=",
"kwargs",
".",
"arg",
":packages",
",",
"[",
"]",
"if",
"packages",
".",
"length",
"==",
"0",
"raise",
"AptlyError"... | Imports package resources from existing mirrors
== Parameters:
from_mirror::
The name of the mirror to import from
packages::
A list of debian pkg_spec strings (e.g. "libc6 (>= 2.7-1)")
deps::
When true, follows package dependencies and adds them | [
"Imports",
"package",
"resources",
"from",
"existing",
"mirrors"
] | 9581c38da30119d6a61b7ddac6334ab17fc67164 | https://github.com/ryanuber/ruby-aptly/blob/9581c38da30119d6a61b7ddac6334ab17fc67164/lib/aptly/repo.rb#L145-L159 |
9,278 | ryanuber/ruby-aptly | lib/aptly/repo.rb | Aptly.Repo.copy | def copy from_repo, to_repo, kwargs={}
deps = kwargs.arg :deps, false
packages = kwargs.arg :packages, []
if packages.length == 0
raise AptlyError.new '1 or more packages are required'
end
cmd = 'aptly repo copy'
cmd += ' -with-deps' if deps
cmd += " #{from_repo.quote... | ruby | def copy from_repo, to_repo, kwargs={}
deps = kwargs.arg :deps, false
packages = kwargs.arg :packages, []
if packages.length == 0
raise AptlyError.new '1 or more packages are required'
end
cmd = 'aptly repo copy'
cmd += ' -with-deps' if deps
cmd += " #{from_repo.quote... | [
"def",
"copy",
"from_repo",
",",
"to_repo",
",",
"kwargs",
"=",
"{",
"}",
"deps",
"=",
"kwargs",
".",
"arg",
":deps",
",",
"false",
"packages",
"=",
"kwargs",
".",
"arg",
":packages",
",",
"[",
"]",
"if",
"packages",
".",
"length",
"==",
"0",
"raise"... | Copy package resources from one repository to another
== Parameters:
from_repo::
The source repository name
to_repo::
The destination repository name
packages::
A list of debian pkg_spec strings
deps::
When true, follow deps and copy them | [
"Copy",
"package",
"resources",
"from",
"one",
"repository",
"to",
"another"
] | 9581c38da30119d6a61b7ddac6334ab17fc67164 | https://github.com/ryanuber/ruby-aptly/blob/9581c38da30119d6a61b7ddac6334ab17fc67164/lib/aptly/repo.rb#L173-L187 |
9,279 | ondra-m/google_api | lib/google_api/session/session.rb | GoogleApi.Session.login | def login(code = nil)
@client = Google::APIClient.new
@client.authorization.client_id = c('client_id')
@client.authorization.client_secret = c('client_secret')
@client.authorization.scope = @scope
@client.authorization.redirect_uri = c('redirect_uri')
@api = @client.dis... | ruby | def login(code = nil)
@client = Google::APIClient.new
@client.authorization.client_id = c('client_id')
@client.authorization.client_secret = c('client_secret')
@client.authorization.scope = @scope
@client.authorization.redirect_uri = c('redirect_uri')
@api = @client.dis... | [
"def",
"login",
"(",
"code",
"=",
"nil",
")",
"@client",
"=",
"Google",
"::",
"APIClient",
".",
"new",
"@client",
".",
"authorization",
".",
"client_id",
"=",
"c",
"(",
"'client_id'",
")",
"@client",
".",
"authorization",
".",
"client_secret",
"=",
"c",
... | Classic oauth 2 login
login() -> return autorization url
login(code) -> try login, return true false | [
"Classic",
"oauth",
"2",
"login"
] | 258ac9958f47e8d4151e944910d649c2b372828f | https://github.com/ondra-m/google_api/blob/258ac9958f47e8d4151e944910d649c2b372828f/lib/google_api/session/session.rb#L63-L84 |
9,280 | ondra-m/google_api | lib/google_api/session/session.rb | GoogleApi.Session.login_by_line | def login_by_line(server = 'http://localhost/oauth2callback', port = 0)
begin
require "launchy" # open browser
rescue
raise GoogleApi::RequireError, "You don't have launchy gem. Firt install it: gem install launchy."
end
require "socket" # make tcp server
require "... | ruby | def login_by_line(server = 'http://localhost/oauth2callback', port = 0)
begin
require "launchy" # open browser
rescue
raise GoogleApi::RequireError, "You don't have launchy gem. Firt install it: gem install launchy."
end
require "socket" # make tcp server
require "... | [
"def",
"login_by_line",
"(",
"server",
"=",
"'http://localhost/oauth2callback'",
",",
"port",
"=",
"0",
")",
"begin",
"require",
"\"launchy\"",
"# open browser",
"rescue",
"raise",
"GoogleApi",
"::",
"RequireError",
",",
"\"You don't have launchy gem. Firt install it: gem i... | Automaticaly open autorization url a waiting for callback.
Launchy gem is required
Parameters:
server:: server will be on this addres, its alson address for oatuh 2 callback
port:: listening port for server
port=0:: server will be on first free port
Steps:
1) create server
2) launch browser and redirect... | [
"Automaticaly",
"open",
"autorization",
"url",
"a",
"waiting",
"for",
"callback",
".",
"Launchy",
"gem",
"is",
"required"
] | 258ac9958f47e8d4151e944910d649c2b372828f | https://github.com/ondra-m/google_api/blob/258ac9958f47e8d4151e944910d649c2b372828f/lib/google_api/session/session.rb#L101-L149 |
9,281 | vladgh/vtasks | lib/vtasks/docker.rb | Vtasks.Docker.add_namespace | def add_namespace(image, path)
namespace path.to_sym do |_args|
require 'rspec/core/rake_task'
::RSpec::Core::RakeTask.new(:spec) do |task|
task.pattern = "#{path}/spec/*_spec.rb"
end
docker_image = Vtasks::Docker::Image.new(image, path, args)
lint_image(path)
... | ruby | def add_namespace(image, path)
namespace path.to_sym do |_args|
require 'rspec/core/rake_task'
::RSpec::Core::RakeTask.new(:spec) do |task|
task.pattern = "#{path}/spec/*_spec.rb"
end
docker_image = Vtasks::Docker::Image.new(image, path, args)
lint_image(path)
... | [
"def",
"add_namespace",
"(",
"image",
",",
"path",
")",
"namespace",
"path",
".",
"to_sym",
"do",
"|",
"_args",
"|",
"require",
"'rspec/core/rake_task'",
"::",
"RSpec",
"::",
"Core",
"::",
"RakeTask",
".",
"new",
"(",
":spec",
")",
"do",
"|",
"task",
"|"... | def define_tasks
Image namespace | [
"def",
"define_tasks",
"Image",
"namespace"
] | 46eff1d2ee6b6f4c906096105ed66aae658cad3c | https://github.com/vladgh/vtasks/blob/46eff1d2ee6b6f4c906096105ed66aae658cad3c/lib/vtasks/docker.rb#L39-L60 |
9,282 | vladgh/vtasks | lib/vtasks/docker.rb | Vtasks.Docker.dockerfiles | def dockerfiles
@dockerfiles = Dir.glob('*').select do |dir|
File.directory?(dir) && File.exist?("#{dir}/Dockerfile")
end
end | ruby | def dockerfiles
@dockerfiles = Dir.glob('*').select do |dir|
File.directory?(dir) && File.exist?("#{dir}/Dockerfile")
end
end | [
"def",
"dockerfiles",
"@dockerfiles",
"=",
"Dir",
".",
"glob",
"(",
"'*'",
")",
".",
"select",
"do",
"|",
"dir",
"|",
"File",
".",
"directory?",
"(",
"dir",
")",
"&&",
"File",
".",
"exist?",
"(",
"\"#{dir}/Dockerfile\"",
")",
"end",
"end"
] | List all folders containing Dockerfiles | [
"List",
"all",
"folders",
"containing",
"Dockerfiles"
] | 46eff1d2ee6b6f4c906096105ed66aae658cad3c | https://github.com/vladgh/vtasks/blob/46eff1d2ee6b6f4c906096105ed66aae658cad3c/lib/vtasks/docker.rb#L85-L89 |
9,283 | vladgh/vtasks | lib/vtasks/docker.rb | Vtasks.Docker.list_images | def list_images
desc 'List all Docker images'
task :list do
info dockerfiles.map { |image| File.basename(image) }
end
end | ruby | def list_images
desc 'List all Docker images'
task :list do
info dockerfiles.map { |image| File.basename(image) }
end
end | [
"def",
"list_images",
"desc",
"'List all Docker images'",
"task",
":list",
"do",
"info",
"dockerfiles",
".",
"map",
"{",
"|",
"image",
"|",
"File",
".",
"basename",
"(",
"image",
")",
"}",
"end",
"end"
] | List all images | [
"List",
"all",
"images"
] | 46eff1d2ee6b6f4c906096105ed66aae658cad3c | https://github.com/vladgh/vtasks/blob/46eff1d2ee6b6f4c906096105ed66aae658cad3c/lib/vtasks/docker.rb#L99-L104 |
9,284 | demersus/return_hook | lib/return_hook/form_tag_helper.rb | ReturnHook.FormTagHelper.html_options_for_form | def html_options_for_form(url_for_options, options)
options.stringify_keys.tap do |html_options|
html_options["enctype"] = "multipart/form-data" if html_options.delete("multipart")
# The following URL is unescaped, this is just a hash of options, and it is the
# responsibility of the calle... | ruby | def html_options_for_form(url_for_options, options)
options.stringify_keys.tap do |html_options|
html_options["enctype"] = "multipart/form-data" if html_options.delete("multipart")
# The following URL is unescaped, this is just a hash of options, and it is the
# responsibility of the calle... | [
"def",
"html_options_for_form",
"(",
"url_for_options",
",",
"options",
")",
"options",
".",
"stringify_keys",
".",
"tap",
"do",
"|",
"html_options",
"|",
"html_options",
"[",
"\"enctype\"",
"]",
"=",
"\"multipart/form-data\"",
"if",
"html_options",
".",
"delete",
... | This method overrides the rails built in form helper's action setting code
to inject a return path | [
"This",
"method",
"overrides",
"the",
"rails",
"built",
"in",
"form",
"helper",
"s",
"action",
"setting",
"code",
"to",
"inject",
"a",
"return",
"path"
] | f5c95bc0bc709cfe1e89a717706dc7e5ea492382 | https://github.com/demersus/return_hook/blob/f5c95bc0bc709cfe1e89a717706dc7e5ea492382/lib/return_hook/form_tag_helper.rb#L6-L30 |
9,285 | pranavraja/beanstalkify | lib/beanstalkify/environment.rb | Beanstalkify.Environment.deploy! | def deploy!(app, settings=[])
@beanstalk.update_environment({
version_label: app.version,
environment_name: self.name,
option_settings: settings
})
end | ruby | def deploy!(app, settings=[])
@beanstalk.update_environment({
version_label: app.version,
environment_name: self.name,
option_settings: settings
})
end | [
"def",
"deploy!",
"(",
"app",
",",
"settings",
"=",
"[",
"]",
")",
"@beanstalk",
".",
"update_environment",
"(",
"{",
"version_label",
":",
"app",
".",
"version",
",",
"environment_name",
":",
"self",
".",
"name",
",",
"option_settings",
":",
"settings",
"... | Assuming the provided app has already been uploaded,
update this environment to the app's version
Optionally pass in a bunch of settings to override | [
"Assuming",
"the",
"provided",
"app",
"has",
"already",
"been",
"uploaded",
"update",
"this",
"environment",
"to",
"the",
"app",
"s",
"version",
"Optionally",
"pass",
"in",
"a",
"bunch",
"of",
"settings",
"to",
"override"
] | adb739b0ae8c6cb003378bc9098a8d1cfd17e06b | https://github.com/pranavraja/beanstalkify/blob/adb739b0ae8c6cb003378bc9098a8d1cfd17e06b/lib/beanstalkify/environment.rb#L19-L25 |
9,286 | pranavraja/beanstalkify | lib/beanstalkify/environment.rb | Beanstalkify.Environment.create! | def create!(archive, stack, cnames, settings=[])
params = {
application_name: archive.app_name,
version_label: archive.version,
environment_name: self.name,
solution_stack_name: stack,
option_settings: settings
}
cnames.each do |c|
if dns_available(c)
... | ruby | def create!(archive, stack, cnames, settings=[])
params = {
application_name: archive.app_name,
version_label: archive.version,
environment_name: self.name,
solution_stack_name: stack,
option_settings: settings
}
cnames.each do |c|
if dns_available(c)
... | [
"def",
"create!",
"(",
"archive",
",",
"stack",
",",
"cnames",
",",
"settings",
"=",
"[",
"]",
")",
"params",
"=",
"{",
"application_name",
":",
"archive",
".",
"app_name",
",",
"version_label",
":",
"archive",
".",
"version",
",",
"environment_name",
":",... | Assuming the archive has already been uploaded,
create a new environment with the app deployed onto the provided stack.
Attempts to use the first available cname in the cnames array. | [
"Assuming",
"the",
"archive",
"has",
"already",
"been",
"uploaded",
"create",
"a",
"new",
"environment",
"with",
"the",
"app",
"deployed",
"onto",
"the",
"provided",
"stack",
".",
"Attempts",
"to",
"use",
"the",
"first",
"available",
"cname",
"in",
"the",
"c... | adb739b0ae8c6cb003378bc9098a8d1cfd17e06b | https://github.com/pranavraja/beanstalkify/blob/adb739b0ae8c6cb003378bc9098a8d1cfd17e06b/lib/beanstalkify/environment.rb#L30-L47 |
9,287 | DamienRobert/drain | lib/dr/base/encoding.rb | DR.Encoding.fix_utf8 | def fix_utf8(s=nil)
s=self if s.nil? #if we are included
if String.method_defined?(:scrub)
#Ruby 2.1
#cf http://ruby-doc.org/core-2.1.0/String.html#method-i-scrub
return s.scrub {|bytes| '<'+bytes.unpack('H*')[0]+'>' }
else
return DR::Encoding.to_utf8(s)
end
e... | ruby | def fix_utf8(s=nil)
s=self if s.nil? #if we are included
if String.method_defined?(:scrub)
#Ruby 2.1
#cf http://ruby-doc.org/core-2.1.0/String.html#method-i-scrub
return s.scrub {|bytes| '<'+bytes.unpack('H*')[0]+'>' }
else
return DR::Encoding.to_utf8(s)
end
e... | [
"def",
"fix_utf8",
"(",
"s",
"=",
"nil",
")",
"s",
"=",
"self",
"if",
"s",
".",
"nil?",
"#if we are included",
"if",
"String",
".",
"method_defined?",
"(",
":scrub",
")",
"#Ruby 2.1",
"#cf http://ruby-doc.org/core-2.1.0/String.html#method-i-scrub",
"return",
"s",
... | if a mostly utf8 has some mixed in latin1 characters, replace the
invalid characters | [
"if",
"a",
"mostly",
"utf8",
"has",
"some",
"mixed",
"in",
"latin1",
"characters",
"replace",
"the",
"invalid",
"characters"
] | d6e5c928821501ad2ebdf2f988558e9690973778 | https://github.com/DamienRobert/drain/blob/d6e5c928821501ad2ebdf2f988558e9690973778/lib/dr/base/encoding.rb#L8-L17 |
9,288 | DamienRobert/drain | lib/dr/base/encoding.rb | DR.Encoding.to_utf8! | def to_utf8!(s=nil,from:nil)
s=self if s.nil? #if we are included
from=s.encoding if from.nil?
return s.encode!('UTF-8',from, :invalid => :replace, :undef => :replace,
:fallback => Proc.new { |bytes| '<'+bytes.unpack('H*')[0]+'>' }
)
end | ruby | def to_utf8!(s=nil,from:nil)
s=self if s.nil? #if we are included
from=s.encoding if from.nil?
return s.encode!('UTF-8',from, :invalid => :replace, :undef => :replace,
:fallback => Proc.new { |bytes| '<'+bytes.unpack('H*')[0]+'>' }
)
end | [
"def",
"to_utf8!",
"(",
"s",
"=",
"nil",
",",
"from",
":",
"nil",
")",
"s",
"=",
"self",
"if",
"s",
".",
"nil?",
"#if we are included",
"from",
"=",
"s",
".",
"encoding",
"if",
"from",
".",
"nil?",
"return",
"s",
".",
"encode!",
"(",
"'UTF-8'",
","... | assume ruby>=1.9 here | [
"assume",
"ruby",
">",
"=",
"1",
".",
"9",
"here"
] | d6e5c928821501ad2ebdf2f988558e9690973778 | https://github.com/DamienRobert/drain/blob/d6e5c928821501ad2ebdf2f988558e9690973778/lib/dr/base/encoding.rb#L35-L41 |
9,289 | godfat/muack | lib/muack/spy.rb | Muack.Spy.__mock_dispatch_spy | def __mock_dispatch_spy
@stub.__mock_disps.values.flatten.each do |disp|
next unless __mock_defis.key?(disp.msg) # ignore undefined spies
defis = __mock_defis[disp.msg]
if idx = __mock_find_checked_difi(defis, disp.args, :index)
__mock_disps_push(defis.delete_at(idx)) # found, d... | ruby | def __mock_dispatch_spy
@stub.__mock_disps.values.flatten.each do |disp|
next unless __mock_defis.key?(disp.msg) # ignore undefined spies
defis = __mock_defis[disp.msg]
if idx = __mock_find_checked_difi(defis, disp.args, :index)
__mock_disps_push(defis.delete_at(idx)) # found, d... | [
"def",
"__mock_dispatch_spy",
"@stub",
".",
"__mock_disps",
".",
"values",
".",
"flatten",
".",
"each",
"do",
"|",
"disp",
"|",
"next",
"unless",
"__mock_defis",
".",
"key?",
"(",
"disp",
".",
"msg",
")",
"# ignore undefined spies",
"defis",
"=",
"__mock_defis... | spies don't leave any track
simulate dispatching before passing to mock to verify | [
"spies",
"don",
"t",
"leave",
"any",
"track",
"simulate",
"dispatching",
"before",
"passing",
"to",
"mock",
"to",
"verify"
] | 3b46287a5a45622f7c3458fb1350c64e105ce2b2 | https://github.com/godfat/muack/blob/3b46287a5a45622f7c3458fb1350c64e105ce2b2/lib/muack/spy.rb#L24-L37 |
9,290 | samsao/danger-samsao | lib/samsao/actions.rb | Samsao.Actions.check_non_single_commit_feature | def check_non_single_commit_feature(level = :fail)
commit_count = git.commits.size
message = "Your feature branch should have a single commit but found #{commit_count}, squash them together!"
report(level, message) if feature_branch? && commit_count > 1
end | ruby | def check_non_single_commit_feature(level = :fail)
commit_count = git.commits.size
message = "Your feature branch should have a single commit but found #{commit_count}, squash them together!"
report(level, message) if feature_branch? && commit_count > 1
end | [
"def",
"check_non_single_commit_feature",
"(",
"level",
"=",
":fail",
")",
"commit_count",
"=",
"git",
".",
"commits",
".",
"size",
"message",
"=",
"\"Your feature branch should have a single commit but found #{commit_count}, squash them together!\"",
"report",
"(",
"level",
... | Check if a feature branch have more than one commit.
@param [Symbol] level (Default: :fail)
The report level (:fail, :warn, :message) if the check fails [report](#report)
@return [void] | [
"Check",
"if",
"a",
"feature",
"branch",
"have",
"more",
"than",
"one",
"commit",
"."
] | 59a9d6d87e6c58d5c6aadc96fae99555f7ea297b | https://github.com/samsao/danger-samsao/blob/59a9d6d87e6c58d5c6aadc96fae99555f7ea297b/lib/samsao/actions.rb#L22-L27 |
9,291 | samsao/danger-samsao | lib/samsao/actions.rb | Samsao.Actions.check_feature_jira_issue_number | def check_feature_jira_issue_number(level = :fail)
return if samsao.trivial_change? || !samsao.feature_branch?
return report(:fail, 'Your Danger config is missing a `jira_project_key` value.') unless jira_project_key?
message = 'The PR title must starts with JIRA issue number between square brackets'... | ruby | def check_feature_jira_issue_number(level = :fail)
return if samsao.trivial_change? || !samsao.feature_branch?
return report(:fail, 'Your Danger config is missing a `jira_project_key` value.') unless jira_project_key?
message = 'The PR title must starts with JIRA issue number between square brackets'... | [
"def",
"check_feature_jira_issue_number",
"(",
"level",
"=",
":fail",
")",
"return",
"if",
"samsao",
".",
"trivial_change?",
"||",
"!",
"samsao",
".",
"feature_branch?",
"return",
"report",
"(",
":fail",
",",
"'Your Danger config is missing a `jira_project_key` value.'",
... | Check if a feature branch contains a single JIRA issue number matching the jira project key.
@param [Symbol] level (Default: :fail)
The report level (:fail, :warn, :message) if the check fails [report](#report)
@return [void] | [
"Check",
"if",
"a",
"feature",
"branch",
"contains",
"a",
"single",
"JIRA",
"issue",
"number",
"matching",
"the",
"jira",
"project",
"key",
"."
] | 59a9d6d87e6c58d5c6aadc96fae99555f7ea297b | https://github.com/samsao/danger-samsao/blob/59a9d6d87e6c58d5c6aadc96fae99555f7ea297b/lib/samsao/actions.rb#L71-L79 |
9,292 | samsao/danger-samsao | lib/samsao/actions.rb | Samsao.Actions.check_fix_jira_issue_number | def check_fix_jira_issue_number(level = :warn)
return if samsao.trivial_change? || !samsao.fix_branch?
return report(:fail, 'Your Danger config is missing a `jira_project_key` value.') unless jira_project_key?
git.commits.each do |commit|
check_commit_contains_jira_issue_number(commit, level)... | ruby | def check_fix_jira_issue_number(level = :warn)
return if samsao.trivial_change? || !samsao.fix_branch?
return report(:fail, 'Your Danger config is missing a `jira_project_key` value.') unless jira_project_key?
git.commits.each do |commit|
check_commit_contains_jira_issue_number(commit, level)... | [
"def",
"check_fix_jira_issue_number",
"(",
"level",
"=",
":warn",
")",
"return",
"if",
"samsao",
".",
"trivial_change?",
"||",
"!",
"samsao",
".",
"fix_branch?",
"return",
"report",
"(",
":fail",
",",
"'Your Danger config is missing a `jira_project_key` value.'",
")",
... | Check if all fix branch commit's message contains any JIRA issue number matching the jira project key.
@param [Symbol] level (Default: :warn)
The report level (:fail, :warn, :message) if the check fails [report](#report)
@return [void] | [
"Check",
"if",
"all",
"fix",
"branch",
"commit",
"s",
"message",
"contains",
"any",
"JIRA",
"issue",
"number",
"matching",
"the",
"jira",
"project",
"key",
"."
] | 59a9d6d87e6c58d5c6aadc96fae99555f7ea297b | https://github.com/samsao/danger-samsao/blob/59a9d6d87e6c58d5c6aadc96fae99555f7ea297b/lib/samsao/actions.rb#L87-L94 |
9,293 | samsao/danger-samsao | lib/samsao/actions.rb | Samsao.Actions.check_acceptance_criteria | def check_acceptance_criteria(level = :warn)
return unless samsao.feature_branch?
message = 'The PR description should have the acceptance criteria in the body.'
report(level, message) if (/acceptance criteria/i =~ github.pr_body).nil?
end | ruby | def check_acceptance_criteria(level = :warn)
return unless samsao.feature_branch?
message = 'The PR description should have the acceptance criteria in the body.'
report(level, message) if (/acceptance criteria/i =~ github.pr_body).nil?
end | [
"def",
"check_acceptance_criteria",
"(",
"level",
"=",
":warn",
")",
"return",
"unless",
"samsao",
".",
"feature_branch?",
"message",
"=",
"'The PR description should have the acceptance criteria in the body.'",
"report",
"(",
"level",
",",
"message",
")",
"if",
"(",
"/... | Check if it's a feature branch and if the PR body contains acceptance criteria.
@param [Symbol] level (Default: :warn)
The report level (:fail, :warn, :message) if the check fails [report](#report)
@return [void] | [
"Check",
"if",
"it",
"s",
"a",
"feature",
"branch",
"and",
"if",
"the",
"PR",
"body",
"contains",
"acceptance",
"criteria",
"."
] | 59a9d6d87e6c58d5c6aadc96fae99555f7ea297b | https://github.com/samsao/danger-samsao/blob/59a9d6d87e6c58d5c6aadc96fae99555f7ea297b/lib/samsao/actions.rb#L102-L108 |
9,294 | samsao/danger-samsao | lib/samsao/actions.rb | Samsao.Actions.check_label_pr | def check_label_pr(level = :fail)
message = 'The PR should have at least one label added to it.'
report(level, message) if github.pr_labels.nil? || github.pr_labels.empty?
end | ruby | def check_label_pr(level = :fail)
message = 'The PR should have at least one label added to it.'
report(level, message) if github.pr_labels.nil? || github.pr_labels.empty?
end | [
"def",
"check_label_pr",
"(",
"level",
"=",
":fail",
")",
"message",
"=",
"'The PR should have at least one label added to it.'",
"report",
"(",
"level",
",",
"message",
")",
"if",
"github",
".",
"pr_labels",
".",
"nil?",
"||",
"github",
".",
"pr_labels",
".",
"... | Check if the PR has at least one label added to it.
@param [Symbol] level (Default: :fail)
The report level (:fail, :warn, :message) if the check fails [report](#report)
@return [void] | [
"Check",
"if",
"the",
"PR",
"has",
"at",
"least",
"one",
"label",
"added",
"to",
"it",
"."
] | 59a9d6d87e6c58d5c6aadc96fae99555f7ea297b | https://github.com/samsao/danger-samsao/blob/59a9d6d87e6c58d5c6aadc96fae99555f7ea297b/lib/samsao/actions.rb#L116-L120 |
9,295 | samsao/danger-samsao | lib/samsao/actions.rb | Samsao.Actions.report | def report(level, content)
case level
when :warn
warn content
when :fail
fail content
when :message
message content
else
raise "Report level '#{level}' is invalid."
end
end | ruby | def report(level, content)
case level
when :warn
warn content
when :fail
fail content
when :message
message content
else
raise "Report level '#{level}' is invalid."
end
end | [
"def",
"report",
"(",
"level",
",",
"content",
")",
"case",
"level",
"when",
":warn",
"warn",
"content",
"when",
":fail",
"fail",
"content",
"when",
":message",
"message",
"content",
"else",
"raise",
"\"Report level '#{level}' is invalid.\"",
"end",
"end"
] | Send report to danger depending on the level.
@param [Symbol] level
The report level sent to Danger :
:message > Comment a message to the table
:warn > Declares a CI warning
:fail > Declares a CI blocking error
@param [String] content
The message of the r... | [
"Send",
"report",
"to",
"danger",
"depending",
"on",
"the",
"level",
"."
] | 59a9d6d87e6c58d5c6aadc96fae99555f7ea297b | https://github.com/samsao/danger-samsao/blob/59a9d6d87e6c58d5c6aadc96fae99555f7ea297b/lib/samsao/actions.rb#L133-L144 |
9,296 | samsao/danger-samsao | lib/samsao/actions.rb | Samsao.Actions.check_commit_contains_jira_issue_number | def check_commit_contains_jira_issue_number(commit, type)
commit_id = "#{shorten_sha(commit.sha)} ('#{truncate(commit.message)}')"
jira_project_key = config.jira_project_key
message = "The commit message #{commit_id} should contain JIRA issue number" \
" between square brackets (i.e. [#{jira_pro... | ruby | def check_commit_contains_jira_issue_number(commit, type)
commit_id = "#{shorten_sha(commit.sha)} ('#{truncate(commit.message)}')"
jira_project_key = config.jira_project_key
message = "The commit message #{commit_id} should contain JIRA issue number" \
" between square brackets (i.e. [#{jira_pro... | [
"def",
"check_commit_contains_jira_issue_number",
"(",
"commit",
",",
"type",
")",
"commit_id",
"=",
"\"#{shorten_sha(commit.sha)} ('#{truncate(commit.message)}')\"",
"jira_project_key",
"=",
"config",
".",
"jira_project_key",
"message",
"=",
"\"The commit message #{commit_id} shou... | Check if the commit's message contains any JIRA issue number matching the jira project key.
@param [Commit] commit
The git commit to check
@param [Symbol] level (Default: :warn)
The report level (:fail, :warn, :message) if the check fails [report](#report)
@return [void] | [
"Check",
"if",
"the",
"commit",
"s",
"message",
"contains",
"any",
"JIRA",
"issue",
"number",
"matching",
"the",
"jira",
"project",
"key",
"."
] | 59a9d6d87e6c58d5c6aadc96fae99555f7ea297b | https://github.com/samsao/danger-samsao/blob/59a9d6d87e6c58d5c6aadc96fae99555f7ea297b/lib/samsao/actions.rb#L156-L164 |
9,297 | zpatten/ztk | lib/ztk/background.rb | ZTK.Background.wait | def wait
config.ui.logger.debug { "wait" }
pid, status = (Process.wait2(@pid) rescue nil)
if !pid.nil? && !status.nil?
data = (Marshal.load(Base64.decode64(@parent_reader.read.to_s)) rescue nil)
config.ui.logger.debug { "read(#{data.inspect})" }
!data.nil? and @result = data
... | ruby | def wait
config.ui.logger.debug { "wait" }
pid, status = (Process.wait2(@pid) rescue nil)
if !pid.nil? && !status.nil?
data = (Marshal.load(Base64.decode64(@parent_reader.read.to_s)) rescue nil)
config.ui.logger.debug { "read(#{data.inspect})" }
!data.nil? and @result = data
... | [
"def",
"wait",
"config",
".",
"ui",
".",
"logger",
".",
"debug",
"{",
"\"wait\"",
"}",
"pid",
",",
"status",
"=",
"(",
"Process",
".",
"wait2",
"(",
"@pid",
")",
"rescue",
"nil",
")",
"if",
"!",
"pid",
".",
"nil?",
"&&",
"!",
"status",
".",
"nil?... | Wait for the background process to finish.
If a process successfully finished, it's return value from the *process*
block is stored into the result set.
It's advisable to use something like the *at_exit* hook to ensure you don't
leave orphaned processes. For example, in the *at_exit* hook you could
call *wait* ... | [
"Wait",
"for",
"the",
"background",
"process",
"to",
"finish",
"."
] | 9b0f35bef36f38428e1a57b36f25a806c240b3fb | https://github.com/zpatten/ztk/blob/9b0f35bef36f38428e1a57b36f25a806c240b3fb/lib/ztk/background.rb#L112-L126 |
9,298 | sugaryourcoffee/syclink | lib/syclink/formatter.rb | SycLink.Formatter.extract_columns | def extract_columns(rows, header)
columns = []
header.each do |h|
columns << rows.map do |r|
r.send(h)
end
end
columns
end | ruby | def extract_columns(rows, header)
columns = []
header.each do |h|
columns << rows.map do |r|
r.send(h)
end
end
columns
end | [
"def",
"extract_columns",
"(",
"rows",
",",
"header",
")",
"columns",
"=",
"[",
"]",
"header",
".",
"each",
"do",
"|",
"h",
"|",
"columns",
"<<",
"rows",
".",
"map",
"do",
"|",
"r",
"|",
"r",
".",
"send",
"(",
"h",
")",
"end",
"end",
"columns",
... | Extracts the columns to display in the table based on the header column
names | [
"Extracts",
"the",
"columns",
"to",
"display",
"in",
"the",
"table",
"based",
"on",
"the",
"header",
"column",
"names"
] | 941ee2045c946daa1e0db394eb643aa82c1254cc | https://github.com/sugaryourcoffee/syclink/blob/941ee2045c946daa1e0db394eb643aa82c1254cc/lib/syclink/formatter.rb#L59-L67 |
9,299 | sugaryourcoffee/syclink | lib/syclink/formatter.rb | SycLink.Formatter.max_column_widths | def max_column_widths(columns, header, opts = {})
row_column_widths = columns.map do |c|
c.reduce(0) { |m, v| [m, v.nil? ? 0 : v.length].max }
end
header_column_widths = header.map { |h| h.length }
row_column_widths = header_column_widths if row_column_widths.empty?
widths = ro... | ruby | def max_column_widths(columns, header, opts = {})
row_column_widths = columns.map do |c|
c.reduce(0) { |m, v| [m, v.nil? ? 0 : v.length].max }
end
header_column_widths = header.map { |h| h.length }
row_column_widths = header_column_widths if row_column_widths.empty?
widths = ro... | [
"def",
"max_column_widths",
"(",
"columns",
",",
"header",
",",
"opts",
"=",
"{",
"}",
")",
"row_column_widths",
"=",
"columns",
".",
"map",
"do",
"|",
"c",
"|",
"c",
".",
"reduce",
"(",
"0",
")",
"{",
"|",
"m",
",",
"v",
"|",
"[",
"m",
",",
"v... | Determines max column widths for each column based on the data and header
columns. | [
"Determines",
"max",
"column",
"widths",
"for",
"each",
"column",
"based",
"on",
"the",
"data",
"and",
"header",
"columns",
"."
] | 941ee2045c946daa1e0db394eb643aa82c1254cc | https://github.com/sugaryourcoffee/syclink/blob/941ee2045c946daa1e0db394eb643aa82c1254cc/lib/syclink/formatter.rb#L71-L85 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.