lib/dry/web/roda/generators/flat_project.rb in dry-web-roda-0.6.3 vs lib/dry/web/roda/generators/flat_project.rb in dry-web-roda-0.7.0
- old
+ new
@@ -1,30 +1,36 @@
require "securerandom"
-require "dry/web/roda/generate"
-require "dry/web/roda/generators/inflections"
+require "dry/web/roda/generators/abstract_project"
module Dry
module Web
module Roda
module Generators
- class FlatProject
- attr_reader :generate
+ class FlatProject < AbstractProject
+ def populate_templates
+ super
+ add_views
+ add_web
+ end
- def initialize
- @generate = Generate.new("flat_project")
+ private
+
+ def add_boot
+ add_template("flat_project/boot.rb.tt", "system/boot.rb")
end
- def call(target_dir)
- generate.(target_dir, prepare_scope(target_dir))
+ def add_application
+ add_template("flat_project/application.rb.tt", "system/#{underscored_project_name}/application.rb")
end
- private
+ def add_views
+ add_template('welcome.rb.tt', "lib/#{underscored_project_name}/views/welcome.rb")
+ end
- def prepare_scope(target_dir)
- {
- underscored_app_name: Inflections.underscored_name(target_dir),
- camel_cased_app_name: Inflections.camel_cased_name(target_dir)
- }
+ def add_web
+ add_template('example_routes.rb.tt', 'web/routes/example.rb')
+ add_template('application.html.slim', 'web/templates/layouts/application.html.slim')
+ add_template('welcome.html.slim', 'web/templates/welcome.html.slim')
end
end
end
end
end