Class: Dynomite::Migration::FileInfo
- Inherits:
-
Object
- Object
- Dynomite::Migration::FileInfo
- Defined in:
- lib/dynomite/migration/file_info.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(path) ⇒ FileInfo
constructor
A new instance of FileInfo.
- #migration_class ⇒ Object
- #pretty_path ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(path) ⇒ FileInfo
Returns a new instance of FileInfo.
4 5 6 |
# File 'lib/dynomite/migration/file_info.rb', line 4 def initialize(path) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/dynomite/migration/file_info.rb', line 3 def path @path end |
Class Method Details
Instance Method Details
#migration_class ⇒ Object
12 13 14 15 16 |
# File 'lib/dynomite/migration/file_info.rb', line 12 def migration_class filename = File.basename(@path, '.rb') filename = filename.sub(/\d+[-_]/, '') # strip leading timestsamp filename.camelize.constantize end |
#pretty_path ⇒ Object
8 9 10 |
# File 'lib/dynomite/migration/file_info.rb', line 8 def pretty_path @path.sub(/^\.\//,'') # remove leading ./ end |
#version ⇒ Object
18 19 20 21 22 |
# File 'lib/dynomite/migration/file_info.rb', line 18 def version filename = File.basename(@path, '.rb') md = filename.match(/(\d+)[-_]/) md[1].to_i end |