Sha256: e69c67faa0f2f20bf29435fa7b8348ab4fc563a6c9f37f45f3ad301be33e4654
Contents?: true
Size: 1.16 KB
Versions: 3
Compression:
Stored size: 1.16 KB
Contents
class HoboGenerator < Rails::Generator::Base def manifest if options[:add_routes] routes_path = File.join(RAILS_ROOT, "config/routes.rb") route = " Hobo.add_routes(map)\n" route_src = File.read(routes_path) unless route_src.include?(route) head = "ActionController::Routing::Routes.draw do |map|" route_src.sub!(head, head + "\n\n" + route) File.open(routes_path, 'w') {|f| f.write(route_src) } end end record do |m| m.directory File.join("app/views/taglibs") m.directory File.join("app/views/taglibs/themes") m.directory File.join("public/hobothemes") m.template "application.dryml", File.join("app/views/taglibs/application.dryml") m.file "guest.rb", File.join("app/models/guest.rb") m.file "dryml-support.js", File.join("public/javascripts/dryml-support.js") end end protected def banner "Usage: #{$0} #{spec.name} [--add-routes]" end def add_options!(opt) opt.separator '' opt.separator 'Options:' opt.on("--add-routes", "Add Hobo routes to config/routes.rb") { |v| options[:add_routes] = v } end end
Version data entries
3 entries across 3 versions & 1 rubygems