Class: Moonrope::HtmlGenerator
- Inherits:
-
Object
- Object
- Moonrope::HtmlGenerator
- Defined in:
- lib/moonrope/html_generator.rb
Instance Attribute Summary collapse
-
#base ⇒ Object
readonly
Returns the value of attribute base.
-
#template_root_path ⇒ Object
readonly
Returns the value of attribute template_root_path.
Instance Method Summary collapse
- #generate(output_path) ⇒ Object
- #host ⇒ Object
-
#initialize(base, template_root_path) ⇒ HtmlGenerator
constructor
A new instance of HtmlGenerator.
- #prefix ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(base, template_root_path) ⇒ HtmlGenerator
Returns a new instance of HtmlGenerator.
8 9 10 11 |
# File 'lib/moonrope/html_generator.rb', line 8 def initialize(base, template_root_path) @base = base @template_root_path = template_root_path end |
Instance Attribute Details
#base ⇒ Object (readonly)
Returns the value of attribute base.
13 14 15 |
# File 'lib/moonrope/html_generator.rb', line 13 def base @base end |
#template_root_path ⇒ Object (readonly)
Returns the value of attribute template_root_path.
14 15 16 |
# File 'lib/moonrope/html_generator.rb', line 14 def template_root_path @template_root_path end |
Instance Method Details
#generate(output_path) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/moonrope/html_generator.rb', line 28 def generate(output_path) FileUtils.mkdir_p(output_path) FileUtils.cp_r(File.join(@template_root_path, 'assets'), File.join(output_path, 'assets')) FileUtils.touch(File.join(output_path, 'moonrope.txt')) # Index generate_file(output_path, "index.html", "index") # Controllers @base.controllers.select { |c| c.doc != false }.each do |controller| generate_file(output_path, File.join("controllers", "#{controller.name}.html"), "controller", {:controller => controller}) controller.actions.select { |_,a| a.doc != false }.each do |_, action| generate_file(output_path, File.join("controllers", controller.name.to_s, "#{action.name}.html"), "action", {:controller => controller, :action => action}) end end # Structures @base.structures.select { |s| s.doc != false }.each do |structure| generate_file(output_path, File.join("structures", "#{structure.name}.html"), "structure", {:structure => structure}) end # Authenticators @base.authenticators.values.select { |s| s.doc != false }.each do |authenticator| generate_file(output_path, File.join("authenticators", "#{authenticator.name}.html"), "authenticator", {:authenticator => authenticator}) end end |
#host ⇒ Object
16 17 18 |
# File 'lib/moonrope/html_generator.rb', line 16 def host ENV['MR_HOST'] end |
#prefix ⇒ Object
20 21 22 |
# File 'lib/moonrope/html_generator.rb', line 20 def prefix ENV['MR_PREFIX'] || 'api' end |
#version ⇒ Object
24 25 26 |
# File 'lib/moonrope/html_generator.rb', line 24 def version ENV['MR_VERSION'] || 'v1' end |