Skip to content

Commit

Permalink
Version 0.1.1 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dazuma committed Oct 19, 2009
1 parent 1d6bde2 commit b882c4e
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 27 deletions.
7 changes: 7 additions & 0 deletions History.rdoc
@@ -1,3 +1,10 @@
=== 0.1.1 / 2009-10-19

* Formats can now be specified by name in the convenience interface.
* FormatRedefinedError no longer subclasses FormatCreationError.
* Some documentation updates.
* Rakefile updates for publishing to rubyforge and gemcutter.

=== 0.1.0 / 2009-10-14

* Alpha release, opened for public feedback
Expand Down
8 changes: 4 additions & 4 deletions README.rdoc
Expand Up @@ -86,7 +86,7 @@ semantics for comparing, parsing, and modifying version numbers.

=== Requirements

* Ruby 1.8.6 or later, Ruby 1.9.1 or later, or JRuby 1.4 or later.
* Ruby 1.8.6 or later (1.8.7 recommended), Ruby 1.9.1 or later, or JRuby 1.4 or later.
* blockenspiel gem.

=== Installation
Expand All @@ -101,11 +101,11 @@ semantics for comparing, parsing, and modifying version numbers.

=== Development and support

Documentation is available at http://virtuoso.rubyforge.org/versionomy
Documentation is available at http://virtuoso.rubyforge.org/versionomy/README_rdoc.html

Source code is hosted by Github at http://github.com/dazuma/versionomy
Source code is hosted on Github at http://github.com/dazuma/versionomy

Report bugs on RubyForge at http://rubyforge.org/projects/virtuoso
Report bugs on Github issues at http://github.org/dazuma/versionomy/issues

Contact the author at dazuma at gmail dot com.

Expand Down
24 changes: 20 additions & 4 deletions Rakefile
Expand Up @@ -48,7 +48,7 @@ extra_rdoc_files_ = ['README.rdoc', 'History.rdoc']


# Default task
task :default => [:clean, :rdoc, :test]
task :default => [:clean, :rdoc, :package, :test]


# Clean task
Expand Down Expand Up @@ -98,15 +98,15 @@ end

# Publish RDocs
desc 'Publishes RDocs to RubyForge'
task :publish_rdoc => [:rerdoc] do
task :publish_rdoc_to_rubyforge => [:rerdoc] do
config_ = YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml")))
username_ = config_['username']
sh "rsync -av --delete doc/ #{username_}@rubyforge.org:/var/www/gforge-projects/virtuoso/versionomy"
end


# Publish gem
task :publish_gem => [:package] do |t_|
task :publish_gem_to_rubyforge => [:package] do |t_|
v_ = ENV["VERSION"]
abort "Must supply VERSION=x.y.z" unless v_
if v_ != Versionomy::VERSION_STRING
Expand All @@ -125,6 +125,22 @@ task :publish_gem => [:package] do |t_|
config_["release_notes"] = release_notes_
config_["release_changes"] = release_changes_
config_["preformatted"] = true
puts "Releasing versionomy #{v_}"
puts "Releasing versionomy #{v_} to RubyForge"
rf_.add_release('virtuoso', 'versionomy', v_, gem_pkg_, tgz_pkg_)
end


# Publish gem
task :publish_gem_to_gemcutter => [:package] do |t_|
v_ = ENV["VERSION"]
abort "Must supply VERSION=x.y.z" unless v_
if v_ != Versionomy::VERSION_STRING
abort "Versions don't match: #{v_} vs #{Versionomy::VERSION_STRING}"
end
puts "Releasing versionomy #{v_} to GemCutter"
`cd pkg && gem push versionomy-#{v_}.gem`
end


# Publish everything
task :publish => [:publish_gem_to_gemcutter, :publish_gem_to_rubyforge, :publish_rdoc_to_rubyforge]
11 changes: 9 additions & 2 deletions lib/versionomy/errors.rb
Expand Up @@ -115,7 +115,7 @@ class CircularDescendantError < SchemaCreationError
end


# Base class for all Versionomy format creation exceptions
# Base class for all Versionomy format creation exceptions.

class FormatCreationError < VersionomyError
end
Expand All @@ -124,7 +124,14 @@ class FormatCreationError < VersionomyError
# This exception is raised if you try to register a format
# with a name that has already been used.

class FormatRedefinedError < FormatCreationError
class FormatRedefinedError < VersionomyError
end


# Raised by the Formats registry if you try to retrieve a format with
# an unrecognized name in strict mode.

class UnknownFormatError < VersionomyError
end


Expand Down
2 changes: 2 additions & 0 deletions lib/versionomy/format/base.rb
Expand Up @@ -69,6 +69,7 @@ def schema


# Parse the given string and return a value.
#
# The optional parameter hash can be used to pass parameters to the
# parser to affect its behavior. The exact parameters supported are
# defined by the format.
Expand All @@ -79,6 +80,7 @@ def parse(string_, params_=nil)


# Unparse the given value and return a string.
#
# The optional parameter hash can be used to pass parameters to the
# unparser to affect its behavior. The exact parameters supported
# are defined by the format.
Expand Down
12 changes: 10 additions & 2 deletions lib/versionomy/formats.rb
Expand Up @@ -53,9 +53,17 @@ module Formats


# Get the format with the given name.
#
# If the given name has not been defined, and strict is set to true,
# raises Versionomy::Errors::UnknownFormatError. If strict is set to
# false, returns nil if the given name has not been defined.

def self.get(name_)
@names[name_.to_s]
def self.get(name_, strict_=false)
format_ = @names[name_.to_s]
if format_.nil? && strict_
raise Errors::UnknownFormatError, name_
end
format_
end


Expand Down
57 changes: 45 additions & 12 deletions lib/versionomy/interface.rb
Expand Up @@ -55,38 +55,71 @@ def default_format
end


# Sets the default format.
# Usually this should be left as the "standard" format returned by
# Versionomy::Formats.standard. To reset to that value, pass nil.
# Sets the default format used by other methods of this convenience
# interface. Usually, this is set to the "standard" format returned by
# Versionomy::Formats.standard and should not be changed.
#
# The format can be specified as a format object or the name of a format
# registered with Versionomy::Formats. If the format is set to nil, the
# default_format will be reset to the "standard" format.
#
# Raises Versionomy::Errors::UnknownFormatError if a name is given that
# is not registered.

def default_format=(format_)
if format_.kind_of?(String) || format_.kind_of?(Symbol)
format_ = Formats.get(format_, true)
end
@default_format = format_
end


# Create a new version number given a hash or array of values, and an
# optional format.
#
# The values should either be a hash of field names and values, or an array
# of values that will be interpreted in field order.
# The values should either be a hash of field names and values, or an
# array of values that will be interpreted in field order.
#
# The format can be specified as a format object or the name of a format
# registered with Versionomy::Formats. If the format is omitted or set
# to nil, the default_format will be used.
#
# If the format is omitted or set to nil, the default_format will be used.
# You can also optionally provide default parameters to be used when
# unparsing this value or any derived from it.
#
# You can also optionally provide default unparsing parameters for the value.
# Raises Versionomy::Errors::UnknownFormatError if a name is given that
# is not registered.

def create(values_=[], format_=nil, unparse_params_=nil)
Value.new(values_, format_ || default_format, unparse_params_)
if format_.kind_of?(String) || format_.kind_of?(Symbol)
format_ = Formats.get(format_, true)
end
format_ ||= default_format
Value.new(values_, format_, unparse_params_)
end


# Create a new version number given a string to parse, and an optional format.
# Create a new version number given a string to parse, and an optional
# format.
#
# The format can be specified as a format object or the name of a format
# registered with Versionomy::Formats. If the format is omitted or set
# to nil, the default_format will be used.
#
# The parameter hash, if present, will be passed as parsing parameters
# to the format.
#
# If the format is omitted or set to nil, the default_format will be used.
# Raises Versionomy::Errors::UnknownFormatError if a name is given that
# is not registered.
#
# The params, if present, will be passed as parsing parameters to the format.
# May raise Versionomy::Errors::ParseError if parsing failed.

def parse(str_, format_=nil, parse_params_=nil)
(format_ || default_format).parse(str_, parse_params_)
if format_.kind_of?(String) || format_.kind_of?(Symbol)
format_ = Formats.get(format_, true)
end
format_ ||= default_format
format_.parse(str_, parse_params_)
end

end
Expand Down
6 changes: 3 additions & 3 deletions lib/versionomy/version.rb
Expand Up @@ -37,13 +37,13 @@
module Versionomy

# Current gem version, as a frozen string.
VERSION_STRING = '0.1.0'.freeze
VERSION_STRING = '0.1.1'.freeze

# Current gem version, as a Versionomy::Value.
VERSION = ::Versionomy.parse(VERSION_STRING, ::Versionomy::Formats.standard)
VERSION = ::Versionomy.parse(VERSION_STRING, :standard)

end


::Blockenspiel.const_set(:VERSION,
::Versionomy.parse(::Blockenspiel::VERSION_STRING, ::Versionomy::Formats.standard))
::Versionomy.parse(::Blockenspiel::VERSION_STRING, :standard))

0 comments on commit b882c4e

Please sign in to comment.