Class: Monocle::VersionGenerator
- Inherits:
-
Object
- Object
- Monocle::VersionGenerator
- Defined in:
- lib/monocle/version_generator.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#view ⇒ Object
readonly
Returns the value of attribute view.
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(path) ⇒ VersionGenerator
constructor
A new instance of VersionGenerator.
Constructor Details
#initialize(path) ⇒ VersionGenerator
Returns a new instance of VersionGenerator.
5 6 7 8 |
# File 'lib/monocle/version_generator.rb', line 5 def initialize(path) @path = path @view = File.basename(path, ".sql") end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/monocle/version_generator.rb', line 3 def path @path end |
#view ⇒ Object (readonly)
Returns the value of attribute view.
3 4 5 |
# File 'lib/monocle/version_generator.rb', line 3 def view @view end |
Instance Method Details
#generate ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/monocle/version_generator.rb', line 10 def generate = File.open path, &:readline fail "can't read timestamp of #{path}! Aborting..." unless .starts_with? "-- Timestamp: " # Get only the digits out of the timestamp line .gsub!(/[^\d]/, '') "#{view}_#{}" end |