rspec-api-docs 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 921c43cbac7e32c779901db4a5519ad6b5fefbc0
4
- data.tar.gz: 68cb6ae49fbf805cb4786ef8494a9466693ea143
3
+ metadata.gz: 7d10d8bca800c45005afc8f8d95a1f5373885cb6
4
+ data.tar.gz: 9f88eb3855beceebd31c878a3be6887c6cfc63d5
5
5
  SHA512:
6
- metadata.gz: 97c817ca345c1a021d701fea14a7881ff58f6b57f283ae413067287ff0b0dc7ebc46b9e8fd08761c79f84437b9a4e071b4a02a5f4154178740df3d064fec50ca
7
- data.tar.gz: f3ce3df2074ed3032314b78d2c1ec6cdd27f8fccbf31cee4431f98032662bfba8b693cdd8408496de1b3e155e7b082bdbc85de4750e5cdaae66ab63e80fec004
6
+ metadata.gz: fec38ab112edb6805a565d7f220c427c66d77499429e61a4ffb3e689a99fc25e3c73edce2113faabc2d437f8fb175c121154865a623ea338706e15a37a844250
7
+ data.tar.gz: 79aa77d8356314ac968ab9a9ca9064e0a5f95f0572b5f45a48013e9d07e727dca3fa1e06d52f6706a41d29134b4bc01eeac7cc579d945633bfc8689720f115bd
data/.rubocop.yml CHANGED
@@ -6,16 +6,13 @@ AllCops:
6
6
  Metrics/LineLength:
7
7
  Max: 120
8
8
 
9
- Metrics/AbcSize:
10
- Enabled: true
11
-
12
- Style/DotPosition:
9
+ Layout/DotPosition:
13
10
  EnforcedStyle: leading
14
11
 
15
- Style/AlignHash:
12
+ Layout/AlignHash:
16
13
  Enabled: true
17
14
 
18
- Style/ExtraSpacing:
15
+ Layout/ExtraSpacing:
19
16
  AllowForAlignment: false
20
17
 
21
18
  Style/HashSyntax:
@@ -33,10 +30,10 @@ Style/PercentLiteralDelimiters:
33
30
  '%W': '[]'
34
31
  '%x': '[]'
35
32
 
36
- Style/SpaceInsideHashLiteralBraces:
33
+ Layout/SpaceInsideHashLiteralBraces:
37
34
  EnforcedStyle: no_space
38
35
 
39
- Style/SpaceInsideBlockBraces:
36
+ Layout/SpaceInsideBlockBraces:
40
37
  EnforcedStyleForEmptyBraces: space
41
38
 
42
39
  Style/StringLiterals:
@@ -51,5 +48,5 @@ Style/TrailingCommaInArguments:
51
48
  Style/ClassAndModuleChildren:
52
49
  EnforcedStyle: nested
53
50
 
54
- Style/MultilineOperationIndentation:
51
+ Layout/MultilineOperationIndentation:
55
52
  EnforcedStyle: indented
@@ -146,6 +146,41 @@ module RspecApiDocs
146
146
  def precedence(value)
147
147
  metadata[METADATA_NAMESPACE][:example_precedence] = value
148
148
  end
149
+
150
+ # For passing a lambda to modify the response body
151
+ #
152
+ # This is useful if the entire body of the response isn't relevant to the
153
+ # documentation example.
154
+ #
155
+ # With a response body of:
156
+ #
157
+ # {
158
+ # characters: [
159
+ # {
160
+ # id: 1,
161
+ # name: 'Finn The Human',
162
+ # },
163
+ # {
164
+ # id: 2,
165
+ # name: 'Jake The Dog',
166
+ # },
167
+ # ],
168
+ # }
169
+ #
170
+ # Usage:
171
+ #
172
+ # doc do
173
+ # response_body_after_hook -> (parsed_response_body) {
174
+ # parsed_response_body[:characters].delete_if { |character| character[:id] != 1 }
175
+ # parsed_response_body
176
+ # }
177
+ # end
178
+ #
179
+ # @param value [Lambda] after hook lambda
180
+ # @return [void]
181
+ def response_body_after_hook(value)
182
+ metadata[METADATA_NAMESPACE][:response_body_after_hook] = value
183
+ end
149
184
  end
150
185
  end
151
186
  end
@@ -130,6 +130,9 @@ module RspecApiDocs
130
130
  DeepHashSet.call(parsed_body, f.scope + [f.name], f.example)
131
131
  end
132
132
  end
133
+ if metadata[:response_body_after_hook]
134
+ parsed_body = metadata[:response_body_after_hook].call(parsed_body)
135
+ end
133
136
  JSON.dump(parsed_body)
134
137
  end
135
138
  end
@@ -1,3 +1,3 @@
1
1
  module RspecApiDocs
2
- VERSION = '0.10.0'
2
+ VERSION = '0.11.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.10.0
4
+ version: 0.11.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-04-11 00:00:00.000000000 Z
11
+ date: 2017-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler