semantic_puppet 0.1.3 → 1.0.3

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.
@@ -9,6 +9,14 @@ describe SemanticPuppet::Version do
9
9
 
10
10
  describe '.parse' do
11
11
 
12
+ let(:parse_failure) do
13
+ /Unable to parse .* as a semantic version identifier/
14
+ end
15
+
16
+ let(:no_leading_zeroes) do
17
+ 'Numeric pre-release identifiers MUST NOT contain leading zeroes'
18
+ end
19
+
12
20
  context 'Spec v2.0.0' do
13
21
  context 'Section 2' do
14
22
  # A normal version number MUST take the form X.Y.Z where X, Y, and Z are
@@ -17,10 +25,6 @@ describe SemanticPuppet::Version do
17
25
  # Each element MUST increase numerically.
18
26
  # For instance: 1.9.0 -> 1.10.0 -> 1.11.0.
19
27
 
20
- let(:parse_failure) do
21
- /Unable to parse .* as a semantic version identifier/
22
- end
23
-
24
28
  it 'rejects versions that contain too few parts' do
25
29
  expect { subject('1.2') }.to raise_error(parse_failure)
26
30
  end
@@ -89,31 +93,19 @@ describe SemanticPuppet::Version do
89
93
  # by its associated normal version.
90
94
  # Examples: 1.0.0-alpha, 1.0.0-alpha.1, 1.0.0-0.3.7, 1.0.0-x.7.z.92.
91
95
 
92
- let(:restricted_charset) do
93
- 'Prerelease identifiers MUST use only ASCII alphanumerics and hyphens'
94
- end
95
-
96
- let(:must_not_be_empty) do
97
- 'Prerelease identifiers MUST NOT be empty'
98
- end
99
-
100
- let(:no_leading_zeroes) do
101
- 'Prerelease identifiers MUST NOT contain leading zeroes'
102
- end
103
-
104
96
  it 'rejects prerelease identifiers with non-alphanumerics' do
105
- expect { subject('1.2.3-$100') }.to raise_error(restricted_charset)
106
- expect { subject('1.2.3-rc.1@me') }.to raise_error(restricted_charset)
97
+ expect { subject('1.2.3-$100') }.to raise_error(parse_failure)
98
+ expect { subject('1.2.3-rc.1@me') }.to raise_error(parse_failure)
107
99
  end
108
100
 
109
101
  it 'rejects empty prerelease versions' do
110
- expect { subject('1.2.3-') }.to raise_error(must_not_be_empty)
102
+ expect { subject('1.2.3-') }.to raise_error(parse_failure)
111
103
  end
112
104
 
113
105
  it 'rejects empty prerelease version identifiers' do
114
- expect { subject('1.2.3-.rc1') }.to raise_error(must_not_be_empty)
115
- expect { subject('1.2.3-rc1.') }.to raise_error(must_not_be_empty)
116
- expect { subject('1.2.3-rc..1') }.to raise_error(must_not_be_empty)
106
+ expect { subject('1.2.3-.rc1') }.to raise_error(parse_failure)
107
+ expect { subject('1.2.3-rc1.') }.to raise_error(parse_failure)
108
+ expect { subject('1.2.3-rc..1') }.to raise_error(parse_failure)
117
109
  end
118
110
 
119
111
  it 'rejects numeric prerelease identifiers with leading zeroes' do
@@ -167,14 +159,6 @@ describe SemanticPuppet::Version do
167
159
  end
168
160
 
169
161
  context 'Section 10' do
170
- # Build metadata is not yet in scope so
171
- it 'rejects build identifiers' do
172
- ver = '1.2.3+anything'
173
- expect { subject(ver) }.to raise_error("'#{ver}' MUST NOT include build identifiers")
174
- end
175
- end
176
-
177
- context 'Section 10', :pending => "build metadata is not yet in scope" do
178
162
  # Build metadata MAY be denoted by appending a plus sign and a series
179
163
  # of dot separated identifiers immediately following the patch or
180
164
  # pre-release version. Identifiers MUST comprise only ASCII
@@ -185,28 +169,19 @@ describe SemanticPuppet::Version do
185
169
  # Examples: 1.0.0-alpha+001, 1.0.0+20130313144700,
186
170
  # 1.0.0-beta+exp.sha.5114f85.
187
171
 
188
-
189
- let(:restricted_charset) do
190
- 'Build identifiers MUST use only ASCII alphanumerics and hyphens'
191
- end
192
-
193
- let(:must_not_be_empty) do
194
- 'Build identifiers MUST NOT be empty'
195
- end
196
-
197
172
  it 'rejects build identifiers with non-alphanumerics' do
198
- expect { subject('1.2.3+$100') }.to raise_error(restricted_charset)
199
- expect { subject('1.2.3+rc.1@me') }.to raise_error(restricted_charset)
173
+ expect { subject('1.2.3+$100') }.to raise_error(parse_failure)
174
+ expect { subject('1.2.3+rc.1@me') }.to raise_error(parse_failure)
200
175
  end
201
176
 
202
177
  it 'rejects empty build metadata' do
203
- expect { subject('1.2.3+') }.to raise_error(must_not_be_empty)
178
+ expect { subject('1.2.3+') }.to raise_error(parse_failure)
204
179
  end
205
180
 
206
181
  it 'rejects empty build identifiers' do
207
- expect { subject('1.2.3+.rc1') }.to raise_error(must_not_be_empty)
208
- expect { subject('1.2.3+rc1.') }.to raise_error(must_not_be_empty)
209
- expect { subject('1.2.3+rc..1') }.to raise_error(must_not_be_empty)
182
+ expect { subject('1.2.3+.rc1') }.to raise_error(parse_failure)
183
+ expect { subject('1.2.3+rc1.') }.to raise_error(parse_failure)
184
+ expect { subject('1.2.3+rc..1') }.to raise_error(parse_failure)
210
185
  end
211
186
 
212
187
  it 'permits numeric build identifiers with leading zeroes' do
@@ -263,10 +238,6 @@ describe SemanticPuppet::Version do
263
238
  # increments of one.
264
239
  # For instance: 1.9.0 -> 1.10.0 -> 1.11.0
265
240
 
266
- let(:parse_failure) do
267
- /Unable to parse .* as a semantic version identifier/
268
- end
269
-
270
241
  it 'rejects versions that contain too few parts' do
271
242
  expect { subject('1.2') }.to raise_error(parse_failure)
272
243
  end
@@ -320,25 +291,13 @@ describe SemanticPuppet::Version do
320
291
  # lexicographic ASCII sort order.
321
292
  # For instance: 1.0.0-alpha1 < 1.0.0-beta1 < 1.0.0-beta2 < 1.0.0-rc1
322
293
 
323
- let(:restricted_charset) do
324
- 'Prerelease identifiers MUST use only ASCII alphanumerics and hyphens'
325
- end
326
-
327
- let(:must_not_be_empty) do
328
- 'Prerelease identifiers MUST NOT be empty'
329
- end
330
-
331
- let(:no_leading_zeroes) do
332
- 'Prerelease identifiers MUST NOT contain leading zeroes'
333
- end
334
-
335
294
  it 'rejects prerelease identifiers with non-alphanumerics' do
336
- expect { subject('1.2.3-$100') }.to raise_error(restricted_charset)
337
- expect { subject('1.2.3-rc.1@me') }.to raise_error(restricted_charset)
295
+ expect { subject('1.2.3-$100') }.to raise_error(parse_failure)
296
+ expect { subject('1.2.3-rc.1@me') }.to raise_error(parse_failure)
338
297
  end
339
298
 
340
299
  it 'rejects empty prerelease versions' do
341
- expect { subject('1.2.3-') }.to raise_error(must_not_be_empty)
300
+ expect { subject('1.2.3-') }.to raise_error(parse_failure)
342
301
  end
343
302
 
344
303
  it 'rejects numeric prerelease identifiers with leading zeroes' do
@@ -392,22 +351,199 @@ describe SemanticPuppet::Version do
392
351
  end
393
352
 
394
353
  describe '.valid?' do
395
- # All the specific variations are tested in the .parse tests, so these are just basic
396
- # smoke tests.
397
-
398
354
  def subject(str)
399
355
  SemanticPuppet::Version.valid?(str)
400
356
  end
401
357
 
402
- it 'recognizes valid versions' do
403
- expect(subject('1.0.1')).to be true
404
- expect(subject('1.0.3-p324')).to be true
358
+ context 'Spec v2.0.0' do
359
+ context 'Section 2' do
360
+ # A normal version number MUST take the form X.Y.Z where X, Y, and Z are
361
+ # non-negative integers, and MUST NOT contain leading zeroes. X is the
362
+ # major version, Y is the minor version, and Z is the patch version.
363
+
364
+ it 'rejects versions that contain too few parts' do
365
+ expect(subject('1.2')).to be false
366
+ end
367
+
368
+ it 'rejects versions that contain too many parts' do
369
+ expect(subject('1.2.3.4')).to be false
370
+ end
371
+
372
+ it 'rejects versions that contain non-integers' do
373
+ expect(subject('x.2.3')).to be false
374
+ expect(subject('1.y.3')).to be false
375
+ expect(subject('1.2.z')).to be false
376
+ end
377
+
378
+ it 'rejects versions that contain negative integers' do
379
+ expect(subject('-1.2.3')).to be false
380
+ expect(subject('1.-2.3')).to be false
381
+ expect(subject('1.2.-3')).to be false
382
+ end
383
+
384
+ it 'rejects version numbers containing leading zeroes' do
385
+ expect(subject('01.2.3')).to be false
386
+ expect(subject('1.02.3')).to be false
387
+ expect(subject('1.2.03')).to be false
388
+ end
389
+
390
+ it 'permits zeroes in version number parts' do
391
+ expect(subject('0.2.3')).to be true
392
+ expect(subject('1.0.3')).to be true
393
+ expect(subject('1.2.0')).to be true
394
+ end
395
+ end
396
+
397
+ context 'Section 9' do
398
+ # A pre-release version MAY be denoted by appending a hyphen and a
399
+ # series of dot separated identifiers immediately following the patch
400
+ # version. Identifiers MUST comprise only ASCII alphanumerics and
401
+ # hyphen [0-9A-Za-z-]. Identifiers MUST NOT be empty. Numeric
402
+ # identifiers MUST NOT include leading zeroes. Pre-release versions
403
+ # have a lower precedence than the associated normal version. A
404
+ # pre-release version indicates that the version is unstable and
405
+ # might not satisfy the intended compatibility requirements as denoted
406
+ # by its associated normal version.
407
+ # Examples: 1.0.0-alpha, 1.0.0-alpha.1, 1.0.0-0.3.7, 1.0.0-x.7.z.92.
408
+
409
+ it 'rejects prerelease identifiers with non-alphanumerics' do
410
+ expect(subject('1.2.3-$100')).to be false
411
+ expect(subject('1.2.3-rc.1@me')).to be false
412
+ end
413
+
414
+ it 'rejects empty prerelease versions' do
415
+ expect(subject('1.2.3-')).to be false
416
+ end
417
+
418
+ it 'rejects empty prerelease version identifiers' do
419
+ expect(subject('1.2.3-.rc1')).to be false
420
+ expect(subject('1.2.3-rc1.')).to be false
421
+ expect(subject('1.2.3-rc..1')).to be false
422
+ end
423
+
424
+ it 'rejects numeric prerelease identifiers with leading zeroes' do
425
+ expect(subject('1.2.3-01')).to be false
426
+ expect(subject('1.2.3-rc.01')).to be false
427
+ end
428
+
429
+ it 'permits numeric prerelease identifiers of zero' do
430
+ expect(subject('1.2.3-0')).to be true
431
+ expect(subject('1.2.3-rc.0')).to be true
432
+ end
433
+
434
+ it 'permits non-numeric prerelease identifiers' do
435
+ expect(subject('1.2.3-DEADBEEF')).to be true
436
+ expect(subject('1.2.3-DE.AD.BE.EF')).to be true
437
+ expect(subject('2.1.0-12-BE-EF')).to be true
438
+ end
439
+
440
+ it 'permits non-numeric prerelease identifiers with leading zeroes' do
441
+ expect(subject('1.2.3-0xDEADBEEF')).to be true
442
+ expect(subject('1.2.3-rc.0x10c')).to be true
443
+ expect(subject('2.1.0-0016-13fae4a9')).to be true
444
+ end
445
+ end
446
+
447
+ context 'Section 10' do
448
+ # Build metadata MAY be denoted by appending a plus sign and a series
449
+ # of dot separated identifiers immediately following the patch or
450
+ # pre-release version. Identifiers MUST comprise only ASCII
451
+ # alphanumerics and hyphen [0-9A-Za-z-]. Identifiers MUST NOT be empty.
452
+ # Build metadata SHOULD be ignored when determining version precedence.
453
+ # Thus two versions that differ only in the build metadata, have the
454
+ # same precedence.
455
+ # Examples: 1.0.0-alpha+001, 1.0.0+20130313144700,
456
+ # 1.0.0-beta+exp.sha.5114f85.
457
+
458
+ it 'rejects build identifiers with non-alphanumerics' do
459
+ expect(subject('1.2.3+$100')).to be false
460
+ expect(subject('1.2.3+rc.1@me')).to be false
461
+ end
462
+
463
+ it 'rejects empty build metadata' do
464
+ expect(subject('1.2.3+')).to be false
465
+ end
466
+
467
+ it 'rejects empty build identifiers' do
468
+ expect(subject('1.2.3+.rc1')).to be false
469
+ expect(subject('1.2.3+rc1.')).to be false
470
+ expect(subject('1.2.3+rc..1')).to be false
471
+ end
472
+
473
+ it 'permits numeric build identifiers with leading zeroes' do
474
+ expect(subject('1.2.3+01')).to be true
475
+ expect(subject('1.2.3+rc.01')).to be true
476
+ end
477
+
478
+ it 'permits numeric build identifiers of zero' do
479
+ expect(subject('1.2.3+0')).to be true
480
+ expect(subject('1.2.3+rc.0')).to be true
481
+ end
482
+
483
+ it 'permits non-numeric build identifiers with leading zeroes' do
484
+ expect(subject('1.2.3+0xDEADBEEF')).to be true
485
+ expect(subject('1.2.3+rc.0x10c')).to be true
486
+ end
487
+ end
405
488
  end
406
489
 
407
- it 'does not recognize invalid versions' do
408
- expect(subject('1.0')).to be false # too few segments
409
- expect(subject('1.0.3.6')).to be false # too many segments
410
- expect(subject('1.03.14')).to be false # leading zero in segment
490
+ context 'Spec v1.0.0' do
491
+ context 'Section 2' do
492
+ # A normal version number MUST take the form X.Y.Z where X, Y, and Z
493
+ # are integers. X is the major version, Y is the minor version, and Z
494
+ # is the patch version.
495
+
496
+ it 'rejects versions that contain too few parts' do
497
+ expect(subject('1.2')).to be false
498
+ end
499
+
500
+ it 'rejects versions that contain too many parts' do
501
+ expect(subject('1.2.3.4')).to be false
502
+ end
503
+
504
+ it 'rejects versions that contain non-integers' do
505
+ expect(subject('x.2.3')).to be false
506
+ expect(subject('1.y.3')).to be false
507
+ expect(subject('1.2.z')).to be false
508
+ end
509
+
510
+ it 'permits zeroes in version number parts' do
511
+ expect(subject('0.2.3')).to be true
512
+ expect(subject('1.0.3')).to be true
513
+ expect(subject('1.2.0')).to be true
514
+ end
515
+ end
516
+
517
+ context 'Section 4' do
518
+ # A pre-release version number MAY be denoted by appending an arbitrary
519
+ # string immediately following the patch version and a dash. The string
520
+ # MUST be comprised of only alphanumerics plus dash [0-9A-Za-z-].
521
+ # Pre-release versions satisfy but have a lower precedence than the
522
+ # associated normal version. Precedence SHOULD be determined by
523
+ # lexicographic ASCII sort order.
524
+ # For instance: 1.0.0-alpha1 < 1.0.0-beta1 < 1.0.0-beta2 < 1.0.0-rc1
525
+
526
+ it 'rejects prerelease identifiers with non-alphanumerics' do
527
+ expect(subject('1.2.3-$100')).to be false
528
+ expect(subject('1.2.3-rc.1@me')).to be false
529
+ end
530
+
531
+ it 'rejects empty prerelease versions' do
532
+ expect(subject('1.2.3-')).to be false
533
+ end
534
+
535
+ it 'rejects numeric prerelease identifiers with leading zeroes' do
536
+ expect(subject('1.2.3-01')).to be false
537
+ end
538
+
539
+ it 'permits numeric prerelease identifiers of zero' do
540
+ expect(subject('1.2.3-0')).to be true
541
+ end
542
+
543
+ it 'permits non-numeric prerelease identifiers with leading zeroes' do
544
+ expect(subject('1.2.3-0xDEADBEEF')).to be true
545
+ end
546
+ end
411
547
  end
412
548
  end
413
549
 
@@ -540,14 +676,19 @@ describe SemanticPuppet::Version do
540
676
  expect(b).to be > a
541
677
  end
542
678
 
543
- example 'build metadata does not figure into precendence' do
544
- pending 'build metadata is not yet in scope'
679
+ example 'build metadata does figure into equality' do
545
680
  a = parse('1.0.0-alpha+SHA1')
546
681
  b = parse('1.0.0-alpha+MD5')
547
- expect(a).to eql b
682
+ expect(a).not_to eql b
548
683
  expect(a.to_s).to_not eql b.to_s
549
684
  end
550
685
 
686
+ example 'build metadata does not figure into precendence' do
687
+ a = parse('1.0.0-alpha+SHA1')
688
+ b = parse('1.0.0-alpha+MD5')
689
+ expect(a <=> b).to eql(0)
690
+ end
691
+
551
692
  example 'sorted order' do
552
693
  list = %w[
553
694
  1.0.0-alpha
@@ -631,7 +772,6 @@ describe SemanticPuppet::Version do
631
772
  end
632
773
 
633
774
  it 'removes any build information' do
634
- pending 'build metadata is not yet in scope'
635
775
  expect(subject('1.0.0+abc').next(:major)).to eql(subject('2.0.0'))
636
776
  end
637
777
  end
@@ -656,7 +796,6 @@ describe SemanticPuppet::Version do
656
796
  end
657
797
 
658
798
  it 'removes any build information' do
659
- pending 'build metadata is not yet in scope'
660
799
  expect(subject('1.1.0+abc').next(:minor)).to eql(subject('1.2.0'))
661
800
  end
662
801
  end
@@ -677,7 +816,6 @@ describe SemanticPuppet::Version do
677
816
  end
678
817
 
679
818
  it 'removes any build information' do
680
- pending 'build metadata is not yet in scope'
681
819
  expect(subject('1.0.0+abc').next(:patch)).to eql(subject('1.0.1'))
682
820
  end
683
821
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: semantic_puppet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet Labs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-24 00:00:00.000000000 Z
11
+ date: 2021-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -103,12 +103,16 @@ extensions: []
103
103
  extra_rdoc_files: []
104
104
  files:
105
105
  - ".gitignore"
106
+ - ".rubocop.yml"
107
+ - ".travis.yml"
106
108
  - ".yardopts"
107
109
  - CHANGELOG.md
110
+ - CODEOWNERS
108
111
  - Gemfile
109
112
  - LICENSE
110
113
  - README.md
111
114
  - Rakefile
115
+ - appveyor.yml
112
116
  - lib/semantic_puppet.rb
113
117
  - lib/semantic_puppet/dependency.rb
114
118
  - lib/semantic_puppet/dependency/graph.rb
@@ -116,6 +120,7 @@ files:
116
120
  - lib/semantic_puppet/dependency/module_release.rb
117
121
  - lib/semantic_puppet/dependency/source.rb
118
122
  - lib/semantic_puppet/dependency/unsatisfiable_graph.rb
123
+ - lib/semantic_puppet/gem_version.rb
119
124
  - lib/semantic_puppet/version.rb
120
125
  - lib/semantic_puppet/version_range.rb
121
126
  - semantic_puppet.gemspec
@@ -140,17 +145,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
140
145
  requirements:
141
146
  - - ">="
142
147
  - !ruby/object:Gem::Version
143
- version: 1.8.7
148
+ version: 1.9.3
144
149
  required_rubygems_version: !ruby/object:Gem::Requirement
145
150
  requirements:
146
151
  - - ">="
147
152
  - !ruby/object:Gem::Version
148
153
  version: '0'
149
154
  requirements: []
150
- rubyforge_project:
151
- rubygems_version: 2.4.5.1
155
+ rubygems_version: 3.0.8
152
156
  signing_key:
153
157
  specification_version: 4
154
158
  summary: Useful tools for working with Semantic Versions.
155
159
  test_files: []
156
- has_rdoc: