Class: Rails::Generator::Commands::Create
- Inherits:
-
Object
- Object
- Rails::Generator::Commands::Create
- Defined in:
- lib/startups.rb
Overview
Here’s a readable version of the long string used above in route_code; but it should be kept on one line to avoid inserting extra whitespace into routes.rb when the generator is run: “map.#:name ‘#:name’,
:controller => '#{route_options[:controller]}',
:action => '#{route_options[:action]}'"
Instance Method Summary collapse
Instance Method Details
#generate(name) ⇒ Object
46 47 48 49 |
# File 'lib/startups.rb', line 46 def generate(name) logger.generate "running additional generator: #{name}" Rails::Generator::Scripts::Generate.new.run([name]) end |
#rm(relative_destination) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/startups.rb', line 51 def rm(relative_destination) destination = destination_path('public/index.html') if File.exist?(destination) logger.rm relative_destination FileUtils.rm(destination) end end |
#route(route_options) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/startups.rb', line 37 def route() sentinel = 'ActionController::Routing::Routes.draw do |map|' logger.route () #TODO add something here to prevent duplicating the route. Like file_contains? or something. gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |m| "#{m}\n #{route_code()}\n" end end |