Class: CabbageDoc::Configuration
- Inherits:
-
Object
- Object
- CabbageDoc::Configuration
- Includes:
- Singleton
- Defined in:
- lib/cabbage_doc/configuration.rb
Constant Summary collapse
- DEFAULTS =
{ path: 'api/v1', title: 'Cabbage Doc', scheme: 'https', verbose: false, dev: false, visibility: [VISIBILITY.first], cache: Cache.new, request: proc { |request| request.perform }, theme: 'github', examples: false, format_example: method(:format_example), page_root: 'pages', page_ext: 'md', auto_generate: true, generators: [:api], tags: [TAG], json: false }.freeze
- OPTIONAL_ATTRIBUTES =
%i(welcome path scheme title verbose authentication dev request cache theme visibility examples format_example page_root page_ext asset_path auto_generate generators tags json).freeze
- REQUIRED_ATTRIBUTES =
%i(domain controllers root).freeze
- ATTRIBUTES =
(OPTIONAL_ATTRIBUTES + REQUIRED_ATTRIBUTES).freeze
- CALLABLE_ATTRIBUTES =
%i(controllers authentication request format_example).freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #validate! ⇒ Object
Methods included from Singleton
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
63 64 65 66 67 |
# File 'lib/cabbage_doc/configuration.rb', line 63 def initialize DEFAULTS.each do |attr, value| send(:"#{attr}=", value) end end |
Class Method Details
.format_example(example, action, auth) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/cabbage_doc/configuration.rb', line 6 def format_example(example, action, auth) cmd = ["$", "curl"] if auth.type == :basic cmd << "-u \"user:pass\"" elsif auth.token cmd << "-H \"Authorization: #{auth.type.to_s.capitalize} token\"" end if action.method == "GET" path = [action.path, example.to_query].join("?") else cmd << "-X #{action.method}" example.params.each do |k, v| cmd << "-d \"#{k}=#{v}\"" end path = action.path end cmd << "\"#{[auth.uri, path].join}\"" cmd.join(' ') end |
Instance Method Details
#validate! ⇒ Object
69 70 71 72 73 74 |
# File 'lib/cabbage_doc/configuration.rb', line 69 def validate! validate_required! validate_callable! validate_root! validate_visibility! end |