appraisal 2.5.0 → 3.0.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/dynamic-security.yml +19 -0
  3. data/.github/workflows/main.yml +55 -0
  4. data/.gitignore +1 -0
  5. data/Gemfile +5 -0
  6. data/README.md +14 -5
  7. data/Rakefile +8 -6
  8. data/SECURITY.md +20 -0
  9. data/appraisal.gemspec +14 -17
  10. data/bin/bundle +109 -0
  11. data/bin/rspec +27 -0
  12. data/{bin → exe}/appraisal +6 -4
  13. data/lib/appraisal/appraisal.rb +20 -17
  14. data/lib/appraisal/appraisal_file.rb +8 -6
  15. data/lib/appraisal/bundler_dsl.rb +17 -13
  16. data/lib/appraisal/cli.rb +49 -43
  17. data/lib/appraisal/command.rb +3 -1
  18. data/lib/appraisal/conditional.rb +4 -0
  19. data/lib/appraisal/customize.rb +22 -2
  20. data/lib/appraisal/dependency.rb +4 -2
  21. data/lib/appraisal/dependency_list.rb +4 -2
  22. data/lib/appraisal/errors.rb +2 -0
  23. data/lib/appraisal/gemfile.rb +2 -0
  24. data/lib/appraisal/gemspec.rb +5 -3
  25. data/lib/appraisal/git.rb +3 -1
  26. data/lib/appraisal/group.rb +7 -5
  27. data/lib/appraisal/path.rb +3 -1
  28. data/lib/appraisal/platform.rb +7 -5
  29. data/lib/appraisal/source.rb +7 -5
  30. data/lib/appraisal/task.rb +8 -6
  31. data/lib/appraisal/utils.rb +6 -7
  32. data/lib/appraisal/version.rb +3 -1
  33. data/lib/appraisal.rb +4 -2
  34. data/spec/acceptance/appraisals_file_bundler_dsl_compatibility_spec.rb +55 -24
  35. data/spec/acceptance/bundle_with_custom_path_spec.rb +26 -20
  36. data/spec/acceptance/bundle_without_spec.rb +10 -10
  37. data/spec/acceptance/cli/clean_spec.rb +13 -11
  38. data/spec/acceptance/cli/generate_spec.rb +14 -12
  39. data/spec/acceptance/cli/help_spec.rb +15 -13
  40. data/spec/acceptance/cli/install_spec.rb +33 -47
  41. data/spec/acceptance/cli/list_spec.rb +11 -9
  42. data/spec/acceptance/cli/run_spec.rb +26 -24
  43. data/spec/acceptance/cli/update_spec.rb +20 -18
  44. data/spec/acceptance/cli/version_spec.rb +3 -1
  45. data/spec/acceptance/cli/with_no_arguments_spec.rb +10 -8
  46. data/spec/acceptance/gemfile_dsl_compatibility_spec.rb +38 -36
  47. data/spec/acceptance/gemspec_spec.rb +26 -24
  48. data/spec/appraisal/appraisal_file_spec.rb +66 -4
  49. data/spec/appraisal/appraisal_spec.rb +20 -23
  50. data/spec/appraisal/customize_spec.rb +133 -11
  51. data/spec/appraisal/dependency_list_spec.rb +3 -1
  52. data/spec/appraisal/gemfile_spec.rb +39 -38
  53. data/spec/appraisal/utils_spec.rb +21 -28
  54. data/spec/spec_helper.rb +14 -6
  55. data/spec/support/acceptance_test_helpers.rb +31 -24
  56. data/spec/support/dependency_helpers.rb +29 -15
  57. data/spec/support/stream_helpers.rb +2 -0
  58. metadata +10 -34
  59. data/.rspec +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3574be66377d3aae65b37b349e4f345a2c3902e4e5ec6030401b6b1b30a2992f
4
- data.tar.gz: 745cb04bc9266861ff9097ce5ff1c1bc84a5a0fd7b7877e66aaa568ca84aa80e
3
+ metadata.gz: 91cd28f94201740fdcc34e58200fec87442a99144b1b4c1b909d818b12f8e644
4
+ data.tar.gz: 7e61989365c22a32cea85d0cd01a7b27056a9daa2eeae452a6dede92537caf0e
5
5
  SHA512:
6
- metadata.gz: 1f7d36071e02f1a31ebea13cf350733708ab799507dc315c97667d50aec24d7a4f51d0e13a88dc4225c65d13599020ff0bc7d5ed62bf64d1ceca24f0b0c1c081
7
- data.tar.gz: 31d3c863906955c139632f6ddd957a6ba73d95012b1fb09b5ffa64112f1b2dc3606b9e5d337d3ef6019e2eec27fd8f745a7bd79eadacd66dfe2f16376000e5a7
6
+ metadata.gz: 442f8a5bad710daee1497ea947a19a5d0378c99b7e76977932cad75291229c02141d0df4eac179c3ced5e142afea8e75a9189116a09d1d2a8374f3ec435de7e3
7
+ data.tar.gz: 3cfe5371dc2a941f71cb16407f0ba804b33b5ec94c4faf94185527e11e36e0a10dcaecab1477515bc4f255c4fe82e7863830a53115586ab614d08e7f2f5429d2
@@ -0,0 +1,19 @@
1
+ name: update-security
2
+
3
+ on:
4
+ push:
5
+ paths:
6
+ - SECURITY.md
7
+ branches:
8
+ - main
9
+ workflow_dispatch:
10
+
11
+ jobs:
12
+ update-security:
13
+ permissions:
14
+ contents: write
15
+ pull-requests: write
16
+ pages: write
17
+ uses: thoughtbot/templates/.github/workflows/dynamic-security.yaml@main
18
+ secrets:
19
+ token: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,55 @@
1
+ ---
2
+ name: Tests
3
+
4
+ on:
5
+ push:
6
+ branches:
7
+ - '**'
8
+ pull_request:
9
+ branches:
10
+ - '**'
11
+
12
+ jobs:
13
+ test:
14
+ runs-on: ubuntu-latest
15
+
16
+ strategy:
17
+ fail-fast: false
18
+ matrix:
19
+ ruby:
20
+ - '3.3'
21
+ - '3.2'
22
+ - '3.1'
23
+ - '3.0'
24
+ - 'head'
25
+ - jruby
26
+ - jruby-head
27
+ - truffleruby
28
+ - truffleruby-head
29
+
30
+ steps:
31
+ - uses: actions/checkout@v4
32
+
33
+ - name: Setup Ruby
34
+ uses: ruby/setup-ruby@v1
35
+ with:
36
+ ruby-version: ${{ matrix.ruby }}
37
+
38
+ - name: Update bundler
39
+ env:
40
+ RUBY_VERSION: ${{ matrix.ruby }}
41
+ run: |
42
+ case ${RUBY_VERSION} in
43
+ truffleruby|truffleruby-head)
44
+ gem install bundler -v 2.5.18
45
+ ;;
46
+
47
+ *)
48
+ gem update --system
49
+ ;;
50
+ esac
51
+
52
+ bundle install
53
+
54
+ - name: Run tests
55
+ run: bin/rspec
data/.gitignore CHANGED
@@ -6,3 +6,4 @@ pkg
6
6
  *.gem
7
7
  Gemfile.lock
8
8
  .bundle
9
+ .DS_Store
data/Gemfile CHANGED
@@ -4,3 +4,8 @@ gemspec
4
4
 
5
5
  # This here to make sure appraisal works with Rails 3.0.0.
6
6
  gem "thor", "~> 0.14.0"
7
+
8
+ group :development, :test do
9
+ gem "activesupport", ">= 3.2.21"
10
+ gem "rspec", "~> 3.0"
11
+ end
data/README.md CHANGED
@@ -136,7 +136,7 @@ appraise 'rails-5' do
136
136
  gem 'rails', '~> 5.2'
137
137
 
138
138
  group :test do
139
- remove_gem :test_after_commit
139
+ remove_gem 'test_after_commit'
140
140
  end
141
141
  end
142
142
  ```
@@ -159,6 +159,15 @@ customizations include:
159
159
  - heading: a string that by default adds "# This file was generated by Appraisal" to the top of each Gemfile, (the string will be commented for you)
160
160
  - single_quotes: a boolean that controls if strings are single quoted in each Gemfile, defaults to false
161
161
 
162
+ You can also provide variables for substitution in the heading, based on each appraisal. Currently supported variables:
163
+ - `%{appraisal}`: Becomes the name of each appraisal, e.g. `rails-3`
164
+ - `%{gemfile}`: Becomes the filename of each gemfile, e.g. `rails-3.gemfile`
165
+ - `%{gemfile_path}`: Becomes the full path of each gemfile, e.g. `/path/to/project/gemfiles/rails-3.gemfile`
166
+ - `%{lockfile}`: Becomes the filename of each lockfile, e.g. `rails-3.gemfile.lock`
167
+ - `%{lockfile_path}`: Becomes the full path of each lockfile, e.g. `/path/to/project/gemfiles/rails-3.gemfile.lock`
168
+ - `%{relative_gemfile_path}`: Becomes the relative path of each gemfile, e.g. `gemfiles/rails-3.gemfile`
169
+ - `%{relative_lockfile_path}`: Becomes the relative path of each lockfile, e.g. `gemfiles/rails-3.gemfile.lock`
170
+
162
171
  ### Example Usage
163
172
 
164
173
  **Appraisals**
@@ -169,8 +178,8 @@ customize_gemfiles do
169
178
  heading: <<~HEADING
170
179
  frozen_string_literal: true
171
180
 
172
- File has been generated by Appraisal, do NOT modify it directly!
173
- See the conventions at https://example.com/
181
+ `%{gemfile}` has been generated by Appraisal, do NOT modify it or `%{lockfile}` directly!
182
+ Make the changes to the "%{appraisal}" block in `Appraisals` instead. See the conventions at https://example.com/
174
183
  HEADING
175
184
  }
176
185
  end
@@ -184,8 +193,8 @@ Using the `Appraisals` file defined above, this is what the resulting `Gemfile`
184
193
  ```ruby
185
194
  # frozen_string_literal: true
186
195
 
187
- # File has been generated by Appraisal, do NOT modify it directly!
188
- # See the conventions at https://example.com/
196
+ # `rails-3.gemfile` has been generated by Appraisal, do NOT modify it or `rails-3.gemfile.lock` directly!
197
+ # Make the changes to the "rails-3" block in `Appraisals` instead. See the conventions at https://example.com/
189
198
 
190
199
  gem 'rails', '3.2.14'
191
200
  ```
data/Rakefile CHANGED
@@ -1,12 +1,14 @@
1
- require 'bundler/setup'
2
- require 'bundler/gem_tasks'
3
- require 'rspec/core/rake_task'
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/setup"
4
+ require "bundler/gem_tasks"
5
+ require "rspec/core/rake_task"
4
6
 
5
7
  RSpec::Core::RakeTask.new do |t|
6
- t.pattern = 'spec/**/*_spec.rb'
8
+ t.pattern = "spec/**/*_spec.rb"
7
9
  t.ruby_opts = %w[-w]
8
10
  t.verbose = false
9
11
  end
10
12
 
11
- desc 'Default: run the rspec examples'
12
- task :default => [:spec]
13
+ desc "Default: run the rspec examples"
14
+ task default: [:spec]
data/SECURITY.md ADDED
@@ -0,0 +1,20 @@
1
+ <!-- START /templates/security.md -->
2
+ # Security Policy
3
+
4
+ ## Supported Versions
5
+
6
+ Only the the latest version of this project is supported at a given time. If
7
+ you find a security issue with an older version, please try updating to the
8
+ latest version first.
9
+
10
+ If for some reason you can't update to the latest version, please let us know
11
+ your reasons so that we can have a better understanding of your situation.
12
+
13
+ ## Reporting a Vulnerability
14
+
15
+ For security inquiries or vulnerability reports, visit
16
+ <https://thoughtbot.com/security>.
17
+
18
+ If you have any suggestions to improve this policy, visit <https://thoughtbot.com/security>.
19
+
20
+ <!-- END /templates/security.md -->
data/appraisal.gemspec CHANGED
@@ -1,29 +1,26 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "appraisal/version"
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/appraisal/version"
4
4
 
5
5
  Gem::Specification.new do |s|
6
- s.name = 'appraisal'
6
+ s.name = "appraisal"
7
7
  s.version = Appraisal::VERSION.dup
8
8
  s.platform = Gem::Platform::RUBY
9
- s.authors = ['Joe Ferris', 'Prem Sichanugrist']
10
- s.email = ['jferris@thoughtbot.com', 'prem@thoughtbot.com']
11
- s.homepage = 'http://github.com/thoughtbot/appraisal'
12
- s.summary = 'Find out what your Ruby gems are worth'
9
+ s.authors = ["Joe Ferris", "Prem Sichanugrist"]
10
+ s.email = ["jferris@thoughtbot.com", "prem@thoughtbot.com"]
11
+ s.homepage = "http://github.com/thoughtbot/appraisal"
12
+ s.summary = "Find out what your Ruby gems are worth"
13
13
  s.description = 'Appraisal integrates with bundler and rake to test your library against different versions of dependencies in repeatable scenarios called "appraisals."'
14
- s.license = 'MIT'
14
+ s.license = "MIT"
15
15
 
16
16
  s.files = `git ls-files`.split("\n")
17
17
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
- s.require_paths = ["lib"]
18
+ s.executables = `git ls-files -- exe/*`.split("\n").map { |f| File.basename(f) }
19
+ s.bindir = "exe"
20
20
 
21
21
  s.required_ruby_version = ">= 2.3.0"
22
22
 
23
- s.add_runtime_dependency('rake')
24
- s.add_runtime_dependency('bundler')
25
- s.add_runtime_dependency('thor', '>= 0.14.0')
26
-
27
- s.add_development_dependency("activesupport", ">= 3.2.21")
28
- s.add_development_dependency('rspec', '~> 3.0')
23
+ s.add_dependency("rake")
24
+ s.add_dependency("bundler")
25
+ s.add_dependency("thor", ">= 0.14.0")
29
26
  end
data/bin/bundle ADDED
@@ -0,0 +1,109 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'bundle' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "rubygems"
12
+
13
+ m = Module.new do
14
+ module_function
15
+
16
+ def invoked_as_script?
17
+ File.expand_path($0) == File.expand_path(__FILE__)
18
+ end
19
+
20
+ def env_var_version
21
+ ENV["BUNDLER_VERSION"]
22
+ end
23
+
24
+ def cli_arg_version
25
+ return unless invoked_as_script? # don't want to hijack other binstubs
26
+ return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
27
+ bundler_version = nil
28
+ update_index = nil
29
+ ARGV.each_with_index do |a, i|
30
+ if update_index && update_index.succ == i && a.match?(Gem::Version::ANCHORED_VERSION_PATTERN)
31
+ bundler_version = a
32
+ end
33
+ next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
34
+ bundler_version = $1
35
+ update_index = i
36
+ end
37
+ bundler_version
38
+ end
39
+
40
+ def gemfile
41
+ gemfile = ENV["BUNDLE_GEMFILE"]
42
+ return gemfile if gemfile && !gemfile.empty?
43
+
44
+ File.expand_path("../Gemfile", __dir__)
45
+ end
46
+
47
+ def lockfile
48
+ lockfile =
49
+ case File.basename(gemfile)
50
+ when "gems.rb" then gemfile.sub(/\.rb$/, ".locked")
51
+ else "#{gemfile}.lock"
52
+ end
53
+ File.expand_path(lockfile)
54
+ end
55
+
56
+ def lockfile_version
57
+ return unless File.file?(lockfile)
58
+ lockfile_contents = File.read(lockfile)
59
+ return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
60
+ Regexp.last_match(1)
61
+ end
62
+
63
+ def bundler_requirement
64
+ @bundler_requirement ||=
65
+ env_var_version ||
66
+ cli_arg_version ||
67
+ bundler_requirement_for(lockfile_version)
68
+ end
69
+
70
+ def bundler_requirement_for(version)
71
+ return "#{Gem::Requirement.default}.a" unless version
72
+
73
+ bundler_gem_version = Gem::Version.new(version)
74
+
75
+ bundler_gem_version.approximate_recommendation
76
+ end
77
+
78
+ def load_bundler!
79
+ ENV["BUNDLE_GEMFILE"] ||= gemfile
80
+
81
+ activate_bundler
82
+ end
83
+
84
+ def activate_bundler
85
+ gem_error = activation_error_handling do
86
+ gem "bundler", bundler_requirement
87
+ end
88
+ return if gem_error.nil?
89
+ require_error = activation_error_handling do
90
+ require "bundler/version"
91
+ end
92
+ return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
93
+ warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
94
+ exit 42
95
+ end
96
+
97
+ def activation_error_handling
98
+ yield
99
+ nil
100
+ rescue StandardError, LoadError => e
101
+ e
102
+ end
103
+ end
104
+
105
+ m.load_bundler!
106
+
107
+ if m.invoked_as_script?
108
+ load Gem.bin_path("bundler", "bundle")
109
+ end
data/bin/rspec ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rspec' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
12
+
13
+ bundle_binstub = File.expand_path("bundle", __dir__)
14
+
15
+ if File.file?(bundle_binstub)
16
+ if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
17
+ load(bundle_binstub)
18
+ else
19
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
20
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
21
+ end
22
+ end
23
+
24
+ require "rubygems"
25
+ require "bundler/setup"
26
+
27
+ load Gem.bin_path("rspec-core", "rspec")
@@ -1,8 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
- require 'rubygems'
3
- require 'bundler/setup'
4
- require 'appraisal'
5
- require 'appraisal/cli'
2
+ # frozen_string_literal: true
3
+
4
+ require "rubygems"
5
+ require "bundler/setup"
6
+ require "appraisal"
7
+ require "appraisal/cli"
6
8
 
7
9
  begin
8
10
  Appraisal::CLI.start
@@ -1,9 +1,11 @@
1
- require 'appraisal/gemfile'
2
- require 'appraisal/command'
1
+ # frozen_string_literal: true
2
+
3
+ require "appraisal/gemfile"
4
+ require "appraisal/command"
3
5
  require "appraisal/customize"
4
- require 'appraisal/utils'
5
- require 'fileutils'
6
- require 'pathname'
6
+ require "appraisal/utils"
7
+ require "fileutils"
8
+ require "pathname"
7
9
 
8
10
  module Appraisal
9
11
  # Represents one appraisal and its dependencies
@@ -63,7 +65,8 @@ module Appraisal
63
65
 
64
66
  def write_gemfile
65
67
  File.open(gemfile_path, "w") do |file|
66
- signature = Customize.heading || "This file was generated by Appraisal"
68
+ signature =
69
+ Customize.heading(self) || "This file was generated by Appraisal"
67
70
  file.puts([comment_lines(signature), quoted_gemfile].join("\n\n"))
68
71
  end
69
72
  end
@@ -78,15 +81,15 @@ module Appraisal
78
81
  command = commands.join(" || ")
79
82
 
80
83
  if Bundler.settings[:path]
81
- env = { 'BUNDLE_DISABLE_SHARED_GEMS' => '1' }
82
- Command.new(command, :env => env).run
84
+ env = { "BUNDLE_DISABLE_SHARED_GEMS" => "1" }
85
+ Command.new(command, env: env).run
83
86
  else
84
87
  Command.new(command).run
85
88
  end
86
89
  end
87
90
 
88
91
  def update(gems = [])
89
- Command.new(update_command(gems), :gemfile => gemfile_path).run
92
+ Command.new(update_command(gems), gemfile: gemfile_path).run
90
93
  end
91
94
 
92
95
  def gemfile_path
@@ -106,10 +109,10 @@ module Appraisal
106
109
  relative_path = current_directory.relative_path_from(gemfile_root).cleanpath
107
110
  lockfile_content = File.read(lockfile_path)
108
111
 
109
- File.open(lockfile_path, 'w') do |file|
112
+ File.open(lockfile_path, "w") do |file|
110
113
  file.write lockfile_content.gsub(
111
114
  / #{current_directory}/,
112
- " #{relative_path}",
115
+ " #{relative_path}"
113
116
  )
114
117
  end
115
118
  end
@@ -118,16 +121,16 @@ module Appraisal
118
121
 
119
122
  def check_command
120
123
  gemfile_option = "--gemfile='#{gemfile_path}'"
121
- ['bundle', 'check', gemfile_option]
124
+ ["bundle", "check", gemfile_option]
122
125
  end
123
126
 
124
127
  def install_command(options = {})
125
128
  gemfile_option = "--gemfile='#{gemfile_path}'"
126
- ['bundle', 'install', gemfile_option, bundle_options(options)].compact
129
+ ["bundle", "install", gemfile_option, bundle_options(options)].compact
127
130
  end
128
131
 
129
132
  def update_command(gems)
130
- ['bundle', 'update', *gems].compact
133
+ ["bundle", "update", *gems].compact
131
134
  end
132
135
 
133
136
  def gemfile_root
@@ -147,7 +150,7 @@ module Appraisal
147
150
  end
148
151
 
149
152
  def clean_name
150
- name.gsub(/[^\w\.]/, '_')
153
+ name.gsub(/[^\w\.]/, "_")
151
154
  end
152
155
 
153
156
  def bundle_options(options)
@@ -158,8 +161,8 @@ module Appraisal
158
161
  if Utils.support_parallel_installation?
159
162
  options_strings << "--jobs=#{jobs}"
160
163
  else
161
- warn 'Your current version of Bundler does not support parallel installation. Please ' +
162
- 'upgrade Bundler to version >= 1.4.0, or invoke `appraisal` without `--jobs` option.'
164
+ warn "Your current version of Bundler does not support parallel installation. Please " +
165
+ "upgrade Bundler to version >= 1.4.0, or invoke `appraisal` without `--jobs` option."
163
166
  end
164
167
  end
165
168
 
@@ -1,7 +1,9 @@
1
- require 'appraisal/appraisal'
1
+ # frozen_string_literal: true
2
+
3
+ require "appraisal/appraisal"
2
4
  require "appraisal/customize"
3
- require 'appraisal/errors'
4
- require 'appraisal/gemfile'
5
+ require "appraisal/errors"
6
+ require "appraisal/gemfile"
5
7
 
6
8
  module Appraisal
7
9
  # Loads and parses Appraisals file
@@ -15,7 +17,7 @@ module Appraisal
15
17
  def initialize
16
18
  @appraisals = []
17
19
  @gemfile = Gemfile.new
18
- @gemfile.load(ENV['BUNDLE_GEMFILE'] || 'Gemfile')
20
+ @gemfile.load(ENV["BUNDLE_GEMFILE"] || "Gemfile")
19
21
 
20
22
  if File.exist? path
21
23
  run IO.read(path)
@@ -35,7 +37,7 @@ module Appraisal
35
37
  end
36
38
 
37
39
  def customize_gemfiles(&_block)
38
- Customize.new(yield)
40
+ Customize.new(**yield)
39
41
  end
40
42
 
41
43
  private
@@ -45,7 +47,7 @@ module Appraisal
45
47
  end
46
48
 
47
49
  def path
48
- 'Appraisals'
50
+ "Appraisals"
49
51
  end
50
52
  end
51
53
  end
@@ -1,22 +1,24 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "appraisal/dependency_list"
2
4
 
3
5
  module Appraisal
4
6
  class BundlerDSL
5
7
  attr_reader :dependencies
6
8
 
7
- PARTS = %w(source ruby_version gits paths dependencies groups
8
- platforms source_blocks install_if gemspec)
9
+ PARTS = %w[source ruby_version gits paths dependencies groups
10
+ platforms source_blocks install_if gemspec]
9
11
 
10
12
  def initialize
11
13
  @sources = []
12
14
  @ruby_version = nil
13
15
  @dependencies = DependencyList.new
14
16
  @gemspecs = []
15
- @groups = Hash.new
16
- @platforms = Hash.new
17
- @gits = Hash.new
18
- @paths = Hash.new
19
- @source_blocks = Hash.new
17
+ @groups = {}
18
+ @platforms = {}
19
+ @gits = {}
20
+ @paths = {}
21
+ @source_blocks = {}
20
22
  @git_sources = {}
21
23
  @install_if = {}
22
24
  end
@@ -80,11 +82,11 @@ module Appraisal
80
82
  end
81
83
 
82
84
  def to_s
83
- Utils.join_parts PARTS.map { |part| send("#{part}_entry") }
85
+ Utils.join_parts(PARTS.map { |part| send("#{part}_entry") })
84
86
  end
85
87
 
86
88
  def for_dup
87
- Utils.join_parts PARTS.map { |part| send("#{part}_entry_for_dup") }
89
+ Utils.join_parts(PARTS.map { |part| send("#{part}_entry_for_dup") })
88
90
  end
89
91
 
90
92
  def gemspec(options = {})
@@ -108,8 +110,11 @@ module Appraisal
108
110
  alias_method :source_entry_for_dup, :source_entry
109
111
 
110
112
  def ruby_version_entry
111
- if @ruby_version
112
- "ruby #{@ruby_version.inspect}"
113
+ return unless @ruby_version
114
+
115
+ case @ruby_version
116
+ when String then "ruby #{@ruby_version.inspect}"
117
+ else "ruby(#{@ruby_version.inspect})"
113
118
  end
114
119
  end
115
120
 
@@ -131,8 +136,7 @@ module Appraisal
131
136
  @dependencies.for_dup
132
137
  end
133
138
 
134
- %i[gits paths platforms groups source_blocks install_if].
135
- each do |method_name|
139
+ %i[gits paths platforms groups source_blocks install_if].each do |method_name|
136
140
  class_eval <<-METHODS, __FILE__, __LINE__
137
141
  private
138
142