Sha256: 80cadebf86c62ec32fa0f0f6623a0123b9d1bc067aae508f4ea76ae58b76daf8

Contents?: true

Size: 603 Bytes

Versions: 8

Compression:

Stored size: 603 Bytes

Contents

require 'yaml'

module VersionInfo
  # Version data is stored in a yaml file as a simple hash, i.e. :

  # --- 
  # major: 1
  # minor: 1
  # patch: 4
  # author: jcangas

  module YamlStorage
    def default_file_name
      'version_info.yml'
    end

    def load_from(io)
      values = YAML.load(io)
      # force keys as symbols
	    values.keys.each{|k| values[k.to_sym] = values.delete(k)}
      assign(values)
      self
    end

    def save_to(io)
	    values = self.to_hash.keys.compact.inject({}){|r, k| r[k.to_s] = send(k); r }
      YAML.dump(values, io)
	    self      
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
version_info-1.7.7 lib/version_info/yaml_storage.rb
version_info-1.7.6 lib/version_info/yaml_storage.rb
version_info-1.7.5 lib/version_info/yaml_storage.rb
version_info-1.7.4 lib/version_info/yaml_storage.rb
version_info-1.7.3 lib/version_info/yaml_storage.rb
version_info-1.7.2 lib/version_info/yaml_storage.rb
version_info-1.7.1 lib/version_info/yaml_storage.rb
version_info-1.7.0 lib/version_info/yaml_storage.rb