Sha256: 9e9c4f95564f5ed14968dd8eac44001aaf73bf89531be104bec3566f587f92e5

Contents?: true

Size: 1017 Bytes

Versions: 57

Compression:

Stored size: 1017 Bytes

Contents

require 'generators/hobo_support/eval_template'

module Hobo
  class RoutesGenerator < Rails::Generators::Base
    source_root File.expand_path('../templates', __FILE__)

    include Generators::HoboSupport::EvalTemplate

    def self.banner
      "rails generate hobo:routes #{self.arguments.map(&:usage).join(' ')} [options]"
    end

    def generate_routes
      Hobo::Routes.reset_linkables
      h = Hobo::Engine.config.hobo
      template_name = 'hobo_routes.rb.erb'
      if h.read_only_file_system
        # just fill the @linkable_keys without writing any file
        eval_template template_name
      else
        template template_name, h.routes_path
      end
    end

private

    def subsites
      [nil, *Hobo.subsites]
    end

    def controllers_for(subsite)
      Hobo::Controller::Model.all_controllers(subsite, :force).select { |c| c < Hobo::Controller::Model }
    end

    def router_for(subsite, controller)
      Generators::Hobo::Routes::Router.new(subsite, controller)
    end

  end
end

Version data entries

57 entries across 57 versions & 1 rubygems

Version Path
hobo-2.2.6 lib/generators/hobo/routes/routes_generator.rb
hobo-2.2.5 lib/generators/hobo/routes/routes_generator.rb
hobo-2.2.4 lib/generators/hobo/routes/routes_generator.rb
hobo-2.2.3 lib/generators/hobo/routes/routes_generator.rb
hobo-2.2.2 lib/generators/hobo/routes/routes_generator.rb
hobo-2.2.1 lib/generators/hobo/routes/routes_generator.rb
hobo-2.2.0 lib/generators/hobo/routes/routes_generator.rb
hobo-2.1.2 lib/generators/hobo/routes/routes_generator.rb
hobo-2.1.1 lib/generators/hobo/routes/routes_generator.rb
hobo-2.1.0 lib/generators/hobo/routes/routes_generator.rb
hobo-2.1.0.pre4 lib/generators/hobo/routes/routes_generator.rb
hobo-2.1.0.pre3 lib/generators/hobo/routes/routes_generator.rb
hobo-2.1.0.pre2 lib/generators/hobo/routes/routes_generator.rb
hobo-2.1.0.pre1 lib/generators/hobo/routes/routes_generator.rb
hobo-2.0.1 lib/generators/hobo/routes/routes_generator.rb
hobo-2.0.0 lib/generators/hobo/routes/routes_generator.rb
hobo-2.0.0.pre10 lib/generators/hobo/routes/routes_generator.rb
hobo-2.0.0.pre9 lib/generators/hobo/routes/routes_generator.rb
hobo-2.0.0.pre8 lib/generators/hobo/routes/routes_generator.rb
hobo-1.3.3 lib/generators/hobo/routes/routes_generator.rb