Module: NandoUtils
- Defined in:
- lib/nando/utils.rb
Class Method Summary collapse
- .get_annotation_from_file_path(file_path) ⇒ Object
-
.get_migration_version_and_name_from_file_path(file_path) ⇒ Object
accepts either a path or a file name.
Class Method Details
.get_annotation_from_file_path(file_path) ⇒ Object
3 4 5 |
# File 'lib/nando/utils.rb', line 3 def self.get_annotation_from_file_path (file_path) return " # NANDO: #{file_path}\n" end |
.get_migration_version_and_name_from_file_path(file_path) ⇒ Object
accepts either a path or a file name
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/nando/utils.rb', line 8 def self.get_migration_version_and_name_from_file_path (file_path) file_name = file_path.split('/')[-1] # get last part of the file path match = /^(\d+)\_(.*)\.rb$/.match(file_name) if match.nil? raise Nando::GenericError.new("'#{file_name}' is not a valid file name") end migration_version = match[1] # by this point, the file name has already been validated, so I don't need to double check migration_name = match[2] return migration_version, migration_name end |