Module: RailsAssist::Migration::ClassMethods
- Included in:
- Artifact::Migration::FileName
- Defined in:
- lib/migration_assist/class_methods.rb
Instance Method Summary collapse
-
#current_migration_number(dirname) ⇒ Object
:nodoc:.
-
#latest_migration_file(dirname, file_name) ⇒ Object
:nodoc:.
-
#migration_exists?(dirname, file_name) ⇒ Boolean
(also: #first_migration_file)
:nodoc:.
-
#migration_lookup_at(dirname) ⇒ Object
:nodoc:.
-
#next_migration_number(dirname) ⇒ Object
:nodoc:.
Instance Method Details
#current_migration_number(dirname) ⇒ Object
:nodoc:
38 39 40 41 42 |
# File 'lib/migration_assist/class_methods.rb', line 38 def current_migration_number(dirname) #:nodoc: migration_lookup_at(dirname).collect do |file| File.basename(file).split("_").first.to_i end.max.to_i end |
#latest_migration_file(dirname, file_name) ⇒ Object
:nodoc:
34 35 36 |
# File 'lib/migration_assist/class_methods.rb', line 34 def latest_migration_file(dirname, file_name) #:nodoc: migration_lookup_at(dirname).grep(/\d+_#{file_name}.rb$/).sort.last end |
#migration_exists?(dirname, file_name) ⇒ Boolean Also known as: first_migration_file
:nodoc:
29 30 31 |
# File 'lib/migration_assist/class_methods.rb', line 29 def migration_exists?(dirname, file_name) #:nodoc: migration_lookup_at(dirname).grep(/\d+_#{file_name}.rb$/).first end |
#migration_lookup_at(dirname) ⇒ Object
:nodoc:
25 26 27 |
# File 'lib/migration_assist/class_methods.rb', line 25 def migration_lookup_at(dirname) #:nodoc: Dir.glob("#{dirname}/[0-9]*_*.rb") end |
#next_migration_number(dirname) ⇒ Object
:nodoc:
44 45 46 47 48 49 50 |
# File 'lib/migration_assist/class_methods.rb', line 44 def next_migration_number(dirname) #:nodoc: orm = RailsAssist::Migration.orm || Rails.configuration.generators.[:rails][:orm] require "rails/generators/#{orm}" "#{orm.to_s.camelize}::Generators::Base".constantize.next_migration_number(dirname) rescue raise NotImplementedError end |