versionomy 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/History.rdoc CHANGED
@@ -1,3 +1,8 @@
1
+ === 0.1.2 / 2009-10-28
2
+
3
+ * You can now specify fields by index in methods of Versionomy::Value.
4
+ * Minor rakefile and documentation updates.
5
+
1
6
  === 0.1.1 / 2009-10-19
2
7
 
3
8
  * Formats can now be specified by name in the convenience interface.
data/Rakefile CHANGED
@@ -33,6 +33,7 @@
33
33
  # -----------------------------------------------------------------------------
34
34
 
35
35
 
36
+ require 'rubygems'
36
37
  require 'rake'
37
38
  require 'rake/clean'
38
39
  require 'rake/gempackagetask'
@@ -88,7 +89,7 @@ gemspec_ = Gem::Specification.new do |s_|
88
89
  s_.has_rdoc = true
89
90
  s_.test_files = FileList['tests/tc_*.rb']
90
91
  s_.platform = Gem::Platform::RUBY
91
- s_.add_dependency('blockenspiel', '>= 0.2.1')
92
+ s_.add_dependency('blockenspiel', '>= 0.2.2')
92
93
  end
93
94
  Rake::GemPackageTask.new(gemspec_) do |task_|
94
95
  task_.need_zip = false
@@ -106,7 +107,7 @@ end
106
107
 
107
108
 
108
109
  # Publish gem
109
- task :publish_gem_to_rubyforge => [:package] do |t_|
110
+ task :release_gem_to_rubyforge => [:package] do |t_|
110
111
  v_ = ENV["VERSION"]
111
112
  abort "Must supply VERSION=x.y.z" unless v_
112
113
  if v_ != Versionomy::VERSION_STRING
@@ -131,7 +132,7 @@ end
131
132
 
132
133
 
133
134
  # Publish gem
134
- task :publish_gem_to_gemcutter => [:package] do |t_|
135
+ task :release_gem_to_gemcutter => [:package] do |t_|
135
136
  v_ = ENV["VERSION"]
136
137
  abort "Must supply VERSION=x.y.z" unless v_
137
138
  if v_ != Versionomy::VERSION_STRING
@@ -143,4 +144,4 @@ end
143
144
 
144
145
 
145
146
  # Publish everything
146
- task :publish => [:publish_gem_to_gemcutter, :publish_gem_to_rubyforge, :publish_rdoc_to_rubyforge]
147
+ task :release => [:release_gem_to_gemcutter, :release_gem_to_rubyforge, :publish_rdoc_to_rubyforge]
@@ -1,6 +1,6 @@
1
1
  # -----------------------------------------------------------------------------
2
2
  #
3
- # Versionomy format module
3
+ # Versionomy format namespace
4
4
  #
5
5
  # -----------------------------------------------------------------------------
6
6
  # Copyright 2008-2009 Daniel Azuma
@@ -49,7 +49,7 @@ module Versionomy
49
49
  #
50
50
  # Under many circumstances, you should use the standard format, which
51
51
  # can be retrieved by calling Versionomy::Formats#standard. This format
52
- # understands most of the common version numbers, including prerelease
52
+ # understands most common version numbers, including prerelease
53
53
  # (e.g. alpha, beta, release candidate, etc.) forms and patchlevels.
54
54
  #
55
55
  # You may also create your own formats, either by implementing the
@@ -1,6 +1,6 @@
1
1
  # -----------------------------------------------------------------------------
2
2
  #
3
- # Versionomy format registry
3
+ # Versionomy standard format implementation
4
4
  #
5
5
  # -----------------------------------------------------------------------------
6
6
  # Copyright 2008-2009 Daniel Azuma
@@ -1,6 +1,6 @@
1
1
  # -----------------------------------------------------------------------------
2
2
  #
3
- # Versionomy format module
3
+ # Versionomy format registry
4
4
  #
5
5
  # -----------------------------------------------------------------------------
6
6
  # Copyright 2008-2009 Daniel Azuma
@@ -1,6 +1,6 @@
1
1
  # -----------------------------------------------------------------------------
2
2
  #
3
- # Versionomy schema module
3
+ # Versionomy schema namespace
4
4
  #
5
5
  # -----------------------------------------------------------------------------
6
6
  # Copyright 2008-2009 Daniel Azuma
@@ -83,7 +83,7 @@ module Versionomy
83
83
  # The Versionomy::Schema::Wrapper class represents a full schema object.
84
84
  #
85
85
  # Generally, you should create schemas using Versionomy::Schema#create.
86
- # This method provides a DSL that lets you quickly create the fields.
86
+ # That method provides a DSL that lets you quickly create the fields.
87
87
 
88
88
  module Schema
89
89
  end
@@ -165,12 +165,14 @@ module Versionomy
165
165
 
166
166
 
167
167
  # Returns true if this value contains the given field, which may be specified
168
- # as a field object or name.
168
+ # as a field object, name, or index.
169
169
 
170
170
  def has_field?(field_)
171
171
  case field_
172
172
  when Schema::Field
173
173
  @field_path.include?(field_)
174
+ when ::Integer
175
+ @field_path.size > field_ && field_ >= 0
174
176
  when ::String, ::Symbol
175
177
  @values.has_key?(field_.to_sym)
176
178
  else
@@ -179,12 +181,14 @@ module Versionomy
179
181
  end
180
182
 
181
183
 
182
- # Returns the value of the given field, or nil if the field is not recognized.
183
- # The field may be specified as a field object or field name.
184
+ # Returns the value of the given field, or nil if the field is not
185
+ # recognized. The field may be specified as a field object, field name,
186
+ # or field index.
184
187
 
185
188
  def [](field_)
189
+ field_ = @field_path[field_] if field_.kind_of?(::Integer)
186
190
  field_ = field_.name if field_.kind_of?(Schema::Field)
187
- @values[field_.to_sym]
191
+ field_ ? @values[field_.to_sym] : nil
188
192
  end
189
193
 
190
194
 
@@ -202,11 +206,17 @@ module Versionomy
202
206
  end
203
207
 
204
208
 
205
- # Returns a new version number created by bumping the given field.
209
+ # Returns a new version number created by bumping the given field. The
210
+ # field may be specified as a field object, field name, or field index.
211
+ # Returns self if value could not be changed.
212
+ # Returns nil if the field was not recognized.
206
213
 
207
214
  def bump(name_)
215
+ name_ = @field_path[name_] if name_.kind_of?(::Integer)
208
216
  name_ = name_.name if name_.kind_of?(Schema::Field)
217
+ return nil unless name_
209
218
  name_ = name_.to_sym
219
+ return nil unless @values.include?(name_)
210
220
  values_ = []
211
221
  @field_path.each do |field_|
212
222
  oldval_ = @values[field_.name]
@@ -37,7 +37,7 @@
37
37
  module Versionomy
38
38
 
39
39
  # Current gem version, as a frozen string.
40
- VERSION_STRING = '0.1.1'.freeze
40
+ VERSION_STRING = '0.1.2'.freeze
41
41
 
42
42
  # Current gem version, as a Versionomy::Value.
43
43
  VERSION = ::Versionomy.parse(VERSION_STRING, :standard)
data/lib/versionomy.rb CHANGED
@@ -36,13 +36,13 @@
36
36
 
37
37
  begin
38
38
  require 'blockenspiel'
39
- rescue LoadError
39
+ rescue ::LoadError
40
40
  require 'rubygems'
41
41
  require 'blockenspiel'
42
42
  end
43
43
 
44
44
 
45
- dir_ = File.expand_path('versionomy', File.dirname(__FILE__))
45
+ dir_ = ::File.expand_path('versionomy', ::File.dirname(__FILE__))
46
46
 
47
47
  includes_ = [
48
48
  'errors',
@@ -141,6 +141,34 @@ module Versionomy
141
141
  end
142
142
 
143
143
 
144
+ # Test specifying fields by index.
145
+
146
+ def test_field_get_index
147
+ value_ = Versionomy.create(:major => 2, :tiny => 1, :release_type => :beta, :beta_version => 3)
148
+ assert_equal(2, value_[0])
149
+ assert_equal(0, value_[1])
150
+ assert_equal(1, value_[2])
151
+ assert_equal(0, value_[3])
152
+ assert_equal(:beta, value_[4])
153
+ assert_equal(3, value_[5])
154
+ assert_equal(0, value_[6])
155
+ end
156
+
157
+
158
+ # Test specifying fields by name.
159
+
160
+ def test_field_get_name
161
+ value_ = Versionomy.create(:major => 2, :tiny => 1, :release_type => :beta, :beta_version => 3)
162
+ assert_equal(2, value_[:major])
163
+ assert_equal(0, value_[:minor])
164
+ assert_equal(1, value_[:tiny])
165
+ assert_equal(0, value_[:tiny2])
166
+ assert_equal(:beta, value_[:release_type])
167
+ assert_equal(3, value_[:beta_version])
168
+ assert_equal(0, value_[:beta_minor])
169
+ end
170
+
171
+
144
172
  end
145
173
 
146
174
  end
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.1
4
+ version: 0.1.2
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-19 00:00:00 -07:00
12
+ date: 2009-10-28 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 0.2.1
23
+ version: 0.2.2
24
24
  version:
25
25
  description: Versionomy is a generalized version number library. It provides tools to represent, manipulate, parse, and compare version numbers in the wide variety of versioning schemes in use.
26
26
  email: dazuma@gmail.com