Module: Rapidoc::Config
- Included in:
- Rapidoc
- Defined in:
- lib/rapidoc/config.rb
Overview
This module has all config information about directories and config files.
Constant Summary collapse
- GEM_CONFIG_DIR =
File.join( File.dirname(__FILE__), 'config' )
- GEM_ASSETS_DIR =
File.join( File.dirname(__FILE__), 'templates/assets' )
- GEM_EXAMPLES_DIR =
File.join( File.dirname(__FILE__), 'config/examples')
- @@config =
nil
Instance Method Summary collapse
-
#actions_dir(f = nil) ⇒ Object
returns the directory where rapidoc generates actions (html files).
- #config_dir(f = nil) ⇒ Object
- #config_file_path ⇒ Object
- #controller_dir(f = nil) ⇒ Object
- #controllers_extension ⇒ Object
- #default_authentication ⇒ Object
- #default_errors ⇒ Object
- #default_errors?(action) ⇒ Boolean
- #default_response_formats ⇒ Object
-
#examples_dir(f = nil) ⇒ Object
returns the directory where rapidoc searches for examples.
- #gem_templates_dir(f = nil) ⇒ Object
- #load_config ⇒ Object
- #rapidoc_config ⇒ Object
- #resources_black_list ⇒ Object
-
#target_dir(f = nil) ⇒ Object
return the directory where rapidoc generates the doc.
- #trace? ⇒ Boolean
Instance Method Details
#actions_dir(f = nil) ⇒ Object
returns the directory where rapidoc generates actions (html files)
88 89 90 |
# File 'lib/rapidoc/config.rb', line 88 def actions_dir( f = nil ) f ? target_dir( "actions/#{f}" ) : target_dir( "actions" ) end |
#config_dir(f = nil) ⇒ Object
20 21 22 23 |
# File 'lib/rapidoc/config.rb', line 20 def config_dir( f = nil ) config_dir ||= File.join( ::Rails.root.to_s, 'config/rapidoc' ) form_file_name config_dir, f end |
#config_file_path ⇒ Object
39 40 41 |
# File 'lib/rapidoc/config.rb', line 39 def config_file_path config_dir 'rapidoc.yml' end |
#controller_dir(f = nil) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/rapidoc/config.rb', line 25 def controller_dir(f = nil) if @@config and @@config['controllers_route'] controller_dir = File.join( ::Rails.root.to_s, @@config['controllers_route'] ) else controller_dir ||= File.join( ::Rails.root.to_s, 'app/controllers' ) end form_file_name controller_dir, f end |
#controllers_extension ⇒ Object
35 36 37 |
# File 'lib/rapidoc/config.rb', line 35 def controllers_extension ( @@config and @@config['controllers_route'] ) ? '.yml' : '.rb' end |
#default_authentication ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/rapidoc/config.rb', line 66 def default_authentication if @@config and [ true, false ].include? @@config['default_authentication'] @@config['default_authentication'] else true end end |
#default_errors ⇒ Object
74 75 76 |
# File 'lib/rapidoc/config.rb', line 74 def default_errors @@config and @@config['errors'] ? @@config['errors'] : nil end |
#default_errors?(action) ⇒ Boolean
61 62 63 64 |
# File 'lib/rapidoc/config.rb', line 61 def default_errors?( action ) @@config and @@config['default_errors'] == true and [ 'create', 'update' ].include? action end |
#default_response_formats ⇒ Object
101 102 103 |
# File 'lib/rapidoc/config.rb', line 101 def default_response_formats @@config['response_formats'] if @@config end |
#examples_dir(f = nil) ⇒ Object
returns the directory where rapidoc searches for examples
93 94 95 96 97 98 99 |
# File 'lib/rapidoc/config.rb', line 93 def examples_dir( f = nil ) if File.exists?( config_file_path ) form_file_name( examples_dir_from_config_file, f ) else form_file_name( config_dir( '/examples' ), f ) end end |
#gem_templates_dir(f = nil) ⇒ Object
15 16 17 18 |
# File 'lib/rapidoc/config.rb', line 15 def gem_templates_dir( f = nil ) gem_templates_dir ||= File.join( File.dirname(__FILE__), 'templates' ) form_file_name gem_templates_dir, f end |
#load_config ⇒ Object
47 48 49 50 51 |
# File 'lib/rapidoc/config.rb', line 47 def load_config if File.exists?( config_file_path ) @@config = YAML.load( File.read( config_file_path ) ) end end |
#rapidoc_config ⇒ Object
43 44 45 |
# File 'lib/rapidoc/config.rb', line 43 def rapidoc_config @@config end |
#resources_black_list ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/rapidoc/config.rb', line 53 def resources_black_list if @@config and @@config['resources_black_list'] @@config['resources_black_list'].gsub(' ', '').split(',').map(&:to_sym) else return [] end end |
#target_dir(f = nil) ⇒ Object
return the directory where rapidoc generates the doc
79 80 81 82 83 84 85 |
# File 'lib/rapidoc/config.rb', line 79 def target_dir( f = nil ) if File.exists?( config_file_path ) form_file_name( target_dir_from_config, f ) else form_file_name( File.join( ::Rails.root.to_s, 'public/docs' ), f ) end end |
#trace? ⇒ Boolean
105 106 107 |
# File 'lib/rapidoc/config.rb', line 105 def trace? ( @@config and @@config['trace'] == true ) ? true : false end |