Class: RiparianGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- RiparianGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/riparian_generator.rb
Class Method Summary collapse
-
.next_migration_number(dirname) ⇒ Object
Implement the required interface for Rails::Generators::Migration.
- .source_root ⇒ Object
Instance Method Summary collapse
Class Method Details
.next_migration_number(dirname) ⇒ Object
Implement the required interface for Rails::Generators::Migration. Cribbed from DelayedJob
17 18 19 20 21 22 23 24 |
# File 'lib/generators/riparian_generator.rb', line 17 def self.next_migration_number(dirname) #:nodoc: next_migration_number = current_migration_number(dirname) + 1 if ActiveRecord::Base. [Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max else "%.3d" % next_migration_number end end |
.source_root ⇒ Object
11 12 13 |
# File 'lib/generators/riparian_generator.rb', line 11 def self.source_root @source_root ||= File.join(File.dirname(__FILE__), 'templates') end |
Instance Method Details
#create_app_files ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/generators/riparian_generator.rb', line 39 def create_app_files unless ["skip-controller"] template 'flow_tasks_controller.rb', 'app/controllers/flow_tasks_controller.rb' unless ["skip-views"] template 'flow_tasks_helper.rb', 'app/helpers/flow_tasks_helper.rb' directory 'views/flow_tasks', 'app/views/flow_tasks' end end end |
#create_migration_file ⇒ Object
49 50 51 52 53 |
# File 'lib/generators/riparian_generator.rb', line 49 def create_migration_file if defined?(ActiveRecord) migration_template 'migration.rb', 'db/migrate/create_riparian.rb' end end |
#create_routes ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/generators/riparian_generator.rb', line 26 def create_routes unless ["skip-controller"] route <<-EOT # Riparian routes resources :flow_tasks do member do get :run end end EOT end end |