Sha256: 6d4db89e5eff9ae38edc2b12d96e51540fcc982392d3542a1173ca57659cacaa

Contents?: true

Size: 1.05 KB

Versions: 8

Compression:

Stored size: 1.05 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)
      return if 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

    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.file "application.dryml", File.join("app/views/taglibs/application.dryml")
      m.file "guest.rb", File.join("app/models/guest.rb")
    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

8 entries across 8 versions & 1 rubygems

Version Path
hobo-0.6 hobo_files/plugin/generators/hobo/hobo_generator.rb
hobo-0.6.1 hobo_files/plugin/generators/hobo/hobo_generator.rb
hobo-0.6.2 hobo_files/plugin/generators/hobo/hobo_generator.rb
hobo-0.6.3 hobo_files/plugin/generators/hobo/hobo_generator.rb
hobo-0.6.4 hobo_files/plugin/generators/hobo/hobo_generator.rb
hobo-0.7.0 hobo_files/plugin/generators/hobo/hobo_generator.rb
hobo-0.7.1 hobo_files/plugin/generators/hobo/hobo_generator.rb
hobo-0.7.2 hobo_files/plugin/generators/hobo/hobo_generator.rb