appraisal 2.1.0 → 2.4.1

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.
data/lib/appraisal/cli.rb CHANGED
@@ -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,23 @@ 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."
49
+ method_option "full-index", :type => :boolean,
50
+ :desc => "Run bundle install with the " \
51
+ "full-index argument."
52
+ method_option "path", type: :string,
53
+ desc: "Install gems in the specified directory. " \
54
+ "Bundler will remember this option."
55
+
44
56
  def install
45
57
  invoke :generate, [], {}
46
58
 
47
- File.each do |appraisal|
48
- appraisal.install(options[:jobs])
59
+ AppraisalFile.each do |appraisal|
60
+ appraisal.install(options)
49
61
  appraisal.relativize
50
62
  end
51
63
  end
@@ -53,7 +65,7 @@ module Appraisal
53
65
  desc 'generate', 'Generate a gemfile for each appraisal'
54
66
  method_option "travis", :type => :boolean, :default => false
55
67
  def generate
56
- File.each do |appraisal|
68
+ AppraisalFile.each do |appraisal|
57
69
  appraisal.write_gemfile
58
70
  end
59
71
 
@@ -73,14 +85,14 @@ module Appraisal
73
85
  def update(*gems)
74
86
  invoke :generate, []
75
87
 
76
- File.each do |appraisal|
88
+ AppraisalFile.each do |appraisal|
77
89
  appraisal.update(gems)
78
90
  end
79
91
  end
80
92
 
81
93
  desc 'list', 'List the names of the defined appraisals'
82
94
  def list
83
- File.new.appraisals.each { |appraisal| puts appraisal.name }
95
+ AppraisalFile.new.appraisals.each { |appraisal| puts appraisal.name }
84
96
  end
85
97
 
86
98
  desc "version", "Display the version and exit"
@@ -91,12 +103,14 @@ module Appraisal
91
103
  private
92
104
 
93
105
  def method_missing(name, *args, &block)
94
- matching_appraisal = File.new.appraisals.detect { |appraisal| appraisal.name == name.to_s }
106
+ matching_appraisal = AppraisalFile.new.appraisals.detect do |appraisal|
107
+ appraisal.name == name.to_s
108
+ end
95
109
 
96
110
  if matching_appraisal
97
111
  Command.new(args, :gemfile => matching_appraisal.gemfile_path).run
98
112
  else
99
- File.each do |appraisal|
113
+ AppraisalFile.each do |appraisal|
100
114
  Command.new(ARGV, :gemfile => appraisal.gemfile_path).run
101
115
  end
102
116
  end
@@ -41,14 +41,17 @@ module Appraisal
41
41
  end
42
42
 
43
43
  def ensure_bundler_is_available
44
- unless system %(gem list -q "^bundler$" | grep -q bundler)
44
+ version = Utils.bundler_version
45
+ unless system %(gem list --silent -i bundler -v #{version})
45
46
  puts ">> Reinstall Bundler into #{ENV["GEM_HOME"]}"
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
@@ -1,14 +1,23 @@
1
1
  require 'appraisal/dependency'
2
- require 'appraisal/ordered_hash'
2
+ require "set"
3
3
 
4
4
  module Appraisal
5
5
  class DependencyList
6
6
  def initialize
7
- @dependencies = OrderedHash.new
7
+ @dependencies = Hash.new
8
+ @removed_dependencies = Set.new
8
9
  end
9
10
 
10
11
  def add(name, requirements)
11
- @dependencies[name] = Dependency.new(name, requirements)
12
+ unless @removed_dependencies.include?(name)
13
+ @dependencies[name] = Dependency.new(name, requirements)
14
+ end
15
+ end
16
+
17
+ def remove(name)
18
+ if @removed_dependencies.add?(name)
19
+ @dependencies.delete(name)
20
+ end
12
21
  end
13
22
 
14
23
  def to_s
@@ -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 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.4.1".freeze
3
3
  end
@@ -2,14 +2,17 @@ require 'spec_helper'
2
2
 
3
3
  describe 'Appraisals file Bundler DSL compatibility' do
4
4
  it 'supports all Bundler DSL in Appraisals file' do
5
- build_gems %w(bagel orange_juice milk waffle coffee ham sausage pancake)
6
- build_git_gem 'egg'
5
+ build_gems %w(bagel orange_juice milk waffle coffee ham
6
+ sausage pancake rotten_egg)
7
+ build_git_gems %w(egg croissant pain_au_chocolat omelette)
7
8
 
8
9
  build_gemfile <<-Gemfile
9
10
  source 'https://rubygems.org'
11
+ git_source(:custom_git_source) { |repo| "../gems/\#{repo}" }
10
12
  ruby RUBY_VERSION
11
13
 
12
14
  gem 'bagel'
15
+ gem "croissant", :custom_git_source => "croissant"
13
16
 
14
17
  git '../gems/egg' do
15
18
  gem 'egg'
@@ -21,6 +24,8 @@ describe 'Appraisals file Bundler DSL compatibility' do
21
24
 
22
25
  group :breakfast do
23
26
  gem 'orange_juice'
27
+ gem "omelette", :custom_git_source => "omelette"
28
+ gem 'rotten_egg'
24
29
  end
25
30
 
26
31
  platforms :ruby, :jruby do
@@ -41,9 +46,10 @@ describe 'Appraisals file Bundler DSL compatibility' do
41
46
  build_appraisal_file <<-Appraisals
42
47
  appraise 'breakfast' do
43
48
  source 'http://some-other-source.com'
44
- ruby "1.8.7"
49
+ ruby "2.3.0"
45
50
 
46
51
  gem 'bread'
52
+ gem "pain_au_chocolat", :custom_git_source => "pain_au_chocolat"
47
53
 
48
54
  git '../gems/egg' do
49
55
  gem 'porched_egg'
@@ -54,6 +60,7 @@ describe 'Appraisals file Bundler DSL compatibility' do
54
60
  end
55
61
 
56
62
  group :breakfast do
63
+ remove_gem 'rotten_egg'
57
64
  gem 'bacon'
58
65
 
59
66
  platforms :rbx do
@@ -70,6 +77,7 @@ describe 'Appraisals file Bundler DSL compatibility' do
70
77
  end
71
78
 
72
79
  gemspec
80
+ gemspec :path => "sitepress"
73
81
  end
74
82
  Appraisals
75
83
 
@@ -82,7 +90,7 @@ describe 'Appraisals file Bundler DSL compatibility' do
82
90
  source "https://rubygems.org"
83
91
  source "http://some-other-source.com"
84
92
 
85
- ruby "1.8.7"
93
+ ruby "2.3.0"
86
94
 
87
95
  git "../../gems/egg" do
88
96
  gem "egg"
@@ -95,11 +103,14 @@ describe 'Appraisals file Bundler DSL compatibility' do
95
103
  end
96
104
 
97
105
  gem "bagel"
106
+ gem "croissant", :git => "../../gems/croissant"
98
107
  gem "appraisal", :path => #{PROJECT_ROOT.inspect}
99
108
  gem "bread"
109
+ gem "pain_au_chocolat", :git => "../../gems/pain_au_chocolat"
100
110
 
101
111
  group :breakfast do
102
112
  gem "orange_juice"
113
+ gem "omelette", :git => "../../gems/omelette"
103
114
  gem "bacon"
104
115
 
105
116
  platforms :rbx do
@@ -122,6 +133,7 @@ describe 'Appraisals file Bundler DSL compatibility' do
122
133
  end
123
134
 
124
135
  gemspec :path => "../"
136
+ gemspec :path => "../sitepress"
125
137
  Gemfile
126
138
  end
127
139
  end
@@ -1,49 +1,16 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe "Bundle with custom path" do
4
- it "supports --path option" do
5
- build_gemfile <<-Gemfile
6
- source "https://rubygems.org"
4
+ let(:gem_name) { 'rack' }
5
+ let(:path) { 'vendor/bundle' }
7
6
 
8
- gem 'appraisal', :path => #{PROJECT_ROOT.inspect}
9
- Gemfile
10
-
11
- build_appraisal_file <<-Appraisals
12
- appraise "breakfast" do
13
- end
14
- Appraisals
15
-
16
- run %(bundle install --path="vendor/bundle")
17
- output = run "appraisal install"
18
-
19
- expect(file "gemfiles/breakfast.gemfile").to be_exists
20
- expect(output).to include("Successfully installed bundler")
21
- end
22
-
23
- context 'when already installed in vendor/another' do
24
- let(:gem_name) { 'rack' }
25
- let(:path) { 'vendor/bundle' }
26
-
27
- before do
28
- build_gemfile <<-Gemfile
29
- source "https://rubygems.org"
30
-
31
- gem '#{gem_name}'
32
- Gemfile
33
-
34
- run 'bundle install --path vendor/another'
35
- end
7
+ shared_examples :gemfile_dependencies_are_satisfied do
36
8
 
37
9
  it 'installs gems in the --path directory' do
38
10
  build_gemfile <<-Gemfile
39
11
  source "https://rubygems.org"
40
12
 
41
13
  gem 'appraisal', :path => #{PROJECT_ROOT.inspect}
42
-
43
- if RUBY_VERSION < "1.9"
44
- gem "i18n", "~> 0.6.0"
45
- gem "activesupport", "~> 3.2.21"
46
- end
47
14
  Gemfile
48
15
 
49
16
  build_appraisal_file <<-Appraisals
@@ -55,7 +22,7 @@ describe "Bundle with custom path" do
55
22
  run %(bundle install --path="#{path}")
56
23
  run 'bundle exec appraisal install'
57
24
 
58
- installed_gem = Dir.glob("tmp/stage/#{path}/ruby/*/gems/*").
25
+ installed_gem = Dir.glob("tmp/stage/#{path}/#{Gem.ruby_engine}/*/gems/*").
59
26
  map { |path| path.split('/').last }.
60
27
  select { |gem| gem.include?(gem_name) }
61
28
  expect(installed_gem).not_to be_empty
@@ -67,4 +34,20 @@ describe "Bundle with custom path" do
67
34
  expect(appraisal_output).to include("The Gemfile's dependencies are satisfied")
68
35
  end
69
36
  end
37
+
38
+ include_examples :gemfile_dependencies_are_satisfied
39
+
40
+ context 'when already installed in vendor/another' do
41
+ before do
42
+ build_gemfile <<-Gemfile
43
+ source "https://rubygems.org"
44
+
45
+ gem '#{gem_name}'
46
+ Gemfile
47
+
48
+ run 'bundle install --path vendor/another'
49
+ end
50
+
51
+ include_examples :gemfile_dependencies_are_satisfied
52
+ end
70
53
  end