Sha256: 73632a46c662744502cf50994f4ec98281c92c27159ffd385990b41e0da91930

Contents?: true

Size: 973 Bytes

Versions: 10

Compression:

Stored size: 973 Bytes

Contents

require 'rails/generators/joosy/joosy_base'

module Joosy
  module Generators
    class PageGenerator < ::Rails::Generators::JoosyBase
      source_root File.join(File.dirname(__FILE__), 'templates')

      def create_files
        super

        template "app/pages/template.js.coffee", "#{app_path}/pages/#{namespace_path}/#{file_name}.js.coffee"

        create_file "#{app_path}/templates/pages/#{namespace_path}/#{file_name}.jst.#{options[:template_kind]}"
      end

      protected

      def app_path
        if class_path.size < 2
          puts <<HELP
Usage: rails generate joosy:page joosy_app_name/page_namespace/page_name
Tip: do not add Page suffix to page_name
HELP
          exit 1
        end
        class_path[0]
      end

      def namespace_path
        File.join class_path[1..-1]
      end

      def namespace_name
        class_path[1..-1].map(&:camelize).join '.'
      end

      def layout_name
        class_path[1]
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
joosy-1.1.2 lib/rails/generators/joosy/page_generator.rb
joosy-1.1.1 lib/rails/generators/joosy/page_generator.rb
joosy-1.1.0 lib/rails/generators/joosy/page_generator.rb
joosy-1.1.0.alpha.3 lib/rails/generators/joosy/page_generator.rb
joosy-1.1.0.alpha.2 lib/rails/generators/joosy/page_generator.rb
joosy-1.1.0.alpha.1 lib/rails/generators/joosy/page_generator.rb
joosy-1.0.0.RC7 lib/rails/generators/joosy/page_generator.rb
joosy-1.0.0.RC6 lib/rails/generators/joosy/page_generator.rb
joosy-1.0.0.RC5 lib/rails/generators/joosy/page_generator.rb
joosy-1.0.0.RC4 lib/rails/generators/joosy/page_generator.rb