pessimize 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -3
- data/HISTORY +9 -0
- data/README.md +27 -2
- data/lib/pessimize/file_manager.rb +1 -1
- data/lib/pessimize/gemfile_lock_version_parser.rb +8 -17
- data/lib/pessimize/pessimizer.rb +6 -10
- data/lib/pessimize/shell.rb +41 -11
- data/lib/pessimize/version.rb +1 -1
- data/lib/pessimize/version_mapper.rb +4 -2
- data/pessimize.gemspec +3 -0
- data/spec/integration_spec.rb +197 -27
- data/spec/spec_helper.rb +2 -1
- data/spec/version_mapper_spec.rb +40 -4
- metadata +38 -5
data/Gemfile
CHANGED
data/HISTORY
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
=== Pessimize 0.1.0
|
2
|
+
|
3
|
+
Features:
|
4
|
+
* Introduce proper command line interface, with help and various options
|
5
|
+
* Change default behaviour to constrain versions on the minor number, instead of patch (issue #8)
|
6
|
+
* Add command line option to change version level constraint (issue #8)
|
7
|
+
* Use Bundler's Gemfile.lock parser, instead of a custom parser (issue #7)
|
8
|
+
* Add license to gemspec (issue #6)
|
9
|
+
|
1
10
|
=== Pessimize 0.0.3
|
2
11
|
|
3
12
|
Bug fixes:
|
data/README.md
CHANGED
@@ -9,7 +9,7 @@ Anyone who works with a Gemfile, i.e. a project that uses [bundler][1].
|
|
9
9
|
Pessimize adds version numbers with the pessimistic constraint operator (`~>`, a.k.a. "spermy" operator) to all gems in your `Gemfile`.
|
10
10
|
|
11
11
|
### Why?
|
12
|
-
You should be using `~> x.x
|
12
|
+
You should be using `~> x.x` to limit the version numbers of your gems, otherwise `bundle update` could potentially break your application. Read the section on "why bundle update can be dangerous" for a more detailed description, or take a look at the [rubygems explanation][2].
|
13
13
|
|
14
14
|
### But why a gem?
|
15
15
|
|
@@ -37,6 +37,31 @@ This backs up the existing `Gemfile` and creates a new one with everything neatl
|
|
37
37
|
|
38
38
|
And that's it!
|
39
39
|
|
40
|
+
### Options
|
41
|
+
|
42
|
+
The executable has various options, which you can read with the `--help` argument:
|
43
|
+
|
44
|
+
```bash
|
45
|
+
Usage: pessimize [options]
|
46
|
+
|
47
|
+
Add the pessimistic constraint operator to all gems in your Gemfile, restricting the maximum update
|
48
|
+
version.
|
49
|
+
|
50
|
+
Run this in a directory containing a Gemfile to apply the version constraint operator to all gems, at
|
51
|
+
their current version. By default, it will restrict updates to the minor version number, but this can be
|
52
|
+
changed to patch level updates.
|
53
|
+
|
54
|
+
Options:
|
55
|
+
--version-constraint, -c <s>: Version constraint ('minor' or 'patch') (default: minor)
|
56
|
+
--backup, --no-backup, -b: Backup existing Gemfile and Gemfile.lock (default: true)
|
57
|
+
--version, -v: Print version and exit
|
58
|
+
--help, -h: Show this message
|
59
|
+
```
|
60
|
+
|
61
|
+
By default, the versions will be constrained to the minor version number (e.g. "~> 3.2"). If you supply the option `--version-constraint patch` then it will only allow updates on the patch version number (e.g. "~> 3.2.5").
|
62
|
+
|
63
|
+
Also, by default, the Gemfile and Gemfile.lock are copied as a form of backup. To skip this backup (for instance, if you're confident that your Gemfile is committed into version control) then add the `--no-backup` option.
|
64
|
+
|
40
65
|
## Known issues
|
41
66
|
|
42
67
|
Pessimize evaluates the Gemfile as executable ruby code. That means that anything method-like will be retained in the output (e.g. `gem "nokogiri"`, or `source "https://rubygems.org"`), but anything else such as conditional statements will not.
|
@@ -49,7 +74,7 @@ If you add gems to your Gemfile without specifying a version, bundler will attem
|
|
49
74
|
|
50
75
|
This is fine until someone runs `bundle update`. In this case, bundler will try to update each gem to the maximum possible version. If no constraints have been applied, that means that **major** versions can potentially be incremented. Gems have interdependencies with other gems, and if those gems haven't specified the version constraints then breakages could occur.
|
51
76
|
|
52
|
-
The pessimistic constraint operator will only allow the final number of the version string to increase. You can use this to only allow patch
|
77
|
+
The pessimistic constraint operator will only allow the final number of the version string to increase. You can use this to only allow patch or minor level upgrades. This means that when you run `bundle update`, there's a limit on how far gems will update.
|
53
78
|
|
54
79
|
## Contributing
|
55
80
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
|
1
3
|
module Pessimize
|
2
4
|
class GemfileLockVersionParser
|
3
5
|
attr_reader :versions
|
@@ -8,28 +10,17 @@ module Pessimize
|
|
8
10
|
end
|
9
11
|
|
10
12
|
def call(gemfile_lock_file)
|
11
|
-
gemfile_lock_file.
|
12
|
-
|
13
|
-
|
14
|
-
end
|
15
|
-
if parse_enabled
|
16
|
-
parse_line(line)
|
17
|
-
end
|
18
|
-
end
|
13
|
+
parser = Bundler::LockfileParser.new gemfile_lock_file.read
|
14
|
+
self.versions = collect_names_and_versions parser.specs
|
15
|
+
self
|
19
16
|
end
|
20
17
|
|
21
18
|
protected
|
22
|
-
attr_writer
|
19
|
+
attr_writer :versions
|
23
20
|
attr_accessor :parse_enabled
|
24
21
|
|
25
|
-
def
|
26
|
-
|
27
|
-
line.strip!
|
28
|
-
matches = /([^(]+)\([^0-9]*([^)]+)/.match(line)
|
29
|
-
if matches
|
30
|
-
self.versions[matches[1].strip] = matches[2]
|
31
|
-
end
|
32
|
-
end
|
22
|
+
def collect_names_and_versions(specs)
|
23
|
+
Hash[specs.collect { |s| [s.name, s.version.to_s] }]
|
33
24
|
end
|
34
25
|
end
|
35
26
|
end
|
data/lib/pessimize/pessimizer.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
require 'pessimize/dsl'
|
2
2
|
require 'pessimize/gem_collection'
|
3
3
|
require 'pessimize/gemfile_lock_version_parser'
|
4
|
+
require 'pessimize/version_mapper'
|
4
5
|
|
5
6
|
module Pessimize
|
6
7
|
class Pessimizer
|
7
|
-
def initialize(file_manager)
|
8
|
+
def initialize(file_manager, options)
|
8
9
|
self.file_manager = file_manager
|
10
|
+
self.options = options
|
9
11
|
self.collection = GemCollection.new
|
10
12
|
self.dsl = DSL.new collection
|
11
13
|
self.lock_parser = GemfileLockVersionParser.new
|
@@ -15,10 +17,11 @@ module Pessimize
|
|
15
17
|
collect_gems_and_versions
|
16
18
|
update_gem_versions
|
17
19
|
write_new_gemfile
|
20
|
+
puts "~> written #{collection.all.length} gems to Gemfile, constrained to #{options[:version_constraint]} version updates\n\n"
|
18
21
|
end
|
19
22
|
|
20
23
|
protected
|
21
|
-
attr_accessor :collection, :dsl, :lock_parser, :file_manager
|
24
|
+
attr_accessor :collection, :dsl, :lock_parser, :file_manager, :options
|
22
25
|
|
23
26
|
def sep(num = 1)
|
24
27
|
"\n" * num
|
@@ -26,17 +29,11 @@ module Pessimize
|
|
26
29
|
|
27
30
|
def collect_gems_and_versions
|
28
31
|
dsl.parse file_manager.gemfile_contents
|
29
|
-
puts "Collected #{collection.all.length} gems from #{file_manager.gemfile}"
|
30
32
|
lock_parser.call File.open(file_manager.gemfile_lock)
|
31
33
|
end
|
32
34
|
|
33
35
|
def update_gem_versions
|
34
|
-
|
35
|
-
collection.all.each do |gem|
|
36
|
-
if lock_parser.versions.has_key? gem.name
|
37
|
-
gem.version = "~> #{lock_parser.versions[gem.name]}"
|
38
|
-
end
|
39
|
-
end
|
36
|
+
VersionMapper.new.call(collection.all, lock_parser.versions, options[:version_constraint])
|
40
37
|
end
|
41
38
|
|
42
39
|
def write_new_gemfile
|
@@ -62,7 +59,6 @@ module Pessimize
|
|
62
59
|
end
|
63
60
|
end
|
64
61
|
end
|
65
|
-
puts "Written new Gemfile"
|
66
62
|
end
|
67
63
|
|
68
64
|
end
|
data/lib/pessimize/shell.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'pessimize/file_manager'
|
2
2
|
require 'pessimize/pessimizer'
|
3
|
+
require 'trollop'
|
3
4
|
|
4
5
|
module Pessimize
|
5
6
|
class Shell
|
@@ -8,8 +9,10 @@ module Pessimize
|
|
8
9
|
end
|
9
10
|
|
10
11
|
def run
|
11
|
-
|
12
|
-
|
12
|
+
options = cli_options
|
13
|
+
check_options! options
|
14
|
+
verify_files!(options[:backup])
|
15
|
+
Pessimizer.new(file_manager, options).run
|
13
16
|
end
|
14
17
|
|
15
18
|
protected
|
@@ -19,7 +22,32 @@ module Pessimize
|
|
19
22
|
"\n" * num
|
20
23
|
end
|
21
24
|
|
22
|
-
def
|
25
|
+
def cli_options
|
26
|
+
Trollop::options do
|
27
|
+
version "pessimize #{VERSION} (c) #{Time.now.year} Jon Cairns"
|
28
|
+
banner <<-EOS
|
29
|
+
Usage: pessimize [options]
|
30
|
+
|
31
|
+
Add the pessimistic constraint operator to all gems in your Gemfile, restricting the maximum update version.
|
32
|
+
|
33
|
+
Run this in a directory containing a Gemfile to apply the version constraint operator to all gems, at their current version. By default, it will restrict updates to the minor version number, but this can be changed to patch level updates.
|
34
|
+
|
35
|
+
Options:
|
36
|
+
EOS
|
37
|
+
|
38
|
+
opt :version_constraint, "Version constraint ('minor' or 'patch')", default: 'minor', type: :string, short: 'c'
|
39
|
+
opt :backup, "Backup existing Gemfile and Gemfile.lock", default: true, type: :boolean, short: 'b'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def check_options!(options)
|
44
|
+
constraints = %w(minor patch)
|
45
|
+
unless constraints.include? options[:version_constraint]
|
46
|
+
Trollop::die :version_constraint, "must be one of #{constraints.join("|")}"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def verify_files!(backup)
|
23
51
|
file_manager.gemfile? or exit_with 1, <<-ERR.strip
|
24
52
|
error: no Gemfile exists in the current directory, exiting
|
25
53
|
ERR
|
@@ -29,16 +57,18 @@ module Pessimize
|
|
29
57
|
Please run `bundle install` before running pessimize
|
30
58
|
ERR
|
31
59
|
|
32
|
-
|
60
|
+
if backup
|
61
|
+
puts "Backing up Gemfile and Gemfile.lock"
|
33
62
|
|
34
|
-
|
35
|
-
|
36
|
-
|
63
|
+
file_manager.backup_gemfile! or exit_with 3, <<-ERR.strip
|
64
|
+
error: failed to backup existing Gemfile, exiting
|
65
|
+
ERR
|
37
66
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
67
|
+
file_manager.backup_gemfile_lock! or exit_with 4, <<-ERR.strip
|
68
|
+
error: failed to backup existing Gemfile.lock, exiting
|
69
|
+
ERR
|
70
|
+
puts ""
|
71
|
+
end
|
42
72
|
end
|
43
73
|
|
44
74
|
def exit_with(status, message)
|
data/lib/pessimize/version.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
module Pessimize
|
2
2
|
class VersionMapper
|
3
|
-
def call(gems, versions)
|
3
|
+
def call(gems, versions, version_constraint)
|
4
4
|
gems.each do |gem|
|
5
5
|
if versions.has_key? gem.name
|
6
|
-
|
6
|
+
version_parts = versions[gem.name].split('.')
|
7
|
+
version = version_constraint == 'minor' ? version_parts.first(2).join('.') : version_parts.join('.')
|
8
|
+
gem.version = "~> #{version}"
|
7
9
|
end
|
8
10
|
end
|
9
11
|
end
|
data/pessimize.gemspec
CHANGED
@@ -14,6 +14,8 @@ This is for people who work with projects that use bundler, such as rails projec
|
|
14
14
|
gem.summary = %q{Add the pessimistic constraint operator to all gems in your Gemfile, restricting the maximum update version.}
|
15
15
|
gem.homepage = "https://github.com/joonty/pessimize"
|
16
16
|
|
17
|
+
gem.add_dependency 'bundler'
|
18
|
+
gem.add_dependency 'trollop'
|
17
19
|
gem.add_development_dependency 'rspec', '~> 2.13.0'
|
18
20
|
gem.add_development_dependency 'rake', '~> 10.0.3'
|
19
21
|
|
@@ -21,4 +23,5 @@ This is for people who work with projects that use bundler, such as rails projec
|
|
21
23
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
22
24
|
gem.test_files = gem.files.grep(%r{^spec/})
|
23
25
|
gem.require_paths = ["lib"]
|
26
|
+
gem.license = 'MIT'
|
24
27
|
end
|
data/spec/integration_spec.rb
CHANGED
@@ -3,11 +3,11 @@ require 'spec_helper'
|
|
3
3
|
describe "running pessimize" do
|
4
4
|
include IntegrationHelper
|
5
5
|
|
6
|
-
shared_examples "a working pessimizer" do |gemfile, lockfile, result|
|
6
|
+
shared_examples "a working pessimizer" do |gemfile, lockfile, result, cli_args = ""|
|
7
7
|
before do
|
8
8
|
write_gemfile(gemfile)
|
9
9
|
write_gemfile_lock(lockfile)
|
10
|
-
run
|
10
|
+
run(cli_args)
|
11
11
|
end
|
12
12
|
|
13
13
|
context "after execution" do
|
@@ -18,7 +18,7 @@ describe "running pessimize" do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
# exclude from jruby
|
21
|
-
context "the return code" do
|
21
|
+
context "the return code", platform: :jruby do
|
22
22
|
subject { $?.exitstatus }
|
23
23
|
it { should == 0 }
|
24
24
|
end
|
@@ -41,6 +41,46 @@ describe "running pessimize" do
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
+
shared_examples "a working pessimizer without backups" do |gemfile, lockfile, result, cli_args = ""|
|
45
|
+
before do
|
46
|
+
write_gemfile(gemfile)
|
47
|
+
write_gemfile_lock(lockfile)
|
48
|
+
run(cli_args)
|
49
|
+
end
|
50
|
+
|
51
|
+
context "after execution" do
|
52
|
+
|
53
|
+
context "the stderr" do
|
54
|
+
subject { stderr }
|
55
|
+
it { should == "" }
|
56
|
+
end
|
57
|
+
|
58
|
+
# exclude from jruby
|
59
|
+
context "the return code", platform: :jruby do
|
60
|
+
subject { $?.exitstatus }
|
61
|
+
it { should == 0 }
|
62
|
+
end
|
63
|
+
|
64
|
+
context "the Gemfile.backup" do
|
65
|
+
it "should not exist" do
|
66
|
+
File.exists?(tmp_path + 'Gemfile.backup').should be_false
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
context "the Gemfile.lock.backup" do
|
71
|
+
it "should not exist" do
|
72
|
+
File.exists?(tmp_path + 'Gemfile.lock.backup').should be_false
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
context "the Gemfile" do
|
77
|
+
subject { gemfile_contents }
|
78
|
+
|
79
|
+
it { should == result }
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
44
84
|
before do
|
45
85
|
setup
|
46
86
|
end
|
@@ -49,6 +89,60 @@ describe "running pessimize" do
|
|
49
89
|
tear_down
|
50
90
|
end
|
51
91
|
|
92
|
+
context "with the help option" do
|
93
|
+
before do
|
94
|
+
run('--help')
|
95
|
+
end
|
96
|
+
|
97
|
+
context "the exit status", :platform => :java do
|
98
|
+
subject { status.exitstatus }
|
99
|
+
|
100
|
+
it { should == 0 }
|
101
|
+
end
|
102
|
+
|
103
|
+
context "the output" do
|
104
|
+
subject { stdout }
|
105
|
+
|
106
|
+
it { should include("Usage:") }
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
context "with the version option" do
|
111
|
+
before do
|
112
|
+
run('--version')
|
113
|
+
end
|
114
|
+
|
115
|
+
context "the exit status", :platform => :java do
|
116
|
+
subject { status.exitstatus }
|
117
|
+
|
118
|
+
it { should == 0 }
|
119
|
+
end
|
120
|
+
|
121
|
+
context "the output" do
|
122
|
+
subject { stdout }
|
123
|
+
|
124
|
+
it { should include(Pessimize::VERSION) }
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
context "with the version option" do
|
129
|
+
before do
|
130
|
+
run('-c rubbish')
|
131
|
+
end
|
132
|
+
|
133
|
+
context "the exit status", :platform => :java do
|
134
|
+
subject { status.exitstatus }
|
135
|
+
|
136
|
+
it { should == 255 }
|
137
|
+
end
|
138
|
+
|
139
|
+
context "the error output" do
|
140
|
+
subject { stderr }
|
141
|
+
|
142
|
+
it { should include("--version-constraint must be one of minor|patch") }
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
52
146
|
context "with no Gemfile" do
|
53
147
|
before do
|
54
148
|
run
|
@@ -147,8 +241,8 @@ GEM
|
|
147
241
|
result = <<-EOD
|
148
242
|
source "https://rubygems.org"
|
149
243
|
|
150
|
-
gem "json", "~> 1.8
|
151
|
-
gem "rake", "~> 10.0
|
244
|
+
gem "json", "~> 1.8"
|
245
|
+
gem "rake", "~> 10.0"
|
152
246
|
EOD
|
153
247
|
|
154
248
|
it_behaves_like "a working pessimizer", gemfile, lockfile, result
|
@@ -175,23 +269,23 @@ GEM
|
|
175
269
|
specs:
|
176
270
|
json (1.8.0)
|
177
271
|
rake (10.0.4)
|
178
|
-
pg (
|
179
|
-
sqlite3 (
|
272
|
+
pg (0.15.0)
|
273
|
+
sqlite3 (1.3.7)
|
180
274
|
EOD
|
181
275
|
|
182
276
|
result = <<-EOD
|
183
277
|
source "https://rubygems.org"
|
184
278
|
|
185
279
|
group :development do
|
186
|
-
gem "sqlite3", "~> 1.3
|
280
|
+
gem "sqlite3", "~> 1.3"
|
187
281
|
end
|
188
282
|
|
189
283
|
group :production do
|
190
|
-
gem "pg", "~> 0.15
|
284
|
+
gem "pg", "~> 0.15"
|
191
285
|
end
|
192
286
|
|
193
|
-
gem "json", "~> 1.8
|
194
|
-
gem "rake", "~> 10.0
|
287
|
+
gem "json", "~> 1.8"
|
288
|
+
gem "rake", "~> 10.0"
|
195
289
|
EOD
|
196
290
|
|
197
291
|
it_behaves_like "a working pessimizer", gemfile, lockfile, result
|
@@ -214,22 +308,22 @@ GEM
|
|
214
308
|
specs:
|
215
309
|
json (1.8.0)
|
216
310
|
rake (10.0.4)
|
217
|
-
sqlite3 (
|
311
|
+
sqlite3 (1.3.7)
|
218
312
|
EOD
|
219
313
|
|
220
314
|
result = <<-EOD
|
221
315
|
source "https://rubygems.org"
|
222
316
|
|
223
317
|
group :development do
|
224
|
-
gem "sqlite3", "~> 1.3
|
318
|
+
gem "sqlite3", "~> 1.3"
|
225
319
|
end
|
226
320
|
|
227
321
|
group :test do
|
228
|
-
gem "sqlite3", "~> 1.3
|
322
|
+
gem "sqlite3", "~> 1.3"
|
229
323
|
end
|
230
324
|
|
231
|
-
gem "json", "~> 1.8
|
232
|
-
gem "rake", "~> 10.0
|
325
|
+
gem "json", "~> 1.8"
|
326
|
+
gem "rake", "~> 10.0"
|
233
327
|
EOD
|
234
328
|
|
235
329
|
it_behaves_like "a working pessimizer", gemfile, lockfile, result
|
@@ -252,22 +346,22 @@ GEM
|
|
252
346
|
specs:
|
253
347
|
json (1.8.0)
|
254
348
|
rake (10.0.4)
|
255
|
-
sqlite3 (
|
349
|
+
sqlite3 (1.3.7)
|
256
350
|
EOD
|
257
351
|
|
258
352
|
result = <<-EOD
|
259
353
|
source "https://rubygems.org"
|
260
354
|
|
261
355
|
group :development do
|
262
|
-
gem "sqlite3", "~> 1.3
|
356
|
+
gem "sqlite3", "~> 1.3"
|
263
357
|
end
|
264
358
|
|
265
359
|
group :test do
|
266
|
-
gem "sqlite3", "~> 1.3
|
360
|
+
gem "sqlite3", "~> 1.3"
|
267
361
|
end
|
268
362
|
|
269
|
-
gem "json", "~> 1.8
|
270
|
-
gem "rake", "~> 10.0
|
363
|
+
gem "json", "~> 1.8"
|
364
|
+
gem "rake", "~> 10.0"
|
271
365
|
EOD
|
272
366
|
|
273
367
|
it_behaves_like "a working pessimizer", gemfile, lockfile, result
|
@@ -310,7 +404,7 @@ GIT
|
|
310
404
|
revision: 8c481090ac928c78ed1f794b4e76b178e1ccf713
|
311
405
|
specs:
|
312
406
|
bf4-metric_fu (2.1.3.1)
|
313
|
-
activesupport (
|
407
|
+
activesupport (2.0.0)
|
314
408
|
arrayfields (= 4.7.4)
|
315
409
|
bluff
|
316
410
|
chronic (= 0.2.3)
|
@@ -320,7 +414,7 @@ GIT
|
|
320
414
|
flay (= 1.2.1)
|
321
415
|
flog (= 2.3.0)
|
322
416
|
googlecharts
|
323
|
-
japgolly-Saikuro (
|
417
|
+
japgolly-Saikuro (1.1.1.0)
|
324
418
|
main (= 4.7.1)
|
325
419
|
map (= 6.2.0)
|
326
420
|
rails_best_practices (~> 0.6)
|
@@ -338,7 +432,7 @@ GEM
|
|
338
432
|
source "https://somewhere-else.org"
|
339
433
|
|
340
434
|
gem "metric_fu", {:git=>"https://github.com/joonty/metric_fu.git", :branch=>"master"}
|
341
|
-
gem "kaminari", "~> 0.14
|
435
|
+
gem "kaminari", "~> 0.14", {:require=>false}
|
342
436
|
EOD
|
343
437
|
|
344
438
|
it_behaves_like "a working pessimizer", gemfile, lockfile, result
|
@@ -358,7 +452,7 @@ GIT
|
|
358
452
|
revision: 8c481090ac928c78ed1f794b4e76b178e1ccf713
|
359
453
|
specs:
|
360
454
|
bf4-metric_fu (2.1.3.1)
|
361
|
-
activesupport (
|
455
|
+
activesupport (2.0.0)
|
362
456
|
arrayfields (= 4.7.4)
|
363
457
|
bluff
|
364
458
|
chronic (= 0.2.3)
|
@@ -368,7 +462,7 @@ GIT
|
|
368
462
|
flay (= 1.2.1)
|
369
463
|
flog (= 2.3.0)
|
370
464
|
googlecharts
|
371
|
-
japgolly-Saikuro (
|
465
|
+
japgolly-Saikuro (1.1.1.0)
|
372
466
|
main (= 4.7.1)
|
373
467
|
map (= 6.2.0)
|
374
468
|
rails_best_practices (~> 0.6)
|
@@ -386,9 +480,85 @@ GEM
|
|
386
480
|
source "https://somewhere-else.org"
|
387
481
|
|
388
482
|
gem "metric_fu", {:git=>"https://github.com/joonty/metric_fu.git", :branch=>"master"}
|
389
|
-
gem "kaminari", "~> 0.14
|
483
|
+
gem "kaminari", "~> 0.14", {:require=>false}
|
390
484
|
EOD
|
391
485
|
|
392
486
|
it_behaves_like "a working pessimizer", gemfile, lockfile, result
|
393
487
|
end
|
488
|
+
|
489
|
+
context "with the option to use patch level constraints" do
|
490
|
+
gemfile = <<-EOD
|
491
|
+
source "https://rubygems.org"
|
492
|
+
gem 'json'
|
493
|
+
gem 'rake'
|
494
|
+
|
495
|
+
group :development, :test do
|
496
|
+
gem 'sqlite3', '>= 1.3.7'
|
497
|
+
end
|
498
|
+
EOD
|
499
|
+
|
500
|
+
lockfile = <<-EOD
|
501
|
+
GEM
|
502
|
+
remote: https://rubygems.org/
|
503
|
+
specs:
|
504
|
+
json (1.8.0)
|
505
|
+
rake (10.0.4)
|
506
|
+
sqlite3 (1.3.7)
|
507
|
+
EOD
|
508
|
+
|
509
|
+
result = <<-EOD
|
510
|
+
source "https://rubygems.org"
|
511
|
+
|
512
|
+
group :development do
|
513
|
+
gem "sqlite3", "~> 1.3.7"
|
514
|
+
end
|
515
|
+
|
516
|
+
group :test do
|
517
|
+
gem "sqlite3", "~> 1.3.7"
|
518
|
+
end
|
519
|
+
|
520
|
+
gem "json", "~> 1.8.0"
|
521
|
+
gem "rake", "~> 10.0.4"
|
522
|
+
EOD
|
523
|
+
|
524
|
+
it_behaves_like "a working pessimizer", gemfile, lockfile, result, '-c patch'
|
525
|
+
end
|
526
|
+
|
527
|
+
context "with the option to not have backups" do
|
528
|
+
gemfile = <<-EOD
|
529
|
+
source "https://rubygems.org"
|
530
|
+
gem 'json'
|
531
|
+
gem 'rake'
|
532
|
+
|
533
|
+
group :development, :test do
|
534
|
+
gem 'sqlite3', '>= 1.3.7'
|
535
|
+
end
|
536
|
+
EOD
|
537
|
+
|
538
|
+
lockfile = <<-EOD
|
539
|
+
GEM
|
540
|
+
remote: https://rubygems.org/
|
541
|
+
specs:
|
542
|
+
json (1.8.0)
|
543
|
+
rake (10.0.4)
|
544
|
+
sqlite3 (1.3.7)
|
545
|
+
EOD
|
546
|
+
|
547
|
+
result = <<-EOD
|
548
|
+
source "https://rubygems.org"
|
549
|
+
|
550
|
+
group :development do
|
551
|
+
gem "sqlite3", "~> 1.3"
|
552
|
+
end
|
553
|
+
|
554
|
+
group :test do
|
555
|
+
gem "sqlite3", "~> 1.3"
|
556
|
+
end
|
557
|
+
|
558
|
+
gem "json", "~> 1.8"
|
559
|
+
gem "rake", "~> 10.0"
|
560
|
+
EOD
|
561
|
+
|
562
|
+
it_behaves_like "a working pessimizer without backups", gemfile, lockfile, result, '--no-backup'
|
563
|
+
end
|
394
564
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -36,7 +36,8 @@ module IntegrationHelper
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def run(argument_string = '')
|
39
|
-
|
39
|
+
command = "ruby -I#{root_path}/lib #{bin_path} #{argument_string}"
|
40
|
+
Open3.popen3 command do |_, io_stdout, io_stderr, thr|
|
40
41
|
@stdout = io_stdout.read
|
41
42
|
@stderr = io_stderr.read
|
42
43
|
@status = thr.value if thr
|
data/spec/version_mapper_spec.rb
CHANGED
@@ -4,13 +4,49 @@ require 'pessimize/gem'
|
|
4
4
|
|
5
5
|
module Pessimize
|
6
6
|
describe VersionMapper do
|
7
|
-
context "with a gem and
|
7
|
+
context "with a gem, version hash and minor constraint" do
|
8
8
|
let(:gems) { [ Gem.new('example') ] }
|
9
9
|
let(:versions) { { 'example' => '2.2.3' } }
|
10
10
|
let(:mapper) { VersionMapper.new }
|
11
11
|
|
12
12
|
before do
|
13
|
-
mapper.call gems, versions
|
13
|
+
mapper.call gems, versions, 'minor'
|
14
|
+
end
|
15
|
+
|
16
|
+
subject { gems.first }
|
17
|
+
|
18
|
+
its(:version) { should == '~> 2.2' }
|
19
|
+
end
|
20
|
+
|
21
|
+
context "with multiple gems, version hash and minor constraint" do
|
22
|
+
let(:gems) { [ Gem.new('example'), Gem.new('fish', '1.3.2') ] }
|
23
|
+
let(:versions) { { 'example' => '1.4.9', 'fish' => '2.3.0' } }
|
24
|
+
let(:mapper) { VersionMapper.new }
|
25
|
+
|
26
|
+
before do
|
27
|
+
mapper.call gems, versions, 'minor'
|
28
|
+
end
|
29
|
+
|
30
|
+
context "the first gem" do
|
31
|
+
subject { gems.first }
|
32
|
+
|
33
|
+
its(:version) { should == '~> 1.4' }
|
34
|
+
end
|
35
|
+
|
36
|
+
context "the second gem" do
|
37
|
+
subject { gems[1] }
|
38
|
+
|
39
|
+
its(:version) { should == '~> 2.3' }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context "with a gem, version hash and patch constraint" do
|
44
|
+
let(:gems) { [ Gem.new('example') ] }
|
45
|
+
let(:versions) { { 'example' => '2.2.3' } }
|
46
|
+
let(:mapper) { VersionMapper.new }
|
47
|
+
|
48
|
+
before do
|
49
|
+
mapper.call gems, versions, 'patch'
|
14
50
|
end
|
15
51
|
|
16
52
|
subject { gems.first }
|
@@ -18,13 +54,13 @@ module Pessimize
|
|
18
54
|
its(:version) { should == '~> 2.2.3' }
|
19
55
|
end
|
20
56
|
|
21
|
-
context "with multiple gems and
|
57
|
+
context "with multiple gems, version hash and patch constraint" do
|
22
58
|
let(:gems) { [ Gem.new('example'), Gem.new('fish', '1.3.2') ] }
|
23
59
|
let(:versions) { { 'example' => '1.4.9', 'fish' => '2.3.0' } }
|
24
60
|
let(:mapper) { VersionMapper.new }
|
25
61
|
|
26
62
|
before do
|
27
|
-
mapper.call gems, versions
|
63
|
+
mapper.call gems, versions, 'patch'
|
28
64
|
end
|
29
65
|
|
30
66
|
context "the first gem" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pessimize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,40 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-09-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: trollop
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
14
46
|
- !ruby/object:Gem::Dependency
|
15
47
|
name: rspec
|
16
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -90,7 +122,8 @@ files:
|
|
90
122
|
- spec/spec_helper.rb
|
91
123
|
- spec/version_mapper_spec.rb
|
92
124
|
homepage: https://github.com/joonty/pessimize
|
93
|
-
licenses:
|
125
|
+
licenses:
|
126
|
+
- MIT
|
94
127
|
post_install_message:
|
95
128
|
rdoc_options: []
|
96
129
|
require_paths:
|
@@ -103,7 +136,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
103
136
|
version: '0'
|
104
137
|
segments:
|
105
138
|
- 0
|
106
|
-
hash:
|
139
|
+
hash: 102420707118458476
|
107
140
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
141
|
none: false
|
109
142
|
requirements:
|
@@ -112,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
145
|
version: '0'
|
113
146
|
segments:
|
114
147
|
- 0
|
115
|
-
hash:
|
148
|
+
hash: 102420707118458476
|
116
149
|
requirements: []
|
117
150
|
rubyforge_project:
|
118
151
|
rubygems_version: 1.8.25
|