Sha256: c0f93bbb1bb95d1b339fc68ed87acfcf71b1c00d29adc98d571c2c1d18e07e3a

Contents?: true

Size: 945 Bytes

Versions: 35

Compression:

Stored size: 945 Bytes

Contents

module Merb
  module Generators

    class NamespacedGenerator < NamedGenerator
      
      # NOTE: Currently this is not inherited, it will have to be declared in each generator
      # that inherits from this.
      first_argument :name, :required => true
      
      def modules
        chunks[0..-2]
      end

      def class_name
        chunks.last.gsub('-', '_').camel_case
      end
      
      alias_method :module_name, :class_name
      
      def file_name
        chunks.last.snake_case
      end
      
      alias_method :base_name, :file_name

      def full_class_name
        (modules + [class_name]).join('::')
      end
      
      def base_path
        File.join(*snake_cased_chunks[0..-2])
      end

      protected

      def snake_cased_chunks
        chunks.map { |c| c.snake_case }
      end

      def chunks
        name.gsub('/', '::').split('::').map { |c| c.camel_case }
      end
      
    end
  
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
merb-gen-1.1.3 lib/merb-gen/namespaced_generator.rb
merb-gen-1.1.2 lib/merb-gen/namespaced_generator.rb
merb-gen-1.1.1 lib/merb-gen/namespaced_generator.rb
merb-gen-1.1.0 lib/merb-gen/namespaced_generator.rb
merb-gen-1.1.0.rc1 lib/merb-gen/namespaced_generator.rb
merb-gen-1.1.0.pre lib/merb-gen/namespaced_generator.rb
merb-gen-1.0.15 lib/merb-gen/namespaced_generator.rb
merb-gen-1.0.14 lib/merb-gen/namespaced_generator.rb
merb-gen-1.0.13 lib/merb-gen/namespaced_generator.rb
merb-gen-1.0.12 lib/merb-gen/namespaced_generator.rb
merb-gen-0.9.10 lib/merb-gen/namespaced_generator.rb
merb-gen-0.9.13 lib/merb-gen/namespaced_generator.rb
merb-gen-0.9.12 lib/merb-gen/namespaced_generator.rb
merb-gen-0.9.11 lib/merb-gen/namespaced_generator.rb
merb-gen-0.9.4 lib/merb-gen/namespaced_generator.rb
merb-gen-0.9.6 lib/merb-gen/namespaced_generator.rb
merb-gen-0.9.8 lib/merb-gen/namespaced_generator.rb
merb-gen-0.9.7 lib/merb-gen/namespaced_generator.rb
merb-gen-0.9.9 lib/merb-gen/namespaced_generator.rb
merb-gen-0.9.5 lib/merb-gen/namespaced_generator.rb