rspec-api-docs 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2e9892448884eff6e7ab9f869c5358595e25af95
4
- data.tar.gz: 11968fb9bb7a942b6859c8f13029ab37765c936c
3
+ metadata.gz: e7e5799e512fca99e136a0909ba2118a90d96073
4
+ data.tar.gz: 48de8b3f91fa45947fc1903fe25b0e4b8351aa93
5
5
  SHA512:
6
- metadata.gz: 0dd30dcf52b5df54ba6ac7179e315619bec8f6652679291fcc12ff0a974d98b184ca97b61da3e6eda8dabed7abd420c4814f32edc86d0fcec00d7441803497dc
7
- data.tar.gz: f313600b62164dfae76b321187860fb894eed9c8b6732249c060418c7daa6c8072fbc22b590dbaf9f4ed13b2a8ea44fcde1ffcf7bbd8dcdeb01d29bc428cac97
6
+ metadata.gz: adac7650aa8fbd77ae177ec13eb55173818a0c48cf725795bbc0fa8821a98c7e9b375cc3418b0df1b668cd508cdad26c83b39e578c1ba76d2400235cbc7478e5
7
+ data.tar.gz: 12f01cf8d991c15c98b5d05b9a452f0ea2e915049160337b8ef5ef39510b356af4ece8d43096aa80cdb2935e564f4394ca06599269c3fd5115e0efdac551f74f
data/README.md CHANGED
@@ -207,6 +207,18 @@ param :id, 'The id of a character', scope: :character, type: 'integer', required
207
207
  param :name, "The character's name", scope: :character, type: 'string'
208
208
  ```
209
209
 
210
+ #### `notes`
211
+
212
+ Accepts a `note` and optional `level`.
213
+
214
+ - `level` [`Symbol`] one of `:success`, `:info`, `:warning`, or `:danger`. Defaults to `:info`
215
+ - `note` [`String`] the note
216
+
217
+ ``` ruby
218
+ note 'You need to supply an id!'
219
+ note :warning, "An error will be thrown if you don't supply an id!"
220
+ ```
221
+
210
222
  See the integration specs for more examples of the DSL in use.
211
223
 
212
224
  ### Formatter
data/Rakefile CHANGED
@@ -10,4 +10,9 @@ RuboCop::RakeTask.new :rubocop do |task|
10
10
  task.verbose = false
11
11
  end
12
12
 
13
- task default: [:rspec, :rubocop]
13
+ task :generate_integration_docs do
14
+ system './bin/generate_integration_docs'
15
+ exit $?.exitstatus
16
+ end
17
+
18
+ task default: [:rspec, :rubocop, :generate_integration_docs]
@@ -1,4 +1,6 @@
1
- #!/usr/bin/env bash -ex
1
+ #!/usr/bin/env bash
2
+
3
+ set -ex
2
4
 
3
5
  rm -rf spec/integration/output
4
6
 
@@ -1,6 +1,7 @@
1
1
  require 'rspec_api_docs/config'
2
2
  require 'rspec_api_docs/version'
3
3
 
4
+ # The base module of the gem.
4
5
  module RspecApiDocs
5
6
  METADATA_NAMESPACE = :rspec_api_docs
6
7
 
@@ -12,6 +12,7 @@ module RspecApiDocs
12
12
  yield configuration
13
13
  end
14
14
 
15
+ # Used to control the behaviour of the gem.
15
16
  class Config
16
17
  attr_accessor \
17
18
  :output_dir,
@@ -1,6 +1,8 @@
1
1
  module RspecApiDocs
2
2
  module Dsl
3
3
  class DocProxy
4
+ UnknownNoteLevel = Class.new(BaseError)
5
+
4
6
  attr_reader :metadata
5
7
 
6
8
  def initialize(example)
@@ -112,6 +114,18 @@ module RspecApiDocs
112
114
  required: required,
113
115
  }
114
116
  end
117
+
118
+ # For setting notes on an example
119
+ #
120
+ # @param level [Symbol] the level of the note
121
+ # @param value [String] the note, +:success+, +:info+, +:warning+, or +:danger+
122
+ # @return [void]
123
+ def note(level = :info, value)
124
+ %i[success info warning danger].include?(level) or
125
+ raise UnknownNoteLevel, "unknown note level #{level.inspect}"
126
+ metadata[METADATA_NAMESPACE][:note] ||= {}
127
+ metadata[METADATA_NAMESPACE][:note][level] = value
128
+ end
115
129
  end
116
130
  end
117
131
  end
@@ -17,6 +17,7 @@ module RspecApiDocs
17
17
  path: example.path,
18
18
  requests: example.requests,
19
19
  response_fields: response_fields,
20
+ notes: example.notes,
20
21
  }
21
22
  end
22
23
 
@@ -33,7 +33,7 @@ module RspecApiDocs
33
33
  parameters.map do |parameter|
34
34
  result = {}
35
35
  result[:required] = true if parameter.required
36
- result[:scope] = parameter.scope
36
+ result[:scope] = parameter.scope.join
37
37
  result = result.merge(
38
38
  name: parameter.name,
39
39
  description: parameter.description,
@@ -45,7 +45,7 @@ module RspecApiDocs
45
45
  def response_fields(fields)
46
46
  fields.map do |field|
47
47
  {
48
- scope: field.scope,
48
+ scope: field.scope.join,
49
49
  Type: field.type,
50
50
  name: field.name,
51
51
  description: field.description,
@@ -82,6 +82,11 @@ module RspecApiDocs
82
82
  request_response_pairs.first.first.request_method
83
83
  end
84
84
 
85
+ # @return [Hash<Symbol,String>, nil]
86
+ def notes
87
+ metadata.fetch(:note, {})
88
+ end
89
+
85
90
  private
86
91
 
87
92
  def request_response_pairs
@@ -10,9 +10,9 @@ module RspecApiDocs
10
10
 
11
11
  # The scope of the parameter
12
12
  #
13
- # @return [String]
13
+ # @return [Array<String>]
14
14
  def scope
15
- parameter[:scope].join
15
+ parameter[:scope]
16
16
  end
17
17
 
18
18
  # If the parameter is required
@@ -10,9 +10,9 @@ module RspecApiDocs
10
10
 
11
11
  # The scope of the response field
12
12
  #
13
- # @return [String]
13
+ # @return [Array<String>]
14
14
  def scope
15
- field[:scope].join
15
+ field[:scope]
16
16
  end
17
17
 
18
18
  # The type of the response field
@@ -1,3 +1,3 @@
1
1
  module RspecApiDocs
2
- VERSION = '0.4.0'
2
+ VERSION = '0.5.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-api-docs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Odin Dutton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-01 00:00:00.000000000 Z
11
+ date: 2017-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler