Sha256: 347d94f0aaa300e30c7be7462cd4d71eb5a562e579593c6f96747a79ca819600

Contents?: true

Size: 1.62 KB

Versions: 3

Compression:

Stored size: 1.62 KB

Contents

require 'rails/generators'

module Redde
  module Generators
    class LayoutGenerator < ::Rails::Generators::Base
      source_root File.expand_path('../templates', __FILE__)
      desc 'Standart redde admin generator'

      attr_reader :app_name

      def make_views
        %w(admin login).each do |layout|
          template "layouts/#{layout}#{ext}", "app/views/layouts/#{layout}#{ext}"
        end
        directory 'base', 'app/views/admin/base'
      end

      def make_js
        %w(admin.js).each do |js|
          template "assets/javascripts/#{js}", "app/assets/javascripts/#{js}"
        end
        directory 'assets/javascripts/admin', 'app/assets/javascripts/admin'
      end

      def make_css
        directory 'assets/stylesheets/admin', 'app/assets/stylesheets/admin'
        directory 'assets/redactor', 'app/assets'
      end

      def make_helpers
        template 'helpers/admin_helper.rb', 'app/helpers/admin_helper.rb'
      end

      def make_images
        directory 'assets/images/admin', 'app/assets/images/admin'
      end

      def make_controllers
        template 'controllers/base_controller.rb', 'app/controllers/admin/base_controller.rb'
        template 'controllers/managers_controller.rb', 'app/controllers/admin/managers_controller.rb'
        directory 'controllers/managers', 'app/controllers/managers'
      end

      def fix_routes
        route("devise_for :managers, controllers: { registrations: 'managers/registrations' }")
      end

      private

      def ext
        '.html.haml'
      end

      def app_name
        Rails.application.class.to_s.split('::').first
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
redde-0.1.13 lib/generators/redde/layout/layout_generator.rb
redde-0.1.12 lib/generators/redde/layout/layout_generator.rb
redde-0.1.11 lib/generators/redde/layout/layout_generator.rb