12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/rack/generator/command.rb', line 12
def middleware(name, author, email, description)
@name = name.gsub(/\W/,'-').underscore.dasherize.gsub(/\Arack\-/, '')
@constant = @name.gsub(/-/, '_').camelize
@author = author
@email = email
@description = description
templates_dir = Pathname.new("#{self.class.source_root}/../../templates/middleware").realpath.to_s
templates = Dir.glob("#{templates_dir}/**/*.erb")
templates.each do |template_path|
rel_path = template_path.gsub(templates_dir, '')
new_path = "#{Dir.pwd}#{rel_path}".gsub('NAME', @name).gsub(/\.erb\Z/, '')
template template_path, new_path
end
end
|