Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for specifying a prerelease that is prefixed with a dash. #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/versionomy/format_definitions/semver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@ def self.create
end

# The optional prerelease field is represented as a string
# beginning with an alphabetic character.
# beginning with an alphabetic character or a dash.
field(:prerelease_suffix) do
recognize_regexp('[a-zA-Z][0-9a-zA-Z-]*', :default_value_optional => true,
:delimiter_regexp => '', :default_delimiter => '')
recognize_regexp('[a-zA-Z][0-9a-zA-Z\-]*', :default_value_optional => true,
:delimiter_regexp => '\-?', :default_delimiter => '')
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/tc_rubygems_basic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

require 'test/unit'
require 'versionomy'

require 'yaml'

module Versionomy
module Tests # :nodoc:
Expand Down
9 changes: 8 additions & 1 deletion test/tc_semver_basic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

require 'test/unit'
require 'versionomy'

require 'yaml'

module Versionomy
module Tests # :nodoc:
Expand Down Expand Up @@ -130,6 +130,13 @@ def test_parsing_with_string
assert_equal('1.9.2pre2', value_.unparse)
end

# Test parsing with a string with a prerelease prefixed by a dash.

def test_parsing_with_string_with_prerelease_prefixed_by_dash
value_ = ::Versionomy.parse('1.9.2-pre2-1', :semver)
assert_equal([1, 9, 2, 'pre2-1'], value_.values_array)
assert_equal('1.9.2-pre2-1', value_.unparse)
end

# Test making sure unparsing requires all three fields.

Expand Down
2 changes: 1 addition & 1 deletion test/tc_standard_misc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

require 'test/unit'
require 'versionomy'

require 'yaml'

module Versionomy
module Tests # :nodoc:
Expand Down