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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
10,600 | fastlane/fastlane | gym/lib/gym/runner.rb | Gym.Runner.move_app_thinning_size_report | def move_app_thinning_size_report
if File.exist?(PackageCommandGenerator.app_thinning_size_report_path)
FileUtils.mv(PackageCommandGenerator.app_thinning_size_report_path, File.expand_path(Gym.config[:output_directory]), force: true)
app_thinning_size_report_path = File.join(File.expand_path(Gym.c... | ruby | def move_app_thinning_size_report
if File.exist?(PackageCommandGenerator.app_thinning_size_report_path)
FileUtils.mv(PackageCommandGenerator.app_thinning_size_report_path, File.expand_path(Gym.config[:output_directory]), force: true)
app_thinning_size_report_path = File.join(File.expand_path(Gym.c... | [
"def",
"move_app_thinning_size_report",
"if",
"File",
".",
"exist?",
"(",
"PackageCommandGenerator",
".",
"app_thinning_size_report_path",
")",
"FileUtils",
".",
"mv",
"(",
"PackageCommandGenerator",
".",
"app_thinning_size_report_path",
",",
"File",
".",
"expand_path",
"... | Move the App Thinning Size Report.txt file into the output directory | [
"Move",
"the",
"App",
"Thinning",
"Size",
"Report",
".",
"txt",
"file",
"into",
"the",
"output",
"directory"
] | 457c5d647c77f0e078dafa5129da616914e002c5 | https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/gym/lib/gym/runner.rb#L237-L246 |
10,601 | fastlane/fastlane | gym/lib/gym/runner.rb | Gym.Runner.move_apps_folder | def move_apps_folder
if Dir.exist?(PackageCommandGenerator.apps_path)
FileUtils.mv(PackageCommandGenerator.apps_path, File.expand_path(Gym.config[:output_directory]), force: true)
apps_path = File.join(File.expand_path(Gym.config[:output_directory]), File.basename(PackageCommandGenerator.apps_path... | ruby | def move_apps_folder
if Dir.exist?(PackageCommandGenerator.apps_path)
FileUtils.mv(PackageCommandGenerator.apps_path, File.expand_path(Gym.config[:output_directory]), force: true)
apps_path = File.join(File.expand_path(Gym.config[:output_directory]), File.basename(PackageCommandGenerator.apps_path... | [
"def",
"move_apps_folder",
"if",
"Dir",
".",
"exist?",
"(",
"PackageCommandGenerator",
".",
"apps_path",
")",
"FileUtils",
".",
"mv",
"(",
"PackageCommandGenerator",
".",
"apps_path",
",",
"File",
".",
"expand_path",
"(",
"Gym",
".",
"config",
"[",
":output_dire... | Move the Apps folder to the output directory | [
"Move",
"the",
"Apps",
"folder",
"to",
"the",
"output",
"directory"
] | 457c5d647c77f0e078dafa5129da616914e002c5 | https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/gym/lib/gym/runner.rb#L249-L258 |
10,602 | fastlane/fastlane | fastlane/lib/fastlane/swift_fastlane_api_generator.rb | Fastlane.SwiftFastlaneAPIGenerator.determine_api_version | def determine_api_version(new_file_content: nil, old_file_content: nil)
# we know 100% there is a difference, so no need to compare
unless old_file_content.length >= new_file_content.length
old_api_version = find_api_version_string(content: old_file_content)
return DEFAULT_API_VERSION_STRIN... | ruby | def determine_api_version(new_file_content: nil, old_file_content: nil)
# we know 100% there is a difference, so no need to compare
unless old_file_content.length >= new_file_content.length
old_api_version = find_api_version_string(content: old_file_content)
return DEFAULT_API_VERSION_STRIN... | [
"def",
"determine_api_version",
"(",
"new_file_content",
":",
"nil",
",",
"old_file_content",
":",
"nil",
")",
"# we know 100% there is a difference, so no need to compare",
"unless",
"old_file_content",
".",
"length",
">=",
"new_file_content",
".",
"length",
"old_api_version... | compares the new file content to the old and figures out what api_version the new content should be | [
"compares",
"the",
"new",
"file",
"content",
"to",
"the",
"old",
"and",
"figures",
"out",
"what",
"api_version",
"the",
"new",
"content",
"should",
"be"
] | 457c5d647c77f0e078dafa5129da616914e002c5 | https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/fastlane/lib/fastlane/swift_fastlane_api_generator.rb#L223-L246 |
10,603 | fastlane/fastlane | fastlane/lib/fastlane/swift_fastlane_api_generator.rb | Fastlane.SwiftFastlaneAPIGenerator.increment_api_version_string | def increment_api_version_string(api_version_string: nil, increment_by: :patch)
versions = api_version_string.split(".")
major = versions[0].to_i
minor = versions[1].to_i
patch = versions[2].to_i
case increment_by
when :patch
patch += 1
when :minor
minor += 1
... | ruby | def increment_api_version_string(api_version_string: nil, increment_by: :patch)
versions = api_version_string.split(".")
major = versions[0].to_i
minor = versions[1].to_i
patch = versions[2].to_i
case increment_by
when :patch
patch += 1
when :minor
minor += 1
... | [
"def",
"increment_api_version_string",
"(",
"api_version_string",
":",
"nil",
",",
"increment_by",
":",
":patch",
")",
"versions",
"=",
"api_version_string",
".",
"split",
"(",
"\".\"",
")",
"major",
"=",
"versions",
"[",
"0",
"]",
".",
"to_i",
"minor",
"=",
... | expects format to be "X.Y.Z" where each value is a number | [
"expects",
"format",
"to",
"be",
"X",
".",
"Y",
".",
"Z",
"where",
"each",
"value",
"is",
"a",
"number"
] | 457c5d647c77f0e078dafa5129da616914e002c5 | https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/fastlane/lib/fastlane/swift_fastlane_api_generator.rb#L249-L269 |
10,604 | fastlane/fastlane | credentials_manager/lib/credentials_manager/appfile_config.rb | CredentialsManager.AppfileConfig.for_lane | def for_lane(lane_name)
if lane_name.to_s.split(" ").count > 1
# That's the legacy syntax 'platform name'
puts("You use deprecated syntax '#{lane_name}' in your Appfile.".yellow)
puts("Please follow the Appfile guide: https://docs.fastlane.tools/advanced/#appfile".yellow)
platform,... | ruby | def for_lane(lane_name)
if lane_name.to_s.split(" ").count > 1
# That's the legacy syntax 'platform name'
puts("You use deprecated syntax '#{lane_name}' in your Appfile.".yellow)
puts("Please follow the Appfile guide: https://docs.fastlane.tools/advanced/#appfile".yellow)
platform,... | [
"def",
"for_lane",
"(",
"lane_name",
")",
"if",
"lane_name",
".",
"to_s",
".",
"split",
"(",
"\" \"",
")",
".",
"count",
">",
"1",
"# That's the legacy syntax 'platform name'",
"puts",
"(",
"\"You use deprecated syntax '#{lane_name}' in your Appfile.\"",
".",
"yellow",
... | Override Appfile configuration for a specific lane.
lane_name - Symbol representing a lane name. (Can be either :name, 'name' or 'platform name')
block - Block to execute to override configuration values.
Discussion If received lane name does not match the lane name available as environment variable, no changes w... | [
"Override",
"Appfile",
"configuration",
"for",
"a",
"specific",
"lane",
"."
] | 457c5d647c77f0e078dafa5129da616914e002c5 | https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/credentials_manager/lib/credentials_manager/appfile_config.rb#L152-L166 |
10,605 | fastlane/fastlane | fastlane/lib/fastlane/swift_runner_upgrader.rb | Fastlane.SwiftRunnerUpgrader.file_needs_update? | def file_needs_update?(filename: nil)
# looking for something like: FastlaneRunnerAPIVersion [0.9.1]
regex_to_use = API_VERSION_REGEX
source = File.join(self.source_swift_code_file_folder_path, "/#{filename}")
target = File.join(self.target_swift_code_file_folder_path, "/#{filename}")
# ... | ruby | def file_needs_update?(filename: nil)
# looking for something like: FastlaneRunnerAPIVersion [0.9.1]
regex_to_use = API_VERSION_REGEX
source = File.join(self.source_swift_code_file_folder_path, "/#{filename}")
target = File.join(self.target_swift_code_file_folder_path, "/#{filename}")
# ... | [
"def",
"file_needs_update?",
"(",
"filename",
":",
"nil",
")",
"# looking for something like: FastlaneRunnerAPIVersion [0.9.1]",
"regex_to_use",
"=",
"API_VERSION_REGEX",
"source",
"=",
"File",
".",
"join",
"(",
"self",
".",
"source_swift_code_file_folder_path",
",",
"\"/#{... | compares source file against the target file's FastlaneRunnerAPIVersion and returned `true` if there is a difference | [
"compares",
"source",
"file",
"against",
"the",
"target",
"file",
"s",
"FastlaneRunnerAPIVersion",
"and",
"returned",
"true",
"if",
"there",
"is",
"a",
"difference"
] | 457c5d647c77f0e078dafa5129da616914e002c5 | https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/fastlane/lib/fastlane/swift_runner_upgrader.rb#L80-L107 |
10,606 | fastlane/fastlane | fastlane/lib/fastlane/swift_runner_upgrader.rb | Fastlane.SwiftRunnerUpgrader.copy_file_if_needed! | def copy_file_if_needed!(filename: nil, dry_run: false)
needs_update = file_needs_update?(filename: filename)
UI.verbose("file #{filename} needs an update") if needs_update
# Ok, we know if this file needs an update, can return now if it's a dry run
return needs_update if dry_run
unless ... | ruby | def copy_file_if_needed!(filename: nil, dry_run: false)
needs_update = file_needs_update?(filename: filename)
UI.verbose("file #{filename} needs an update") if needs_update
# Ok, we know if this file needs an update, can return now if it's a dry run
return needs_update if dry_run
unless ... | [
"def",
"copy_file_if_needed!",
"(",
"filename",
":",
"nil",
",",
"dry_run",
":",
"false",
")",
"needs_update",
"=",
"file_needs_update?",
"(",
"filename",
":",
"filename",
")",
"UI",
".",
"verbose",
"(",
"\"file #{filename} needs an update\"",
")",
"if",
"needs_up... | currently just copies file, even if not needed. | [
"currently",
"just",
"copies",
"file",
"even",
"if",
"not",
"needed",
"."
] | 457c5d647c77f0e078dafa5129da616914e002c5 | https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/fastlane/lib/fastlane/swift_runner_upgrader.rb#L110-L128 |
10,607 | apache/thrift | lib/rb/lib/thrift/server/thread_pool_server.rb | Thrift.ThreadPoolServer.serve | def serve
@server_transport.listen
begin
loop do
@thread_q.push(:token)
Thread.new do
begin
loop do
client = @server_transport.accept
trans = @transport_factory.get_transport(client)
prot = @protocol_facto... | ruby | def serve
@server_transport.listen
begin
loop do
@thread_q.push(:token)
Thread.new do
begin
loop do
client = @server_transport.accept
trans = @transport_factory.get_transport(client)
prot = @protocol_facto... | [
"def",
"serve",
"@server_transport",
".",
"listen",
"begin",
"loop",
"do",
"@thread_q",
".",
"push",
"(",
":token",
")",
"Thread",
".",
"new",
"do",
"begin",
"loop",
"do",
"client",
"=",
"@server_transport",
".",
"accept",
"trans",
"=",
"@transport_factory",
... | exceptions that happen in worker threads simply cause that thread
to die and another to be spawned in its place. | [
"exceptions",
"that",
"happen",
"in",
"worker",
"threads",
"simply",
"cause",
"that",
"thread",
"to",
"die",
"and",
"another",
"to",
"be",
"spawned",
"in",
"its",
"place",
"."
] | 27d8387c49a49fcf193893f834e9766ae0b051c1 | https://github.com/apache/thrift/blob/27d8387c49a49fcf193893f834e9766ae0b051c1/lib/rb/lib/thrift/server/thread_pool_server.rb#L42-L73 |
10,608 | apache/thrift | lib/rb/lib/thrift/protocol/json_protocol.rb | Thrift.JsonProtocol.write_json_char | def write_json_char(ch)
# This table describes the handling for the first 0x30 characters
# 0 : escape using "\u00xx" notation
# 1 : just output index
# <other> : escape using "\<other>" notation
kJSONCharTable = [
# 0 1 2 3 4 5 6 7 8 9 A B C D E F
0, 0, 0, 0, 0, 0, 0, ... | ruby | def write_json_char(ch)
# This table describes the handling for the first 0x30 characters
# 0 : escape using "\u00xx" notation
# 1 : just output index
# <other> : escape using "\<other>" notation
kJSONCharTable = [
# 0 1 2 3 4 5 6 7 8 9 A B C D E F
0, 0, 0, 0, 0, 0, 0, ... | [
"def",
"write_json_char",
"(",
"ch",
")",
"# This table describes the handling for the first 0x30 characters",
"# 0 : escape using \"\\u00xx\" notation",
"# 1 : just output index",
"# <other> : escape using \"\\<other>\" notation",
"kJSONCharTable",
"=",
"[",
"# 0 1 2 3 4 5 6 7 8 9 A B C D E... | Write the character ch as part of a JSON string, escaping as appropriate. | [
"Write",
"the",
"character",
"ch",
"as",
"part",
"of",
"a",
"JSON",
"string",
"escaping",
"as",
"appropriate",
"."
] | 27d8387c49a49fcf193893f834e9766ae0b051c1 | https://github.com/apache/thrift/blob/27d8387c49a49fcf193893f834e9766ae0b051c1/lib/rb/lib/thrift/protocol/json_protocol.rb#L262-L297 |
10,609 | apache/thrift | lib/rb/lib/thrift/protocol/json_protocol.rb | Thrift.JsonProtocol.write_json_string | def write_json_string(str)
@context.write(trans)
trans.write(@@kJSONStringDelimiter)
str.split('').each do |ch|
write_json_char(ch)
end
trans.write(@@kJSONStringDelimiter)
end | ruby | def write_json_string(str)
@context.write(trans)
trans.write(@@kJSONStringDelimiter)
str.split('').each do |ch|
write_json_char(ch)
end
trans.write(@@kJSONStringDelimiter)
end | [
"def",
"write_json_string",
"(",
"str",
")",
"@context",
".",
"write",
"(",
"trans",
")",
"trans",
".",
"write",
"(",
"@@kJSONStringDelimiter",
")",
"str",
".",
"split",
"(",
"''",
")",
".",
"each",
"do",
"|",
"ch",
"|",
"write_json_char",
"(",
"ch",
"... | Write out the contents of the string str as a JSON string, escaping characters as appropriate. | [
"Write",
"out",
"the",
"contents",
"of",
"the",
"string",
"str",
"as",
"a",
"JSON",
"string",
"escaping",
"characters",
"as",
"appropriate",
"."
] | 27d8387c49a49fcf193893f834e9766ae0b051c1 | https://github.com/apache/thrift/blob/27d8387c49a49fcf193893f834e9766ae0b051c1/lib/rb/lib/thrift/protocol/json_protocol.rb#L300-L307 |
10,610 | apache/thrift | lib/rb/lib/thrift/protocol/json_protocol.rb | Thrift.JsonProtocol.write_json_base64 | def write_json_base64(str)
@context.write(trans)
trans.write(@@kJSONStringDelimiter)
trans.write(Base64.strict_encode64(str))
trans.write(@@kJSONStringDelimiter)
end | ruby | def write_json_base64(str)
@context.write(trans)
trans.write(@@kJSONStringDelimiter)
trans.write(Base64.strict_encode64(str))
trans.write(@@kJSONStringDelimiter)
end | [
"def",
"write_json_base64",
"(",
"str",
")",
"@context",
".",
"write",
"(",
"trans",
")",
"trans",
".",
"write",
"(",
"@@kJSONStringDelimiter",
")",
"trans",
".",
"write",
"(",
"Base64",
".",
"strict_encode64",
"(",
"str",
")",
")",
"trans",
".",
"write",
... | Write out the contents of the string as JSON string, base64-encoding
the string's contents, and escaping as appropriate | [
"Write",
"out",
"the",
"contents",
"of",
"the",
"string",
"as",
"JSON",
"string",
"base64",
"-",
"encoding",
"the",
"string",
"s",
"contents",
"and",
"escaping",
"as",
"appropriate"
] | 27d8387c49a49fcf193893f834e9766ae0b051c1 | https://github.com/apache/thrift/blob/27d8387c49a49fcf193893f834e9766ae0b051c1/lib/rb/lib/thrift/protocol/json_protocol.rb#L311-L316 |
10,611 | apache/thrift | lib/rb/lib/thrift/protocol/json_protocol.rb | Thrift.JsonProtocol.write_json_double | def write_json_double(num)
@context.write(trans)
# Normalize output of thrift::to_string for NaNs and Infinities
special = false;
if (num.nan?)
special = true;
val = @@kThriftNan;
elsif (num.infinite?)
special = true;
val = @@kThriftInfinity;
if (num... | ruby | def write_json_double(num)
@context.write(trans)
# Normalize output of thrift::to_string for NaNs and Infinities
special = false;
if (num.nan?)
special = true;
val = @@kThriftNan;
elsif (num.infinite?)
special = true;
val = @@kThriftInfinity;
if (num... | [
"def",
"write_json_double",
"(",
"num",
")",
"@context",
".",
"write",
"(",
"trans",
")",
"# Normalize output of thrift::to_string for NaNs and Infinities",
"special",
"=",
"false",
";",
"if",
"(",
"num",
".",
"nan?",
")",
"special",
"=",
"true",
";",
"val",
"="... | Convert the given double to a JSON string, which is either the number,
"NaN" or "Infinity" or "-Infinity". | [
"Convert",
"the",
"given",
"double",
"to",
"a",
"JSON",
"string",
"which",
"is",
"either",
"the",
"number",
"NaN",
"or",
"Infinity",
"or",
"-",
"Infinity",
"."
] | 27d8387c49a49fcf193893f834e9766ae0b051c1 | https://github.com/apache/thrift/blob/27d8387c49a49fcf193893f834e9766ae0b051c1/lib/rb/lib/thrift/protocol/json_protocol.rb#L334-L359 |
10,612 | apache/thrift | lib/rb/lib/thrift/protocol/json_protocol.rb | Thrift.JsonProtocol.read_json_escape_char | def read_json_escape_char
str = @reader.read
str += @reader.read
str += @reader.read
str += @reader.read
if RUBY_VERSION >= '1.9'
str.hex.chr(Encoding::UTF_8)
else
str.hex.chr
end
end | ruby | def read_json_escape_char
str = @reader.read
str += @reader.read
str += @reader.read
str += @reader.read
if RUBY_VERSION >= '1.9'
str.hex.chr(Encoding::UTF_8)
else
str.hex.chr
end
end | [
"def",
"read_json_escape_char",
"str",
"=",
"@reader",
".",
"read",
"str",
"+=",
"@reader",
".",
"read",
"str",
"+=",
"@reader",
".",
"read",
"str",
"+=",
"@reader",
".",
"read",
"if",
"RUBY_VERSION",
">=",
"'1.9'",
"str",
".",
"hex",
".",
"chr",
"(",
... | Decodes the four hex parts of a JSON escaped string character and returns
the character via out.
Note - this only supports Unicode characters in the BMP (U+0000 to U+FFFF);
characters above the BMP are encoded as two escape sequences (surrogate pairs),
which is not yet implemented | [
"Decodes",
"the",
"four",
"hex",
"parts",
"of",
"a",
"JSON",
"escaped",
"string",
"character",
"and",
"returns",
"the",
"character",
"via",
"out",
"."
] | 27d8387c49a49fcf193893f834e9766ae0b051c1 | https://github.com/apache/thrift/blob/27d8387c49a49fcf193893f834e9766ae0b051c1/lib/rb/lib/thrift/protocol/json_protocol.rb#L495-L505 |
10,613 | apache/thrift | lib/rb/lib/thrift/protocol/json_protocol.rb | Thrift.JsonProtocol.read_json_string | def read_json_string(skipContext = false)
# This string's characters must match up with the elements in escape_char_vals.
# I don't have '/' on this list even though it appears on www.json.org --
# it is not in the RFC -> it is. See RFC 4627
escape_chars = "\"\\/bfnrt"
# The elements of t... | ruby | def read_json_string(skipContext = false)
# This string's characters must match up with the elements in escape_char_vals.
# I don't have '/' on this list even though it appears on www.json.org --
# it is not in the RFC -> it is. See RFC 4627
escape_chars = "\"\\/bfnrt"
# The elements of t... | [
"def",
"read_json_string",
"(",
"skipContext",
"=",
"false",
")",
"# This string's characters must match up with the elements in escape_char_vals.",
"# I don't have '/' on this list even though it appears on www.json.org --",
"# it is not in the RFC -> it is. See RFC 4627",
"escape_chars",
"="... | Decodes a JSON string, including unescaping, and returns the string via str | [
"Decodes",
"a",
"JSON",
"string",
"including",
"unescaping",
"and",
"returns",
"the",
"string",
"via",
"str"
] | 27d8387c49a49fcf193893f834e9766ae0b051c1 | https://github.com/apache/thrift/blob/27d8387c49a49fcf193893f834e9766ae0b051c1/lib/rb/lib/thrift/protocol/json_protocol.rb#L508-L546 |
10,614 | apache/thrift | lib/rb/lib/thrift/protocol/json_protocol.rb | Thrift.JsonProtocol.read_json_base64 | def read_json_base64
str = read_json_string
m = str.length % 4
if m != 0
# Add missing padding
(4 - m).times do
str += '='
end
end
Base64.strict_decode64(str)
end | ruby | def read_json_base64
str = read_json_string
m = str.length % 4
if m != 0
# Add missing padding
(4 - m).times do
str += '='
end
end
Base64.strict_decode64(str)
end | [
"def",
"read_json_base64",
"str",
"=",
"read_json_string",
"m",
"=",
"str",
".",
"length",
"%",
"4",
"if",
"m",
"!=",
"0",
"# Add missing padding",
"(",
"4",
"-",
"m",
")",
".",
"times",
"do",
"str",
"+=",
"'='",
"end",
"end",
"Base64",
".",
"strict_de... | Reads a block of base64 characters, decoding it, and returns via str | [
"Reads",
"a",
"block",
"of",
"base64",
"characters",
"decoding",
"it",
"and",
"returns",
"via",
"str"
] | 27d8387c49a49fcf193893f834e9766ae0b051c1 | https://github.com/apache/thrift/blob/27d8387c49a49fcf193893f834e9766ae0b051c1/lib/rb/lib/thrift/protocol/json_protocol.rb#L549-L559 |
10,615 | apache/thrift | lib/rb/lib/thrift/protocol/json_protocol.rb | Thrift.JsonProtocol.read_json_numeric_chars | def read_json_numeric_chars
str = ""
while (true)
ch = @reader.peek
if (!is_json_numeric(ch))
break;
end
ch = @reader.read
str += ch
end
return str
end | ruby | def read_json_numeric_chars
str = ""
while (true)
ch = @reader.peek
if (!is_json_numeric(ch))
break;
end
ch = @reader.read
str += ch
end
return str
end | [
"def",
"read_json_numeric_chars",
"str",
"=",
"\"\"",
"while",
"(",
"true",
")",
"ch",
"=",
"@reader",
".",
"peek",
"if",
"(",
"!",
"is_json_numeric",
"(",
"ch",
")",
")",
"break",
";",
"end",
"ch",
"=",
"@reader",
".",
"read",
"str",
"+=",
"ch",
"en... | Reads a sequence of characters, stopping at the first one that is not
a valid JSON numeric character. | [
"Reads",
"a",
"sequence",
"of",
"characters",
"stopping",
"at",
"the",
"first",
"one",
"that",
"is",
"not",
"a",
"valid",
"JSON",
"numeric",
"character",
"."
] | 27d8387c49a49fcf193893f834e9766ae0b051c1 | https://github.com/apache/thrift/blob/27d8387c49a49fcf193893f834e9766ae0b051c1/lib/rb/lib/thrift/protocol/json_protocol.rb#L563-L574 |
10,616 | apache/thrift | lib/rb/lib/thrift/protocol/json_protocol.rb | Thrift.JsonProtocol.read_json_integer | def read_json_integer
@context.read(@reader)
if (@context.escapeNum)
read_json_syntax_char(@@kJSONStringDelimiter)
end
str = read_json_numeric_chars
begin
num = Integer(str);
rescue
raise ProtocolException.new(ProtocolException::INVALID_DATA, "Expected numeri... | ruby | def read_json_integer
@context.read(@reader)
if (@context.escapeNum)
read_json_syntax_char(@@kJSONStringDelimiter)
end
str = read_json_numeric_chars
begin
num = Integer(str);
rescue
raise ProtocolException.new(ProtocolException::INVALID_DATA, "Expected numeri... | [
"def",
"read_json_integer",
"@context",
".",
"read",
"(",
"@reader",
")",
"if",
"(",
"@context",
".",
"escapeNum",
")",
"read_json_syntax_char",
"(",
"@@kJSONStringDelimiter",
")",
"end",
"str",
"=",
"read_json_numeric_chars",
"begin",
"num",
"=",
"Integer",
"(",
... | Reads a sequence of characters and assembles them into a number,
returning them via num | [
"Reads",
"a",
"sequence",
"of",
"characters",
"and",
"assembles",
"them",
"into",
"a",
"number",
"returning",
"them",
"via",
"num"
] | 27d8387c49a49fcf193893f834e9766ae0b051c1 | https://github.com/apache/thrift/blob/27d8387c49a49fcf193893f834e9766ae0b051c1/lib/rb/lib/thrift/protocol/json_protocol.rb#L578-L596 |
10,617 | apache/thrift | lib/rb/lib/thrift/protocol/json_protocol.rb | Thrift.JsonProtocol.read_json_double | def read_json_double
@context.read(@reader)
num = 0
if (@reader.peek == @@kJSONStringDelimiter)
str = read_json_string(true)
# Check for NaN, Infinity and -Infinity
if (str == @@kThriftNan)
num = (+1.0/0.0)/(+1.0/0.0)
elsif (str == @@kThriftInfinity)
... | ruby | def read_json_double
@context.read(@reader)
num = 0
if (@reader.peek == @@kJSONStringDelimiter)
str = read_json_string(true)
# Check for NaN, Infinity and -Infinity
if (str == @@kThriftNan)
num = (+1.0/0.0)/(+1.0/0.0)
elsif (str == @@kThriftInfinity)
... | [
"def",
"read_json_double",
"@context",
".",
"read",
"(",
"@reader",
")",
"num",
"=",
"0",
"if",
"(",
"@reader",
".",
"peek",
"==",
"@@kJSONStringDelimiter",
")",
"str",
"=",
"read_json_string",
"(",
"true",
")",
"# Check for NaN, Infinity and -Infinity",
"if",
"... | Reads a JSON number or string and interprets it as a double. | [
"Reads",
"a",
"JSON",
"number",
"or",
"string",
"and",
"interprets",
"it",
"as",
"a",
"double",
"."
] | 27d8387c49a49fcf193893f834e9766ae0b051c1 | https://github.com/apache/thrift/blob/27d8387c49a49fcf193893f834e9766ae0b051c1/lib/rb/lib/thrift/protocol/json_protocol.rb#L599-L635 |
10,618 | apache/thrift | lib/rb/lib/thrift/protocol/base_protocol.rb | Thrift.BaseProtocol.write_field | def write_field(*args)
if args.size == 3
# handles the documented method signature - write_field(field_info, fid, value)
field_info = args[0]
fid = args[1]
value = args[2]
elsif args.size == 4
# handles the deprecated method signature - write_field(name, type, fid, va... | ruby | def write_field(*args)
if args.size == 3
# handles the documented method signature - write_field(field_info, fid, value)
field_info = args[0]
fid = args[1]
value = args[2]
elsif args.size == 4
# handles the deprecated method signature - write_field(name, type, fid, va... | [
"def",
"write_field",
"(",
"*",
"args",
")",
"if",
"args",
".",
"size",
"==",
"3",
"# handles the documented method signature - write_field(field_info, fid, value)",
"field_info",
"=",
"args",
"[",
"0",
"]",
"fid",
"=",
"args",
"[",
"1",
"]",
"value",
"=",
"args... | Writes a field based on the field information, field ID and value.
field_info - A Hash containing the definition of the field:
:name - The name of the field.
:type - The type of the field, which must be a Thrift::Types constant.
:binary - A Boolean flag that indicates if ... | [
"Writes",
"a",
"field",
"based",
"on",
"the",
"field",
"information",
"field",
"ID",
"and",
"value",
"."
] | 27d8387c49a49fcf193893f834e9766ae0b051c1 | https://github.com/apache/thrift/blob/27d8387c49a49fcf193893f834e9766ae0b051c1/lib/rb/lib/thrift/protocol/base_protocol.rb#L225-L243 |
10,619 | apache/thrift | lib/rb/lib/thrift/protocol/base_protocol.rb | Thrift.BaseProtocol.write_type | def write_type(field_info, value)
# if field_info is a Fixnum, assume it is a Thrift::Types constant
# convert it into a field_info Hash for backwards compatibility
if field_info.is_a? Fixnum
field_info = {:type => field_info}
end
case field_info[:type]
when Types::BOOL
... | ruby | def write_type(field_info, value)
# if field_info is a Fixnum, assume it is a Thrift::Types constant
# convert it into a field_info Hash for backwards compatibility
if field_info.is_a? Fixnum
field_info = {:type => field_info}
end
case field_info[:type]
when Types::BOOL
... | [
"def",
"write_type",
"(",
"field_info",
",",
"value",
")",
"# if field_info is a Fixnum, assume it is a Thrift::Types constant",
"# convert it into a field_info Hash for backwards compatibility",
"if",
"field_info",
".",
"is_a?",
"Fixnum",
"field_info",
"=",
"{",
":type",
"=>",
... | Writes a field value based on the field information.
field_info - A Hash containing the definition of the field:
:type - The Thrift::Types constant that determines how the value is written.
:binary - A Boolean flag that indicates if Thrift::Types::STRING is a binary string (string withou... | [
"Writes",
"a",
"field",
"value",
"based",
"on",
"the",
"field",
"information",
"."
] | 27d8387c49a49fcf193893f834e9766ae0b051c1 | https://github.com/apache/thrift/blob/27d8387c49a49fcf193893f834e9766ae0b051c1/lib/rb/lib/thrift/protocol/base_protocol.rb#L253-L284 |
10,620 | apache/thrift | lib/rb/lib/thrift/protocol/base_protocol.rb | Thrift.BaseProtocol.read_type | def read_type(field_info)
# if field_info is a Fixnum, assume it is a Thrift::Types constant
# convert it into a field_info Hash for backwards compatibility
if field_info.is_a? Fixnum
field_info = {:type => field_info}
end
case field_info[:type]
when Types::BOOL
read... | ruby | def read_type(field_info)
# if field_info is a Fixnum, assume it is a Thrift::Types constant
# convert it into a field_info Hash for backwards compatibility
if field_info.is_a? Fixnum
field_info = {:type => field_info}
end
case field_info[:type]
when Types::BOOL
read... | [
"def",
"read_type",
"(",
"field_info",
")",
"# if field_info is a Fixnum, assume it is a Thrift::Types constant",
"# convert it into a field_info Hash for backwards compatibility",
"if",
"field_info",
".",
"is_a?",
"Fixnum",
"field_info",
"=",
"{",
":type",
"=>",
"field_info",
"}... | Reads a field value based on the field information.
field_info - A Hash containing the pertinent data to write:
:type - The Thrift::Types constant that determines how the value is written.
:binary - A flag that indicates if Thrift::Types::STRING is a binary string (string without encodin... | [
"Reads",
"a",
"field",
"value",
"based",
"on",
"the",
"field",
"information",
"."
] | 27d8387c49a49fcf193893f834e9766ae0b051c1 | https://github.com/apache/thrift/blob/27d8387c49a49fcf193893f834e9766ae0b051c1/lib/rb/lib/thrift/protocol/base_protocol.rb#L293-L322 |
10,621 | apache/thrift | lib/rb/lib/thrift/protocol/compact_protocol.rb | Thrift.CompactProtocol.write_field_begin_internal | def write_field_begin_internal(type, id, type_override=nil)
last_id = @last_field.pop
# if there's a type override, use that.
typeToWrite = type_override || CompactTypes.get_compact_type(type)
# check if we can use delta encoding for the field id
if id > last_id && id - last_id <= ... | ruby | def write_field_begin_internal(type, id, type_override=nil)
last_id = @last_field.pop
# if there's a type override, use that.
typeToWrite = type_override || CompactTypes.get_compact_type(type)
# check if we can use delta encoding for the field id
if id > last_id && id - last_id <= ... | [
"def",
"write_field_begin_internal",
"(",
"type",
",",
"id",
",",
"type_override",
"=",
"nil",
")",
"last_id",
"=",
"@last_field",
".",
"pop",
"# if there's a type override, use that.",
"typeToWrite",
"=",
"type_override",
"||",
"CompactTypes",
".",
"get_compact_type",
... | The workhorse of writeFieldBegin. It has the option of doing a
'type override' of the type header. This is used specifically in the
boolean field case. | [
"The",
"workhorse",
"of",
"writeFieldBegin",
".",
"It",
"has",
"the",
"option",
"of",
"doing",
"a",
"type",
"override",
"of",
"the",
"type",
"header",
".",
"This",
"is",
"used",
"specifically",
"in",
"the",
"boolean",
"field",
"case",
"."
] | 27d8387c49a49fcf193893f834e9766ae0b051c1 | https://github.com/apache/thrift/blob/27d8387c49a49fcf193893f834e9766ae0b051c1/lib/rb/lib/thrift/protocol/compact_protocol.rb#L140-L158 |
10,622 | apache/thrift | lib/rb/lib/thrift/protocol/compact_protocol.rb | Thrift.CompactProtocol.write_collection_begin | def write_collection_begin(elem_type, size)
if size <= 14
write_byte(size << 4 | CompactTypes.get_compact_type(elem_type))
else
write_byte(0xf0 | CompactTypes.get_compact_type(elem_type))
write_varint32(size)
end
end | ruby | def write_collection_begin(elem_type, size)
if size <= 14
write_byte(size << 4 | CompactTypes.get_compact_type(elem_type))
else
write_byte(0xf0 | CompactTypes.get_compact_type(elem_type))
write_varint32(size)
end
end | [
"def",
"write_collection_begin",
"(",
"elem_type",
",",
"size",
")",
"if",
"size",
"<=",
"14",
"write_byte",
"(",
"size",
"<<",
"4",
"|",
"CompactTypes",
".",
"get_compact_type",
"(",
"elem_type",
")",
")",
"else",
"write_byte",
"(",
"0xf0",
"|",
"CompactTyp... | Abstract method for writing the start of lists and sets. List and sets on
the wire differ only by the type indicator. | [
"Abstract",
"method",
"for",
"writing",
"the",
"start",
"of",
"lists",
"and",
"sets",
".",
"List",
"and",
"sets",
"on",
"the",
"wire",
"differ",
"only",
"by",
"the",
"type",
"indicator",
"."
] | 27d8387c49a49fcf193893f834e9766ae0b051c1 | https://github.com/apache/thrift/blob/27d8387c49a49fcf193893f834e9766ae0b051c1/lib/rb/lib/thrift/protocol/compact_protocol.rb#L359-L366 |
10,623 | apache/thrift | lib/rb/lib/thrift/transport/buffered_transport.rb | Thrift.BufferedTransport.read_into_buffer | def read_into_buffer(buffer, size)
i = 0
while i < size
# If the read buffer is exhausted, try to read up to DEFAULT_BUFFER more bytes into it.
if @index >= @rbuf.size
@rbuf = @transport.read(DEFAULT_BUFFER)
@index = 0
end
# The read buffer has some data ... | ruby | def read_into_buffer(buffer, size)
i = 0
while i < size
# If the read buffer is exhausted, try to read up to DEFAULT_BUFFER more bytes into it.
if @index >= @rbuf.size
@rbuf = @transport.read(DEFAULT_BUFFER)
@index = 0
end
# The read buffer has some data ... | [
"def",
"read_into_buffer",
"(",
"buffer",
",",
"size",
")",
"i",
"=",
"0",
"while",
"i",
"<",
"size",
"# If the read buffer is exhausted, try to read up to DEFAULT_BUFFER more bytes into it.",
"if",
"@index",
">=",
"@rbuf",
".",
"size",
"@rbuf",
"=",
"@transport",
"."... | Reads a number of bytes from the transport into the buffer passed.
buffer - The String (byte buffer) to write data to; this is assumed to have a BINARY encoding.
size - The number of bytes to read from the transport and write to the buffer.
Returns the number of bytes read. | [
"Reads",
"a",
"number",
"of",
"bytes",
"from",
"the",
"transport",
"into",
"the",
"buffer",
"passed",
"."
] | 27d8387c49a49fcf193893f834e9766ae0b051c1 | https://github.com/apache/thrift/blob/27d8387c49a49fcf193893f834e9766ae0b051c1/lib/rb/lib/thrift/transport/buffered_transport.rb#L77-L93 |
10,624 | apache/thrift | lib/rb/benchmark/server.rb | Server.BenchmarkHandler.fibonacci | def fibonacci(n)
seq = [1, 1]
3.upto(n) do
seq << seq[-1] + seq[-2]
end
seq[n-1] # n is 1-based
end | ruby | def fibonacci(n)
seq = [1, 1]
3.upto(n) do
seq << seq[-1] + seq[-2]
end
seq[n-1] # n is 1-based
end | [
"def",
"fibonacci",
"(",
"n",
")",
"seq",
"=",
"[",
"1",
",",
"1",
"]",
"3",
".",
"upto",
"(",
"n",
")",
"do",
"seq",
"<<",
"seq",
"[",
"-",
"1",
"]",
"+",
"seq",
"[",
"-",
"2",
"]",
"end",
"seq",
"[",
"n",
"-",
"1",
"]",
"# n is 1-based"... | 1-based index into the fibonacci sequence | [
"1",
"-",
"based",
"index",
"into",
"the",
"fibonacci",
"sequence"
] | 27d8387c49a49fcf193893f834e9766ae0b051c1 | https://github.com/apache/thrift/blob/27d8387c49a49fcf193893f834e9766ae0b051c1/lib/rb/benchmark/server.rb#L30-L36 |
10,625 | apache/thrift | lib/rb/lib/thrift/transport/framed_transport.rb | Thrift.FramedTransport.flush | def flush
return @transport.flush unless @write
out = [@wbuf.length].pack('N')
# Array#pack should return a BINARY encoded String, so it shouldn't be necessary to force encoding
out << @wbuf
@transport.write(out)
@transport.flush
@wbuf = Bytes.empty_byte_buffer
end | ruby | def flush
return @transport.flush unless @write
out = [@wbuf.length].pack('N')
# Array#pack should return a BINARY encoded String, so it shouldn't be necessary to force encoding
out << @wbuf
@transport.write(out)
@transport.flush
@wbuf = Bytes.empty_byte_buffer
end | [
"def",
"flush",
"return",
"@transport",
".",
"flush",
"unless",
"@write",
"out",
"=",
"[",
"@wbuf",
".",
"length",
"]",
".",
"pack",
"(",
"'N'",
")",
"# Array#pack should return a BINARY encoded String, so it shouldn't be necessary to force encoding",
"out",
"<<",
"@wbu... | Writes the output buffer to the stream in the format of a 4-byte length
followed by the actual data. | [
"Writes",
"the",
"output",
"buffer",
"to",
"the",
"stream",
"in",
"the",
"format",
"of",
"a",
"4",
"-",
"byte",
"length",
"followed",
"by",
"the",
"actual",
"data",
"."
] | 27d8387c49a49fcf193893f834e9766ae0b051c1 | https://github.com/apache/thrift/blob/27d8387c49a49fcf193893f834e9766ae0b051c1/lib/rb/lib/thrift/transport/framed_transport.rb#L91-L100 |
10,626 | huginn/huginn | app/concerns/liquid_interpolatable.rb | LiquidInterpolatable.Filters.to_uri | def to_uri(uri, base_uri = nil)
case base_uri
when nil, ''
Utils.normalize_uri(uri.to_s)
else
Utils.normalize_uri(base_uri) + Utils.normalize_uri(uri.to_s)
end
rescue URI::Error
nil
end | ruby | def to_uri(uri, base_uri = nil)
case base_uri
when nil, ''
Utils.normalize_uri(uri.to_s)
else
Utils.normalize_uri(base_uri) + Utils.normalize_uri(uri.to_s)
end
rescue URI::Error
nil
end | [
"def",
"to_uri",
"(",
"uri",
",",
"base_uri",
"=",
"nil",
")",
"case",
"base_uri",
"when",
"nil",
",",
"''",
"Utils",
".",
"normalize_uri",
"(",
"uri",
".",
"to_s",
")",
"else",
"Utils",
".",
"normalize_uri",
"(",
"base_uri",
")",
"+",
"Utils",
".",
... | Parse an input into a URI object, optionally resolving it
against a base URI if given.
A URI object will have the following properties: scheme,
userinfo, host, port, registry, path, opaque, query, and
fragment. | [
"Parse",
"an",
"input",
"into",
"a",
"URI",
"object",
"optionally",
"resolving",
"it",
"against",
"a",
"base",
"URI",
"if",
"given",
"."
] | 01e18fef7b6bd827a5d48a89391e460b5fb1bee3 | https://github.com/huginn/huginn/blob/01e18fef7b6bd827a5d48a89391e460b5fb1bee3/app/concerns/liquid_interpolatable.rb#L142-L151 |
10,627 | huginn/huginn | app/concerns/liquid_interpolatable.rb | LiquidInterpolatable.Filters.to_xpath | def to_xpath(string)
subs = string.to_s.scan(/\G(?:\A\z|[^"]+|[^']+)/).map { |x|
case x
when /"/
%Q{'#{x}'}
else
%Q{"#{x}"}
end
}
if subs.size == 1
subs.first
else
'concat(' << subs.join(', ') << ')'
end
end | ruby | def to_xpath(string)
subs = string.to_s.scan(/\G(?:\A\z|[^"]+|[^']+)/).map { |x|
case x
when /"/
%Q{'#{x}'}
else
%Q{"#{x}"}
end
}
if subs.size == 1
subs.first
else
'concat(' << subs.join(', ') << ')'
end
end | [
"def",
"to_xpath",
"(",
"string",
")",
"subs",
"=",
"string",
".",
"to_s",
".",
"scan",
"(",
"/",
"\\G",
"\\A",
"\\z",
"/",
")",
".",
"map",
"{",
"|",
"x",
"|",
"case",
"x",
"when",
"/",
"/",
"%Q{'#{x}'}",
"else",
"%Q{\"#{x}\"}",
"end",
"}",
"if"... | Escape a string for use in XPath expression | [
"Escape",
"a",
"string",
"for",
"use",
"in",
"XPath",
"expression"
] | 01e18fef7b6bd827a5d48a89391e460b5fb1bee3 | https://github.com/huginn/huginn/blob/01e18fef7b6bd827a5d48a89391e460b5fb1bee3/app/concerns/liquid_interpolatable.rb#L218-L232 |
10,628 | huginn/huginn | app/models/agents/website_agent.rb | Agents.WebsiteAgent.store_payload! | def store_payload!(old_events, result)
case interpolated['mode'].presence
when 'on_change'
result_json = result.to_json
if found = old_events.find { |event| event.payload.to_json == result_json }
found.update!(expires_at: new_event_expiration_date)
false
else
... | ruby | def store_payload!(old_events, result)
case interpolated['mode'].presence
when 'on_change'
result_json = result.to_json
if found = old_events.find { |event| event.payload.to_json == result_json }
found.update!(expires_at: new_event_expiration_date)
false
else
... | [
"def",
"store_payload!",
"(",
"old_events",
",",
"result",
")",
"case",
"interpolated",
"[",
"'mode'",
"]",
".",
"presence",
"when",
"'on_change'",
"result_json",
"=",
"result",
".",
"to_json",
"if",
"found",
"=",
"old_events",
".",
"find",
"{",
"|",
"event"... | This method returns true if the result should be stored as a new event.
If mode is set to 'on_change', this method may return false and update an existing
event to expire further in the future. | [
"This",
"method",
"returns",
"true",
"if",
"the",
"result",
"should",
"be",
"stored",
"as",
"a",
"new",
"event",
".",
"If",
"mode",
"is",
"set",
"to",
"on_change",
"this",
"method",
"may",
"return",
"false",
"and",
"update",
"an",
"existing",
"event",
"t... | 01e18fef7b6bd827a5d48a89391e460b5fb1bee3 | https://github.com/huginn/huginn/blob/01e18fef7b6bd827a5d48a89391e460b5fb1bee3/app/models/agents/website_agent.rb#L507-L522 |
10,629 | hashicorp/vagrant | lib/vagrant/batch_action.rb | Vagrant.BatchAction.run | def run
par = false
if @allow_parallel
par = true
@logger.info("Enabling parallelization by default.")
end
if par
@actions.each do |machine, _, _|
if !machine.provider_options[:parallel]
@logger.info("Disabling parallelization because provider does... | ruby | def run
par = false
if @allow_parallel
par = true
@logger.info("Enabling parallelization by default.")
end
if par
@actions.each do |machine, _, _|
if !machine.provider_options[:parallel]
@logger.info("Disabling parallelization because provider does... | [
"def",
"run",
"par",
"=",
"false",
"if",
"@allow_parallel",
"par",
"=",
"true",
"@logger",
".",
"info",
"(",
"\"Enabling parallelization by default.\"",
")",
"end",
"if",
"par",
"@actions",
".",
"each",
"do",
"|",
"machine",
",",
"_",
",",
"_",
"|",
"if",
... | Run all the queued up actions, parallelizing if possible.
This will parallelize if and only if the provider of every machine
supports parallelization and parallelization is possible from
initialization of the class. | [
"Run",
"all",
"the",
"queued",
"up",
"actions",
"parallelizing",
"if",
"possible",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/batch_action.rb#L39-L163 |
10,630 | hashicorp/vagrant | lib/vagrant/registry.rb | Vagrant.Registry.get | def get(key)
return nil if !@items.key?(key)
return @results_cache[key] if @results_cache.key?(key)
@results_cache[key] = @items[key].call
end | ruby | def get(key)
return nil if !@items.key?(key)
return @results_cache[key] if @results_cache.key?(key)
@results_cache[key] = @items[key].call
end | [
"def",
"get",
"(",
"key",
")",
"return",
"nil",
"if",
"!",
"@items",
".",
"key?",
"(",
"key",
")",
"return",
"@results_cache",
"[",
"key",
"]",
"if",
"@results_cache",
".",
"key?",
"(",
"key",
")",
"@results_cache",
"[",
"key",
"]",
"=",
"@items",
"[... | Get a value by the given key.
This will evaluate the block given to `register` and return the
resulting value. | [
"Get",
"a",
"value",
"by",
"the",
"given",
"key",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/registry.rb#L24-L28 |
10,631 | hashicorp/vagrant | lib/vagrant/registry.rb | Vagrant.Registry.merge | def merge(other)
self.class.new.tap do |result|
result.merge!(self)
result.merge!(other)
end
end | ruby | def merge(other)
self.class.new.tap do |result|
result.merge!(self)
result.merge!(other)
end
end | [
"def",
"merge",
"(",
"other",
")",
"self",
".",
"class",
".",
"new",
".",
"tap",
"do",
"|",
"result",
"|",
"result",
".",
"merge!",
"(",
"self",
")",
"result",
".",
"merge!",
"(",
"other",
")",
"end",
"end"
] | Merge one registry with another and return a completely new
registry. Note that the result cache is completely busted, so
any gets on the new registry will result in a cache miss. | [
"Merge",
"one",
"registry",
"with",
"another",
"and",
"return",
"a",
"completely",
"new",
"registry",
".",
"Note",
"that",
"the",
"result",
"cache",
"is",
"completely",
"busted",
"so",
"any",
"gets",
"on",
"the",
"new",
"registry",
"will",
"result",
"in",
... | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/registry.rb#L71-L76 |
10,632 | hashicorp/vagrant | lib/vagrant/bundler.rb | Vagrant.Bundler.init! | def init!(plugins, repair=false)
if !@initial_specifications
@initial_specifications = Gem::Specification.find_all{true}
else
Gem::Specification.all = @initial_specifications
Gem::Specification.reset
end
# Add HashiCorp RubyGems source
if !Gem.sources.include?(HASH... | ruby | def init!(plugins, repair=false)
if !@initial_specifications
@initial_specifications = Gem::Specification.find_all{true}
else
Gem::Specification.all = @initial_specifications
Gem::Specification.reset
end
# Add HashiCorp RubyGems source
if !Gem.sources.include?(HASH... | [
"def",
"init!",
"(",
"plugins",
",",
"repair",
"=",
"false",
")",
"if",
"!",
"@initial_specifications",
"@initial_specifications",
"=",
"Gem",
"::",
"Specification",
".",
"find_all",
"{",
"true",
"}",
"else",
"Gem",
"::",
"Specification",
".",
"all",
"=",
"@... | Initializes Bundler and the various gem paths so that we can begin
loading gems. | [
"Initializes",
"Bundler",
"and",
"the",
"various",
"gem",
"paths",
"so",
"that",
"we",
"can",
"begin",
"loading",
"gems",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/bundler.rb#L55-L120 |
10,633 | hashicorp/vagrant | lib/vagrant/bundler.rb | Vagrant.Bundler.update | def update(plugins, specific, **opts)
specific ||= []
update = opts.merge({gems: specific.empty? ? true : specific})
internal_install(plugins, update)
end | ruby | def update(plugins, specific, **opts)
specific ||= []
update = opts.merge({gems: specific.empty? ? true : specific})
internal_install(plugins, update)
end | [
"def",
"update",
"(",
"plugins",
",",
"specific",
",",
"**",
"opts",
")",
"specific",
"||=",
"[",
"]",
"update",
"=",
"opts",
".",
"merge",
"(",
"{",
"gems",
":",
"specific",
".",
"empty?",
"?",
"true",
":",
"specific",
"}",
")",
"internal_install",
... | Update updates the given plugins, or every plugin if none is given.
@param [Hash] plugins
@param [Array<String>] specific Specific plugin names to update. If
empty or nil, all plugins will be updated. | [
"Update",
"updates",
"the",
"given",
"plugins",
"or",
"every",
"plugin",
"if",
"none",
"is",
"given",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/bundler.rb#L159-L163 |
10,634 | hashicorp/vagrant | lib/vagrant/bundler.rb | Vagrant.Bundler.clean | def clean(plugins, **opts)
@logger.debug("Cleaning Vagrant plugins of stale gems.")
# Generate dependencies for all registered plugins
plugin_deps = plugins.map do |name, info|
gem_version = info['installed_gem_version']
gem_version = info['gem_version'] if gem_version.to_s.empty?
... | ruby | def clean(plugins, **opts)
@logger.debug("Cleaning Vagrant plugins of stale gems.")
# Generate dependencies for all registered plugins
plugin_deps = plugins.map do |name, info|
gem_version = info['installed_gem_version']
gem_version = info['gem_version'] if gem_version.to_s.empty?
... | [
"def",
"clean",
"(",
"plugins",
",",
"**",
"opts",
")",
"@logger",
".",
"debug",
"(",
"\"Cleaning Vagrant plugins of stale gems.\"",
")",
"# Generate dependencies for all registered plugins",
"plugin_deps",
"=",
"plugins",
".",
"map",
"do",
"|",
"name",
",",
"info",
... | Clean removes any unused gems. | [
"Clean",
"removes",
"any",
"unused",
"gems",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/bundler.rb#L166-L247 |
10,635 | hashicorp/vagrant | lib/vagrant/bundler.rb | Vagrant.Bundler.validate_configured_sources! | def validate_configured_sources!
Gem.sources.each_source do |src|
begin
src.load_specs(:released)
rescue Gem::Exception => source_error
if ENV["VAGRANT_ALLOW_PLUGIN_SOURCE_ERRORS"]
@logger.warn("Failed to load configured plugin source: #{src}!")
@logger.... | ruby | def validate_configured_sources!
Gem.sources.each_source do |src|
begin
src.load_specs(:released)
rescue Gem::Exception => source_error
if ENV["VAGRANT_ALLOW_PLUGIN_SOURCE_ERRORS"]
@logger.warn("Failed to load configured plugin source: #{src}!")
@logger.... | [
"def",
"validate_configured_sources!",
"Gem",
".",
"sources",
".",
"each_source",
"do",
"|",
"src",
"|",
"begin",
"src",
".",
"load_specs",
"(",
":released",
")",
"rescue",
"Gem",
"::",
"Exception",
"=>",
"source_error",
"if",
"ENV",
"[",
"\"VAGRANT_ALLOW_PLUGIN... | Iterates each configured RubyGem source to validate that it is properly
available. If source is unavailable an exception is raised. | [
"Iterates",
"each",
"configured",
"RubyGem",
"source",
"to",
"validate",
"that",
"it",
"is",
"properly",
"available",
".",
"If",
"source",
"is",
"unavailable",
"an",
"exception",
"is",
"raised",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/bundler.rb#L426-L443 |
10,636 | hashicorp/vagrant | lib/vagrant/bundler.rb | Vagrant.Bundler.generate_builtin_set | def generate_builtin_set(system_plugins=[])
builtin_set = BuiltinSet.new
@logger.debug("Generating new builtin set instance.")
vagrant_internal_specs.each do |spec|
if !system_plugins.include?(spec.name)
builtin_set.add_builtin_spec(spec)
end
end
builtin_set
e... | ruby | def generate_builtin_set(system_plugins=[])
builtin_set = BuiltinSet.new
@logger.debug("Generating new builtin set instance.")
vagrant_internal_specs.each do |spec|
if !system_plugins.include?(spec.name)
builtin_set.add_builtin_spec(spec)
end
end
builtin_set
e... | [
"def",
"generate_builtin_set",
"(",
"system_plugins",
"=",
"[",
"]",
")",
"builtin_set",
"=",
"BuiltinSet",
".",
"new",
"@logger",
".",
"debug",
"(",
"\"Generating new builtin set instance.\"",
")",
"vagrant_internal_specs",
".",
"each",
"do",
"|",
"spec",
"|",
"i... | Generate the builtin resolver set | [
"Generate",
"the",
"builtin",
"resolver",
"set"
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/bundler.rb#L446-L455 |
10,637 | hashicorp/vagrant | lib/vagrant/bundler.rb | Vagrant.Bundler.activate_solution | def activate_solution(solution)
retried = false
begin
@logger.debug("Activating solution set: #{solution.map(&:full_name)}")
solution.each do |activation_request|
unless activation_request.full_spec.activated?
@logger.debug("Activating gem #{activation_request.full_spec... | ruby | def activate_solution(solution)
retried = false
begin
@logger.debug("Activating solution set: #{solution.map(&:full_name)}")
solution.each do |activation_request|
unless activation_request.full_spec.activated?
@logger.debug("Activating gem #{activation_request.full_spec... | [
"def",
"activate_solution",
"(",
"solution",
")",
"retried",
"=",
"false",
"begin",
"@logger",
".",
"debug",
"(",
"\"Activating solution set: #{solution.map(&:full_name)}\"",
")",
"solution",
".",
"each",
"do",
"|",
"activation_request",
"|",
"unless",
"activation_reque... | Activate a given solution | [
"Activate",
"a",
"given",
"solution"
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/bundler.rb#L483-L526 |
10,638 | hashicorp/vagrant | lib/vagrant/machine_index.rb | Vagrant.MachineIndex.delete | def delete(entry)
return true if !entry.id
@lock.synchronize do
with_index_lock do
return true if !@machines[entry.id]
# If we don't have the lock, then we need to acquire it.
if !@machine_locks[entry.id]
raise "Unlocked delete on machine: #{entry.id}"
... | ruby | def delete(entry)
return true if !entry.id
@lock.synchronize do
with_index_lock do
return true if !@machines[entry.id]
# If we don't have the lock, then we need to acquire it.
if !@machine_locks[entry.id]
raise "Unlocked delete on machine: #{entry.id}"
... | [
"def",
"delete",
"(",
"entry",
")",
"return",
"true",
"if",
"!",
"entry",
".",
"id",
"@lock",
".",
"synchronize",
"do",
"with_index_lock",
"do",
"return",
"true",
"if",
"!",
"@machines",
"[",
"entry",
".",
"id",
"]",
"# If we don't have the lock, then we need ... | Initializes a MachineIndex at the given file location.
@param [Pathname] data_dir Path to the directory where data for the
index can be stored. This folder should exist and must be writable.
Deletes a machine by UUID.
The machine being deleted with this UUID must either be locked
by this index or must be unloc... | [
"Initializes",
"a",
"MachineIndex",
"at",
"the",
"given",
"file",
"location",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/machine_index.rb#L64-L87 |
10,639 | hashicorp/vagrant | lib/vagrant/machine_index.rb | Vagrant.MachineIndex.find_by_prefix | def find_by_prefix(prefix)
@machines.each do |uuid, data|
return data.merge("id" => uuid) if uuid.start_with?(prefix)
end
nil
end | ruby | def find_by_prefix(prefix)
@machines.each do |uuid, data|
return data.merge("id" => uuid) if uuid.start_with?(prefix)
end
nil
end | [
"def",
"find_by_prefix",
"(",
"prefix",
")",
"@machines",
".",
"each",
"do",
"|",
"uuid",
",",
"data",
"|",
"return",
"data",
".",
"merge",
"(",
"\"id\"",
"=>",
"uuid",
")",
"if",
"uuid",
".",
"start_with?",
"(",
"prefix",
")",
"end",
"nil",
"end"
] | Finds a machine where the UUID is prefixed by the given string.
@return [Hash] | [
"Finds",
"a",
"machine",
"where",
"the",
"UUID",
"is",
"prefixed",
"by",
"the",
"given",
"string",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/machine_index.rb#L239-L245 |
10,640 | hashicorp/vagrant | lib/vagrant/machine_index.rb | Vagrant.MachineIndex.lock_machine | def lock_machine(uuid)
lock_path = @data_dir.join("#{uuid}.lock")
lock_file = lock_path.open("w+")
if lock_file.flock(File::LOCK_EX | File::LOCK_NB) === false
lock_file.close
lock_file = nil
end
lock_file
end | ruby | def lock_machine(uuid)
lock_path = @data_dir.join("#{uuid}.lock")
lock_file = lock_path.open("w+")
if lock_file.flock(File::LOCK_EX | File::LOCK_NB) === false
lock_file.close
lock_file = nil
end
lock_file
end | [
"def",
"lock_machine",
"(",
"uuid",
")",
"lock_path",
"=",
"@data_dir",
".",
"join",
"(",
"\"#{uuid}.lock\"",
")",
"lock_file",
"=",
"lock_path",
".",
"open",
"(",
"\"w+\"",
")",
"if",
"lock_file",
".",
"flock",
"(",
"File",
"::",
"LOCK_EX",
"|",
"File",
... | Locks a machine exclusively to us, returning the file handle
that holds the lock.
If the lock cannot be acquired, then nil is returned.
This should be called within an index lock.
@return [File] | [
"Locks",
"a",
"machine",
"exclusively",
"to",
"us",
"returning",
"the",
"file",
"handle",
"that",
"holds",
"the",
"lock",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/machine_index.rb#L255-L264 |
10,641 | hashicorp/vagrant | lib/vagrant/machine_index.rb | Vagrant.MachineIndex.unlocked_release | def unlocked_release(id)
lock_file = @machine_locks[id]
if lock_file
lock_file.close
begin
File.delete(lock_file.path)
rescue Errno::EACCES
# Another process is probably opened it, no problem.
end
@machine_locks.delete(id)
end
end | ruby | def unlocked_release(id)
lock_file = @machine_locks[id]
if lock_file
lock_file.close
begin
File.delete(lock_file.path)
rescue Errno::EACCES
# Another process is probably opened it, no problem.
end
@machine_locks.delete(id)
end
end | [
"def",
"unlocked_release",
"(",
"id",
")",
"lock_file",
"=",
"@machine_locks",
"[",
"id",
"]",
"if",
"lock_file",
"lock_file",
".",
"close",
"begin",
"File",
".",
"delete",
"(",
"lock_file",
".",
"path",
")",
"rescue",
"Errno",
"::",
"EACCES",
"# Another pro... | Releases a local lock on a machine. This does not acquire any locks
so make sure to lock around it.
@param [String] id | [
"Releases",
"a",
"local",
"lock",
"on",
"a",
"machine",
".",
"This",
"does",
"not",
"acquire",
"any",
"locks",
"so",
"make",
"sure",
"to",
"lock",
"around",
"it",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/machine_index.rb#L270-L282 |
10,642 | hashicorp/vagrant | lib/vagrant/machine_index.rb | Vagrant.MachineIndex.unlocked_reload | def unlocked_reload
return if !@index_file.file?
data = nil
begin
data = JSON.load(@index_file.read)
rescue JSON::ParserError
raise Errors::CorruptMachineIndex, path: @index_file.to_s
end
if data
if !data["version"] || data["version"].to_i != 1
rai... | ruby | def unlocked_reload
return if !@index_file.file?
data = nil
begin
data = JSON.load(@index_file.read)
rescue JSON::ParserError
raise Errors::CorruptMachineIndex, path: @index_file.to_s
end
if data
if !data["version"] || data["version"].to_i != 1
rai... | [
"def",
"unlocked_reload",
"return",
"if",
"!",
"@index_file",
".",
"file?",
"data",
"=",
"nil",
"begin",
"data",
"=",
"JSON",
".",
"load",
"(",
"@index_file",
".",
"read",
")",
"rescue",
"JSON",
"::",
"ParserError",
"raise",
"Errors",
"::",
"CorruptMachineIn... | This will reload the data without locking the index. It is assumed
the caller with lock the index outside of this call.
@param [File] f | [
"This",
"will",
"reload",
"the",
"data",
"without",
"locking",
"the",
"index",
".",
"It",
"is",
"assumed",
"the",
"caller",
"with",
"lock",
"the",
"index",
"outside",
"of",
"this",
"call",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/machine_index.rb#L288-L305 |
10,643 | hashicorp/vagrant | lib/vagrant/machine_index.rb | Vagrant.MachineIndex.with_index_lock | def with_index_lock
lock_path = "#{@index_file}.lock"
File.open(lock_path, "w+") do |f|
f.flock(File::LOCK_EX)
yield
end
end | ruby | def with_index_lock
lock_path = "#{@index_file}.lock"
File.open(lock_path, "w+") do |f|
f.flock(File::LOCK_EX)
yield
end
end | [
"def",
"with_index_lock",
"lock_path",
"=",
"\"#{@index_file}.lock\"",
"File",
".",
"open",
"(",
"lock_path",
",",
"\"w+\"",
")",
"do",
"|",
"f",
"|",
"f",
".",
"flock",
"(",
"File",
"::",
"LOCK_EX",
")",
"yield",
"end",
"end"
] | This will hold a lock to the index so it can be read or updated. | [
"This",
"will",
"hold",
"a",
"lock",
"to",
"the",
"index",
"so",
"it",
"can",
"be",
"read",
"or",
"updated",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/machine_index.rb#L319-L325 |
10,644 | hashicorp/vagrant | lib/vagrant/box_metadata.rb | Vagrant.BoxMetadata.version | def version(version, **opts)
requirements = version.split(",").map do |v|
Gem::Requirement.new(v.strip)
end
providers = nil
providers = Array(opts[:provider]).map(&:to_sym) if opts[:provider]
@version_map.keys.sort.reverse.each do |v|
next if !requirements.all? { |r| r.sa... | ruby | def version(version, **opts)
requirements = version.split(",").map do |v|
Gem::Requirement.new(v.strip)
end
providers = nil
providers = Array(opts[:provider]).map(&:to_sym) if opts[:provider]
@version_map.keys.sort.reverse.each do |v|
next if !requirements.all? { |r| r.sa... | [
"def",
"version",
"(",
"version",
",",
"**",
"opts",
")",
"requirements",
"=",
"version",
".",
"split",
"(",
"\",\"",
")",
".",
"map",
"do",
"|",
"v",
"|",
"Gem",
"::",
"Requirement",
".",
"new",
"(",
"v",
".",
"strip",
")",
"end",
"providers",
"="... | Loads the metadata associated with the box from the given
IO.
@param [IO] io An IO object to read the metadata from.
Returns data about a single version that is included in this
metadata.
@param [String] version The version to return, this can also
be a constraint.
@return [Version] The matching version or n... | [
"Loads",
"the",
"metadata",
"associated",
"with",
"the",
"box",
"from",
"the",
"given",
"IO",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/box_metadata.rb#L51-L67 |
10,645 | hashicorp/vagrant | lib/vagrant/cli.rb | Vagrant.CLI.help | def help
# We use the optionparser for this. Its just easier. We don't use
# an optionparser above because I don't think the performance hits
# of creating a whole object are worth checking only a couple flags.
opts = OptionParser.new do |o|
o.banner = "Usage: vagrant [options] <command>... | ruby | def help
# We use the optionparser for this. Its just easier. We don't use
# an optionparser above because I don't think the performance hits
# of creating a whole object are worth checking only a couple flags.
opts = OptionParser.new do |o|
o.banner = "Usage: vagrant [options] <command>... | [
"def",
"help",
"# We use the optionparser for this. Its just easier. We don't use",
"# an optionparser above because I don't think the performance hits",
"# of creating a whole object are worth checking only a couple flags.",
"opts",
"=",
"OptionParser",
".",
"new",
"do",
"|",
"o",
"|",
... | This prints out the help for the CLI. | [
"This",
"prints",
"out",
"the",
"help",
"for",
"the",
"CLI",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/cli.rb#L78-L119 |
10,646 | hashicorp/vagrant | lib/vagrant/environment.rb | Vagrant.Environment.action_runner | def action_runner
@action_runner ||= Action::Runner.new do
{
action_runner: action_runner,
box_collection: boxes,
hook: method(:hook),
host: host,
machine_index: machine_index,
gems_path: gems_path,
home_path:... | ruby | def action_runner
@action_runner ||= Action::Runner.new do
{
action_runner: action_runner,
box_collection: boxes,
hook: method(:hook),
host: host,
machine_index: machine_index,
gems_path: gems_path,
home_path:... | [
"def",
"action_runner",
"@action_runner",
"||=",
"Action",
"::",
"Runner",
".",
"new",
"do",
"{",
"action_runner",
":",
"action_runner",
",",
"box_collection",
":",
"boxes",
",",
"hook",
":",
"method",
"(",
":hook",
")",
",",
"host",
":",
"host",
",",
"mac... | Action runner for executing actions in the context of this environment.
@return [Action::Runner] | [
"Action",
"runner",
"for",
"executing",
"actions",
"in",
"the",
"context",
"of",
"this",
"environment",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/environment.rb#L201-L217 |
10,647 | hashicorp/vagrant | lib/vagrant/environment.rb | Vagrant.Environment.active_machines | def active_machines
# We have no active machines if we have no data path
return [] if !@local_data_path
machine_folder = @local_data_path.join("machines")
# If the machine folder is not a directory then we just return
# an empty array since no active machines exist.
return [] if !m... | ruby | def active_machines
# We have no active machines if we have no data path
return [] if !@local_data_path
machine_folder = @local_data_path.join("machines")
# If the machine folder is not a directory then we just return
# an empty array since no active machines exist.
return [] if !m... | [
"def",
"active_machines",
"# We have no active machines if we have no data path",
"return",
"[",
"]",
"if",
"!",
"@local_data_path",
"machine_folder",
"=",
"@local_data_path",
".",
"join",
"(",
"\"machines\"",
")",
"# If the machine folder is not a directory then we just return",
... | Returns a list of machines that this environment is currently
managing that physically have been created.
An "active" machine is a machine that Vagrant manages that has
been created. The machine itself may be in any state such as running,
suspended, etc. but if a machine is "active" then it exists.
Note that the... | [
"Returns",
"a",
"list",
"of",
"machines",
"that",
"this",
"environment",
"is",
"currently",
"managing",
"that",
"physically",
"have",
"been",
"created",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/environment.rb#L233-L265 |
10,648 | hashicorp/vagrant | lib/vagrant/environment.rb | Vagrant.Environment.batch | def batch(parallel=true)
parallel = false if ENV["VAGRANT_NO_PARALLEL"]
@batch_lock.synchronize do
BatchAction.new(parallel).tap do |b|
# Yield it so that the caller can setup actions
yield b
# And run it!
b.run
end
end
end | ruby | def batch(parallel=true)
parallel = false if ENV["VAGRANT_NO_PARALLEL"]
@batch_lock.synchronize do
BatchAction.new(parallel).tap do |b|
# Yield it so that the caller can setup actions
yield b
# And run it!
b.run
end
end
end | [
"def",
"batch",
"(",
"parallel",
"=",
"true",
")",
"parallel",
"=",
"false",
"if",
"ENV",
"[",
"\"VAGRANT_NO_PARALLEL\"",
"]",
"@batch_lock",
".",
"synchronize",
"do",
"BatchAction",
".",
"new",
"(",
"parallel",
")",
".",
"tap",
"do",
"|",
"b",
"|",
"# Y... | This creates a new batch action, yielding it, and then running it
once the block is called.
This handles the case where batch actions are disabled by the
VAGRANT_NO_PARALLEL environmental variable. | [
"This",
"creates",
"a",
"new",
"batch",
"action",
"yielding",
"it",
"and",
"then",
"running",
"it",
"once",
"the",
"block",
"is",
"called",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/environment.rb#L272-L284 |
10,649 | hashicorp/vagrant | lib/vagrant/environment.rb | Vagrant.Environment.hook | def hook(name, opts=nil)
@logger.info("Running hook: #{name}")
opts ||= {}
opts[:callable] ||= Action::Builder.new
opts[:runner] ||= action_runner
opts[:action_name] = name
opts[:env] = self
opts.delete(:runner).run(opts.delete(:callable), opts)
end | ruby | def hook(name, opts=nil)
@logger.info("Running hook: #{name}")
opts ||= {}
opts[:callable] ||= Action::Builder.new
opts[:runner] ||= action_runner
opts[:action_name] = name
opts[:env] = self
opts.delete(:runner).run(opts.delete(:callable), opts)
end | [
"def",
"hook",
"(",
"name",
",",
"opts",
"=",
"nil",
")",
"@logger",
".",
"info",
"(",
"\"Running hook: #{name}\"",
")",
"opts",
"||=",
"{",
"}",
"opts",
"[",
":callable",
"]",
"||=",
"Action",
"::",
"Builder",
".",
"new",
"opts",
"[",
":runner",
"]",
... | This defines a hook point where plugin action hooks that are registered
against the given name will be run in the context of this environment.
@param [Symbol] name Name of the hook.
@param [Action::Runner] action_runner A custom action runner for running hooks. | [
"This",
"defines",
"a",
"hook",
"point",
"where",
"plugin",
"action",
"hooks",
"that",
"are",
"registered",
"against",
"the",
"given",
"name",
"will",
"be",
"run",
"in",
"the",
"context",
"of",
"this",
"environment",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/environment.rb#L520-L528 |
10,650 | hashicorp/vagrant | lib/vagrant/environment.rb | Vagrant.Environment.host | def host
return @host if defined?(@host)
# Determine the host class to use. ":detect" is an old Vagrant config
# that shouldn't be valid anymore, but we respect it here by assuming
# its old behavior. No need to deprecate this because I thin it is
# fairly harmless.
host_klass = vag... | ruby | def host
return @host if defined?(@host)
# Determine the host class to use. ":detect" is an old Vagrant config
# that shouldn't be valid anymore, but we respect it here by assuming
# its old behavior. No need to deprecate this because I thin it is
# fairly harmless.
host_klass = vag... | [
"def",
"host",
"return",
"@host",
"if",
"defined?",
"(",
"@host",
")",
"# Determine the host class to use. \":detect\" is an old Vagrant config",
"# that shouldn't be valid anymore, but we respect it here by assuming",
"# its old behavior. No need to deprecate this because I thin it is",
"# ... | Returns the host object associated with this environment.
@return [Class] | [
"Returns",
"the",
"host",
"object",
"associated",
"with",
"this",
"environment",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/environment.rb#L533-L564 |
10,651 | hashicorp/vagrant | lib/vagrant/environment.rb | Vagrant.Environment.lock | def lock(name="global", **opts)
f = nil
# If we don't have a block, then locking is useless, so ignore it
return if !block_given?
# This allows multiple locks in the same process to be nested
return yield if @locks[name] || opts[:noop]
# The path to this lock
lock_path = dat... | ruby | def lock(name="global", **opts)
f = nil
# If we don't have a block, then locking is useless, so ignore it
return if !block_given?
# This allows multiple locks in the same process to be nested
return yield if @locks[name] || opts[:noop]
# The path to this lock
lock_path = dat... | [
"def",
"lock",
"(",
"name",
"=",
"\"global\"",
",",
"**",
"opts",
")",
"f",
"=",
"nil",
"# If we don't have a block, then locking is useless, so ignore it",
"return",
"if",
"!",
"block_given?",
"# This allows multiple locks in the same process to be nested",
"return",
"yield"... | This acquires a process-level lock with the given name.
The lock file is held within the data directory of this environment,
so make sure that all environments that are locking are sharing
the same data directory.
This will raise Errors::EnvironmentLockedError if the lock can't
be obtained.
@param [String] nam... | [
"This",
"acquires",
"a",
"process",
"-",
"level",
"lock",
"with",
"the",
"given",
"name",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/environment.rb#L577-L645 |
10,652 | hashicorp/vagrant | lib/vagrant/environment.rb | Vagrant.Environment.push | def push(name)
@logger.info("Getting push: #{name}")
name = name.to_sym
pushes = self.vagrantfile.config.push.__compiled_pushes
if !pushes.key?(name)
raise Vagrant::Errors::PushStrategyNotDefined,
name: name,
pushes: pushes.keys
end
strategy, config = p... | ruby | def push(name)
@logger.info("Getting push: #{name}")
name = name.to_sym
pushes = self.vagrantfile.config.push.__compiled_pushes
if !pushes.key?(name)
raise Vagrant::Errors::PushStrategyNotDefined,
name: name,
pushes: pushes.keys
end
strategy, config = p... | [
"def",
"push",
"(",
"name",
")",
"@logger",
".",
"info",
"(",
"\"Getting push: #{name}\"",
")",
"name",
"=",
"name",
".",
"to_sym",
"pushes",
"=",
"self",
".",
"vagrantfile",
".",
"config",
".",
"push",
".",
"__compiled_pushes",
"if",
"!",
"pushes",
".",
... | This executes the push with the given name, raising any exceptions that
occur.
Precondition: the push is not nil and exists. | [
"This",
"executes",
"the",
"push",
"with",
"the",
"given",
"name",
"raising",
"any",
"exceptions",
"that",
"occur",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/environment.rb#L651-L673 |
10,653 | hashicorp/vagrant | lib/vagrant/environment.rb | Vagrant.Environment.machine | def machine(name, provider, refresh=false)
@logger.info("Getting machine: #{name} (#{provider})")
# Compose the cache key of the name and provider, and return from
# the cache if we have that.
cache_key = [name, provider]
@machines ||= {}
if refresh
@logger.info("Refreshing ... | ruby | def machine(name, provider, refresh=false)
@logger.info("Getting machine: #{name} (#{provider})")
# Compose the cache key of the name and provider, and return from
# the cache if we have that.
cache_key = [name, provider]
@machines ||= {}
if refresh
@logger.info("Refreshing ... | [
"def",
"machine",
"(",
"name",
",",
"provider",
",",
"refresh",
"=",
"false",
")",
"@logger",
".",
"info",
"(",
"\"Getting machine: #{name} (#{provider})\"",
")",
"# Compose the cache key of the name and provider, and return from",
"# the cache if we have that.",
"cache_key",
... | This returns a machine with the proper provider for this environment.
The machine named by `name` must be in this environment.
@param [Symbol] name Name of the machine (as configured in the
Vagrantfile).
@param [Symbol] provider The provider that this machine should be
backed by.
@param [Boolean] refresh If ... | [
"This",
"returns",
"a",
"machine",
"with",
"the",
"proper",
"provider",
"for",
"this",
"environment",
".",
"The",
"machine",
"named",
"by",
"name",
"must",
"be",
"in",
"this",
"environment",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/environment.rb#L692-L719 |
10,654 | hashicorp/vagrant | lib/vagrant/environment.rb | Vagrant.Environment.setup_local_data_path | def setup_local_data_path(force=false)
if @local_data_path.nil?
@logger.warn("No local data path is set. Local data cannot be stored.")
return
end
@logger.info("Local data path: #{@local_data_path}")
# If the local data path is a file, then we are probably seeing an
# old... | ruby | def setup_local_data_path(force=false)
if @local_data_path.nil?
@logger.warn("No local data path is set. Local data cannot be stored.")
return
end
@logger.info("Local data path: #{@local_data_path}")
# If the local data path is a file, then we are probably seeing an
# old... | [
"def",
"setup_local_data_path",
"(",
"force",
"=",
"false",
")",
"if",
"@local_data_path",
".",
"nil?",
"@logger",
".",
"warn",
"(",
"\"No local data path is set. Local data cannot be stored.\"",
")",
"return",
"end",
"@logger",
".",
"info",
"(",
"\"Local data path: #{@... | This creates the local data directory and show an error if it
couldn't properly be created. | [
"This",
"creates",
"the",
"local",
"data",
"directory",
"and",
"show",
"an",
"error",
"if",
"it",
"couldn",
"t",
"properly",
"be",
"created",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/environment.rb#L889-L921 |
10,655 | hashicorp/vagrant | lib/vagrant/environment.rb | Vagrant.Environment.process_configured_plugins | def process_configured_plugins
return if !Vagrant.plugins_enabled?
errors = vagrantfile.config.vagrant.validate(nil)
if !errors["vagrant"].empty?
raise Errors::ConfigInvalid,
errors: Util::TemplateRenderer.render(
"config/validation_failed",
errors: errors)
... | ruby | def process_configured_plugins
return if !Vagrant.plugins_enabled?
errors = vagrantfile.config.vagrant.validate(nil)
if !errors["vagrant"].empty?
raise Errors::ConfigInvalid,
errors: Util::TemplateRenderer.render(
"config/validation_failed",
errors: errors)
... | [
"def",
"process_configured_plugins",
"return",
"if",
"!",
"Vagrant",
".",
"plugins_enabled?",
"errors",
"=",
"vagrantfile",
".",
"config",
".",
"vagrant",
".",
"validate",
"(",
"nil",
")",
"if",
"!",
"errors",
"[",
"\"vagrant\"",
"]",
".",
"empty?",
"raise",
... | Check for any local plugins defined within the Vagrantfile. If
found, validate they are available. If they are not available,
request to install them, or raise an exception
@return [Hash] plugin list for loading | [
"Check",
"for",
"any",
"local",
"plugins",
"defined",
"within",
"the",
"Vagrantfile",
".",
"If",
"found",
"validate",
"they",
"are",
"available",
".",
"If",
"they",
"are",
"not",
"available",
"request",
"to",
"install",
"them",
"or",
"raise",
"an",
"exceptio... | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/environment.rb#L930-L984 |
10,656 | hashicorp/vagrant | lib/vagrant/environment.rb | Vagrant.Environment.copy_insecure_private_key | def copy_insecure_private_key
if !@default_private_key_path.exist?
@logger.info("Copying private key to home directory")
source = File.expand_path("keys/vagrant", Vagrant.source_root)
destination = @default_private_key_path
begin
FileUtils.cp(source, destination)
... | ruby | def copy_insecure_private_key
if !@default_private_key_path.exist?
@logger.info("Copying private key to home directory")
source = File.expand_path("keys/vagrant", Vagrant.source_root)
destination = @default_private_key_path
begin
FileUtils.cp(source, destination)
... | [
"def",
"copy_insecure_private_key",
"if",
"!",
"@default_private_key_path",
".",
"exist?",
"@logger",
".",
"info",
"(",
"\"Copying private key to home directory\"",
")",
"source",
"=",
"File",
".",
"expand_path",
"(",
"\"keys/vagrant\"",
",",
"Vagrant",
".",
"source_roo... | This method copies the private key into the home directory if it
doesn't already exist.
This must be done because `ssh` requires that the key is chmod
0600, but if Vagrant is installed as a separate user, then the
effective uid won't be able to read the key. So the key is copied
to the home directory and chmod 06... | [
"This",
"method",
"copies",
"the",
"private",
"key",
"into",
"the",
"home",
"directory",
"if",
"it",
"doesn",
"t",
"already",
"exist",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/environment.rb#L993-L1017 |
10,657 | hashicorp/vagrant | lib/vagrant/environment.rb | Vagrant.Environment.find_vagrantfile | def find_vagrantfile(search_path, filenames=nil)
filenames ||= ["Vagrantfile", "vagrantfile"]
filenames.each do |vagrantfile|
current_path = search_path.join(vagrantfile)
return current_path if current_path.file?
end
nil
end | ruby | def find_vagrantfile(search_path, filenames=nil)
filenames ||= ["Vagrantfile", "vagrantfile"]
filenames.each do |vagrantfile|
current_path = search_path.join(vagrantfile)
return current_path if current_path.file?
end
nil
end | [
"def",
"find_vagrantfile",
"(",
"search_path",
",",
"filenames",
"=",
"nil",
")",
"filenames",
"||=",
"[",
"\"Vagrantfile\"",
",",
"\"vagrantfile\"",
"]",
"filenames",
".",
"each",
"do",
"|",
"vagrantfile",
"|",
"current_path",
"=",
"search_path",
".",
"join",
... | Finds the Vagrantfile in the given directory.
@param [Pathname] path Path to search in.
@return [Pathname] | [
"Finds",
"the",
"Vagrantfile",
"in",
"the",
"given",
"directory",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/environment.rb#L1023-L1031 |
10,658 | hashicorp/vagrant | lib/vagrant/environment.rb | Vagrant.Environment.upgrade_home_path_v1_1 | def upgrade_home_path_v1_1
if !ENV["VAGRANT_UPGRADE_SILENT_1_5"]
@ui.ask(I18n.t("vagrant.upgrading_home_path_v1_5"))
end
collection = BoxCollection.new(
@home_path.join("boxes"), temp_dir_root: tmp_path)
collection.upgrade_v1_1_v1_5
end | ruby | def upgrade_home_path_v1_1
if !ENV["VAGRANT_UPGRADE_SILENT_1_5"]
@ui.ask(I18n.t("vagrant.upgrading_home_path_v1_5"))
end
collection = BoxCollection.new(
@home_path.join("boxes"), temp_dir_root: tmp_path)
collection.upgrade_v1_1_v1_5
end | [
"def",
"upgrade_home_path_v1_1",
"if",
"!",
"ENV",
"[",
"\"VAGRANT_UPGRADE_SILENT_1_5\"",
"]",
"@ui",
".",
"ask",
"(",
"I18n",
".",
"t",
"(",
"\"vagrant.upgrading_home_path_v1_5\"",
")",
")",
"end",
"collection",
"=",
"BoxCollection",
".",
"new",
"(",
"@home_path"... | This upgrades a home directory that was in the v1.1 format to the
v1.5 format. It will raise exceptions if anything fails. | [
"This",
"upgrades",
"a",
"home",
"directory",
"that",
"was",
"in",
"the",
"v1",
".",
"1",
"format",
"to",
"the",
"v1",
".",
"5",
"format",
".",
"It",
"will",
"raise",
"exceptions",
"if",
"anything",
"fails",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/environment.rb#L1041-L1049 |
10,659 | hashicorp/vagrant | lib/vagrant/environment.rb | Vagrant.Environment.upgrade_v1_dotfile | def upgrade_v1_dotfile(path)
@logger.info("Upgrading V1 dotfile to V2 directory structure...")
# First, verify the file isn't empty. If it is an empty file, we
# just delete it and go on with life.
contents = path.read.strip
if contents.strip == ""
@logger.info("V1 dotfile was emp... | ruby | def upgrade_v1_dotfile(path)
@logger.info("Upgrading V1 dotfile to V2 directory structure...")
# First, verify the file isn't empty. If it is an empty file, we
# just delete it and go on with life.
contents = path.read.strip
if contents.strip == ""
@logger.info("V1 dotfile was emp... | [
"def",
"upgrade_v1_dotfile",
"(",
"path",
")",
"@logger",
".",
"info",
"(",
"\"Upgrading V1 dotfile to V2 directory structure...\"",
")",
"# First, verify the file isn't empty. If it is an empty file, we",
"# just delete it and go on with life.",
"contents",
"=",
"path",
".",
"read... | This upgrades a Vagrant 1.0.x "dotfile" to the new V2 format.
This is a destructive process. Once the upgrade is complete, the
old dotfile is removed, and the environment becomes incompatible for
Vagrant 1.0 environments.
@param [Pathname] path The path to the dotfile | [
"This",
"upgrades",
"a",
"Vagrant",
"1",
".",
"0",
".",
"x",
"dotfile",
"to",
"the",
"new",
"V2",
"format",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/environment.rb#L1058-L1114 |
10,660 | hashicorp/vagrant | lib/vagrant/guest.rb | Vagrant.Guest.detect! | def detect!
guest_name = @machine.config.vm.guest
initialize_capabilities!(guest_name, @guests, @capabilities, @machine)
rescue Errors::CapabilityHostExplicitNotDetected => e
raise Errors::GuestExplicitNotDetected, value: e.extra_data[:value]
rescue Errors::CapabilityHostNotDetected
rais... | ruby | def detect!
guest_name = @machine.config.vm.guest
initialize_capabilities!(guest_name, @guests, @capabilities, @machine)
rescue Errors::CapabilityHostExplicitNotDetected => e
raise Errors::GuestExplicitNotDetected, value: e.extra_data[:value]
rescue Errors::CapabilityHostNotDetected
rais... | [
"def",
"detect!",
"guest_name",
"=",
"@machine",
".",
"config",
".",
"vm",
".",
"guest",
"initialize_capabilities!",
"(",
"guest_name",
",",
"@guests",
",",
"@capabilities",
",",
"@machine",
")",
"rescue",
"Errors",
"::",
"CapabilityHostExplicitNotDetected",
"=>",
... | This will detect the proper guest OS for the machine and set up
the class to actually execute capabilities. | [
"This",
"will",
"detect",
"the",
"proper",
"guest",
"OS",
"for",
"the",
"machine",
"and",
"set",
"up",
"the",
"class",
"to",
"actually",
"execute",
"capabilities",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/guest.rb#L32-L39 |
10,661 | hashicorp/vagrant | lib/vagrant/vagrantfile.rb | Vagrant.Vagrantfile.machine | def machine(name, provider, boxes, data_path, env)
# Load the configuration for the machine
results = machine_config(name, provider, boxes, data_path)
box = results[:box]
config = results[:config]
config_errors = results[:config_errors]
config_warnings = result... | ruby | def machine(name, provider, boxes, data_path, env)
# Load the configuration for the machine
results = machine_config(name, provider, boxes, data_path)
box = results[:box]
config = results[:config]
config_errors = results[:config_errors]
config_warnings = result... | [
"def",
"machine",
"(",
"name",
",",
"provider",
",",
"boxes",
",",
"data_path",
",",
"env",
")",
"# Load the configuration for the machine",
"results",
"=",
"machine_config",
"(",
"name",
",",
"provider",
",",
"boxes",
",",
"data_path",
")",
"box",
"=",
"resul... | Initializes by loading a Vagrantfile.
@param [Config::Loader] loader Configuration loader that should
already be configured with the proper Vagrantfile locations.
This usually comes from {Vagrant::Environment}
@param [Array<Symbol>] keys The Vagrantfiles to load and the
order to load them in (keys within th... | [
"Initializes",
"by",
"loading",
"a",
"Vagrantfile",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/vagrantfile.rb#L45-L83 |
10,662 | hashicorp/vagrant | lib/vagrant/vagrantfile.rb | Vagrant.Vagrantfile.machine_names_and_options | def machine_names_and_options
{}.tap do |r|
@config.vm.defined_vms.each do |name, subvm|
r[name] = subvm.options || {}
end
end
end | ruby | def machine_names_and_options
{}.tap do |r|
@config.vm.defined_vms.each do |name, subvm|
r[name] = subvm.options || {}
end
end
end | [
"def",
"machine_names_and_options",
"{",
"}",
".",
"tap",
"do",
"|",
"r",
"|",
"@config",
".",
"vm",
".",
"defined_vms",
".",
"each",
"do",
"|",
"name",
",",
"subvm",
"|",
"r",
"[",
"name",
"]",
"=",
"subvm",
".",
"options",
"||",
"{",
"}",
"end",
... | Returns a list of the machine names as well as the options that
were specified for that machine.
@return [Hash<Symbol, Hash>] | [
"Returns",
"a",
"list",
"of",
"the",
"machine",
"names",
"as",
"well",
"as",
"the",
"options",
"that",
"were",
"specified",
"for",
"that",
"machine",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/vagrantfile.rb#L273-L279 |
10,663 | hashicorp/vagrant | lib/vagrant/vagrantfile.rb | Vagrant.Vagrantfile.primary_machine_name | def primary_machine_name
# If it is a single machine environment, then return the name
return machine_names.first if machine_names.length == 1
# If it is a multi-machine environment, then return the primary
@config.vm.defined_vms.each do |name, subvm|
return name if subvm.options[:prima... | ruby | def primary_machine_name
# If it is a single machine environment, then return the name
return machine_names.first if machine_names.length == 1
# If it is a multi-machine environment, then return the primary
@config.vm.defined_vms.each do |name, subvm|
return name if subvm.options[:prima... | [
"def",
"primary_machine_name",
"# If it is a single machine environment, then return the name",
"return",
"machine_names",
".",
"first",
"if",
"machine_names",
".",
"length",
"==",
"1",
"# If it is a multi-machine environment, then return the primary",
"@config",
".",
"vm",
".",
... | Returns the name of the machine that is designated as the
"primary."
In the case of a single-machine environment, this is just the
single machine name. In the case of a multi-machine environment,
then this is the machine that is marked as primary, or nil if
no primary machine was specified.
@return [Symbol] | [
"Returns",
"the",
"name",
"of",
"the",
"machine",
"that",
"is",
"designated",
"as",
"the",
"primary",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/vagrantfile.rb#L290-L301 |
10,664 | hashicorp/vagrant | lib/vagrant/machine.rb | Vagrant.Machine.action | def action(name, opts=nil)
@triggers.fire_triggers(name, :before, @name.to_s, :action)
@logger.info("Calling action: #{name} on provider #{@provider}")
opts ||= {}
# Determine whether we lock or not
lock = true
lock = opts.delete(:lock) if opts.key?(:lock)
# Extra env keys ... | ruby | def action(name, opts=nil)
@triggers.fire_triggers(name, :before, @name.to_s, :action)
@logger.info("Calling action: #{name} on provider #{@provider}")
opts ||= {}
# Determine whether we lock or not
lock = true
lock = opts.delete(:lock) if opts.key?(:lock)
# Extra env keys ... | [
"def",
"action",
"(",
"name",
",",
"opts",
"=",
"nil",
")",
"@triggers",
".",
"fire_triggers",
"(",
"name",
",",
":before",
",",
"@name",
".",
"to_s",
",",
":action",
")",
"@logger",
".",
"info",
"(",
"\"Calling action: #{name} on provider #{@provider}\"",
")"... | Initialize a new machine.
@param [String] name Name of the virtual machine.
@param [Class] provider The provider backing this machine. This is
currently expected to be a V1 `provider` plugin.
@param [Object] provider_config The provider-specific configuration for
this machine.
@param [Hash] provider_options ... | [
"Initialize",
"a",
"new",
"machine",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/machine.rb#L162-L221 |
10,665 | hashicorp/vagrant | lib/vagrant/machine.rb | Vagrant.Machine.action_raw | def action_raw(name, callable, extra_env=nil)
# Run the action with the action runner on the environment
env = {
action_name: "machine_action_#{name}".to_sym,
machine: self,
machine_action: name,
ui: @ui,
}.merge(extra_env || {})
@env.action_runner.run(callable, e... | ruby | def action_raw(name, callable, extra_env=nil)
# Run the action with the action runner on the environment
env = {
action_name: "machine_action_#{name}".to_sym,
machine: self,
machine_action: name,
ui: @ui,
}.merge(extra_env || {})
@env.action_runner.run(callable, e... | [
"def",
"action_raw",
"(",
"name",
",",
"callable",
",",
"extra_env",
"=",
"nil",
")",
"# Run the action with the action runner on the environment",
"env",
"=",
"{",
"action_name",
":",
"\"machine_action_#{name}\"",
".",
"to_sym",
",",
"machine",
":",
"self",
",",
"m... | This calls a raw callable in the proper context of the machine using
the middleware stack.
@param [Symbol] name Name of the action
@param [Proc] callable
@param [Hash] extra_env Extra env for the action env.
@return [Hash] The resulting env | [
"This",
"calls",
"a",
"raw",
"callable",
"in",
"the",
"proper",
"context",
"of",
"the",
"machine",
"using",
"the",
"middleware",
"stack",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/machine.rb#L230-L239 |
10,666 | hashicorp/vagrant | lib/vagrant/machine.rb | Vagrant.Machine.id= | def id=(value)
@logger.info("New machine ID: #{value.inspect}")
id_file = nil
if @data_dir
# The file that will store the id if we have one. This allows the
# ID to persist across Vagrant runs. Also, store the UUID for the
# machine index.
id_file = @data_dir.join("id"... | ruby | def id=(value)
@logger.info("New machine ID: #{value.inspect}")
id_file = nil
if @data_dir
# The file that will store the id if we have one. This allows the
# ID to persist across Vagrant runs. Also, store the UUID for the
# machine index.
id_file = @data_dir.join("id"... | [
"def",
"id",
"=",
"(",
"value",
")",
"@logger",
".",
"info",
"(",
"\"New machine ID: #{value.inspect}\"",
")",
"id_file",
"=",
"nil",
"if",
"@data_dir",
"# The file that will store the id if we have one. This allows the",
"# ID to persist across Vagrant runs. Also, store the UUID... | This sets the unique ID associated with this machine. This will
persist this ID so that in the future Vagrant will be able to find
this machine again. The unique ID must be absolutely unique to the
virtual machine, and can be used by providers for finding the
actual machine associated with this instance.
**WARNIN... | [
"This",
"sets",
"the",
"unique",
"ID",
"associated",
"with",
"this",
"machine",
".",
"This",
"will",
"persist",
"this",
"ID",
"so",
"that",
"in",
"the",
"future",
"Vagrant",
"will",
"be",
"able",
"to",
"find",
"this",
"machine",
"again",
".",
"The",
"uni... | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/machine.rb#L287-L373 |
10,667 | hashicorp/vagrant | lib/vagrant/machine.rb | Vagrant.Machine.reload | def reload
old_id = @id
@id = nil
if @data_dir
# Read the id file from the data directory if it exists as the
# ID for the pre-existing physical representation of this machine.
id_file = @data_dir.join("id")
id_content = id_file.read.strip if id_file.file?
if !... | ruby | def reload
old_id = @id
@id = nil
if @data_dir
# Read the id file from the data directory if it exists as the
# ID for the pre-existing physical representation of this machine.
id_file = @data_dir.join("id")
id_content = id_file.read.strip if id_file.file?
if !... | [
"def",
"reload",
"old_id",
"=",
"@id",
"@id",
"=",
"nil",
"if",
"@data_dir",
"# Read the id file from the data directory if it exists as the",
"# ID for the pre-existing physical representation of this machine.",
"id_file",
"=",
"@data_dir",
".",
"join",
"(",
"\"id\"",
")",
"... | This reloads the ID of the underlying machine. | [
"This",
"reloads",
"the",
"ID",
"of",
"the",
"underlying",
"machine",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/machine.rb#L394-L414 |
10,668 | hashicorp/vagrant | lib/vagrant/machine.rb | Vagrant.Machine.state | def state
result = @provider.state
raise Errors::MachineStateInvalid if !result.is_a?(MachineState)
# Update our state cache if we have a UUID and an entry in the
# master index.
uuid = index_uuid
if uuid
# active_machines provides access to query this info on each machine
... | ruby | def state
result = @provider.state
raise Errors::MachineStateInvalid if !result.is_a?(MachineState)
# Update our state cache if we have a UUID and an entry in the
# master index.
uuid = index_uuid
if uuid
# active_machines provides access to query this info on each machine
... | [
"def",
"state",
"result",
"=",
"@provider",
".",
"state",
"raise",
"Errors",
"::",
"MachineStateInvalid",
"if",
"!",
"result",
".",
"is_a?",
"(",
"MachineState",
")",
"# Update our state cache if we have a UUID and an entry in the",
"# master index.",
"uuid",
"=",
"inde... | Returns the state of this machine. The state is queried from the
backing provider, so it can be any arbitrary symbol.
@return [MachineState] | [
"Returns",
"the",
"state",
"of",
"this",
"machine",
".",
"The",
"state",
"is",
"queried",
"from",
"the",
"backing",
"provider",
"so",
"it",
"can",
"be",
"any",
"arbitrary",
"symbol",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/machine.rb#L531-L554 |
10,669 | hashicorp/vagrant | lib/vagrant/machine.rb | Vagrant.Machine.check_cwd | def check_cwd
desired_encoding = @env.root_path.to_s.encoding
vagrant_cwd_filepath = @data_dir.join('vagrant_cwd')
vagrant_cwd = if File.exist?(vagrant_cwd_filepath)
File.read(vagrant_cwd_filepath,
external_encoding: desired_encoding
... | ruby | def check_cwd
desired_encoding = @env.root_path.to_s.encoding
vagrant_cwd_filepath = @data_dir.join('vagrant_cwd')
vagrant_cwd = if File.exist?(vagrant_cwd_filepath)
File.read(vagrant_cwd_filepath,
external_encoding: desired_encoding
... | [
"def",
"check_cwd",
"desired_encoding",
"=",
"@env",
".",
"root_path",
".",
"to_s",
".",
"encoding",
"vagrant_cwd_filepath",
"=",
"@data_dir",
".",
"join",
"(",
"'vagrant_cwd'",
")",
"vagrant_cwd",
"=",
"if",
"File",
".",
"exist?",
"(",
"vagrant_cwd_filepath",
"... | Checks the current directory for a given machine
and displays a warning if that machine has moved
from its previous location on disk. If the machine
has moved, it prints a warning to the user. | [
"Checks",
"the",
"current",
"directory",
"for",
"a",
"given",
"machine",
"and",
"displays",
"a",
"warning",
"if",
"that",
"machine",
"has",
"moved",
"from",
"its",
"previous",
"location",
"on",
"disk",
".",
"If",
"the",
"machine",
"has",
"moved",
"it",
"pr... | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/machine.rb#L593-L613 |
10,670 | hashicorp/vagrant | lib/vagrant/box_collection.rb | Vagrant.BoxCollection.all | def all
results = []
with_collection_lock do
@logger.debug("Finding all boxes in: #{@directory}")
@directory.children(true).each do |child|
# Ignore non-directories, since files are not interesting to
# us in our folder structure.
next if !child.directory?
... | ruby | def all
results = []
with_collection_lock do
@logger.debug("Finding all boxes in: #{@directory}")
@directory.children(true).each do |child|
# Ignore non-directories, since files are not interesting to
# us in our folder structure.
next if !child.directory?
... | [
"def",
"all",
"results",
"=",
"[",
"]",
"with_collection_lock",
"do",
"@logger",
".",
"debug",
"(",
"\"Finding all boxes in: #{@directory}\"",
")",
"@directory",
".",
"children",
"(",
"true",
")",
".",
"each",
"do",
"|",
"child",
"|",
"# Ignore non-directories, si... | This returns an array of all the boxes on the system, given by
their name and their provider.
@return [Array] Array of `[name, version, provider]` of the boxes
installed on this system. | [
"This",
"returns",
"an",
"array",
"of",
"all",
"the",
"boxes",
"on",
"the",
"system",
"given",
"by",
"their",
"name",
"and",
"their",
"provider",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/box_collection.rb#L215-L263 |
10,671 | hashicorp/vagrant | lib/vagrant/box_collection.rb | Vagrant.BoxCollection.find | def find(name, providers, version)
providers = Array(providers)
# Build up the requirements we have
requirements = version.to_s.split(",").map do |v|
Gem::Requirement.new(v.strip)
end
with_collection_lock do
box_directory = @directory.join(dir_name(name))
if !box_... | ruby | def find(name, providers, version)
providers = Array(providers)
# Build up the requirements we have
requirements = version.to_s.split(",").map do |v|
Gem::Requirement.new(v.strip)
end
with_collection_lock do
box_directory = @directory.join(dir_name(name))
if !box_... | [
"def",
"find",
"(",
"name",
",",
"providers",
",",
"version",
")",
"providers",
"=",
"Array",
"(",
"providers",
")",
"# Build up the requirements we have",
"requirements",
"=",
"version",
".",
"to_s",
".",
"split",
"(",
"\",\"",
")",
".",
"map",
"do",
"|",
... | Find a box in the collection with the given name and provider.
@param [String] name Name of the box (logical name).
@param [Array] providers Providers that the box implements.
@param [String] version Version constraints to adhere to. Example:
"~> 1.0" or "= 1.0, ~> 1.1"
@return [Box] The box found, or `nil` if ... | [
"Find",
"a",
"box",
"in",
"the",
"collection",
"with",
"the",
"given",
"name",
"and",
"provider",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/box_collection.rb#L272-L335 |
10,672 | hashicorp/vagrant | lib/vagrant/box_collection.rb | Vagrant.BoxCollection.upgrade_v1_1_v1_5 | def upgrade_v1_1_v1_5
with_collection_lock do
temp_dir = Pathname.new(Dir.mktmpdir(TEMP_PREFIX, @temp_root))
@directory.children(true).each do |boxdir|
# Ignore all non-directories because they can't be boxes
next if !boxdir.directory?
box_name = boxdir.basename.to_... | ruby | def upgrade_v1_1_v1_5
with_collection_lock do
temp_dir = Pathname.new(Dir.mktmpdir(TEMP_PREFIX, @temp_root))
@directory.children(true).each do |boxdir|
# Ignore all non-directories because they can't be boxes
next if !boxdir.directory?
box_name = boxdir.basename.to_... | [
"def",
"upgrade_v1_1_v1_5",
"with_collection_lock",
"do",
"temp_dir",
"=",
"Pathname",
".",
"new",
"(",
"Dir",
".",
"mktmpdir",
"(",
"TEMP_PREFIX",
",",
"@temp_root",
")",
")",
"@directory",
".",
"children",
"(",
"true",
")",
".",
"each",
"do",
"|",
"boxdir"... | This upgrades a v1.1 - v1.4 box directory structure up to a v1.5
directory structure. This will raise exceptions if it fails in any
way. | [
"This",
"upgrades",
"a",
"v1",
".",
"1",
"-",
"v1",
".",
"4",
"box",
"directory",
"structure",
"up",
"to",
"a",
"v1",
".",
"5",
"directory",
"structure",
".",
"This",
"will",
"raise",
"exceptions",
"if",
"it",
"fails",
"in",
"any",
"way",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/box_collection.rb#L340-L370 |
10,673 | hashicorp/vagrant | lib/vagrant/box_collection.rb | Vagrant.BoxCollection.clean | def clean(name)
return false if exists?(name)
path = File.join(directory, dir_name(name))
FileUtils.rm_rf(path)
end | ruby | def clean(name)
return false if exists?(name)
path = File.join(directory, dir_name(name))
FileUtils.rm_rf(path)
end | [
"def",
"clean",
"(",
"name",
")",
"return",
"false",
"if",
"exists?",
"(",
"name",
")",
"path",
"=",
"File",
".",
"join",
"(",
"directory",
",",
"dir_name",
"(",
"name",
")",
")",
"FileUtils",
".",
"rm_rf",
"(",
"path",
")",
"end"
] | Cleans the directory for a box by removing the folders that are
empty. | [
"Cleans",
"the",
"directory",
"for",
"a",
"box",
"by",
"removing",
"the",
"folders",
"that",
"are",
"empty",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/box_collection.rb#L374-L378 |
10,674 | hashicorp/vagrant | lib/vagrant/box_collection.rb | Vagrant.BoxCollection.dir_name | def dir_name(name)
name = name.dup
name.gsub!(":", VAGRANT_COLON) if Util::Platform.windows?
name.gsub!("/", VAGRANT_SLASH)
name
end | ruby | def dir_name(name)
name = name.dup
name.gsub!(":", VAGRANT_COLON) if Util::Platform.windows?
name.gsub!("/", VAGRANT_SLASH)
name
end | [
"def",
"dir_name",
"(",
"name",
")",
"name",
"=",
"name",
".",
"dup",
"name",
".",
"gsub!",
"(",
"\":\"",
",",
"VAGRANT_COLON",
")",
"if",
"Util",
"::",
"Platform",
".",
"windows?",
"name",
".",
"gsub!",
"(",
"\"/\"",
",",
"VAGRANT_SLASH",
")",
"name",... | Returns the directory name for the box of the given name.
@param [String] name
@return [String] | [
"Returns",
"the",
"directory",
"name",
"for",
"the",
"box",
"of",
"the",
"given",
"name",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/box_collection.rb#L386-L391 |
10,675 | hashicorp/vagrant | lib/vagrant/box_collection.rb | Vagrant.BoxCollection.undir_name | def undir_name(name)
name = name.dup
name.gsub!(VAGRANT_COLON, ":")
name.gsub!(VAGRANT_SLASH, "/")
name
end | ruby | def undir_name(name)
name = name.dup
name.gsub!(VAGRANT_COLON, ":")
name.gsub!(VAGRANT_SLASH, "/")
name
end | [
"def",
"undir_name",
"(",
"name",
")",
"name",
"=",
"name",
".",
"dup",
"name",
".",
"gsub!",
"(",
"VAGRANT_COLON",
",",
"\":\"",
")",
"name",
".",
"gsub!",
"(",
"VAGRANT_SLASH",
",",
"\"/\"",
")",
"name",
"end"
] | Returns the directory name for the box cleaned up | [
"Returns",
"the",
"directory",
"name",
"for",
"the",
"box",
"cleaned",
"up"
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/box_collection.rb#L394-L399 |
10,676 | hashicorp/vagrant | lib/vagrant/box_collection.rb | Vagrant.BoxCollection.v1_upgrade | def v1_upgrade(dir)
@logger.debug("Upgrading box in directory: #{dir}")
temp_dir = Pathname.new(Dir.mktmpdir(TEMP_PREFIX, @temp_root))
@logger.debug("Temporary directory for upgrading: #{temp_dir}")
# Move all the things into the temporary directory
dir.children(true).each do |child|
... | ruby | def v1_upgrade(dir)
@logger.debug("Upgrading box in directory: #{dir}")
temp_dir = Pathname.new(Dir.mktmpdir(TEMP_PREFIX, @temp_root))
@logger.debug("Temporary directory for upgrading: #{temp_dir}")
# Move all the things into the temporary directory
dir.children(true).each do |child|
... | [
"def",
"v1_upgrade",
"(",
"dir",
")",
"@logger",
".",
"debug",
"(",
"\"Upgrading box in directory: #{dir}\"",
")",
"temp_dir",
"=",
"Pathname",
".",
"new",
"(",
"Dir",
".",
"mktmpdir",
"(",
"TEMP_PREFIX",
",",
"@temp_root",
")",
")",
"@logger",
".",
"debug",
... | This upgrades the V1 box contained unpacked in the given directory
and returns the directory of the upgraded version. This is
_destructive_ to the contents of the old directory. That is, the
contents of the old V1 box will be destroyed or moved.
Preconditions:
* `dir` is a valid V1 box. Verify with {#v1_box?}
@... | [
"This",
"upgrades",
"the",
"V1",
"box",
"contained",
"unpacked",
"in",
"the",
"given",
"directory",
"and",
"returns",
"the",
"directory",
"of",
"the",
"upgraded",
"version",
".",
"This",
"is",
"_destructive_",
"to",
"the",
"contents",
"of",
"the",
"old",
"di... | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/box_collection.rb#L422-L451 |
10,677 | hashicorp/vagrant | lib/vagrant/box_collection.rb | Vagrant.BoxCollection.with_temp_dir | def with_temp_dir(dir=nil)
dir ||= Dir.mktmpdir(TEMP_PREFIX, @temp_root)
dir = Pathname.new(dir)
yield dir
ensure
FileUtils.rm_rf(dir.to_s)
end | ruby | def with_temp_dir(dir=nil)
dir ||= Dir.mktmpdir(TEMP_PREFIX, @temp_root)
dir = Pathname.new(dir)
yield dir
ensure
FileUtils.rm_rf(dir.to_s)
end | [
"def",
"with_temp_dir",
"(",
"dir",
"=",
"nil",
")",
"dir",
"||=",
"Dir",
".",
"mktmpdir",
"(",
"TEMP_PREFIX",
",",
"@temp_root",
")",
"dir",
"=",
"Pathname",
".",
"new",
"(",
"dir",
")",
"yield",
"dir",
"ensure",
"FileUtils",
".",
"rm_rf",
"(",
"dir",... | This is a helper that makes sure that our temporary directories
are cleaned up no matter what.
@param [String] dir Path to a temporary directory
@return [Object] The result of whatever the yield is | [
"This",
"is",
"a",
"helper",
"that",
"makes",
"sure",
"that",
"our",
"temporary",
"directories",
"are",
"cleaned",
"up",
"no",
"matter",
"what",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/box_collection.rb#L466-L473 |
10,678 | hashicorp/vagrant | lib/vagrant/capability_host.rb | Vagrant.CapabilityHost.initialize_capabilities! | def initialize_capabilities!(host, hosts, capabilities, *args)
@cap_logger = Log4r::Logger.new(
"vagrant::capability_host::#{self.class.to_s.downcase}")
if host && !hosts[host]
raise Errors::CapabilityHostExplicitNotDetected, value: host.to_s
end
if !host
host = autodet... | ruby | def initialize_capabilities!(host, hosts, capabilities, *args)
@cap_logger = Log4r::Logger.new(
"vagrant::capability_host::#{self.class.to_s.downcase}")
if host && !hosts[host]
raise Errors::CapabilityHostExplicitNotDetected, value: host.to_s
end
if !host
host = autodet... | [
"def",
"initialize_capabilities!",
"(",
"host",
",",
"hosts",
",",
"capabilities",
",",
"*",
"args",
")",
"@cap_logger",
"=",
"Log4r",
"::",
"Logger",
".",
"new",
"(",
"\"vagrant::capability_host::#{self.class.to_s.downcase}\"",
")",
"if",
"host",
"&&",
"!",
"host... | Initializes the capability system by detecting the proper capability
host to execute on and building the chain of capabilities to execute.
@param [Symbol] host The host to use for the capabilities, or nil if
we should auto-detect it.
@param [Hash<Symbol, Array<Class, Symbol>>] hosts Potential capability
hosts... | [
"Initializes",
"the",
"capability",
"system",
"by",
"detecting",
"the",
"proper",
"capability",
"host",
"to",
"execute",
"on",
"and",
"building",
"the",
"chain",
"of",
"capabilities",
"to",
"execute",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/capability_host.rb#L27-L69 |
10,679 | hashicorp/vagrant | lib/vagrant/capability_host.rb | Vagrant.CapabilityHost.capability | def capability(cap_name, *args)
cap_mod = capability_module(cap_name.to_sym)
if !cap_mod
raise Errors::CapabilityNotFound,
cap: cap_name.to_s,
host: @cap_host_chain[0][0].to_s
end
cap_method = nil
begin
cap_method = cap_mod.method(cap_name)
rescu... | ruby | def capability(cap_name, *args)
cap_mod = capability_module(cap_name.to_sym)
if !cap_mod
raise Errors::CapabilityNotFound,
cap: cap_name.to_s,
host: @cap_host_chain[0][0].to_s
end
cap_method = nil
begin
cap_method = cap_mod.method(cap_name)
rescu... | [
"def",
"capability",
"(",
"cap_name",
",",
"*",
"args",
")",
"cap_mod",
"=",
"capability_module",
"(",
"cap_name",
".",
"to_sym",
")",
"if",
"!",
"cap_mod",
"raise",
"Errors",
"::",
"CapabilityNotFound",
",",
"cap",
":",
"cap_name",
".",
"to_s",
",",
"host... | Executes the capability with the given name, optionally passing more
arguments onwards to the capability. If the capability returns a value,
it will be returned.
@param [Symbol] cap_name Name of the capability | [
"Executes",
"the",
"capability",
"with",
"the",
"given",
"name",
"optionally",
"passing",
"more",
"arguments",
"onwards",
"to",
"the",
"capability",
".",
"If",
"the",
"capability",
"returns",
"a",
"value",
"it",
"will",
"be",
"returned",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/capability_host.rb#L91-L112 |
10,680 | hashicorp/vagrant | lib/vagrant/capability_host.rb | Vagrant.CapabilityHost.capability_module | def capability_module(cap_name)
@cap_logger.debug("Searching for cap: #{cap_name}")
@cap_host_chain.each do |host_name, host|
@cap_logger.debug("Checking in: #{host_name}")
caps = @cap_caps[host_name]
if caps && caps.key?(cap_name)
@cap_logger.debug("Found cap: #{cap_name}... | ruby | def capability_module(cap_name)
@cap_logger.debug("Searching for cap: #{cap_name}")
@cap_host_chain.each do |host_name, host|
@cap_logger.debug("Checking in: #{host_name}")
caps = @cap_caps[host_name]
if caps && caps.key?(cap_name)
@cap_logger.debug("Found cap: #{cap_name}... | [
"def",
"capability_module",
"(",
"cap_name",
")",
"@cap_logger",
".",
"debug",
"(",
"\"Searching for cap: #{cap_name}\"",
")",
"@cap_host_chain",
".",
"each",
"do",
"|",
"host_name",
",",
"host",
"|",
"@cap_logger",
".",
"debug",
"(",
"\"Checking in: #{host_name}\"",
... | Returns the registered module for a capability with the given name.
@param [Symbol] cap_name
@return [Module] | [
"Returns",
"the",
"registered",
"module",
"for",
"a",
"capability",
"with",
"the",
"given",
"name",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/capability_host.rb#L162-L175 |
10,681 | hashicorp/vagrant | lib/vagrant/box.rb | Vagrant.Box.in_use? | def in_use?(index)
results = []
index.each do |entry|
box_data = entry.extra_data["box"]
next if !box_data
# If all the data matches, record it
if box_data["name"] == self.name &&
box_data["provider"] == self.provider.to_s &&
box_data["version"] == self.v... | ruby | def in_use?(index)
results = []
index.each do |entry|
box_data = entry.extra_data["box"]
next if !box_data
# If all the data matches, record it
if box_data["name"] == self.name &&
box_data["provider"] == self.provider.to_s &&
box_data["version"] == self.v... | [
"def",
"in_use?",
"(",
"index",
")",
"results",
"=",
"[",
"]",
"index",
".",
"each",
"do",
"|",
"entry",
"|",
"box_data",
"=",
"entry",
".",
"extra_data",
"[",
"\"box\"",
"]",
"next",
"if",
"!",
"box_data",
"# If all the data matches, record it",
"if",
"bo... | Checks if this box is in use according to the given machine
index and returns the entries that appear to be using the box.
The entries returned, if any, are not tested for validity
with {MachineIndex::Entry#valid?}, so the caller should do that
if the caller cares.
@param [MachineIndex] index
@return [Array<Mac... | [
"Checks",
"if",
"this",
"box",
"is",
"in",
"use",
"according",
"to",
"the",
"given",
"machine",
"index",
"and",
"returns",
"the",
"entries",
"that",
"appear",
"to",
"be",
"using",
"the",
"box",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/box.rb#L100-L116 |
10,682 | hashicorp/vagrant | lib/vagrant/box.rb | Vagrant.Box.load_metadata | def load_metadata(**download_options)
tf = Tempfile.new("vagrant-load-metadata")
tf.close
url = @metadata_url
if File.file?(url) || url !~ /^[a-z0-9]+:.*$/i
url = File.expand_path(url)
url = Util::Platform.cygwin_windows_path(url)
url = "file:#{url}"
end
opt... | ruby | def load_metadata(**download_options)
tf = Tempfile.new("vagrant-load-metadata")
tf.close
url = @metadata_url
if File.file?(url) || url !~ /^[a-z0-9]+:.*$/i
url = File.expand_path(url)
url = Util::Platform.cygwin_windows_path(url)
url = "file:#{url}"
end
opt... | [
"def",
"load_metadata",
"(",
"**",
"download_options",
")",
"tf",
"=",
"Tempfile",
".",
"new",
"(",
"\"vagrant-load-metadata\"",
")",
"tf",
".",
"close",
"url",
"=",
"@metadata_url",
"if",
"File",
".",
"file?",
"(",
"url",
")",
"||",
"url",
"!~",
"/",
"/... | Loads the metadata URL and returns the latest metadata associated
with this box.
@param [Hash] download_options Options to pass to the downloader.
@return [BoxMetadata] | [
"Loads",
"the",
"metadata",
"URL",
"and",
"returns",
"the",
"latest",
"metadata",
"associated",
"with",
"this",
"box",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/box.rb#L123-L142 |
10,683 | hashicorp/vagrant | lib/vagrant/box.rb | Vagrant.Box.has_update? | def has_update?(version=nil, download_options: {})
if !@metadata_url
raise Errors::BoxUpdateNoMetadata, name: @name
end
if download_options.delete(:automatic_check) && !automatic_update_check_allowed?
@logger.info("Skipping box update check")
return
end
version +=... | ruby | def has_update?(version=nil, download_options: {})
if !@metadata_url
raise Errors::BoxUpdateNoMetadata, name: @name
end
if download_options.delete(:automatic_check) && !automatic_update_check_allowed?
@logger.info("Skipping box update check")
return
end
version +=... | [
"def",
"has_update?",
"(",
"version",
"=",
"nil",
",",
"download_options",
":",
"{",
"}",
")",
"if",
"!",
"@metadata_url",
"raise",
"Errors",
"::",
"BoxUpdateNoMetadata",
",",
"name",
":",
"@name",
"end",
"if",
"download_options",
".",
"delete",
"(",
":autom... | Checks if the box has an update and returns the metadata, version,
and provider. If the box doesn't have an update that satisfies the
constraints, it will return nil.
This will potentially make a network call if it has to load the
metadata from the network.
@param [String] version Version constraints the update ... | [
"Checks",
"if",
"the",
"box",
"has",
"an",
"update",
"and",
"returns",
"the",
"metadata",
"version",
"and",
"provider",
".",
"If",
"the",
"box",
"doesn",
"t",
"have",
"an",
"update",
"that",
"satisfies",
"the",
"constraints",
"it",
"will",
"return",
"nil",... | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/box.rb#L155-L173 |
10,684 | hashicorp/vagrant | lib/vagrant/box.rb | Vagrant.Box.automatic_update_check_allowed? | def automatic_update_check_allowed?
check_path = directory.join("box_update_check")
if check_path.exist?
last_check_span = Time.now.to_i - check_path.mtime.to_i
if last_check_span < BOX_UPDATE_CHECK_INTERVAL
@logger.info("box update check is under the interval threshold")
... | ruby | def automatic_update_check_allowed?
check_path = directory.join("box_update_check")
if check_path.exist?
last_check_span = Time.now.to_i - check_path.mtime.to_i
if last_check_span < BOX_UPDATE_CHECK_INTERVAL
@logger.info("box update check is under the interval threshold")
... | [
"def",
"automatic_update_check_allowed?",
"check_path",
"=",
"directory",
".",
"join",
"(",
"\"box_update_check\"",
")",
"if",
"check_path",
".",
"exist?",
"last_check_span",
"=",
"Time",
".",
"now",
".",
"to_i",
"-",
"check_path",
".",
"mtime",
".",
"to_i",
"if... | Check if a box update check is allowed. Uses a file
in the box data directory to track when the last auto
update check was performed and returns true if the
BOX_UPDATE_CHECK_INTERVAL has passed.
@return [Boolean] | [
"Check",
"if",
"a",
"box",
"update",
"check",
"is",
"allowed",
".",
"Uses",
"a",
"file",
"in",
"the",
"box",
"data",
"directory",
"to",
"track",
"when",
"the",
"last",
"auto",
"update",
"check",
"was",
"performed",
"and",
"returns",
"true",
"if",
"the",
... | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/box.rb#L181-L192 |
10,685 | hashicorp/vagrant | lib/vagrant/box.rb | Vagrant.Box.repackage | def repackage(path)
@logger.debug("Repackaging box '#{@name}' to: #{path}")
Util::SafeChdir.safe_chdir(@directory) do
# Find all the files in our current directory and tar it up!
files = Dir.glob(File.join(".", "**", "*")).select { |f| File.file?(f) }
# Package!
Util::Subpr... | ruby | def repackage(path)
@logger.debug("Repackaging box '#{@name}' to: #{path}")
Util::SafeChdir.safe_chdir(@directory) do
# Find all the files in our current directory and tar it up!
files = Dir.glob(File.join(".", "**", "*")).select { |f| File.file?(f) }
# Package!
Util::Subpr... | [
"def",
"repackage",
"(",
"path",
")",
"@logger",
".",
"debug",
"(",
"\"Repackaging box '#{@name}' to: #{path}\"",
")",
"Util",
"::",
"SafeChdir",
".",
"safe_chdir",
"(",
"@directory",
")",
"do",
"# Find all the files in our current directory and tar it up!",
"files",
"=",... | This repackages this box and outputs it to the given path.
@param [Pathname] path The full path (filename included) of where
to output this box.
@return [Boolean] true if this succeeds. | [
"This",
"repackages",
"this",
"box",
"and",
"outputs",
"it",
"to",
"the",
"given",
"path",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/box.rb#L199-L213 |
10,686 | hashicorp/vagrant | lib/vagrant/alias.rb | Vagrant.Alias.interpret | def interpret(line)
# is it a comment?
return nil if line.strip.start_with?("#")
keyword, command = line.split("=", 2).collect(&:strip)
# validate the keyword
if keyword.match(/\s/i)
raise Errors::AliasInvalidError, alias: line, message: "Alias keywords must not contain any white... | ruby | def interpret(line)
# is it a comment?
return nil if line.strip.start_with?("#")
keyword, command = line.split("=", 2).collect(&:strip)
# validate the keyword
if keyword.match(/\s/i)
raise Errors::AliasInvalidError, alias: line, message: "Alias keywords must not contain any white... | [
"def",
"interpret",
"(",
"line",
")",
"# is it a comment?",
"return",
"nil",
"if",
"line",
".",
"strip",
".",
"start_with?",
"(",
"\"#\"",
")",
"keyword",
",",
"command",
"=",
"line",
".",
"split",
"(",
"\"=\"",
",",
"2",
")",
".",
"collect",
"(",
":st... | This interprets a raw line from the aliases file. | [
"This",
"interprets",
"a",
"raw",
"line",
"from",
"the",
"aliases",
"file",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/alias.rb#L28-L40 |
10,687 | hashicorp/vagrant | lib/vagrant/alias.rb | Vagrant.Alias.register | def register(keyword, command)
@aliases.register(keyword.to_sym) do
lambda do |args|
# directly execute shell commands
if command.start_with?("!")
return Util::SafeExec.exec "#{command[1..-1]} #{args.join(" ")}".strip
end
return CLI.new(command.split.co... | ruby | def register(keyword, command)
@aliases.register(keyword.to_sym) do
lambda do |args|
# directly execute shell commands
if command.start_with?("!")
return Util::SafeExec.exec "#{command[1..-1]} #{args.join(" ")}".strip
end
return CLI.new(command.split.co... | [
"def",
"register",
"(",
"keyword",
",",
"command",
")",
"@aliases",
".",
"register",
"(",
"keyword",
".",
"to_sym",
")",
"do",
"lambda",
"do",
"|",
"args",
"|",
"# directly execute shell commands",
"if",
"command",
".",
"start_with?",
"(",
"\"!\"",
")",
"ret... | This registers an alias. | [
"This",
"registers",
"an",
"alias",
"."
] | c22a145c59790c098f95d50141d9afb48e1ef55f | https://github.com/hashicorp/vagrant/blob/c22a145c59790c098f95d50141d9afb48e1ef55f/lib/vagrant/alias.rb#L43-L54 |
10,688 | github/linguist | samples/Ruby/sinatra.rb | Sinatra.Helpers.redirect | def redirect(uri, *args)
if env['HTTP_VERSION'] == 'HTTP/1.1' and env["REQUEST_METHOD"] != 'GET'
status 303
else
status 302
end
# According to RFC 2616 section 14.30, "the field value consists of a
# single absolute URI"
response['Location'] = uri(uri, settings.absol... | ruby | def redirect(uri, *args)
if env['HTTP_VERSION'] == 'HTTP/1.1' and env["REQUEST_METHOD"] != 'GET'
status 303
else
status 302
end
# According to RFC 2616 section 14.30, "the field value consists of a
# single absolute URI"
response['Location'] = uri(uri, settings.absol... | [
"def",
"redirect",
"(",
"uri",
",",
"*",
"args",
")",
"if",
"env",
"[",
"'HTTP_VERSION'",
"]",
"==",
"'HTTP/1.1'",
"and",
"env",
"[",
"\"REQUEST_METHOD\"",
"]",
"!=",
"'GET'",
"status",
"303",
"else",
"status",
"302",
"end",
"# According to RFC 2616 section 14... | Halt processing and redirect to the URI provided. | [
"Halt",
"processing",
"and",
"redirect",
"to",
"the",
"URI",
"provided",
"."
] | 9116c90fcbb82ac03b4b33c58cfbde1fcf745e99 | https://github.com/github/linguist/blob/9116c90fcbb82ac03b4b33c58cfbde1fcf745e99/samples/Ruby/sinatra.rb#L167-L178 |
10,689 | github/linguist | samples/Ruby/sinatra.rb | Sinatra.Helpers.uri | def uri(addr = nil, absolute = true, add_script_name = true)
return addr if addr =~ /\A[A-z][A-z0-9\+\.\-]*:/
uri = [host = ""]
if absolute
host << "http#{'s' if request.secure?}://"
if request.forwarded? or request.port != (request.secure? ? 443 : 80)
host << request.host_wi... | ruby | def uri(addr = nil, absolute = true, add_script_name = true)
return addr if addr =~ /\A[A-z][A-z0-9\+\.\-]*:/
uri = [host = ""]
if absolute
host << "http#{'s' if request.secure?}://"
if request.forwarded? or request.port != (request.secure? ? 443 : 80)
host << request.host_wi... | [
"def",
"uri",
"(",
"addr",
"=",
"nil",
",",
"absolute",
"=",
"true",
",",
"add_script_name",
"=",
"true",
")",
"return",
"addr",
"if",
"addr",
"=~",
"/",
"\\A",
"\\+",
"\\.",
"\\-",
"/",
"uri",
"=",
"[",
"host",
"=",
"\"\"",
"]",
"if",
"absolute",
... | Generates the absolute URI for a given path in the app.
Takes Rack routers and reverse proxies into account. | [
"Generates",
"the",
"absolute",
"URI",
"for",
"a",
"given",
"path",
"in",
"the",
"app",
".",
"Takes",
"Rack",
"routers",
"and",
"reverse",
"proxies",
"into",
"account",
"."
] | 9116c90fcbb82ac03b4b33c58cfbde1fcf745e99 | https://github.com/github/linguist/blob/9116c90fcbb82ac03b4b33c58cfbde1fcf745e99/samples/Ruby/sinatra.rb#L182-L196 |
10,690 | github/linguist | samples/Ruby/sinatra.rb | Sinatra.Helpers.content_type | def content_type(type = nil, params={})
return response['Content-Type'] unless type
default = params.delete :default
mime_type = mime_type(type) || default
fail "Unknown media type: %p" % type if mime_type.nil?
mime_type = mime_type.dup
unless params.include? :charset or settings.add... | ruby | def content_type(type = nil, params={})
return response['Content-Type'] unless type
default = params.delete :default
mime_type = mime_type(type) || default
fail "Unknown media type: %p" % type if mime_type.nil?
mime_type = mime_type.dup
unless params.include? :charset or settings.add... | [
"def",
"content_type",
"(",
"type",
"=",
"nil",
",",
"params",
"=",
"{",
"}",
")",
"return",
"response",
"[",
"'Content-Type'",
"]",
"unless",
"type",
"default",
"=",
"params",
".",
"delete",
":default",
"mime_type",
"=",
"mime_type",
"(",
"type",
")",
"... | Set the Content-Type of the response body given a media type or file
extension. | [
"Set",
"the",
"Content",
"-",
"Type",
"of",
"the",
"response",
"body",
"given",
"a",
"media",
"type",
"or",
"file",
"extension",
"."
] | 9116c90fcbb82ac03b4b33c58cfbde1fcf745e99 | https://github.com/github/linguist/blob/9116c90fcbb82ac03b4b33c58cfbde1fcf745e99/samples/Ruby/sinatra.rb#L236-L251 |
10,691 | github/linguist | samples/Ruby/sinatra.rb | Sinatra.Helpers.stream | def stream(keep_open = false)
scheduler = env['async.callback'] ? EventMachine : Stream
current = @params.dup
body Stream.new(scheduler, keep_open) { |out| with_params(current) { yield(out) } }
end | ruby | def stream(keep_open = false)
scheduler = env['async.callback'] ? EventMachine : Stream
current = @params.dup
body Stream.new(scheduler, keep_open) { |out| with_params(current) { yield(out) } }
end | [
"def",
"stream",
"(",
"keep_open",
"=",
"false",
")",
"scheduler",
"=",
"env",
"[",
"'async.callback'",
"]",
"?",
"EventMachine",
":",
"Stream",
"current",
"=",
"@params",
".",
"dup",
"body",
"Stream",
".",
"new",
"(",
"scheduler",
",",
"keep_open",
")",
... | Allows to start sending data to the client even though later parts of
the response body have not yet been generated.
The close parameter specifies whether Stream#close should be called
after the block has been executed. This is only relevant for evented
servers like Thin or Rainbows. | [
"Allows",
"to",
"start",
"sending",
"data",
"to",
"the",
"client",
"even",
"though",
"later",
"parts",
"of",
"the",
"response",
"body",
"have",
"not",
"yet",
"been",
"generated",
"."
] | 9116c90fcbb82ac03b4b33c58cfbde1fcf745e99 | https://github.com/github/linguist/blob/9116c90fcbb82ac03b4b33c58cfbde1fcf745e99/samples/Ruby/sinatra.rb#L343-L347 |
10,692 | github/linguist | samples/Ruby/sinatra.rb | Sinatra.Helpers.etag_matches? | def etag_matches?(list, new_resource = request.post?)
return !new_resource if list == '*'
list.to_s.split(/\s*,\s*/).include? response['ETag']
end | ruby | def etag_matches?(list, new_resource = request.post?)
return !new_resource if list == '*'
list.to_s.split(/\s*,\s*/).include? response['ETag']
end | [
"def",
"etag_matches?",
"(",
"list",
",",
"new_resource",
"=",
"request",
".",
"post?",
")",
"return",
"!",
"new_resource",
"if",
"list",
"==",
"'*'",
"list",
".",
"to_s",
".",
"split",
"(",
"/",
"\\s",
"\\s",
"/",
")",
".",
"include?",
"response",
"["... | Helper method checking if a ETag value list includes the current ETag. | [
"Helper",
"method",
"checking",
"if",
"a",
"ETag",
"value",
"list",
"includes",
"the",
"current",
"ETag",
"."
] | 9116c90fcbb82ac03b4b33c58cfbde1fcf745e99 | https://github.com/github/linguist/blob/9116c90fcbb82ac03b4b33c58cfbde1fcf745e99/samples/Ruby/sinatra.rb#L529-L532 |
10,693 | github/linguist | samples/Ruby/sinatra.rb | Sinatra.Templates.render_ruby | def render_ruby(engine, template, options={}, locals={}, &block)
options, template = template, nil if template.is_a?(Hash)
template = Proc.new { block } if template.nil?
render engine, template, options, locals
end | ruby | def render_ruby(engine, template, options={}, locals={}, &block)
options, template = template, nil if template.is_a?(Hash)
template = Proc.new { block } if template.nil?
render engine, template, options, locals
end | [
"def",
"render_ruby",
"(",
"engine",
",",
"template",
",",
"options",
"=",
"{",
"}",
",",
"locals",
"=",
"{",
"}",
",",
"&",
"block",
")",
"options",
",",
"template",
"=",
"template",
",",
"nil",
"if",
"template",
".",
"is_a?",
"(",
"Hash",
")",
"t... | logic shared between builder and nokogiri | [
"logic",
"shared",
"between",
"builder",
"and",
"nokogiri"
] | 9116c90fcbb82ac03b4b33c58cfbde1fcf745e99 | https://github.com/github/linguist/blob/9116c90fcbb82ac03b4b33c58cfbde1fcf745e99/samples/Ruby/sinatra.rb#L665-L669 |
10,694 | github/linguist | samples/Ruby/sinatra.rb | Sinatra.Base.filter! | def filter!(type, base = settings)
filter! type, base.superclass if base.superclass.respond_to?(:filters)
base.filters[type].each { |args| process_route(*args) }
end | ruby | def filter!(type, base = settings)
filter! type, base.superclass if base.superclass.respond_to?(:filters)
base.filters[type].each { |args| process_route(*args) }
end | [
"def",
"filter!",
"(",
"type",
",",
"base",
"=",
"settings",
")",
"filter!",
"type",
",",
"base",
".",
"superclass",
"if",
"base",
".",
"superclass",
".",
"respond_to?",
"(",
":filters",
")",
"base",
".",
"filters",
"[",
"type",
"]",
".",
"each",
"{",
... | Run filters defined on the class and all superclasses. | [
"Run",
"filters",
"defined",
"on",
"the",
"class",
"and",
"all",
"superclasses",
"."
] | 9116c90fcbb82ac03b4b33c58cfbde1fcf745e99 | https://github.com/github/linguist/blob/9116c90fcbb82ac03b4b33c58cfbde1fcf745e99/samples/Ruby/sinatra.rb#L831-L834 |
10,695 | github/linguist | samples/Ruby/sinatra.rb | Sinatra.Base.route! | def route!(base = settings, pass_block=nil)
if routes = base.routes[@request.request_method]
routes.each do |pattern, keys, conditions, block|
pass_block = process_route(pattern, keys, conditions) do |*args|
route_eval { block[*args] }
end
end
end
# Run... | ruby | def route!(base = settings, pass_block=nil)
if routes = base.routes[@request.request_method]
routes.each do |pattern, keys, conditions, block|
pass_block = process_route(pattern, keys, conditions) do |*args|
route_eval { block[*args] }
end
end
end
# Run... | [
"def",
"route!",
"(",
"base",
"=",
"settings",
",",
"pass_block",
"=",
"nil",
")",
"if",
"routes",
"=",
"base",
".",
"routes",
"[",
"@request",
".",
"request_method",
"]",
"routes",
".",
"each",
"do",
"|",
"pattern",
",",
"keys",
",",
"conditions",
","... | Run routes defined on the class and all superclasses. | [
"Run",
"routes",
"defined",
"on",
"the",
"class",
"and",
"all",
"superclasses",
"."
] | 9116c90fcbb82ac03b4b33c58cfbde1fcf745e99 | https://github.com/github/linguist/blob/9116c90fcbb82ac03b4b33c58cfbde1fcf745e99/samples/Ruby/sinatra.rb#L837-L853 |
10,696 | github/linguist | samples/Ruby/sinatra.rb | Sinatra.Base.indifferent_hash | def indifferent_hash
Hash.new {|hash,key| hash[key.to_s] if Symbol === key }
end | ruby | def indifferent_hash
Hash.new {|hash,key| hash[key.to_s] if Symbol === key }
end | [
"def",
"indifferent_hash",
"Hash",
".",
"new",
"{",
"|",
"hash",
",",
"key",
"|",
"hash",
"[",
"key",
".",
"to_s",
"]",
"if",
"Symbol",
"===",
"key",
"}",
"end"
] | Creates a Hash with indifferent access. | [
"Creates",
"a",
"Hash",
"with",
"indifferent",
"access",
"."
] | 9116c90fcbb82ac03b4b33c58cfbde1fcf745e99 | https://github.com/github/linguist/blob/9116c90fcbb82ac03b4b33c58cfbde1fcf745e99/samples/Ruby/sinatra.rb#L926-L928 |
10,697 | github/linguist | samples/Ruby/racc.rb | RJSON.Parser._reduce_22 | def _reduce_22(val, _values, result)
n = val[0]; result = n.count('.') > 0 ? n.to_f : n.to_i
result
end | ruby | def _reduce_22(val, _values, result)
n = val[0]; result = n.count('.') > 0 ? n.to_f : n.to_i
result
end | [
"def",
"_reduce_22",
"(",
"val",
",",
"_values",
",",
"result",
")",
"n",
"=",
"val",
"[",
"0",
"]",
";",
"result",
"=",
"n",
".",
"count",
"(",
"'.'",
")",
">",
"0",
"?",
"n",
".",
"to_f",
":",
"n",
".",
"to_i",
"result",
"end"
] | reduce 21 omitted | [
"reduce",
"21",
"omitted"
] | 9116c90fcbb82ac03b4b33c58cfbde1fcf745e99 | https://github.com/github/linguist/blob/9116c90fcbb82ac03b4b33c58cfbde1fcf745e99/samples/Ruby/racc.rb#L237-L240 |
10,698 | fluent/fluentd | lib/fluent/supervisor.rb | Fluent.Supervisor.dry_run | def dry_run
begin
Fluent::Engine.dry_run_mode = true
change_privilege
init_engine
run_configure
rescue Fluent::ConfigError => e
$log.error "config error", file: @config_path, error: e
$log.debug_backtrace
exit!(1)
ensure
Fluent::Engine.dr... | ruby | def dry_run
begin
Fluent::Engine.dry_run_mode = true
change_privilege
init_engine
run_configure
rescue Fluent::ConfigError => e
$log.error "config error", file: @config_path, error: e
$log.debug_backtrace
exit!(1)
ensure
Fluent::Engine.dr... | [
"def",
"dry_run",
"begin",
"Fluent",
"::",
"Engine",
".",
"dry_run_mode",
"=",
"true",
"change_privilege",
"init_engine",
"run_configure",
"rescue",
"Fluent",
"::",
"ConfigError",
"=>",
"e",
"$log",
".",
"error",
"\"config error\"",
",",
"file",
":",
"@config_path... | Set Engine's dry_run_mode true to override all target_id of worker sections | [
"Set",
"Engine",
"s",
"dry_run_mode",
"true",
"to",
"override",
"all",
"target_id",
"of",
"worker",
"sections"
] | add2af9a5b7f74fc36957b8e6138b3c5a2871a92 | https://github.com/fluent/fluentd/blob/add2af9a5b7f74fc36957b8e6138b3c5a2871a92/lib/fluent/supervisor.rb#L574-L587 |
10,699 | fluent/fluentd | lib/fluent/event.rb | Fluent.MessagePackEventStream.slice | def slice(index, num)
ensure_unpacked!
MultiEventStream.new(@unpacked_times.slice(index, num), @unpacked_records.slice(index, num))
end | ruby | def slice(index, num)
ensure_unpacked!
MultiEventStream.new(@unpacked_times.slice(index, num), @unpacked_records.slice(index, num))
end | [
"def",
"slice",
"(",
"index",
",",
"num",
")",
"ensure_unpacked!",
"MultiEventStream",
".",
"new",
"(",
"@unpacked_times",
".",
"slice",
"(",
"index",
",",
"num",
")",
",",
"@unpacked_records",
".",
"slice",
"(",
"index",
",",
"num",
")",
")",
"end"
] | This method returns MultiEventStream, because there are no reason
to surve binary serialized by msgpack. | [
"This",
"method",
"returns",
"MultiEventStream",
"because",
"there",
"are",
"no",
"reason",
"to",
"surve",
"binary",
"serialized",
"by",
"msgpack",
"."
] | add2af9a5b7f74fc36957b8e6138b3c5a2871a92 | https://github.com/fluent/fluentd/blob/add2af9a5b7f74fc36957b8e6138b3c5a2871a92/lib/fluent/event.rb#L248-L251 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.