appraisal 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3b0fc3ea3d75b4caacecc601a02f5cc3dbe9aad9
4
- data.tar.gz: 12d540aa5afe3fe1a12813e21dbccbf65e3c2b9f
3
+ metadata.gz: 398a456edb84cd58cc28ce0e4f1f48fa71fba9ec
4
+ data.tar.gz: f345bc81392798434127f0809c9038f73901822c
5
5
  SHA512:
6
- metadata.gz: bb0850ae7207e6f668668dcfdd0debb6c06b38989ca7bf557530a0e40ecb71aca98404d9d469106b60f2f5469833a40a49743acb96690fb31a492df51f1115b5
7
- data.tar.gz: 6ec513b116b30e95f775df2e5f88d06a5eafad736e922cbd5db3c0f6b2703b655750e9417f700d73cc34f95e30a3c9bd04e55cfd9b9dfe2579fcccd3c73f864a
6
+ metadata.gz: 5828d0980b60a878098edb125dcb09582d5328315c0724e50522489e9d3bdd63f7c68b353d372d8442521e98d4dbc84fc2373f32aedf7dafabc5a88a81ecf625
7
+ data.tar.gz: a6fc78e3735ed05b871ac0ddb7f1f7dc64b0734985ace8992b0a7198a28eeb2f9dd1910b925a2fe9c2ca3f50cbe46bea4d28d93db5712a9366c2eb9e52a3a207
@@ -3,12 +3,13 @@ sudo: false
3
3
  before_install: gem install bundler
4
4
 
5
5
  rvm:
6
- - 1.8
7
- - 1.9
8
- - 2.0
9
- - 2.1
10
- - 2.2
11
- - rbx-2
6
+ - 1.8.7-head
7
+ - 1.9.3-p551
8
+ - 2.0.0-p648
9
+ - 2.1.10
10
+ - 2.2.6
11
+ - 2.3.3
12
+ - 2.4.0-preview3
12
13
  - jruby-19mode
13
14
  - ruby-head
14
15
  - jruby-head
@@ -16,7 +17,7 @@ rvm:
16
17
  matrix:
17
18
  fast_finish: true
18
19
  allow_failures:
19
- - rvm: rbx-2
20
20
  - rvm: jruby-19mode
21
- - rvm: ruby-head
22
21
  - rvm: jruby-head
22
+ - rvm: ruby-head
23
+ - rvm: 2.4.0-preview3
data/Gemfile CHANGED
@@ -1,11 +1,12 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
5
  # This here to make sure appraisal works with Rails 3.0.0.
6
- gem 'thor', '~> 0.14.0'
6
+ gem "thor", "~> 0.14.0"
7
7
 
8
8
  if RUBY_VERSION < "1.9"
9
- gem "i18n", "~> 0.6.0"
10
- gem "activesupport", "~> 3.2.21"
9
+ eval File.read("Gemfile-1.8")
10
+ elsif RUBY_VERSION < "2.2"
11
+ eval File.read("Gemfile-2.1")
11
12
  end
@@ -0,0 +1,5 @@
1
+ # These gems are locked for Ruby 1.8.7 compatibility
2
+ gem "i18n", "~> 0.6.0"
3
+ gem "activesupport", "~> 3.2.21"
4
+ gem "rake", "~> 10.5"
5
+ gem "rack", "~> 1.6.5"
@@ -0,0 +1,3 @@
1
+ # These gems are locked for Ruby 2.1.0 compatibility
2
+ gem "activesupport", "~> 4.2.7"
3
+ gem "rack", "~> 1.6.5"
data/README.md CHANGED
@@ -5,7 +5,7 @@ Appraisal
5
5
 
6
6
  Find out what your Ruby gems are worth.
7
7
 
8
- [Build Status Image]: https://secure.travis-ci.org/thoughtbot/appraisal.png?branch=master
8
+ [Build Status Image]: https://secure.travis-ci.org/thoughtbot/appraisal.svg?branch=master
9
9
  [Build Status]: http://travis-ci.org/thoughtbot/appraisal
10
10
 
11
11
  Synopsis
@@ -23,18 +23,19 @@ In your Gemfile:
23
23
 
24
24
  gem "appraisal"
25
25
 
26
- Note that gems must be bundled in the global namespace. Bundling gems to a local
27
- location or vendoring plugins is not supported. If you do not want to pollute the
28
- global namespace, one alternative is [RVM's Gemsets](http://rvm.io/gemsets).
26
+ Note that gems must be bundled in the global namespace. Bundling gems to a
27
+ local location or vendoring plugins is not supported. If you do not want to
28
+ pollute the global namespace, one alternative is
29
+ [RVM's Gemsets](http://rvm.io/gemsets).
29
30
 
30
31
  Setup
31
32
  -----
32
33
 
33
- Setting up appraisal requires an Appraisals file (similar to a Gemfile) in your
34
- project root, named "Appraisals" (note the case), and some slight changes to
35
- your project's Rakefile.
34
+ Setting up appraisal requires an `Appraisals` file (similar to a `Gemfile`) in
35
+ your project root, named "Appraisals" (note the case), and some slight changes
36
+ to your project's `Rakefile`.
36
37
 
37
- An Appraisals file consists of several appraisal definitions. An appraisal
38
+ An `Appraisals` file consists of several appraisal definitions. An appraisal
38
39
  definition is simply a list of gem dependencies. For example, to test with a
39
40
  few versions of Rails:
40
41
 
@@ -46,8 +47,8 @@ few versions of Rails:
46
47
  gem "rails", "4.0.0"
47
48
  end
48
49
 
49
- The dependencies in your Appraisals file are combined with dependencies in your
50
- Gemfile, so you don't need to repeat anything that's the same for each
50
+ The dependencies in your `Appraisals` file are combined with dependencies in
51
+ your `Gemfile`, so you don't need to repeat anything that's the same for each
51
52
  appraisal. If something is specified in both the Gemfile and an appraisal, the
52
53
  version from the appraisal takes precedence.
53
54
 
@@ -63,18 +64,18 @@ Usage
63
64
  Once you've configured the appraisals you want to use, you need to install the
64
65
  dependencies for each appraisal:
65
66
 
66
- appraisal install
67
+ $ appraisal install
67
68
 
68
69
  This will resolve, install, and lock the dependencies for that appraisal using
69
70
  bundler. Once you have your dependencies set up, you can run any command in a
70
71
  single appraisal:
71
72
 
72
- appraisal rails-3 rake test
73
+ $ appraisal rails-3 rake test
73
74
 
74
75
  This will run `rake test` using the dependencies configured for Rails 3. You can
75
76
  also run each appraisal in turn:
76
77
 
77
- appraisal rake test
78
+ $ appraisal rake test
78
79
 
79
80
  If you want to use only the dependencies from your Gemfile, just run `rake
80
81
  test` as normal. This allows you to keep running with the latest versions of
@@ -139,15 +140,38 @@ all versions of its dependency, you might have to set a `script` setting:
139
140
  That will make sure that each of the test sub-job are not getting run more than
140
141
  one time.
141
142
 
142
- You can also running your test against multiple versions of Ruby locally, just
143
+ You can also run your tests against multiple versions of Ruby locally, just
143
144
  like running on Travis CI, by using [WWTD].
144
145
 
145
146
  [WWTD]: https://github.com/grosser/wwtd
146
147
 
148
+ Circle CI Integration
149
+ ---------------------
150
+
151
+ In Circle CI you can override the default testing behaviour to customize your
152
+ testing. Using this feature you can configure appraisal to execute your tests.
153
+
154
+ In order to this you can put the following configuration in your circle.yml file:
155
+
156
+ ```yml
157
+ dependencies:
158
+ post:
159
+ - bundle exec appraisal install
160
+ test:
161
+ pre:
162
+ - bundle exec appraisal rake db:create
163
+ - bundle exec appraisal rake db:migrate
164
+ override:
165
+ - bundle exec appraisal rspec
166
+ ```
167
+
168
+ Notice that we are running an rspec suite. You can customize your testing
169
+ command in the `override` section and use your favourite one.
170
+
147
171
  Credits
148
172
  -------
149
173
 
150
- ![thoughtbot](http://thoughtbot.com/images/tm/logo.png)
174
+ ![thoughtbot](http://presskit.thoughtbot.com/images/thoughtbot-logo-for-readmes.svg)
151
175
 
152
176
  Appraisal is maintained and funded by [thoughtbot, inc][thoughtbot]
153
177
 
@@ -7,6 +7,8 @@ require 'pathname'
7
7
  module Appraisal
8
8
  # Represents one appraisal and its dependencies
9
9
  class Appraisal
10
+ DEFAULT_INSTALL_OPTIONS = { "jobs" => 1 }.freeze
11
+
10
12
  attr_reader :name, :gemfile
11
13
 
12
14
  def initialize(name, source_gemfile)
@@ -46,19 +48,25 @@ module Appraisal
46
48
  gemfile.gemspec(options)
47
49
  end
48
50
 
51
+ def git_source(*args, &block)
52
+ gemfile.git_source(*args, &block)
53
+ end
54
+
49
55
  def write_gemfile
50
- ::File.open(gemfile_path, "w") do |file|
56
+ File.open(gemfile_path, "w") do |file|
51
57
  signature = "# This file was generated by Appraisal"
52
58
  file.puts([signature, gemfile.to_s].join("\n\n"))
53
59
  end
54
60
  end
55
61
 
56
- def install(job_size = 1)
57
- command = [
58
- check_command,
59
- "||",
60
- install_command(job_size)
61
- ].flatten.join(" ")
62
+ def install(options = {})
63
+ commands = [install_command(options).join(" ")]
64
+
65
+ if options["without"].nil? || options["without"].empty?
66
+ commands.unshift(check_command.join(" "))
67
+ end
68
+
69
+ command = commands.join(" || ")
62
70
 
63
71
  if Bundler.settings[:path]
64
72
  env = { 'BUNDLE_DISABLE_SHARED_GEMS' => '1' }
@@ -69,8 +77,7 @@ module Appraisal
69
77
  end
70
78
 
71
79
  def update(gems = [])
72
- command, env = update_command(gems)
73
- Command.new(command, :env => env).run
80
+ Command.new(update_command(gems), :gemfile => gemfile_path).run
74
81
  end
75
82
 
76
83
  def gemfile_path
@@ -82,15 +89,15 @@ module Appraisal
82
89
  end
83
90
 
84
91
  def relative_gemfile_path
85
- ::File.join("gemfiles", gemfile_name)
92
+ File.join("gemfiles", gemfile_name)
86
93
  end
87
94
 
88
95
  def relativize
89
96
  current_directory = Pathname.new(Dir.pwd)
90
97
  relative_path = current_directory.relative_path_from(gemfile_root).cleanpath
91
- lockfile_content = ::File.read(lockfile_path)
98
+ lockfile_content = File.read(lockfile_path)
92
99
 
93
- ::File.open(lockfile_path, 'w') do |file|
100
+ File.open(lockfile_path, 'w') do |file|
94
101
  file.write lockfile_content.gsub(/#{current_directory}/, relative_path.to_s)
95
102
  end
96
103
  end
@@ -102,19 +109,17 @@ module Appraisal
102
109
  ['bundle', 'check', gemfile_option]
103
110
  end
104
111
 
105
- def install_command(job_size)
112
+ def install_command(options = {})
106
113
  gemfile_option = "--gemfile='#{gemfile_path}'"
107
- ['bundle', 'install', gemfile_option, bundle_parallel_option(job_size)].compact
114
+ ['bundle', 'install', gemfile_option, bundle_options(options)].compact
108
115
  end
109
116
 
110
117
  def update_command(gems)
111
- env = { "BUNDLE_GEMFILE" => gemfile_path }
112
- command = ['bundle', 'update', *gems].compact
113
- [command, env]
118
+ ['bundle', 'update', *gems].compact
114
119
  end
115
120
 
116
121
  def gemfile_root
117
- Pathname.new(::File.join(Dir.pwd, "gemfiles"))
122
+ Pathname.new(File.join(Dir.pwd, "gemfiles"))
118
123
  end
119
124
 
120
125
  def gemfile_name
@@ -129,15 +134,24 @@ module Appraisal
129
134
  name.gsub(/[^\w\.]/, '_')
130
135
  end
131
136
 
132
- def bundle_parallel_option(job_size)
133
- if job_size > 1
137
+ def bundle_options(options)
138
+ full_options = DEFAULT_INSTALL_OPTIONS.dup.merge(options)
139
+ options_strings = []
140
+ jobs = full_options.delete("jobs")
141
+ if jobs > 1
134
142
  if Utils.support_parallel_installation?
135
- "--jobs=#{job_size}"
143
+ options_strings << "--jobs=#{jobs}"
136
144
  else
137
145
  warn 'Your current version of Bundler does not support parallel installation. Please ' +
138
146
  'upgrade Bundler to version >= 1.4.0, or invoke `appraisal` without `--jobs` option.'
139
147
  end
140
148
  end
149
+
150
+ full_options.each do |flag, val|
151
+ options_strings << "--#{flag} #{val}"
152
+ end
153
+
154
+ options_strings.join(" ") if options_strings != []
141
155
  end
142
156
  end
143
157
  end
@@ -4,7 +4,7 @@ require 'appraisal/gemfile'
4
4
 
5
5
  module Appraisal
6
6
  # Loads and parses Appraisals file
7
- class File
7
+ class AppraisalFile
8
8
  attr_reader :appraisals, :gemfile
9
9
 
10
10
  def self.each(&block)
@@ -16,7 +16,7 @@ module Appraisal
16
16
  @gemfile = Gemfile.new
17
17
  @gemfile.load(ENV['BUNDLE_GEMFILE'] || 'Gemfile')
18
18
 
19
- if ::File.exist? path
19
+ if File.exist? path
20
20
  run IO.read(path)
21
21
  else
22
22
  raise AppraisalsNotFound
@@ -5,19 +5,20 @@ module Appraisal
5
5
  class BundlerDSL
6
6
  attr_reader :dependencies
7
7
 
8
- PARTS = %w(source ruby_version git_sources path_sources dependencies groups
8
+ PARTS = %w(source ruby_version gits paths dependencies groups
9
9
  platforms source_blocks gemspec)
10
10
 
11
11
  def initialize
12
12
  @sources = []
13
13
  @ruby_version = nil
14
14
  @dependencies = DependencyList.new
15
- @gemspec = nil
15
+ @gemspecs = []
16
16
  @groups = OrderedHash.new
17
17
  @platforms = OrderedHash.new
18
- @git_sources = OrderedHash.new
19
- @path_sources = OrderedHash.new
18
+ @gits = OrderedHash.new
19
+ @paths = OrderedHash.new
20
20
  @source_blocks = OrderedHash.new
21
+ @git_sources = {}
21
22
  end
22
23
 
23
24
  def run(&block)
@@ -25,7 +26,7 @@ module Appraisal
25
26
  end
26
27
 
27
28
  def gem(name, *requirements)
28
- @dependencies.add(name, requirements)
29
+ @dependencies.add(name, substitute_git_source(requirements))
29
30
  end
30
31
 
31
32
  def group(*names, &block)
@@ -54,13 +55,13 @@ module Appraisal
54
55
  end
55
56
 
56
57
  def git(source, options = {}, &block)
57
- @git_sources[source] ||= GitSource.new(source, options)
58
- @git_sources[source].run(&block)
58
+ @gits[source] ||= Git.new(source, options)
59
+ @gits[source].run(&block)
59
60
  end
60
61
 
61
62
  def path(source, options = {}, &block)
62
- @path_sources[source] ||= PathSource.new(source, options)
63
- @path_sources[source].run(&block)
63
+ @paths[source] ||= Path.new(source, options)
64
+ @paths[source].run(&block)
64
65
  end
65
66
 
66
67
  def to_s
@@ -72,9 +73,17 @@ module Appraisal
72
73
  end
73
74
 
74
75
  def gemspec(options = {})
75
- @gemspec = Gemspec.new(options)
76
+ @gemspecs << Gemspec.new(options)
76
77
  end
77
78
 
79
+ def git_source(source, &block)
80
+ @git_sources[source] = block
81
+ end
82
+
83
+ protected
84
+
85
+ attr_writer :git_sources
86
+
78
87
  private
79
88
 
80
89
  def source_entry
@@ -91,25 +100,23 @@ module Appraisal
91
100
 
92
101
  alias_method :ruby_version_entry_for_dup, :ruby_version_entry
93
102
 
94
- [:dependencies, :gemspec].each do |method_name|
95
- class_eval <<-METHODS, __FILE__, __LINE__
96
- private
103
+ def gemspec_entry
104
+ @gemspecs.map(&:to_s).join("\n")
105
+ end
97
106
 
98
- def #{method_name}_entry
99
- if @#{method_name}
100
- @#{method_name}.to_s
101
- end
102
- end
107
+ def gemspec_entry_for_dup
108
+ @gemspecs.map(&:for_dup).join("\n")
109
+ end
103
110
 
104
- def #{method_name}_entry_for_dup
105
- if @#{method_name}
106
- @#{method_name}.for_dup
107
- end
108
- end
109
- METHODS
111
+ def dependencies_entry
112
+ @dependencies.to_s
113
+ end
114
+
115
+ def dependencies_entry_for_dup
116
+ @dependencies.for_dup
110
117
  end
111
118
 
112
- [:git_sources, :path_sources, :platforms, :groups, :source_blocks].
119
+ [:gits, :paths, :platforms, :groups, :source_blocks].
113
120
  each do |method_name|
114
121
  class_eval <<-METHODS, __FILE__, __LINE__
115
122
  private
@@ -127,5 +134,16 @@ module Appraisal
127
134
  def indent(string)
128
135
  string.strip.gsub(/^(.+)$/, ' \1')
129
136
  end
137
+
138
+ def substitute_git_source(requirements)
139
+ requirements.each do |requirement|
140
+ if requirement.is_a?(Hash)
141
+ (requirement.keys & @git_sources.keys).each do |matching_source|
142
+ value = requirement.delete(matching_source)
143
+ requirement[:git] = @git_sources[matching_source].call(value)
144
+ end
145
+ end
146
+ end
147
+ end
130
148
  end
131
149
  end
@@ -19,11 +19,11 @@ module Appraisal
19
19
  appraisal, otherwise it runs the EXTERNAL_COMMAND against all appraisals.
20
20
  help
21
21
 
22
- if ::File.exist?('Appraisals')
22
+ if File.exist?('Appraisals')
23
23
  shell.say
24
24
  shell.say 'Available Appraisal(s):'
25
25
 
26
- File.each do |appraisal|
26
+ AppraisalFile.each do |appraisal|
27
27
  shell.say " - #{appraisal.name}"
28
28
  end
29
29
  end
@@ -41,11 +41,16 @@ module Appraisal
41
41
  method_option 'jobs', :aliases => 'j', :type => :numeric, :default => 1,
42
42
  :banner => 'SIZE',
43
43
  :desc => 'Install gems in parallel using the given number of workers.'
44
+ method_option 'retry', :type => :numeric, :default => 1,
45
+ :desc => 'Retry network and git requests that have failed'
46
+ method_option "without", :banner => "GROUP_NAMES",
47
+ :desc => "A space-separated list of groups referencing gems to skip " +
48
+ "during installation. Bundler will remember this option."
44
49
  def install
45
50
  invoke :generate, [], {}
46
51
 
47
- File.each do |appraisal|
48
- appraisal.install(options[:jobs])
52
+ AppraisalFile.each do |appraisal|
53
+ appraisal.install(options)
49
54
  appraisal.relativize
50
55
  end
51
56
  end
@@ -53,7 +58,7 @@ module Appraisal
53
58
  desc 'generate', 'Generate a gemfile for each appraisal'
54
59
  method_option "travis", :type => :boolean, :default => false
55
60
  def generate
56
- File.each do |appraisal|
61
+ AppraisalFile.each do |appraisal|
57
62
  appraisal.write_gemfile
58
63
  end
59
64
 
@@ -73,14 +78,14 @@ module Appraisal
73
78
  def update(*gems)
74
79
  invoke :generate, []
75
80
 
76
- File.each do |appraisal|
81
+ AppraisalFile.each do |appraisal|
77
82
  appraisal.update(gems)
78
83
  end
79
84
  end
80
85
 
81
86
  desc 'list', 'List the names of the defined appraisals'
82
87
  def list
83
- File.new.appraisals.each { |appraisal| puts appraisal.name }
88
+ AppraisalFile.new.appraisals.each { |appraisal| puts appraisal.name }
84
89
  end
85
90
 
86
91
  desc "version", "Display the version and exit"
@@ -91,12 +96,14 @@ module Appraisal
91
96
  private
92
97
 
93
98
  def method_missing(name, *args, &block)
94
- matching_appraisal = File.new.appraisals.detect { |appraisal| appraisal.name == name.to_s }
99
+ matching_appraisal = AppraisalFile.new.appraisals.detect do |appraisal|
100
+ appraisal.name == name.to_s
101
+ end
95
102
 
96
103
  if matching_appraisal
97
104
  Command.new(args, :gemfile => matching_appraisal.gemfile_path).run
98
105
  else
99
- File.each do |appraisal|
106
+ AppraisalFile.each do |appraisal|
100
107
  Command.new(ARGV, :gemfile => appraisal.gemfile_path).run
101
108
  end
102
109
  end
@@ -43,12 +43,15 @@ module Appraisal
43
43
  def ensure_bundler_is_available
44
44
  unless system %(gem list -q "^bundler$" | grep -q bundler)
45
45
  puts ">> Reinstall Bundler into #{ENV["GEM_HOME"]}"
46
+ version = Utils.bundler_version
46
47
 
47
- unless system "gem install bundler"
48
+ unless system "gem install bundler --version #{version}"
48
49
  puts
49
50
  puts <<-ERROR.strip.gsub(/\s+/, " ")
50
- Bundler installation failed. Please try running
51
- `GEM_HOME="#{ENV["GEM_HOME"]}" gem install bundler` manually.
51
+ Bundler installation failed.
52
+ Please try running:
53
+ `GEM_HOME="#{ENV["GEM_HOME"]}" gem install bundler --version #{version}`
54
+ manually.
52
55
  ERROR
53
56
  exit(1)
54
57
  end
@@ -2,16 +2,16 @@ require "appraisal/bundler_dsl"
2
2
 
3
3
  module Appraisal
4
4
  autoload :Gemspec, "appraisal/gemspec"
5
- autoload :GitSource, "appraisal/git_source"
5
+ autoload :Git, "appraisal/git"
6
6
  autoload :Group, "appraisal/group"
7
- autoload :PathSource, "appraisal/path_source"
7
+ autoload :Path, "appraisal/path"
8
8
  autoload :Platform, "appraisal/platform"
9
9
  autoload :Source, "appraisal/source"
10
10
 
11
11
  # Load bundler Gemfiles and merge dependencies
12
12
  class Gemfile < BundlerDSL
13
13
  def load(path)
14
- if ::File.exist?(path)
14
+ if File.exist?(path)
15
15
  run(IO.read(path))
16
16
  end
17
17
  end
@@ -22,6 +22,7 @@ module Appraisal
22
22
 
23
23
  def dup
24
24
  Gemfile.new.tap do |gemfile|
25
+ gemfile.git_sources = @git_sources
25
26
  gemfile.run(for_dup)
26
27
  end
27
28
  end
@@ -2,7 +2,7 @@ require "appraisal/bundler_dsl"
2
2
  require 'appraisal/utils'
3
3
 
4
4
  module Appraisal
5
- class GitSource < BundlerDSL
5
+ class Git < BundlerDSL
6
6
  def initialize(source, options = {})
7
7
  super()
8
8
  @source = source
@@ -2,7 +2,7 @@ require "appraisal/bundler_dsl"
2
2
  require 'appraisal/utils'
3
3
 
4
4
  module Appraisal
5
- class PathSource < BundlerDSL
5
+ class Path < BundlerDSL
6
6
  def initialize(source, options = {})
7
7
  super()
8
8
  @source = source
@@ -1,4 +1,4 @@
1
- require 'appraisal/file'
1
+ require 'appraisal/appraisal_file'
2
2
  require 'rake/tasklib'
3
3
 
4
4
  module Appraisal
@@ -29,7 +29,7 @@ module Appraisal
29
29
  end
30
30
 
31
31
  begin
32
- File.each do |appraisal|
32
+ AppraisalFile.each do |appraisal|
33
33
  desc "DEPRECATED: Run the given task for appraisal #{appraisal.name}"
34
34
  task appraisal.name do
35
35
  ARGV.shift
@@ -1,4 +1,4 @@
1
- require "appraisal/file"
1
+ require "appraisal/appraisal_file"
2
2
  require "yaml"
3
3
 
4
4
  module Appraisal
@@ -20,7 +20,7 @@ module Appraisal
20
20
  puts "# Put this in your .travis.yml"
21
21
  puts "#{GEMFILES_CONFIGURATION_KEY}:"
22
22
 
23
- File.each do |appraisal|
23
+ AppraisalFile.each do |appraisal|
24
24
  puts " - #{appraisal.relative_gemfile_path}"
25
25
  end
26
26
  end
@@ -45,7 +45,7 @@ module Appraisal
45
45
  private
46
46
 
47
47
  def has_configuration_file?
48
- ::File.exist?(CONFIGURATION_FILE)
48
+ File.exist?(CONFIGURATION_FILE)
49
49
  end
50
50
 
51
51
  def has_no_gemfiles_configuration?
@@ -55,7 +55,7 @@ module Appraisal
55
55
  def has_invalid_gemfiles_configuration?
56
56
  if configuration && configuration[GEMFILES_CONFIGURATION_KEY]
57
57
  appraisal_paths =
58
- File.new.appraisals.map(&:relative_gemfile_path).sort
58
+ AppraisalFile.new.appraisals.map(&:relative_gemfile_path).sort
59
59
  travis_gemfile_paths = configuration[GEMFILES_CONFIGURATION_KEY].sort
60
60
  appraisal_paths != travis_gemfile_paths
61
61
  end
@@ -9,7 +9,7 @@ module Appraisal
9
9
  case object
10
10
  when Hash
11
11
  items = object.map do |key, value|
12
- "#{format_string(key, true)} => #{format_string(value, true)}"
12
+ format_hash_value(key, value)
13
13
  end
14
14
 
15
15
  if enclosing_object
@@ -22,6 +22,17 @@ module Appraisal
22
22
  end
23
23
  end
24
24
 
25
+ def self.format_hash_value(key, value)
26
+ key = format_string(key, true)
27
+ value = format_string(value, true)
28
+
29
+ if RUBY_VERSION >= "1.9" && key.start_with?(":")
30
+ "#{key.sub(/^:/, "")}: #{value}"
31
+ else
32
+ "#{key} => #{value}"
33
+ end
34
+ end
35
+
25
36
  def self.format_arguments(arguments)
26
37
  unless arguments.empty?
27
38
  arguments.map { |object| format_string(object, false) }.join(', ')
@@ -35,10 +46,17 @@ module Appraisal
35
46
  def self.prefix_path(path)
36
47
  if path !~ /^(?:\/|\S:)/ && path !~ /^\S+:\/\// && path !~ /^\S+@\S+:/
37
48
  cleaned_path = path.gsub(/(^|\/)\.(?:\/|$)/, "\\1")
38
- ::File.join("..", cleaned_path)
49
+ File.join("..", cleaned_path)
39
50
  else
40
51
  path
41
52
  end
42
53
  end
54
+
55
+ def self.bundler_version
56
+ Gem::Specification.
57
+ detect { |spec| spec.name == "bundler" }.
58
+ version.
59
+ to_s
60
+ end
43
61
  end
44
62
  end
@@ -1,3 +1,3 @@
1
1
  module Appraisal
2
- VERSION = "2.1.0".freeze
2
+ VERSION = "2.2.0".freeze
3
3
  end
@@ -3,13 +3,15 @@ require 'spec_helper'
3
3
  describe 'Appraisals file Bundler DSL compatibility' do
4
4
  it 'supports all Bundler DSL in Appraisals file' do
5
5
  build_gems %w(bagel orange_juice milk waffle coffee ham sausage pancake)
6
- build_git_gem 'egg'
6
+ build_git_gems %w(egg croissant pain_au_chocolat)
7
7
 
8
8
  build_gemfile <<-Gemfile
9
9
  source 'https://rubygems.org'
10
+ git_source(:custom_git_source) { |repo| "../gems/\#{repo}" }
10
11
  ruby RUBY_VERSION
11
12
 
12
13
  gem 'bagel'
14
+ gem "croissant", :custom_git_source => "croissant"
13
15
 
14
16
  git '../gems/egg' do
15
17
  gem 'egg'
@@ -44,6 +46,7 @@ describe 'Appraisals file Bundler DSL compatibility' do
44
46
  ruby "1.8.7"
45
47
 
46
48
  gem 'bread'
49
+ gem "pain_au_chocolat", :custom_git_source => "pain_au_chocolat"
47
50
 
48
51
  git '../gems/egg' do
49
52
  gem 'porched_egg'
@@ -70,6 +73,7 @@ describe 'Appraisals file Bundler DSL compatibility' do
70
73
  end
71
74
 
72
75
  gemspec
76
+ gemspec :path => "sitepress"
73
77
  end
74
78
  Appraisals
75
79
 
@@ -95,8 +99,10 @@ describe 'Appraisals file Bundler DSL compatibility' do
95
99
  end
96
100
 
97
101
  gem "bagel"
102
+ gem "croissant", :git => "../../gems/croissant"
98
103
  gem "appraisal", :path => #{PROJECT_ROOT.inspect}
99
104
  gem "bread"
105
+ gem "pain_au_chocolat", :git => "../../gems/pain_au_chocolat"
100
106
 
101
107
  group :breakfast do
102
108
  gem "orange_juice"
@@ -122,6 +128,7 @@ describe 'Appraisals file Bundler DSL compatibility' do
122
128
  end
123
129
 
124
130
  gemspec :path => "../"
131
+ gemspec :path => "../sitepress"
125
132
  Gemfile
126
133
  end
127
134
  end
@@ -41,8 +41,9 @@ describe "Bundle with custom path" do
41
41
  gem 'appraisal', :path => #{PROJECT_ROOT.inspect}
42
42
 
43
43
  if RUBY_VERSION < "1.9"
44
- gem "i18n", "~> 0.6.0"
45
- gem "activesupport", "~> 3.2.21"
44
+ #{File.read(File.join(PROJECT_ROOT, "Gemfile-1.8"))}
45
+ elsif RUBY_VERSION < "2.2"
46
+ #{File.read(File.join(PROJECT_ROOT, "Gemfile-2.1"))}
46
47
  end
47
48
  Gemfile
48
49
 
@@ -0,0 +1,51 @@
1
+ require "spec_helper"
2
+
3
+ describe "Bundler without flag" do
4
+ it "passes --without flag to Bundler on install" do
5
+ build_gems %w(pancake orange_juice waffle coffee sausage soda)
6
+
7
+ build_gemfile <<-Gemfile
8
+ source "https://rubygems.org"
9
+
10
+ gem "pancake"
11
+ gem "rake", "~> 10.5", :platform => :ruby_18
12
+
13
+ group :drinks do
14
+ gem "orange_juice"
15
+ end
16
+
17
+ gem "appraisal", :path => #{PROJECT_ROOT.inspect}
18
+ Gemfile
19
+
20
+ build_appraisal_file <<-Appraisals
21
+ appraise "breakfast" do
22
+ gem "waffle"
23
+
24
+ group :drinks do
25
+ gem "coffee"
26
+ end
27
+ end
28
+
29
+ appraise "lunch" do
30
+ gem "sausage"
31
+
32
+ group :drinks do
33
+ gem "soda"
34
+ end
35
+ end
36
+ Appraisals
37
+
38
+ run "bundle install --local"
39
+ output = run "appraisal install --without drinks"
40
+
41
+ expect(output).to include("Bundle complete")
42
+ expect(output).to include("Gems in the group drinks were not installed.")
43
+ expect(output).not_to include("orange_juice")
44
+ expect(output).not_to include("coffee")
45
+ expect(output).not_to include("soda")
46
+
47
+ output = run "appraisal install"
48
+
49
+ expect(output).to include("The Gemfile's dependencies are satisfied")
50
+ end
51
+ end
@@ -25,8 +25,9 @@ describe 'CLI', 'appraisal update' do
25
25
 
26
26
  context 'with no arguments' do
27
27
  it 'updates all the gems' do
28
- run 'appraisal update'
28
+ output = run 'appraisal update'
29
29
 
30
+ expect(output).to include("gemfiles/dummy.gemfile bundle update")
30
31
  expect(content_of 'gemfiles/dummy.gemfile.lock').to include 'dummy (1.0.1)'
31
32
  expect(content_of 'gemfiles/dummy.gemfile.lock').to include 'dummy2 (1.0.1)'
32
33
  end
@@ -67,6 +67,7 @@ describe 'Gemspec' do
67
67
  s.name = 'gemspec_project'
68
68
  s.version = '0.1'
69
69
  s.summary = 'Awesome Gem!'
70
+ s.authors = "Appraisal"
70
71
 
71
72
  s.add_development_dependency('dummy', '1.1.0')
72
73
  end
@@ -1,14 +1,14 @@
1
1
  require 'spec_helper'
2
- require 'appraisal/file'
2
+ require 'appraisal/appraisal_file'
3
3
 
4
4
  # Requiring this to make the test pass on Rubinius 2.2.5
5
5
  # https://github.com/rubinius/rubinius/issues/2934
6
6
  require 'rspec/matchers/built_in/raise_error'
7
7
 
8
- describe Appraisal::File do
8
+ describe Appraisal::AppraisalFile do
9
9
  it "complains when no Appraisals file is found" do
10
- allow(::File).to receive(:exist?).with(/Gemfile/).and_return(true)
11
- allow(::File).to receive(:exist?).with("Appraisals").and_return(false)
10
+ allow(File).to receive(:exist?).with(/Gemfile/).and_return(true)
11
+ allow(File).to receive(:exist?).with("Appraisals").and_return(false)
12
12
  expect { described_class.new }.to raise_error(Appraisal::AppraisalsNotFound)
13
13
  end
14
14
  end
@@ -41,7 +41,7 @@ describe Appraisal::Appraisal do
41
41
  stub_const('Bundler::VERSION', '1.3.0')
42
42
 
43
43
  warning = capture(:stderr) do
44
- @appraisal.install(42)
44
+ @appraisal.install("jobs" => 42)
45
45
  end
46
46
 
47
47
  expect(Appraisal::Command).to have_received(:new).
@@ -52,12 +52,19 @@ describe Appraisal::Appraisal do
52
52
  it 'runs parallel install command on Bundler >= 1.4.0' do
53
53
  stub_const('Bundler::VERSION', '1.4.0')
54
54
 
55
- @appraisal.install(42)
55
+ @appraisal.install("jobs" => 42)
56
56
 
57
57
  expect(Appraisal::Command).to have_received(:new).
58
58
  with("#{bundle_check_command} || #{bundle_parallel_install_command}")
59
59
  end
60
60
 
61
+ it 'runs install command with retries on Bundler' do
62
+ @appraisal.install("retry" => 3)
63
+
64
+ expect(Appraisal::Command).to have_received(:new).
65
+ with("#{bundle_check_command} || #{bundle_install_command_with_retries}")
66
+ end
67
+
61
68
  def bundle_check_command
62
69
  "bundle check --gemfile='/home/test/test directory'"
63
70
  end
@@ -69,5 +76,9 @@ describe Appraisal::Appraisal do
69
76
  def bundle_parallel_install_command
70
77
  "bundle install --gemfile='/home/test/test directory' --jobs=42"
71
78
  end
79
+
80
+ def bundle_install_command_with_retries
81
+ "bundle install --gemfile='/home/test/test directory' --retry 3"
82
+ end
72
83
  end
73
84
  end
@@ -251,6 +251,8 @@ describe Appraisal::Gemfile do
251
251
  end
252
252
 
253
253
  context "relative path handling" do
254
+ before { stub_const('RUBY_VERSION', '1.8.7') }
255
+
254
256
  context "in :path option" do
255
257
  it "handles dot path" do
256
258
  gemfile = Appraisal::Gemfile.new
@@ -416,4 +418,16 @@ describe Appraisal::Gemfile do
416
418
  end
417
419
  end
418
420
  end
421
+
422
+ context "git_source support" do
423
+ before { stub_const('RUBY_VERSION', '1.8.7') }
424
+
425
+ it "stores git_source declaration and apply it as git option" do
426
+ gemfile = Appraisal::Gemfile.new
427
+ gemfile.git_source(:custom_source) { |repo| "path/#{repo}" }
428
+ gemfile.gem "bacon", :custom_source => "bacon_pancake"
429
+
430
+ expect(gemfile.to_s).to eq %(gem "bacon", :git => "../path/bacon_pancake")
431
+ end
432
+ end
419
433
  end
@@ -3,17 +3,30 @@ require 'appraisal/utils'
3
3
 
4
4
  describe Appraisal::Utils do
5
5
  describe '.format_string' do
6
- it 'prints out a nice looking hash without a brackets' do
7
- hash = { :foo => 'bar' }
8
- expect(Appraisal::Utils.format_string(hash)).to eq(':foo => "bar"')
6
+ if RUBY_VERSION > "1.9"
7
+ it "prints out a nice looking hash without brackets with new syntax" do
8
+ hash = { :foo => 'bar' }
9
+ expect(Appraisal::Utils.format_string(hash)).to eq('foo: "bar"')
9
10
 
10
- hash = { 'baz' => { :ball => 'boo' }}
11
- expect(Appraisal::Utils.format_string(hash)).
12
- to eq('"baz" => { :ball => "boo" }')
11
+ hash = { 'baz' => { :ball => 'boo' }}
12
+ expect(Appraisal::Utils.format_string(hash)).
13
+ to eq('"baz" => { ball: "boo" }')
14
+ end
15
+ else
16
+ it "prints out a nice looking hash without brackets with old syntax" do
17
+ hash = { :foo => 'bar' }
18
+ expect(Appraisal::Utils.format_string(hash)).to eq(':foo => "bar"')
19
+
20
+ hash = { 'baz' => { :ball => 'boo' }}
21
+ expect(Appraisal::Utils.format_string(hash)).
22
+ to eq('"baz" => { :ball => "boo" }')
23
+ end
13
24
  end
14
25
  end
15
26
 
16
27
  describe '.format_arguments' do
28
+ before { stub_const('RUBY_VERSION', '1.8.7') }
29
+
17
30
  it 'prints out arguments without enclosing square brackets' do
18
31
  arguments = [:foo, { :bar => { :baz => 'ball' }}]
19
32
 
@@ -58,4 +71,16 @@ describe Appraisal::Utils do
58
71
  ).to eq("https://github.com/bacon/bacon.git")
59
72
  end
60
73
  end
74
+
75
+ describe ".bundler_version" do
76
+ it "returns the bundler version" do
77
+ bundler = double("Bundler", :name => "bundler", :version => "a.b.c")
78
+ allow(Gem::Specification).to receive(:detect).and_return(bundler)
79
+
80
+ version = Appraisal::Utils.bundler_version
81
+
82
+ expect(version).to eq "a.b.c"
83
+ expect(Gem::Specification).to have_received(:detect)
84
+ end
85
+ end
61
86
  end
@@ -80,12 +80,17 @@ module AcceptanceTestHelpers
80
80
  s.name = 'stage'
81
81
  s.version = '0.1'
82
82
  s.summary = 'Awesome Gem!'
83
+ s.authors = "Appraisal"
83
84
  end
84
85
  gemspec
85
86
  end
86
87
 
87
88
  def content_of(path)
88
- file(path).read
89
+ file(path).read.tap do |content|
90
+ if RUBY_VERSION >= "1.9"
91
+ content.gsub!(/(\S+): /, ":\\1 => ")
92
+ end
93
+ end
89
94
  end
90
95
 
91
96
  def file(path)
@@ -125,8 +130,9 @@ module AcceptanceTestHelpers
125
130
  Reinstall Bundler to #{TMP_GEM_ROOT} as `BUNDLE_DISABLE_SHARED_GEMS`
126
131
  is enabled.
127
132
  WARNING
133
+ version = Utils.bundler_version
128
134
 
129
- run "gem install bundler --install-dir '#{TMP_GEM_ROOT}'"
135
+ run "gem install bundler --version #{version} --install-dir '#{TMP_GEM_ROOT}'"
130
136
  end
131
137
  end
132
138
 
@@ -137,8 +143,9 @@ module AcceptanceTestHelpers
137
143
  gem 'appraisal', :path => '#{PROJECT_ROOT}'
138
144
 
139
145
  if RUBY_VERSION < "1.9"
140
- gem "i18n", "~> 0.6.0"
141
- gem "activesupport", "~> 3.2.21"
146
+ #{File.read(File.join(PROJECT_ROOT, "Gemfile-1.8"))}
147
+ elsif RUBY_VERSION < "2.2"
148
+ #{File.read(File.join(PROJECT_ROOT, "Gemfile-2.1"))}
142
149
  end
143
150
  Gemfile
144
151
 
@@ -53,4 +53,8 @@ module DependencyHelpers
53
53
  FileUtils.rm_r(path)
54
54
  end
55
55
  end
56
+
57
+ def build_git_gems(gems)
58
+ gems.each { |gem| build_git_gem(gem) }
59
+ end
56
60
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appraisal
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Ferris
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-08-13 00:00:00.000000000 Z
12
+ date: 2017-04-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -96,6 +96,8 @@ files:
96
96
  - ".travis.yml"
97
97
  - CONTRIBUTING.md
98
98
  - Gemfile
99
+ - Gemfile-1.8
100
+ - Gemfile-2.1
99
101
  - MIT-LICENSE
100
102
  - README.md
101
103
  - Rakefile
@@ -103,19 +105,19 @@ files:
103
105
  - bin/appraisal
104
106
  - lib/appraisal.rb
105
107
  - lib/appraisal/appraisal.rb
108
+ - lib/appraisal/appraisal_file.rb
106
109
  - lib/appraisal/bundler_dsl.rb
107
110
  - lib/appraisal/cli.rb
108
111
  - lib/appraisal/command.rb
109
112
  - lib/appraisal/dependency.rb
110
113
  - lib/appraisal/dependency_list.rb
111
114
  - lib/appraisal/errors.rb
112
- - lib/appraisal/file.rb
113
115
  - lib/appraisal/gemfile.rb
114
116
  - lib/appraisal/gemspec.rb
115
- - lib/appraisal/git_source.rb
117
+ - lib/appraisal/git.rb
116
118
  - lib/appraisal/group.rb
117
119
  - lib/appraisal/ordered_hash.rb
118
- - lib/appraisal/path_source.rb
120
+ - lib/appraisal/path.rb
119
121
  - lib/appraisal/platform.rb
120
122
  - lib/appraisal/source.rb
121
123
  - lib/appraisal/task.rb
@@ -124,6 +126,7 @@ files:
124
126
  - lib/appraisal/version.rb
125
127
  - spec/acceptance/appraisals_file_bundler_dsl_compatibility_spec.rb
126
128
  - spec/acceptance/bundle_with_custom_path_spec.rb
129
+ - spec/acceptance/bundle_without_spec.rb
127
130
  - spec/acceptance/cli/clean_spec.rb
128
131
  - spec/acceptance/cli/generate_spec.rb
129
132
  - spec/acceptance/cli/help_spec.rb
@@ -136,9 +139,9 @@ files:
136
139
  - spec/acceptance/gemfile_dsl_compatibility_spec.rb
137
140
  - spec/acceptance/gemspec_spec.rb
138
141
  - spec/acceptance/travis_ci_integration_spec.rb
142
+ - spec/appraisal/appraisal_file_spec.rb
139
143
  - spec/appraisal/appraisal_spec.rb
140
144
  - spec/appraisal/dependency_list_spec.rb
141
- - spec/appraisal/file_spec.rb
142
145
  - spec/appraisal/gemfile_spec.rb
143
146
  - spec/appraisal/utils_spec.rb
144
147
  - spec/spec_helper.rb
@@ -165,13 +168,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
168
  version: '0'
166
169
  requirements: []
167
170
  rubyforge_project:
168
- rubygems_version: 2.4.8
171
+ rubygems_version: 2.6.8
169
172
  signing_key:
170
173
  specification_version: 4
171
174
  summary: Find out what your Ruby gems are worth
172
175
  test_files:
173
176
  - spec/acceptance/appraisals_file_bundler_dsl_compatibility_spec.rb
174
177
  - spec/acceptance/bundle_with_custom_path_spec.rb
178
+ - spec/acceptance/bundle_without_spec.rb
175
179
  - spec/acceptance/cli/clean_spec.rb
176
180
  - spec/acceptance/cli/generate_spec.rb
177
181
  - spec/acceptance/cli/help_spec.rb
@@ -184,9 +188,9 @@ test_files:
184
188
  - spec/acceptance/gemfile_dsl_compatibility_spec.rb
185
189
  - spec/acceptance/gemspec_spec.rb
186
190
  - spec/acceptance/travis_ci_integration_spec.rb
191
+ - spec/appraisal/appraisal_file_spec.rb
187
192
  - spec/appraisal/appraisal_spec.rb
188
193
  - spec/appraisal/dependency_list_spec.rb
189
- - spec/appraisal/file_spec.rb
190
194
  - spec/appraisal/gemfile_spec.rb
191
195
  - spec/appraisal/utils_spec.rb
192
196
  - spec/spec_helper.rb