_id stringlengths 2 6 | title stringlengths 9 130 | partition stringclasses 3
values | text stringlengths 66 10.5k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q10600 | Gym.Runner.move_app_thinning_size_report | train | 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 | {
"resource": ""
} |
q10601 | Gym.Runner.move_apps_folder | train | 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 | {
"resource": ""
} |
q10602 | Fastlane.SwiftFastlaneAPIGenerator.determine_api_version | train | 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 | {
"resource": ""
} |
q10603 | Fastlane.SwiftFastlaneAPIGenerator.increment_api_version_string | train | 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 | {
"resource": ""
} |
q10604 | CredentialsManager.AppfileConfig.for_lane | train | 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 | {
"resource": ""
} |
q10605 | Fastlane.SwiftRunnerUpgrader.file_needs_update? | train | 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 | {
"resource": ""
} |
q10606 | Fastlane.SwiftRunnerUpgrader.copy_file_if_needed! | train | 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 | {
"resource": ""
} |
q10607 | Thrift.ThreadPoolServer.serve | train | 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 | {
"resource": ""
} |
q10608 | Thrift.JsonProtocol.write_json_char | train | 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 | {
"resource": ""
} |
q10609 | Thrift.JsonProtocol.write_json_string | train | 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 | {
"resource": ""
} |
q10610 | Thrift.JsonProtocol.write_json_base64 | train | def write_json_base64(str)
@context.write(trans)
trans.write(@@kJSONStringDelimiter)
trans.write(Base64.strict_encode64(str))
trans.write(@@kJSONStringDelimiter)
end | ruby | {
"resource": ""
} |
q10611 | Thrift.JsonProtocol.write_json_double | train | 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 | {
"resource": ""
} |
q10612 | Thrift.JsonProtocol.read_json_escape_char | train | 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 | {
"resource": ""
} |
q10613 | Thrift.JsonProtocol.read_json_string | train | 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 | {
"resource": ""
} |
q10614 | Thrift.JsonProtocol.read_json_base64 | train | 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 | {
"resource": ""
} |
q10615 | Thrift.JsonProtocol.read_json_numeric_chars | train | 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 | {
"resource": ""
} |
q10616 | Thrift.JsonProtocol.read_json_integer | train | 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 | {
"resource": ""
} |
q10617 | Thrift.JsonProtocol.read_json_double | train | 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 | {
"resource": ""
} |
q10618 | Thrift.BaseProtocol.write_field | train | 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 | {
"resource": ""
} |
q10619 | Thrift.BaseProtocol.write_type | train | 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 | {
"resource": ""
} |
q10620 | Thrift.BaseProtocol.read_type | train | 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 | {
"resource": ""
} |
q10621 | Thrift.CompactProtocol.write_field_begin_internal | train | 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 | {
"resource": ""
} |
q10622 | Thrift.CompactProtocol.write_collection_begin | train | 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 | {
"resource": ""
} |
q10623 | Thrift.BufferedTransport.read_into_buffer | train | 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 | {
"resource": ""
} |
q10624 | Server.BenchmarkHandler.fibonacci | train | 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 | {
"resource": ""
} |
q10625 | Thrift.FramedTransport.flush | train | 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 | {
"resource": ""
} |
q10626 | LiquidInterpolatable.Filters.to_uri | train | 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 | {
"resource": ""
} |
q10627 | LiquidInterpolatable.Filters.to_xpath | train | 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 | {
"resource": ""
} |
q10628 | Agents.WebsiteAgent.store_payload! | train | 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 | {
"resource": ""
} |
q10629 | Vagrant.BatchAction.run | train | 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 | {
"resource": ""
} |
q10630 | Vagrant.Registry.get | train | 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 | {
"resource": ""
} |
q10631 | Vagrant.Registry.merge | train | def merge(other)
self.class.new.tap do |result|
result.merge!(self)
result.merge!(other)
end
end | ruby | {
"resource": ""
} |
q10632 | Vagrant.Bundler.init! | train | 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 | {
"resource": ""
} |
q10633 | Vagrant.Bundler.update | train | def update(plugins, specific, **opts)
specific ||= []
update = opts.merge({gems: specific.empty? ? true : specific})
internal_install(plugins, update)
end | ruby | {
"resource": ""
} |
q10634 | Vagrant.Bundler.clean | train | 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 | {
"resource": ""
} |
q10635 | Vagrant.Bundler.validate_configured_sources! | train | 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 | {
"resource": ""
} |
q10636 | Vagrant.Bundler.generate_builtin_set | train | 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 | {
"resource": ""
} |
q10637 | Vagrant.Bundler.activate_solution | train | 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 | {
"resource": ""
} |
q10638 | Vagrant.MachineIndex.delete | train | 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 | {
"resource": ""
} |
q10639 | Vagrant.MachineIndex.find_by_prefix | train | def find_by_prefix(prefix)
@machines.each do |uuid, data|
return data.merge("id" => uuid) if uuid.start_with?(prefix)
end
nil
end | ruby | {
"resource": ""
} |
q10640 | Vagrant.MachineIndex.lock_machine | train | 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 | {
"resource": ""
} |
q10641 | Vagrant.MachineIndex.unlocked_release | train | 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 | {
"resource": ""
} |
q10642 | Vagrant.MachineIndex.unlocked_reload | train | 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 | {
"resource": ""
} |
q10643 | Vagrant.MachineIndex.with_index_lock | train | 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 | {
"resource": ""
} |
q10644 | Vagrant.BoxMetadata.version | train | 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 | {
"resource": ""
} |
q10645 | Vagrant.CLI.help | train | 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 | {
"resource": ""
} |
q10646 | Vagrant.Environment.action_runner | train | 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 | {
"resource": ""
} |
q10647 | Vagrant.Environment.active_machines | train | 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 | {
"resource": ""
} |
q10648 | Vagrant.Environment.batch | train | 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 | {
"resource": ""
} |
q10649 | Vagrant.Environment.hook | train | 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 | {
"resource": ""
} |
q10650 | Vagrant.Environment.host | train | 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 | {
"resource": ""
} |
q10651 | Vagrant.Environment.lock | train | 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 | {
"resource": ""
} |
q10652 | Vagrant.Environment.push | train | 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 | {
"resource": ""
} |
q10653 | Vagrant.Environment.machine | train | 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 | {
"resource": ""
} |
q10654 | Vagrant.Environment.setup_local_data_path | train | 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 | {
"resource": ""
} |
q10655 | Vagrant.Environment.process_configured_plugins | train | 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 | {
"resource": ""
} |
q10656 | Vagrant.Environment.copy_insecure_private_key | train | 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 | {
"resource": ""
} |
q10657 | Vagrant.Environment.find_vagrantfile | train | 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 | {
"resource": ""
} |
q10658 | Vagrant.Environment.upgrade_home_path_v1_1 | train | 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 | {
"resource": ""
} |
q10659 | Vagrant.Environment.upgrade_v1_dotfile | train | 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 | {
"resource": ""
} |
q10660 | Vagrant.Guest.detect! | train | 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 | {
"resource": ""
} |
q10661 | Vagrant.Vagrantfile.machine | train | 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 | {
"resource": ""
} |
q10662 | Vagrant.Vagrantfile.machine_names_and_options | train | def machine_names_and_options
{}.tap do |r|
@config.vm.defined_vms.each do |name, subvm|
r[name] = subvm.options || {}
end
end
end | ruby | {
"resource": ""
} |
q10663 | Vagrant.Vagrantfile.primary_machine_name | train | 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 | {
"resource": ""
} |
q10664 | Vagrant.Machine.action | train | 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 | {
"resource": ""
} |
q10665 | Vagrant.Machine.action_raw | train | 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 | {
"resource": ""
} |
q10666 | Vagrant.Machine.id= | train | 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 | {
"resource": ""
} |
q10667 | Vagrant.Machine.reload | train | 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 | {
"resource": ""
} |
q10668 | Vagrant.Machine.state | train | 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 | {
"resource": ""
} |
q10669 | Vagrant.Machine.check_cwd | train | 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 | {
"resource": ""
} |
q10670 | Vagrant.BoxCollection.all | train | 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 | {
"resource": ""
} |
q10671 | Vagrant.BoxCollection.find | train | 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 | {
"resource": ""
} |
q10672 | Vagrant.BoxCollection.upgrade_v1_1_v1_5 | train | 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 | {
"resource": ""
} |
q10673 | Vagrant.BoxCollection.clean | train | def clean(name)
return false if exists?(name)
path = File.join(directory, dir_name(name))
FileUtils.rm_rf(path)
end | ruby | {
"resource": ""
} |
q10674 | Vagrant.BoxCollection.dir_name | train | def dir_name(name)
name = name.dup
name.gsub!(":", VAGRANT_COLON) if Util::Platform.windows?
name.gsub!("/", VAGRANT_SLASH)
name
end | ruby | {
"resource": ""
} |
q10675 | Vagrant.BoxCollection.undir_name | train | def undir_name(name)
name = name.dup
name.gsub!(VAGRANT_COLON, ":")
name.gsub!(VAGRANT_SLASH, "/")
name
end | ruby | {
"resource": ""
} |
q10676 | Vagrant.BoxCollection.v1_upgrade | train | def v1_upgrade(dir)
@logger.debug("Upgrading box in directory: #{dir}")
temp_dir = Pathname.new(Dir.mktmpdir(TEMP_PREFIX, @temp_root))
@logger.debug("Temporary directory for upgrading: #{temp_dir}")
# Move all the things into the temporary directory
dir.children(true).each do |child|
... | ruby | {
"resource": ""
} |
q10677 | Vagrant.BoxCollection.with_temp_dir | train | def with_temp_dir(dir=nil)
dir ||= Dir.mktmpdir(TEMP_PREFIX, @temp_root)
dir = Pathname.new(dir)
yield dir
ensure
FileUtils.rm_rf(dir.to_s)
end | ruby | {
"resource": ""
} |
q10678 | Vagrant.CapabilityHost.initialize_capabilities! | train | def initialize_capabilities!(host, hosts, capabilities, *args)
@cap_logger = Log4r::Logger.new(
"vagrant::capability_host::#{self.class.to_s.downcase}")
if host && !hosts[host]
raise Errors::CapabilityHostExplicitNotDetected, value: host.to_s
end
if !host
host = autodet... | ruby | {
"resource": ""
} |
q10679 | Vagrant.CapabilityHost.capability | train | def capability(cap_name, *args)
cap_mod = capability_module(cap_name.to_sym)
if !cap_mod
raise Errors::CapabilityNotFound,
cap: cap_name.to_s,
host: @cap_host_chain[0][0].to_s
end
cap_method = nil
begin
cap_method = cap_mod.method(cap_name)
rescu... | ruby | {
"resource": ""
} |
q10680 | Vagrant.CapabilityHost.capability_module | train | def capability_module(cap_name)
@cap_logger.debug("Searching for cap: #{cap_name}")
@cap_host_chain.each do |host_name, host|
@cap_logger.debug("Checking in: #{host_name}")
caps = @cap_caps[host_name]
if caps && caps.key?(cap_name)
@cap_logger.debug("Found cap: #{cap_name}... | ruby | {
"resource": ""
} |
q10681 | Vagrant.Box.in_use? | train | def in_use?(index)
results = []
index.each do |entry|
box_data = entry.extra_data["box"]
next if !box_data
# If all the data matches, record it
if box_data["name"] == self.name &&
box_data["provider"] == self.provider.to_s &&
box_data["version"] == self.v... | ruby | {
"resource": ""
} |
q10682 | Vagrant.Box.load_metadata | train | def load_metadata(**download_options)
tf = Tempfile.new("vagrant-load-metadata")
tf.close
url = @metadata_url
if File.file?(url) || url !~ /^[a-z0-9]+:.*$/i
url = File.expand_path(url)
url = Util::Platform.cygwin_windows_path(url)
url = "file:#{url}"
end
opt... | ruby | {
"resource": ""
} |
q10683 | Vagrant.Box.has_update? | train | def has_update?(version=nil, download_options: {})
if !@metadata_url
raise Errors::BoxUpdateNoMetadata, name: @name
end
if download_options.delete(:automatic_check) && !automatic_update_check_allowed?
@logger.info("Skipping box update check")
return
end
version +=... | ruby | {
"resource": ""
} |
q10684 | Vagrant.Box.automatic_update_check_allowed? | train | def automatic_update_check_allowed?
check_path = directory.join("box_update_check")
if check_path.exist?
last_check_span = Time.now.to_i - check_path.mtime.to_i
if last_check_span < BOX_UPDATE_CHECK_INTERVAL
@logger.info("box update check is under the interval threshold")
... | ruby | {
"resource": ""
} |
q10685 | Vagrant.Box.repackage | train | def repackage(path)
@logger.debug("Repackaging box '#{@name}' to: #{path}")
Util::SafeChdir.safe_chdir(@directory) do
# Find all the files in our current directory and tar it up!
files = Dir.glob(File.join(".", "**", "*")).select { |f| File.file?(f) }
# Package!
Util::Subpr... | ruby | {
"resource": ""
} |
q10686 | Vagrant.Alias.interpret | train | def interpret(line)
# is it a comment?
return nil if line.strip.start_with?("#")
keyword, command = line.split("=", 2).collect(&:strip)
# validate the keyword
if keyword.match(/\s/i)
raise Errors::AliasInvalidError, alias: line, message: "Alias keywords must not contain any white... | ruby | {
"resource": ""
} |
q10687 | Vagrant.Alias.register | train | def register(keyword, command)
@aliases.register(keyword.to_sym) do
lambda do |args|
# directly execute shell commands
if command.start_with?("!")
return Util::SafeExec.exec "#{command[1..-1]} #{args.join(" ")}".strip
end
return CLI.new(command.split.co... | ruby | {
"resource": ""
} |
q10688 | Sinatra.Helpers.redirect | train | def redirect(uri, *args)
if env['HTTP_VERSION'] == 'HTTP/1.1' and env["REQUEST_METHOD"] != 'GET'
status 303
else
status 302
end
# According to RFC 2616 section 14.30, "the field value consists of a
# single absolute URI"
response['Location'] = uri(uri, settings.absol... | ruby | {
"resource": ""
} |
q10689 | Sinatra.Helpers.uri | train | def uri(addr = nil, absolute = true, add_script_name = true)
return addr if addr =~ /\A[A-z][A-z0-9\+\.\-]*:/
uri = [host = ""]
if absolute
host << "http#{'s' if request.secure?}://"
if request.forwarded? or request.port != (request.secure? ? 443 : 80)
host << request.host_wi... | ruby | {
"resource": ""
} |
q10690 | Sinatra.Helpers.content_type | train | def content_type(type = nil, params={})
return response['Content-Type'] unless type
default = params.delete :default
mime_type = mime_type(type) || default
fail "Unknown media type: %p" % type if mime_type.nil?
mime_type = mime_type.dup
unless params.include? :charset or settings.add... | ruby | {
"resource": ""
} |
q10691 | Sinatra.Helpers.stream | train | def stream(keep_open = false)
scheduler = env['async.callback'] ? EventMachine : Stream
current = @params.dup
body Stream.new(scheduler, keep_open) { |out| with_params(current) { yield(out) } }
end | ruby | {
"resource": ""
} |
q10692 | Sinatra.Helpers.etag_matches? | train | def etag_matches?(list, new_resource = request.post?)
return !new_resource if list == '*'
list.to_s.split(/\s*,\s*/).include? response['ETag']
end | ruby | {
"resource": ""
} |
q10693 | Sinatra.Templates.render_ruby | train | def render_ruby(engine, template, options={}, locals={}, &block)
options, template = template, nil if template.is_a?(Hash)
template = Proc.new { block } if template.nil?
render engine, template, options, locals
end | ruby | {
"resource": ""
} |
q10694 | Sinatra.Base.filter! | train | def filter!(type, base = settings)
filter! type, base.superclass if base.superclass.respond_to?(:filters)
base.filters[type].each { |args| process_route(*args) }
end | ruby | {
"resource": ""
} |
q10695 | Sinatra.Base.route! | train | def route!(base = settings, pass_block=nil)
if routes = base.routes[@request.request_method]
routes.each do |pattern, keys, conditions, block|
pass_block = process_route(pattern, keys, conditions) do |*args|
route_eval { block[*args] }
end
end
end
# Run... | ruby | {
"resource": ""
} |
q10696 | Sinatra.Base.indifferent_hash | train | def indifferent_hash
Hash.new {|hash,key| hash[key.to_s] if Symbol === key }
end | ruby | {
"resource": ""
} |
q10697 | RJSON.Parser._reduce_22 | train | def _reduce_22(val, _values, result)
n = val[0]; result = n.count('.') > 0 ? n.to_f : n.to_i
result
end | ruby | {
"resource": ""
} |
q10698 | Fluent.Supervisor.dry_run | train | def dry_run
begin
Fluent::Engine.dry_run_mode = true
change_privilege
init_engine
run_configure
rescue Fluent::ConfigError => e
$log.error "config error", file: @config_path, error: e
$log.debug_backtrace
exit!(1)
ensure
Fluent::Engine.dr... | ruby | {
"resource": ""
} |
q10699 | Fluent.MessagePackEventStream.slice | train | def slice(index, num)
ensure_unpacked!
MultiEventStream.new(@unpacked_times.slice(index, num), @unpacked_records.slice(index, num))
end | ruby | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.