Sha256: 800dfab977b859f9fe867e694fc132b85318d6eb5575124a76dee372f6a0fc4c

Contents?: true

Size: 782 Bytes

Versions: 1

Compression:

Stored size: 782 Bytes

Contents

module VersionInfo
  # Version data is stored in a ruby file into the project top module :

  # module MyProject
  #   VERSION = "0.0.1"
  #   VERSION.author = "jcangas"
  #   VERSION.email = "jorge.cangas@gmail.com"
  # end
  #
  # The convenion is to name this file "version.rb"

  class ModuleStorage < Storage

    def default_file_name
      'version.rb'
    end

    def parse_from(content)
      match = content.join("\n").match /(\s*VERSION\s*=\s*)('|")(.*)('|")/
      str = match[3]
      data.set_version_info(str)
      self
    end

    def save      
      content = load_content.join
      content.gsub!(/(\s*VERSION\s*=\s*)('|").*('|")/, "\\1\\2#{data.tag}\\3")
	    File.open(file_name, 'w' ) {|out| out.print content}
	    self
      content
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
version_info-1.8.8 lib/version_info/module_storage.rb