solve 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -16
- data/README.md +3 -4
- data/lib/solve/constraint.rb +11 -3
- data/lib/solve/demand.rb +2 -2
- data/lib/solve/gem_version.rb +1 -1
- data/lib/solve/graph.rb +5 -5
- data/lib/solve/version.rb +4 -0
- data/spec/unit/solve/constraint_spec.rb +216 -17
- data/spec/unit/solve/version_spec.rb +22 -0
- metadata +3 -3
data/Gemfile
CHANGED
@@ -3,37 +3,24 @@ source 'https://rubygems.org'
|
|
3
3
|
gemspec
|
4
4
|
|
5
5
|
group :development do
|
6
|
-
gem 'pry'
|
7
6
|
gem 'fuubar'
|
8
7
|
gem 'yard'
|
9
8
|
gem 'redcarpet'
|
10
|
-
gem 'guard'
|
11
9
|
gem 'guard-rspec'
|
12
10
|
gem 'guard-spork'
|
13
11
|
gem 'guard-yard'
|
14
|
-
|
15
|
-
platform :ruby_19 do
|
16
|
-
gem 'coolline'
|
17
|
-
end
|
12
|
+
gem 'coolline'
|
18
13
|
|
19
14
|
require 'rbconfig'
|
20
15
|
|
21
16
|
if RbConfig::CONFIG['target_os'] =~ /darwin/i
|
22
|
-
gem '
|
23
|
-
gem 'rb-fsevent', require: false
|
24
|
-
|
25
|
-
if `uname`.strip == 'Darwin' && `sw_vers -productVersion`.strip >= '10.8'
|
26
|
-
gem 'terminal-notifier-guard', '~> 1.5.3', require: false
|
27
|
-
end rescue Errno::ENOENT
|
17
|
+
gem 'ruby_gntp', require: false
|
28
18
|
|
29
19
|
elsif RbConfig::CONFIG['target_os'] =~ /linux/i
|
30
|
-
gem 'libnotify',
|
31
|
-
gem 'rb-inotify', require: false
|
20
|
+
gem 'libnotify', require: false
|
32
21
|
|
33
22
|
elsif RbConfig::CONFIG['target_os'] =~ /mswin|mingw/i
|
34
23
|
gem 'win32console', require: false
|
35
|
-
gem 'rb-notifu', '>= 0.0.4', require: false
|
36
|
-
gem 'wdm', require: false
|
37
24
|
end
|
38
25
|
end
|
39
26
|
|
data/README.md
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
# Solve
|
2
2
|
[![Gem Version](https://badge.fury.io/rb/solve.png)](http://badge.fury.io/rb/solve)
|
3
|
-
[![Build Status](https://secure.travis-ci.org/
|
4
|
-
[![Dependency Status](https://gemnasium.com/
|
5
|
-
[![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/reset/solve)
|
3
|
+
[![Build Status](https://secure.travis-ci.org/RiotGames/solve.png?branch=master)](http://travis-ci.org/RiotGames/solve)
|
4
|
+
[![Dependency Status](https://gemnasium.com/RiotGames/solve.png?travis)](https://gemnasium.com/RiotGames/solve)
|
6
5
|
|
7
|
-
A Ruby versioning constraint solver implementing [Semantic Versioning 2.0.0
|
6
|
+
A Ruby versioning constraint solver implementing [Semantic Versioning 2.0.0](http://semver.org).
|
8
7
|
|
9
8
|
## Installation
|
10
9
|
|
data/lib/solve/constraint.rb
CHANGED
@@ -189,9 +189,7 @@ module Solve
|
|
189
189
|
def satisfies?(target_version)
|
190
190
|
target_version = Version.new(target_version.to_s)
|
191
191
|
|
192
|
-
if
|
193
|
-
return false
|
194
|
-
end
|
192
|
+
return false if !version.zero? && greedy_match?(target_version)
|
195
193
|
|
196
194
|
compare(target_version)
|
197
195
|
end
|
@@ -217,6 +215,16 @@ module Solve
|
|
217
215
|
|
218
216
|
private
|
219
217
|
|
218
|
+
# Returns true if the given version is a pre-release and if the constraint
|
219
|
+
# does not include a pre-release and if the operator isn't < or <=.
|
220
|
+
# This avoids greedy matches, e.g. 2.0.0.alpha won't satisfy >= 1.0.0.
|
221
|
+
#
|
222
|
+
# @param [Solve::Version] target_version
|
223
|
+
#
|
224
|
+
def greedy_match?(target_version)
|
225
|
+
operator_type !~ /less/ && target_version.pre_release? && !version.pre_release?
|
226
|
+
end
|
227
|
+
|
220
228
|
# @param [Solve::Version] target
|
221
229
|
#
|
222
230
|
# @return [Boolean]
|
data/lib/solve/demand.rb
CHANGED
@@ -20,7 +20,7 @@ module Solve
|
|
20
20
|
# @param [Solve::Constraint, #to_s] constraint
|
21
21
|
def initialize(solver, name, constraint = ">= 0.0.0")
|
22
22
|
@solver = solver
|
23
|
-
@name
|
23
|
+
@name = name
|
24
24
|
@constraint = if constraint.is_a?(Solve::Constraint)
|
25
25
|
constraint
|
26
26
|
else
|
@@ -33,7 +33,7 @@ module Solve
|
|
33
33
|
# @return [Solve::Demand, nil]
|
34
34
|
def delete
|
35
35
|
unless solver.nil?
|
36
|
-
result
|
36
|
+
result = solver.remove_demand(self)
|
37
37
|
@solver = nil
|
38
38
|
result
|
39
39
|
end
|
data/lib/solve/gem_version.rb
CHANGED
data/lib/solve/graph.rb
CHANGED
@@ -157,11 +157,11 @@ module Solve
|
|
157
157
|
end
|
158
158
|
alias_method :eql?, :==
|
159
159
|
|
160
|
-
|
160
|
+
private
|
161
161
|
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
162
|
+
# @return [Array<Solve::Artifact>]
|
163
|
+
def artifact_collection
|
164
|
+
@artifacts.collect { |name, artifact| artifact }
|
165
|
+
end
|
166
166
|
end
|
167
167
|
end
|
data/lib/solve/version.rb
CHANGED
@@ -272,36 +272,130 @@ describe Solve::Constraint do
|
|
272
272
|
should satisfies(Solve::Version.new("1.0.0"))
|
273
273
|
end
|
274
274
|
|
275
|
-
context "
|
276
|
-
subject { Solve::Constraint.new("
|
275
|
+
context "strictly greater than (>) pre-release constraint" do
|
276
|
+
subject { Solve::Constraint.new("> 1.0.0-alpha") }
|
277
277
|
|
278
|
-
it
|
279
|
-
|
280
|
-
|
278
|
+
it { should_not satisfies("0.9.9+build") }
|
279
|
+
it { should_not satisfies("1.0.0-alpha") }
|
280
|
+
it { should satisfies("1.0.0-alpha.2") }
|
281
|
+
it { should satisfies("1.0.0") }
|
282
|
+
it { should satisfies("1.0.0+build") }
|
283
|
+
it { should satisfies("1.0.1-beta") }
|
284
|
+
it { should satisfies("1.0.1") }
|
285
|
+
it { should satisfies("1.0.1+build.2") }
|
286
|
+
it { should satisfies("2.0.0") }
|
281
287
|
end
|
282
288
|
|
283
|
-
context "
|
284
|
-
subject { Solve::Constraint.new("
|
289
|
+
context "strictly greater than (>)" do
|
290
|
+
subject { Solve::Constraint.new("> 1.0.0") }
|
285
291
|
|
286
|
-
it
|
287
|
-
|
288
|
-
|
292
|
+
it { should_not satisfies("0.9.9+build") }
|
293
|
+
it { should_not satisfies("1.0.0-alpha") }
|
294
|
+
it { should_not satisfies("1.0.0-alpha.2") }
|
295
|
+
it { should_not satisfies("1.0.0") }
|
296
|
+
it { should satisfies("1.0.0+build") }
|
297
|
+
it { should_not satisfies("1.0.1-beta") }
|
298
|
+
it { should satisfies("1.0.1") }
|
299
|
+
it { should satisfies("1.0.1+build.2") }
|
300
|
+
it { should satisfies("2.0.0") }
|
289
301
|
end
|
290
302
|
|
291
|
-
context "strictly greater than (>)" do
|
292
|
-
subject { Solve::Constraint.new("> 1.0.0
|
303
|
+
context "strictly greater than (>) build constraint" do
|
304
|
+
subject { Solve::Constraint.new("> 1.0.0+build") }
|
293
305
|
|
306
|
+
it { should_not satisfies("0.9.9+build") }
|
307
|
+
it { should_not satisfies("1.0.0-alpha") }
|
308
|
+
it { should_not satisfies("1.0.0-alpha.2") }
|
309
|
+
it { should_not satisfies("1.0.0") }
|
310
|
+
it { should_not satisfies("1.0.0+build") }
|
311
|
+
it { should_not satisfies("1.0.1-beta") }
|
312
|
+
it { should satisfies("1.0.1") }
|
313
|
+
it { should satisfies("1.0.1+build.2") }
|
294
314
|
it { should satisfies("2.0.0") }
|
315
|
+
end
|
316
|
+
|
317
|
+
context "greater than or equal to (>) zero pre-release constraint" do
|
318
|
+
subject { Solve::Constraint.new("> 0.0.0-alpha") }
|
319
|
+
|
320
|
+
it { should satisfies("0.9.9+build") }
|
321
|
+
it { should satisfies("1.0.0-alpha") }
|
322
|
+
it { should satisfies("1.0.0-alpha.2") }
|
295
323
|
it { should satisfies("1.0.0") }
|
296
|
-
it {
|
324
|
+
it { should satisfies("1.0.0+build") }
|
325
|
+
it { should satisfies("1.0.1-beta") }
|
326
|
+
it { should satisfies("1.0.1") }
|
327
|
+
it { should satisfies("1.0.1+build.2") }
|
328
|
+
it { should satisfies("2.0.0") }
|
329
|
+
end
|
330
|
+
|
331
|
+
context "greater than or equal to (>) zero constraint" do
|
332
|
+
subject { Solve::Constraint.new("> 0.0.0") }
|
333
|
+
|
334
|
+
it { should satisfies("0.9.9+build") }
|
335
|
+
it { should satisfies("1.0.0-alpha") }
|
336
|
+
it { should satisfies("1.0.0-alpha.2") }
|
337
|
+
it { should satisfies("1.0.0") }
|
338
|
+
it { should satisfies("1.0.0+build") }
|
339
|
+
it { should satisfies("1.0.1-beta") }
|
340
|
+
it { should satisfies("1.0.1") }
|
341
|
+
it { should satisfies("1.0.1+build.2") }
|
342
|
+
it { should satisfies("2.0.0") }
|
343
|
+
end
|
344
|
+
|
345
|
+
context "greater than or equal to (>) zero build constraint" do
|
346
|
+
subject { Solve::Constraint.new("> 0.0.0+build") }
|
347
|
+
|
348
|
+
it { should satisfies("0.9.9+build") }
|
349
|
+
it { should satisfies("1.0.0-alpha") }
|
350
|
+
it { should satisfies("1.0.0-alpha.2") }
|
351
|
+
it { should satisfies("1.0.0") }
|
352
|
+
it { should satisfies("1.0.0+build") }
|
353
|
+
it { should satisfies("1.0.1-beta") }
|
354
|
+
it { should satisfies("1.0.1") }
|
355
|
+
it { should satisfies("1.0.1+build.2") }
|
356
|
+
it { should satisfies("2.0.0") }
|
357
|
+
end
|
358
|
+
|
359
|
+
context "strictly less than (<) pre-release constraint" do
|
360
|
+
subject { Solve::Constraint.new("< 1.0.0-alpha.3") }
|
361
|
+
|
362
|
+
it { should satisfies("0.9.9+build") }
|
363
|
+
it { should satisfies("1.0.0-alpha") }
|
364
|
+
it { should satisfies("1.0.0-alpha.2") }
|
365
|
+
it { should_not satisfies("1.0.0") }
|
366
|
+
it { should_not satisfies("1.0.0+build") }
|
367
|
+
it { should_not satisfies("1.0.1-beta") }
|
368
|
+
it { should_not satisfies("1.0.1") }
|
369
|
+
it { should_not satisfies("1.0.1+build.2") }
|
370
|
+
it { should_not satisfies("2.0.0") }
|
297
371
|
end
|
298
372
|
|
299
373
|
context "strictly less than (<)" do
|
374
|
+
subject { Solve::Constraint.new("< 1.0.0") }
|
375
|
+
|
376
|
+
it { should satisfies("0.9.9+build") }
|
377
|
+
it { should satisfies("1.0.0-alpha") }
|
378
|
+
it { should satisfies("1.0.0-alpha.2") }
|
379
|
+
it { should_not satisfies("1.0.0") }
|
380
|
+
it { should_not satisfies("1.0.0+build") }
|
381
|
+
it { should_not satisfies("1.0.1-beta") }
|
382
|
+
it { should_not satisfies("1.0.1") }
|
383
|
+
it { should_not satisfies("1.0.1+build.2") }
|
384
|
+
it { should_not satisfies("2.0.0") }
|
385
|
+
end
|
386
|
+
|
387
|
+
context "strictly less than (<) build constraint" do
|
300
388
|
subject { Solve::Constraint.new("< 1.0.0+build.20") }
|
301
389
|
|
302
|
-
it { should satisfies("0.
|
390
|
+
it { should satisfies("0.9.9+build") }
|
391
|
+
it { should satisfies("1.0.0-alpha") }
|
392
|
+
it { should satisfies("1.0.0-alpha.2") }
|
303
393
|
it { should satisfies("1.0.0") }
|
304
|
-
it {
|
394
|
+
it { should satisfies("1.0.0+build") }
|
395
|
+
it { should_not satisfies("1.0.1-beta") }
|
396
|
+
it { should_not satisfies("1.0.1") }
|
397
|
+
it { should_not satisfies("1.0.1+build.2") }
|
398
|
+
it { should_not satisfies("2.0.0") }
|
305
399
|
end
|
306
400
|
|
307
401
|
context "strictly equal to (=)" do
|
@@ -313,24 +407,129 @@ describe Solve::Constraint do
|
|
313
407
|
it { should_not satisfies("1.0.0-alpha") }
|
314
408
|
end
|
315
409
|
|
410
|
+
context "greater than or equal to (>=) pre-release constraint" do
|
411
|
+
subject { Solve::Constraint.new(">= 1.0.0-alpha") }
|
412
|
+
|
413
|
+
it { should_not satisfies("0.9.9+build") }
|
414
|
+
it { should satisfies("1.0.0-alpha") }
|
415
|
+
it { should satisfies("1.0.0-alpha.2") }
|
416
|
+
it { should satisfies("1.0.0") }
|
417
|
+
it { should satisfies("1.0.0+build") }
|
418
|
+
it { should satisfies("1.0.1-beta") }
|
419
|
+
it { should satisfies("1.0.1") }
|
420
|
+
it { should satisfies("1.0.1+build.2") }
|
421
|
+
it { should satisfies("2.0.0") }
|
422
|
+
end
|
423
|
+
|
316
424
|
context "greater than or equal to (>=)" do
|
317
425
|
subject { Solve::Constraint.new(">= 1.0.0") }
|
318
426
|
|
319
427
|
it { should_not satisfies("0.9.9+build") }
|
320
428
|
it { should_not satisfies("1.0.0-alpha") }
|
429
|
+
it { should_not satisfies("1.0.0-alpha.2") }
|
321
430
|
it { should satisfies("1.0.0") }
|
431
|
+
it { should satisfies("1.0.0+build") }
|
432
|
+
it { should_not satisfies("1.0.1-beta") }
|
322
433
|
it { should satisfies("1.0.1") }
|
434
|
+
it { should satisfies("1.0.1+build.2") }
|
323
435
|
it { should satisfies("2.0.0") }
|
324
436
|
end
|
325
437
|
|
326
|
-
context "greater than or equal to (
|
438
|
+
context "greater than or equal to (>=) build constraint" do
|
439
|
+
subject { Solve::Constraint.new(">= 1.0.0+build") }
|
440
|
+
|
441
|
+
it { should_not satisfies("0.9.9+build") }
|
442
|
+
it { should_not satisfies("1.0.0-alpha") }
|
443
|
+
it { should_not satisfies("1.0.0-alpha.2") }
|
444
|
+
it { should_not satisfies("1.0.0") }
|
445
|
+
it { should satisfies("1.0.0+build") }
|
446
|
+
it { should_not satisfies("1.0.1-beta") }
|
447
|
+
it { should satisfies("1.0.1") }
|
448
|
+
it { should satisfies("1.0.1+build.2") }
|
449
|
+
it { should satisfies("2.0.0") }
|
450
|
+
end
|
451
|
+
|
452
|
+
context "greater than or equal to (>=) zero pre-release constraint" do
|
453
|
+
subject { Solve::Constraint.new(">= 0.0.0-alpha") }
|
454
|
+
|
455
|
+
it { should satisfies("0.9.9+build") }
|
456
|
+
it { should satisfies("1.0.0-alpha") }
|
457
|
+
it { should satisfies("1.0.0-alpha.2") }
|
458
|
+
it { should satisfies("1.0.0") }
|
459
|
+
it { should satisfies("1.0.0+build") }
|
460
|
+
it { should satisfies("1.0.1-beta") }
|
461
|
+
it { should satisfies("1.0.1") }
|
462
|
+
it { should satisfies("1.0.1+build.2") }
|
463
|
+
it { should satisfies("2.0.0") }
|
464
|
+
end
|
465
|
+
|
466
|
+
context "greater than or equal to (>=) zero constraint" do
|
467
|
+
subject { Solve::Constraint.new(">= 0.0.0") }
|
468
|
+
|
469
|
+
it { should satisfies("0.9.9+build") }
|
470
|
+
it { should satisfies("1.0.0-alpha") }
|
471
|
+
it { should satisfies("1.0.0-alpha.2") }
|
472
|
+
it { should satisfies("1.0.0") }
|
473
|
+
it { should satisfies("1.0.0+build") }
|
474
|
+
it { should satisfies("1.0.1-beta") }
|
475
|
+
it { should satisfies("1.0.1") }
|
476
|
+
it { should satisfies("1.0.1+build.2") }
|
477
|
+
it { should satisfies("2.0.0") }
|
478
|
+
end
|
479
|
+
|
480
|
+
context "greater than or equal to (>=) zero build constraint" do
|
481
|
+
subject { Solve::Constraint.new(">= 0.0.0+build") }
|
482
|
+
|
483
|
+
it { should satisfies("0.9.9+build") }
|
484
|
+
it { should satisfies("1.0.0-alpha") }
|
485
|
+
it { should satisfies("1.0.0-alpha.2") }
|
486
|
+
it { should satisfies("1.0.0") }
|
487
|
+
it { should satisfies("1.0.0+build") }
|
488
|
+
it { should satisfies("1.0.1-beta") }
|
489
|
+
it { should satisfies("1.0.1") }
|
490
|
+
it { should satisfies("1.0.1+build.2") }
|
491
|
+
it { should satisfies("2.0.0") }
|
492
|
+
end
|
493
|
+
|
494
|
+
context "lower than or equal to (<=) pre-release constraint" do
|
327
495
|
subject { Solve::Constraint.new("<= 1.0.0") }
|
328
496
|
|
329
497
|
it { should satisfies("0.9.9+build") }
|
330
|
-
it {
|
498
|
+
it { should satisfies("1.0.0-alpha") }
|
499
|
+
it { should satisfies("1.0.0-alpha.2") }
|
331
500
|
it { should satisfies("1.0.0") }
|
332
501
|
it { should_not satisfies("1.0.0+build") }
|
502
|
+
it { should_not satisfies("1.0.1-beta") }
|
503
|
+
it { should_not satisfies("1.0.1") }
|
504
|
+
it { should_not satisfies("1.0.1+build.2") }
|
505
|
+
it { should_not satisfies("2.0.0") }
|
506
|
+
end
|
507
|
+
|
508
|
+
context "lower than or equal to (<=)" do
|
509
|
+
subject { Solve::Constraint.new("<= 1.0.0-alpha") }
|
510
|
+
|
511
|
+
it { should satisfies("0.9.9+build") }
|
512
|
+
it { should satisfies("1.0.0-alpha") }
|
513
|
+
it { should_not satisfies("1.0.0-alpha.2") }
|
514
|
+
it { should_not satisfies("1.0.0") }
|
515
|
+
it { should_not satisfies("1.0.0+build") }
|
516
|
+
it { should_not satisfies("1.0.1-beta") }
|
517
|
+
it { should_not satisfies("1.0.1") }
|
518
|
+
it { should_not satisfies("1.0.1+build.2") }
|
519
|
+
it { should_not satisfies("2.0.0") }
|
520
|
+
end
|
521
|
+
|
522
|
+
context "lower than or equal to (<=) build constraint" do
|
523
|
+
subject { Solve::Constraint.new("<= 1.0.0+build") }
|
524
|
+
|
525
|
+
it { should satisfies("0.9.9+build") }
|
526
|
+
it { should satisfies("1.0.0-alpha") }
|
527
|
+
it { should satisfies("1.0.0-alpha.2") }
|
528
|
+
it { should satisfies("1.0.0") }
|
529
|
+
it { should satisfies("1.0.0+build") }
|
530
|
+
it { should_not satisfies("1.0.1-beta") }
|
333
531
|
it { should_not satisfies("1.0.1") }
|
532
|
+
it { should_not satisfies("1.0.1+build.2") }
|
334
533
|
it { should_not satisfies("2.0.0") }
|
335
534
|
end
|
336
535
|
|
@@ -294,6 +294,28 @@ describe Solve::Version do
|
|
294
294
|
end
|
295
295
|
end
|
296
296
|
|
297
|
+
describe "#zero?" do
|
298
|
+
context "major, minor and patch are equal to 0" do
|
299
|
+
subject { described_class.new("0.0.0").zero? }
|
300
|
+
it { should be_true }
|
301
|
+
end
|
302
|
+
|
303
|
+
context "major is not equal to 0" do
|
304
|
+
subject { described_class.new("1.0.0").zero? }
|
305
|
+
it { should be_false }
|
306
|
+
end
|
307
|
+
|
308
|
+
context "minor is not equal to 0" do
|
309
|
+
subject { described_class.new("0.1.0").zero? }
|
310
|
+
it { should be_false }
|
311
|
+
end
|
312
|
+
|
313
|
+
context "patch is not equal to 0" do
|
314
|
+
subject { described_class.new("0.0.1").zero? }
|
315
|
+
it { should be_false }
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
297
319
|
describe "#to_s" do
|
298
320
|
subject { Solve::Version.new("1.0.0-rc.1+build.1") }
|
299
321
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solve
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2013-06-
|
14
|
+
date: 2013-06-27 00:00:00.000000000 Z
|
15
15
|
dependencies: []
|
16
16
|
description: A Ruby version constraint solver
|
17
17
|
email:
|
@@ -78,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
78
|
version: '0'
|
79
79
|
segments:
|
80
80
|
- 0
|
81
|
-
hash:
|
81
|
+
hash: 682127496261768650
|
82
82
|
requirements: []
|
83
83
|
rubyforge_project:
|
84
84
|
rubygems_version: 1.8.23
|