Skip to content

Commit

Permalink
Merge pull request #32 from hammer2j2/master
Browse files Browse the repository at this point in the history
adding "-" as a legal seperator in identifiers section
  • Loading branch information
jlindsey authored Feb 14, 2018
2 parents 3039c16 + 4a4f9d9 commit ee9d331
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/semantic.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Semantic
GEM_VERSION = '1.6.0'
GEM_VERSION = '1.6.1'
autoload :Version, 'semantic/version'
end
2 changes: 1 addition & 1 deletion lib/semantic/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def build=(b)
end

def identifiers(pre)
array = pre.split(".")
array = pre.split(/[\.\-]/)
array.each_with_index {|e,i| array[i] = Integer(e) if /\A\d+\z/.match(e)}
return array
end
Expand Down
Binary file added semantic-1.6.1.gem
Binary file not shown.
11 changes: 11 additions & 0 deletions spec/version_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@
@v1_5_9_pre_1 = Semantic::Version.new '1.5.9-pre.1'
@v1_5_9_pre_1_build_5127 = Semantic::Version.new '1.5.9-pre.1+build.5127'
@v1_5_9_pre_1_build_4352 = Semantic::Version.new '1.5.9-pre.1+build.4352'
# more pre syntax testing: "-"
@v3_13_0_75_generic = Semantic::Version.new '3.13.0-75-generic'
@v3_13_0_141_generic = Semantic::Version.new '3.13.0-141-generic'

@v1_5_9 = Semantic::Version.new '1.5.9'
@v1_6_0 = Semantic::Version.new '1.6.0'
Expand Down Expand Up @@ -132,6 +135,14 @@
expect(ary.shuffle.sort).to eq(ary)
end

it 'determine alternate char sep works in pre' do
expect((@v3_13_0_75_generic <=> @v3_13_0_141_generic.to_s)).to eq(-1)
expect((@v3_13_0_75_generic <=> @v3_13_0_141_generic)).to eq(-1)
expect((@v3_13_0_75_generic <=> '3.13.0-75-generic')).to eq(0)
expect((@v3_13_0_75_generic <=> '3.13.0-141-generic')).to eq(-1)
expect((@v3_13_0_141_generic <=> '3.13.0-75-generic')).to eq(1)
end

it 'determines whether it is greater than another instance' do
# These should be equal, since "Build metadata SHOULD be ignored
# when determining version precedence".
Expand Down

0 comments on commit ee9d331

Please sign in to comment.