versionomy 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.rdoc ADDED
@@ -0,0 +1,31 @@
1
+ === 0.1.0 / 2009-10-14
2
+
3
+ * Alpha release, opened for public feedback
4
+ * General rearchitecture. Better distinction between format and schema. Schema split into schema and field objects so the API makes more sense. Values are tighter and easier to use. Formats can now be built using a DSL. A bunch of API changes and bug fixes accompanied this-- too many to list.
5
+ * In the standard schema, renamed release type "release" to "final". Also renamed release type "prerelease" to "preview", now sorted between "release candidate" and "final".
6
+ * Documentation is much more complete.
7
+ * Now tested and confirmed compatible with Matz Ruby 1.9.1 and JRuby 1.4.
8
+ * Now uses blockenspiel 0.2; thus longer requires the mixology gem.
9
+ * Building no longer requires hoe.
10
+
11
+ === 0.0.4 / 2008-10-24
12
+
13
+ * Fixed incompatibility with Blockenspiel 0.0.4
14
+ * Fixed a number of issues with remembering value parse settings
15
+ * Parser recognizes additional release type formats
16
+ * Values have a parse method to parse another string in the same form
17
+ * Implemented comparison between value and string
18
+ * Exceptions correctly raised on comparison between incompatible types
19
+
20
+ === 0.0.3 / 2008-10-21
21
+
22
+ * Fixed string representations (inspect method)
23
+ * Fixed up equality and hash computation for version values
24
+
25
+ === 0.0.2 / 2008-10-20
26
+
27
+ * Fixed manifest
28
+
29
+ === 0.0.1 / 2008-10-20
30
+
31
+ * Initial test release
data/README.rdoc ADDED
@@ -0,0 +1,144 @@
1
+ == Versionomy
2
+
3
+ Versionomy is a generalized version number library.
4
+ It provides tools to represent, manipulate, parse, and compare version
5
+ numbers in the wide variety of versioning schemes in use.
6
+
7
+ === Some examples
8
+
9
+ require 'versionomy'
10
+
11
+ v1 = Versionomy.parse('1.3.2')
12
+ v1.major # => 1
13
+ v1.minor # => 3
14
+ v1.tiny # => 2
15
+
16
+ v2 = Versionomy.parse('1.4a3')
17
+ v2.major # => 1
18
+ v2.minor # => 4
19
+ v2.tiny # => 0
20
+ v2.release_type # => :alpha
21
+ v2.alpha_version # => 3
22
+ v2 > v1 # => true
23
+
24
+ v3 = Versionomy.parse('1.4.0b2')
25
+ v3.major # => 1
26
+ v3.minor # => 4
27
+ v3.tiny # => 0
28
+ v3.release_type # => :beta
29
+ v3.alpha_version # raises NoMethodError
30
+ v3.beta_version # => 2
31
+ v3 > v2 # => true
32
+ v3.to_s # => '1.4.0b2'
33
+
34
+ v4 = v3.bump(:beta_version)
35
+ v4.to_s # => '1.4.0b3'
36
+
37
+ v5 = v4.bump(:release_type)
38
+ v5.to_s # => '1.4.0rc1'
39
+
40
+ v6 = v5.bump(:release_type)
41
+ v6.to_s # => '1.4.0'
42
+
43
+ v7 = v3.bump(:tiny)
44
+ v7.to_s # => '1.4.1'
45
+
46
+ v8 = v3.bump(:major)
47
+ v8.to_s # => '2.0.0'
48
+ v8.unparse(:optional_fields => [:tiny]) # => '2.0'
49
+
50
+ v9 = Versionomy.parse('2.0.0.0')
51
+ v9.to_s # => '2.0.0.0'
52
+ v9 == v8 # => true
53
+
54
+ v10 = v8.bump(:patchlevel)
55
+ v10.to_s # => '2.0.0-1'
56
+
57
+ microsoft_format = Versionomy.default_format.modified_copy do
58
+ field(:minor) do
59
+ recognize_number(:default_value_optional => true,
60
+ :delimiter_regexp => '\s?sp',
61
+ :default_delimiter => ' SP')
62
+ end
63
+ end
64
+ v11 = microsoft_format.parse('2008 SP2')
65
+ v11.major # => 2008
66
+ v11.minor # => 2
67
+ v11.tiny # => 0
68
+ v11.to_s # => '2008 SP2'
69
+ v11 == Versionomy.parse('2008.2') # => true
70
+
71
+ === Feature list
72
+
73
+ Versionomy's default versioning scheme handles four primary fields (labeled
74
+ +major+, +minor+, +tiny+, and +tiny2+). It also supports prerelease versions
75
+ such as preview, development, alpha, beta, and release candidate. Finally,
76
+ it supports patchlevel numbers for released versions.
77
+
78
+ Versionomy can compare any two version numbers with compatible structure,
79
+ and "bump" versions at any level. It supports parsing and unparsing in most
80
+ commonly-used formats, and allows you to extend the parsing to include
81
+ custom formats.
82
+
83
+ Finally, Versionomy also lets you to create alternate versioning "schemas".
84
+ You can define any number of version number fields, and provide your own
85
+ semantics for comparing, parsing, and modifying version numbers.
86
+
87
+ === Requirements
88
+
89
+ * Ruby 1.8.6 or later, Ruby 1.9.1 or later, or JRuby 1.4 or later.
90
+ * blockenspiel gem.
91
+
92
+ === Installation
93
+
94
+ gem install versionomy
95
+
96
+ === Known issues and limitations
97
+
98
+ * Test coverage is still a little skimpy. It is focused on the "standard"
99
+ version number format and schema, but doesn't fully exercise all the
100
+ capabilities of custom formats.
101
+
102
+ === Development and support
103
+
104
+ Documentation is available at http://virtuoso.rubyforge.org/versionomy
105
+
106
+ Source code is hosted by Github at http://github.com/dazuma/versionomy
107
+
108
+ Report bugs on RubyForge at http://rubyforge.org/projects/virtuoso
109
+
110
+ Contact the author at dazuma at gmail dot com.
111
+
112
+ === Author / Credits
113
+
114
+ Versionomy is written by Daniel Azuma (http://www.daniel-azuma.com/).
115
+
116
+ == LICENSE:
117
+
118
+ Copyright 2008-2009 Daniel Azuma.
119
+
120
+ All rights reserved.
121
+
122
+ Redistribution and use in source and binary forms, with or without
123
+ modification, are permitted provided that the following conditions are met:
124
+
125
+ * Redistributions of source code must retain the above copyright notice,
126
+ this list of conditions and the following disclaimer.
127
+ * Redistributions in binary form must reproduce the above copyright notice,
128
+ this list of conditions and the following disclaimer in the documentation
129
+ and/or other materials provided with the distribution.
130
+ * Neither the name of the copyright holder, nor the names of any other
131
+ contributors to this software, may be used to endorse or promote products
132
+ derived from this software without specific prior written permission.
133
+
134
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
135
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
136
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
137
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
138
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
139
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
140
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
141
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
142
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
143
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
144
+ POSSIBILITY OF SUCH DAMAGE.
data/Rakefile CHANGED
@@ -3,7 +3,7 @@
3
3
  # Versionomy Rakefile
4
4
  #
5
5
  # -----------------------------------------------------------------------------
6
- # Copyright 2008 Daniel Azuma
6
+ # Copyright 2008-2009 Daniel Azuma
7
7
  #
8
8
  # All rights reserved.
9
9
  #
@@ -33,17 +33,98 @@
33
33
  # -----------------------------------------------------------------------------
34
34
 
35
35
 
36
- require 'rubygems'
37
- require 'hoe'
36
+ require 'rake'
37
+ require 'rake/clean'
38
+ require 'rake/gempackagetask'
39
+ require 'rake/testtask'
40
+ require 'rake/rdoctask'
41
+ require 'rdoc/generator/darkfish'
42
+
38
43
  require File.expand_path("#{File.dirname(__FILE__)}/lib/versionomy.rb")
39
44
 
40
- Hoe.new('versionomy', Versionomy::VERSION_STRING) do |p_|
41
- p_.rubyforge_name = 'virtuoso'
42
- p_.developer('Daniel Azuma', 'dazuma@gmail.com')
43
- p_.author = ['Daniel Azuma']
44
- p_.email = ['dazuma@gmail.com']
45
- p_.test_globs = ['tests/tc_*.rb']
46
- p_.extra_deps = [['blockenspiel', '>= 0.0.4']]
47
- p_.description_sections = ['versionomy']
48
- p_.url = 'http://virtuoso.rubyforge.org/versionomy'
45
+
46
+ # Configuration
47
+ extra_rdoc_files_ = ['README.rdoc', 'History.rdoc']
48
+
49
+
50
+ # Default task
51
+ task :default => [:clean, :rdoc, :test]
52
+
53
+
54
+ # Clean task
55
+ CLEAN.include(['doc', 'pkg'])
56
+
57
+
58
+ # Test task
59
+ Rake::TestTask.new('test') do |task_|
60
+ task_.pattern = 'tests/tc_*.rb'
61
+ end
62
+
63
+
64
+ # RDoc task
65
+ Rake::RDocTask.new do |task_|
66
+ task_.main = 'README.rdoc'
67
+ task_.rdoc_files.include(*extra_rdoc_files_)
68
+ task_.rdoc_files.include('lib/versionomy/**/*.rb')
69
+ task_.rdoc_dir = 'doc'
70
+ task_.title = "Versionomy #{Versionomy::VERSION_STRING} documentation"
71
+ task_.options << '-f' << 'darkfish'
72
+ end
73
+
74
+
75
+ # Gem task
76
+ gemspec_ = Gem::Specification.new do |s_|
77
+ s_.name = 'versionomy'
78
+ s_.summary = 'Versionomy is a generalized version number library.'
79
+ s_.version = Versionomy::VERSION_STRING
80
+ s_.author = 'Daniel Azuma'
81
+ s_.email = 'dazuma@gmail.com'
82
+ s_.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.'
83
+ s_.homepage = 'http://virtuoso.rubyforge.org/versionomy'
84
+ s_.rubyforge_project = 'virtuoso'
85
+ s_.required_ruby_version = '>= 1.8.6'
86
+ s_.files = FileList['lib/**/*.rb', 'tests/**/*.rb', '*.rdoc', 'Rakefile'].to_a
87
+ s_.extra_rdoc_files = extra_rdoc_files_
88
+ s_.has_rdoc = true
89
+ s_.test_files = FileList['tests/tc_*.rb']
90
+ s_.platform = Gem::Platform::RUBY
91
+ s_.add_dependency('blockenspiel', '>= 0.2.1')
92
+ end
93
+ Rake::GemPackageTask.new(gemspec_) do |task_|
94
+ task_.need_zip = false
95
+ task_.need_tar = true
96
+ end
97
+
98
+
99
+ # Publish RDocs
100
+ desc 'Publishes RDocs to RubyForge'
101
+ task :publish_rdoc => [:rerdoc] do
102
+ config_ = YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml")))
103
+ username_ = config_['username']
104
+ sh "rsync -av --delete doc/ #{username_}@rubyforge.org:/var/www/gforge-projects/virtuoso/versionomy"
105
+ end
106
+
107
+
108
+ # Publish gem
109
+ task :publish_gem => [:package] do |t_|
110
+ v_ = ENV["VERSION"]
111
+ abort "Must supply VERSION=x.y.z" unless v_
112
+ if v_ != Versionomy::VERSION_STRING
113
+ abort "Versions don't match: #{v_} vs #{Versionomy::VERSION_STRING}"
114
+ end
115
+ gem_pkg_ = "pkg/versionomy-#{v_}.gem"
116
+ tgz_pkg_ = "pkg/versionomy-#{v_}.tgz"
117
+ release_notes_ = File.read("README.rdoc").split(/^(==.*)/)[2].strip
118
+ release_changes_ = File.read("History.rdoc").split(/^(===.*)/)[1..2].join.strip
119
+
120
+ require 'rubyforge'
121
+ rf_ = RubyForge.new.configure
122
+ puts "Logging in to RubyForge"
123
+ rf_.login
124
+ config_ = rf_.userconfig
125
+ config_["release_notes"] = release_notes_
126
+ config_["release_changes"] = release_changes_
127
+ config_["preformatted"] = true
128
+ puts "Releasing versionomy #{v_}"
129
+ rf_.add_release('virtuoso', 'versionomy', v_, gem_pkg_, tgz_pkg_)
49
130
  end
@@ -3,7 +3,7 @@
3
3
  # Versionomy exceptions
4
4
  #
5
5
  # -----------------------------------------------------------------------------
6
- # Copyright 2008 Daniel Azuma
6
+ # Copyright 2008-2009 Daniel Azuma
7
7
  #
8
8
  # All rights reserved.
9
9
  #
@@ -44,16 +44,22 @@ module Versionomy
44
44
 
45
45
  # Base class for all Versionomy exceptions
46
46
 
47
- class VersionomyError < RuntimeError
47
+ class VersionomyError < ::RuntimeError
48
48
  end
49
49
 
50
50
 
51
- # This exception is raised if parsing or unparsing failed.
51
+ # This exception is raised if parsing failed.
52
52
 
53
53
  class ParseError < VersionomyError
54
54
  end
55
55
 
56
56
 
57
+ # This exception is raised if unparsing failed.
58
+
59
+ class UnparseError < VersionomyError
60
+ end
61
+
62
+
57
63
  # This exception is raised if you try to set a value that is not
58
64
  # allowed by the schema.
59
65
 
@@ -68,13 +74,6 @@ module Versionomy
68
74
  end
69
75
 
70
76
 
71
- # This exception is raised during parsing if the specified format
72
- # name is not recognized.
73
-
74
- class UnknownFormatError < VersionomyError
75
- end
76
-
77
-
78
77
  # Base class for all Versionomy schema creation exceptions
79
78
 
80
79
  class SchemaCreationError < VersionomyError
@@ -89,7 +88,7 @@ module Versionomy
89
88
 
90
89
 
91
90
  # This exception is raised during schema creation if you try to
92
- # create two subschemas covering overlapping ranges.
91
+ # create two fields covering overlapping ranges.
93
92
 
94
93
  class RangeOverlapError < SchemaCreationError
95
94
  end
@@ -109,6 +108,26 @@ module Versionomy
109
108
  end
110
109
 
111
110
 
111
+ # This exception is raised during schema creation if you try to
112
+ # create a circular dependency.
113
+
114
+ class CircularDescendantError < SchemaCreationError
115
+ end
116
+
117
+
118
+ # Base class for all Versionomy format creation exceptions
119
+
120
+ class FormatCreationError < VersionomyError
121
+ end
122
+
123
+
124
+ # This exception is raised if you try to register a format
125
+ # with a name that has already been used.
126
+
127
+ class FormatRedefinedError < FormatCreationError
128
+ end
129
+
130
+
112
131
  end
113
132
 
114
133
  end
@@ -0,0 +1,96 @@
1
+ # -----------------------------------------------------------------------------
2
+ #
3
+ # Versionomy format base class
4
+ #
5
+ # -----------------------------------------------------------------------------
6
+ # Copyright 2008-2009 Daniel Azuma
7
+ #
8
+ # All rights reserved.
9
+ #
10
+ # Redistribution and use in source and binary forms, with or without
11
+ # modification, are permitted provided that the following conditions are met:
12
+ #
13
+ # * Redistributions of source code must retain the above copyright notice,
14
+ # this list of conditions and the following disclaimer.
15
+ # * Redistributions in binary form must reproduce the above copyright notice,
16
+ # this list of conditions and the following disclaimer in the documentation
17
+ # and/or other materials provided with the distribution.
18
+ # * Neither the name of the copyright holder, nor the names of any other
19
+ # contributors to this software, may be used to endorse or promote products
20
+ # derived from this software without specific prior written permission.
21
+ #
22
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
+ # POSSIBILITY OF SUCH DAMAGE.
33
+ # -----------------------------------------------------------------------------
34
+ ;
35
+
36
+
37
+ module Versionomy
38
+
39
+
40
+ module Format
41
+
42
+
43
+ # The base format.
44
+ #
45
+ # This format doesn't actually do anything useful. It causes all strings
46
+ # to parse to the schema's default value, and unparses all values to the
47
+ # empty string.
48
+ #
49
+ # Instead, the purpose here is to define the API for a format. All
50
+ # formats must define the methods +schema+, +parse+, and +unparse+.
51
+ # Formats need not extend this base class, as long as they duck-type
52
+ # these methods.
53
+
54
+ class Base
55
+
56
+
57
+ # Create an instance of this base format, with the given schema.
58
+
59
+ def initialize(schema_)
60
+ @schema = schema_
61
+ end
62
+
63
+
64
+ # Returns the schema understood by this format.
65
+
66
+ def schema
67
+ @schema
68
+ end
69
+
70
+
71
+ # Parse the given string and return a value.
72
+ # The optional parameter hash can be used to pass parameters to the
73
+ # parser to affect its behavior. The exact parameters supported are
74
+ # defined by the format.
75
+
76
+ def parse(string_, params_=nil)
77
+ Value.new([], self)
78
+ end
79
+
80
+
81
+ # Unparse the given value and return a string.
82
+ # The optional parameter hash can be used to pass parameters to the
83
+ # unparser to affect its behavior. The exact parameters supported
84
+ # are defined by the format.
85
+
86
+ def unparse(value_, params_=nil)
87
+ ''
88
+ end
89
+
90
+
91
+ end
92
+
93
+
94
+ end
95
+
96
+ end