Class: CalMonths::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- CalMonths::Generators::InstallGenerator
- Defined in:
- lib/generators/cal_months/install_generator.rb
Instance Method Summary collapse
- #add_helper ⇒ Object
- #add_migrations ⇒ Object
- #add_routes ⇒ Object
- #copy_locale ⇒ Object
- #copy_stylesheets ⇒ Object
- #copy_views ⇒ Object
- #detect_css_format ⇒ Object
Instance Method Details
#add_helper ⇒ Object
27 28 29 |
# File 'lib/generators/cal_months/install_generator.rb', line 27 def add_helper insert_into_file "app/helpers/application_helper.rb", "\n include CalMonthsHelper\n", after: "module ApplicationHelper" end |
#add_migrations ⇒ Object
44 45 46 47 |
# File 'lib/generators/cal_months/install_generator.rb', line 44 def add_migrations copy_file '../../../db/migrate/create_cal_events.rb', "db/migrate/#{Time.now.to_i}_create_cal_events.rb" copy_file '../../../db/migrate/create_cal_months.rb', "db/migrate/#{Time.now.to_i + 1}_create_cal_months.rb" end |
#add_routes ⇒ Object
39 40 41 42 |
# File 'lib/generators/cal_months/install_generator.rb', line 39 def add_routes route "get '/cal_months/calendar/:year-:month', to: 'cal_months#show', as: :cal_month" route "get '/cal_months/current-events/:id', to: 'cal_months#show_current_event', as: :current_event" end |
#copy_locale ⇒ Object
8 9 10 11 |
# File 'lib/generators/cal_months/install_generator.rb', line 8 def copy_locale copy_file '../../../config/locales/cal_months_en.yml', 'config/locales/cal_months_en.yml' copy_file '../../../config/locales/cal_months_cs.yml', 'config/locales/cal_months_cs.yml' end |
#copy_stylesheets ⇒ Object
13 14 15 16 17 |
# File 'lib/generators/cal_months/install_generator.rb', line 13 def copy_stylesheets copy_file '../../../app/assets/javascripts/cal_months.js.coffee', 'app/assets/javascripts/cal_months.js.coffee' copy_file '../../../app/assets/stylesheets/cal_months.css.sass', 'app/assets/stylesheets/cal_months.css.sass' insert_into_file "app/assets/stylesheets/application#{detect_css_format[0]}", "\n#{detect_css_format[1]} require cal_months\n", :after => "require_self" end |
#copy_views ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/generators/cal_months/install_generator.rb', line 31 def copy_views copy_file '../../../app/views/cal_months/_calendar.html.haml', 'app/views/cal_months/_calendar.html.haml' copy_file '../../../app/views/cal_months/_month.html.haml', 'app/views/cal_months/_month.html.haml' copy_file '../../../app/views/cal_months/_upcoming_events.html.haml', 'app/views/cal_months/_upcoming_events.html.haml' copy_file '../../../app/views/cal_months/show.js.erb', 'app/views/cal_months/show.js.erb' copy_file '../../../app/views/cal_months/show_current_event.js.erb', 'app/views/cal_months/show_current_event.js.erb' end |
#detect_css_format ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/generators/cal_months/install_generator.rb', line 19 def detect_css_format return ['.css', ' *='] if File.exist?('app/assets/stylesheets/application.css') return ['.css.sass', ' //='] if File.exist?('app/assets/stylesheets/application.css.sass') return ['.sass', ' //='] if File.exist?('app/assets/stylesheets/application.sass') return ['.css.scss', ' //='] if File.exist?('app/assets/stylesheets/application.css.scss') return ['.scss', ' //='] if File.exist?('app/assets/stylesheets/application.scss') end |