Class: Had::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/had/configuration.rb

Constant Summary collapse

DEFAULT_FORMATTERS =
%w(html json)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/had/configuration.rb', line 26

def initialize
  Had.logger.level = Logger::INFO

  if ENV['APP_ROOT'].nil?
    raise 'APP_ROOT is not defined'
  else
    @root = ENV['APP_ROOT']
  end

  @templates_path = File.expand_path('../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

#formattersObject

Returns the value of attribute formatters.



49
50
51
# File 'lib/had/configuration.rb', line 49

def formatters
  @formatters
end

#output_pathObject

Returns the value of attribute output_path.



47
48
49
# File 'lib/had/configuration.rb', line 47

def output_path
  @output_path
end

#rootObject (readonly)

Returns the value of attribute root.



50
51
52
# File 'lib/had/configuration.rb', line 50

def root
  @root
end

#templates_pathObject

Returns the value of attribute templates_path.



46
47
48
# File 'lib/had/configuration.rb', line 46

def templates_path
  @templates_path
end

#titleObject

Returns the value of attribute title.



48
49
50
# File 'lib/had/configuration.rb', line 48

def title
  @title
end