tomograph 2.0.1 → 2.1.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: cd13ddea2ad89aa83a1fb6f63e3fb11f43c35695
4
- data.tar.gz: e923b97d4fecf64944f852ac309bf6460163352d
3
+ metadata.gz: 0f6bd7ef6a03950f113a0492c08e4d9aa17f26eb
4
+ data.tar.gz: bd068832137f783a9d50b5d42b73824f7355f0a2
5
5
  SHA512:
6
- metadata.gz: 6adeaa6ea548b8649854bbd23a0682d6721f93c6a63c0449fcc48b99bc14b6113cf822e60a10e41ab9a73ea9f1e745dbe288fedb7b095944f268d0ba98df2f0e
7
- data.tar.gz: b1aa467325fd8798cfd8d04a10548e70da31ab79a0a7736052a40cfbebe2ea24f937087dc97ba163bf0ce3ba889de4bde39b2dcbd1cdeb0b54ae71ab4c075027
6
+ metadata.gz: 580304b7f2e90c5ed4f34e016549277025fef310ddb97deb758787e73376243da3e96fa58abd4d48adabcdb4751c4facaf47c02ccc2d97f5050ca2718fd6dd9a
7
+ data.tar.gz: fef696a261c995d5fa8c44cc8b553742271a99486738a8a70bca989f3b95341cf4b4f71fe3ed81ebe16dfb6d90f01eacba7b3fe7d840391729cfc7b6575646fc
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2
4
+ before_install: gem install bundler -v 1.12
5
+
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change log
2
2
 
3
+ ### 2.1.0 - 2018-03-16
4
+
5
+ * features
6
+ * add content-type for requests and responses
7
+ * add find_request_with_content_type
8
+
3
9
  ### 2.0.1 - 2018-03-02
4
10
 
5
11
  * bug fixes
data/README.md CHANGED
@@ -1,4 +1,11 @@
1
- # tomograph
1
+ # Tomograph
2
+
3
+ <a href="https://funbox.ru">
4
+ <img src="https://funbox.ru/badges/sponsored_by_funbox_compact.svg" alt="Sponsored by FunBox" width=250 />
5
+ </a>
6
+
7
+ [![Gem Version](https://badge.fury.io/rb/tomograph.svg)](https://badge.fury.io/rb/tomograph)
8
+ [![Build Status](https://travis-ci.org/funbox/tomograph.svg?branch=master)](https://travis-ci.org/funbox/tomograph)
2
9
 
3
10
  Convert API Blueprint to JSON Schema and search.
4
11
 
@@ -82,6 +89,7 @@ Example output:
82
89
  {
83
90
  "path": "/sessions",
84
91
  "method": "POST",
92
+ "content-type": "application/json",
85
93
  "request": {
86
94
  "$schema": "http://json-schema.org/draft-04/schema#",
87
95
  "type": "object",
@@ -104,14 +112,17 @@ Example output:
104
112
  "responses": [
105
113
  {
106
114
  "status": "401",
115
+ "content-type": "application/json",
107
116
  "body": {}
108
117
  },
109
118
  {
110
119
  "status": "429",
120
+ "content-type": "application/json",
111
121
  "body": {}
112
122
  },
113
123
  {
114
124
  "status": "201",
125
+ "content-type": "application/json",
115
126
  "body": {
116
127
  "$schema": "http://json-schema.org/draft-04/schema#",
117
128
  "type": "object",
@@ -157,6 +168,12 @@ Example output:
157
168
  request = tomogram.find_request(method: 'GET', path: '/status/1?qwe=rty')
158
169
  ```
159
170
 
171
+ ### find_request
172
+
173
+ ```ruby
174
+ request = tomogram.find_request_with_content_type(method: 'GET', path: '/status/1?qwe=rty', content_type: 'application/json')
175
+ ```
176
+
160
177
  ### find_responses
161
178
 
162
179
 
@@ -97,6 +97,7 @@ module Tomograph
97
97
  {
98
98
  path: "#{@prefix}#{related_actions.first.path}",
99
99
  method: related_actions.first.method,
100
+ content_type: related_actions.first.content_type,
100
101
  request: related_actions.first.request,
101
102
  responses: related_actions.map(&:responses).flatten,
102
103
  resource: related_actions.first.resource
@@ -16,6 +16,11 @@ module Tomograph
16
16
  @method ||= @content.first['attributes']['method']
17
17
  end
18
18
 
19
+ def content_type
20
+ @content_type ||= @content.first['attributes'].has_key?('headers') ?
21
+ @content.first['attributes']['headers']['content'][0]['content']['value']['content'] : nil
22
+ end
23
+
19
24
  def request
20
25
  return @request if @request
21
26
 
@@ -44,7 +49,9 @@ module Tomograph
44
49
  @responses = @responses.map do |response|
45
50
  {
46
51
  'status' => response['attributes']['statusCode'],
47
- 'body' => json_schema(response['content'])
52
+ 'body' => json_schema(response['content']),
53
+ 'content-type' => response['attributes'].has_key?('headers') ?
54
+ response['attributes']['headers']['content'][0]['content']['value']['content'] : nil
48
55
  }
49
56
  end
50
57
  end
@@ -25,6 +25,14 @@ module Tomograph
25
25
  end
26
26
  end
27
27
 
28
+ def find_request_with_content_type(method:, path:, content_type:)
29
+ path = Tomograph::Path.new(path).to_s
30
+
31
+ @documentation.to_tomogram.find do |action|
32
+ action.method == method && action.path.match(path) && action.content_type == content_type
33
+ end
34
+ end
35
+
28
36
  def to_resources
29
37
  @documentation.to_resources
30
38
  end
@@ -3,11 +3,12 @@ require 'tomograph/path'
3
3
  module Tomograph
4
4
  class Tomogram
5
5
  class Action
6
- attr_reader :path, :method, :request, :responses
6
+ attr_reader :path, :method, :content_type, :request, :responses
7
7
 
8
- def initialize(path:, method:, request:, responses:, resource:)
8
+ def initialize(path:, method:, content_type:, request:, responses:, resource:)
9
9
  @path ||= Tomograph::Path.new(path)
10
10
  @method ||= method
11
+ @content_type ||= content_type
11
12
  @request ||= request
12
13
  @responses ||= responses
13
14
  @resource ||= resource
@@ -23,6 +24,7 @@ module Tomograph
23
24
  @action ||= {
24
25
  'path' => path,
25
26
  'method' => method,
27
+ 'content-type': content_type,
26
28
  'request' => request,
27
29
  'responses' => responses
28
30
  }
@@ -1,3 +1,3 @@
1
1
  module Tomograph
2
- VERSION = '2.0.1'.freeze
2
+ VERSION = '2.1.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tomograph
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - d.efimov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-03-02 00:00:00.000000000 Z
11
+ date: 2018-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -147,6 +147,7 @@ extra_rdoc_files: []
147
147
  files:
148
148
  - ".gitignore"
149
149
  - ".rubocop.yml"
150
+ - ".travis.yml"
150
151
  - CHANGELOG.md
151
152
  - CODE_OF_CONDUCT.md
152
153
  - Gemfile
@@ -183,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
183
184
  version: '0'
184
185
  requirements: []
185
186
  rubyforge_project:
186
- rubygems_version: 2.5.1
187
+ rubygems_version: 2.4.5
187
188
  signing_key:
188
189
  specification_version: 4
189
190
  summary: Convert API Blueprint to JSON Schema and search