bump-cli 0.1.1 → 0.2.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
  SHA256:
3
- metadata.gz: 547fdfc416eb3c6e2f0e61ccd677f1bdd79ccd8aa761aee2723d397985df657c
4
- data.tar.gz: 5b3e598e4469546da9c16275138e97bdcd750801022d49c792dbd70c9d2c7773
3
+ metadata.gz: eae58f754a98f3e2e633376bee6bd7dd3be44fc00e4f8c5d0a7d1b9f88e19236
4
+ data.tar.gz: bde4b9c983ef8dbccca2432526c86ab4417b1deef95994d2aff0412f009ee08f
5
5
  SHA512:
6
- metadata.gz: 4036fc2b31fbadc3019f055cf0b4bbaa46b9ee935cc42335287be9a63df8f72c7ebaecd681956f80ec2075b433bf94af1e0c434db6d641cf41df7fd27c357227
7
- data.tar.gz: 83e5a034d7b4f8a983c44f262a39e206256a29b2c3d98a0fef49cf72b7c4baf3f0c7b4baf7022944ceaa0314d0ac92f694032372be7922ec7b30f5f28cdf855d
6
+ metadata.gz: e0f74113804392d5f473e882b091567ce84cd2d09a9f980b35e2e9770170475d8856c667ec52926d2ff787e469f51fcb362dc1dd9414cee5e4ad14f49d916315
7
+ data.tar.gz: f241dfd78599b68123d1146546cc338f73c447db28aeb2247701bde03fe87bc7216af00b0ba5101ec021fd192e1dd1166b0cb597c3fef51bf8c72a54aa8d3ff7
@@ -6,6 +6,13 @@ module Bump
6
6
  class Base < Hanami::CLI::Command
7
7
  private
8
8
 
9
+ def body(file, specification)
10
+ {
11
+ definition: open(file).read,
12
+ specification: specification
13
+ }
14
+ end
15
+
9
16
  def with_errors_rescued
10
17
  yield
11
18
  rescue HTTP::Error, Errno::ENOENT, SocketError => error
@@ -8,13 +8,13 @@ module Bump
8
8
  argument :file, required: true, desc: "Path or URL to your API documentation file. Only OpenApi 2.0 (Swagger) specification is currently supported."
9
9
  option :id, default: ENV.fetch("BUMP_ID", ""), desc: "Documentation public id"
10
10
  option :token, default: ENV.fetch("BUMP_TOKEN", ""), desc: "Documentation private token"
11
- option :format, default: "yaml", values: %w[yaml json], desc: "Format of the definition"
11
+ option :specification, default: 'openapi/v2/yaml', values: %w[openapi/v2/json openapi/v2/yaml], desc: "Specification of the definition"
12
12
 
13
- def call(file:, format:, id:, token:)
13
+ def call(file:, specification:, id:, token:)
14
14
  with_errors_rescued do
15
15
  response = HTTP
16
16
  .headers(headers(token: token))
17
- .post(API_URL + "/docs/#{id}/versions", body: body(file, format).to_json)
17
+ .post(API_URL + "/docs/#{id}/versions", body: body(file, specification).to_json)
18
18
 
19
19
  if response.code == 201
20
20
  puts "New version has been successfully deployed."
@@ -25,15 +25,6 @@ module Bump
25
25
  end
26
26
  end
27
27
  end
28
-
29
- private
30
-
31
- def body(file, format)
32
- {
33
- definition: open(file).read,
34
- format: format
35
- }
36
- end
37
28
  end
38
29
  end
39
30
  end
@@ -4,13 +4,13 @@ module Bump
4
4
  class Preview < Base
5
5
  desc "Create a documentation preview for the given file"
6
6
  argument :file, required: true, desc: "Path or URL to your API documentation file. Only OpenApi 2.0 (Swagger) specification is currently supported."
7
- option :format, default: "yaml", values: %w[yaml json], desc: "Format of the definition"
7
+ option :specification, default: 'openapi/v2/yaml', values: %w[openapi/v2/json openapi/v2/yaml], desc: "Specification of the definition"
8
8
 
9
- def call(**options)
9
+ def call(file:, specification:)
10
10
  with_errors_rescued do
11
11
  response = HTTP
12
12
  .headers(headers)
13
- .post(API_URL + "/previews", body: body(options).to_json)
13
+ .post(API_URL + "/previews", body: body(file, specification).to_json)
14
14
 
15
15
  if response.code == 201
16
16
  body = JSON.parse(response.body)
@@ -20,15 +20,6 @@ module Bump
20
20
  end
21
21
  end
22
22
  end
23
-
24
- private
25
-
26
- def body(options)
27
- {
28
- definition: open(options.fetch(:file)).read,
29
- format: options.fetch(:format)
30
- }
31
- end
32
23
  end
33
24
  end
34
25
  end
@@ -8,13 +8,13 @@ module Bump
8
8
  argument :file, required: true, desc: "Path or URL to your API documentation file. Only OpenApi 2.0 (Swagger) specification is currently supported."
9
9
  option :id, default: ENV.fetch("BUMP_ID", ""), desc: "Documentation public id"
10
10
  option :token, default: ENV.fetch("BUMP_TOKEN", ""), desc: "Documentation private token"
11
- option :format, default: "yaml", values: %w[yaml json], desc: "Format of the definition"
11
+ option :specification, default: 'openapi/v2/yaml', values: %w[openapi/v2/json openapi/v2/yaml], desc: "Specification of the definition"
12
12
 
13
- def call(file:, format:, id:, token:)
13
+ def call(file:, specification:, id:, token:)
14
14
  with_errors_rescued do
15
15
  response = HTTP
16
16
  .headers(headers(token: token))
17
- .post(API_URL + "/docs/#{id}/validations", body: body(file, format).to_json)
17
+ .post(API_URL + "/docs/#{id}/validations", body: body(file, specification).to_json)
18
18
 
19
19
  if response.code == 200
20
20
  puts "Definition is valid."
@@ -23,15 +23,6 @@ module Bump
23
23
  end
24
24
  end
25
25
  end
26
-
27
- private
28
-
29
- def body(file, format)
30
- {
31
- definition: open(file).read,
32
- format: format
33
- }
34
- end
35
26
  end
36
27
  end
37
28
  end
@@ -1,5 +1,5 @@
1
1
  module Bump
2
2
  class CLI
3
- VERSION = "0.1.1"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bump-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mehdi Lahmam
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2018-03-22 00:00:00.000000000 Z
12
+ date: 2018-03-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: hanami-cli