11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# 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
|