Sha256: e268dc3c1ba61a9bb454994a81d901cd486b517e97ac6b96f1f1ab1a4ed6940a

Contents?: true

Size: 1.89 KB

Versions: 1

Compression:

Stored size: 1.89 KB

Contents

module Chaplin
  module Generators
    module Helpers

      def asset_path
        File.join('app', 'assets')
      end

      def javascript_path
        File.join(asset_path, 'javascripts')
      end

      def model_path
        File.join(javascript_path, "models")
      end

      def view_path
        File.join(javascript_path, "views")
      end

      def controller_path
        File.join(javascript_path, "controllers")
      end

      def lib_path
        File.join(javascript_path, "lib")
      end

      def base_path(path)
        File.join(path, 'base')
      end

      def template_path
        File.join(asset_path, "templates")
      end

      def singular_file_name
        "#{file_name.singularize}#{@ext}"
      end

      def plural_file_name
        "#{file_name.pluralize}#{@ext}"
      end

      def router_file_name
        "#{file_name.pluralize}_router#{@ext}"
      end

      def view_file_name
        "#{file_name.pluralize}_index#{@ext}"
      end

      def model_namespace
        [app_name, "Models", file_name.singularize.camelize].join(".")
      end

      def collection_namespace
        [app_name, "Collections", file_name.pluralize.camelize].join(".")
      end

      def router_namespace
        [app_name, "Routers", file_name.pluralize.camelize].join(".")
      end

      def view_namespace
        [app_name, "Views", "#{file_name.pluralize.camelize}Index"].join(".")
      end

      def template_namespace
        File.join(file_path.pluralize, "index")
      end

      def app_name
        rails_app_name.camelize
      end

      def app_filename
        rails_app_name.underscore
      end

      def rails_app_name
        Rails.application.class.name.split('::').first
      end

      def layout_path
        Dir['app/views/layouts/application*'].first
      end

      def display(output, color = :green)
        say(" - #{output}", color)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
chaplin-on-rails-0.7.0.1 lib/generators/chaplin/helpers.rb