tomograph 3.0.0 → 3.0.1

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
  SHA256:
3
- metadata.gz: c457270d6d9ab0b7d23c4af643248636f3fe9b3f673858700505ab55ee31716f
4
- data.tar.gz: d089a1f21d1ab2e739854f962eff9e0e7fcdc3cdb631a595f84a328afc016823
3
+ metadata.gz: 6b82305a8afc3940fb54799c20a96c71685f1950addb5b0413572bb3ca6e5c2f
4
+ data.tar.gz: eddef2bcfd9ba3f22d3cf4511e0e7ce6a32c28992e0c022602c499210b72c2a1
5
5
  SHA512:
6
- metadata.gz: 4f31296ba8532f93e0f89f881e0c0aa07a3a2a2752d2f6764be9ac6bf0ee5a8e1103b4f5bc2eb9b8ef0472f70432acaec379d2b914338fefed6f8e7c2842f3d3
7
- data.tar.gz: b54f9a273905b2e7d3bd2d91777f46fc5c626dec43124abf6a3b5fed85a63e3ec63e21568498e6f072ab48020a58e6c833ab89a2ef7bf2692acc184c614cb6d4
6
+ metadata.gz: 4843bb38871e842c26f63c6af9ac1d87fd5f153a56255c1b3d070eb35686c08b84c8279bf900d9dd4a0cf38fb9daff3b905bb58285e169c118ad7d36c7855b8c
7
+ data.tar.gz: 3df3afd4cc5064d767dad8640f156bd39972a728927621ac740f332609b21a3533be36d71099208f527e7d290970ab0e59814bc5d00239135687e2015a9e8b9d
@@ -0,0 +1,33 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Ruby
9
+
10
+ on:
11
+ push:
12
+ branches: [ master ]
13
+ pull_request:
14
+ branches: [ master ]
15
+
16
+ jobs:
17
+ test:
18
+
19
+ runs-on: ubuntu-latest
20
+
21
+ steps:
22
+ - uses: actions/checkout@v2
23
+ - name: Set up Ruby
24
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
25
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
26
+ # uses: ruby/setup-ruby@v1
27
+ uses: ruby/setup-ruby@ec106b438a1ff6ff109590de34ddc62c540232e0
28
+ with:
29
+ ruby-version: 2.6
30
+ - name: Install dependencies
31
+ run: bundle install
32
+ - name: Run tests
33
+ run: bundle exec rake
@@ -1,5 +1,14 @@
1
1
  # Change log
2
2
 
3
+ ### 3.0.1 - 2020-10-14
4
+
5
+ * removed
6
+ * delete apib_path [#31](https://github.com/funbox/tomograph/issues/31)
7
+ * delete drafter_4_apib_path [#32](https://github.com/funbox/tomograph/issues/32)
8
+ * replace drafter_yaml_path with drafter_4_yaml_path [#33](https://github.com/funbox/tomograph/issues/33)
9
+ * delete crafter_apib_path [#34](https://github.com/funbox/tomograph/issues/34)
10
+ * delete multi_json [#35](https://github.com/funbox/tomograph/issues/35)
11
+
3
12
  ### 3.0.0 - 2020-08-27
4
13
 
5
14
  * features
data/README.md CHANGED
@@ -31,15 +31,15 @@ $ gem install tomograph
31
31
  ```ruby
32
32
  require 'tomograph'
33
33
 
34
- tomogram = Tomograph::Tomogram.new(apib_path: '/path/to/doc.apib')
34
+ tomogram = Tomograph::Tomogram.new(drafter_yaml_path: '/path/to/doc.yaml')
35
35
  ```
36
36
 
37
37
  ### Command line tool
38
38
 
39
- CLI allows you to convert files from API Blueprint or API Elements to JSON Schema.
39
+ CLI allows you to convert files from API Elements to JSON Schema.
40
40
 
41
41
  ```bash
42
- tomograph doc.apib doc.json
42
+ tomograph doc.yaml doc.json
43
43
  ```
44
44
 
45
45
  There is also support for documents pre-parsed by [drafter](https://github.com/apiaryio/drafter) versions 3 and 4, or `crafter`.
@@ -236,10 +236,6 @@ Example output:
236
236
 
237
237
  You can specify API prefix and path to the spec using one of the possible formats:
238
238
 
239
- ```ruby
240
- Tomograph::Tomogram.new(prefix: '/api/v2', apib_path: '/path/to/doc.apib')
241
- ```
242
-
243
239
  ```ruby
244
240
  Tomograph::Tomogram.new(prefix: '/api/v2', drafter_yaml_path: '/path/to/doc.yaml')
245
241
  ```
@@ -248,19 +244,15 @@ Tomograph::Tomogram.new(prefix: '/api/v2', drafter_yaml_path: '/path/to/doc.yaml
248
244
  Tomograph::Tomogram.new(prefix: '/api/v2', tomogram_json_path: '/path/to/doc.json')
249
245
  ```
250
246
 
251
- ### `apib_path`
252
-
253
- Path to API Blueprint documentation. There must be an installed [drafter](https://github.com/apiaryio/drafter) to parse it.
254
-
255
247
  ### `drafter_yaml_path`
256
248
 
257
249
  Path to API Blueprint documentation pre-parsed with `drafter` and saved to a YAML file.
258
250
 
259
251
  ### Drafter v4 & Crafter support
260
252
 
261
- If you are using a `drafter v4`, you should use `drafter_4_apib_path` and `drafter_4_yaml_path` respectively.
253
+ If you are using a `drafter v4`, you should use `drafter_yaml_path`.
262
254
 
263
- In case when you want to use `сrafter`, then you should pass these params: `crafter_apib_path`, `crafter_yaml_path`.
255
+ In case when you want to use `сrafter`, then you should pass `crafter_yaml_path` respectively.
264
256
 
265
257
  ### `tomogram_json_path`
266
258
 
@@ -13,10 +13,9 @@ include Methadone::CLILogging
13
13
  version Tomograph::VERSION
14
14
  description 'Converts API Blueprint to JSON Schema'
15
15
  on('-d DRAFTER_VERSION', '--drafter', 'Choose drafter version: crafter or 4. Default: use drafter v.4.')
16
- on('-f INPUT_FORMAT', '--format', 'Force input format: "apib" or "yaml". Default: detect by file extension.')
17
16
  on('--exclude-description', 'Exclude "description" keys.')
18
17
  on('--split', 'Split output into files by method.')
19
- arg :input, 'path/to/doc.apib (API Blueprint) or path/to/doc.yaml (API Elements)'
18
+ arg :input, 'path/to/doc.yaml (API Elements)'
20
19
  arg :output, 'path/to/doc.json or path/to/dir if --split is used.'
21
20
 
22
21
  def prune!(obj, unwanted_key)
@@ -28,26 +27,6 @@ def prune!(obj, unwanted_key)
28
27
  end
29
28
  end
30
29
 
31
- def guess_format(opt_format, input)
32
- case opt_format && opt_format.downcase
33
- when 'apib'
34
- :apib
35
- when 'yaml'
36
- :yaml
37
- when nil
38
- case File.extname(input).downcase
39
- when '.apib'
40
- :apib
41
- when '.yaml', '.yml'
42
- :yaml
43
- else
44
- fail 'Unsupported input file extension!'
45
- end
46
- else
47
- fail 'Unsupported input format!'
48
- end
49
- end
50
-
51
30
  def choose_drafter(opt_parser)
52
31
  case opt_parser
53
32
  when 'crafter'
@@ -75,31 +54,19 @@ def write_split_json(actions, output)
75
54
  end
76
55
 
77
56
  def write_json(obj, path)
78
- json = MultiJson.dump(obj, pretty: true)
57
+ json = JSON.pretty_generate(obj)
79
58
  File.open(path, 'w') do |file|
80
59
  file.write(json)
81
60
  end
82
61
  end
83
62
 
84
63
  main do |input, output|
85
- format = guess_format(options['format'], input)
86
64
  version = choose_drafter(options['drafter'])
87
- format_key = case format
88
- when :apib
89
- if version == :crafter
90
- :crafter_apib_path
91
- else
92
- :drafter_4_apib_path
93
- end
94
- when :yaml
95
- if version == :crafter
96
- :crafter_yaml_path
97
- else
98
- :drafter_4_yaml_path
99
- end
100
- else
101
- fail NotImplementedError
102
- end
65
+ format_key = {
66
+ crafter: :crafter_yaml_path,
67
+ drafter_4: :drafter_yaml_path
68
+ }[version]
69
+
103
70
  tomogram = Tomograph::Tomogram.new(format_key => input)
104
71
  actions = tomogram.to_a.map(&:to_hash)
105
72
 
@@ -6,13 +6,9 @@ module Tomograph
6
6
  module ApiBlueprint
7
7
  class Crafter
8
8
  class Yaml
9
- def initialize(prefix, apib_path, drafter_yaml_path)
9
+ def initialize(prefix, drafter_yaml_path)
10
10
  @prefix = prefix
11
- @documentation = if apib_path
12
- YAML.safe_load(`drafter #{apib_path}`)
13
- elsif drafter_yaml_path
14
- YAML.safe_load(File.read(drafter_yaml_path))
15
- end
11
+ @documentation = YAML.safe_load(File.read(drafter_yaml_path))
16
12
  end
17
13
 
18
14
  def groups
@@ -37,8 +37,8 @@ module Tomograph
37
37
  end
38
38
  return {} unless schema_node
39
39
 
40
- MultiJson.load(schema_node['content'])
41
- rescue MultiJson::ParseError => e
40
+ JSON.parse(schema_node['content'])
41
+ rescue JSON::ParserError => e
42
42
  puts "[Tomograph] Error while parsing #{e}. skipping..."
43
43
  {}
44
44
  end
@@ -6,13 +6,9 @@ module Tomograph
6
6
  module ApiBlueprint
7
7
  class Drafter4
8
8
  class Yaml
9
- def initialize(prefix, apib_path, drafter_yaml_path)
9
+ def initialize(prefix, drafter_yaml_path)
10
10
  @prefix = prefix
11
- @documentation = if apib_path
12
- YAML.safe_load(`drafter #{apib_path}`)
13
- elsif drafter_yaml_path
14
- YAML.safe_load(File.read(drafter_yaml_path))
15
- end
11
+ @documentation = YAML.safe_load(File.read(drafter_yaml_path))
16
12
  end
17
13
 
18
14
  def groups
@@ -37,8 +37,8 @@ module Tomograph
37
37
  end
38
38
  return {} unless schema_node
39
39
 
40
- MultiJson.load(schema_node['content'])
41
- rescue MultiJson::ParseError => e
40
+ JSON.parse(schema_node['content'])
41
+ rescue JSON::ParserError => e
42
42
  puts "[Tomograph] Error while parsing #{e}. skipping..."
43
43
  {}
44
44
  end
@@ -5,7 +5,7 @@ module Tomograph
5
5
  class JsonSchema
6
6
  def initialize(prefix, json_schema_path)
7
7
  @prefix = prefix
8
- @documentation = MultiJson.load(File.read(json_schema_path))
8
+ @documentation = JSON.parse(File.read(json_schema_path))
9
9
  end
10
10
 
11
11
  def to_tomogram
@@ -1,4 +1,4 @@
1
- require 'multi_json'
1
+ require 'json'
2
2
  require 'tomograph/path'
3
3
  require 'tomograph/api_blueprint/json_schema'
4
4
  require 'tomograph/api_blueprint/drafter_4/yaml'
@@ -8,13 +8,13 @@ module Tomograph
8
8
  class Tomogram
9
9
  extend Gem::Deprecate
10
10
 
11
- def initialize(prefix: '', apib_path: nil, drafter_yaml_path: nil, tomogram_json_path: nil, drafter_4_apib_path: nil, drafter_4_yaml_path: nil, crafter_apib_path: nil, crafter_yaml_path: nil)
11
+ def initialize(prefix: '', drafter_yaml_path: nil, tomogram_json_path: nil, crafter_yaml_path: nil)
12
12
  @documentation = if tomogram_json_path
13
13
  Tomograph::ApiBlueprint::JsonSchema.new(prefix, tomogram_json_path)
14
- elsif crafter_yaml_path || crafter_apib_path
15
- Tomograph::ApiBlueprint::Crafter::Yaml.new(prefix, crafter_apib_path, crafter_yaml_path)
14
+ elsif crafter_yaml_path
15
+ Tomograph::ApiBlueprint::Crafter::Yaml.new(prefix, crafter_yaml_path)
16
16
  else
17
- Tomograph::ApiBlueprint::Drafter4::Yaml.new(prefix, drafter_4_apib_path, drafter_4_yaml_path)
17
+ Tomograph::ApiBlueprint::Drafter4::Yaml.new(prefix, drafter_yaml_path)
18
18
  end
19
19
  @prefix = prefix
20
20
  end
@@ -29,7 +29,7 @@ module Tomograph
29
29
  deprecate :to_hash, 'to_a with method access', 2018, 8
30
30
 
31
31
  def to_json
32
- MultiJson.dump(to_a.map(&:to_hash), pretty: true)
32
+ JSON.pretty_generate(to_a.map(&:to_hash))
33
33
  end
34
34
 
35
35
  def find_request(method:, path:)
@@ -1,3 +1,3 @@
1
1
  module Tomograph
2
- VERSION = '3.0.0'.freeze
2
+ VERSION = '3.0.1'.freeze
3
3
  end
@@ -19,7 +19,6 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ['lib']
20
20
 
21
21
  spec.add_runtime_dependency 'methadone', '~> 2', '>= 2.0.2'
22
- spec.add_runtime_dependency 'multi_json', '~> 1.14', '>= 1.14.1'
23
22
  spec.add_development_dependency 'byebug', '~> 11.1', '>= 11.1.1'
24
23
  spec.add_development_dependency 'rake', '>= 13.0.1'
25
24
  spec.add_development_dependency 'rspec', '~> 3.9', '>= 3.9.0'
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: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - d.efimov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-08-27 00:00:00.000000000 Z
11
+ date: 2020-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: methadone
@@ -30,26 +30,6 @@ dependencies:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: 2.0.2
33
- - !ruby/object:Gem::Dependency
34
- name: multi_json
35
- requirement: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - "~>"
38
- - !ruby/object:Gem::Version
39
- version: '1.14'
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- version: 1.14.1
43
- type: :runtime
44
- prerelease: false
45
- version_requirements: !ruby/object:Gem::Requirement
46
- requirements:
47
- - - "~>"
48
- - !ruby/object:Gem::Version
49
- version: '1.14'
50
- - - ">="
51
- - !ruby/object:Gem::Version
52
- version: 1.14.1
53
33
  - !ruby/object:Gem::Dependency
54
34
  name: byebug
55
35
  requirement: !ruby/object:Gem::Requirement
@@ -152,7 +132,7 @@ executables:
152
132
  extensions: []
153
133
  extra_rdoc_files: []
154
134
  files:
155
- - ".github/workflows/gempush.yml"
135
+ - ".github/workflows/ruby.yml"
156
136
  - ".gitignore"
157
137
  - ".rubocop.yml"
158
138
  - ".ruby-version"
@@ -1,28 +0,0 @@
1
- name: Ruby Gem
2
-
3
- on:
4
- push:
5
- branches: [ master ]
6
- pull_request:
7
- branches: [ master ]
8
-
9
- jobs:
10
- build:
11
- name: Build + Publish
12
- runs-on: ubuntu-latest
13
-
14
- steps:
15
- - uses: actions/checkout@v2
16
- - name: Set up Ruby
17
- uses: actions/setup-ruby@v1
18
-
19
- - name: Publish to RubyGems
20
- run: |
21
- mkdir -p $HOME/.gem
22
- touch $HOME/.gem/credentials
23
- chmod 0600 $HOME/.gem/credentials
24
- printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
25
- gem build *.gemspec
26
- gem push *.gem
27
- env:
28
- GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}