class Utter::Generators::Ext

Public Instance Methods

create_ext(params={}) click to toggle source
# File lib/generators/ext_gem_generator.rb, line 11
      def create_ext params={}
        @ext_name = params[:ext_name].downcase

        empty_directory "domain/#{@ext_name.downcase}/lib/internals"

        @file = <<-FOO
module #{@ext_name.capitalize} 
  VERSION = "0.0.0"
  class Main
    def initialize(app, opts={}, params={})
      @app      = app
      @opts     = opts 
      @params   = params 
    end

    def call(env)
      #TODO manipulate value objects, before passing to the stack!
      @app.call(env)
      #TODO manipulate value objects, after passing to the stack!
    end
  end
end
        FOO
        create_file "domain/#{@ext_name.downcase}/lib/main.rb"
        append_to_file "domain/#{@ext_name.downcase}/lib/main.rb", @file

        empty_directory "domain/#{@ext_name.downcase}/spec"
        create_file "domain/#{@ext_name.downcase}/spec/spec_helper.rb"
        create_file "domain/#{@ext_name.downcase}/spec/main_spec.rb"

        create_file "domain/#{@ext_name.downcase}/README.md"
      end