Class: DocMyRoutes::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/doc_my_routes/doc/config.rb

Overview

Inner class to maintain configuration settings

Defined Under Namespace

Classes: UnsupportedFormat

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/doc_my_routes/doc/config.rb', line 26

def initialize
  @title = @description = @examples_path_regexp = nil

  @destination_dir = File.join(Dir.pwd, 'doc', 'api')
  @format = :html
  @partial = false

  default_static_path = File.join(File.dirname(__FILE__), '..', '..',
                                  '..', 'etc')
  @css_file_path = File.join(default_static_path, 'css', 'base.css')
  @index_template_file = File.join(default_static_path, 'index.html.erb')
  @partial_template_file = File.join(default_static_path, 'partial.html.erb')
end

Instance Attribute Details

#css_file_pathObject

Project title



17
18
19
# File 'lib/doc_my_routes/doc/config.rb', line 17

def css_file_path
  @css_file_path
end

#descriptionObject

Project title



17
18
19
# File 'lib/doc_my_routes/doc/config.rb', line 17

def description
  @description
end

#destination_dirObject

Project title



17
18
19
# File 'lib/doc_my_routes/doc/config.rb', line 17

def destination_dir
  @destination_dir
end

#examples_path_regexpObject

Project title



17
18
19
# File 'lib/doc_my_routes/doc/config.rb', line 17

def examples_path_regexp
  @examples_path_regexp
end

#formatObject

Template used for the index.html



22
23
24
# File 'lib/doc_my_routes/doc/config.rb', line 22

def format
  @format
end

#index_template_fileObject (readonly)

Template used for the index.html



22
23
24
# File 'lib/doc_my_routes/doc/config.rb', line 22

def index_template_file
  @index_template_file
end

#partial_template_fileObject (readonly)

Template used for the index.html



22
23
24
# File 'lib/doc_my_routes/doc/config.rb', line 22

def partial_template_file
  @partial_template_file
end

#titleObject

Project title



17
18
19
# File 'lib/doc_my_routes/doc/config.rb', line 17

def title
  @title
end

Instance Method Details

#destination_cssObject

Calculate the relative path of the CSS used



53
54
55
56
# File 'lib/doc_my_routes/doc/config.rb', line 53

def destination_css
  # TODO: make it more robust
  File.basename(@css_file_path)
end

#examplesObject



40
41
42
# File 'lib/doc_my_routes/doc/config.rb', line 40

def examples
  @examples_path_regexp.nil? ? [] : Dir.glob(@examples_path_regexp)
end

#index_fileObject



58
59
60
61
# File 'lib/doc_my_routes/doc/config.rb', line 58

def index_file
  filename = @partial ? 'index_partial.html' : 'index.html'
  File.join(@destination_dir, filename)
end