appraisal 1.0.3 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CONTRIBUTING.md +6 -2
- data/Gemfile +5 -0
- data/README.md +5 -0
- data/appraisal.gemspec +1 -1
- data/lib/appraisal/appraisal.rb +10 -2
- data/lib/appraisal/bundler_dsl.rb +124 -0
- data/lib/appraisal/cli.rb +21 -2
- data/lib/appraisal/command.rb +22 -6
- data/lib/appraisal/dependency_list.rb +2 -1
- data/lib/appraisal/gemfile.rb +9 -126
- data/lib/appraisal/gemspec.rb +1 -1
- data/lib/appraisal/git_source.rb +7 -19
- data/lib/appraisal/group.rb +5 -46
- data/lib/appraisal/path_source.rb +7 -19
- data/lib/appraisal/platform.rb +16 -14
- data/lib/appraisal/travis_ci_helper.rb +65 -0
- data/lib/appraisal/version.rb +1 -1
- data/spec/acceptance/appraisals_file_bundler_dsl_compatibility_spec.rb +18 -2
- data/spec/acceptance/bundle_with_custom_path_spec.rb +22 -0
- data/spec/acceptance/cli/generate_spec.rb +6 -0
- data/spec/acceptance/cli/install_spec.rb +1 -1
- data/spec/acceptance/cli/list_spec.rb +28 -0
- data/spec/acceptance/cli/version_spec.rb +27 -0
- data/spec/acceptance/gemfile_dsl_compatibility_spec.rb +3 -3
- data/spec/acceptance/gemspec_spec.rb +3 -3
- data/spec/acceptance/travis_ci_integration_spec.rb +94 -0
- data/spec/appraisal/gemfile_spec.rb +147 -16
- data/spec/appraisal/utils_spec.rb +6 -5
- data/spec/spec_helper.rb +6 -2
- data/spec/support/acceptance_test_helpers.rb +24 -18
- data/spec/support/dependency_helpers.rb +7 -0
- metadata +15 -7
- data/features/support/dependency_helpers.rb +0 -35
data/lib/appraisal/gemspec.rb
CHANGED
data/lib/appraisal/git_source.rb
CHANGED
@@ -1,42 +1,30 @@
|
|
1
|
-
require
|
1
|
+
require "appraisal/bundler_dsl"
|
2
2
|
require 'appraisal/utils'
|
3
3
|
|
4
4
|
module Appraisal
|
5
|
-
class GitSource
|
5
|
+
class GitSource < BundlerDSL
|
6
6
|
def initialize(source, options = {})
|
7
|
-
|
7
|
+
super()
|
8
8
|
@source = source
|
9
9
|
@options = options
|
10
10
|
end
|
11
11
|
|
12
|
-
def gem(name, *requirements)
|
13
|
-
@dependencies.add(name, requirements)
|
14
|
-
end
|
15
|
-
|
16
|
-
def run(&block)
|
17
|
-
instance_exec(&block)
|
18
|
-
end
|
19
|
-
|
20
12
|
def to_s
|
21
|
-
dependencies = @dependencies.to_s.strip.gsub(/^/, ' ')
|
22
|
-
|
23
13
|
if @options.empty?
|
24
|
-
"git #{Utils.prefix_path(@source).inspect} do\n#{
|
14
|
+
"git #{Utils.prefix_path(@source).inspect} do\n#{indent(super)}\nend"
|
25
15
|
else
|
26
16
|
"git #{Utils.prefix_path(@source).inspect}, #{Utils.format_string(@options)} do\n" +
|
27
|
-
"#{
|
17
|
+
"#{indent(super)}\nend"
|
28
18
|
end
|
29
19
|
end
|
30
20
|
|
31
21
|
# :nodoc:
|
32
22
|
def for_dup
|
33
|
-
dependencies = @dependencies.for_dup.strip.gsub(/^/, ' ')
|
34
|
-
|
35
23
|
if @options.empty?
|
36
|
-
"git #{@source.inspect} do\n#{
|
24
|
+
"git #{@source.inspect} do\n#{indent(super)}\nend"
|
37
25
|
else
|
38
26
|
"git #{@source.inspect}, #{Utils.format_string(@options)} do\n" +
|
39
|
-
"#{
|
27
|
+
"#{indent(super)}\nend"
|
40
28
|
end
|
41
29
|
end
|
42
30
|
end
|
data/lib/appraisal/group.rb
CHANGED
@@ -1,51 +1,24 @@
|
|
1
|
-
require
|
1
|
+
require "appraisal/bundler_dsl"
|
2
2
|
require 'appraisal/utils'
|
3
3
|
|
4
4
|
module Appraisal
|
5
|
-
class Group
|
5
|
+
class Group < BundlerDSL
|
6
6
|
def initialize(group_names)
|
7
|
-
|
7
|
+
super()
|
8
8
|
@group_names = group_names
|
9
|
-
@gemspec = nil
|
10
|
-
end
|
11
|
-
|
12
|
-
def run(&block)
|
13
|
-
instance_exec(&block)
|
14
|
-
end
|
15
|
-
|
16
|
-
def gem(name, *requirements)
|
17
|
-
@dependencies.add(name, requirements)
|
18
|
-
end
|
19
|
-
|
20
|
-
def gemspec(options = {})
|
21
|
-
@gemspec = Gemspec.new(options)
|
22
9
|
end
|
23
10
|
|
24
11
|
def to_s
|
25
|
-
formatted_output
|
12
|
+
formatted_output indent(super)
|
26
13
|
end
|
27
14
|
|
28
15
|
# :nodoc:
|
29
16
|
def for_dup
|
30
|
-
formatted_output
|
17
|
+
formatted_output indent(super)
|
31
18
|
end
|
32
19
|
|
33
20
|
private
|
34
21
|
|
35
|
-
def dependencies_list
|
36
|
-
Utils.join_parts([
|
37
|
-
dependencies_entry,
|
38
|
-
gemspec_entry
|
39
|
-
]).gsub(/^/, " ")
|
40
|
-
end
|
41
|
-
|
42
|
-
def dependencies_list_for_dup
|
43
|
-
Utils.join_parts([
|
44
|
-
dependencies_entry,
|
45
|
-
gemspec_entry_for_dup
|
46
|
-
]).gsub(/^/, " ")
|
47
|
-
end
|
48
|
-
|
49
22
|
def formatted_output(output_dependencies)
|
50
23
|
<<-OUTPUT.strip
|
51
24
|
group #{Utils.format_arguments(@group_names)} do
|
@@ -53,19 +26,5 @@ group #{Utils.format_arguments(@group_names)} do
|
|
53
26
|
end
|
54
27
|
OUTPUT
|
55
28
|
end
|
56
|
-
|
57
|
-
def dependencies_entry
|
58
|
-
@dependencies.to_s
|
59
|
-
end
|
60
|
-
|
61
|
-
def gemspec_entry
|
62
|
-
@gemspec.to_s
|
63
|
-
end
|
64
|
-
|
65
|
-
def gemspec_entry_for_dup
|
66
|
-
if @gemspec
|
67
|
-
@gemspec.for_dup
|
68
|
-
end
|
69
|
-
end
|
70
29
|
end
|
71
30
|
end
|
@@ -1,42 +1,30 @@
|
|
1
|
-
require
|
1
|
+
require "appraisal/bundler_dsl"
|
2
2
|
require 'appraisal/utils'
|
3
3
|
|
4
4
|
module Appraisal
|
5
|
-
class PathSource
|
5
|
+
class PathSource < BundlerDSL
|
6
6
|
def initialize(source, options = {})
|
7
|
-
|
7
|
+
super()
|
8
8
|
@source = source
|
9
9
|
@options = options
|
10
10
|
end
|
11
11
|
|
12
|
-
def gem(name, *requirements)
|
13
|
-
@dependencies.add(name, requirements)
|
14
|
-
end
|
15
|
-
|
16
|
-
def run(&block)
|
17
|
-
instance_exec(&block)
|
18
|
-
end
|
19
|
-
|
20
12
|
def to_s
|
21
|
-
dependencies = @dependencies.to_s.strip.gsub(/^/, ' ')
|
22
|
-
|
23
13
|
if @options.empty?
|
24
|
-
"path #{Utils.prefix_path(@source).inspect} do\n#{
|
14
|
+
"path #{Utils.prefix_path(@source).inspect} do\n#{indent(super)}\nend"
|
25
15
|
else
|
26
16
|
"path #{Utils.prefix_path(@source).inspect}, #{Utils.format_string(@options)} do\n" +
|
27
|
-
"#{
|
17
|
+
"#{indent(super)}\nend"
|
28
18
|
end
|
29
19
|
end
|
30
20
|
|
31
21
|
# :nodoc:
|
32
22
|
def for_dup
|
33
|
-
dependencies = @dependencies.for_dup.strip.gsub(/^/, ' ')
|
34
|
-
|
35
23
|
if @options.empty?
|
36
|
-
"path #{@source.inspect} do\n#{
|
24
|
+
"path #{@source.inspect} do\n#{indent(super)}\nend"
|
37
25
|
else
|
38
26
|
"path #{@source.inspect}, #{Utils.format_string(@options)} do\n" +
|
39
|
-
"#{
|
27
|
+
"#{indent(super)}\nend"
|
40
28
|
end
|
41
29
|
end
|
42
30
|
end
|
data/lib/appraisal/platform.rb
CHANGED
@@ -1,28 +1,30 @@
|
|
1
|
-
require
|
1
|
+
require "appraisal/bundler_dsl"
|
2
2
|
require 'appraisal/utils'
|
3
3
|
|
4
4
|
module Appraisal
|
5
|
-
class Platform
|
5
|
+
class Platform < BundlerDSL
|
6
6
|
def initialize(platform_names)
|
7
|
-
|
7
|
+
super()
|
8
8
|
@platform_names = platform_names
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
12
|
-
|
11
|
+
def to_s
|
12
|
+
formatted_output indent(super)
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
|
-
|
15
|
+
# :nodoc:
|
16
|
+
def for_dup
|
17
|
+
formatted_output indent(super)
|
17
18
|
end
|
18
19
|
|
19
|
-
|
20
|
-
"platforms #{Utils.format_arguments(@platform_names)} do\n" +
|
21
|
-
@dependencies.to_s.strip.gsub(/^/, ' ') +
|
22
|
-
"\nend"
|
23
|
-
end
|
20
|
+
private
|
24
21
|
|
25
|
-
|
26
|
-
|
22
|
+
def formatted_output(output_dependencies)
|
23
|
+
<<-OUTPUT.strip
|
24
|
+
platforms #{Utils.format_arguments(@platform_names)} do
|
25
|
+
#{output_dependencies}
|
26
|
+
end
|
27
|
+
OUTPUT
|
28
|
+
end
|
27
29
|
end
|
28
30
|
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require "appraisal/file"
|
2
|
+
require "yaml"
|
3
|
+
|
4
|
+
module Appraisal
|
5
|
+
class TravisCIHelper
|
6
|
+
NO_CONFIGURATION_WARNING = <<-WARNING.strip
|
7
|
+
Note: Run with --travis to generate Travis CI configuration.
|
8
|
+
WARNING
|
9
|
+
|
10
|
+
INVALID_CONFIGURATION_WARNING = <<-WARNING.strip.gsub(/\s+/, " ")
|
11
|
+
Warning: Your gemfiles directive in .travis.yml is incorrect. Run
|
12
|
+
`appraisal generate --travis` to get the correct configuration.
|
13
|
+
WARNING
|
14
|
+
|
15
|
+
def self.display_instruction
|
16
|
+
puts "# Put this in your .travis.yml"
|
17
|
+
puts "gemfiles:"
|
18
|
+
|
19
|
+
File.each do |appraisal|
|
20
|
+
puts " - #{appraisal.relative_gemfile_path}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.validate_configuration_file
|
25
|
+
ConfigurationValidator.new.validate
|
26
|
+
end
|
27
|
+
|
28
|
+
class ConfigurationValidator
|
29
|
+
CONFIGURATION_FILE = ".travis.yml"
|
30
|
+
|
31
|
+
def validate
|
32
|
+
if has_configuration_file?
|
33
|
+
if has_no_gemfiles_configuration?
|
34
|
+
$stderr.puts(NO_CONFIGURATION_WARNING)
|
35
|
+
elsif has_invalid_gemfiles_configuration?
|
36
|
+
$stderr.puts(INVALID_CONFIGURATION_WARNING)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def has_configuration_file?
|
44
|
+
::File.exist?(CONFIGURATION_FILE)
|
45
|
+
end
|
46
|
+
|
47
|
+
def has_no_gemfiles_configuration?
|
48
|
+
!(configuration && configuration.has_key?("gemfiles"))
|
49
|
+
end
|
50
|
+
|
51
|
+
def has_invalid_gemfiles_configuration?
|
52
|
+
if configuration && configuration["gemfiles"]
|
53
|
+
appraisal_paths =
|
54
|
+
File.new.appraisals.map(&:relative_gemfile_path).sort
|
55
|
+
travis_gemfile_paths = configuration["gemfiles"].sort
|
56
|
+
appraisal_paths != travis_gemfile_paths
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def configuration
|
61
|
+
YAML.load_file(CONFIGURATION_FILE) rescue nil
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
data/lib/appraisal/version.rb
CHANGED
@@ -2,7 +2,7 @@ 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)
|
5
|
+
build_gems %w(bagel orange_juice milk waffle coffee ham)
|
6
6
|
build_git_gem 'egg'
|
7
7
|
|
8
8
|
build_gemfile <<-Gemfile
|
@@ -25,9 +25,13 @@ describe 'Appraisals file Bundler DSL compatibility' do
|
|
25
25
|
|
26
26
|
platforms :ruby, :jruby do
|
27
27
|
gem 'milk'
|
28
|
+
|
29
|
+
group :lunch do
|
30
|
+
gem "coffee"
|
31
|
+
end
|
28
32
|
end
|
29
33
|
|
30
|
-
gem 'appraisal', path
|
34
|
+
gem 'appraisal', :path => #{PROJECT_ROOT.inspect}
|
31
35
|
Gemfile
|
32
36
|
|
33
37
|
build_appraisal_file <<-Appraisals
|
@@ -47,6 +51,10 @@ describe 'Appraisals file Bundler DSL compatibility' do
|
|
47
51
|
|
48
52
|
group :breakfast do
|
49
53
|
gem 'bacon'
|
54
|
+
|
55
|
+
platforms :rbx do
|
56
|
+
gem "ham"
|
57
|
+
end
|
50
58
|
end
|
51
59
|
|
52
60
|
platforms :ruby, :jruby do
|
@@ -85,11 +93,19 @@ describe 'Appraisals file Bundler DSL compatibility' do
|
|
85
93
|
group :breakfast do
|
86
94
|
gem "orange_juice"
|
87
95
|
gem "bacon"
|
96
|
+
|
97
|
+
platforms :rbx do
|
98
|
+
gem "ham"
|
99
|
+
end
|
88
100
|
end
|
89
101
|
|
90
102
|
platforms :ruby, :jruby do
|
91
103
|
gem "milk"
|
92
104
|
gem "yoghurt"
|
105
|
+
|
106
|
+
group :lunch do
|
107
|
+
gem "coffee"
|
108
|
+
end
|
93
109
|
end
|
94
110
|
|
95
111
|
gemspec :path => "../"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "Bundle with custom path" do
|
4
|
+
it "supports --path option" do
|
5
|
+
build_gemfile <<-Gemfile
|
6
|
+
source "https://rubygems.org"
|
7
|
+
|
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
|
+
end
|
@@ -2,6 +2,12 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe 'CLI', 'appraisal generate' do
|
4
4
|
it 'generates the gemfiles' do
|
5
|
+
build_gemfile <<-Gemfile
|
6
|
+
source "https://rubygems.org"
|
7
|
+
|
8
|
+
gem "appraisal", :path => "#{PROJECT_ROOT}"
|
9
|
+
Gemfile
|
10
|
+
|
5
11
|
build_appraisal_file <<-Appraisal
|
6
12
|
appraise '1.0.0' do
|
7
13
|
gem 'dummy', '1.0.0'
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'CLI', 'appraisal list' do
|
4
|
+
it 'prints list of appraisals' do
|
5
|
+
build_appraisal_file <<-Appraisal
|
6
|
+
appraise '1.0.0' do
|
7
|
+
gem 'dummy', '1.0.0'
|
8
|
+
end
|
9
|
+
appraise '2.0.0' do
|
10
|
+
gem 'dummy', '1.0.0'
|
11
|
+
end
|
12
|
+
appraise '1.1.0' do
|
13
|
+
gem 'dummy', '1.0.0'
|
14
|
+
end
|
15
|
+
Appraisal
|
16
|
+
|
17
|
+
output = run 'appraisal list'
|
18
|
+
|
19
|
+
expect(output).to eq("1.0.0\n2.0.0\n1.1.0\n")
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'prints nothing if there are no appraisals in the file' do
|
23
|
+
build_appraisal_file ''
|
24
|
+
output = run 'appraisal list'
|
25
|
+
|
26
|
+
expect(output.length).to eq(0)
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "CLI", "appraisal version" do
|
4
|
+
context "with version subcommand" do
|
5
|
+
it "prints out version string" do
|
6
|
+
output = run "appraisal version"
|
7
|
+
|
8
|
+
expect(output).to include("Appraisal #{Appraisal::VERSION}")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
context "with -v flag" do
|
13
|
+
it "prints out version string" do
|
14
|
+
output = run "appraisal -v"
|
15
|
+
|
16
|
+
expect(output).to include("Appraisal #{Appraisal::VERSION}")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context "with --version flag" do
|
21
|
+
it "prints out version string" do
|
22
|
+
output = run "appraisal --version"
|
23
|
+
|
24
|
+
expect(output).to include("Appraisal #{Appraisal::VERSION}")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|