repo
stringlengths
5
58
path
stringlengths
9
168
func_name
stringlengths
9
130
original_string
stringlengths
66
10.5k
language
stringclasses
1 value
code
stringlengths
66
10.5k
code_tokens
list
docstring
stringlengths
8
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
94
266
partition
stringclasses
1 value
fastlane/fastlane
sigh/lib/sigh/runner.rb
Sigh.Runner.create_profile!
def create_profile! cert = certificate_to_use bundle_id = Sigh.config[:app_identifier] name = Sigh.config[:provisioning_name] || [bundle_id, profile_type.pretty_type].join(' ') unless Sigh.config[:skip_fetch_profiles] if Spaceship.provisioning_profile.all.find { |p| p.name == name } ...
ruby
def create_profile! cert = certificate_to_use bundle_id = Sigh.config[:app_identifier] name = Sigh.config[:provisioning_name] || [bundle_id, profile_type.pretty_type].join(' ') unless Sigh.config[:skip_fetch_profiles] if Spaceship.provisioning_profile.all.find { |p| p.name == name } ...
[ "def", "create_profile!", "cert", "=", "certificate_to_use", "bundle_id", "=", "Sigh", ".", "config", "[", ":app_identifier", "]", "name", "=", "Sigh", ".", "config", "[", ":provisioning_name", "]", "||", "[", "bundle_id", ",", "profile_type", ".", "pretty_type"...
Create a new profile and return it
[ "Create", "a", "new", "profile", "and", "return", "it" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/sigh/lib/sigh/runner.rb#L122-L142
train
fastlane/fastlane
sigh/lib/sigh/runner.rb
Sigh.Runner.certificate_to_use
def certificate_to_use certificates = certificates_for_profile_and_platform # Filter them certificates = certificates.find_all do |c| if Sigh.config[:cert_id] next unless c.id == Sigh.config[:cert_id].strip end if Sigh.config[:cert_owner_name] next unless ...
ruby
def certificate_to_use certificates = certificates_for_profile_and_platform # Filter them certificates = certificates.find_all do |c| if Sigh.config[:cert_id] next unless c.id == Sigh.config[:cert_id].strip end if Sigh.config[:cert_owner_name] next unless ...
[ "def", "certificate_to_use", "certificates", "=", "certificates_for_profile_and_platform", "# Filter them", "certificates", "=", "certificates", ".", "find_all", "do", "|", "c", "|", "if", "Sigh", ".", "config", "[", ":cert_id", "]", "next", "unless", "c", ".", "i...
Certificate to use based on the current distribution mode
[ "Certificate", "to", "use", "based", "on", "the", "current", "distribution", "mode" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/sigh/lib/sigh/runner.rb#L186-L237
train
fastlane/fastlane
sigh/lib/sigh/runner.rb
Sigh.Runner.download_profile
def download_profile(profile) UI.important("Downloading provisioning profile...") profile_name ||= "#{profile_type.pretty_type}_#{Sigh.config[:app_identifier]}" if Sigh.config[:platform].to_s == 'tvos' profile_name += "_tvos" end if Sigh.config[:platform].to_s == 'macos' ...
ruby
def download_profile(profile) UI.important("Downloading provisioning profile...") profile_name ||= "#{profile_type.pretty_type}_#{Sigh.config[:app_identifier]}" if Sigh.config[:platform].to_s == 'tvos' profile_name += "_tvos" end if Sigh.config[:platform].to_s == 'macos' ...
[ "def", "download_profile", "(", "profile", ")", "UI", ".", "important", "(", "\"Downloading provisioning profile...\"", ")", "profile_name", "||=", "\"#{profile_type.pretty_type}_#{Sigh.config[:app_identifier]}\"", "if", "Sigh", ".", "config", "[", ":platform", "]", ".", ...
Downloads and stores the provisioning profile
[ "Downloads", "and", "stores", "the", "provisioning", "profile" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/sigh/lib/sigh/runner.rb#L240-L262
train
fastlane/fastlane
sigh/lib/sigh/runner.rb
Sigh.Runner.ensure_app_exists!
def ensure_app_exists! return if Spaceship::App.find(Sigh.config[:app_identifier], mac: Sigh.config[:platform].to_s == 'macos') print_produce_command(Sigh.config) UI.user_error!("Could not find App with App Identifier '#{Sigh.config[:app_identifier]}'") end
ruby
def ensure_app_exists! return if Spaceship::App.find(Sigh.config[:app_identifier], mac: Sigh.config[:platform].to_s == 'macos') print_produce_command(Sigh.config) UI.user_error!("Could not find App with App Identifier '#{Sigh.config[:app_identifier]}'") end
[ "def", "ensure_app_exists!", "return", "if", "Spaceship", "::", "App", ".", "find", "(", "Sigh", ".", "config", "[", ":app_identifier", "]", ",", "mac", ":", "Sigh", ".", "config", "[", ":platform", "]", ".", "to_s", "==", "'macos'", ")", "print_produce_co...
Makes sure the current App ID exists. If not, it will show an appropriate error message
[ "Makes", "sure", "the", "current", "App", "ID", "exists", ".", "If", "not", "it", "will", "show", "an", "appropriate", "error", "message" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/sigh/lib/sigh/runner.rb#L265-L269
train
fastlane/fastlane
sigh/lib/sigh/download_all.rb
Sigh.DownloadAll.download_all
def download_all(download_xcode_profiles: false) UI.message("Starting login with user '#{Sigh.config[:username]}'") Spaceship.login(Sigh.config[:username], nil) Spaceship.select_team UI.message("Successfully logged in") Spaceship.provisioning_profile.all(xcode: download_xcode_profiles).ea...
ruby
def download_all(download_xcode_profiles: false) UI.message("Starting login with user '#{Sigh.config[:username]}'") Spaceship.login(Sigh.config[:username], nil) Spaceship.select_team UI.message("Successfully logged in") Spaceship.provisioning_profile.all(xcode: download_xcode_profiles).ea...
[ "def", "download_all", "(", "download_xcode_profiles", ":", "false", ")", "UI", ".", "message", "(", "\"Starting login with user '#{Sigh.config[:username]}'\"", ")", "Spaceship", ".", "login", "(", "Sigh", ".", "config", "[", ":username", "]", ",", "nil", ")", "Sp...
Download all valid provisioning profiles
[ "Download", "all", "valid", "provisioning", "profiles" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/sigh/lib/sigh/download_all.rb#L9-L29
train
fastlane/fastlane
fastlane/lib/fastlane/server/socket_server.rb
Fastlane.SocketServer.handle_control_command
def handle_control_command(command) exit_reason = nil if command.cancel_signal? UI.verbose("received cancel signal shutting down, reason: #{command.reason}") # send an ack to the client to let it know we're shutting down cancel_response = '{"payload":{"status":"cancelled"}}' ...
ruby
def handle_control_command(command) exit_reason = nil if command.cancel_signal? UI.verbose("received cancel signal shutting down, reason: #{command.reason}") # send an ack to the client to let it know we're shutting down cancel_response = '{"payload":{"status":"cancelled"}}' ...
[ "def", "handle_control_command", "(", "command", ")", "exit_reason", "=", "nil", "if", "command", ".", "cancel_signal?", "UI", ".", "verbose", "(", "\"received cancel signal shutting down, reason: #{command.reason}\"", ")", "# send an ack to the client to let it know we're shutti...
we got a server control command from the client to do something like shutdown
[ "we", "got", "a", "server", "control", "command", "from", "the", "client", "to", "do", "something", "like", "shutdown" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/fastlane/lib/fastlane/server/socket_server.rb#L94-L119
train
fastlane/fastlane
fastlane/lib/fastlane/server/socket_server.rb
Fastlane.SocketServer.send_response
def send_response(json) UI.verbose("sending #{json}") begin @client.puts(json) # Send some json to the client rescue Errno::EPIPE => e UI.verbose(e) return COMMAND_EXECUTION_STATE[:error] end return COMMAND_EXECUTION_STATE[:ready] end
ruby
def send_response(json) UI.verbose("sending #{json}") begin @client.puts(json) # Send some json to the client rescue Errno::EPIPE => e UI.verbose(e) return COMMAND_EXECUTION_STATE[:error] end return COMMAND_EXECUTION_STATE[:ready] end
[ "def", "send_response", "(", "json", ")", "UI", ".", "verbose", "(", "\"sending #{json}\"", ")", "begin", "@client", ".", "puts", "(", "json", ")", "# Send some json to the client", "rescue", "Errno", "::", "EPIPE", "=>", "e", "UI", ".", "verbose", "(", "e",...
send json back to client
[ "send", "json", "back", "to", "client" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/fastlane/lib/fastlane/server/socket_server.rb#L128-L137
train
fastlane/fastlane
fastlane/lib/fastlane/server/socket_server.rb
Fastlane.SocketServer.execute_action_command
def execute_action_command(command: nil) command_return = @command_executor.execute(command: command, target_object: nil) ## probably need to just return Strings, or ready_for_next with object isn't String return_object = command_return.return_value return_value_type = command_return.return_valu...
ruby
def execute_action_command(command: nil) command_return = @command_executor.execute(command: command, target_object: nil) ## probably need to just return Strings, or ready_for_next with object isn't String return_object = command_return.return_value return_value_type = command_return.return_valu...
[ "def", "execute_action_command", "(", "command", ":", "nil", ")", "command_return", "=", "@command_executor", ".", "execute", "(", "command", ":", "command", ",", "target_object", ":", "nil", ")", "## probably need to just return Strings, or ready_for_next with object isn't...
execute fastlane action command
[ "execute", "fastlane", "action", "command" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/fastlane/lib/fastlane/server/socket_server.rb#L180-L230
train
fastlane/fastlane
fastlane_core/lib/fastlane_core/project.rb
FastlaneCore.Project.schemes
def schemes @schemes ||= if workspace? workspace.schemes.reject do |k, v| v.include?("Pods/Pods.xcodeproj") end.keys else Xcodeproj::Project.schemes(path) end end
ruby
def schemes @schemes ||= if workspace? workspace.schemes.reject do |k, v| v.include?("Pods/Pods.xcodeproj") end.keys else Xcodeproj::Project.schemes(path) end end
[ "def", "schemes", "@schemes", "||=", "if", "workspace?", "workspace", ".", "schemes", ".", "reject", "do", "|", "k", ",", "v", "|", "v", ".", "include?", "(", "\"Pods/Pods.xcodeproj\"", ")", "end", ".", "keys", "else", "Xcodeproj", "::", "Project", ".", ...
Get all available schemes in an array
[ "Get", "all", "available", "schemes", "in", "an", "array" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/fastlane_core/lib/fastlane_core/project.rb#L118-L126
train
fastlane/fastlane
fastlane_core/lib/fastlane_core/project.rb
FastlaneCore.Project.select_scheme
def select_scheme(preferred_to_include: nil) if options[:scheme].to_s.length > 0 # Verify the scheme is available unless schemes.include?(options[:scheme].to_s) UI.error("Couldn't find specified scheme '#{options[:scheme]}'. Please make sure that the scheme is shared, see https://develop...
ruby
def select_scheme(preferred_to_include: nil) if options[:scheme].to_s.length > 0 # Verify the scheme is available unless schemes.include?(options[:scheme].to_s) UI.error("Couldn't find specified scheme '#{options[:scheme]}'. Please make sure that the scheme is shared, see https://develop...
[ "def", "select_scheme", "(", "preferred_to_include", ":", "nil", ")", "if", "options", "[", ":scheme", "]", ".", "to_s", ".", "length", ">", "0", "# Verify the scheme is available", "unless", "schemes", ".", "include?", "(", "options", "[", ":scheme", "]", "."...
Let the user select a scheme Use a scheme containing the preferred_to_include string when multiple schemes were found
[ "Let", "the", "user", "select", "a", "scheme", "Use", "a", "scheme", "containing", "the", "preferred_to_include", "string", "when", "multiple", "schemes", "were", "found" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/fastlane_core/lib/fastlane_core/project.rb#L130-L168
train
fastlane/fastlane
fastlane_core/lib/fastlane_core/project.rb
FastlaneCore.Project.configurations
def configurations @configurations ||= if workspace? workspace .file_references .map(&:path) .reject { |p| p.include?("Pods/Pods.xcodeproj") } .map do |p| ...
ruby
def configurations @configurations ||= if workspace? workspace .file_references .map(&:path) .reject { |p| p.include?("Pods/Pods.xcodeproj") } .map do |p| ...
[ "def", "configurations", "@configurations", "||=", "if", "workspace?", "workspace", ".", "file_references", ".", "map", "(", ":path", ")", ".", "reject", "{", "|", "p", "|", "p", ".", "include?", "(", "\"Pods/Pods.xcodeproj\"", ")", "}", ".", "map", "do", ...
Get all available configurations in an array
[ "Get", "all", "available", "configurations", "in", "an", "array" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/fastlane_core/lib/fastlane_core/project.rb#L177-L199
train
fastlane/fastlane
fastlane_core/lib/fastlane_core/project.rb
FastlaneCore.Project.default_build_settings
def default_build_settings(key: nil, optional: true) options[:scheme] ||= schemes.first if is_workspace build_settings(key: key, optional: optional) end
ruby
def default_build_settings(key: nil, optional: true) options[:scheme] ||= schemes.first if is_workspace build_settings(key: key, optional: optional) end
[ "def", "default_build_settings", "(", "key", ":", "nil", ",", "optional", ":", "true", ")", "options", "[", ":scheme", "]", "||=", "schemes", ".", "first", "if", "is_workspace", "build_settings", "(", "key", ":", "key", ",", "optional", ":", "optional", ")...
Returns the build settings and sets the default scheme to the options hash
[ "Returns", "the", "build", "settings", "and", "sets", "the", "default", "scheme", "to", "the", "options", "hash" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/fastlane_core/lib/fastlane_core/project.rb#L385-L388
train
fastlane/fastlane
match/lib/match/nuke.rb
Match.Nuke.print_tables
def print_tables puts("") if self.certs.count > 0 rows = self.certs.collect do |cert| cert_expiration = cert.expires.nil? ? "Unknown" : cert.expires.strftime("%Y-%m-%d") [cert.name, cert.id, cert.class.to_s.split("::").last, cert_expiration] end puts(Terminal::Tab...
ruby
def print_tables puts("") if self.certs.count > 0 rows = self.certs.collect do |cert| cert_expiration = cert.expires.nil? ? "Unknown" : cert.expires.strftime("%Y-%m-%d") [cert.name, cert.id, cert.class.to_s.split("::").last, cert_expiration] end puts(Terminal::Tab...
[ "def", "print_tables", "puts", "(", "\"\"", ")", "if", "self", ".", "certs", ".", "count", ">", "0", "rows", "=", "self", ".", "certs", ".", "collect", "do", "|", "cert", "|", "cert_expiration", "=", "cert", ".", "expires", ".", "nil?", "?", "\"Unkno...
Print tables to ask the user
[ "Print", "tables", "to", "ask", "the", "user" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/match/lib/match/nuke.rb#L132-L180
train
fastlane/fastlane
deliver/lib/deliver/upload_metadata.rb
Deliver.UploadMetadata.upload
def upload(options) return if options[:skip_metadata] # it is not possible to create new languages, because # :keywords is not write-able on published versions # therefore skip it. verify_available_languages!(options) unless options[:edit_live] app = options[:app] details = a...
ruby
def upload(options) return if options[:skip_metadata] # it is not possible to create new languages, because # :keywords is not write-able on published versions # therefore skip it. verify_available_languages!(options) unless options[:edit_live] app = options[:app] details = a...
[ "def", "upload", "(", "options", ")", "return", "if", "options", "[", ":skip_metadata", "]", "# it is not possible to create new languages, because", "# :keywords is not write-able on published versions", "# therefore skip it.", "verify_available_languages!", "(", "options", ")", ...
Make sure to call `load_from_filesystem` before calling upload
[ "Make", "sure", "to", "call", "load_from_filesystem", "before", "calling", "upload" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/deliver/lib/deliver/upload_metadata.rb#L67-L152
train
fastlane/fastlane
deliver/lib/deliver/upload_metadata.rb
Deliver.UploadMetadata.upload_individual_item
def upload_individual_item(app, version, language, key, value) details = app.details version.send(key)[language] = value if LOCALISED_VERSION_VALUES.include?(key) details.send(key)[language] = value if LOCALISED_APP_VALUES.include?(key) Helper.show_loading_indicator("Uploading #{language} #{key}...
ruby
def upload_individual_item(app, version, language, key, value) details = app.details version.send(key)[language] = value if LOCALISED_VERSION_VALUES.include?(key) details.send(key)[language] = value if LOCALISED_APP_VALUES.include?(key) Helper.show_loading_indicator("Uploading #{language} #{key}...
[ "def", "upload_individual_item", "(", "app", ",", "version", ",", "language", ",", "key", ",", "value", ")", "details", "=", "app", ".", "details", "version", ".", "send", "(", "key", ")", "[", "language", "]", "=", "value", "if", "LOCALISED_VERSION_VALUES...
Uploads metadata individually by language to help identify exactly which items have issues
[ "Uploads", "metadata", "individually", "by", "language", "to", "help", "identify", "exactly", "which", "items", "have", "issues" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/deliver/lib/deliver/upload_metadata.rb#L155-L169
train
fastlane/fastlane
deliver/lib/deliver/upload_metadata.rb
Deliver.UploadMetadata.verify_available_languages!
def verify_available_languages!(options) return if options[:skip_metadata] # Collect all languages we need # We only care about languages from user provided values # as the other languages are on iTC already anyway v = options[:app].edit_version(platform: options[:platform]) UI.user...
ruby
def verify_available_languages!(options) return if options[:skip_metadata] # Collect all languages we need # We only care about languages from user provided values # as the other languages are on iTC already anyway v = options[:app].edit_version(platform: options[:platform]) UI.user...
[ "def", "verify_available_languages!", "(", "options", ")", "return", "if", "options", "[", ":skip_metadata", "]", "# Collect all languages we need", "# We only care about languages from user provided values", "# as the other languages are on iTC already anyway", "v", "=", "options", ...
Makes sure all languages we need are actually created
[ "Makes", "sure", "all", "languages", "we", "need", "are", "actually", "created" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/deliver/lib/deliver/upload_metadata.rb#L247-L281
train
fastlane/fastlane
deliver/lib/deliver/upload_metadata.rb
Deliver.UploadMetadata.load_from_filesystem
def load_from_filesystem(options) return if options[:skip_metadata] # Load localised data ignore_validation = options[:ignore_language_directory_validation] Loader.language_folders(options[:metadata_path], ignore_validation).each do |lang_folder| language = File.basename(lang_folder) ...
ruby
def load_from_filesystem(options) return if options[:skip_metadata] # Load localised data ignore_validation = options[:ignore_language_directory_validation] Loader.language_folders(options[:metadata_path], ignore_validation).each do |lang_folder| language = File.basename(lang_folder) ...
[ "def", "load_from_filesystem", "(", "options", ")", "return", "if", "options", "[", ":skip_metadata", "]", "# Load localised data", "ignore_validation", "=", "options", "[", ":ignore_language_directory_validation", "]", "Loader", ".", "language_folders", "(", "options", ...
Loads the metadata files and stores them into the options object
[ "Loads", "the", "metadata", "files", "and", "stores", "them", "into", "the", "options", "object" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/deliver/lib/deliver/upload_metadata.rb#L284-L331
train
fastlane/fastlane
deliver/lib/deliver/upload_metadata.rb
Deliver.UploadMetadata.normalize_language_keys
def normalize_language_keys(options) (LOCALISED_VERSION_VALUES + LOCALISED_APP_VALUES).each do |key| current = options[key] next unless current && current.kind_of?(Hash) current.keys.each do |language| current[language.to_s] = current.delete(language) end end ...
ruby
def normalize_language_keys(options) (LOCALISED_VERSION_VALUES + LOCALISED_APP_VALUES).each do |key| current = options[key] next unless current && current.kind_of?(Hash) current.keys.each do |language| current[language.to_s] = current.delete(language) end end ...
[ "def", "normalize_language_keys", "(", "options", ")", "(", "LOCALISED_VERSION_VALUES", "+", "LOCALISED_APP_VALUES", ")", ".", "each", "do", "|", "key", "|", "current", "=", "options", "[", "key", "]", "next", "unless", "current", "&&", "current", ".", "kind_o...
Normalizes languages keys from symbols to strings
[ "Normalizes", "languages", "keys", "from", "symbols", "to", "strings" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/deliver/lib/deliver/upload_metadata.rb#L336-L347
train
fastlane/fastlane
spaceship/lib/spaceship/du/utilities.rb
Spaceship.Utilities.resolution
def resolution(path) return FastImage.size(path) if content_type(path).start_with?("image") return video_resolution(path) if content_type(path).start_with?("video") raise "Cannot find resolution of file #{path}" end
ruby
def resolution(path) return FastImage.size(path) if content_type(path).start_with?("image") return video_resolution(path) if content_type(path).start_with?("video") raise "Cannot find resolution of file #{path}" end
[ "def", "resolution", "(", "path", ")", "return", "FastImage", ".", "size", "(", "path", ")", "if", "content_type", "(", "path", ")", ".", "start_with?", "(", "\"image\"", ")", "return", "video_resolution", "(", "path", ")", "if", "content_type", "(", "path...
Identifies the resolution of a video or an image. Supports all video and images required by DU-UTC right now @param path (String) the path to the file
[ "Identifies", "the", "resolution", "of", "a", "video", "or", "an", "image", ".", "Supports", "all", "video", "and", "images", "required", "by", "DU", "-", "UTC", "right", "now" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/spaceship/lib/spaceship/du/utilities.rb#L25-L29
train
fastlane/fastlane
fastlane/lib/fastlane/server/socket_server_action_command_executor.rb
Fastlane.SocketServerActionCommandExecutor.run_action_requiring_special_handling
def run_action_requiring_special_handling(command: nil, parameter_map: nil, action_return_type: nil) action_return = nil closure_argument_value = nil # only used if the action uses it case command.method_name when "sh" error_callback = proc { |string_value| closure_argument_value = stri...
ruby
def run_action_requiring_special_handling(command: nil, parameter_map: nil, action_return_type: nil) action_return = nil closure_argument_value = nil # only used if the action uses it case command.method_name when "sh" error_callback = proc { |string_value| closure_argument_value = stri...
[ "def", "run_action_requiring_special_handling", "(", "command", ":", "nil", ",", "parameter_map", ":", "nil", ",", "action_return_type", ":", "nil", ")", "action_return", "=", "nil", "closure_argument_value", "=", "nil", "# only used if the action uses it", "case", "com...
Some actions have special handling in fast_file.rb, that means we can't directly call the action but we have to use the same logic that is in fast_file.rb instead. That's where this switch statement comes into play
[ "Some", "actions", "have", "special", "handling", "in", "fast_file", ".", "rb", "that", "means", "we", "can", "t", "directly", "call", "the", "action", "but", "we", "have", "to", "use", "the", "same", "logic", "that", "is", "in", "fast_file", ".", "rb", ...
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/fastlane/lib/fastlane/server/socket_server_action_command_executor.rb#L80-L99
train
fastlane/fastlane
gym/lib/gym/runner.rb
Gym.Runner.build_app
def build_app command = BuildCommandGenerator.generate print_command(command, "Generated Build Command") if FastlaneCore::Globals.verbose? FastlaneCore::CommandExecutor.execute(command: command, print_all: true, print_comm...
ruby
def build_app command = BuildCommandGenerator.generate print_command(command, "Generated Build Command") if FastlaneCore::Globals.verbose? FastlaneCore::CommandExecutor.execute(command: command, print_all: true, print_comm...
[ "def", "build_app", "command", "=", "BuildCommandGenerator", ".", "generate", "print_command", "(", "command", ",", "\"Generated Build Command\"", ")", "if", "FastlaneCore", "::", "Globals", ".", "verbose?", "FastlaneCore", "::", "CommandExecutor", ".", "execute", "("...
Builds the app and prepares the archive
[ "Builds", "the", "app", "and", "prepares", "the", "archive" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/gym/lib/gym/runner.rb#L90-L105
train
fastlane/fastlane
gym/lib/gym/runner.rb
Gym.Runner.post_build_app
def post_build_app command = BuildCommandGenerator.post_build return if command.empty? print_command(command, "Generated Post-Build Command") if FastlaneCore::Globals.verbose? FastlaneCore::CommandExecutor.execute(command: command, print_all: true, ...
ruby
def post_build_app command = BuildCommandGenerator.post_build return if command.empty? print_command(command, "Generated Post-Build Command") if FastlaneCore::Globals.verbose? FastlaneCore::CommandExecutor.execute(command: command, print_all: true, ...
[ "def", "post_build_app", "command", "=", "BuildCommandGenerator", ".", "post_build", "return", "if", "command", ".", "empty?", "print_command", "(", "command", ",", "\"Generated Post-Build Command\"", ")", "if", "FastlaneCore", "::", "Globals", ".", "verbose?", "Fastl...
Post-processing of build_app
[ "Post", "-", "processing", "of", "build_app" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/gym/lib/gym/runner.rb#L108-L120
train
fastlane/fastlane
gym/lib/gym/runner.rb
Gym.Runner.move_ipa
def move_ipa FileUtils.mv(PackageCommandGenerator.ipa_path, File.expand_path(Gym.config[:output_directory]), force: true) ipa_path = File.expand_path(File.join(Gym.config[:output_directory], File.basename(PackageCommandGenerator.ipa_path))) UI.success("Successfully exported and signed the ipa file:")...
ruby
def move_ipa FileUtils.mv(PackageCommandGenerator.ipa_path, File.expand_path(Gym.config[:output_directory]), force: true) ipa_path = File.expand_path(File.join(Gym.config[:output_directory], File.basename(PackageCommandGenerator.ipa_path))) UI.success("Successfully exported and signed the ipa file:")...
[ "def", "move_ipa", "FileUtils", ".", "mv", "(", "PackageCommandGenerator", ".", "ipa_path", ",", "File", ".", "expand_path", "(", "Gym", ".", "config", "[", ":output_directory", "]", ")", ",", "force", ":", "true", ")", "ipa_path", "=", "File", ".", "expan...
Moves over the binary and dsym file to the output directory @return (String) The path to the resulting ipa file
[ "Moves", "over", "the", "binary", "and", "dsym", "file", "to", "the", "output", "directory" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/gym/lib/gym/runner.rb#L173-L180
train
fastlane/fastlane
gym/lib/gym/runner.rb
Gym.Runner.copy_mac_app
def copy_mac_app exe_name = Gym.project.build_settings(key: "EXECUTABLE_NAME") app_path = File.join(BuildCommandGenerator.archive_path, "Products/Applications/#{exe_name}.app") UI.crash!("Couldn't find application in '#{BuildCommandGenerator.archive_path}'") unless File.exist?(app_path) FileUtil...
ruby
def copy_mac_app exe_name = Gym.project.build_settings(key: "EXECUTABLE_NAME") app_path = File.join(BuildCommandGenerator.archive_path, "Products/Applications/#{exe_name}.app") UI.crash!("Couldn't find application in '#{BuildCommandGenerator.archive_path}'") unless File.exist?(app_path) FileUtil...
[ "def", "copy_mac_app", "exe_name", "=", "Gym", ".", "project", ".", "build_settings", "(", "key", ":", "\"EXECUTABLE_NAME\"", ")", "app_path", "=", "File", ".", "join", "(", "BuildCommandGenerator", ".", "archive_path", ",", "\"Products/Applications/#{exe_name}.app\""...
Copies the .app from the archive into the output directory
[ "Copies", "the", ".", "app", "from", "the", "archive", "into", "the", "output", "directory" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/gym/lib/gym/runner.rb#L201-L210
train
fastlane/fastlane
gym/lib/gym/runner.rb
Gym.Runner.move_manifest
def move_manifest if File.exist?(PackageCommandGenerator.manifest_path) FileUtils.mv(PackageCommandGenerator.manifest_path, File.expand_path(Gym.config[:output_directory]), force: true) manifest_path = File.join(File.expand_path(Gym.config[:output_directory]), File.basename(PackageCommandGenerator...
ruby
def move_manifest if File.exist?(PackageCommandGenerator.manifest_path) FileUtils.mv(PackageCommandGenerator.manifest_path, File.expand_path(Gym.config[:output_directory]), force: true) manifest_path = File.join(File.expand_path(Gym.config[:output_directory]), File.basename(PackageCommandGenerator...
[ "def", "move_manifest", "if", "File", ".", "exist?", "(", "PackageCommandGenerator", ".", "manifest_path", ")", "FileUtils", ".", "mv", "(", "PackageCommandGenerator", ".", "manifest_path", ",", "File", ".", "expand_path", "(", "Gym", ".", "config", "[", ":outpu...
Move the manifest.plist if exists into the output directory
[ "Move", "the", "manifest", ".", "plist", "if", "exists", "into", "the", "output", "directory" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/gym/lib/gym/runner.rb#L213-L222
train
fastlane/fastlane
gym/lib/gym/runner.rb
Gym.Runner.move_app_thinning
def move_app_thinning if File.exist?(PackageCommandGenerator.app_thinning_path) FileUtils.mv(PackageCommandGenerator.app_thinning_path, File.expand_path(Gym.config[:output_directory]), force: true) app_thinning_path = File.join(File.expand_path(Gym.config[:output_directory]), File.basename(Package...
ruby
def move_app_thinning if File.exist?(PackageCommandGenerator.app_thinning_path) FileUtils.mv(PackageCommandGenerator.app_thinning_path, File.expand_path(Gym.config[:output_directory]), force: true) app_thinning_path = File.join(File.expand_path(Gym.config[:output_directory]), File.basename(Package...
[ "def", "move_app_thinning", "if", "File", ".", "exist?", "(", "PackageCommandGenerator", ".", "app_thinning_path", ")", "FileUtils", ".", "mv", "(", "PackageCommandGenerator", ".", "app_thinning_path", ",", "File", ".", "expand_path", "(", "Gym", ".", "config", "[...
Move the app-thinning.plist file into the output directory
[ "Move", "the", "app", "-", "thinning", ".", "plist", "file", "into", "the", "output", "directory" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/gym/lib/gym/runner.rb#L225-L234
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train