bundler 1.11.2 → 1.12.0.pre.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +24 -0
  3. data/.gitignore +2 -2
  4. data/.rubocop.yml +17 -2
  5. data/.rubocop_todo.yml +145 -18
  6. data/.travis.yml +9 -2
  7. data/CHANGELOG.md +42 -0
  8. data/Rakefile +20 -13
  9. data/bin/rake +5 -0
  10. data/bin/rspec +5 -0
  11. data/bin/rubocop +7 -1
  12. data/bundler.gemspec +2 -1
  13. data/exe/bundle +10 -2
  14. data/exe/bundle_ruby +2 -1
  15. data/exe/bundler +3 -1
  16. data/lib/bundler.rb +54 -51
  17. data/lib/bundler/capistrano.rb +1 -0
  18. data/lib/bundler/cli.rb +26 -4
  19. data/lib/bundler/cli/binstubs.rb +1 -0
  20. data/lib/bundler/cli/cache.rb +1 -0
  21. data/lib/bundler/cli/check.rb +4 -1
  22. data/lib/bundler/cli/clean.rb +1 -0
  23. data/lib/bundler/cli/common.rb +1 -0
  24. data/lib/bundler/cli/config.rb +5 -5
  25. data/lib/bundler/cli/console.rb +1 -0
  26. data/lib/bundler/cli/exec.rb +4 -9
  27. data/lib/bundler/cli/gem.rb +12 -9
  28. data/lib/bundler/cli/init.rb +1 -0
  29. data/lib/bundler/cli/inject.rb +1 -0
  30. data/lib/bundler/cli/install.rb +8 -5
  31. data/lib/bundler/cli/lock.rb +2 -0
  32. data/lib/bundler/cli/open.rb +1 -0
  33. data/lib/bundler/cli/outdated.rb +36 -9
  34. data/lib/bundler/cli/package.rb +1 -0
  35. data/lib/bundler/cli/platform.rb +4 -1
  36. data/lib/bundler/cli/show.rb +1 -0
  37. data/lib/bundler/cli/update.rb +6 -6
  38. data/lib/bundler/cli/viz.rb +4 -6
  39. data/lib/bundler/constants.rb +1 -0
  40. data/lib/bundler/current_ruby.rb +34 -168
  41. data/lib/bundler/definition.rb +41 -15
  42. data/lib/bundler/dep_proxy.rb +1 -0
  43. data/lib/bundler/dependency.rb +10 -0
  44. data/lib/bundler/deployment.rb +1 -0
  45. data/lib/bundler/deprecate.rb +1 -0
  46. data/lib/bundler/dsl.rb +19 -9
  47. data/lib/bundler/endpoint_specification.rb +37 -8
  48. data/lib/bundler/env.rb +4 -3
  49. data/lib/bundler/environment.rb +1 -0
  50. data/lib/bundler/errors.rb +51 -32
  51. data/lib/bundler/fetcher.rb +44 -30
  52. data/lib/bundler/fetcher/base.rb +3 -2
  53. data/lib/bundler/fetcher/compact_index.rb +98 -0
  54. data/lib/bundler/fetcher/dependency.rb +36 -36
  55. data/lib/bundler/fetcher/downloader.rb +14 -8
  56. data/lib/bundler/fetcher/index.rb +28 -5
  57. data/lib/bundler/friendly_errors.rb +93 -85
  58. data/lib/bundler/gem_helper.rb +20 -21
  59. data/lib/bundler/gem_helpers.rb +9 -2
  60. data/lib/bundler/gem_remote_fetcher.rb +1 -0
  61. data/lib/bundler/gem_tasks.rb +1 -0
  62. data/lib/bundler/graph.rb +16 -17
  63. data/lib/bundler/index.rb +4 -6
  64. data/lib/bundler/injector.rb +1 -0
  65. data/lib/bundler/inline.rb +8 -2
  66. data/lib/bundler/installer.rb +4 -4
  67. data/lib/bundler/installer/gem_installer.rb +1 -0
  68. data/lib/bundler/installer/parallel_installer.rb +3 -2
  69. data/lib/bundler/installer/standalone.rb +5 -1
  70. data/lib/bundler/lazy_specification.rb +5 -2
  71. data/lib/bundler/lockfile_parser.rb +22 -15
  72. data/lib/bundler/match_platform.rb +1 -0
  73. data/lib/bundler/mirror.rb +218 -0
  74. data/lib/bundler/path_preserver.rb +12 -0
  75. data/lib/bundler/psyched_yaml.rb +1 -0
  76. data/lib/bundler/remote_specification.rb +4 -1
  77. data/lib/bundler/resolver.rb +17 -16
  78. data/lib/bundler/retry.rb +1 -0
  79. data/lib/bundler/ruby_dsl.rb +8 -2
  80. data/lib/bundler/ruby_version.rb +58 -61
  81. data/lib/bundler/rubygems_ext.rb +4 -3
  82. data/lib/bundler/rubygems_gem_installer.rb +1 -0
  83. data/lib/bundler/rubygems_integration.rb +9 -14
  84. data/lib/bundler/runtime.rb +17 -22
  85. data/lib/bundler/settings.rb +17 -21
  86. data/lib/bundler/setup.rb +1 -0
  87. data/lib/bundler/shared_helpers.rb +47 -17
  88. data/lib/bundler/similarity_detector.rb +1 -0
  89. data/lib/bundler/source.rb +2 -1
  90. data/lib/bundler/source/git.rb +2 -1
  91. data/lib/bundler/source/git/git_proxy.rb +33 -7
  92. data/lib/bundler/source/path.rb +17 -10
  93. data/lib/bundler/source/path/installer.rb +1 -0
  94. data/lib/bundler/source/rubygems.rb +4 -3
  95. data/lib/bundler/source/rubygems/remote.rb +16 -0
  96. data/lib/bundler/source_list.rb +1 -0
  97. data/lib/bundler/spec_set.rb +1 -0
  98. data/lib/bundler/ssl_certs/certificate_manager.rb +1 -0
  99. data/lib/bundler/stub_specification.rb +1 -0
  100. data/lib/bundler/templates/Executable +1 -0
  101. data/lib/bundler/templates/Gemfile +1 -0
  102. data/lib/bundler/templates/newgem/.travis.yml.tt +1 -0
  103. data/lib/bundler/templates/newgem/newgem.gemspec.tt +2 -2
  104. data/lib/bundler/ui.rb +1 -0
  105. data/lib/bundler/ui/rg_proxy.rb +1 -0
  106. data/lib/bundler/ui/shell.rb +2 -1
  107. data/lib/bundler/ui/silent.rb +1 -0
  108. data/lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb +78 -0
  109. data/lib/bundler/vendor/compact_index_client/lib/compact_index_client/cache.rb +97 -0
  110. data/lib/bundler/vendor/compact_index_client/lib/compact_index_client/updater.rb +55 -0
  111. data/lib/bundler/vendor/compact_index_client/lib/compact_index_client/version.rb +3 -0
  112. data/lib/bundler/vendor/molinillo/lib/molinillo.rb +4 -0
  113. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +13 -0
  114. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +5 -0
  115. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +2 -1
  116. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +2 -1
  117. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +37 -14
  118. data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +2 -1
  119. data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +7 -7
  120. data/lib/bundler/vendored_molinillo.rb +1 -0
  121. data/lib/bundler/vendored_persistent.rb +1 -0
  122. data/lib/bundler/vendored_thor.rb +1 -0
  123. data/lib/bundler/version.rb +6 -1
  124. data/lib/bundler/vlad.rb +1 -0
  125. data/lib/bundler/worker.rb +12 -2
  126. data/man/bundle-config.ronn +6 -0
  127. data/man/bundle-gem.ronn +5 -5
  128. metadata +14 -6
  129. data/lib/bundler/gem_path_manipulation.rb +0 -8
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Bundler
2
3
  class CLI::Console
3
4
  attr_reader :options, :group
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "bundler/current_ruby"
2
3
 
3
4
  module Bundler
@@ -20,18 +21,12 @@ module Bundler
20
21
  ui = Bundler.ui
21
22
  raise ArgumentError if cmd.nil?
22
23
 
23
- # First, try to exec directly to something in PATH
24
24
  SharedHelpers.set_bundle_environment
25
25
  bin_path = Bundler.which(@cmd)
26
- if bin_path
27
- Bundler.ui = nil
28
- Kernel.exec(bin_path, *args)
29
- end
30
-
31
- # If that didn't work, set up the whole bundle
32
- Bundler.definition.validate_ruby!
33
- Bundler.load.setup_environment
34
26
  Bundler.ui = nil
27
+ # First, try to exec directly to something in PATH
28
+ Kernel.exec([bin_path, @cmd], *args) if bin_path
29
+ # Just exec using the given command
35
30
  Kernel.exec(@cmd, *args)
36
31
  rescue Errno::EACCES, Errno::ENOEXEC
37
32
  Bundler.ui = ui
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "pathname"
2
3
 
3
4
  module Bundler
@@ -5,7 +6,7 @@ module Bundler
5
6
  TEST_FRAMEWORK_VERSIONS = {
6
7
  "rspec" => "3.0",
7
8
  "minitest" => "5.0"
8
- }
9
+ }.freeze
9
10
 
10
11
  attr_reader :options, :gem_name, :thor, :name, :target
11
12
 
@@ -27,7 +28,6 @@ module Bundler
27
28
  namespaced_path = name.tr("-", "/")
28
29
  constant_name = name.gsub(/-[_-]*(?![_-]|$)/) { "::" }.gsub(/([_-]+|(::)|^)(.|$)/) { $2.to_s + $3.upcase }
29
30
  constant_array = constant_name.split("::")
30
- test_task = options[:test] == "minitest" ? "test" : "spec"
31
31
 
32
32
  git_user_name = `git config user.name`.chomp
33
33
  git_user_email = `git config user.email`.chomp
@@ -42,9 +42,8 @@ module Bundler
42
42
  :author => git_user_name.empty? ? "TODO: Write your name" : git_user_name,
43
43
  :email => git_user_email.empty? ? "TODO: Write your email address" : git_user_email,
44
44
  :test => options[:test],
45
- :test_task => test_task,
46
45
  :ext => options[:ext],
47
- :bin => options[:bin],
46
+ :exe => options[:exe],
48
47
  :bundler_version => bundler_dependency_version
49
48
  }
50
49
  ensure_safe_gem_name(name, constant_array)
@@ -87,6 +86,8 @@ module Bundler
87
86
  end
88
87
  end
89
88
 
89
+ config[:test_task] = config[:test] == "minitest" ? "test" : "spec"
90
+
90
91
  if ask_and_set(:mit, "Do you want to license your code permissively under the MIT license?",
91
92
  "This means that any other developer or company will be legally allowed to use your code " \
92
93
  "for free as long as they admit you created it. You can read more about the MIT license " \
@@ -109,7 +110,7 @@ module Bundler
109
110
  templates.merge!("CODE_OF_CONDUCT.md.tt" => "CODE_OF_CONDUCT.md")
110
111
  end
111
112
 
112
- templates.merge!("exe/newgem.tt" => "exe/#{name}") if options[:bin]
113
+ templates.merge!("exe/newgem.tt" => "exe/#{name}") if config[:exe]
113
114
 
114
115
  if options[:ext]
115
116
  templates.merge!(
@@ -135,10 +136,8 @@ module Bundler
135
136
  `git add .`
136
137
  end
137
138
 
138
- if options[:edit]
139
- # Open gemspec in editor
140
- thor.run("#{options["edit"]} \"#{target.join("#{name}.gemspec")}\"")
141
- end
139
+ # Open gemspec in editor
140
+ open_editor(options["edit"], target.join("#{name}.gemspec")) if options[:edit]
142
141
  end
143
142
 
144
143
  private
@@ -207,5 +206,9 @@ module Bundler
207
206
  exit 1
208
207
  end
209
208
  end
209
+
210
+ def open_editor(editor, file)
211
+ thor.run(%(#{editor} "#{file}"))
212
+ end
210
213
  end
211
214
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Bundler
2
3
  class CLI::Init
3
4
  attr_reader :options
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Bundler
2
3
  class CLI::Inject
3
4
  attr_reader :options, :name, :version, :gems
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Bundler
2
3
  class CLI::Install
3
4
  attr_reader :options
@@ -94,7 +95,7 @@ module Bundler
94
95
  Bundler.settings.without = options[:without]
95
96
  Bundler.settings.with = options[:with]
96
97
  Bundler::Fetcher.disable_endpoint = options["full-index"]
97
- Bundler.settings[:disable_shared_gems] = Bundler.settings[:path] ? "1" : nil
98
+ Bundler.settings[:disable_shared_gems] = Bundler.settings[:path] ? true : nil
98
99
 
99
100
  # rubygems plugins sometimes hook into the gem install process
100
101
  Gem.load_env_plugins if Gem.respond_to?(:load_env_plugins)
@@ -150,6 +151,9 @@ module Bundler
150
151
  WARN
151
152
  end
152
153
  raise e
154
+ rescue Gem::InvalidSpecificationException => e
155
+ Bundler.ui.warn "You have one or more invalid gemspecs that need to be fixed."
156
+ raise e
153
157
  end
154
158
 
155
159
  private
@@ -162,10 +166,9 @@ module Bundler
162
166
  end
163
167
 
164
168
  def confirm_without_groups
165
- if Bundler.settings.without.any?
166
- require "bundler/cli/common"
167
- Bundler.ui.confirm Bundler::CLI::Common.without_groups_message
168
- end
169
+ return unless Bundler.settings.without.any?
170
+ require "bundler/cli/common"
171
+ Bundler.ui.confirm Bundler::CLI::Common.without_groups_message
169
172
  end
170
173
 
171
174
  def dependencies_count_for(definition)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Bundler
2
3
  class CLI::Lock
3
4
  attr_reader :options
@@ -17,6 +18,7 @@ module Bundler
17
18
  Bundler.ui = UI::Silent.new if print
18
19
 
19
20
  gems = options[:update]
21
+ Bundler::Fetcher.disable_endpoint = options["full-index"]
20
22
 
21
23
  if gems && !gems.empty?
22
24
  definition = Bundler.definition(:gems => gems)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "bundler/cli/common"
2
3
  require "shellwords"
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "bundler/cli/common"
2
3
 
3
4
  module Bundler
@@ -26,7 +27,13 @@ module Bundler
26
27
  else
27
28
  definition = Bundler.definition(:gems => gems, :sources => sources)
28
29
  end
29
- options["local"] ? definition.resolve_with_cache! : definition.resolve_remotely!
30
+
31
+ definition_resolution = proc { options["local"] ? definition.resolve_with_cache! : definition.resolve_remotely! }
32
+ if options[:parseable]
33
+ Bundler.ui.silence(&definition_resolution)
34
+ else
35
+ definition_resolution.call
36
+ end
30
37
 
31
38
  Bundler.ui.info ""
32
39
 
@@ -46,17 +53,31 @@ module Bundler
46
53
  active_spec = active_spec.delete_if {|b| b.respond_to?(:version) && b.version.prerelease? }
47
54
  end
48
55
  active_spec = active_spec.last
56
+
57
+ if options[:major]
58
+ current_major = current_spec.version.segments.first
59
+ active_major = active_spec.version.segments.first
60
+ active_spec = nil unless active_major > current_major
61
+ end
62
+
63
+ if options[:minor]
64
+ current_minor = current_spec.version.segments[0, 2].compact.join(".")
65
+ active_minor = active_spec.version.segments[0, 2].compact.join(".")
66
+ active_spec = nil unless active_minor > current_minor
67
+ end
49
68
  end
50
69
  next if active_spec.nil?
51
70
 
52
71
  gem_outdated = Gem::Version.new(active_spec.version) > Gem::Version.new(current_spec.version)
53
72
  git_outdated = current_spec.git_version != active_spec.git_version
54
73
  if gem_outdated || git_outdated
55
- if out_count == 0
56
- if options["pre"]
57
- Bundler.ui.info "Outdated gems included in the bundle (including pre-releases):"
58
- else
59
- Bundler.ui.info "Outdated gems included in the bundle:"
74
+ unless options[:parseable]
75
+ if out_count == 0
76
+ if options["pre"]
77
+ Bundler.ui.info "Outdated gems included in the bundle (including pre-releases):"
78
+ else
79
+ Bundler.ui.info "Outdated gems included in the bundle:"
80
+ end
60
81
  end
61
82
  end
62
83
 
@@ -64,20 +85,26 @@ module Bundler
64
85
  current_version = "#{current_spec.version}#{current_spec.git_version}"
65
86
  dependency_version = %(, requested #{dependency.requirement}) if dependency && dependency.specific?
66
87
 
67
- if dependency
88
+ if dependency && !options[:parseable]
68
89
  groups = dependency.groups.join(", ")
69
90
  pl = (dependency.groups.length > 1) ? "s" : ""
70
91
  groups = " in group#{pl} \"#{groups}\""
71
92
  end
72
93
 
73
- Bundler.ui.info " * #{active_spec.name} (newest #{spec_version}, installed #{current_version}#{dependency_version})#{groups}".rstrip
94
+ spec_outdated_info = "#{active_spec.name} (newest #{spec_version}, installed #{current_version}#{dependency_version})"
95
+ if options[:parseable]
96
+ Bundler.ui.info spec_outdated_info.to_s.rstrip
97
+ else
98
+ Bundler.ui.info " * #{spec_outdated_info}#{groups}".rstrip
99
+ end
100
+
74
101
  out_count += 1
75
102
  end
76
103
  Bundler.ui.debug "from #{active_spec.loaded_from}"
77
104
  end
78
105
 
79
106
  if out_count.zero?
80
- Bundler.ui.info "Bundle up to date!\n"
107
+ Bundler.ui.info "Bundle up to date!\n" unless options[:parseable]
81
108
  else
82
109
  exit 1
83
110
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Bundler
2
3
  class CLI::Package
3
4
  attr_reader :options
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Bundler
2
3
  class CLI::Platform
3
4
  attr_reader :options
@@ -7,8 +8,10 @@ module Bundler
7
8
 
8
9
  def run
9
10
  platforms, ruby_version = Bundler.ui.silence do
11
+ locked_ruby_version = Bundler.locked_gems && Bundler.locked_gems.ruby_version
12
+ gemfile_ruby_version = Bundler.definition.ruby_version && Bundler.definition.ruby_version.single_version_string
10
13
  [Bundler.definition.platforms.map {|p| "* #{p}" },
11
- Bundler.definition.ruby_version]
14
+ locked_ruby_version || gemfile_ruby_version]
12
15
  end
13
16
  output = []
14
17
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "bundler/cli/common"
2
3
 
3
4
  module Bundler
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Bundler
2
3
  class CLI::Update
3
4
  attr_reader :options, :gems
@@ -12,7 +13,7 @@ module Bundler
12
13
  sources = Array(options[:source])
13
14
  groups = Array(options[:group]).map(&:to_sym)
14
15
 
15
- if gems.empty? && sources.empty? && groups.empty?
16
+ if gems.empty? && sources.empty? && groups.empty? && !options[:ruby]
16
17
  # We're doing a full update
17
18
  Bundler.definition(true)
18
19
  else
@@ -33,7 +34,7 @@ module Bundler
33
34
  gems.concat(specs.map(&:name))
34
35
  end
35
36
 
36
- Bundler.definition(:gems => gems, :sources => sources)
37
+ Bundler.definition(:gems => gems, :sources => sources, :ruby => options[:ruby])
37
38
  end
38
39
 
39
40
  Bundler::Fetcher.disable_endpoint = options["full-index"]
@@ -63,10 +64,9 @@ module Bundler
63
64
  private
64
65
 
65
66
  def without_groups_messages
66
- if Bundler.settings.without.any?
67
- require "bundler/cli/common"
68
- Bundler.ui.confirm Bundler::CLI::Common.without_groups_message
69
- end
67
+ return unless Bundler.settings.without.any?
68
+ require "bundler/cli/common"
69
+ Bundler.ui.confirm Bundler::CLI::Common.without_groups_message
70
70
  end
71
71
  end
72
72
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Bundler
2
3
  class CLI::Viz
3
4
  attr_reader :options, :gem_name
@@ -15,12 +16,9 @@ module Bundler
15
16
  Bundler.ui.warn "Make sure you have the graphviz ruby gem. You can install it with:"
16
17
  Bundler.ui.warn "`gem install ruby-graphviz`"
17
18
  rescue StandardError => e
18
- if e.message =~ /GraphViz not installed or dot not in PATH/
19
- Bundler.ui.error e.message
20
- Bundler.ui.warn "Please install GraphViz. On a Mac with homebrew, you can run `brew install graphviz`."
21
- else
22
- raise
23
- end
19
+ raise unless e.message =~ /GraphViz not installed or dot not in PATH/
20
+ Bundler.ui.error e.message
21
+ Bundler.ui.warn "Please install GraphViz. On a Mac with homebrew, you can run `brew install graphviz`."
24
22
  end
25
23
  end
26
24
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Bundler
2
3
  WINDOWS = RbConfig::CONFIG["host_os"] =~ /(msdos|mswin|djgpp|mingw)/
3
4
  FREEBSD = RbConfig::CONFIG["host_os"] =~ /bsd/
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Bundler
2
3
  # Returns current version of Ruby
3
4
  #
@@ -7,94 +8,38 @@ module Bundler
7
8
  end
8
9
 
9
10
  class CurrentRuby
10
- def on_18?
11
- RUBY_VERSION =~ /^1\.8/
12
- end
13
-
14
- def on_19?
15
- RUBY_VERSION =~ /^1\.9/
16
- end
17
-
18
- def on_20?
19
- RUBY_VERSION =~ /^2\.0/
20
- end
21
-
22
- def on_21?
23
- RUBY_VERSION =~ /^2\.1/
24
- end
25
-
26
- def on_22?
27
- RUBY_VERSION =~ /^2\.2/
28
- end
29
-
30
- def on_23?
31
- RUBY_VERSION =~ /^2\.3/
32
- end
33
-
34
- def on_2?
35
- on_20? || on_21? || on_22? || on_23?
36
- end
11
+ KNOWN_MINOR_VERSIONS = %w(
12
+ 1.8
13
+ 1.9
14
+ 2.0
15
+ 2.1
16
+ 2.2
17
+ 2.3
18
+ 2.4
19
+ ).freeze
20
+
21
+ KNOWN_MAJOR_VERSIONS = KNOWN_MINOR_VERSIONS.map {|v| v.split(".", 2).first }.uniq.freeze
22
+
23
+ KNOWN_PLATFORMS = %w(
24
+ jruby
25
+ maglev
26
+ mingw
27
+ mri
28
+ mswin
29
+ mswin64
30
+ rbx
31
+ ruby
32
+ x64_mingw
33
+ ).freeze
37
34
 
38
35
  def ruby?
39
36
  !mswin? && (!defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby" || RUBY_ENGINE == "rbx" || RUBY_ENGINE == "maglev")
40
37
  end
41
38
 
42
- def ruby_18?
43
- ruby? && on_18?
44
- end
45
-
46
- def ruby_19?
47
- ruby? && on_19?
48
- end
49
-
50
- def ruby_20?
51
- ruby? && on_20?
52
- end
53
-
54
- def ruby_21?
55
- ruby? && on_21?
56
- end
57
-
58
- def ruby_22?
59
- ruby? && on_22?
60
- end
61
-
62
- def ruby_23?
63
- ruby? && on_23?
64
- end
65
-
66
- def ruby_2?
67
- ruby? && on_2?
68
- end
69
-
70
39
  def mri?
71
40
  !mswin? && (!defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby")
72
41
  end
73
42
 
74
- def mri_18?
75
- mri? && on_18?
76
- end
77
-
78
- def mri_19?
79
- mri? && on_19?
80
- end
81
-
82
- def mri_20?
83
- mri? && on_20?
84
- end
85
-
86
- def mri_21?
87
- mri? && on_21?
88
- end
89
-
90
- def mri_22?
91
- mri? && on_22?
92
- end
93
-
94
- def mri_23?
95
- mri? && on_23?
96
- end
97
-
98
43
  def rbx?
99
44
  ruby? && defined?(RUBY_ENGINE) && RUBY_ENGINE == "rbx"
100
45
  end
@@ -103,14 +48,6 @@ module Bundler
103
48
  defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
104
49
  end
105
50
 
106
- def jruby_18?
107
- jruby? && on_18?
108
- end
109
-
110
- def jruby_19?
111
- jruby? && on_19?
112
- end
113
-
114
51
  def maglev?
115
52
  defined?(RUBY_ENGINE) && RUBY_ENGINE == "maglev"
116
53
  end
@@ -119,100 +56,29 @@ module Bundler
119
56
  Bundler::WINDOWS
120
57
  end
121
58
 
122
- def mswin_18?
123
- mswin? && on_18?
124
- end
125
-
126
- def mswin_19?
127
- mswin? && on_19?
128
- end
129
-
130
- def mswin_20?
131
- mswin? && on_20?
132
- end
133
-
134
- def mswin_21?
135
- mswin? && on_21?
136
- end
137
-
138
- def mswin_22?
139
- mswin? && on_22?
140
- end
141
-
142
- def mswin_23?
143
- mswin? && on_23?
144
- end
145
-
146
59
  def mswin64?
147
60
  Bundler::WINDOWS && Gem::Platform.local.os == "mswin64" && Gem::Platform.local.cpu == "x64"
148
61
  end
149
62
 
150
- def mswin64_19?
151
- mswin64? && on_19?
152
- end
153
-
154
- def mswin64_20?
155
- mswin64? && on_20?
156
- end
157
-
158
- def mswin64_21?
159
- mswin64? && on_21?
160
- end
161
-
162
- def mswin64_22?
163
- mswin64? && on_22?
164
- end
165
-
166
- def mswin64_23?
167
- mswin64? && on_23?
168
- end
169
-
170
63
  def mingw?
171
64
  Bundler::WINDOWS && Gem::Platform.local.os == "mingw32" && Gem::Platform.local.cpu != "x64"
172
65
  end
173
66
 
174
- def mingw_18?
175
- mingw? && on_18?
176
- end
177
-
178
- def mingw_19?
179
- mingw? && on_19?
180
- end
181
-
182
- def mingw_20?
183
- mingw? && on_20?
184
- end
185
-
186
- def mingw_21?
187
- mingw? && on_21?
188
- end
189
-
190
- def mingw_22?
191
- mingw? && on_22?
192
- end
193
-
194
- def mingw_23?
195
- mingw? && on_23?
196
- end
197
-
198
67
  def x64_mingw?
199
68
  Bundler::WINDOWS && Gem::Platform.local.os == "mingw32" && Gem::Platform.local.cpu == "x64"
200
69
  end
201
70
 
202
- def x64_mingw_20?
203
- x64_mingw? && on_20?
204
- end
205
-
206
- def x64_mingw_21?
207
- x64_mingw? && on_21?
208
- end
209
-
210
- def x64_mingw_22?
211
- x64_mingw? && on_22?
212
- end
71
+ (KNOWN_MINOR_VERSIONS + KNOWN_MAJOR_VERSIONS).each do |version|
72
+ trimmed_version = version.tr(".", "")
73
+ define_method(:"on_#{trimmed_version}?") do
74
+ RUBY_VERSION.start_with?("#{version}.")
75
+ end
213
76
 
214
- def x64_mingw_23?
215
- x64_mingw? && on_23?
77
+ KNOWN_PLATFORMS.each do |platform|
78
+ define_method(:"#{platform}_#{trimmed_version}?") do
79
+ send(:"#{platform}?") && send(:"on_#{trimmed_version}?")
80
+ end
81
+ end
216
82
  end
217
83
  end
218
84
  end