Sha256: 8947d2efc6eafb28e641536d28f958c6976b0808fc3fe278213bd934e9441557

Contents?: true

Size: 1.64 KB

Versions: 17

Compression:

Stored size: 1.64 KB

Contents

gem 'templater', '>= 0.3.2'
require 'templater'

module Bowline
  module Generators
    extend Templater::Manifold
    
    desc <<-DESC
      Generate components for your application or entirely new applications.
    DESC
    class Generator < Templater::Generator
      def with_modules(modules, options={}, &block)
        indent = options[:indent] || 0
        text = capture(&block)
        modules.each_with_index do |mod, i|
          concat(("  " * (indent + i)) + "module #{mod}\n", block.binding)
        end
        text = text.to_a.map{ |line| ("  " * modules.size) + line }.join
        concat(text, block.binding)
        modules.reverse.each_with_index do |mod, i|
          concat(("  " * (indent + modules.size - i - 1)) + "end # #{mod}\n", block.binding)
        end
      end
      
      def self.source_root
        File.join(File.dirname(__FILE__), *%w[.. .. templates])
      end
    end
    
    class NamedGenerator < Generator
      # 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 initialize(*args)
        super
      end
      
      def class_name
        name.gsub('-', '_').camel_case
      end
      alias_method :module_name, :class_name

      def file_name
        name.snake_case
      end
      alias_method :base_name, :file_name

      def symbol_name
        file_name.gsub('-', '_')
      end
    end
  end
end

require "bowline/generators/application"
require "bowline/generators/binder"
require "bowline/generators/model"
require "bowline/generators/helper"
require "bowline/generators/migration"

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
maccman-bowline-0.3.0 lib/bowline/generators.rb
maccman-bowline-0.3.1 lib/bowline/generators.rb
maccman-bowline-0.3.3 lib/bowline/generators.rb
maccman-bowline-0.3.5 lib/bowline/generators.rb
maccman-bowline-0.3.6 lib/bowline/generators.rb
maccman-bowline-0.3.7 lib/bowline/generators.rb
maccman-bowline-0.3.9 lib/bowline/generators.rb
maccman-bowline-0.4.0 lib/bowline/generators.rb
maccman-bowline-0.4.1 lib/bowline/generators.rb
maccman-bowline-0.4.3 lib/bowline/generators.rb
maccman-bowline-0.4.4 lib/bowline/generators.rb
maccman-bowline-0.4.5 lib/bowline/generators.rb
maccman-bowline-0.4.6 lib/bowline/generators.rb
maccman-bowline-0.4.7 lib/bowline/generators.rb
maccman-bowline-0.4.8 lib/bowline/generators.rb
bowline-0.4.6 lib/bowline/generators.rb
bowline-0.3.9 lib/bowline/generators.rb