Class: Had::Configuration
- Inherits:
-
Object
- Object
- Had::Configuration
- Defined in:
- lib/had/configuration.rb
Constant Summary collapse
- DEFAULT_FORMATTERS =
%w(html json)
Instance Attribute Summary collapse
-
#formatters ⇒ Object
Returns the value of attribute formatters.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#output_path ⇒ Object
Returns the value of attribute output_path.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#templates_path ⇒ Object
Returns the value of attribute templates_path.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/had/configuration.rb', line 30 def initialize Had.logger.level = Logger::INFO if ENV['APP_HOST'].nil? @host = "example.com" else @host = ENV['APP_HOST'] end if ENV['APP_ROOT'].nil? raise 'APP_ROOT is not defined' else @root = ENV['APP_ROOT'] end @templates_path = File.('../templates', __FILE__) @output_path = File.join(@root, '/doc/had') FileUtils.mkdir_p @output_path requested_formats = (ENV['HAD_FORMATTERS'].to_s).split(',') requested_formats.sort_by!{|fmt| [DEFAULT_FORMATTERS.index(fmt), fmt]} @formatters = requested_formats.empty? ? %w(html) : requested_formats @title = 'Hanami Api Documentation' end |
Instance Attribute Details
#formatters ⇒ Object
Returns the value of attribute formatters.
59 60 61 |
# File 'lib/had/configuration.rb', line 59 def formatters @formatters end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
60 61 62 |
# File 'lib/had/configuration.rb', line 60 def host @host end |
#output_path ⇒ Object
Returns the value of attribute output_path.
57 58 59 |
# File 'lib/had/configuration.rb', line 57 def output_path @output_path end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
60 61 62 |
# File 'lib/had/configuration.rb', line 60 def root @root end |
#templates_path ⇒ Object
Returns the value of attribute templates_path.
56 57 58 |
# File 'lib/had/configuration.rb', line 56 def templates_path @templates_path end |
#title ⇒ Object
Returns the value of attribute title.
58 59 60 |
# File 'lib/had/configuration.rb', line 58 def title @title end |