apiaryio 0.15.2 → 0.16.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
  SHA256:
3
- metadata.gz: a2cbc41bcb380395b638267fe70ca1e7edae887ef7ff2476a4748ace00f670b3
4
- data.tar.gz: 3b2b4bafaab4e05805814aae78addd36aedaa69d7dc20e83cd41c612bc46fb93
3
+ metadata.gz: '0285a16e62857c93d0102d3b35bf5c4b413ae412f13972ab12af5b8201ee3dcb'
4
+ data.tar.gz: 4d45af225fb2df5579cbd9d0cc8262e286c45a0281451fe14555703fe54c420e
5
5
  SHA512:
6
- metadata.gz: 681b132cdb458157d71e9c89577a406b5b232af6727dcdcff75151f40be3ddb3403040245e2f42b890bbe30e1c6f291d7cc426f20ccb3e3fe6f3626d5817ac66
7
- data.tar.gz: '0620901f63e3b66b45dc33d524ac1e34039d9e660c1f98b7a2253ee34214eeb0392a899f0bc5dc01f9d797219bf85c2b3b237dfaa540ae9838e2f3b7f4a7cf62'
6
+ metadata.gz: 6a7e045cae664b7357e965f80fe126e9ffa213869284e23fd806768a78b5217eb8734d1cdaefe53ceda3bd574db9b8e4cdf76c6b54793654b132618ecfb2e5dd
7
+ data.tar.gz: e70b4ae7a5dc7e0d93dc97a57f7ca7f7a8df7821534bc93dd2fc0e5fe769b090f878a01fd825051599400f93e783907d69066eb0ab13a29bd0f72bae4f2b9ecd
data/.editorconfig ADDED
@@ -0,0 +1,15 @@
1
+ ; EditorConfig file: http://EditorConfig.org
2
+ ; Install the "EditorConfig" plugin into your editor to use
3
+
4
+ root = true
5
+
6
+ [*]
7
+ charset = utf-8
8
+ insert_final_newline = true
9
+ indent_style = space
10
+ indent_size = 2
11
+ trim_trailing_whitespace = true
12
+
13
+ [README.md]
14
+ trim_trailing_whitespace = false
15
+ insert_final_newline = false
data/README.md CHANGED
@@ -57,6 +57,7 @@ export APIARY_API_KEY=<your_token>
57
57
  ```
58
58
  $ apiary help
59
59
  Commands:
60
+ apiary archive # Archive All Your API Description Documents from apiary.io to local files named following [api-project-subdomain.apib] pattern.
60
61
  apiary fetch --api-name=API_NAME # Fetch API Description Document from API_NAME.docs.apiary.io
61
62
  apiary help [COMMAND] # Describe available commands or one specific command
62
63
  apiary preview # Show API documentation in browser or write it to file
@@ -68,6 +69,18 @@ Commands:
68
69
 
69
70
  ### Details
70
71
 
72
+ #### archive
73
+
74
+ ```
75
+ $ apiary help archive
76
+ Usage:
77
+ apiary archive
78
+
79
+ Options:
80
+
81
+ Archive All Your API Description Documents from apiary.io to local files named following [api-project-subdomain.apib] pattern.
82
+ ```
83
+
71
84
  #### fetch
72
85
 
73
86
  ```
@@ -198,7 +211,8 @@ Only gem owners `gem owner apiaryio` can publish new gem into [RubyGems](https:/
198
211
  4. make gem release:
199
212
 
200
213
  ```sh
201
- $ rake release
214
+ $ git tag $VERSION
215
+ $ git push --tags
202
216
  ```
203
217
 
204
218
  - if release is stuck you need use `$ rake release --trace` to get OTP prompt.
data/lib/apiary/cli.rb CHANGED
@@ -2,12 +2,22 @@
2
2
 
3
3
  require 'thor'
4
4
  require 'apiary/command/fetch'
5
+ require 'apiary/command/archive'
5
6
  require 'apiary/command/preview'
6
7
  require 'apiary/command/publish'
7
8
  require 'apiary/command/styleguide'
8
9
 
9
10
  module Apiary
10
11
  class CLI < Thor
12
+
13
+ desc 'archive', 'Archive All Your API Description Documents from apiary.io to local files named following [api-project-subdomain.apib] pattern.'
14
+ method_option :api_host, type: :string, banner: 'HOST', desc: 'Specify apiary host', hide: true
15
+
16
+ def archive
17
+ cmd = Apiary::Command::Archive.new options
18
+ cmd.execute
19
+ end
20
+
11
21
  desc 'fetch', 'Fetch API Description Document from API_NAME.docs.apiary.io'
12
22
  method_option :api_name, type: :string, required: true
13
23
  method_option :api_host, type: :string, banner: 'HOST', desc: 'Specify apiary host', hide: true
@@ -0,0 +1,71 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rest-client'
4
+ require 'json'
5
+
6
+ require 'apiary/agent'
7
+
8
+ module Apiary::Command
9
+ # Retrieve blueprint from apiary
10
+ class Archive
11
+ def initialize(opts)
12
+ @options = OpenStruct.new(opts)
13
+ @options.api_host ||= 'api.apiary.io'
14
+ @options.api_key ||= ENV['APIARY_API_KEY']
15
+ @options.proxy ||= ENV['http_proxy']
16
+ @options.headers ||= {
17
+ accept: 'application/json',
18
+ content_type: 'application/json',
19
+ authorization: "Bearer #{@options.api_key}",
20
+ user_agent: Apiary.user_agent
21
+ }
22
+ end
23
+
24
+ def execute
25
+ response = apilist_from_apiary
26
+
27
+ return unless response.instance_of? String
28
+
29
+ puts response
30
+ end
31
+
32
+ def apilist_from_apiary
33
+ unless @options.api_key
34
+ abort 'API key must be provided through environment variable APIARY_API_KEY. Please go to https://login.apiary.io/tokens to obtain it.'
35
+ end
36
+
37
+ response = query_apiary
38
+
39
+ response['apis'].each do |api|
40
+ puts api['apiSubdomain']
41
+ @options = OpenStruct.new
42
+ @options.api_host ||= 'api.apiary.io'
43
+ @options.api_name ||= api['apiSubdomain']
44
+ @options.api_key ||= ENV['APIARY_API_KEY']
45
+ @options.proxy ||= ENV['http_proxy']
46
+ @options.output ||= api['apiSubdomain'] + '.apib'
47
+ @options.headers ||= {
48
+ accept: 'text/html',
49
+ content_type: 'text/plain',
50
+ authentication: "Token #{@options.api_key}",
51
+ user_agent: Apiary.user_agent
52
+ }
53
+ cmd = Apiary::Command::Fetch.new(@options)
54
+ cmd.execute
55
+ end
56
+ end
57
+
58
+ def query_apiary
59
+ url = "https://#{@options.api_host}/me/apis"
60
+ RestClient.proxy = @options.proxy
61
+
62
+ begin
63
+ response = RestClient.get url, @options.headers
64
+ rescue RestClient::Exception => e
65
+ abort "Apiary service responded with an error: #{e.message}"
66
+ end
67
+ JSON.parse response.body
68
+ end
69
+
70
+ end
71
+ end
@@ -1,3 +1,3 @@
1
1
  module Apiary
2
- VERSION = '0.15.2'.freeze
2
+ VERSION = '0.16.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apiaryio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.2
4
+ version: 0.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Apiary Ltd.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-26 00:00:00.000000000 Z
11
+ date: 2021-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -201,6 +201,7 @@ extensions: []
201
201
  extra_rdoc_files: []
202
202
  files:
203
203
  - ".circleci/config.yml"
204
+ - ".editorconfig"
204
205
  - ".github/workflows/release.yml"
205
206
  - ".github/workflows/test.yml"
206
207
  - ".gitignore"
@@ -228,6 +229,7 @@ files:
228
229
  - lib/apiary.rb
229
230
  - lib/apiary/agent.rb
230
231
  - lib/apiary/cli.rb
232
+ - lib/apiary/command/archive.rb
231
233
  - lib/apiary/command/fetch.rb
232
234
  - lib/apiary/command/preview.rb
233
235
  - lib/apiary/command/publish.rb
@@ -260,7 +262,7 @@ homepage: https://apiary.io
260
262
  licenses:
261
263
  - MIT
262
264
  metadata: {}
263
- post_install_message:
265
+ post_install_message:
264
266
  rdoc_options: []
265
267
  require_paths:
266
268
  - lib
@@ -276,7 +278,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
276
278
  version: '0'
277
279
  requirements: []
278
280
  rubygems_version: 3.1.2
279
- signing_key:
281
+ signing_key:
280
282
  specification_version: 4
281
283
  summary: Apiary.io CLI
282
284
  test_files: