Module: Spree::GeneratorBaseExtension

Defined in:
lib/generators/generator_base_extension.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
5
6
7
8
9
# File 'lib/generators/generator_base_extension.rb', line 4

def self.included(base)
  base.class_eval %{
    alias_method_chain :existing_migrations, :extensions
    alias_method_chain :current_migration_number, :extensions
  }
end

Instance Method Details

#current_migration_number_with_extensionsObject



15
16
17
18
19
20
# File 'lib/generators/generator_base_extension.rb', line 15

def current_migration_number_with_extensions
  Dir.glob("#{destination_path(@migration_directory)}/[0-9]*.rb").inject(0) do |max, file_path|
    n = File.basename(file_path).split('_', 2).first.to_i
    if n > max then n else max end
  end
end

#existing_migrations_with_extensions(file_name) ⇒ Object



11
12
13
# File 'lib/generators/generator_base_extension.rb', line 11

def existing_migrations_with_extensions(file_name)
  Dir.glob("#{destination_path(@migration_directory)}/[0-9]*_*.rb").grep(/[0-9]+_#{file_name}.rb$/)
end