Module: RapiDoc::RapiConfig

Included in:
RAPIDoc
Defined in:
lib/rapi_doc/rapi_config.rb

Instance Method Summary collapse

Instance Method Details

#config_dir(f = nil) ⇒ Object



11
12
13
14
# File 'lib/rapi_doc/rapi_config.rb', line 11

def config_dir(f = nil)
  @config_dir ||= File.join(::Rails.root.to_s, 'config/rapi_doc')
  form_file_name @config_dir, f
end

#controller_dir(f = nil) ⇒ Object



21
22
23
24
# File 'lib/rapi_doc/rapi_config.rb', line 21

def controller_dir(f = nil)
  @controller_dir ||= File.join(::Rails.root.to_s, 'app/controllers/')
  form_file_name @controller_dir, f
end

#form_file_name(dir, file) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/rapi_doc/rapi_config.rb', line 32

def form_file_name(dir, file)
  case file
  when NilClass then dir
  when String then File.join(dir, file)
  else raise ArgumentError, "Invalid argument #{file}"
  end
end

#target_dir(f = nil) ⇒ Object



16
17
18
19
# File 'lib/rapi_doc/rapi_config.rb', line 16

def target_dir(f = nil)
  @target_dir ||= File.join(::Rails.root.to_s, 'public/apidoc/')
  form_file_name @target_dir, f 
end

#temp_dir(f = nil) ⇒ Object

WARNING! - temp_dir will return different location for different runs. Use with Caution!



27
28
29
30
# File 'lib/rapi_doc/rapi_config.rb', line 27

def temp_dir(f = nil)
  @temp_dir ||= "#{Dir.mktmpdir("apidoc")}/"
  form_file_name @temp_dir, f
end

#template_dir(f = nil) ⇒ Object

following helper methods return the directory location if no file type is specified or return the file location for that directory if one is supplied



6
7
8
9
# File 'lib/rapi_doc/rapi_config.rb', line 6

def template_dir(f = nil)
  @template_dir ||= File.join(File.dirname(__FILE__), '../../templates')
  form_file_name @template_dir, f
end