Class: ActsAsCleo::UpdateGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/acts_as_cleo/update/update_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/generators/acts_as_cleo/update/update_generator.rb', line 27

def self.next_migration_number(dirname)
  next_migration_number = current_migration_number(dirname) + 1
  if ActiveRecord::Base.timestamped_migrations
    [Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max
  else
    "%.3d" % next_migration_number
  end
end

Instance Method Details

#copy_migration_and_configObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/generators/acts_as_cleo/update/update_generator.rb', line 12

def copy_migration_and_config
  #Resque workers
  %w{update create delete}.each do |life|
    remove_file "app/jobs/#{life}.rb"
  end
  remove_file "app/jobs/cleo_processor.rb"

  #Resque workers
  copy_file "jobs/cleo_connection_processor.rb", "app/jobs/cleo_connection_processor.rb"
  copy_file "jobs/cleo_element_processor.rb", "app/jobs/cleo_element_processor.rb"

  #create migration
  migration_template 'update.rb', 'db/migrate/update_acts_as_cleo.rb'
end