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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 902024f31f3dd843bcc2b0756bce28c81c93cc3e
4
- data.tar.gz: 0f3be37d8d7f30686971857371723cacd89dd1b0
3
+ metadata.gz: 0f0ed208de18ec1152d5f8d9d77e86a42236f89f
4
+ data.tar.gz: 5a0a145e1c89faeb6447aa5ca47b9662e69ed84c
5
5
  SHA512:
6
- metadata.gz: 084bc598430ce3fac142d1ce4f00e59f7d612e1be8da20a18c33d12d6ecb9caac991b88431e2975b38427e8a3162d7f6d1101ebcefd5572a4db4772a8e523e50
7
- data.tar.gz: 282c02041c422bb54cafadcc59a7315e4ee87392cccedb0c302f03ab197e08c1803ee0a9a92f98b2ef6330b312bfbcb5a411468f33a9f92fc0d2f89ed8d3e603
6
+ metadata.gz: 5c182a653a7e693cfcf9f288aa25a0f9c5ec312b89c7ea3741927eea0a4d4c7890230ef760313a3753bfee4cb9ddf3a5829f255f5a14393fd6013724e0bcf97f
7
+ data.tar.gz: 9bc7f08e8982c0234ddc3e098fe75ba530604eb2f79546032537db14faa74d2dc3aa71a17e5e15ced8059e39de17701bff90e6b66caa3c76422071d8b4a44f6b
@@ -3,6 +3,7 @@ sudo: false
3
3
  before_install: gem install bundler
4
4
 
5
5
  rvm:
6
+ - 1.8
6
7
  - 1.9
7
8
  - 2.0
8
9
  - 2.1
@@ -1,4 +1,9 @@
1
- We love pull requests. Here's a quick guide:
1
+ # Contributing
2
+
3
+ We love pull requests from everyone. By participating in this project, you agree
4
+ to abide by the thoughtbot [code of conduct].
5
+
6
+ [code of conduct]: https://thoughtbot.com/open-source-code-of-conduct
2
7
 
3
8
  1. Fork the repo.
4
9
 
@@ -13,7 +18,6 @@ a test!
13
18
 
14
19
  5. Push to your fork and submit a pull request.
15
20
 
16
-
17
21
  At this point you're waiting on us. We like to at least comment on, if not
18
22
  accept, pull requests within three business days (and, typically, one business
19
23
  day). We may suggest some changes or improvements or alternatives.
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
+ if RUBY_VERSION < "1.9"
9
+ gem "i18n", "~> 0.6.0"
10
+ gem "activesupport", "~> 3.2.21"
11
+ end
data/README.md CHANGED
@@ -139,6 +139,11 @@ all versions of its dependency, you might have to set a `script` setting:
139
139
  That will make sure that each of the test sub-job are not getting run more than
140
140
  one time.
141
141
 
142
+ You can also running your test against multiple versions of Ruby locally, just
143
+ like running on Travis CI, by using [WWTD].
144
+
145
+ [WWTD]: https://github.com/grosser/wwtd
146
+
142
147
  Credits
143
148
  -------
144
149
 
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
21
21
  s.add_runtime_dependency('rake')
22
22
  s.add_runtime_dependency('bundler')
23
23
  s.add_runtime_dependency('thor', '>= 0.14.0')
24
+ s.add_runtime_dependency("activesupport", ">= 3.2.21")
24
25
 
25
- s.add_development_dependency('activesupport', '>= 3.2.13')
26
26
  s.add_development_dependency('rspec', '~> 3.0')
27
27
  end
@@ -65,7 +65,7 @@ module Appraisal
65
65
 
66
66
  def update(gems = [])
67
67
  command, env = update_command(gems)
68
- Command.new(command, env: env).run
68
+ Command.new(command, :env => env).run
69
69
  end
70
70
 
71
71
  def gemfile_path
@@ -73,7 +73,11 @@ module Appraisal
73
73
  gemfile_root.mkdir
74
74
  end
75
75
 
76
- gemfile_root.join("#{clean_name}.gemfile").to_s
76
+ gemfile_root.join(gemfile_name).to_s
77
+ end
78
+
79
+ def relative_gemfile_path
80
+ ::File.join("gemfiles", gemfile_name)
77
81
  end
78
82
 
79
83
  def relativize
@@ -108,6 +112,10 @@ module Appraisal
108
112
  Pathname.new(::File.join(Dir.pwd, "gemfiles"))
109
113
  end
110
114
 
115
+ def gemfile_name
116
+ "#{clean_name}.gemfile"
117
+ end
118
+
111
119
  def lockfile_path
112
120
  "#{gemfile_path}.lock"
113
121
  end
@@ -0,0 +1,124 @@
1
+ require "appraisal/dependency_list"
2
+ require "active_support/ordered_hash"
3
+
4
+ module Appraisal
5
+ class BundlerDSL
6
+ attr_reader :dependencies
7
+
8
+ PARTS = %w(source ruby_version git_sources path_sources dependencies groups
9
+ platforms gemspec)
10
+
11
+ def initialize
12
+ @sources = []
13
+ @ruby_version = nil
14
+ @dependencies = DependencyList.new
15
+ @gemspec = nil
16
+ @groups = ActiveSupport::OrderedHash.new
17
+ @platforms = ActiveSupport::OrderedHash.new
18
+ @git_sources = ActiveSupport::OrderedHash.new
19
+ @path_sources = ActiveSupport::OrderedHash.new
20
+ end
21
+
22
+ def run(&block)
23
+ instance_exec(&block)
24
+ end
25
+
26
+ def gem(name, *requirements)
27
+ @dependencies.add(name, requirements)
28
+ end
29
+
30
+ def group(*names, &block)
31
+ @groups[names] ||= Group.new(names)
32
+ @groups[names].run(&block)
33
+ end
34
+
35
+ def platforms(*names, &block)
36
+ @platforms[names] ||= Platform.new(names)
37
+ @platforms[names].run(&block)
38
+ end
39
+
40
+ alias_method :platform, :platforms
41
+
42
+ def source(source)
43
+ @sources << source
44
+ end
45
+
46
+ def ruby(ruby_version)
47
+ @ruby_version = ruby_version
48
+ end
49
+
50
+ def git(source, options = {}, &block)
51
+ @git_sources[source] ||= GitSource.new(source, options)
52
+ @git_sources[source].run(&block)
53
+ end
54
+
55
+ def path(source, options = {}, &block)
56
+ @path_sources[source] ||= PathSource.new(source, options)
57
+ @path_sources[source].run(&block)
58
+ end
59
+
60
+ def to_s
61
+ Utils.join_parts PARTS.map { |part| send("#{part}_entry") }
62
+ end
63
+
64
+ def for_dup
65
+ Utils.join_parts PARTS.map { |part| send("#{part}_entry_for_dup") }
66
+ end
67
+
68
+ def gemspec(options = {})
69
+ @gemspec = Gemspec.new(options)
70
+ end
71
+
72
+ private
73
+
74
+ def source_entry
75
+ @sources.uniq.map { |source| "source #{source.inspect}" }.join("\n")
76
+ end
77
+
78
+ alias_method :source_entry_for_dup, :source_entry
79
+
80
+ def ruby_version_entry
81
+ if @ruby_version
82
+ "ruby #{@ruby_version.inspect}"
83
+ end
84
+ end
85
+
86
+ alias_method :ruby_version_entry_for_dup, :ruby_version_entry
87
+
88
+ [:dependencies, :gemspec].each do |method_name|
89
+ class_eval <<-METHODS, __FILE__, __LINE__
90
+ private
91
+
92
+ def #{method_name}_entry
93
+ if @#{method_name}
94
+ @#{method_name}.to_s
95
+ end
96
+ end
97
+
98
+ def #{method_name}_entry_for_dup
99
+ if @#{method_name}
100
+ @#{method_name}.for_dup
101
+ end
102
+ end
103
+ METHODS
104
+ end
105
+
106
+ [:git_sources, :path_sources, :platforms, :groups].each do |method_name|
107
+ class_eval <<-METHODS, __FILE__, __LINE__
108
+ private
109
+
110
+ def #{method_name}_entry
111
+ @#{method_name}.values.map(&:to_s).join("\n\n")
112
+ end
113
+
114
+ def #{method_name}_entry_for_dup
115
+ @#{method_name}.values.map(&:for_dup).join("\n\n")
116
+ end
117
+ METHODS
118
+ end
119
+
120
+ def indent(string)
121
+ string.strip.gsub(/^(.+)$/, ' \1')
122
+ end
123
+ end
124
+ end
@@ -1,9 +1,11 @@
1
1
  require 'thor'
2
2
  require 'fileutils'
3
+ require "appraisal/travis_ci_helper"
3
4
 
4
5
  module Appraisal
5
6
  class CLI < Thor
6
7
  default_task :install
8
+ map ["-v", "--version"] => "version"
7
9
 
8
10
  # Override help command to print out usage
9
11
  def self.help(shell, subcommand = false)
@@ -49,10 +51,17 @@ module Appraisal
49
51
  end
50
52
 
51
53
  desc 'generate', 'Generate a gemfile for each appraisal'
54
+ method_option "travis", :type => :boolean, :default => false
52
55
  def generate
53
56
  File.each do |appraisal|
54
57
  appraisal.write_gemfile
55
58
  end
59
+
60
+ if options[:travis]
61
+ TravisCIHelper.display_instruction
62
+ else
63
+ TravisCIHelper.validate_configuration_file
64
+ end
56
65
  end
57
66
 
58
67
  desc 'clean', 'Remove all generated gemfiles and lockfiles from gemfiles folder'
@@ -69,16 +78,26 @@ module Appraisal
69
78
  end
70
79
  end
71
80
 
81
+ desc 'list', 'List the names of the defined appraisals'
82
+ def list
83
+ File.new.appraisals.each { |appraisal| puts appraisal.name }
84
+ end
85
+
86
+ desc "version", "Display the version and exit"
87
+ def version
88
+ puts "Appraisal #{VERSION}"
89
+ end
90
+
72
91
  private
73
92
 
74
93
  def method_missing(name, *args, &block)
75
94
  matching_appraisal = File.new.appraisals.detect { |appraisal| appraisal.name == name.to_s }
76
95
 
77
96
  if matching_appraisal
78
- Command.new(args, gemfile: matching_appraisal.gemfile_path).run
97
+ Command.new(args, :gemfile => matching_appraisal.gemfile_path).run
79
98
  else
80
99
  File.each do |appraisal|
81
- Command.new(ARGV, gemfile: appraisal.gemfile_path).run
100
+ Command.new(ARGV, :gemfile => appraisal.gemfile_path).run
82
101
  end
83
102
  end
84
103
  end
@@ -15,19 +15,20 @@ module Appraisal
15
15
  end
16
16
 
17
17
  def run
18
+ with_clean_env { ensure_bundler_is_available }
18
19
  announce
20
+
19
21
  with_clean_env do
20
- unless Kernel.system(env, command_as_string)
22
+ env.each_pair do |key, value|
23
+ ENV[key] = value
24
+ end
25
+
26
+ unless Kernel.system(command_as_string)
21
27
  exit(1)
22
28
  end
23
29
  end
24
30
  end
25
31
 
26
- def exec
27
- announce
28
- with_clean_env { Kernel.exec(env, command_as_string) }
29
- end
30
-
31
32
  private
32
33
 
33
34
  def with_clean_env
@@ -39,6 +40,21 @@ module Appraisal
39
40
  restore_env
40
41
  end
41
42
 
43
+ def ensure_bundler_is_available
44
+ unless system %(gem list -q "^bundler$" | grep -q bundler)
45
+ puts ">> Reinstall Bundler into #{ENV["GEM_HOME"]}"
46
+
47
+ unless system "gem install bundler"
48
+ puts
49
+ puts <<-ERROR.strip.gsub(/\s+/, " ")
50
+ Bundler installation failed. Please try running
51
+ `GEM_HOME="#{ENV["GEM_HOME"]}" gem install bundler` manually.
52
+ ERROR
53
+ exit(1)
54
+ end
55
+ end
56
+ end
57
+
42
58
  def announce
43
59
  if gemfile
44
60
  puts ">> BUNDLE_GEMFILE=#{gemfile} #{command_as_string}"
@@ -1,9 +1,10 @@
1
1
  require 'appraisal/dependency'
2
+ require "active_support/ordered_hash"
2
3
 
3
4
  module Appraisal
4
5
  class DependencyList
5
6
  def initialize
6
- @dependencies = {}
7
+ @dependencies = ActiveSupport::OrderedHash.new
7
8
  end
8
9
 
9
10
  def add(name, requirements)
@@ -1,29 +1,14 @@
1
- require 'appraisal/dependency_list'
2
- require 'appraisal/gemspec'
3
- require 'appraisal/git_source'
4
- require 'appraisal/path_source'
5
- require 'appraisal/group'
6
- require 'appraisal/platform'
1
+ require "appraisal/bundler_dsl"
7
2
 
8
3
  module Appraisal
9
- # Load bundler Gemfiles and merge dependencies
10
- class Gemfile
11
- attr_reader :dependencies
12
-
13
- PARTS = %w(source ruby_version git_sources path_sources dependencies groups
14
- platforms gemspec)
15
-
16
- def initialize
17
- @sources = []
18
- @ruby_version = nil
19
- @dependencies = DependencyList.new
20
- @gemspec = nil
21
- @groups = {}
22
- @platforms = {}
23
- @git_sources = {}
24
- @path_sources = {}
25
- end
4
+ autoload :Gemspec, "appraisal/gemspec"
5
+ autoload :GitSource, "appraisal/git_source"
6
+ autoload :PathSource, "appraisal/path_source"
7
+ autoload :Group, "appraisal/group"
8
+ autoload :Platform, "appraisal/platform"
26
9
 
10
+ # Load bundler Gemfiles and merge dependencies
11
+ class Gemfile < BundlerDSL
27
12
  def load(path)
28
13
  run(IO.read(path))
29
14
  end
@@ -32,112 +17,10 @@ module Appraisal
32
17
  instance_eval(definitions, __FILE__, __LINE__) if definitions
33
18
  end
34
19
 
35
- def gem(name, *requirements)
36
- @dependencies.add(name, requirements)
37
- end
38
-
39
- def group(*names, &block)
40
- @groups[names] ||= Group.new(names)
41
- @groups[names].run(&block)
42
- end
43
-
44
- # :nodoc:
45
- def groups(*names, &block)
46
- $stderr.puts <<-WARNING.gsub(/\n\s+/, " ").strip
47
- Warning: `#groups` is deprecated and will be removed in 2.0.0.
48
- Please use `#group` instead.
49
- WARNING
50
-
51
- group(*names, &block)
52
- end
53
-
54
- def platforms(*names, &block)
55
- @platforms[names] ||= Platform.new(names)
56
- @platforms[names].run(&block)
57
- end
58
-
59
- alias_method :platform, :platforms
60
-
61
- def source(source)
62
- @sources << source
63
- end
64
-
65
- def ruby(ruby_version)
66
- @ruby_version = ruby_version
67
- end
68
-
69
- def git(source, options = {}, &block)
70
- @git_sources[source] ||= GitSource.new(source, options)
71
- @git_sources[source].run(&block)
72
- end
73
-
74
- def path(source, options = {}, &block)
75
- @path_sources[source] ||= PathSource.new(source, options)
76
- @path_sources[source].run(&block)
77
- end
78
-
79
- def to_s
80
- Utils.join_parts PARTS.map { |part| send("#{part}_entry") }
81
- end
82
-
83
20
  def dup
84
21
  Gemfile.new.tap do |gemfile|
85
- gemfile.run(
86
- Utils.join_parts PARTS.map { |part| send("#{part}_entry_for_dup") }
87
- )
22
+ gemfile.run(for_dup)
88
23
  end
89
24
  end
90
-
91
- def gemspec(options = {})
92
- @gemspec = Gemspec.new(options)
93
- end
94
-
95
- private
96
-
97
- def source_entry
98
- @sources.map { |source| "source #{source.inspect}" }.join("\n")
99
- end
100
-
101
- alias_method :source_entry_for_dup, :source_entry
102
-
103
- def ruby_version_entry
104
- if @ruby_version
105
- "ruby #{@ruby_version.inspect}"
106
- end
107
- end
108
-
109
- alias_method :ruby_version_entry_for_dup, :ruby_version_entry
110
-
111
- [:dependencies, :gemspec].each do |method_name|
112
- class_eval <<-METHODS, __FILE__, __LINE__
113
- private
114
-
115
- def #{method_name}_entry
116
- if @#{method_name}
117
- @#{method_name}.to_s
118
- end
119
- end
120
-
121
- def #{method_name}_entry_for_dup
122
- if @#{method_name}
123
- @#{method_name}.for_dup
124
- end
125
- end
126
- METHODS
127
- end
128
-
129
- [:git_sources, :path_sources, :platforms, :groups].each do |method_name|
130
- class_eval <<-METHODS, __FILE__, __LINE__
131
- private
132
-
133
- def #{method_name}_entry
134
- @#{method_name}.values.map(&:to_s).join("\n\n")
135
- end
136
-
137
- def #{method_name}_entry_for_dup
138
- @#{method_name}.values.map(&:for_dup).join("\n\n")
139
- end
140
- METHODS
141
- end
142
25
  end
143
26
  end