query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
Creates a new progress reporter that will write to +out_stream+ for +size+ items. Shows the given +initial_message+ when progress starts and the +terminal_message+ when it is complete. | def initialize(out_stream, size, initial_message,
terminal_message = 'complete')
@out = out_stream
@total = size
@count = 0
@terminal_message = terminal_message
@out.puts initial_message
end | [
"def initialize(out_stream, size, initial_message,\n terminal_message = \"complete\")\n @out = out_stream\n @total = size\n @count = 0\n @terminal_message = terminal_message\n\n @out.puts initial_message\n end",
"def run_with_progress(message, size, progr = nil, &bloc... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return a download reporter object chosen from the current verbosity | def download_reporter(*args)
if [nil, false].include?(Gem.configuration.verbose) || !@outs.tty?
SilentDownloadReporter.new(@outs, *args)
else
ThreadedDownloadReporter.new(@outs, *args)
end
end | [
"def progress_reporter(*args)\n case Gem.configuration.verbose\n when nil, false\n SilentProgressReporter.new(@outs, *args)\n when true\n SimpleProgressReporter.new(@outs, *args)\n else\n VerboseProgressReporter.new(@outs, *args)\n end\n end",
"def progress_reporter(*args)\n ca... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates a new threaded download reporter that will display on +out_stream+. The other arguments are ignored. | def initialize(out_stream, *args)
@file_name = nil
@out = out_stream
end | [
"def download_reporter(*args)\n if [nil, false].include?(Gem.configuration.verbose) || !@outs.tty?\n SilentDownloadReporter.new(@outs, *args)\n else\n ThreadedDownloadReporter.new(@outs, *args)\n end\n end",
"def initialize(output_stream)\n @output_stream = output_stream\n end",
"def... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Tells the download reporter that the +file_name+ is being fetched. The other arguments are ignored. | def fetch(file_name, *args)
if @file_name.nil?
@file_name = file_name
locked_puts "Fetching #{@file_name}"
end
end | [
"def fetchfile(file)\n fetchfiles(:file => file, :testdata_url => TestBase::testdata_url(@hostname)).first\n end",
"def fetch_export(username, req_id, filename)\n export_status_doc = export_status(username, req_id)\n\n if export_ready?(export_status_doc)\n download_export(export_status_doc, f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Updates the threaded download reporter for the given number of +bytes+. | def update(bytes)
# Do nothing.
end | [
"def mark_progress(bytes)\n # N.B.: we do *not* use update here to ensure that we trigger an\n # +updated_at+ change even when we've made no other\n # progress. This helps clarify the distinction between \"still\n # running but has not yet processed any more data\" and \"it's an\n # ex-tran... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks that no duplicate dependencies are specified. | def validate_duplicate_dependencies # :nodoc:
# NOTE: see REFACTOR note in Gem::Dependency about types - this might be brittle
seen = Gem::Dependency::TYPES.inject({}) {|types, type| types.merge({ type => {}}) }
error_messages = []
@specification.dependencies.each do |dep|
if prev = seen[dep.type... | [
"def check_circular_dependency!\n requires = @options[:_requires] ||= []\n if requires.include?(pathname.to_s)\n raise CircularDependencyError, \"#{pathname} has already been required\"\n end\n requires << pathname.to_s\n end",
"def validate_dependencies\n Spicewease... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks that dependencies use requirements as we recommend. Warnings are issued when dependencies are openended or overly strict for semantic versioning. | def validate_dependencies # :nodoc:
warning_messages = []
@specification.dependencies.each do |dep|
prerelease_dep = dep.requirements_list.any? do |req|
Gem::Requirement.new(req).prerelease?
end
warning_messages << "prerelease dependency on #{dep} is not recommended" if
prer... | [
"def dependencies_check\n dependencies.each do |required|\n dependency = Dependency.find_by(name: required['name'])\n if dependency && (version = required['version'])\n dependency.do_download(version)\n end\n end\n end",
"def verify_deps( packages )\n deps = []\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Issues a warning for each file to be packaged which is worldreadable. Implementation for Specificationvalidate_permissions | def validate_permissions
return if Gem.win_platform?
@specification.files.each do |file|
next unless File.file?(file)
next if File.stat(file).mode & 0444 == 0444
warning "#{file} is not world-readable"
end
@specification.executables.each do |name|
exec = File.join @specificatio... | [
"def file_checks\n errors = []\n errors << 'There are no entries in the manifest file.' if @current_package.manifest.count == 0\n errors\n end",
"def show_inaccessible\n warn \"#{@skipped_files.size} files/folders inaccessible \" + \\\n \"(try running as root):\"\n @skipped_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Does +other+ match this platform? Two platforms match if they have the same CPU, or either has a CPU of 'universal', they have the same OS, and they have the same version, or either has no version. Additionally, the platform will match if the local CPU is 'arm' and the other CPU starts with "arm" (for generic ARM famil... | def ===(other)
return nil unless Gem::Platform === other
# cpu
([nil,'universal'].include?(@cpu) or [nil, 'universal'].include?(other.cpu) or @cpu == other.cpu or
(@cpu == 'arm' and other.cpu.start_with?("arm"))) and
# os
@os == other.os and
# version
(@version.nil? or other.version.n... | [
"def =~(other)\n case other\n when Gem::Platform then # nop\n when String then\n # This data is from http://gems.rubyforge.org/gems/yaml on 19 Aug 2007\n other = case other\n when /^i686-darwin(\\d)/ then ['x86', 'darwin', $1 ]\n when /^i\\d86-linux/ then ['x86', ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Does +other+ match this platform? If +other+ is a String it will be converted to a Gem::Platform first. See === for matching rules. | def =~(other)
case other
when Gem::Platform then # nop
when String then
# This data is from http://gems.rubyforge.org/gems/yaml on 19 Aug 2007
other = case other
when /^i686-darwin(\d)/ then ['x86', 'darwin', $1 ]
when /^i\d86-linux/ then ['x86', 'linux', ... | [
"def ===(other)\n return nil unless Gem::Platform === other\n\n # cpu\n ([nil,'universal'].include?(@cpu) or [nil, 'universal'].include?(other.cpu) or @cpu == other.cpu or\n (@cpu == 'arm' and other.cpu.start_with?(\"arm\"))) and\n\n # os\n @os == other.os and\n\n # version\n (@version.nil? ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Constructs a Version from the +version+ string. A version string is a series of digits or ASCII letters separated by dots. | def initialize(version)
unless self.class.correct?(version)
raise ArgumentError, "Malformed version number string #{version}"
end
# If version is an empty string convert it to 0
version = 0 if version.is_a?(String) && version =~ /\A\s*\Z/
@version = version.to_s.strip.gsub("-",".pre.")
@... | [
"def initialize(version)\n @string = version.to_s\n @parsed = parse @string\n end",
"def parse_version(string)\n string[0] == \"v\" ? string[1..-1] : string\n end",
"def version_for(version_string)\n Mixlib::Versioning.parse(version_string)\n end",
"def parse_version(str)\n ver... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Dump only the raw version string, not the complete object. It's a string for backwards (RubyGems 1.3.5 and earlier) compatibility. | def marshal_dump
[version]
end | [
"def marshal_dump\n [version]\n end",
"def marshal_dump\n [ @version ]\n end",
"def full_version_string; end",
"def marshal_dump\n [@version]\n end",
"def to_s\n @version\n end",
"def version_string #:nodoc:\n @version\n end",
"def version_string(include_buildnum = T.unsa... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
:nodoc: Constructs a requirement from +requirements+. Requirements can be Strings, Gem::Versions, or Arrays of those. +nil+ and duplicate requirements are ignored. An empty set of +requirements+ is the same as ">= 0". | def initialize(*requirements)
requirements = requirements.flatten
requirements.compact!
requirements.uniq!
if requirements.empty?
@requirements = [DefaultRequirement]
else
@requirements = requirements.map! {|r| self.class.parse r }
end
end | [
"def initialize(*requirements)\n requirements = requirements.flatten\n requirements.compact!\n requirements.uniq!\n\n if requirements.empty?\n @requirements = [DefaultRequirement]\n else\n @requirements = requirements.map! { |r| self.class.parse r }\n end\n end",
"def initialize(requi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Concatenates the +new+ requirements onto this requirement. | def concat(new)
new = new.flatten
new.compact!
new.uniq!
new = new.map {|r| self.class.parse r }
@requirements.concat new
end | [
"def concat(new)\n new = new.flatten\n new.compact!\n new.uniq!\n new = new.map { |r| self.class.parse r }\n\n @requirements.concat new\n end",
"def update_deps_from(new_source)\n @metadata[:requires] =\n non_gem_requirements +\n extra_gem_requirements(new_source) +\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Formats this requirement for use in a Gem::RequestSet::Lockfile. | def for_lockfile # :nodoc:
return if [DefaultRequirement] == @requirements
list = requirements.sort_by do |_, version|
version
end.map do |op, version|
"#{op} #{version}"
end.uniq
" (#{list.join ', '})"
end | [
"def to_requirement_spec\n result = to_spec\n result = \"#{name} -> #{result}\" if name\n result = \"#{result} -> #{requirement}\" if requirement\n result\n end",
"def format_deps(deps); end",
"def requirement\n Gem::Requirement.new('~>' + pharos_version.segments.first(2)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A requirement is a prerelease if any of the versions inside of it are prereleases | def prerelease?
requirements.any? {|r| r.last.prerelease? }
end | [
"def prerelease?\n @prerelease || requirement.prerelease?\n end",
"def prerelease?\n @prerelease ||= requirement.requirements.\n any? { |r| Version.new(r[1].version).prerelease? }\n end",
"def prerelease?\n @prerelease ||= @version =~ /[a-zA-Z]/\n end",
"def prerelease\n duplic... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
True if +version+ satisfies this Requirement. | def satisfied_by?(version)
raise ArgumentError, "Need a Gem::Version: #{version.inspect}" unless
Gem::Version === version
requirements.all? {|op, rv| OPS[op].call version, rv }
end | [
"def satisfied_by?(version)\n version_reqs.all? {|r| r.satisfied_by?(version)}\n end",
"def satisfies?(version)\n dep_constraint.include?(version)\n end",
"def check_version(version, requirement)\n Gem::Requirement.new( requirement ).satisfied_by? Gem::Version.new( version )\n en... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A list of authors for this gem. Alternatively, a single author can be specified by assigning a string to +spec.author+ Usage: spec.authors = ['John Jones', 'Mary Smith'] | def authors=(value)
@authors = Array(value).flatten.grep(String)
end | [
"def authors=(authors)\n @authors = case authors\n when Array\n authors\n else\n [authors]\n end\n end",
"def authors\n @authors ||= []\n end",
"def authors(authors)\n\t\t\t\tauthors.map { |k,v|\n\t\t\t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The platform this gem runs on. This is usually Gem::Platform::RUBY or Gem::Platform::CURRENT. Most gems contain pure Ruby code; they should simply leave the default value in place. Some gems contain C (or other) code to be compiled into a Ruby "extension". The gem should leave the default value in place unless the code... | def platform=(platform)
if @original_platform.nil? or
@original_platform == Gem::Platform::RUBY
@original_platform = platform
end
case platform
when Gem::Platform::CURRENT then
@new_platform = Gem::Platform.local
@original_platform = @new_platform.to_s
when Gem::Platform t... | [
"def platform\n @_platform ||= begin\n os = []\n os << :windows if OS.windows?\n os << :linux if OS.linux?\n os << :osx if OS.osx?\n os << :posix if OS.posix?\n unless OS.windows? || OS.osx?\n os << :ubuntu if command_e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds a development dependency named +gem+ with +requirements+ to this gem. Usage: spec.add_development_dependency 'example', '~> 1.1', '>= 1.1.4' Development dependencies aren't installed by default and aren't activated when a gem is required. | def add_development_dependency(gem, *requirements)
add_dependency_with_type(gem, :development, requirements)
end | [
"def gem( name, *requirements, **options )\n\t\tif options[:group] == :development ||\n\t\t\toptions[:groups]&.include?( :development ) ||\n\t\t\tself.current_groups.include?( :development )\n\n\t\t\trequirements.push( :development )\n\t\tend\n\n\t\tdependency = Gem::Dependency.new( name, *requirements )\n\n\t\tsel... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds a runtime dependency named +gem+ with +requirements+ to this gem. Usage: spec.add_runtime_dependency 'example', '~> 1.1', '>= 1.1.4' | def add_runtime_dependency(gem, *requirements)
if requirements.uniq.size != requirements.size
warn "WARNING: duplicated #{gem} dependency #{requirements}"
end
add_dependency_with_type(gem, :runtime, requirements)
end | [
"def add_runtime_dependency dependency, *requirements\n requirements = if requirements.empty? then\n Gem::Requirement.default\n else\n requirements.flatten\n end\n\n unless dependency.respond_to?(:name) &&\n depen... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Extra files to add to RDoc such as README or doc/examples.txt When the user elects to generate the RDoc documentation for a gem (typically at install time), all the library files are sent to RDoc for processing. This option allows you to have some noncode files included for a more complete set of documentation. Usage: ... | def extra_rdoc_files
@extra_rdoc_files ||= []
end | [
"def extra_rdoc_files=(files)\n @extra_rdoc_files = Array files\n end",
"def setup_rdoc\n self.extra_rdoc_files = [ \"README.rdoc\", \"LICENSE\", \"ChangeLog\" ]\n self.rdoc_options << \"--title\" << \"#{title} #{version}\" \\\n << \"--main\" << \"README.rdoc\" \\\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the version of RubyGems that installed this gem. See also installed_by_version. | def installed_by_version=(version) # :nodoc:
@installed_by_version = Gem::Version.new version
end | [
"def mark_version\n @rubygems_version = RubyGemsVersion\n end",
"def mark_version\n @rubygems_version = Gem::VERSION\n end",
"def version=(version)\n @version = Gem::Version.create(version)\n # skip to set required_ruby_version when pre-released rubygems.\n # It caused to raise CircularDepe... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Specifies the rdoc options to be used when generating API documentation. Usage: spec.rdoc_options << 'title' << 'Rake Ruby Make' << 'main' << 'README' << 'linenumbers' | def rdoc_options
@rdoc_options ||= []
end | [
"def setup_rdoc\n self.extra_rdoc_files = [ \"README.rdoc\", \"LICENSE\", \"ChangeLog\" ]\n self.rdoc_options << \"--title\" << \"#{title} #{version}\" \\\n << \"--main\" << \"README.rdoc\" \\\n << \"--line-numbers\" \\\n << \"--all\" \\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Activate this spec, registering it as a loaded spec and adding it's lib paths to $LOAD_PATH. Returns true if the spec was activated, false if it was previously activated. Freaks out if there are conflicts upon activation. | def activate
other = Gem.loaded_specs[self.name]
if other
check_version_conflict other
return false
end
raise_if_conflicts
activate_dependencies
add_self_to_load_path
Gem.loaded_specs[self.name] = self
@activated = true
@loaded = true
return true
end | [
"def activate path\n found = nil\n catch :found do\n gems.each do |gem_spec|\n gem_spec.libs.each do |lib_path|\n if File.exist? \"#{lib_path}/#{path}\"\n found = gem_spec\n throw :found\n end\n end\n end\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Activate all unambiguously resolved runtime dependencies of this spec. Add any ambiguous dependencies to the unresolved list to be resolved later, as needed. | def activate_dependencies
unresolved = Gem::Specification.unresolved_deps
self.runtime_dependencies.each do |spec_dep|
if loaded = Gem.loaded_specs[spec_dep.name]
next if spec_dep.matches_spec? loaded
msg = "can't satisfy '#{spec_dep}', already activated '#{loaded.full_name}'"
e ... | [
"def resolve_dependencies\n puts \"resolving dependency names for #{program} #{version}\" if $DEBUG\n dep_names = dependencies | applicable_compliment | applicable_supplement\n @resolved_dependencies, @unresolved_dependencies = *Catalog.resolve_names(dep_names)\n end",
"def resolve_dependencies\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds a dependency on gem +dependency+ with type +type+ that requires +requirements+. Valid types are currently :runtime and :development. | def add_dependency_with_type(dependency, type, requirements)
requirements = if requirements.empty?
Gem::Requirement.default
else
requirements.flatten
end
unless dependency.respond_to?(:name) &&
dependency.respond_to?(:requirement)
dependency = Gem::Dependency.new(dependency... | [
"def add_runtime_dependency dependency, *requirements\n requirements = if requirements.empty? then\n Gem::Requirement.default\n else\n requirements.flatten\n end\n\n unless dependency.respond_to?(:name) &&\n depen... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The list of author names who wrote this gem. spec.authors = ['Chad Fowler', 'Jim Weirich', 'Rich Kilmer'] | def authors
@authors ||= []
end | [
"def author_names\n\t\treturn self.authors.map do |author|\n\t\t\tauthor[ /^(.*?) </, 1 ]\n\t\tend\n\tend",
"def document_authors\n Rantly {\n array(range(1, 5)) {\n \"#{sized(6) { string(:alpha) }} #{sized(2) { string(:upper) }}\"\n }.join('|')\n }\n end",
"def a... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Builds extensions for this platform if the gem has extensions listed and the gem.build_complete file is missing. | def build_extensions # :nodoc:
return if extensions.empty?
return if default_gem?
return if File.exist? gem_build_complete_path
return if !File.writable?(base_dir)
return if !File.exist?(File.join(base_dir, 'extensions'))
begin
# We need to require things in $LOAD_PATH without looking for... | [
"def missing_extensions?\n return false if extensions.empty?\n return false if default_gem?\n return false if File.exist? gem_build_complete_path\n\n true\n end",
"def build_extensions(install_root)\n if @spec.respond_to?(:extension_dir=)\n tempdir do |workroot|\n extract_files_into(wo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the full path to the build info directory | def build_info_dir
File.join base_dir, "build_info"
end | [
"def build_info_file\n File.join build_info_dir, \"#{full_name}.info\"\n end",
"def build_path\n build_dir || settings.build_path\n end",
"def build_path\n @build_path ||= Pathname.new(source_dir).join(data['build_path'] || './build').to_s\n end",
"def build_dir\n @app.root_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the full path to the file containing the build information generated when the gem was installed | def build_info_file
File.join build_info_dir, "#{full_name}.info"
end | [
"def build_info_dir\n File.join base_dir, \"build_info\"\n end",
"def build\n\t@built_gem_path ||= @helper.build_gem\n\t\n\tgemspec = @helper.gemspec\n\t\n\t$stdout.puts \"Your gem contains the following files:\"\n\tpp gemspec.files\nend",
"def gem_build_complete_path # :nodoc:\n File.join extension_dir,... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
return true if there will be conflict when spec if loaded together with the list of specs. | def conficts_when_loaded_with?(list_of_specs) # :nodoc:
result = list_of_specs.any? do |spec|
spec.dependencies.any? {|dep| dep.runtime? && (dep.name == name) && !satisfies_requirement?(dep) }
end
result
end | [
"def conflicting?\n !conflicts.empty?\n end",
"def current_spec_is?(spec)\n return false unless file_name_spec_set?\n spec = [spec] unless spec.is_a? Array\n spec = spec.flatten\n spec = spec.map do |spec|\n Noop::Utils.convert_to_spec spec\n end\n spec.any? do |spec|\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return true if there are possible conflicts against the currently loaded specs. | def has_conflicts?
return true unless Gem.env_requirement(name).satisfied_by?(version)
self.dependencies.any? do |dep|
if dep.runtime?
spec = Gem.loaded_specs[dep.name]
spec and not spec.satisfies_requirement? dep
else
false
end
end
end | [
"def conflicting?\n !conflicts.empty?\n end",
"def conficts_when_loaded_with?(list_of_specs) # :nodoc:\n result = list_of_specs.any? do |spec|\n spec.dependencies.any? {|dep| dep.runtime? && (dep.name == name) && !satisfies_requirement?(dep) }\n end\n result\n end",
"def complete?\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The date this gem was created. If SOURCE_DATE_EPOCH is set as an environment variable, use that to support reproducible builds; otherwise, default to the current UTC date. Details on SOURCE_DATE_EPOCH: | def date
@date ||= Time.utc(*Gem.source_date_epoch.utc.to_a[3..5].reverse)
end | [
"def build_timestamp\n @build_timestamp\n end",
"def epoch_date\n @epoch_date ||= Time.zone.at(0).to_date\n end",
"def build_start_time\n @build_start_time ||= begin\n if !ENV['BUILD_ID'].nil?\n begin\n Tim... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The default executable for this gem. Deprecated: The name of the gem is assumed to be the name of the executable now. See Gem.bin_path. | def default_executable # :nodoc:
if defined?(@default_executable) and @default_executable
result = @default_executable
elsif @executables and @executables.size == 1
result = Array(@executables).first
else
result = nil
end
result
end | [
"def bundler_exe\n @bundler_exe ||= begin\n exe = config.dig(\"bundler\", \"bundler_exe\")\n return \"bundle\" unless exe\n return exe if Licensed::Shell.tool_available?(exe)\n config.root.join(exe)\n end\n end",
"def ruby_executable\n unless (path... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The default value for specification attribute +name+ | def default_value(name)
@@default_value[name]
end | [
"def default(name,value)\n @network.spec_factory.defaults[name]=value\n end",
"def attr(name, default_value=:undefined)\n other_attrs[name] = Attr.new(name, default_value, @_current_desc)\n @_current_desc = nil\n _define_attr(name)\n end",
"def apply_default(name)\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return a list of all gems that have a dependency on this gemspec. The list is structured with entries that conform to: [depending_gem, dependency, [list_of_gems_that_satisfy_dependency]] | def dependent_gems(check_dev=true)
out = []
Gem::Specification.each do |spec|
deps = check_dev ? spec.dependencies : spec.runtime_dependencies
deps.each do |dep|
if self.satisfies_requirement?(dep)
sats = []
find_all_satisfiers(dep) do |sat|
sats << sat
... | [
"def dependent_gems\n out = []\n Gem.source_index.each do |name,gem|\n gem.dependencies.each do |dep|\n if self.satisfies_requirement?(dep) then\n sats = []\n find_all_satisfiers(dep) do |sat|\n sats << sat\n end\n out << [gem, dep, ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns all specs that matches this spec's runtime dependencies. | def dependent_specs
runtime_dependencies.map {|dep| dep.to_specs }.flatten
end | [
"def find_all req\n res = []\n\n versions(req.name).each do |ver|\n if req.dependency.match? req.name, ver[:number]\n res << Gem::DependencyResolver::APISpecification.new(self, ver)\n end\n end\n\n res\n end",
"def dependencies\n spec.dependencies\n end",
"def dependencies_for(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
List of dependencies that are used for development | def development_dependencies
dependencies.select {|d| d.type == :development }
end | [
"def development_dependencies\n Gem::Specification.load(gemspec_path.to_s).development_dependencies\n end",
"def dependencies\n []\n end",
"def fetch_development_dependencies # :nodoc:\n end",
"def dependent_gems(check_dev=true)\n out = []\n Gem::Specification.each do |spec|\n deps... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the full path to this spec's documentation directory. If +type+ is given it will be appended to the end. For example: spec.doc_dir => "/path/to/gem_repo/doc/a1" spec.doc_dir 'ri' => "/path/to/gem_repo/doc/a1/ri" | def doc_dir(type = nil)
@doc_dir ||= File.join base_dir, 'doc', full_name
if type
File.join @doc_dir, type
else
@doc_dir
end
end | [
"def docs_dir\n File.expand_path(File.join(__FILE__, '..', '..', '..', '..', '..', 'documentation', 'cli'))\n end",
"def doc_path\n config['docs']\n end",
"def javadoc_directory\n FilePath.new(@build_dir, 'doc', 'api')\n end",
"def doc_path\n File.join(@gen.out, doc_basename)\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Singular accessor for executables | def executable
val = executables and val.first
end | [
"def executable_path; end",
"def executable(value)\n @executable[0] = value\n end",
"def executable_real?() end",
"def executable=(value)\n @executable = value\n end",
"def executable_code\n metadata_hash['executable']\n end",
"def executable?() end",
"def executable(value=true)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets executables to +value+, ensuring it is an array. | def executables=(value)
@executables = Array(value)
end | [
"def executable(value)\n @executable[0] = value\n end",
"def executable=(value)\n @executable = value\n end",
"def executable(value=true)\n @executable = value\n end",
"def value_array=(arg)\n \tself.value = arg.join(VALUE_DELIMITER)\n end",
"def set_array(column, value)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets extensions to +extensions+, ensuring it is an array. | def extensions=(extensions)
@extensions = Array extensions
end | [
"def extensions=(value)\n @extensions = value\n end",
"def extensions=(value)\n subtags = Array(value).flatten\n self.extensions_sequence = subtags.empty? ? nil : subtags.join(HYPHEN)\n end",
"def extensions=(val)\n set_extensions(val)\n val\n end",
"d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets extra_rdoc_files to +files+, ensuring it is an array. | def extra_rdoc_files=(files)
@extra_rdoc_files = Array files
end | [
"def extra_rdoc_files\n @extra_rdoc_files ||= []\n end",
"def normalize\n if @extra_rdoc_files\n @extra_rdoc_files.uniq!\n @files ||= []\n @files.concat(@extra_rdoc_files)\n end\n @files.uniq! if @files\n end",
"def files=(files)\n @files = Array files\n end",
"d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The default (generated) file name of the gem. See also spec_name. spec.file_name => "example1.0.gem" | def file_name
"#{full_name}.gem"
end | [
"def filename(gem_version = nil)\n gem_version ||= version.to_s\n\n \"#{name}-#{gem_version}.gem\"\n end",
"def gem_filename\n \"#{gem_dirname}.gem\"\n end",
"def spec_name\n \"#{full_name}.gemspec\"\n end",
"def spec_file\n File.join(spec.full_gem_path, spec.name + '.gemspec')\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets files to +files+, ensuring it is an array. | def files=(files)
@files = Array files
end | [
"def files_array(files)\n return [] unless files\n files.is_a?(Array) ? files : pattern_to_filelist(files.to_s)\n end",
"def files=(value)\n @files = value\n end",
"def input_files=(files)\n @input_files = files.map do |file|\n file.with_encoding(encoding)\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Finds all gems that satisfy +dep+ | def find_all_satisfiers(dep)
Gem::Specification.each do |spec|
yield spec if spec.satisfies_requirement? dep
end
end | [
"def dependent_gems(check_dev=true)\n out = []\n Gem::Specification.each do |spec|\n deps = check_dev ? spec.dependencies : spec.runtime_dependencies\n deps.each do |dep|\n if self.satisfies_requirement?(dep)\n sats = []\n find_all_satisfiers(dep) do |sat|\n sats ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates a duplicate spec without large blobs that aren't used at runtime. | def for_cache
spec = dup
spec.files = nil
spec.test_files = nil
spec
end | [
"def dup_fixture\n fixture = prospects(:all_valid)\n fixture.directory_id = SecureRandom.hex\n fixture\n end",
"def generate_clone_spec(vm_config)\n rp = Vsimple::Config[:cluster].resourcePool\n rspec = RbVmomi::VIM.VirtualMachineRelocateSpec(:pool => rp)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
True if this gem has files in test_files | def has_unit_tests? # :nodoc:
not test_files.empty?
end | [
"def test_file?(path)\n @tests_files.include?(path)\n end",
"def has_test\n\t\treturn @t_cpp_files.length > 0\n\tend",
"def has_tests?\n FileList[test_pattern].any?\n end",
"def test_file?(filename)\n @test_files.include?(filename)\n end",
"def installed?\n results = tar... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Duplicates array_attributes from +other_spec+ so state isn't shared. | def initialize_copy(other_spec)
self.class.array_attributes.each do |name|
name = :"@#{name}"
next unless other_spec.instance_variable_defined? name
begin
val = other_spec.instance_variable_get(name)
if val
instance_variable_set name, val.dup
elsif Gem.configurat... | [
"def dup\r\n other = self.shallow_dup\r\n other.array_specs = @array_specs.dup\r\n other.array_data = @array_data.dup\r\n other\r\n end",
"def extend_other(other)\n other.extend(Hash[removed_attributes.zip])\n end",
"def merge_attributes(other)\n _attrs.each do |attr|\n current... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Expire memoized instance variables that can incorrectly generate, replace or miss files due changes in certain attributes used to compute them. | def invalidate_memoized_attributes
@full_name = nil
@cache_file = nil
end | [
"def invalidate_memoized_attributes\n @zip_file = nil\n @manifest_file = nil\n end",
"def destructive_cache; @@destructive_cache; end",
"def reset_memoized; end",
"def expire_cache_for(class_name)\n self.class.reflections.each do |name, reflection|\n if reflection.options[:cached] and r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Singular accessor for licenses | def license
licenses.first
end | [
"def licenses\n data[:licenses]\n end",
"def licenses\n @licenses ||= {}\n end",
"def licenses\n @licenses ||= self.details['licenses'].collect{|l| License.new(self, l)}\n end",
"def license\n @license || 'Unknown'\n end",
"def license\n return @lic... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the rubygems_version to the current RubyGems version. | def mark_version
@rubygems_version = Gem::VERSION
end | [
"def mark_version\n @rubygems_version = RubyGemsVersion\n end",
"def version=(version)\n @version = Gem::Version.create(version)\n # skip to set required_ruby_version when pre-released rubygems.\n # It caused to raise CircularDependencyError\n if @version.prerelease? && (@name.nil? || @name.st... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Track removed method calls to warn about during build time. Warn about unknown attributes while loading a spec. | def method_missing(sym, *a, &b) # :nodoc:
if REMOVED_METHODS.include?(sym)
removed_method_calls << sym
return
end
if @specification_version > CURRENT_SPECIFICATION_VERSION and
sym.to_s.end_with?("=")
warn "ignoring #{sym} loading #{full_name}" if $DEBUG
else
super
end
... | [
"def silence_redefinition_of_method(method); end",
"def missing_documentation\n analytics_methods.flat_map do |method_object|\n error_prefix = \"#{method_object.file}:#{method_object.line} #{method_object.name}\"\n errors = []\n\n param_names = method_object.parameters.map { |p| p.first }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Is this specification missing its extensions? When this returns true you probably want to build_extensions | def missing_extensions?
return false if extensions.empty?
return false if default_gem?
return false if File.exist? gem_build_complete_path
true
end | [
"def extensions_present?\n\t\treturn !self.extensions.empty?\n\tend",
"def specification_attached?\n self.eco_documents.detect { |d| d.specification? } != nil\n end",
"def extension?\n !extension.nil?\n end",
"def extensions_installed?\n !@extensions.empty?\n end",
"def gemspec?\n !... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Normalize the list of files so that: All file lists have redundancies removed. Files referenced in the extra_rdoc_files are included in the package file list. | def normalize
if defined?(@extra_rdoc_files) and @extra_rdoc_files
@extra_rdoc_files.uniq!
@files ||= []
@files.concat(@extra_rdoc_files)
end
@files = @files.uniq if @files
@extensions = @extensions.uniq if @extensions
@test_files = @test_files.uniq if @test... | [
"def normalize\n if @extra_rdoc_files\n @extra_rdoc_files.uniq!\n @files ||= []\n @files.concat(@extra_rdoc_files)\n end\n @files.uniq! if @files\n end",
"def normalized_file_list(options, relative_files, force_doc = false, exclude_pattern=nil)\n file_list = []\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return a NameTuple that represents this Specification | def name_tuple
Gem::NameTuple.new name, version, original_platform
end | [
"def get_specification()\n\t\tend",
"def to_requirement_spec\n result = to_spec\n result = \"#{name} -> #{result}\" if name\n result = \"#{result} -> #{requirement}\" if requirement\n result\n end",
"def specs_with_name(name)\n matching_specs = @specs.select do |spec|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the full name (nameversion) of this gemspec using the original platform. For use with legacy gems. | def original_name # :nodoc:
if platform == Gem::Platform::RUBY or platform.nil?
"#{@name}-#{@version}"
else
"#{@name}-#{@version}-#{@original_platform}"
end
end | [
"def full_name\n if platform == Gem::Platform::RUBY || platform.nil?\n \"#{@name}-#{@version}\"\n else\n \"#{@name}-#{@version}-#{platform}\"\n end \n end",
"def full_name\n if platform == Gem::Platform::RUBY or platform.nil? then\n \"#{name}-#{version}\".untaint\n else\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Raise an exception if the version of this spec conflicts with the one that is already loaded (+other+) | def check_version_conflict(other) # :nodoc:
return if self.version == other.version
# This gem is already loaded. If the currently loaded gem is not in the
# list of candidate gems, then we have a version conflict.
msg = "can't activate #{full_name}, already activated #{other.full_name}"
e = Gem... | [
"def version_mismatch_detected\n end",
"def raise_if_conflicts # :nodoc:\n if has_conflicts?\n raise Gem::ConflictError.new self, conflicts\n end\n end",
"def <=>(other)\n case other\n when Gem::Source::SpecificFile then\n return nil if @spec.name != other.spec.name\n\n @spec.vers... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Check the spec for possible conflicts and freak out if there are any. | def raise_if_conflicts # :nodoc:
if has_conflicts?
raise Gem::ConflictError.new self, conflicts
end
end | [
"def conflicts\n @conflicts ||= []\n end",
"def check_if_untagged_version_is_acceptable(spec, previous_spec, errors)\n return if !spec.source[:git] || spec.source[:tag]\n return unless related_specifications(spec)\n return if previous_spec\n has_tagged_spec = related_specificat... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets rdoc_options to +value+, ensuring it is an array. | def rdoc_options=(options)
@rdoc_options = Array options
end | [
"def values=(value_array)\r\n if value_array and !value_array.is_a? Array\r\n raise \"The values must be a Ruby array, not #{value_array.class}\"\r\n end\r\n @values = value_array || Array.new\r\n end",
"def argument_value=(value)\n if @argument_type == 'array'\n @argument_val... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set requirements to +req+, ensuring it is an array. | def requirements=(req)
@requirements = Array req
end | [
"def exteneral_requirements=(requirements)\n @external_requirements = case requirements\n when Array\n requirements\n else\n [requirements]\n end... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the full path to this spec's ri directory. | def ri_dir
@ri_dir ||= File.join base_dir, 'ri', full_name
end | [
"def path\n File.dirname(root)\n end",
"def get_path_of_rrd\n\t\t\t\t# The location of the rrd.\n\t\t\t\trrd_dir = File.dirname(__FILE__) + \"/../../../../../db/colored-rrds/\"\n\n\t\t\t\t# Check if the RRD directory exists.\n\t\t\t\treturn false if !check_for_rrd_dir rrd_dir\n\n\t\t\t\t# rrd is now the f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return a string containing a Ruby code representation of the given object. | def ruby_code(obj)
case obj
when String then obj.dump + ".freeze"
when Array then '[' + obj.map {|x| ruby_code x }.join(", ") + ']'
when Hash then
seg = obj.keys.sort.map {|k| "#{k.to_s.dump} => #{obj[k].to_s.dump}" }
"{ #{seg.join(', ')} }"
when Ge... | [
"def ruby_code(obj)\n case obj\n when String then '%q{' + obj + '}'\n when Array then obj.inspect\n when Gem::Version then obj.to_s.inspect\n when Date, Time then '%q{' + obj.strftime('%Y-%m-%d') + '}'\n when Numeric then obj.inspect\n when ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks if this specification meets the requirement of +dependency+. | def satisfies_requirement?(dependency)
return @name == dependency.name &&
dependency.requirement.satisfied_by?(@version)
end | [
"def satisfies_requirement?(dependency)\n return @name == dependency.name && \n dependency.version_requirements.satisfied_by?(@version)\n end",
"def satisfy?(dependency)\n return false unless @current_packages.key? dependency.name.to_s\n dependency.satisfied_by?(@current_packages[dependency.n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the full path to the directory containing this spec's gemspec file. eg: /usr/local/lib/ruby/gems/1.8/specifications | def spec_dir
@spec_dir ||= File.join base_dir, "specifications"
end | [
"def specdir\n pwd = Dir.pwd\n specdir = File.join(pwd, 'spec')\n unless Dir.exist?(specdir)\n raise 'No spec directory was found under the CWD. A spec manifest can be specified with the --manifest flag'\n end\n specdir\n end",
"def gemspec_path\n Pathname.glob('*.gemspec').first\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The default name of the gemspec. See also file_name spec.spec_name => "example1.0.gemspec" | def spec_name
"#{full_name}.gemspec"
end | [
"def spec_file\n File.join(spec.full_gem_path, spec.name + '.gemspec')\n end",
"def gem_name\n gemspec.name\n end",
"def gemspec_file\n project_path( \"#{ name }.gemspec\" )\n end",
"def full_name\n \"#{spec.name}-#{spec.version}\"\n end",
"def gem_name\n @spec.name\n end",
"de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Singular accessor for test_files | def test_file # :nodoc:
val = test_files and val.first
end | [
"def test_file=(file) # :nodoc:\n self.test_files = [file]\n end",
"def test_files=(list)\n @test_files = list\n end",
"def test_files\n get_folder_files(TESTS_PATH)\n end",
"def inspected_files=(_); end",
"def interesting_files\n self.class.interesting_files\n end",
"def acts_as_f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Singular mutator for test_files | def test_file=(file) # :nodoc:
self.test_files = [file]
end | [
"def test_files=(list)\n @test_files = list\n end",
"def target_files=(_); end",
"def inspected_files=(_); end",
"def test_file # :nodoc:\n val = test_files and val.first\n end",
"def test_files(pr)\n files_at_commit(pr, test_file_filter)\n end",
"def acts_as_file_test(options={})\r\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a Ruby code representation of this specification, such that it can be eval'ed and reconstruct the same specification later. Attributes that still have their default values are omitted. | def to_ruby
mark_version
result = []
result << "# -*- encoding: utf-8 -*-"
result << "#{Gem::StubSpecification::PREFIX}#{name} #{version} #{platform} #{raw_require_paths.join("\0")}"
result << "#{Gem::StubSpecification::PREFIX}#{extensions.join "\0"}" unless
extensions.empty?
result << nil... | [
"def generate_ruby_code_from_attributes(attributes)\n\t\tcode = []\n\t\tnames = []\n\t\tattributes.each {|att| names << att[:name].snakecase}\n\n\t\t# Instance variables\n\t\tnames.each do |name|\n\t\t\tcode << \" attr_accessor #{name.to_sym.inspect}\"\n\t\tend\n\t\tcode << \"\" # An empty string is enough to trig... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Recursively walk dependencies of this spec, executing the +block+ for each hop. | def traverse(trail = [], visited = {}, &block)
trail.push(self)
begin
dependencies.each do |dep|
next unless dep.runtime?
dep.matching_specs(true).each do |dep_spec|
next if visited.has_key?(dep_spec)
visited[dep_spec] = true
trail.push(dep_spec)
beg... | [
"def each_forward_dependency(&block)\n forward_dependencies.each(&block)\n end",
"def each_dependency(&block)\n return dependencies_enumerator if block.nil?\n\n dependencies_enumerator.each(&block)\n end",
"def each_start_dependency(&block)\n return unless @start_dependencies\n @s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set the version to +version+, potentially also setting required_rubygems_version if +version+ indicates it is a prerelease. | def version=(version)
@version = Gem::Version.create(version)
# skip to set required_ruby_version when pre-released rubygems.
# It caused to raise CircularDependencyError
if @version.prerelease? && (@name.nil? || @name.strip != "rubygems")
self.required_rubygems_version = '> 1.3.1'
end
inv... | [
"def version=(value)\n @version = value\n end",
"def version=(version)\n mutate_config(:version) { version.dup }\n end",
"def version=(value)\n @version = value\n end",
"def setVersion(version)\r\n\t\t\t\t\t@version = version\r\n\t\t\t\tend",
"def mark_version\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Reset nil attributes to their default values to make the spec valid | def reset_nil_attributes_to_default
nil_attributes = self.class.non_nil_attributes.find_all do |name|
!instance_variable_defined?("@#{name}") || instance_variable_get("@#{name}").nil?
end
nil_attributes.each do |attribute|
default = self.default_value attribute
value = case default
... | [
"def set_default_attributes\n self.attributes = default_attributes\n self.attributes.each do |key, value|\n # Scrub the attributes if there's no value\n attr_clean!(key) unless value\n end\n end",
"def defaulted_attrs\n given_attrs.reject {|attr| send(\"given_#{a... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Constructs a dependency with +name+ and +requirements+. The last argument can optionally be the dependency type, which defaults to :runtime. | def initialize(name, *requirements)
case name
when String then # ok
when Regexp then
msg = ["NOTE: Dependency.new w/ a regexp is deprecated.",
"Dependency.new called from #{Gem.location_of_caller.join(":")}"]
warn msg.join("\n") unless Gem::Deprecate.skip
else
raise Argume... | [
"def dep(name, *requirements)\n FoobarMod::Dependency.new name, *requirements\n end",
"def dependency name, version, type = :runtime\n raise \"Unknown dependency type: #{type}\" unless\n [:runtime, :dev, :development, :developer].include? type\n\n ary = if type == :runtime then\n extra_d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A dependency's hash is the XOR of the hashes of +name+, +type+, and +requirement+. | def hash # :nodoc:
name.hash ^ type.hash ^ requirement.hash
end | [
"def hash # :nodoc:\n identifier.hash ^ requirement.hash\n end",
"def hash\n name.hash ^ deployment_target.hash\n end",
"def requirement_hash(spec = self)\n result = {}\n if String === spec\n parts = spec.split(/\\s*->\\s*/, 3).map(&:strip)\n case parts.size\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Does this dependency require a prerelease? | def prerelease?
@prerelease || requirement.prerelease?
end | [
"def prerelease?\n @prerelease ||= @version =~ /[a-zA-Z]/\n end",
"def prerelease?\n requirements.any? {|r| r.last.prerelease? }\n end",
"def prerelease?\n @prerelease ||= requirement.requirements.\n any? { |r| Version.new(r[1].version).prerelease? }\n end",
"def prerelease_version?... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Is this dependency simply asking for the latest version of a gem? | def latest_version?
@requirement.none?
end | [
"def version_matches?(current:, required:)\n Gem::Dependency.new(\"gem\", required).match? \"gem\", current\n end",
"def gem_version_more?(name, version)\n Gem.loaded_specs[name].version >= Gem::Version.new(version)\n end",
"def latest_version\n gem['version']\n end",
"def latest_versi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Uses this dependency as a pattern to compare to +other+. This dependency will match if the name matches the other's name, and other has only an equal version requirement that satisfies this dependency. | def =~(other)
unless Gem::Dependency === other
return unless other.respond_to?(:name) && other.respond_to?(:version)
other = Gem::Dependency.new other.name, other.version
end
return false unless name === other.name
reqs = other.requirement.requirements
return false unless reqs.length ... | [
"def =~(other)\n return false unless self.class === other\n\n pattern = @name\n pattern = /\\A#{@name}\\Z/ unless Regexp === pattern\n\n return false unless pattern =~ other.name\n\n reqs = other.version_requirements.requirements\n\n return false unless reqs.length == 1\n return false unless re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Merges the requirements of +other+ into this dependency | def merge(other)
unless name == other.name
raise ArgumentError,
"#{self} and #{other} have different names"
end
default = Gem::Requirement.default
self_req = self.requirement
other_req = other.requirement
return self.class.new name, self_req if other_req == default
retur... | [
"def merge(other)\n unless name == other.name\n raise ArgumentError, \"#{self} and #{other} have different names\"\n end\n\n default = Requirement.default\n self_req = requirement\n other_req = other.requirement\n\n req = if other_req == default\n self_req\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Register a Gem::Specification for default gem. Two formats for the specification are supported: MRI 2.0 style, where spec.files contains unprefixed require names. The spec's filenames will be registered asis. New style, where spec.files contains files prefixed with paths from spec.require_paths. The prefixes are stripp... | def register_default_spec(spec)
extended_require_paths = spec.require_paths.map {|f| f + "/" }
new_format = extended_require_paths.any? {|path| spec.files.any? {|f| f.start_with? path } }
if new_format
prefix_group = extended_require_paths.join("|")
prefix_pattern = /^(#{prefix_group}... | [
"def add_spec(gem_spec)\n @gems[gem_spec.full_name] = gem_spec\n end",
"def add_spec(gem_spec, name = gem_spec.full_name)\n # No idea why, but the Indexer wants to insert them using original_name\n # instead of full_name. So we make it an optional arg.\n @gems[name] = gem_spec\n end",
"def add... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Split the Gem search path (as reported by Gem.path). | def split_gem_path(gpaths, home)
# FIX: it should be [home, *path], not [*path, home]
gem_path = []
if gpaths
gem_path = gpaths.split(Gem.path_separator)
# Handle the path_separator being set to a regexp, which will cause
# end_with? to error
if gpaths =~ /#{Gem.path_separator}\z/
... | [
"def vendored_path_parts(package)\n return if package.nil? || package[\"Dir\"].nil?\n package[\"Dir\"].match(/^(?<vendor_path>#{config.root}(\\/.+)*\\/[^\\/]*vendor[^\\/]*)\\/(?<import_path>.+)$/i)\n end",
"def gem_paths\n @_gem_paths ||= (ENV['GEM_PATH'] || ENV['GEM_HOME']).split(/[:;]/)\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return the default Gem path | def default_path
Gem.default_path + [@home]
end | [
"def gemfile_path\n @config.pwd.join ::Bundler.default_gemfile.basename.to_s\n end",
"def default_gems_install_path\n xdg_default_gem_path = xdg_var(\"XDG_DATA_HOME\",\n File.join(Dir.home, \".local\", \"share\", \"autoproj\", \"gems\"))\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
detects the minimum value out of three arguments. This method is faster than `[a, b, c].min` and puts less GC pressure. See for a performance benchmark. | def min3(a, b, c)
if a < b && a < c
a
elsif b < c
b
else
c
end
end | [
"def min_of_three(number1, number2, number3)\n if number1 < number2\n min = number1\n else\n min = number2\n end\n if min < number3\n return min\n else\n return number3\n end\nend",
"def min_of_three(n1, n2, n3)\n smallest = n1\n if n2 < n3\n smallest = n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Should be implemented by a extended class. tsort_each_node is used to iterate for all nodes over a graph. | def tsort_each_node # :yields: node
raise NotImplementedError.new
end | [
"def tsort_each_node\n @nodes.each { |node| yield node }\n end",
"def tsort_each_node(&aBlock)\n return dependencies.each(&aBlock)\n end",
"def tsort_each_node\n referenced_tables.each_key do |table|\n yield table\n end\n end",
"def tsort_each_child(node) # :yields: chi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Should be implemented by a extended class. tsort_each_child is used to iterate for child nodes of _node_. | def tsort_each_child(node) # :yields: child
raise NotImplementedError.new
end | [
"def tsort_each_child(node)\n node.nodes(:out, @label).each { |out| yield out }\n end",
"def tsort_each_node # :yields: node\n raise NotImplementedError.new\n end",
"def tsort_each_child(node)\n node.out_edges.select(&@filter).each { |edge| yield edge.to }\n end",
"def tsort_each_n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds +dependencies+ to the request set if any of the +groups+ are allowed. This is used for gemspec dependencies. | def add_dependencies(groups, dependencies) # :nodoc:
return unless (groups & @without_groups).empty?
dependencies.each do |dep|
@set.gem dep.name, *dep.requirement.as_list
end
end | [
"def add_dependencies groups, dependencies # :nodoc:\n return unless (groups & @without_groups).empty?\n\n dependencies.each do |dep|\n @set.gem dep.name, *dep.requirement\n end\n end",
"def add_dependencies(dependencies: required(\"dependencies\"), options: {}, **data)\n with_params = data.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Finds a gemspec with the given +name+ that lives at +path+. | def find_gemspec(name, path) # :nodoc:
glob = File.join path, "#{name}.gemspec"
spec_files = Dir[glob]
case spec_files.length
when 1 then
spec_file = spec_files.first
spec = Gem::Specification.load spec_file
return spec if spec
raise ArgumentError, "invalid gemspec #{spec_fi... | [
"def find(path)\n @gemspecs.each do |spec|\n return spec if matching_file(spec, path)\n end\n nil\n end",
"def find(path)\n @gemspecs.each do |spec|\n return spec if matching_file(spec, path)\n end\n nil\n end",
"def find_gemspec name, path # :nodoc:\n glob = File.join... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
:category: Gem Dependencies DSL :callseq: gem(name) gem(name, requirements) gem(name, requirements, options) Specifies a gem dependency with the given +name+ and +requirements+. You may also supply +options+ following the +requirements+ +options+ include: require: :: RubyGems does not provide any autorequire features s... | def gem(name, *requirements)
options = requirements.pop if requirements.last.kind_of?(Hash)
options ||= {}
options[:git] = @current_repository if @current_repository
source_set = false
source_set ||= gem_path name, options
source_set ||= gem_git name, options
source_set ||= g... | [
"def gem(name, *reqs)\n if dep = @dependency_names[name]\n dep.requirement.concat reqs\n else\n dep = Gem::Dependency.new name, *reqs\n @dependency_names[name] = dep\n @dependencies << dep\n end\n end",
"def gem(name, *reqs)\n @dependencies << Gem::Dependency.new(name, reqs)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Handles the git: option from +options+ for gem +name+. Returns +true+ if the gist or git option was handled. | def gem_git(name, options) # :nodoc:
if gist = options.delete(:gist)
options[:git] = "https://gist.github.com/#{gist}.git"
end
return unless repository = options.delete(:git)
pin_gem_source name, :git, repository
reference = gem_git_reference options
submodules = options.delete :submod... | [
"def gem_git_source(name, options) # :nodoc:\n return unless git_source = (@git_sources.keys & options.keys).last\n\n source_callback = @git_sources[git_source]\n source_param = options.delete git_source\n\n git_url = source_callback.call source_param\n\n options[:git] = git_url\n\n gem_git name, ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Handles the git options from +options+ for git gem. Returns reference for the git gem. | def gem_git_reference(options) # :nodoc:
ref = options.delete :ref
branch = options.delete :branch
tag = options.delete :tag
reference = nil
reference ||= ref
reference ||= branch
reference ||= tag
reference ||= 'master'
if ref && branch
warn <<-WARNING
Gem dependencies... | [
"def gem_git(name, options) # :nodoc:\n if gist = options.delete(:gist)\n options[:git] = \"https://gist.github.com/#{gist}.git\"\n end\n\n return unless repository = options.delete(:git)\n\n pin_gem_source name, :git, repository\n\n reference = gem_git_reference options\n\n submodules = opti... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Handles a git gem option from +options+ for gem +name+ for a git source registered through git_source. Returns +true+ if the custom source option was handled. | def gem_git_source(name, options) # :nodoc:
return unless git_source = (@git_sources.keys & options.keys).last
source_callback = @git_sources[git_source]
source_param = options.delete git_source
git_url = source_callback.call source_param
options[:git] = git_url
gem_git name, options
tr... | [
"def gem_github name, options # :nodoc:\n return unless path = options.delete(:github)\n\n options[:git] = \"git://github.com/#{path}.git\"\n\n gem_git name, options\n\n true\n end",
"def gem_source(name, options) # :nodoc:\n return unless source = options.delete(:source)\n\n pin_gem_source nam... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Handles the :group and :groups +options+ for the gem with the given +name+. | def gem_group(name, options) # :nodoc:
g = options.delete :group
all_groups = g ? Array(g) : []
groups = options.delete :groups
all_groups |= groups if groups
all_groups |= @current_groups if @current_groups
all_groups
end | [
"def gem_group name, options # :nodoc:\n g = options.delete :group\n all_groups = g ? Array(g) : []\n\n groups = options.delete :groups\n all_groups |= groups if groups\n\n all_groups |= @current_groups if @current_groups\n\n all_groups\n end",
"def command_line_options_group_name= name\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Handles the path: option from +options+ for gem +name+. Returns +true+ if the path option was handled. | def gem_path(name, options) # :nodoc:
return unless directory = options.delete(:path)
pin_gem_source name, :path, directory
@vendor_set.add_vendor_gem name, directory
true
end | [
"def vendorize?\n !!options[:path]\n end",
"def validate_path(options = {})\n if path_set?\n validate_path_resolves(options)\n else\n true\n end\n end",
"def option?(name)\n @option_names.include?(name) || @option_aliases.key?(name)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Handles the source: option from +options+ for gem +name+. Returns +true+ if the source option was handled. | def gem_source(name, options) # :nodoc:
return unless source = options.delete(:source)
pin_gem_source name, :source, source
@source_set.add_source_gem name, source
true
end | [
"def gem_git_source(name, options) # :nodoc:\n return unless git_source = (@git_sources.keys & options.keys).last\n\n source_callback = @git_sources[git_source]\n source_param = options.delete git_source\n\n git_url = source_callback.call source_param\n\n options[:git] = git_url\n\n gem_git name, ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Handles the platforms: option from +options+. Returns true if the platform matches the current platform. | def gem_platforms(name, options) # :nodoc:
platform_names = Array(options.delete :platform)
platform_names.concat Array(options.delete :platforms)
platform_names.concat @current_platforms if @current_platforms
return true if platform_names.empty?
platform_names.any? do |platform_name|
raise ... | [
"def gem_platforms options # :nodoc:\n platform_names = Array(options.delete :platforms)\n platform_names << @current_platform if @current_platform\n\n return true if platform_names.empty?\n\n platform_names.any? do |platform_name|\n raise ArgumentError, \"unknown platform #{platform_name.inspect}\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Records the require: option from +options+ and adds those files, or the default file to the require list for +name+. | def gem_requires(name, options) # :nodoc:
if options.include? :require
if requires = options.delete(:require)
@requires[name].concat Array requires
end
else
@requires[name] << name
end
raise ArgumentError, "Unhandled gem options #{options.inspect}" unless options.empty?
end | [
"def gem_requires name, options # :nodoc:\n if options.include? :require then\n if requires = options.delete(:require) then\n @requires[name].concat Array requires\n end\n else\n @requires[name] << name\n end\n end",
"def add_asset_files(options)\n select_assets(options).eac... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Defines a custom git source that uses +name+ to expand git repositories for use in gems built from git repositories. You must provide a block that accepts a git repository name for expansion. | def git_source(name, &callback)
@git_sources[name] = callback
end | [
"def gem_git_source(name, options) # :nodoc:\n return unless git_source = (@git_sources.keys & options.keys).last\n\n source_callback = @git_sources[git_source]\n source_param = options.delete git_source\n\n git_url = source_callback.call source_param\n\n options[:git] = git_url\n\n gem_git name, ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the basename of the file the dependencies were loaded from | def gem_deps_file # :nodoc:
File.basename @path
end | [
"def basename\n self.class.name.split(\"::\").last || \"\"\n end",
"def basename\n File.basename(source_path, File.extname(source_path))\n end",
"def caller_filename\n path = caller_locations(2, 1).first.path\n return File.basename(path)\n end",
"def basename\n basename = \"#{@... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
:category: Gem Dependencies DSL Loads dependencies from a gemspec file. +options+ include: name: :: The name portion of the gemspec file. Defaults to searching for any gemspec file in the current directory. gemspec name: 'my_gem' path: :: The path the gemspec lives in. Defaults to the current directory: gemspec 'my_gem... | def gemspec(options = {})
name = options.delete(:name) || '{,*}'
path = options.delete(:path) || '.'
development_group = options.delete(:development_group) || :development
spec = find_gemspec name, path
groups = gem_group spec.name, {}
self_dep = Gem::Dependency.new ... | [
"def insert_into_gemfile(name, options={})\r\n after_pattern = \"# Component requirements\\n\"\r\n after_pattern = \"# #{options[:group].to_s.capitalize} requirements\\n\" if group = options[:group]\r\n include_text = \"gem '#{name}'\"\r\n include_text << \", :require => #{options[:require].insp... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Pins the gem +name+ to the given +source+. Adding a gem with the same name from a different +source+ will raise an exception. | def pin_gem_source(name, type = :default, source = nil)
source_description =
case type
when :default then '(default)'
when :path then "path: #{source}"
when :git then "git: #{source}"
when :source then "source: #{source}"
else '(unknown)'
end
rais... | [
"def pin_gem_source name, type = :default, source = nil\n source_description =\n case type\n when :default then '(default)'\n when :path then \"path: #{source}\"\n when :git then \"git: #{source}\"\n else '(unknown)'\n end\n\n raise ArgumentError,\n \"du... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.