Sha256: 09ff3061a5d98f11249d8f3ee2e13d49739a162ba5c5edef2e935b6893ff81e1

Contents?: true

Size: 986 Bytes

Versions: 1

Compression:

Stored size: 986 Bytes

Contents

# -*- encoding : utf-8 -*-

module Cardio
  module Generators
    # methods shared across Generator bases (which inherit from Rails generator classes)
    module ClassMethods
      def source_root path=nil
        if path
          @_card_source_root = path
        else
          @_card_source_root ||= File.expand_path(
            "../../../generators/card/#{generator_name}/templates", __FILE__
          )
        end
      end

      # Override Rails default banner (using card/decko for the command name).
      def banner
        usage_arguments = arguments.map(&:usage).join " "
        text = "#{banner_command} generate #{namespace} #{usage_arguments} [options]"
        text.gsub(/\s+/, " ")
      end

      def banner_command
        "card"
      end

      # Override Rails namespace handling so we can put generators in `module Cardio`
      def namespace name=nil
        return super if name
        @namespace ||= super.sub(/cardio:/, "")
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
card-1.102.0 lib/cardio/generators/class_methods.rb