Class: ActiveSeed::Generators::ExampleHtmlColorsGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- ActiveSeed::Generators::ExampleHtmlColorsGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/active_seed/example_html_colors_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.next_migration_number(dirname) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/generators/active_seed/example_html_colors_generator.rb', line 13 def self.next_migration_number(dirname) if ActiveRecord::Base. @add = @add.nil? ? 0.0 : @add + 0.1 Time.now.utc.strftime("%Y%m%d%H%M%S").to_f + @add else "%.3d" % (current_migration_number(dirname) + 1) end end |
.source_root ⇒ Object
9 10 11 |
# File 'lib/generators/active_seed/example_html_colors_generator.rb', line 9 def self.source_root @source_root ||= File.join(File.dirname(__FILE__), 'templates', 'example_html_colors') end |
Instance Method Details
#create_files ⇒ Object
22 23 24 25 26 |
# File 'lib/generators/active_seed/example_html_colors_generator.rb', line 22 def create_files install_dir = File.join('db', 'active_seed') directory 'html_colors', File.join(install_dir, "data", "html_colors") copy_file 'html_colors.yml', File.join(install_dir, 'html_colors.yml') end |
#create_migrations ⇒ Object
33 34 35 |
# File 'lib/generators/active_seed/example_html_colors_generator.rb', line 33 def create_migrations migration_template 'create_html_colors.rb', File.join("db", "migrate", "create_html_colors.rb") end |
#create_models ⇒ Object
28 29 30 31 |
# File 'lib/generators/active_seed/example_html_colors_generator.rb', line 28 def create_models copy_file 'html_color.rb', File.join("app", "models", 'html_color.rb') copy_file 'html_color_family.rb', File.join("app", "models", 'html_color_family.rb') end |