semantic 1.6.0 → 1.6.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6b0d05c7bf684f53e2868af8b7ef4d10b4e32147
4
- data.tar.gz: 2b056bdd6e59fd70c009ec240a486eecc1be6ce4
3
+ metadata.gz: 49f4f8185e5b08f5e55c52e84b9e97514734e773
4
+ data.tar.gz: d0348d4f5c518868f35a68fc17730e65b6b19a41
5
5
  SHA512:
6
- metadata.gz: 20af7df4c207994a636249361d917e84cd63429c1e2423a53899632bc8fcd65ebdc89c6f785ab2476260db2bac94f35cdb7809687af0b2bd76705fb9a955398e
7
- data.tar.gz: 442ba8444462357df0fe5e40baef7225de789da8c518c1309d521e89f5d83b0eb5890871828f859945695c1ec77c77d0b00b456c6249a252260c4c244d402211
6
+ metadata.gz: e8b5397c167716fec08c08c156cd83adc8feaf97865311cd761bc344dfbeac4dc88aad60c2b4b771e4e69ffae217bdefd875715d05222ea6a486f01fb516419e
7
+ data.tar.gz: 4ac7c975674f02f07cbffbd5829532305f998ce74922866a413d6182041cf2cad3e0b8272d3546cab7793752657b1a60d026db175408f69a91411e70a290c7e3
data/README.md CHANGED
@@ -27,6 +27,21 @@ newer_version <=> version # => 1
27
27
  complex_version = Semantic::Version.new '3.7.9-pre.1+revision.15723'
28
28
  complex_version.pre # => "pre.1"
29
29
  complex_version.build # => "revision.15623"
30
+
31
+ # semantic supports Pessimistic Operator
32
+ version.satisfies? '~> 1.5' # => true
33
+ version.satisfies? '~> 1.6.0' # => true
34
+
35
+ # incrementing version numbers
36
+ version = Semantic::Version.new('0.1.0')
37
+ new_version = version.increment!(:major) # 1.1.0
38
+ new_version = version.increment!(:minor) # 0.2.0
39
+ new_version = version.increment!(:patch) # 0.1.1
40
+
41
+ new_version = verstion.major! # 1.1.0
42
+ new_version = verstion.minor! # 0.2.0
43
+ new_version = verstion.patch! # 0.1.1
44
+ # (note: increment! & friends return a copy and leave the original unchanged)
30
45
  ```
31
46
 
32
47
  There is also a set of core extensions as an optional require:
@@ -1,4 +1,4 @@
1
1
  module Semantic
2
- GEM_VERSION = '1.6.0'
2
+ GEM_VERSION = '1.6.1'
3
3
  autoload :Version, 'semantic/version'
4
4
  end
@@ -2,4 +2,8 @@ class String
2
2
  def to_version
3
3
  Semantic::Version.new self
4
4
  end
5
+
6
+ def is_version?
7
+ (match Semantic::Version::SemVerRegexp) ? true : false
8
+ end
5
9
  end
@@ -6,7 +6,8 @@ module Semantic
6
6
  SemVerRegexp = /\A(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][a-zA-Z0-9-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][a-zA-Z0-9-]*))*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?\Z/
7
7
 
8
8
 
9
- attr_accessor :major, :minor, :patch, :pre, :build
9
+ attr_accessor :major, :minor, :patch, :pre
10
+ attr_reader :build
10
11
 
11
12
  def initialize version_str
12
13
  v = version_str.match(SemVerRegexp)
@@ -26,7 +27,7 @@ module Semantic
26
27
  end
27
28
 
28
29
  def identifiers(pre)
29
- array = pre.split(".")
30
+ array = pre.split(/[\.\-]/)
30
31
  array.each_with_index {|e,i| array[i] = Integer(e) if /\A\d+\z/.match(e)}
31
32
  return array
32
33
  end
@@ -43,5 +43,21 @@ describe 'Core Extensions' do
43
43
  )
44
44
  end
45
45
  end
46
+
47
+ it 'extends String with a #is_version? method' do
48
+ expect('').to respond_to(:is_version?)
49
+ end
50
+
51
+ it 'detects valid semantic version strings' do
52
+ @test_versions.each do |v|
53
+ expect(v.is_version?).to be true
54
+ end
55
+ end
56
+
57
+ it 'detects invalid semantic version strings' do
58
+ @bad_versions.each do |v|
59
+ expect(v.is_version?).to be false
60
+ end
61
+ end
46
62
  end
47
63
  end
@@ -87,6 +87,9 @@ describe Semantic::Version do
87
87
  @v1_5_9_pre_1 = Semantic::Version.new '1.5.9-pre.1'
88
88
  @v1_5_9_pre_1_build_5127 = Semantic::Version.new '1.5.9-pre.1+build.5127'
89
89
  @v1_5_9_pre_1_build_4352 = Semantic::Version.new '1.5.9-pre.1+build.4352'
90
+ # more pre syntax testing: "-"
91
+ @v3_13_0_75_generic = Semantic::Version.new '3.13.0-75-generic'
92
+ @v3_13_0_141_generic = Semantic::Version.new '3.13.0-141-generic'
90
93
 
91
94
  @v1_5_9 = Semantic::Version.new '1.5.9'
92
95
  @v1_6_0 = Semantic::Version.new '1.6.0'
@@ -132,6 +135,14 @@ describe Semantic::Version do
132
135
  expect(ary.shuffle.sort).to eq(ary)
133
136
  end
134
137
 
138
+ it 'determine alternate char sep works in pre' do
139
+ expect((@v3_13_0_75_generic <=> @v3_13_0_141_generic.to_s)).to eq(-1)
140
+ expect((@v3_13_0_75_generic <=> @v3_13_0_141_generic)).to eq(-1)
141
+ expect((@v3_13_0_75_generic <=> '3.13.0-75-generic')).to eq(0)
142
+ expect((@v3_13_0_75_generic <=> '3.13.0-141-generic')).to eq(-1)
143
+ expect((@v3_13_0_141_generic <=> '3.13.0-75-generic')).to eq(1)
144
+ end
145
+
135
146
  it 'determines whether it is greater than another instance' do
136
147
  # These should be equal, since "Build metadata SHOULD be ignored
137
148
  # when determining version precedence".
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: semantic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Lindsey
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-09 00:00:00.000000000 Z
11
+ date: 2018-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -74,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
74
  version: '0'
75
75
  requirements: []
76
76
  rubyforge_project:
77
- rubygems_version: 2.5.1
77
+ rubygems_version: 2.6.13
78
78
  signing_key:
79
79
  specification_version: 4
80
80
  summary: Semantic Version utility class