versionomy 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +7 -0
- data/README.rdoc +4 -4
- data/Rakefile +20 -4
- data/lib/versionomy/errors.rb +9 -2
- data/lib/versionomy/format/base.rb +2 -0
- data/lib/versionomy/formats.rb +10 -2
- data/lib/versionomy/interface.rb +45 -12
- data/lib/versionomy/version.rb +3 -3
- metadata +2 -2
data/History.rdoc
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
=== 0.1.1 / 2009-10-19
|
2
|
+
|
3
|
+
* Formats can now be specified by name in the convenience interface.
|
4
|
+
* FormatRedefinedError no longer subclasses FormatCreationError.
|
5
|
+
* Some documentation updates.
|
6
|
+
* Rakefile updates for publishing to rubyforge and gemcutter.
|
7
|
+
|
1
8
|
=== 0.1.0 / 2009-10-14
|
2
9
|
|
3
10
|
* Alpha release, opened for public feedback
|
data/README.rdoc
CHANGED
@@ -86,7 +86,7 @@ semantics for comparing, parsing, and modifying version numbers.
|
|
86
86
|
|
87
87
|
=== Requirements
|
88
88
|
|
89
|
-
* Ruby 1.8.6 or later, Ruby 1.9.1 or later, or JRuby 1.4 or later.
|
89
|
+
* Ruby 1.8.6 or later (1.8.7 recommended), Ruby 1.9.1 or later, or JRuby 1.4 or later.
|
90
90
|
* blockenspiel gem.
|
91
91
|
|
92
92
|
=== Installation
|
@@ -101,11 +101,11 @@ semantics for comparing, parsing, and modifying version numbers.
|
|
101
101
|
|
102
102
|
=== Development and support
|
103
103
|
|
104
|
-
Documentation is available at http://virtuoso.rubyforge.org/versionomy
|
104
|
+
Documentation is available at http://virtuoso.rubyforge.org/versionomy/README_rdoc.html
|
105
105
|
|
106
|
-
Source code is hosted
|
106
|
+
Source code is hosted on Github at http://github.com/dazuma/versionomy
|
107
107
|
|
108
|
-
Report bugs on
|
108
|
+
Report bugs on Github issues at http://github.org/dazuma/versionomy/issues
|
109
109
|
|
110
110
|
Contact the author at dazuma at gmail dot com.
|
111
111
|
|
data/Rakefile
CHANGED
@@ -48,7 +48,7 @@ extra_rdoc_files_ = ['README.rdoc', 'History.rdoc']
|
|
48
48
|
|
49
49
|
|
50
50
|
# Default task
|
51
|
-
task :default => [:clean, :rdoc, :test]
|
51
|
+
task :default => [:clean, :rdoc, :package, :test]
|
52
52
|
|
53
53
|
|
54
54
|
# Clean task
|
@@ -98,7 +98,7 @@ end
|
|
98
98
|
|
99
99
|
# Publish RDocs
|
100
100
|
desc 'Publishes RDocs to RubyForge'
|
101
|
-
task :
|
101
|
+
task :publish_rdoc_to_rubyforge => [:rerdoc] do
|
102
102
|
config_ = YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml")))
|
103
103
|
username_ = config_['username']
|
104
104
|
sh "rsync -av --delete doc/ #{username_}@rubyforge.org:/var/www/gforge-projects/virtuoso/versionomy"
|
@@ -106,7 +106,7 @@ end
|
|
106
106
|
|
107
107
|
|
108
108
|
# Publish gem
|
109
|
-
task :
|
109
|
+
task :publish_gem_to_rubyforge => [:package] do |t_|
|
110
110
|
v_ = ENV["VERSION"]
|
111
111
|
abort "Must supply VERSION=x.y.z" unless v_
|
112
112
|
if v_ != Versionomy::VERSION_STRING
|
@@ -125,6 +125,22 @@ task :publish_gem => [:package] do |t_|
|
|
125
125
|
config_["release_notes"] = release_notes_
|
126
126
|
config_["release_changes"] = release_changes_
|
127
127
|
config_["preformatted"] = true
|
128
|
-
puts "Releasing versionomy #{v_}"
|
128
|
+
puts "Releasing versionomy #{v_} to RubyForge"
|
129
129
|
rf_.add_release('virtuoso', 'versionomy', v_, gem_pkg_, tgz_pkg_)
|
130
130
|
end
|
131
|
+
|
132
|
+
|
133
|
+
# Publish gem
|
134
|
+
task :publish_gem_to_gemcutter => [:package] do |t_|
|
135
|
+
v_ = ENV["VERSION"]
|
136
|
+
abort "Must supply VERSION=x.y.z" unless v_
|
137
|
+
if v_ != Versionomy::VERSION_STRING
|
138
|
+
abort "Versions don't match: #{v_} vs #{Versionomy::VERSION_STRING}"
|
139
|
+
end
|
140
|
+
puts "Releasing versionomy #{v_} to GemCutter"
|
141
|
+
`cd pkg && gem push versionomy-#{v_}.gem`
|
142
|
+
end
|
143
|
+
|
144
|
+
|
145
|
+
# Publish everything
|
146
|
+
task :publish => [:publish_gem_to_gemcutter, :publish_gem_to_rubyforge, :publish_rdoc_to_rubyforge]
|
data/lib/versionomy/errors.rb
CHANGED
@@ -115,7 +115,7 @@ module Versionomy
|
|
115
115
|
end
|
116
116
|
|
117
117
|
|
118
|
-
# Base class for all Versionomy format creation exceptions
|
118
|
+
# Base class for all Versionomy format creation exceptions.
|
119
119
|
|
120
120
|
class FormatCreationError < VersionomyError
|
121
121
|
end
|
@@ -124,7 +124,14 @@ module Versionomy
|
|
124
124
|
# This exception is raised if you try to register a format
|
125
125
|
# with a name that has already been used.
|
126
126
|
|
127
|
-
class FormatRedefinedError <
|
127
|
+
class FormatRedefinedError < VersionomyError
|
128
|
+
end
|
129
|
+
|
130
|
+
|
131
|
+
# Raised by the Formats registry if you try to retrieve a format with
|
132
|
+
# an unrecognized name in strict mode.
|
133
|
+
|
134
|
+
class UnknownFormatError < VersionomyError
|
128
135
|
end
|
129
136
|
|
130
137
|
|
@@ -69,6 +69,7 @@ module Versionomy
|
|
69
69
|
|
70
70
|
|
71
71
|
# Parse the given string and return a value.
|
72
|
+
#
|
72
73
|
# The optional parameter hash can be used to pass parameters to the
|
73
74
|
# parser to affect its behavior. The exact parameters supported are
|
74
75
|
# defined by the format.
|
@@ -79,6 +80,7 @@ module Versionomy
|
|
79
80
|
|
80
81
|
|
81
82
|
# Unparse the given value and return a string.
|
83
|
+
#
|
82
84
|
# The optional parameter hash can be used to pass parameters to the
|
83
85
|
# unparser to affect its behavior. The exact parameters supported
|
84
86
|
# are defined by the format.
|
data/lib/versionomy/formats.rb
CHANGED
@@ -53,9 +53,17 @@ module Versionomy
|
|
53
53
|
|
54
54
|
|
55
55
|
# Get the format with the given name.
|
56
|
+
#
|
57
|
+
# If the given name has not been defined, and strict is set to true,
|
58
|
+
# raises Versionomy::Errors::UnknownFormatError. If strict is set to
|
59
|
+
# false, returns nil if the given name has not been defined.
|
56
60
|
|
57
|
-
def self.get(name_)
|
58
|
-
@names[name_.to_s]
|
61
|
+
def self.get(name_, strict_=false)
|
62
|
+
format_ = @names[name_.to_s]
|
63
|
+
if format_.nil? && strict_
|
64
|
+
raise Errors::UnknownFormatError, name_
|
65
|
+
end
|
66
|
+
format_
|
59
67
|
end
|
60
68
|
|
61
69
|
|
data/lib/versionomy/interface.rb
CHANGED
@@ -55,11 +55,21 @@ module Versionomy
|
|
55
55
|
end
|
56
56
|
|
57
57
|
|
58
|
-
# Sets the default format
|
59
|
-
# Usually this
|
60
|
-
# Versionomy::Formats.standard
|
58
|
+
# Sets the default format used by other methods of this convenience
|
59
|
+
# interface. Usually, this is set to the "standard" format returned by
|
60
|
+
# Versionomy::Formats.standard and should not be changed.
|
61
|
+
#
|
62
|
+
# The format can be specified as a format object or the name of a format
|
63
|
+
# registered with Versionomy::Formats. If the format is set to nil, the
|
64
|
+
# default_format will be reset to the "standard" format.
|
65
|
+
#
|
66
|
+
# Raises Versionomy::Errors::UnknownFormatError if a name is given that
|
67
|
+
# is not registered.
|
61
68
|
|
62
69
|
def default_format=(format_)
|
70
|
+
if format_.kind_of?(String) || format_.kind_of?(Symbol)
|
71
|
+
format_ = Formats.get(format_, true)
|
72
|
+
end
|
63
73
|
@default_format = format_
|
64
74
|
end
|
65
75
|
|
@@ -67,26 +77,49 @@ module Versionomy
|
|
67
77
|
# Create a new version number given a hash or array of values, and an
|
68
78
|
# optional format.
|
69
79
|
#
|
70
|
-
# The values should either be a hash of field names and values, or an
|
71
|
-
# of values that will be interpreted in field order.
|
80
|
+
# The values should either be a hash of field names and values, or an
|
81
|
+
# array of values that will be interpreted in field order.
|
82
|
+
#
|
83
|
+
# The format can be specified as a format object or the name of a format
|
84
|
+
# registered with Versionomy::Formats. If the format is omitted or set
|
85
|
+
# to nil, the default_format will be used.
|
72
86
|
#
|
73
|
-
#
|
87
|
+
# You can also optionally provide default parameters to be used when
|
88
|
+
# unparsing this value or any derived from it.
|
74
89
|
#
|
75
|
-
#
|
90
|
+
# Raises Versionomy::Errors::UnknownFormatError if a name is given that
|
91
|
+
# is not registered.
|
76
92
|
|
77
93
|
def create(values_=[], format_=nil, unparse_params_=nil)
|
78
|
-
|
94
|
+
if format_.kind_of?(String) || format_.kind_of?(Symbol)
|
95
|
+
format_ = Formats.get(format_, true)
|
96
|
+
end
|
97
|
+
format_ ||= default_format
|
98
|
+
Value.new(values_, format_, unparse_params_)
|
79
99
|
end
|
80
100
|
|
81
101
|
|
82
|
-
# Create a new version number given a string to parse, and an optional
|
102
|
+
# Create a new version number given a string to parse, and an optional
|
103
|
+
# format.
|
104
|
+
#
|
105
|
+
# The format can be specified as a format object or the name of a format
|
106
|
+
# registered with Versionomy::Formats. If the format is omitted or set
|
107
|
+
# to nil, the default_format will be used.
|
108
|
+
#
|
109
|
+
# The parameter hash, if present, will be passed as parsing parameters
|
110
|
+
# to the format.
|
83
111
|
#
|
84
|
-
#
|
112
|
+
# Raises Versionomy::Errors::UnknownFormatError if a name is given that
|
113
|
+
# is not registered.
|
85
114
|
#
|
86
|
-
#
|
115
|
+
# May raise Versionomy::Errors::ParseError if parsing failed.
|
87
116
|
|
88
117
|
def parse(str_, format_=nil, parse_params_=nil)
|
89
|
-
(
|
118
|
+
if format_.kind_of?(String) || format_.kind_of?(Symbol)
|
119
|
+
format_ = Formats.get(format_, true)
|
120
|
+
end
|
121
|
+
format_ ||= default_format
|
122
|
+
format_.parse(str_, parse_params_)
|
90
123
|
end
|
91
124
|
|
92
125
|
end
|
data/lib/versionomy/version.rb
CHANGED
@@ -37,13 +37,13 @@
|
|
37
37
|
module Versionomy
|
38
38
|
|
39
39
|
# Current gem version, as a frozen string.
|
40
|
-
VERSION_STRING = '0.1.
|
40
|
+
VERSION_STRING = '0.1.1'.freeze
|
41
41
|
|
42
42
|
# Current gem version, as a Versionomy::Value.
|
43
|
-
VERSION = ::Versionomy.parse(VERSION_STRING,
|
43
|
+
VERSION = ::Versionomy.parse(VERSION_STRING, :standard)
|
44
44
|
|
45
45
|
end
|
46
46
|
|
47
47
|
|
48
48
|
::Blockenspiel.const_set(:VERSION,
|
49
|
-
::Versionomy.parse(::Blockenspiel::VERSION_STRING,
|
49
|
+
::Versionomy.parse(::Blockenspiel::VERSION_STRING, :standard))
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: versionomy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Azuma
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-10-
|
12
|
+
date: 2009-10-19 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|