appraisal 1.0.0.beta3 → 1.0.0

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 (41) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +2 -8
  3. data/appraisal.gemspec +0 -2
  4. data/bin/appraisal +6 -1
  5. data/features/support/dependency_helpers.rb +27 -21
  6. data/lib/appraisal/appraisal.rb +30 -2
  7. data/lib/appraisal/dependency.rb +3 -5
  8. data/lib/appraisal/dependency_list.rb +21 -0
  9. data/lib/appraisal/gemfile.rb +37 -27
  10. data/lib/appraisal/gemspec.rb +5 -4
  11. data/lib/appraisal/git_source.rb +12 -4
  12. data/lib/appraisal/group.rb +11 -4
  13. data/lib/appraisal/path_source.rb +31 -0
  14. data/lib/appraisal/platform.rb +12 -4
  15. data/lib/appraisal/task.rb +10 -7
  16. data/lib/appraisal/utils.rb +21 -0
  17. data/lib/appraisal/version.rb +1 -1
  18. data/spec/acceptance/appraisals_file_bundler_dsl_compatibility_spec.rb +98 -0
  19. data/spec/acceptance/cli/clean_spec.rb +20 -0
  20. data/spec/acceptance/cli/generate_spec.rb +28 -0
  21. data/spec/acceptance/cli/help_spec.rb +17 -0
  22. data/spec/acceptance/cli/install_spec.rb +70 -0
  23. data/spec/acceptance/cli/run_spec.rb +47 -0
  24. data/spec/acceptance/cli/update_spec.rb +43 -0
  25. data/spec/acceptance/cli/with_no_arguments_spec.rb +16 -0
  26. data/spec/acceptance/gemfile_dsl_compatibility_spec.rb +107 -0
  27. data/spec/acceptance/gemspec_spec.rb +75 -0
  28. data/spec/appraisal/gemspec_spec.rb +22 -0
  29. data/spec/appraisal/utils_spec.rb +24 -0
  30. data/spec/spec_helper.rb +0 -1
  31. data/spec/support/acceptance_test_helpers.rb +73 -35
  32. data/spec/support/dependency_helpers.rb +49 -0
  33. metadata +32 -48
  34. data/features/appraisals.feature +0 -105
  35. data/features/bundler_gemfile_compatibility.feature +0 -70
  36. data/features/gemspec.feature +0 -68
  37. data/features/missing_appraisals_file.feature +0 -23
  38. data/features/step_definitions/dependency_steps.rb +0 -24
  39. data/features/support/aruba.rb +0 -4
  40. data/features/support/env.rb +0 -11
  41. data/spec/acceptance/cli_spec.rb +0 -233
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dd2ee2315b61f0dcce2a6f62993c81cd9fc194ab
4
- data.tar.gz: 25e20815d7a45d0a0f9ad8ec59c738797a83ac32
3
+ metadata.gz: 7235cdefdbcdbd117d7af0c2d8cc5c32598afa9f
4
+ data.tar.gz: 61e43a15a3402034ab64749580abcfc06ff944f8
5
5
  SHA512:
6
- metadata.gz: ca6fcbf95100f06416300d0490720f1a9f41b7831601aebce780e340f108ce2f5f2f749b3fb61409894cc7f6e4790cac4ef2ac02e42e6c6cae92870768d48d6a
7
- data.tar.gz: 9870e80c7fd87d7ed89340015b8d986f4e760620e24bb13be9d8eb12aa2cd96363f3c5efd045e09c2281ff201c3c1fc594bf635da912241673468f25e27367ec
6
+ metadata.gz: cfddd86b51ffb0fae598dd4751466f7ccbb826020ffb818c471cc6b2bf67a1208e2c7c913baa64ddfffed51fe7a5f3b85702e5f1f860b747c20a2853bf287ff5
7
+ data.tar.gz: c04030efcbe4c934206002e43552af9c28d7449324a6c53b7fb5d1e9b66105a4bac9c2faf51de7644447fd5c09bd013ce3af2593d25e3344345e8b4e805e7ab1
data/Rakefile CHANGED
@@ -1,7 +1,6 @@
1
1
  require 'bundler/setup'
2
2
  require 'bundler/gem_tasks'
3
3
  require 'rspec/core/rake_task'
4
- require 'cucumber/rake/task'
5
4
 
6
5
  RSpec::Core::RakeTask.new do |t|
7
6
  t.pattern = 'spec/**/*_spec.rb'
@@ -9,10 +8,5 @@ RSpec::Core::RakeTask.new do |t|
9
8
  t.verbose = false
10
9
  end
11
10
 
12
- Cucumber::Rake::Task.new(:cucumber) do |t|
13
- t.fork = true
14
- t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'progress')]
15
- end
16
-
17
- desc "Default: run the rspec examples and cucumber scenarios"
18
- task :default => [:spec, :cucumber]
11
+ desc 'Default: run the rspec examples'
12
+ task :default => [:spec]
@@ -23,7 +23,5 @@ Gem::Specification.new do |s|
23
23
  s.add_runtime_dependency('thor', '>= 0.14.0')
24
24
 
25
25
  s.add_development_dependency('activesupport', '>= 3.2.13')
26
- s.add_development_dependency('cucumber', '~> 1.0')
27
26
  s.add_development_dependency('rspec', '~> 2.6')
28
- s.add_development_dependency('aruba', '~> 0.5.1')
29
27
  end
@@ -4,4 +4,9 @@ require 'bundler/setup'
4
4
  require 'appraisal'
5
5
  require 'appraisal/cli'
6
6
 
7
- Appraisal::CLI.start
7
+ begin
8
+ Appraisal::CLI.start
9
+ rescue Appraisal::AppraisalsNotFound => e
10
+ puts e.message
11
+ exit 127
12
+ end
@@ -1,26 +1,32 @@
1
1
  module DependencyHelpers
2
- def build_gem(name, version)
3
- create_dir(name)
4
- cd(name)
5
- create_dir("lib")
6
- gem_path = "#{name}.gemspec"
7
- version_path = "lib/#{name}.rb"
8
- spec = <<-SPEC
9
- Gem::Specification.new do |s|
10
- s.name = '#{name}'
11
- s.version = '#{version}'
12
- s.authors = 'Mr. Smith'
13
- s.summary = 'summary'
14
- s.files = '#{version_path}'
2
+ def build_gem(gem_name, version)
3
+ FileUtils.mkdir_p "tmp/aruba/#{gem_name}/lib"
4
+
5
+ FileUtils.cd "tmp/aruba/#{gem_name}" do
6
+ gemspec = "#{gem_name}.gemspec"
7
+ lib_file = "lib/#{gem_name}.rb"
8
+
9
+ File.open gemspec, 'w' do |file|
10
+ file.puts <<-gemspec
11
+ Gem::Specification.new do |s|
12
+ s.name = #{gem_name.inspect}
13
+ s.version = #{version.inspect}
14
+ s.authors = 'Mr. Smith'
15
+ s.summary = 'summary'
16
+ s.files = #{lib_file.inspect}
17
+ end
18
+ gemspec
19
+ end
20
+
21
+ File.open lib_file, 'w' do |file|
22
+ file.puts "$#{gem_name}_version = '#{version}'"
15
23
  end
16
- SPEC
17
- write_file(gem_path, spec)
18
- write_file(version_path, "$#{name}_version = '#{version}'")
19
- in_current_dir { `gem build #{gem_path} 2>&1` }
20
- set_env("GEM_HOME", TMP_GEM_ROOT)
21
- in_current_dir { `gem install #{name}-#{version}.gem 2>&1` }
22
- FileUtils.rm_rf(File.join(current_dir, name))
23
- dirs.pop
24
+
25
+ `gem build #{gemspec} 2>&1`
26
+
27
+ ENV['GEM_HOME'] = TMP_GEM_ROOT
28
+ `gem install #{gem_name}-#{version}.gem 2>&1`
29
+ end
24
30
  end
25
31
  end
26
32
 
@@ -14,8 +14,36 @@ module Appraisal
14
14
  @gemfile = source_gemfile.dup
15
15
  end
16
16
 
17
- def gem(name, *requirements)
18
- gemfile.gem(name, *requirements)
17
+ def gem(*args)
18
+ gemfile.gem(*args)
19
+ end
20
+
21
+ def source(*args)
22
+ gemfile.source(*args)
23
+ end
24
+
25
+ def ruby(*args)
26
+ gemfile.ruby(*args)
27
+ end
28
+
29
+ def git(*args, &block)
30
+ gemfile.git(*args, &block)
31
+ end
32
+
33
+ def path(*args, &block)
34
+ gemfile.path(*args, &block)
35
+ end
36
+
37
+ def group(*args, &block)
38
+ gemfile.group(*args, &block)
39
+ end
40
+
41
+ def platforms(*args, &block)
42
+ gemfile.platforms(*args, &block)
43
+ end
44
+
45
+ def gemspec(options = {})
46
+ gemfile.gemspec(options)
19
47
  end
20
48
 
21
49
  def write_gemfile
@@ -1,3 +1,5 @@
1
+ require 'appraisal/utils'
2
+
1
3
  module Appraisal
2
4
  # Dependency on a gem and optional version requirements
3
5
  class Dependency
@@ -12,7 +14,7 @@ module Appraisal
12
14
  if no_requirements?
13
15
  gem_name
14
16
  else
15
- "#{gem_name}, #{inspect_requirements}"
17
+ "#{gem_name}, #{Utils.format_arguments(requirements)}"
16
18
  end
17
19
  end
18
20
 
@@ -25,9 +27,5 @@ module Appraisal
25
27
  def no_requirements?
26
28
  requirements.nil? || requirements.empty?
27
29
  end
28
-
29
- def inspect_requirements
30
- requirements.map { |requirement| requirement.inspect.gsub(/^\{|\}$/, '') }.join(", ")
31
- end
32
30
  end
33
31
  end
@@ -0,0 +1,21 @@
1
+ require 'appraisal/dependency'
2
+
3
+ module Appraisal
4
+ class DependencyList
5
+ def initialize
6
+ @dependency_names = []
7
+ @dependencies = []
8
+ end
9
+
10
+ def add(name, requirements)
11
+ unless @dependency_names.include?(name)
12
+ @dependency_names << name
13
+ @dependencies << Dependency.new(name, requirements)
14
+ end
15
+ end
16
+
17
+ def to_s
18
+ @dependencies.map(&:to_s).join("\n")
19
+ end
20
+ end
21
+ end
@@ -1,5 +1,9 @@
1
- require 'appraisal/dependency'
1
+ require 'appraisal/dependency_list'
2
2
  require 'appraisal/gemspec'
3
+ require 'appraisal/git_source'
4
+ require 'appraisal/path_source'
5
+ require 'appraisal/group'
6
+ require 'appraisal/platform'
3
7
 
4
8
  module Appraisal
5
9
  # Load bundler Gemfiles and merge dependencies
@@ -9,11 +13,12 @@ module Appraisal
9
13
  def initialize
10
14
  @sources = []
11
15
  @ruby_version = nil
12
- @dependencies = []
16
+ @dependencies = DependencyList.new
13
17
  @gemspec = nil
14
- @groups = []
15
- @platforms = []
16
- @git_sources = []
18
+ @groups = {}
19
+ @platforms = {}
20
+ @git_sources = {}
21
+ @path_sources = {}
17
22
  end
18
23
 
19
24
  def load(path)
@@ -25,26 +30,19 @@ module Appraisal
25
30
  end
26
31
 
27
32
  def gem(name, *requirements)
28
- @dependencies.reject! { |dependency| dependency.name == name }
29
- @dependencies << Dependency.new(name, requirements)
33
+ @dependencies.add(name, requirements)
30
34
  end
31
35
 
32
36
  def group(*names, &block)
33
- require 'appraisal/group'
34
-
35
- group = Group.new(names)
36
- group.run(&block)
37
- @groups << group
37
+ @groups[names] ||= Group.new(names)
38
+ @groups[names].run(&block)
38
39
  end
39
40
 
40
41
  alias_method :groups, :group
41
42
 
42
43
  def platforms(*names, &block)
43
- require 'appraisal/platform'
44
-
45
- platform = Platform.new(names)
46
- platform.run(&block)
47
- @platforms << platform
44
+ @platforms[names] ||= Platform.new(names)
45
+ @platforms[names].run(&block)
48
46
  end
49
47
 
50
48
  def source(source)
@@ -56,16 +54,24 @@ module Appraisal
56
54
  end
57
55
 
58
56
  def git(source, options = {}, &block)
59
- require 'appraisal/git_source'
57
+ @git_sources[source] ||= GitSource.new(source, options)
58
+ @git_sources[source].run(&block)
59
+ end
60
60
 
61
- git_source = GitSource.new(source, options)
62
- git_source.run(&block)
63
- @git_sources << git_source
61
+ def path(source, options = {}, &block)
62
+ @path_sources[source] ||= PathSource.new(source, options)
63
+ @path_sources[source].run(&block)
64
64
  end
65
65
 
66
66
  def to_s
67
- [source_entry, ruby_version_entry, git_sources_entry, dependencies_entry, groups_entry, platforms_entry,
68
- gemspec_entry].reject{ |s| s.nil? || s.empty? }.join("\n\n").strip
67
+ [source_entry,
68
+ ruby_version_entry,
69
+ git_sources_entry,
70
+ path_sources_entry,
71
+ dependencies_entry,
72
+ groups_entry,
73
+ platforms_entry,
74
+ gemspec_entry].reject{ |s| s.nil? || s.empty? }.join("\n\n").strip
69
75
  end
70
76
 
71
77
  def dup
@@ -91,19 +97,23 @@ module Appraisal
91
97
  end
92
98
 
93
99
  def git_sources_entry
94
- @git_sources.map(&:to_s).join("\n\n")
100
+ @git_sources.values.map(&:to_s).join("\n\n")
101
+ end
102
+
103
+ def path_sources_entry
104
+ @path_sources.values.map(&:to_s).join("\n\n")
95
105
  end
96
106
 
97
107
  def dependencies_entry
98
- dependencies.map(&:to_s).join("\n")
108
+ @dependencies.to_s
99
109
  end
100
110
 
101
111
  def groups_entry
102
- @groups.map(&:to_s).join("\n\n")
112
+ @groups.values.map(&:to_s).join("\n\n")
103
113
  end
104
114
 
105
115
  def platforms_entry
106
- @platforms.map(&:to_s).join("\n\n")
116
+ @platforms.values.map(&:to_s).join("\n\n")
107
117
  end
108
118
 
109
119
  def gemspec_entry
@@ -1,4 +1,4 @@
1
- require 'pathname'
1
+ require 'appraisal/utils'
2
2
 
3
3
  module Appraisal
4
4
  class Gemspec
@@ -10,18 +10,19 @@ module Appraisal
10
10
  end
11
11
 
12
12
  def to_s
13
- "gemspec #{exported_options.inspect.gsub(/^\{|\}$/, '')}"
13
+ "gemspec #{Utils.format_string(exported_options)}"
14
14
  end
15
15
 
16
16
  private
17
17
 
18
18
  def exported_options
19
19
  # Check to see if this is an absolute path
20
- if @options[:path] =~ /^(?:\/|\S:)/
20
+ if @options[:path] =~ /^(?:\/|\S:)/ || @options[:path] == '../'
21
21
  @options
22
22
  else
23
23
  # Remove leading ./ from path, if any
24
- exported_path = ::File.join("..", @options[:path].sub(/^\.\/?/,''))
24
+ cleaned_path = @options[:path].gsub(/(^|\/)\.\/?/, '\1')
25
+ exported_path = ::File.join("..", cleaned_path)
25
26
  @options.merge(:path => exported_path)
26
27
  end
27
28
  end
@@ -1,22 +1,30 @@
1
+ require 'appraisal/dependency_list'
2
+ require 'appraisal/utils'
3
+
1
4
  module Appraisal
2
- class GitSource < Gemfile
5
+ class GitSource
3
6
  def initialize(source, options = {})
4
- super()
7
+ @dependencies = DependencyList.new
5
8
  @source = source
6
9
  @options = options
7
10
  end
8
11
 
12
+ def gem(name, *requirements)
13
+ @dependencies.add(name, requirements)
14
+ end
15
+
9
16
  def run(&block)
10
17
  instance_exec(&block)
11
18
  end
12
19
 
13
20
  def to_s
14
- dependencies = super.strip.gsub(/^/, ' ')
21
+ dependencies = @dependencies.to_s.strip.gsub(/^/, ' ')
15
22
 
16
23
  if @options.empty?
17
24
  "git #{@source.inspect} do\n#{dependencies}\nend"
18
25
  else
19
- "git #{@source.inspect}, #{@options.inspect} do\n#{dependencies}\nend"
26
+ "git #{@source.inspect}, #{Utils.format_string(@options)} do\n" +
27
+ "#{dependencies}\nend"
20
28
  end
21
29
  end
22
30
  end
@@ -1,7 +1,10 @@
1
+ require 'appraisal/dependency_list'
2
+ require 'appraisal/utils'
3
+
1
4
  module Appraisal
2
- class Group < Gemfile
5
+ class Group
3
6
  def initialize(group_names)
4
- super()
7
+ @dependencies = DependencyList.new
5
8
  @group_names = group_names
6
9
  end
7
10
 
@@ -9,9 +12,13 @@ module Appraisal
9
12
  instance_exec(&block)
10
13
  end
11
14
 
15
+ def gem(name, *requirements)
16
+ @dependencies.add(name, requirements)
17
+ end
18
+
12
19
  def to_s
13
- "group #{@group_names.map(&:inspect).join(', ')} do\n" +
14
- super.strip.gsub(/^/, ' ') + "\nend"
20
+ "group #{Utils.format_arguments(@group_names)} do\n" +
21
+ @dependencies.to_s.strip.gsub(/^/, ' ') + "\nend"
15
22
  end
16
23
  end
17
24
  end
@@ -0,0 +1,31 @@
1
+ require 'appraisal/dependency_list'
2
+ require 'appraisal/utils'
3
+
4
+ module Appraisal
5
+ class PathSource
6
+ def initialize(source, options = {})
7
+ @dependencies = DependencyList.new
8
+ @source = source
9
+ @options = options
10
+ end
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
+ def to_s
21
+ dependencies = @dependencies.to_s.strip.gsub(/^/, ' ')
22
+
23
+ if @options.empty?
24
+ "path #{@source.inspect} do\n#{dependencies}\nend"
25
+ else
26
+ "path #{@source.inspect}, #{Utils.format_string(@options)} do\n" +
27
+ "#{dependencies}\nend"
28
+ end
29
+ end
30
+ end
31
+ end
@@ -1,17 +1,25 @@
1
+ require 'appraisal/dependency_list'
2
+ require 'appraisal/utils'
3
+
1
4
  module Appraisal
2
- class Platform < Gemfile
5
+ class Platform
3
6
  def initialize(platform_names)
4
- super()
7
+ @dependencies = DependencyList.new
5
8
  @platform_names = platform_names
6
9
  end
7
10
 
11
+ def gem(name, *requirements)
12
+ @dependencies.add(name, requirements)
13
+ end
14
+
8
15
  def run(&block)
9
16
  instance_exec(&block)
10
17
  end
11
18
 
12
19
  def to_s
13
- "platforms #{@platform_names.map(&:inspect).join(', ')} do\n" +
14
- super.strip.gsub(/^/, ' ') + "\nend"
20
+ "platforms #{Utils.format_arguments(@platform_names)} do\n" +
21
+ @dependencies.to_s.strip.gsub(/^/, ' ') +
22
+ "\nend"
15
23
  end
16
24
  end
17
25
  end