Best Selenium code snippet using Platform.engine
test_gem_request_set_gem_dependency_api.rb
Source:test_gem_request_set_gem_dependency_api.rb
...11 @gda = @GDA.new @set, 'gem.deps.rb'12 @gda.instance_variable_set :@git_set, @git_set13 @gda.instance_variable_set :@vendor_set, @vendor_set14 end15 def with_engine_version(name, version)16 engine = RUBY_ENGINE if Object.const_defined? :RUBY_ENGINE17 engine_version_const = "#{Gem.ruby_engine.upcase}_VERSION"18 engine_version = Object.const_get engine_version_const19 Object.send :remove_const, :RUBY_ENGINE if engine20 Object.send :remove_const, engine_version_const if name == 'ruby' and21 Object.const_defined? engine_version_const22 new_engine_version_const = "#{name.upcase}_VERSION"23 Object.const_set :RUBY_ENGINE, name if name24 Object.const_set new_engine_version_const, version if version25 Gem.instance_variable_set :@ruby_version, Gem::Version.new(version)26 yield27 ensure28 Object.send :remove_const, :RUBY_ENGINE if name29 Object.send :remove_const, new_engine_version_const if version30 Object.send :remove_const, engine_version_const if name == 'ruby' and31 Object.const_defined? engine_version_const32 Object.const_set :RUBY_ENGINE, engine if engine33 Object.const_set engine_version_const, engine_version unless34 Object.const_defined? engine_version_const35 Gem.send :remove_instance_variable, :@ruby_version if36 Gem.instance_variables.include? :@ruby_version37 end38 def test_gempspec_with_multiple_runtime_deps39 save_gemspec 'foo', '1.0' do |s|40 s.add_runtime_dependency 'bar', '>= 1.6.0', '< 1.6.4'41 end42 @gda.gemspec43 assert_equal %w{ foo bar }.sort, @set.dependencies.map(&:name).sort44 bar = @set.dependencies.find { |d| d.name == 'bar' }45 assert_equal [["<", Gem::Version.create('1.6.4')],46 [">=", Gem::Version.create('1.6.0')]], bar.requirement.requirements.sort47 end48 def test_gemspec_without_group49 @gda.send :add_dependencies, [:development], [dep('a', '= 1')]50 assert_equal [dep('a', '= 1')], @set.dependencies51 @gda.without_groups << :development52 @gda.send :add_dependencies, [:development], [dep('b', '= 2')]53 assert_equal [dep('a', '= 1')], @set.dependencies54 end55 def test_gem56 @gda.gem 'a'57 assert_equal [dep('a')], @set.dependencies58 assert_equal %w[a], @gda.requires['a']59 expected = { 'a' => Gem::Requirement.default }60 assert_equal expected, @gda.dependencies61 end62 def test_gem_duplicate63 @gda.gem 'a'64 _, err = capture_io do65 @gda.gem 'a'66 end67 expected = "Gem dependencies file gem.deps.rb requires a more than once."68 assert_match expected, err69 end70 def test_gem_git71 @gda.gem 'a', :git => 'git/a'72 assert_equal [dep('a')], @set.dependencies73 assert_equal %w[git/a master], @git_set.repositories['a']74 expected = { 'a' => Gem::Requirement.create('!') }75 assert_equal expected, @gda.dependencies76 end77 def test_gem_bitbucket78 @gda.gem 'a', :bitbucket => 'example/repository'79 assert_equal [dep('a')], @set.dependencies80 assert_equal %w[https://example@bitbucket.org/example/repository.git master],81 @git_set.repositories['a']82 expected = { 'a' => Gem::Requirement.create('!') }83 assert_equal expected, @gda.dependencies84 end85 def test_gem_bitbucket_expand_path86 @gda.gem 'a', :bitbucket => 'example'87 assert_equal [dep('a')], @set.dependencies88 assert_equal %w[https://example@bitbucket.org/example/example.git master],89 @git_set.repositories['a']90 expected = { 'a' => Gem::Requirement.create('!') }91 assert_equal expected, @gda.dependencies92 end93 def test_gem_git_branch94 _, err = capture_io do95 @gda.gem 'a', :git => 'git/a', :branch => 'other', :tag => 'v1'96 end97 expected = "Gem dependencies file gem.deps.rb includes git reference for both ref/branch and tag but only ref/branch is used."98 assert_match expected, err99 assert_equal [dep('a')], @set.dependencies100 assert_equal %w[git/a other], @git_set.repositories['a']101 end102 def test_gem_git_gist103 @gda.gem 'a', :gist => 'a'104 assert_equal [dep('a')], @set.dependencies105 assert_equal %w[https://gist.github.com/a.git master],106 @git_set.repositories['a']107 end108 def test_gem_git_ref109 _, err = capture_io do110 @gda.gem 'a', :git => 'git/a', :ref => 'abcd123', :branch => 'other'111 end112 expected = "Gem dependencies file gem.deps.rb includes git reference for both ref and branch but only ref is used."113 assert_match expected, err114 assert_equal [dep('a')], @set.dependencies115 assert_equal %w[git/a abcd123], @git_set.repositories['a']116 end117 def test_gem_git_submodules118 @gda.gem 'a', :git => 'git/a', :submodules => true119 assert_equal [dep('a')], @set.dependencies120 assert_equal %w[git/a master], @git_set.repositories['a']121 assert_equal %w[git/a], @git_set.need_submodules.keys122 end123 def test_gem_git_tag124 @gda.gem 'a', :git => 'git/a', :tag => 'v1'125 assert_equal [dep('a')], @set.dependencies126 assert_equal %w[git/a v1], @git_set.repositories['a']127 end128 def test_gem_github129 @gda.gem 'a', :github => 'example/repository'130 assert_equal [dep('a')], @set.dependencies131 assert_equal %w[git://github.com/example/repository.git master],132 @git_set.repositories['a']133 expected = { 'a' => Gem::Requirement.create('!') }134 assert_equal expected, @gda.dependencies135 end136 def test_gem_github_expand_path137 @gda.gem 'a', :github => 'example'138 assert_equal [dep('a')], @set.dependencies139 assert_equal %w[git://github.com/example/example.git master],140 @git_set.repositories['a']141 expected = { 'a' => Gem::Requirement.create('!') }142 assert_equal expected, @gda.dependencies143 end144 def test_gem_group145 @gda.gem 'a', :group => :test146 assert_equal [dep('a')], @set.dependencies147 end148 def test_gem_group_without149 @gda.without_groups << :test150 @gda.gem 'a', :group => :test151 assert_empty @set.dependencies152 expected = { 'a' => Gem::Requirement.default }153 assert_equal expected, @gda.dependencies154 end155 def test_gem_groups156 @gda.gem 'a', :groups => [:test, :development]157 assert_equal [dep('a')], @set.dependencies158 end159 def test_gem_path160 name, version, directory = vendor_gem161 @gda.gem name, :path => directory162 assert_equal [dep(name)], @set.dependencies163 loaded = @vendor_set.load_spec(name, version, Gem::Platform::RUBY, nil)164 assert_equal "#{name}-#{version}", loaded.full_name165 expected = { name => Gem::Requirement.create('!') }166 assert_equal expected, @gda.dependencies167 end168 def test_gem_platforms169 win_platform, Gem.win_platform = Gem.win_platform?, false170 with_engine_version 'ruby', '2.0.0' do171 @gda.gem 'a', :platforms => :ruby172 refute_empty @set.dependencies173 end174 ensure175 Gem.win_platform = win_platform176 end177 def test_gem_platforms_bundler_ruby178 win_platform, Gem.win_platform = Gem.win_platform?, false179 with_engine_version 'ruby', '2.0.0' do180 set = Gem::RequestSet.new181 gda = @GDA.new set, 'gem.deps.rb'182 gda.gem 'a', :platforms => :ruby183 refute_empty set.dependencies184 end185 with_engine_version 'rbx', '2.0.0' do186 set = Gem::RequestSet.new187 gda = @GDA.new set, 'gem.deps.rb'188 gda.gem 'a', :platforms => :ruby189 refute_empty set.dependencies190 end191 with_engine_version 'jruby', '1.7.6' do192 set = Gem::RequestSet.new193 gda = @GDA.new set, 'gem.deps.rb'194 gda.gem 'a', :platforms => :ruby195 assert_empty set.dependencies196 end197 Gem.win_platform = true198 with_engine_version 'ruby', '2.0.0' do199 set = Gem::RequestSet.new200 gda = @GDA.new set, 'gem.deps.rb'201 gda.gem 'a', :platforms => :ruby202 assert_empty set.dependencies203 end204 Gem.win_platform = win_platform205 end206 def test_gem_platforms_engine207 with_engine_version 'jruby', '1.7.6' do208 @gda.gem 'a', :platforms => :mri209 assert_empty @set.dependencies210 end211 end212 def test_gem_platforms_maglev213 win_platform, Gem.win_platform = Gem.win_platform?, false214 with_engine_version 'maglev', '1.0.0' do215 set = Gem::RequestSet.new216 gda = @GDA.new set, 'gem.deps.rb'217 gda.gem 'a', :platforms => :ruby218 refute_empty set.dependencies219 set = Gem::RequestSet.new220 gda = @GDA.new set, 'gem.deps.rb'221 gda.gem 'a', :platforms => :maglev222 refute_empty set.dependencies223 end224 ensure225 Gem.win_platform = win_platform226 end227 def test_gem_platforms_multiple228 win_platform, Gem.win_platform = Gem.win_platform?, false229 with_engine_version 'ruby', '2.0.0' do230 @gda.gem 'a', :platforms => [:mswin, :jruby]231 assert_empty @set.dependencies232 end233 ensure234 Gem.win_platform = win_platform235 end236 def test_gem_platforms_platform237 win_platform, Gem.win_platform = Gem.win_platform?, false238 with_engine_version 'ruby', '2.0.0' do239 @gda.gem 'a', :platforms => :jruby, :platform => :ruby240 refute_empty @set.dependencies241 end242 ensure243 Gem.win_platform = win_platform244 end245 def test_gem_platforms_version246 with_engine_version 'ruby', '2.0.0' do247 @gda.gem 'a', :platforms => :ruby_18248 assert_empty @set.dependencies249 end250 end251 def test_gem_platforms_unknown252 e = assert_raises ArgumentError do253 @gda.gem 'a', :platforms => :unknown254 end255 assert_equal 'unknown platform :unknown', e.message256 end257 def test_gem_requires258 @gda.gem 'a', :require => %w[b c]259 @gda.gem 'd', :require => 'e'260 assert_equal [dep('a'), dep('d')], @set.dependencies261 assert_equal %w[b c], @gda.requires['a']262 assert_equal %w[e], @gda.requires['d']263 end264 def test_gem_requires_false265 @gda.gem 'a', :require => false266 assert_equal [dep('a')], @set.dependencies267 assert_empty @gda.requires268 end269 def test_gem_requires_without_group270 @gda.without_groups << :test271 @gda.gem 'a', :group => :test272 assert_empty @set.dependencies273 assert_empty @gda.requires['a']274 end275 def test_gem_requirement276 @gda.gem 'a', '~> 1.0'277 assert_equal [dep('a', '~> 1.0')], @set.dependencies278 expected = { 'a' => Gem::Requirement.create(['~> 1.0']) }279 assert_equal expected, @gda.dependencies280 end281 def test_gem_requirements282 @gda.gem 'b', '~> 1.0', '>= 1.0.2'283 assert_equal [dep('b', '~> 1.0', '>= 1.0.2')], @set.dependencies284 expected = { 'b' => Gem::Requirement.create(['~> 1.0', '>= 1.0.2']) }285 assert_equal expected, @gda.dependencies286 end287 def test_gem_requirements_options288 @gda.gem 'c', :git => 'https://example/c.git'289 assert_equal [dep('c')], @set.dependencies290 end291 def test_gem_source_mismatch292 name, _, directory = vendor_gem293 gda = @GDA.new @set, nil294 gda.gem name295 e = assert_raises ArgumentError do296 gda.gem name, :path => directory297 end298 assert_equal "duplicate source path: #{directory} for gem #{name}",299 e.message300 gda = @GDA.new @set, nil301 gda.instance_variable_set :@vendor_set, @vendor_set302 gda.gem name, :path => directory303 e = assert_raises ArgumentError do304 gda.gem name305 end306 assert_equal "duplicate source (default) for gem #{name}",307 e.message308 end309 def test_gem_deps_file310 assert_equal 'gem.deps.rb', @gda.gem_deps_file311 gda = @GDA.new @set, 'foo/Gemfile'312 assert_equal 'Gemfile', gda.gem_deps_file313 end314 def test_gem_group_method315 groups = []316 @gda.group :a do317 groups = @gda.send :gem_group, 'a', :group => :b, :groups => [:c, :d]318 end319 assert_equal [:a, :b, :c, :d], groups.sort_by { |group| group.to_s }320 end321 def test_gemspec322 save_gemspec 'a', 1 do |s|323 s.add_dependency 'b', 2324 s.add_development_dependency 'c', 3325 end326 @gda.gemspec327 assert_equal [dep('a', '= 1'), dep('b', '= 2'), dep('c', '=3')],328 @set.dependencies329 assert_equal %w[a], @gda.requires['a']330 expected = {331 'a' => Gem::Requirement.create('!'),332 'b' => req('= 2'),333 'c' => req('= 3'),334 }335 assert_equal expected, @gda.dependencies336 end337 def test_gemspec_bad338 FileUtils.touch 'a.gemspec'339 e = assert_raises ArgumentError do340 capture_io do341 @gda.gemspec342 end343 end344 assert_equal 'invalid gemspec ./a.gemspec', e.message345 end346 def test_gemspec_development_group347 save_gemspec 'a', 1 do |s|348 s.add_dependency 'b', 2349 s.add_development_dependency 'c', 3350 end351 @gda.without_groups << :other352 @gda.gemspec :development_group => :other353 assert_equal [dep('a', '= 1'), dep('b', '= 2')], @set.dependencies354 assert_equal %w[a], @gda.requires['a']355 end356 def test_gemspec_multiple357 save_gemspec 'a', 1 do |s|358 s.add_dependency 'b', 2359 end360 save_gemspec 'b', 2 do |s|361 s.add_dependency 'c', 3362 end363 e = assert_raises ArgumentError do364 @gda.gemspec365 end366 assert_equal "found multiple gemspecs at #{@tempdir}, use the name: option to specify the one you want", e.message367 end368 def test_gemspec_name369 save_gemspec 'a', 1 do |s|370 s.add_dependency 'b', 2371 end372 save_gemspec 'b', 2 do |s|373 s.add_dependency 'c', 3374 end375 @gda.gemspec :name => 'b'376 assert_equal [dep('b', '= 2'), dep('c', '= 3')], @set.dependencies377 end378 def test_gemspec_named379 save_gemspec 'a', 1 do |s|380 s.add_dependency 'b', 2381 end382 @gda.gemspec383 assert_equal [dep('a', '= 1'), dep('b', '= 2')], @set.dependencies384 end385 def test_gemspec_none386 e = assert_raises ArgumentError do387 @gda.gemspec388 end389 assert_equal "no gemspecs found at #{@tempdir}", e.message390 end391 def test_gemspec_path392 FileUtils.mkdir 'other'393 save_gemspec 'a', 1, 'other' do |s|394 s.add_dependency 'b', 2395 end396 @gda.gemspec :path => 'other'397 assert_equal [dep('a', '= 1'), dep('b', '= 2')], @set.dependencies398 end399 def test_git400 @gda.git 'git://example/repo.git' do401 @gda.gem 'a'402 @gda.gem 'b'403 end404 assert_equal [dep('a'), dep('b')], @set.dependencies405 assert_equal %w[git://example/repo.git master], @git_set.repositories['a']406 assert_equal %w[git://example/repo.git master], @git_set.repositories['b']407 end408 def test_git_source409 @gda.git_source :example do |repo_name|410 "git://example/#{repo_name}.git"411 end412 @gda.gem 'a', :example => 'repo'413 assert_equal %w[git://example/repo.git master], @git_set.repositories['a']414 end415 def test_group416 @gda.group :test do417 @gda.gem 'a'418 end419 assert_equal [dep('a')], @set.dependencies420 end421 def test_load422 tf = Tempfile.open 'gem.deps.rb' do |io|423 io.write <<-GEM_DEPS424gem 'a'425group :test do426 gem 'b'427end428 GEM_DEPS429 io.flush430 gda = @GDA.new @set, io.path431 assert_equal gda, gda.load432 assert_equal [dep('a'), dep('b')], @set.dependencies433 io434 end435 tf.close!436 end437 def test_pin_gem_source438 gda = @GDA.new @set, nil439 gda.send :pin_gem_source, 'a'440 gda.send :pin_gem_source, 'a'441 e = assert_raises ArgumentError do442 gda.send :pin_gem_source, 'a', :path, 'vendor/a'443 end444 assert_equal "duplicate source path: vendor/a for gem a",445 e.message446 e = assert_raises ArgumentError do447 gda.send :pin_gem_source, 'a', :git, 'git://example/repo.git'448 end449 assert_equal "duplicate source git: git://example/repo.git for gem a",450 e.message451 end452 def test_platform_mswin453 util_set_arch 'i686-darwin8.10.1' do454 @gda.platform :mswin do455 @gda.gem 'a'456 end457 assert_empty @set.dependencies458 end459 util_set_arch 'x86-mswin32-60' do460 @gda.platform :mswin do461 @gda.gem 'a'462 end463 refute_empty @set.dependencies464 end465 end466 def test_platform_multiple467 win_platform, Gem.win_platform = Gem.win_platform?, false468 gda = @GDA.new @set, nil469 with_engine_version 'ruby', '1.8.7' do470 gda.platform :mri_19, :mri_20 do471 gda.gem 'a'472 end473 end474 assert_empty @set.dependencies475 gda = @GDA.new @set, nil476 with_engine_version 'ruby', '2.0.0' do477 gda.platform :mri_19, :mri_20 do478 gda.gem 'a'479 end480 end481 refute_empty @set.dependencies482 ensure483 Gem.win_platform = win_platform484 end485 def test_platform_ruby486 win_platform, Gem.win_platform = Gem.win_platform?, false487 @gda.platform :ruby do488 @gda.gem 'a'489 end490 assert_equal [dep('a')], @set.dependencies491 ensure492 Gem.win_platform = win_platform493 end494 def test_platforms495 util_set_arch 'i686-darwin8.10.1' do496 @gda.platforms :ruby do497 @gda.gem 'a'498 end499 assert_equal [dep('a')], @set.dependencies500 @gda.platforms :mswin do501 @gda.gem 'b'502 end503 assert_equal [dep('a')], @set.dependencies504 end505 util_set_arch 'x86-mswin32-60' do506 @gda.platforms :mswin do507 @gda.gem 'c'508 end509 assert_equal [dep('a'), dep('c')], @set.dependencies510 end511 end512 def test_ruby513 assert @gda.ruby RUBY_VERSION514 end515 def test_ruby_engine516 with_engine_version 'jruby', '1.7.6' do517 assert @gda.ruby RUBY_VERSION,518 :engine => 'jruby', :engine_version => '1.7.6'519 end520 end521 def test_ruby_engine_mismatch_engine522 with_engine_version 'ruby', '2.0.0' do523 e = assert_raises Gem::RubyVersionMismatch do524 @gda.ruby RUBY_VERSION, :engine => 'jruby', :engine_version => '1.7.4'525 end526 assert_equal 'Your Ruby engine is ruby, but your gem.deps.rb requires jruby',527 e.message528 end529 end530 def test_ruby_engine_mismatch_version531 with_engine_version 'jruby', '1.7.6' do532 e = assert_raises Gem::RubyVersionMismatch do533 @gda.ruby RUBY_VERSION, :engine => 'jruby', :engine_version => '1.7.4'534 end535 assert_equal 'Your Ruby engine version is jruby 1.7.6, but your gem.deps.rb requires jruby 1.7.4',536 e.message537 end538 end539 def test_ruby_engine_no_engine_version540 e = assert_raises ArgumentError do541 @gda.ruby RUBY_VERSION, :engine => 'jruby'542 end543 assert_equal 'You must specify engine_version along with the Ruby engine',544 e.message545 end546 def test_ruby_mismatch547 e = assert_raises Gem::RubyVersionMismatch do548 @gda.ruby '1.8.0'549 end550 assert_equal "Your Ruby version is #{RUBY_VERSION}, but your gem.deps.rb requires 1.8.0", e.message551 end552 def test_ruby_mismatch_installing553 @gda.installing = true554 assert @gda.ruby '1.8.0'555 end556 def test_source557 sources = Gem.sources558 @gda.source 'http://first.example'559 assert_equal %w[http://first.example], Gem.sources560 assert_same sources, Gem.sources561 @gda.source 'http://second.example'562 assert_equal %w[http://first.example http://second.example], Gem.sources563 end564 def test_with_engine_version565 version = RUBY_VERSION566 engine = Gem.ruby_engine567 engine_version_const = "#{Gem.ruby_engine.upcase}_VERSION"568 engine_version = Object.const_get engine_version_const569 with_engine_version 'other', '1.2.3' do570 assert_equal 'other', Gem.ruby_engine571 assert_equal '1.2.3', OTHER_VERSION572 assert_equal version, RUBY_VERSION if engine573 end574 assert_equal version, RUBY_VERSION575 assert_equal engine, Gem.ruby_engine576 assert_equal engine_version, Object.const_get(engine_version_const) if577 engine578 end579end...
gem_dependency_api.rb
Source:gem_dependency_api.rb
...249 platform_names.any? do |platform_name|250 raise ArgumentError, "unknown platform #{platform_name.inspect}" unless251 platform = PLATFORM_MAP[platform_name]252 next false unless Gem::Platform.match platform253 if engines = ENGINE_MAP[platform_name] then254 next false unless engines.include? Gem.ruby_engine255 end256 case WINDOWS[platform_name]257 when :only then258 next false unless Gem.win_platform?259 when :never then260 next false if Gem.win_platform?261 end262 VERSION_MAP[platform_name].satisfied_by? Gem.ruby_version263 end264 end265 private :gem_platforms266 ##267 # Handles the require: option from +options+ and adds those files, or the268 # default file to the require list for +name+.269 def gem_requires name, options # :nodoc:270 if options.include? :require then271 if requires = options.delete(:require) then272 @requires[name].concat Array requires273 end274 else275 @requires[name] << name276 end277 end278 private :gem_requires279 ##280 # :category: Gem Dependencies DSL281 #282 # Block form for specifying gems from a git +repository+.283 def git repository284 @current_repository = repository285 yield286 ensure287 @current_repository = nil288 end289 ##290 # Returns the basename of the file the dependencies were loaded from291 def gem_deps_file # :nodoc:292 File.basename @path293 end294 ##295 # :category: Gem Dependencies DSL296 #297 # Loads dependencies from a gemspec file.298 def gemspec options = {}299 name = options.delete(:name) || '{,*}'300 path = options.delete(:path) || '.'301 development_group = options.delete(:development_group) || :development302 spec = find_gemspec name, path303 groups = gem_group spec.name, {}304 add_dependencies groups, spec.runtime_dependencies305 groups << development_group306 add_dependencies groups, spec.development_dependencies307 gem_requires spec.name, options308 end309 ##310 # :category: Gem Dependencies DSL311 # Block form for placing a dependency in the given +groups+.312 def group *groups313 @current_groups = groups314 yield315 ensure316 @current_groups = nil317 end318 ##319 # Pins the gem +name+ to the given +source+. Adding a gem with the same320 # name from a different +source+ will raise an exception.321 def pin_gem_source name, type = :default, source = nil322 source_description =323 case type324 when :default then '(default)'325 when :path then "path: #{source}"326 when :git then "git: #{source}"327 else '(unknown)'328 end329 raise ArgumentError,330 "duplicate source #{source_description} for gem #{name}" if331 @gem_sources.fetch(name, source) != source332 @gem_sources[name] = source333 end334 private :pin_gem_source335 ##336 # :category: Gem Dependencies DSL337 #338 # Block form for restricting gems to a particular platform.339 def platform what340 @current_platform = what341 yield342 ensure343 @current_platform = nil344 end345 ##346 # :category: Gem Dependencies DSL347 #348 # Block form for restricting gems to a particular platform.349 alias :platforms :platform350 ##351 # :category: Gem Dependencies DSL352 # Restricts this gem dependencies file to the given ruby +version+. The353 # +:engine+ options from Bundler are currently ignored.354 def ruby version, options = {}355 engine = options[:engine]356 engine_version = options[:engine_version]357 raise ArgumentError,358 'you must specify engine_version along with the ruby engine' if359 engine and not engine_version360 unless RUBY_VERSION == version then361 message = "Your Ruby version is #{RUBY_VERSION}, " +362 "but your #{gem_deps_file} requires #{version}"363 raise Gem::RubyVersionMismatch, message364 end365 if engine and engine != Gem.ruby_engine then366 message = "Your ruby engine is #{Gem.ruby_engine}, " +367 "but your #{gem_deps_file} requires #{engine}"368 raise Gem::RubyVersionMismatch, message369 end370 if engine_version then371 my_engine_version = Object.const_get "#{Gem.ruby_engine.upcase}_VERSION"372 if engine_version != my_engine_version then373 message =374 "Your ruby engine version is #{Gem.ruby_engine} #{my_engine_version}, " +375 "but your #{gem_deps_file} requires #{engine} #{engine_version}"376 raise Gem::RubyVersionMismatch, message377 end378 end379 return true380 end381 ##382 # :category: Gem Dependencies DSL383 #384 # Sets +url+ as a source for gems for this dependency API.385 def source url386 Gem.sources.clear if @default_sources387 @default_sources = false388 Gem.sources << url389 end...
dependency.rb
Source:dependency.rb
1require 'rubygems/dependency'2require 'bundler/shared_helpers'3require 'bundler/rubygems_ext'4module Bundler5 class Dependency < Gem::Dependency6 attr_reader :autorequire7 attr_reader :groups8 attr_reader :platforms9 PLATFORM_MAP = {10 :ruby => Gem::Platform::RUBY,11 :ruby_18 => Gem::Platform::RUBY,12 :ruby_19 => Gem::Platform::RUBY,13 :ruby_20 => Gem::Platform::RUBY,14 :mri => Gem::Platform::RUBY,15 :mri_18 => Gem::Platform::RUBY,16 :mri_19 => Gem::Platform::RUBY,17 :mri_20 => Gem::Platform::RUBY,18 :rbx => Gem::Platform::RUBY,19 :jruby => Gem::Platform::JAVA,20 :mswin => Gem::Platform::MSWIN,21 :mingw => Gem::Platform::MINGW,22 :mingw_18 => Gem::Platform::MINGW,23 :mingw_19 => Gem::Platform::MINGW,24 :mingw_20 => Gem::Platform::MINGW25 }.freeze26 def initialize(name, version, options = {}, &blk)27 type = options["type"] || :runtime28 super(name, version, type)29 @autorequire = nil30 @groups = Array(options["group"] || :default).map { |g| g.to_sym }31 @source = options["source"]32 @platforms = Array(options["platforms"])33 @env = options["env"]34 if options.key?('require')35 @autorequire = Array(options['require'] || [])36 end37 end38 def gem_platforms(valid_platforms)39 return valid_platforms if @platforms.empty?40 platforms = []41 @platforms.each do |p|42 platform = PLATFORM_MAP[p]43 next unless valid_platforms.include?(platform)44 platforms |= [platform]45 end46 platforms47 end48 def should_include?49 current_env? && current_platform?50 end51 def current_env?52 return true unless @env53 if Hash === @env54 @env.all? do |key, val|55 ENV[key.to_s] && (String === val ? ENV[key.to_s] == val : ENV[key.to_s] =~ val)56 end57 else58 ENV[@env.to_s]59 end60 end61 def current_platform?62 return true if @platforms.empty?63 @platforms.any? { |p| send("#{p}?") }64 end65 def to_lock66 out = super67 out << '!' if source68 out << "\n"69 end70 private71 def on_18?72 RUBY_VERSION =~ /^1\.8/73 end74 def on_19?75 RUBY_VERSION =~ /^1\.9/76 end77 def on_20?78 RUBY_VERSION =~ /^2\.0/79 end80 def ruby?81 !mswin? && (!defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby" || RUBY_ENGINE == "rbx" || RUBY_ENGINE == "maglev")82 end83 def ruby_18?84 ruby? && on_18?85 end86 def ruby_19?87 ruby? && on_19?88 end89 def ruby_20?90 ruby? && on_20?91 end92 def mri?93 !mswin? && (!defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby")94 end95 def mri_18?96 mri? && on_18?97 end98 def mri_19?99 mri? && on_19?100 end101 def mri_20?102 mri? && on_20?103 end104 def rbx?105 ruby? && defined?(RUBY_ENGINE) && RUBY_ENGINE == "rbx"106 end107 def jruby?108 defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"109 end110 def maglev?111 defined?(RUBY_ENGINE) && RUBY_ENGINE == "maglev"112 end113 def mswin?114 Bundler::WINDOWS115 end116 def mingw?117 Bundler::WINDOWS && Gem::Platform.local.os == "mingw32"118 end119 def mingw_18?120 mingw? && on_18?121 end122 def mingw_19?123 mingw? && on_19?124 end125 def mingw_20?126 mingw? && on_20?127 end128 end129end...
current_ruby.rb
Source:current_ruby.rb
1# frozen_string_literal: true2module Bundler3 # Returns current version of Ruby4 #5 # @return [CurrentRuby] Current version of Ruby6 def self.current_ruby7 @current_ruby ||= CurrentRuby.new8 end9 class CurrentRuby10 KNOWN_MINOR_VERSIONS = %w[11 1.812 1.913 2.014 2.115 2.216 2.317 2.418 2.519 2.620 ].freeze21 KNOWN_MAJOR_VERSIONS = KNOWN_MINOR_VERSIONS.map {|v| v.split(".", 2).first }.uniq.freeze22 KNOWN_PLATFORMS = %w[23 jruby24 maglev25 mingw26 mri27 mswin28 mswin6429 rbx30 ruby31 truffleruby32 x64_mingw33 ].freeze34 def ruby?35 !mswin? && (!defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby" ||36 RUBY_ENGINE == "rbx" || RUBY_ENGINE == "maglev" || RUBY_ENGINE == "truffleruby")37 end38 def mri?39 !mswin? && (!defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby")40 end41 def rbx?42 ruby? && defined?(RUBY_ENGINE) && RUBY_ENGINE == "rbx"43 end44 def jruby?45 defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"46 end47 def maglev?48 defined?(RUBY_ENGINE) && RUBY_ENGINE == "maglev"49 end50 def truffleruby?51 defined?(RUBY_ENGINE) && RUBY_ENGINE == "truffleruby"52 end53 def mswin?54 Bundler::WINDOWS55 end56 def mswin64?57 Bundler::WINDOWS && Bundler.local_platform != Gem::Platform::RUBY && Bundler.local_platform.os == "mswin64" && Bundler.local_platform.cpu == "x64"58 end59 def mingw?60 Bundler::WINDOWS && Bundler.local_platform != Gem::Platform::RUBY && Bundler.local_platform.os == "mingw32" && Bundler.local_platform.cpu != "x64"61 end62 def x64_mingw?63 Bundler::WINDOWS && Bundler.local_platform != Gem::Platform::RUBY && Bundler.local_platform.os == "mingw32" && Bundler.local_platform.cpu == "x64"64 end65 (KNOWN_MINOR_VERSIONS + KNOWN_MAJOR_VERSIONS).each do |version|66 trimmed_version = version.tr(".", "")67 define_method(:"on_#{trimmed_version}?") do68 RUBY_VERSION.start_with?("#{version}.")69 end70 KNOWN_PLATFORMS.each do |platform|71 define_method(:"#{platform}_#{trimmed_version}?") do72 send(:"#{platform}?") && send(:"on_#{trimmed_version}?")73 end74 end75 end76 end77end...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!