Class: EventCalendarGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- EventCalendarGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/event_calendar/event_calendar_generator.rb
Class Method Summary collapse
-
.next_migration_number(dirname) ⇒ Object
FIXME: Should be proxied to ActiveRecord::Generators::Base Implement the required interface for Rails::Generators::Migration.
Instance Method Summary collapse
- #controller_class_name ⇒ Object
- #controller_name ⇒ Object
- #do_it ⇒ Object
- #helper_class_name ⇒ Object
- #helper_name ⇒ Object
- #model_class_name ⇒ Object
- #model_name ⇒ Object
- #named_route_name ⇒ Object
- #table_name ⇒ Object
- #view_name ⇒ Object
Class Method Details
.next_migration_number(dirname) ⇒ Object
FIXME: Should be proxied to ActiveRecord::Generators::Base Implement the required interface for Rails::Generators::Migration.
84 85 86 87 88 89 90 |
# File 'lib/generators/event_calendar/event_calendar_generator.rb', line 84 def self.next_migration_number(dirname) #:nodoc: if ActiveRecord::Base. Time.now.utc.strftime("%Y%m%d%H%M%S") else "%.3d" % (current_migration_number(dirname) + 1) end end |
Instance Method Details
#controller_class_name ⇒ Object
54 55 56 |
# File 'lib/generators/event_calendar/event_calendar_generator.rb', line 54 def controller_class_name "#{@controller_name}_controller".classify end |
#controller_name ⇒ Object
58 59 60 |
# File 'lib/generators/event_calendar/event_calendar_generator.rb', line 58 def controller_name controller_class_name.underscore end |
#do_it ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/generators/event_calendar/event_calendar_generator.rb', line 16 def do_it say "Adding an all_day column", :yellow if [:use_all_day] say "Adding a color column", :yellow if [:use_color] if [:use_jquery] say "Using JQuery for scripting", :yellow copy_file 'jq_javascript.js', "public/javascripts/event_calendar.js" else say "Using Prototype for scripting", :yellow copy_file 'javascript.js', "public/javascripts/event_calendar.js" end copy_file "stylesheet.css", "public/stylesheets/event_calendar.css" unless .static_only? template "model.rb.erb", "app/models/#{model_name}.rb" template "controller.rb.erb", "app/controllers/#{controller_name}.rb" empty_directory "app/views/#{view_name}" template "view.html.erb", File.join("app/views/#{view_name}/index.html.erb") template "helper.rb.erb", "app/helpers/#{helper_name}.rb" migration_template "migration.rb.erb", "db/migrate/create_#{table_name}.rb" route "match '/#{view_name}(/:year(/:month))' => '#{view_name}#index', :as => :#{named_route_name}, :constraints => {:year => /\\d{4}/, :month => /\\d{1,2}/}" end end |
#helper_class_name ⇒ Object
62 63 64 |
# File 'lib/generators/event_calendar/event_calendar_generator.rb', line 62 def helper_class_name "#{@controller_name}_helper".classify end |
#helper_name ⇒ Object
66 67 68 |
# File 'lib/generators/event_calendar/event_calendar_generator.rb', line 66 def helper_name helper_class_name.underscore end |
#model_class_name ⇒ Object
42 43 44 |
# File 'lib/generators/event_calendar/event_calendar_generator.rb', line 42 def model_class_name @model_name.classify end |
#model_name ⇒ Object
46 47 48 |
# File 'lib/generators/event_calendar/event_calendar_generator.rb', line 46 def model_name model_class_name.underscore end |
#named_route_name ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/generators/event_calendar/event_calendar_generator.rb', line 74 def named_route_name if view_name.include?("/") view_name.split("/").join("_") else view_name end end |
#table_name ⇒ Object
70 71 72 |
# File 'lib/generators/event_calendar/event_calendar_generator.rb', line 70 def table_name model_name.pluralize end |
#view_name ⇒ Object
50 51 52 |
# File 'lib/generators/event_calendar/event_calendar_generator.rb', line 50 def view_name @controller_name.underscore end |