Sha256: 7e498392090ba9613608b5cf8e5ae10ebdb7dd23eead734c08e5fc0183754c63
Contents?: true
Size: 1.03 KB
Versions: 2
Compression:
Stored size: 1.03 KB
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" class TextStorage < Storage def default_file_name 'VERSION' end def load_content File.exist?(file_name) ? File.readlines(file_name) : [""] end def load content = load_content parse_from(content) self end def parse_from(content) str = content.shift custom = content.inject({}) {|result, line| k, v = line.chomp.split(':'); result[k.strip.to_sym] = v.strip; result} data.set_version_info(str) data.to_hash.merge!(custom) self end def save_to(io) io.puts data.tag #VersionInfo.segments.map{|sgm| data.send(sgm)}.join('.') data.to_hash.each {|k, v| io.puts "#{k}: #{v}" unless data.segments.include?(k) } self end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
version_info-1.9.0 | lib/version_info/text_storage.rb |
version_info-1.8.8 | lib/version_info/text_storage.rb |