How to use latest_specs method of Gem Package

Best Rr_ruby code snippet using Gem.latest_specs

test_gem_source.rb

Source:test_gem_source.rb Github

copy

Full Screen

...93 cache_file = File.join cache_dir, "specs.#{Gem.marshal_version}"94 assert File.exist?(cache_file)95 end96 def test_load_specs_cached97 latest_specs = @source.load_specs :latest98 # Make sure the cached version is actually different:99 latest_specs << Gem::NameTuple.new('cached', Gem::Version.new('1.0.0'), 'ruby')100 @fetcher.data["#{@gem_repo}latest_specs.#{Gem.marshal_version}.gz"] = nil101 @fetcher.data["#{@gem_repo}latest_specs.#{Gem.marshal_version}"] =102 ' ' * Marshal.dump(latest_specs).length103 cache_dir = File.join Gem.spec_cache_dir, 'gems.example.com%80'104 FileUtils.mkdir_p cache_dir105 cache_file = File.join cache_dir, "latest_specs.#{Gem.marshal_version}"106 File.open cache_file, 'wb' do |io|107 Marshal.dump latest_specs, io108 end109 cached_specs = @source.load_specs :latest110 assert_equal latest_specs, cached_specs111 end112 def test_load_specs_cached_empty113 latest_specs = @source.load_specs :latest114 # Make sure the cached version is actually different:115 latest_specs << Gem::NameTuple.new('fixed', Gem::Version.new('1.0.0'), 'ruby')116 # Setup valid data on the 'remote'117 @fetcher.data["#{@gem_repo}latest_specs.#{Gem.marshal_version}.gz"] =118 util_gzip(Marshal.dump(latest_specs))119 cache_dir = File.join Gem.spec_cache_dir, 'gems.example.com%80'120 FileUtils.mkdir_p cache_dir121 cache_file = File.join cache_dir, "latest_specs.#{Gem.marshal_version}"122 File.open cache_file, 'wb' do |io|123 # Setup invalid data in the cache:124 io.write Marshal.dump(latest_specs)[0, 10]125 end126 fixed_specs = @source.load_specs :latest127 assert_equal latest_specs, fixed_specs128 end129 def test_load_specs_from_unavailable_uri130 src = Gem::Source.new("http://not-there.nothing")131 assert_raises Gem::RemoteFetcher::FetchError do132 src.load_specs :latest133 end134 end135 def test_spaceship136 remote = @source137 specific = Gem::Source::SpecificFile.new @specs['a-1'].cache_file138 installed = Gem::Source::Installed.new139 local = Gem::Source::Local.new140 assert_equal( 0, remote. <=>(remote), 'remote <=> remote')141 assert_equal(-1, remote. <=>(specific), 'remote <=> specific')...

Full Screen

Full Screen

subcommand_loader_spec.rb

Source:subcommand_loader_spec.rb Github

copy

Full Screen

...38 '/usr/lib/ruby/gems/knife-ec2-0.5.12/lib/chef/knife/ec2_base.rb',39 '/usr/lib/ruby/gems/knife-ec2-0.5.12/lib/chef/knife/ec2_otherstuff.rb'40 ]41 $LOAD_PATH.should_receive(:map).and_return([])42 if Gem::Specification.respond_to? :latest_specs43 Gem::Specification.should_receive(:latest_specs).with(true).and_return(gems)44 gems[0].should_receive(:matches_for_glob).with(/chef\/knife\/\*\.rb\{(.*),\.rb,(.*)\}/).and_return(gem_files)45 else46 Gem.source_index.should_receive(:latest_specs).with(true).and_return(gems)47 gems[0].should_receive(:require_paths).twice.and_return(['lib'])48 gems[0].should_receive(:full_gem_path).and_return('/usr/lib/ruby/gems/knife-ec2-0.5.12')49 Dir.should_receive(:[]).with('/usr/lib/ruby/gems/knife-ec2-0.5.12/lib/chef/knife/*.rb').and_return(gem_files)50 end51 @loader.should_receive(:find_subcommands_via_dirglob).and_return({})52 @loader.find_subcommands_via_rubygems.values.select { |file| file =~ /knife-ec2/ }.sort.should == gem_files53 end54 it "finds files using a dirglob when rubygems is not available" do55 @loader.find_subcommands_via_dirglob.should include('chef/knife/node_create')56 @loader.find_subcommands_via_dirglob.each {|rel_path, abs_path| abs_path.should match(%r[chef/knife/.+])}57 end58 it "finds user-specific subcommands in the user's ~/.chef directory" do59 expected_command = File.join(@home, '.chef', 'plugins', 'knife', 'example_home_subcommand.rb')60 @loader.site_subcommands.should include(expected_command)61 end62 it "finds repo specific subcommands by searching for a .chef directory" do63 expected_command = File.join(CHEF_SPEC_DATA, 'knife-site-subcommands', 'plugins', 'knife', 'example_subcommand.rb')64 @loader.site_subcommands.should include(expected_command)65 end66 describe "finding 3rd party plugins" do 67 let(:env_home) { "/home/alice" }68 let(:manifest_path) { env_home + "/.chef/plugin_manifest.json" }69 before do70 env_dup = ENV.to_hash71 ENV.stub(:[]).and_return { |key| env_dup[key] }72 ENV.stub(:[]).with("HOME").and_return(env_home)73 end74 context "when there is not a ~/.chef/plugin_manifest.json file" do75 before do76 File.stub(:exist?).with(manifest_path).and_return(false)77 end78 it "searches rubygems for plugins" do79 if Gem::Specification.respond_to?(:latest_specs)80 Gem::Specification.should_receive(:latest_specs).and_call_original81 else82 Gem.source_index.should_receive(:latest_specs).and_call_original83 end84 @loader.subcommand_files.each do |require_path|85 require_path.should match(/chef\/knife\/.*|plugins\/knife\/.*/)86 end87 end88 context "and HOME environment variable is not set" do89 before do90 ENV.stub(:[]).with("HOME").and_return(nil)91 end92 it "searches rubygems for plugins" do93 if Gem::Specification.respond_to?(:latest_specs)94 Gem::Specification.should_receive(:latest_specs).and_call_original95 else96 Gem.source_index.should_receive(:latest_specs).and_call_original97 end98 @loader.subcommand_files.each do |require_path|99 require_path.should match(/chef\/knife\/.*|plugins\/knife\/.*/)100 end101 end102 end103 end104 context "when there is a ~/.chef/plugin_manifest.json file" do105 let(:ec2_server_create_plugin) { "/usr/lib/ruby/gems/knife-ec2-0.5.12/lib/chef/knife/ec2_server_create.rb" }106 let(:manifest_content) do107 { "plugins" => {108 "knife-ec2" => {109 "paths" => [110 ec2_server_create_plugin111 ]112 }113 }114 }115 end116 let(:manifest_json) { Chef::JSONCompat.to_json(manifest_content) }117 before do118 File.stub(:exist?).with(manifest_path).and_return(true)119 File.stub(:read).with(manifest_path).and_return(manifest_json)120 end121 it "uses paths from the manifest instead of searching gems" do122 Gem::Specification.should_not_receive(:latest_specs).and_call_original123 @loader.subcommand_files.should include(ec2_server_create_plugin)124 end125 end126 end127end...

Full Screen

Full Screen

show.rb

Source:show.rb Github

copy

Full Screen

1# frozen_string_literal: true2module Bundler3 class CLI::Show4 attr_reader :options, :gem_name, :latest_specs5 def initialize(options, gem_name)6 @options = options7 @gem_name = gem_name8 @verbose = options[:verbose] || options[:outdated]9 @latest_specs = fetch_latest_specs if @verbose10 end11 def run12 Bundler.ui.silence do13 Bundler.definition.validate_runtime!14 Bundler.load.lock15 end16 if gem_name17 if gem_name == "bundler"18 path = File.expand_path("../../../..", __FILE__)19 else20 spec = Bundler::CLI::Common.select_spec(gem_name, :regex_match)21 return unless spec22 path = spec.full_gem_path23 unless File.directory?(path)24 Bundler.ui.warn "The gem #{gem_name} has been deleted. It was installed at:"25 end26 end27 return Bundler.ui.info(path)28 end29 if options[:paths]30 Bundler.load.specs.sort_by(&:name).map do |s|31 Bundler.ui.info s.full_gem_path32 end33 else34 Bundler.ui.info "Gems included by the bundle:"35 Bundler.load.specs.sort_by(&:name).each do |s|36 desc = " * #{s.name} (#{s.version}#{s.git_version})"37 if @verbose38 latest = latest_specs.find {|l| l.name == s.name }39 Bundler.ui.info <<-END.gsub(/^ +/, "")40 #{desc}41 \tSummary: #{s.summary || "No description available."}42 \tHomepage: #{s.homepage || "No website available."}43 \tStatus: #{outdated?(s, latest) ? "Outdated - #{s.version} < #{latest.version}" : "Up to date"}44 END45 else46 Bundler.ui.info desc47 end48 end49 end50 end51 private52 def fetch_latest_specs53 definition = Bundler.definition(true)54 if options[:outdated]55 Bundler.ui.info "Fetching remote specs for outdated check...\n\n"56 Bundler.ui.silence { definition.resolve_remotely! }57 else58 definition.resolve_with_cache!59 end60 Bundler.reset!61 definition.specs62 end63 def outdated?(current, latest)64 return false unless latest65 Gem::Version.new(current.version) < Gem::Version.new(latest.version)66 end...

Full Screen

Full Screen

latest_specs

Using AI Code Generation

copy

Full Screen

1pp Gem::Specification.map { |g| g.name }2pp Gem::Specification.map { |g| g.name }3pp Gem::Specification.map { |g| g.name }4pp Gem::Specification.map { |g| g.name }5pp Gem::Specification.map { |g| g.name }6pp Gem::Specification.map { |g| g.name }7pp Gem::Specification.map { |g| g.name }8pp Gem::Specification.map { |g| g.name }9pp Gem::Specification.map { |g| g.name }10pp Gem::Specification.map { |g| g.name }

Full Screen

Full Screen

latest_specs

Using AI Code Generation

copy

Full Screen

1pp Gem.search(/.*/)2pp Gem.search(/^a/)3pp Gem.search(/^a.*s$/)4pp Gem.search(/^a.*r.*s$/)5pp Gem.search(/^a.*r.*s$/, '= 0.1.0')6pp Gem.search(/^a.*r.*s$/, '= 0.1.0', 'java')

Full Screen

Full Screen

latest_specs

Using AI Code Generation

copy

Full Screen

1latest_version = Gem.latest_specs('gem_name').first.version2latest_version = Gem::Specification.latest_specs(true).find { |spec| spec.name == 'gem_name' }.version3latest_version = Gem::Specification.find_by_name('gem_name').version4latest_version = Gem.latest_specs('gem_name').first.version5latest_version = Gem::Specification.latest_specs(true).find { |spec| spec.name == 'gem_name' }.version6latest_version = Gem::Specification.find_by_name('gem_name').version

Full Screen

Full Screen

latest_specs

Using AI Code Generation

copy

Full Screen

1installer.install("activesupport", "~> 3.0.0")2installer = pp Gem::Specification.map { 3require 'rubygeme/de }ndency_installer'4installer.install("ativesupport", "~> 30.0")5installer.install("activesupport" "~> 3.0.0")6installer.install("activesupport", "~> 3.0.0")7installer.install("activesupport", "~> 3.0.0")8installer.install("activesupport", "~> 3.0.0"9installer.install("act

Full Screen

Full Screen

latest_specs

Using AI Code Generation

copy

Full Screen

1pp latest_specs.map {|spec| spec.name}2pp Gem::Specification.map { |g| g.name }3pp Gem::Specification.map { |g| g.name }4pp Gem::Specification.map { |g| g.name }5pp Gem::Specification.map { |g| g.name }6pp Gem::Specification.map { |g| g.name }7pp Gem::Specification.map { |g| g.name }8pp Gem::Specification.map { |g| g.name }9pp Gem::Specification.map { |g| g.name }

Full Screen

Full Screen

latest_specs

Using AI Code Generation

copy

Full Screen

1pp Gem.search(/.*/)2pp Gem.search(/^a/)3pp Gem.search(/^a.*s$/)4pp Gem.search(/^a.*r.*s$/)5pp Gem.search(/^a.*r.*s$/, '= 0.1.0')6pp Gem.search(/^a.*r.*s$/, '= 0.1.0', 'java')

Full Screen

Full Screen

latest_specs

Using AI Code Generation

copy

Full Screen

1latest_version = Gem.latest_specs('gem_name').first.version2latest_version = Gem::Specification.latest_specs(true).find { |spec| spec.name == 'gem_name' }.version3latest_version = Gem::Specification.find_by_name('gem_name').version4latest_version = Gem.latest_specs('gem_name').first.version5latest_version = Gem::Specification.latest_specs(true).find { |spec| spec.name == 'gem_name' }.version6latest_version = Gem::Specification.find_by_name('gem_name').version

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful