Sha256: 39e3e892173cc9c85934d3345f40bc7297f62f2aed50a392ff8b9b827ccbe2c3
Contents?: true
Size: 1.7 KB
Versions: 2
Compression:
Stored size: 1.7 KB
Contents
module Rake # # Simple helper class for maintaining a Version number within a Rakefile. # Provides an easy way increase the version tags. Supports purely numeric # version tags only. # class Version def self.increment( symbol ) Version.new.increment symbol end def initialize( config = {} ) @config = config @config[ :version_file ] ||= 'Version' @config[ :version_regex ] ||= /\A(\d+)\.(\d+).(\d+)\Z/ @config[ :version_tags ] ||= [ :release, :version, :build ] @tag_values = {} read end def increment( symbol ) raise "Unknown tag: #{symbol}" unless version_tags.include? symbol read @tag_values[ symbol ] += 1 write current_version end def current_version version_tags.map { |tag| @tag_values[ tag ] }.join( '.' ) end alias version current_version alias to_s version private def read version = IO.read version_file raise "Error reading #{version_file}" unless version_regex =~ version version_tags.each_index do |idx| @tag_values[ version_tags[ idx ] ] = Regexp.last_match[ 1 + idx ].to_i end self end def write File.open( version_file, 'w' ) do |file| file.write current_version end self end def version_file @config[ :version_file ] end def version_regex @config[ :version_regex ] end def version_tags @config[ :version_tags ] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
BitStructEx-0.0.54 | lib/ruby/rake/version.rb |
BitStructEx-0.0.64 | lib/ruby/rake/version.rb |