|
2 | 2 |
|
3 | 3 | source ENV['GEM_SOURCE'] || "https://rubygems.org"
|
4 | 4 |
|
5 |
| -def location_from_env(env, default_location = []) |
6 |
| - if location = ENV[env] |
7 |
| - if location =~ /^((?:git|https?)[:@][^#]*)#(.*)/ |
8 |
| - [{ :git => $1, :branch => $2, :require => false }] |
9 |
| - elsif location =~ /^file:\/\/(.*)/ |
10 |
| - ['>= 0', { :path => File.expand_path($1), :require => false }] |
11 |
| - else |
12 |
| - [location, { :require => false }] |
13 |
| - end |
| 5 | +# Determines what type of gem is requested based on place_or_version. |
| 6 | +def gem_type(place_or_version) |
| 7 | + if place_or_version =~ /^git:/ |
| 8 | + :git |
| 9 | + elsif place_or_version =~ /^file:/ |
| 10 | + :file |
14 | 11 | else
|
15 |
| - default_location |
| 12 | + :gem |
16 | 13 | end
|
17 | 14 | end
|
18 | 15 |
|
19 |
| -group :development, :unit_tests do |
20 |
| - gem 'metadata-json-lint' |
21 |
| - gem 'puppet_facts' |
22 |
| - gem 'puppet-blacksmith', '>= 3.4.0' |
23 |
| - gem 'puppetlabs_spec_helper', '>= 1.2.1' |
24 |
| - gem 'rspec-puppet', '>= 2.3.2' |
25 |
| - gem 'rspec-puppet-facts' |
26 |
| - gem 'mocha', '< 1.2.0' |
27 |
| - gem 'simplecov' |
28 |
| - gem 'parallel_tests', '< 2.10.0' if RUBY_VERSION < '2.0.0' |
29 |
| - gem 'parallel_tests' if RUBY_VERSION >= '2.0.0' |
30 |
| - gem 'rubocop', '0.41.2' if RUBY_VERSION < '2.0.0' |
31 |
| - gem 'rubocop' if RUBY_VERSION >= '2.0.0' |
32 |
| - gem 'rubocop-rspec', '~> 1.6' if RUBY_VERSION >= '2.3.0' |
33 |
| - gem 'json_pure', '<= 2.0.1' if RUBY_VERSION < '2.0.0' |
34 |
| - gem 'rspec-puppet-facts' |
| 16 | +# Find a location or specific version for a gem. place_or_version can be a |
| 17 | +# version, which is most often used. It can also be git, which is specified as |
| 18 | +# `git://somewhere.git#branch`. You can also use a file source location, which |
| 19 | +# is specified as `file://some/location/on/disk`. |
| 20 | +def location_for(place_or_version, fake_version = nil) |
| 21 | + if place_or_version =~ /^(git[:@][^#]*)#(.*)/ |
| 22 | + [fake_version, { :git => $1, :branch => $2, :require => false }].compact |
| 23 | + elsif place_or_version =~ /^file:\/\/(.*)/ |
| 24 | + ['>= 0', { :path => File.expand_path($1), :require => false }] |
| 25 | + else |
| 26 | + [place_or_version, { :require => false }] |
| 27 | + end |
| 28 | +end |
| 29 | + |
| 30 | +# Used for gem conditionals |
| 31 | +supports_windows = false |
| 32 | + |
| 33 | +group :development do |
| 34 | + gem 'puppet-lint', :require => false |
| 35 | + gem 'metadata-json-lint', :require => false |
| 36 | + gem 'puppet_facts', :require => false |
| 37 | + gem 'puppet-blacksmith', '>= 3.4.0', :require => false, :platforms => 'ruby' |
| 38 | + gem 'puppetlabs_spec_helper', '>= 1.2.1', :require => false |
| 39 | + gem 'rspec-puppet', '>= 2.3.2', :require => false |
| 40 | + gem 'rspec-puppet-facts', :require => false |
| 41 | + gem 'mocha', '< 1.2.0', :require => false |
| 42 | + gem 'simplecov', :require => false |
| 43 | + gem 'parallel_tests', '< 2.10.0', :require => false if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.0.0') |
| 44 | + gem 'parallel_tests', :require => false if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.0.0') |
| 45 | + gem 'rubocop', '0.41.2', :require => false if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.0.0') |
| 46 | + gem 'rubocop', :require => false if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.0.0') |
| 47 | + gem 'rubocop-rspec', '~> 1.6', :require => false if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.3.0') |
| 48 | + gem 'pry', :require => false |
| 49 | + gem 'json_pure', '<= 2.0.1', :require => false if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.0.0') |
35 | 50 | end
|
| 51 | + |
36 | 52 | group :system_tests do
|
37 |
| - gem 'beaker', *location_from_env('BEAKER_VERSION', []) if RUBY_VERSION >= '2.3.0' |
38 |
| - gem 'beaker', *location_from_env('BEAKER_VERSION', ['< 3']) if RUBY_VERSION < '2.3.0' |
39 |
| - gem 'beaker-pe' if RUBY_VERSION >= '2.3.0' |
40 |
| - gem 'beaker-rspec', *location_from_env('BEAKER_RSPEC_VERSION', ['>= 3.4']) |
41 |
| - gem 'serverspec' |
42 |
| - gem 'beaker-puppet_install_helper' |
43 |
| - gem 'master_manipulator' |
44 |
| - gem 'beaker-hostgenerator', *location_from_env('BEAKER_HOSTGENERATOR_VERSION', []) |
| 53 | + gem 'beaker', *location_for(ENV['BEAKER_VERSION'] || '~> 2.20') if supports_windows |
| 54 | + gem 'beaker', *location_for(ENV['BEAKER_VERSION']) if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.3.0') and ! supports_windows |
| 55 | + gem 'beaker', *location_for(ENV['BEAKER_VERSION'] || '< 3') if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.3.0') and ! supports_windows |
| 56 | + gem 'beaker-pe', :require => false if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.3.0') |
| 57 | + gem 'beaker-rspec', *location_for(ENV['BEAKER_RSPEC_VERSION'] || '>= 3.4') if ! supports_windows |
| 58 | + gem 'beaker-rspec', *location_for(ENV['BEAKER_RSPEC_VERSION'] || '~> 5.1') if supports_windows |
| 59 | + gem 'beaker-puppet_install_helper', :require => false |
| 60 | + gem 'master_manipulator', :require => false |
| 61 | + gem 'beaker-hostgenerator', *location_for(ENV['BEAKER_HOSTGENERATOR_VERSION']) |
45 | 62 | end
|
46 | 63 |
|
47 |
| -gem 'facter', *location_from_env('FACTER_GEM_VERSION') |
48 |
| -gem 'puppet', *location_from_env('PUPPET_GEM_VERSION') |
| 64 | +group :development, :unit_tests do |
| 65 | + gem 'rspec-puppet-facts', :require => false |
| 66 | +end |
| 67 | + |
| 68 | +gem 'puppet', *location_for(ENV['PUPPET_GEM_VERSION']) |
| 69 | + |
| 70 | +# Only explicitly specify Facter/Hiera if a version has been specified. |
| 71 | +# Otherwise it can lead to strange bundler behavior. If you are seeing weird |
| 72 | +# gem resolution behavior, try setting `DEBUG_RESOLVER` environment variable |
| 73 | +# to `1` and then run bundle install. |
| 74 | +gem 'facter', *location_for(ENV['FACTER_GEM_VERSION']) if ENV['FACTER_GEM_VERSION'] |
| 75 | +gem 'hiera', *location_for(ENV['HIERA_GEM_VERSION']) if ENV['HIERA_GEM_VERSION'] |
| 76 | + |
49 | 77 |
|
| 78 | +# Evaluate Gemfile.local if it exists |
50 | 79 | if File.exists? "#{__FILE__}.local"
|
51 | 80 | eval(File.read("#{__FILE__}.local"), binding)
|
52 | 81 | end
|
| 82 | + |
| 83 | +# Evaluate ~/.gemfile if it exists |
| 84 | +if File.exists?(File.join(Dir.home, '.gemfile')) |
| 85 | + eval(File.read(File.join(Dir.home, '.gemfile')), binding) |
| 86 | +end |
| 87 | + |
| 88 | +# vim:ft=ruby |
0 commit comments