Class: Sunrise::Widgets::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Sunrise::Widgets::InstallGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/sunrise/widgets/install_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.current_time ⇒ Object
14 15 16 17 |
# File 'lib/generators/sunrise/widgets/install_generator.rb', line 14 def self.current_time @current_time ||= Time.now @current_time += 1.minute end |
.next_migration_number(dirname) ⇒ Object
19 20 21 |
# File 'lib/generators/sunrise/widgets/install_generator.rb', line 19 def self.next_migration_number(dirname) current_time.strftime("%Y%m%d%H%M%S") end |
Instance Method Details
#copy_sweeper ⇒ Object
29 30 31 |
# File 'lib/generators/sunrise/widgets/install_generator.rb', line 29 def copy_sweeper copy_file('widget_sweeper.rb', 'app/sweepers/widget_sweeper.rb') end |
#create_migration ⇒ Object
33 34 35 36 37 |
# File 'lib/generators/sunrise/widgets/install_generator.rb', line 33 def create_migration if .migrations migration_template "create_widgets.rb", File.join('db/migrate', "sunrise_create_widgets.rb") end end |
#create_models ⇒ Object
23 24 25 26 27 |
# File 'lib/generators/sunrise/widgets/install_generator.rb', line 23 def create_models copy_file('widget.rb', 'app/models/widget.rb') copy_file('widget_position.rb', 'app/models/widget_position.rb') copy_file('widget_type.rb', 'app/models/widget_type.rb') end |