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.



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.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.



59
60
61
# File 'lib/had/configuration.rb', line 59

def formatters
  @formatters
end

#hostObject (readonly)

Returns the value of attribute host.



60
61
62
# File 'lib/had/configuration.rb', line 60

def host
  @host
end

#output_pathObject

Returns the value of attribute output_path.



57
58
59
# File 'lib/had/configuration.rb', line 57

def output_path
  @output_path
end

#rootObject (readonly)

Returns the value of attribute root.



60
61
62
# File 'lib/had/configuration.rb', line 60

def root
  @root
end

#templates_pathObject

Returns the value of attribute templates_path.



56
57
58
# File 'lib/had/configuration.rb', line 56

def templates_path
  @templates_path
end

#titleObject

Returns the value of attribute title.



58
59
60
# File 'lib/had/configuration.rb', line 58

def title
  @title
end