appraisal 2.4.1 → 3.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) 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 +49 -33
  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 +45 -18
  14. data/lib/appraisal/appraisal_file.rb +12 -5
  15. data/lib/appraisal/bundler_dsl.rb +24 -13
  16. data/lib/appraisal/cli.rb +49 -51
  17. data/lib/appraisal/command.rb +21 -29
  18. data/lib/appraisal/conditional.rb +24 -0
  19. data/lib/appraisal/customize.rb +36 -0
  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 +7 -6
  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 +68 -24
  35. data/spec/acceptance/bundle_with_custom_path_spec.rb +26 -20
  36. data/spec/acceptance/bundle_without_spec.rb +10 -8
  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 +50 -44
  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 +44 -36
  47. data/spec/acceptance/gemspec_spec.rb +30 -24
  48. data/spec/appraisal/appraisal_file_spec.rb +66 -4
  49. data/spec/appraisal/appraisal_spec.rb +77 -23
  50. data/spec/appraisal/customize_spec.rb +140 -0
  51. data/spec/appraisal/dependency_list_spec.rb +3 -1
  52. data/spec/appraisal/gemfile_spec.rb +48 -38
  53. data/spec/appraisal/utils_spec.rb +21 -28
  54. data/spec/spec_helper.rb +15 -6
  55. data/spec/support/acceptance_test_helpers.rb +33 -25
  56. data/spec/support/dependency_helpers.rb +29 -15
  57. data/spec/support/stream_helpers.rb +2 -0
  58. metadata +14 -38
  59. data/.rspec +0 -1
  60. data/.travis.yml +0 -18
  61. data/lib/appraisal/travis_ci_helper.rb +0 -69
  62. data/spec/acceptance/travis_ci_integration_spec.rb +0 -94
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3f28af4a3f925fd52ded81f375ed865a56a844fe20d4bdaf09a4a6fc8c7ad644
4
- data.tar.gz: 3016386d58c9a22889d2e3e137cec003040f28e75040cc5349fa7d8ef2081c52
3
+ metadata.gz: 91cd28f94201740fdcc34e58200fec87442a99144b1b4c1b909d818b12f8e644
4
+ data.tar.gz: 7e61989365c22a32cea85d0cd01a7b27056a9daa2eeae452a6dede92537caf0e
5
5
  SHA512:
6
- metadata.gz: 8f610b40f4e7282377c0d98eb36ee735ca6ecc24daac98995029affb811f2d86e41189628e1667464000ab706392b3ea418411760847bd8a61aea08629e1d461
7
- data.tar.gz: 709cc7583d98cdaa1ead29f3804f9f02ebf1a7f089af2a751433dc4860748438e6f2f3974eb14fe58ae67dcd1f406b7a00ddf5be6228112258698c67d13595c8
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
@@ -1,13 +1,8 @@
1
1
  Appraisal
2
2
  =========
3
3
 
4
- [![Build Status][Build Status Image]][Build Status]
5
-
6
4
  Find out what your Ruby gems are worth.
7
5
 
8
- [Build Status Image]: https://secure.travis-ci.org/thoughtbot/appraisal.svg?branch=master
9
- [Build Status]: http://travis-ci.org/thoughtbot/appraisal
10
-
11
6
  Synopsis
12
7
  --------
13
8
 
@@ -89,7 +84,7 @@ your real default task, which usually is your `test` task.)
89
84
 
90
85
  Note that this may conflict with your CI setup if you decide to split the test
91
86
  into multiple processes by Appraisal and you are using `rake` to run tests by
92
- default. Please see **Travis CI Integration** for more detail.
87
+ default.
93
88
 
94
89
  ### Commands
95
90
 
@@ -141,7 +136,7 @@ appraise 'rails-5' do
141
136
  gem 'rails', '~> 5.2'
142
137
 
143
138
  group :test do
144
- remove_gem :test_after_commit
139
+ remove_gem 'test_after_commit'
145
140
  end
146
141
  end
147
142
  ```
@@ -155,41 +150,62 @@ group :test do
155
150
  end
156
151
  ```
157
152
 
158
- Version Control
159
- ---------------
153
+ Customization
154
+ -------------
160
155
 
161
- When using Appraisal, we recommend you check in the Gemfiles that Appraisal
162
- generates within the gemfiles directory, but exclude the lockfiles there
163
- (`*.gemfile.lock`.) The Gemfiles are useful when running your tests against a
164
- continuous integration server such as [Travis CI][Travis CI].
156
+ It is possible to customize the generated Gemfiles by adding a `customize_gemfiles` block to
157
+ your `Appraisals` file. The block must contain a hash of key/value pairs. Currently supported
158
+ customizations include:
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
+ - single_quotes: a boolean that controls if strings are single quoted in each Gemfile, defaults to false
165
161
 
166
- [Travis CI]: https://travis-ci.org
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`
167
170
 
168
- Travis CI integration
169
- ---------------------
171
+ ### Example Usage
170
172
 
171
- If you're using Appraisal and using Travis CI, we're recommending you to setup
172
- Travis to run the test against multiple generated Gemfiles. This can be done
173
- by using `gemfile` setting:
173
+ **Appraisals**
174
+ ```ruby
175
+ customize_gemfiles do
176
+ {
177
+ single_quotes: true,
178
+ heading: <<~HEADING
179
+ frozen_string_literal: true
180
+
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/
183
+ HEADING
184
+ }
185
+ end
174
186
 
175
- # In .travis.yml
176
- gemfile:
177
- - gemfiles/3.0.gemfile
178
- - gemfiles/3.1.gemfile
179
- - gemfiles/3.2.gemfile
187
+ appraise "rails-3" do
188
+ gem "rails", "3.2.14"
189
+ end
190
+ ```
180
191
 
181
- Please note that if you've set your default rake task to run the test against
182
- all versions of its dependency, you might have to set a `script` setting:
192
+ Using the `Appraisals` file defined above, this is what the resulting `Gemfile` will look like:
193
+ ```ruby
194
+ # frozen_string_literal: true
183
195
 
184
- script: "bundle exec rake test"
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/
185
198
 
186
- That will make sure that each of the test sub-job are not getting run more than
187
- one time.
199
+ gem 'rails', '3.2.14'
200
+ ```
188
201
 
189
- You can also run your tests against multiple versions of Ruby locally, just
190
- like running on Travis CI, by using [WWTD].
202
+ Version Control
203
+ ---------------
191
204
 
192
- [WWTD]: https://github.com/grosser/wwtd
205
+ When using Appraisal, we recommend you check in the Gemfiles that Appraisal
206
+ generates within the gemfiles directory, but exclude the lockfiles there
207
+ (`*.gemfile.lock`.) The Gemfiles are useful when running your tests against a
208
+ continuous integration server.
193
209
 
194
210
  Circle CI Integration
195
211
  ---------------------
@@ -217,7 +233,7 @@ command in the `override` section and use your favourite one.
217
233
  Credits
218
234
  -------
219
235
 
220
- ![thoughtbot](http://presskit.thoughtbot.com/images/thoughtbot-logo-for-readmes.svg)
236
+ ![thoughtbot](https://thoughtbot.com/thoughtbot-logo-for-readmes.svg)
221
237
 
222
238
  Appraisal is maintained and funded by [thoughtbot, inc][thoughtbot]
223
239
 
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,8 +1,11 @@
1
- require 'appraisal/gemfile'
2
- require 'appraisal/command'
3
- require 'appraisal/utils'
4
- require 'fileutils'
5
- require 'pathname'
1
+ # frozen_string_literal: true
2
+
3
+ require "appraisal/gemfile"
4
+ require "appraisal/command"
5
+ require "appraisal/customize"
6
+ require "appraisal/utils"
7
+ require "fileutils"
8
+ require "pathname"
6
9
 
7
10
  module Appraisal
8
11
  # Represents one appraisal and its dependencies
@@ -44,6 +47,10 @@ module Appraisal
44
47
  gemfile.group(*args, &block)
45
48
  end
46
49
 
50
+ def install_if(*args, &block)
51
+ gemfile.install_if(*args, &block)
52
+ end
53
+
47
54
  def platforms(*args, &block)
48
55
  gemfile.platforms(*args, &block)
49
56
  end
@@ -58,8 +65,9 @@ module Appraisal
58
65
 
59
66
  def write_gemfile
60
67
  File.open(gemfile_path, "w") do |file|
61
- signature = "# This file was generated by Appraisal"
62
- file.puts([signature, gemfile.to_s].join("\n\n"))
68
+ signature =
69
+ Customize.heading(self) || "This file was generated by Appraisal"
70
+ file.puts([comment_lines(signature), quoted_gemfile].join("\n\n"))
63
71
  end
64
72
  end
65
73
 
@@ -73,15 +81,15 @@ module Appraisal
73
81
  command = commands.join(" || ")
74
82
 
75
83
  if Bundler.settings[:path]
76
- env = { 'BUNDLE_DISABLE_SHARED_GEMS' => '1' }
77
- Command.new(command, :env => env).run
84
+ env = { "BUNDLE_DISABLE_SHARED_GEMS" => "1" }
85
+ Command.new(command, env: env).run
78
86
  else
79
87
  Command.new(command).run
80
88
  end
81
89
  end
82
90
 
83
91
  def update(gems = [])
84
- Command.new(update_command(gems), :gemfile => gemfile_path).run
92
+ Command.new(update_command(gems), gemfile: gemfile_path).run
85
93
  end
86
94
 
87
95
  def gemfile_path
@@ -101,8 +109,11 @@ module Appraisal
101
109
  relative_path = current_directory.relative_path_from(gemfile_root).cleanpath
102
110
  lockfile_content = File.read(lockfile_path)
103
111
 
104
- File.open(lockfile_path, 'w') do |file|
105
- file.write lockfile_content.gsub(/#{current_directory}/, relative_path.to_s)
112
+ File.open(lockfile_path, "w") do |file|
113
+ file.write lockfile_content.gsub(
114
+ / #{current_directory}/,
115
+ " #{relative_path}"
116
+ )
106
117
  end
107
118
  end
108
119
 
@@ -110,16 +121,16 @@ module Appraisal
110
121
 
111
122
  def check_command
112
123
  gemfile_option = "--gemfile='#{gemfile_path}'"
113
- ['bundle', 'check', gemfile_option]
124
+ ["bundle", "check", gemfile_option]
114
125
  end
115
126
 
116
127
  def install_command(options = {})
117
128
  gemfile_option = "--gemfile='#{gemfile_path}'"
118
- ['bundle', 'install', gemfile_option, bundle_options(options)].compact
129
+ ["bundle", "install", gemfile_option, bundle_options(options)].compact
119
130
  end
120
131
 
121
132
  def update_command(gems)
122
- ['bundle', 'update', *gems].compact
133
+ ["bundle", "update", *gems].compact
123
134
  end
124
135
 
125
136
  def gemfile_root
@@ -139,7 +150,7 @@ module Appraisal
139
150
  end
140
151
 
141
152
  def clean_name
142
- name.gsub(/[^\w\.]/, '_')
153
+ name.gsub(/[^\w\.]/, "_")
143
154
  end
144
155
 
145
156
  def bundle_options(options)
@@ -150,8 +161,8 @@ module Appraisal
150
161
  if Utils.support_parallel_installation?
151
162
  options_strings << "--jobs=#{jobs}"
152
163
  else
153
- warn 'Your current version of Bundler does not support parallel installation. Please ' +
154
- '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."
155
166
  end
156
167
  end
157
168
 
@@ -167,5 +178,21 @@ module Appraisal
167
178
 
168
179
  options_strings.join(" ") if options_strings != []
169
180
  end
181
+
182
+ def comment_lines(heading)
183
+ heading.lines.map do |line|
184
+ if line.lstrip.empty?
185
+ line
186
+ else
187
+ "# #{line}"
188
+ end
189
+ end.join
190
+ end
191
+
192
+ def quoted_gemfile
193
+ return gemfile.to_s unless Customize.single_quotes
194
+
195
+ gemfile.to_s.tr('"', "'")
196
+ end
170
197
  end
171
198
  end
@@ -1,6 +1,9 @@
1
- require 'appraisal/appraisal'
2
- require 'appraisal/errors'
3
- require 'appraisal/gemfile'
1
+ # frozen_string_literal: true
2
+
3
+ require "appraisal/appraisal"
4
+ require "appraisal/customize"
5
+ require "appraisal/errors"
6
+ require "appraisal/gemfile"
4
7
 
5
8
  module Appraisal
6
9
  # Loads and parses Appraisals file
@@ -14,7 +17,7 @@ module Appraisal
14
17
  def initialize
15
18
  @appraisals = []
16
19
  @gemfile = Gemfile.new
17
- @gemfile.load(ENV['BUNDLE_GEMFILE'] || 'Gemfile')
20
+ @gemfile.load(ENV["BUNDLE_GEMFILE"] || "Gemfile")
18
21
 
19
22
  if File.exist? path
20
23
  run IO.read(path)
@@ -33,6 +36,10 @@ module Appraisal
33
36
  @appraisals << appraisal
34
37
  end
35
38
 
39
+ def customize_gemfiles(&_block)
40
+ Customize.new(**yield)
41
+ end
42
+
36
43
  private
37
44
 
38
45
  def run(definitions)
@@ -40,7 +47,7 @@ module Appraisal
40
47
  end
41
48
 
42
49
  def path
43
- 'Appraisals'
50
+ "Appraisals"
44
51
  end
45
52
  end
46
53
  end