Class: VersionInfo::ModuleStorage

Inherits:
Storage
  • Object
show all
Defined in:
lib/version_info/module_storage.rb

Overview

module MyProject

VERSION = "0.0.1"
VERSION.author = "jcangas"
VERSION.email = "[email protected]"

end

The convenion is to name this file “version.rb”

Instance Attribute Summary

Attributes inherited from Storage

#data

Instance Method Summary collapse

Methods inherited from Storage

#file_name, #file_name=, #initialize, #load

Constructor Details

This class inherits a constructor from VersionInfo::Storage

Instance Method Details

#default_file_nameObject



15
16
17
# File 'lib/version_info/module_storage.rb', line 15

def default_file_name
  'version.rb'
end

#load_from(io) ⇒ Object



19
20
21
# File 'lib/version_info/module_storage.rb', line 19

def load_from(io)
  self
end

#saveObject



23
24
25
26
27
28
# File 'lib/version_info/module_storage.rb', line 23

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