Sha256: d4224977e7dd2e96829d53b47476d8e213b4203abebdce5dd86e8cc19dfb9f57

Contents?: true

Size: 874 Bytes

Versions: 3

Compression:

Stored size: 874 Bytes

Contents

module VersionInfo
  # Version data is stored in a text file with this structure
  # 2.2.3  # => numeric segments at first line
  # author: jcangas # => custom key after, one per line
  # email: jorge.cangas@gmail.com # => another custom key
  #
  # The convenion is to name this file "VERSION"
    
  module TextStorage
    
    def default_file_name
      'VERSION'
    end

    def load_from(io)
      content = io.readlines
      str = content.shift
      custom = content.inject({}) {|result, line| k, v = line.chomp.split(':'); result[k.strip.to_sym] = v.strip; result}
      self.to_hash.merge!(custom)
      self.set_version_info(str)
      self
    end

    def save_to(io)
      io.puts VersionInfo.segments.map{|sgm| send(sgm)}.join('.')
      to_hash.each {|k, v| io.puts "#{k}: #{v}" unless VersionInfo.segments.include?(k) }
	    self      
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
version_info-1.7.2 lib/version_info/text_storage.rb
version_info-1.7.1 lib/version_info/text_storage.rb
version_info-1.7.0 lib/version_info/text_storage.rb