Skip to content

Commit

Permalink
adding - as a legal seperator in identifier section
Browse files Browse the repository at this point in the history
  • Loading branch information
Clayton Han-Mitchell committed Jan 29, 2018
1 parent d6d4a82 commit 2f0c110
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/semantic/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,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
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 2f0c110

Please sign in to comment.