apiaryio 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +18 -0
- data/apiary.gemspec +1 -0
- data/lib/apiary/cli.rb +4 -0
- data/lib/apiary/command/help.rb +1 -0
- data/lib/apiary/command/publish.rb +74 -0
- data/lib/apiary/version.rb +1 -1
- metadata +99 -97
data/.travis.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- "1.8.7"
|
4
|
+
- "1.9.2"
|
5
|
+
- "1.9.3"
|
6
|
+
- jruby-18mode # JRuby in 1.8 mode
|
7
|
+
- jruby-19mode # JRuby in 1.9 mode
|
8
|
+
- rbx-18mode
|
9
|
+
- rbx-19mode
|
10
|
+
|
11
|
+
notifications:
|
12
|
+
email:
|
13
|
+
recipients:
|
14
|
+
- lukas@apiary.io
|
15
|
+
on_success: change
|
16
|
+
on_failure: always
|
17
|
+
hipchat:
|
18
|
+
- secure: "HqBUrmf4P2bgvwb4b9PL1tBae2wcZaXadOgwRwAFhdhDZFHaKXIXlJRUW8tN\ntdO83OZgatxJrpWWQj8VYTfDuhlE3b3NxVWeXc3PkfrHmuvejQf4veh7kwR0\njLVE6jb+ZbFIwRE2W0VFLFKYQHI6PLem4W0OKXW5Shqzy8Ewlow="
|
data/apiary.gemspec
CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |gem|
|
|
19
19
|
gem.add_dependency "rest-client", "~> 1.6.7"
|
20
20
|
gem.add_dependency "rack", "~> 1.4.1"
|
21
21
|
gem.add_dependency "json"
|
22
|
+
gem.add_dependency "rake"
|
22
23
|
|
23
24
|
gem.add_development_dependency "rspec", "~> 2.11.0"
|
24
25
|
gem.add_development_dependency "yard", "~> 0.8.2.1"
|
data/lib/apiary/cli.rb
CHANGED
data/lib/apiary/command/help.rb
CHANGED
@@ -22,6 +22,7 @@ module Apiary
|
|
22
22
|
puts "\tpreview --api_host [HOST] Specify apiary host"
|
23
23
|
puts "\tpreview --server Start standalone web server on port 8080"
|
24
24
|
puts "\tpreview --server --port [PORT] Start standalone web server on specified port"
|
25
|
+
puts "\tpublish --api-name [API_NAME] Publish apiary.apib on docs.API_NAME.apiary.io"
|
25
26
|
puts "\tokapi help Show okapi testing tool help"
|
26
27
|
puts "\n"
|
27
28
|
puts "\thelp Show this help"
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'rest_client'
|
3
|
+
require 'rack'
|
4
|
+
require 'ostruct'
|
5
|
+
|
6
|
+
module Apiary
|
7
|
+
module Command
|
8
|
+
# Display preview of local blueprint file
|
9
|
+
class Publish
|
10
|
+
|
11
|
+
attr_reader :options
|
12
|
+
|
13
|
+
# TODO: use OpenStruct to store @options
|
14
|
+
def initialize(opts)
|
15
|
+
@options = OpenStruct.new(opts)
|
16
|
+
@options.path ||= "apiary.apib"
|
17
|
+
@options.api_host ||= "api.apiary.io"
|
18
|
+
@options.port ||= 8080
|
19
|
+
@options.api_name ||= false
|
20
|
+
@options.api_key ||= ENV['APIARY_API_KEY']
|
21
|
+
@options.headers ||= {
|
22
|
+
:accept => "text/html",
|
23
|
+
:content_type => "text/plain",
|
24
|
+
:authentication => "Token #{@options.api_key}"
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.execute(args)
|
29
|
+
new(args).publish_on_apiary
|
30
|
+
end
|
31
|
+
|
32
|
+
def publish_on_apiary
|
33
|
+
unless @options.api_name
|
34
|
+
abort "Please provide an api-name option (subdomain part from your http://docs.<api-name>.apiary.io/)"
|
35
|
+
end
|
36
|
+
|
37
|
+
unless @options.api_key
|
38
|
+
abort "API key must be provided through environment variable APIARY_API_KEY. Please go to https://login.apiary.io/tokens to obtain it."
|
39
|
+
end
|
40
|
+
|
41
|
+
self.query_apiary(@options.api_host, @options.path)
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
def validate_apib_file(apib_file)
|
46
|
+
unless File.exist?(apib_file)
|
47
|
+
abort "Apiary definition file hasn't been found: #{apib_file.inspect}"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def path
|
52
|
+
@options.path || "#{File.basename(Dir.pwd)}.apib"
|
53
|
+
end
|
54
|
+
|
55
|
+
def query_apiary(host, path)
|
56
|
+
url = "https://#{host}/blueprint/publish/#{@options.api_name}"
|
57
|
+
data = {
|
58
|
+
:code => File.read(path)
|
59
|
+
}
|
60
|
+
response = RestClient.post url, data, @options.headers
|
61
|
+
|
62
|
+
unless response.code == 201
|
63
|
+
abort "Request failed with code #{response.code}"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
def api_name
|
69
|
+
"-a"
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
data/lib/apiary/version.rb
CHANGED
metadata
CHANGED
@@ -1,114 +1,123 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: apiaryio
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 4
|
10
|
-
version: 0.0.4
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.5
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Apiary Ltd.
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2013-07-18 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: rest-client
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
25
17
|
none: false
|
26
|
-
requirements:
|
18
|
+
requirements:
|
27
19
|
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 1
|
30
|
-
segments:
|
31
|
-
- 1
|
32
|
-
- 6
|
33
|
-
- 7
|
20
|
+
- !ruby/object:Gem::Version
|
34
21
|
version: 1.6.7
|
35
22
|
type: :runtime
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: rack
|
39
23
|
prerelease: false
|
40
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.6.7
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rack
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
41
33
|
none: false
|
42
|
-
requirements:
|
34
|
+
requirements:
|
43
35
|
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
hash: 5
|
46
|
-
segments:
|
47
|
-
- 1
|
48
|
-
- 4
|
49
|
-
- 1
|
36
|
+
- !ruby/object:Gem::Version
|
50
37
|
version: 1.4.1
|
51
38
|
type: :runtime
|
52
|
-
|
53
|
-
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.4.1
|
46
|
+
- !ruby/object:Gem::Dependency
|
54
47
|
name: json
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
55
|
prerelease: false
|
56
|
-
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
none: false
|
58
|
-
requirements:
|
59
|
-
- -
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rake
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
65
70
|
type: :runtime
|
66
|
-
version_requirements: *id003
|
67
|
-
- !ruby/object:Gem::Dependency
|
68
|
-
name: rspec
|
69
71
|
prerelease: false
|
70
|
-
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rspec
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
71
81
|
none: false
|
72
|
-
requirements:
|
82
|
+
requirements:
|
73
83
|
- - ~>
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
hash: 35
|
76
|
-
segments:
|
77
|
-
- 2
|
78
|
-
- 11
|
79
|
-
- 0
|
84
|
+
- !ruby/object:Gem::Version
|
80
85
|
version: 2.11.0
|
81
86
|
type: :development
|
82
|
-
version_requirements: *id004
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: yard
|
85
87
|
prerelease: false
|
86
|
-
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
87
89
|
none: false
|
88
|
-
requirements:
|
90
|
+
requirements:
|
89
91
|
- - ~>
|
90
|
-
- !ruby/object:Gem::Version
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 2.11.0
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: yard
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
97
101
|
version: 0.8.2.1
|
98
102
|
type: :development
|
99
|
-
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 0.8.2.1
|
100
110
|
description: Apiary.io CLI
|
101
|
-
email:
|
111
|
+
email:
|
102
112
|
- team@apiary.io
|
103
|
-
executables:
|
113
|
+
executables:
|
104
114
|
- apiary
|
105
115
|
extensions: []
|
106
|
-
|
107
116
|
extra_rdoc_files: []
|
108
|
-
|
109
|
-
files:
|
117
|
+
files:
|
110
118
|
- .gitignore
|
111
119
|
- .rspec
|
120
|
+
- .travis.yml
|
112
121
|
- Gemfile
|
113
122
|
- Gemfile.lock
|
114
123
|
- LICENSE
|
@@ -141,6 +150,7 @@ files:
|
|
141
150
|
- lib/apiary/cli.rb
|
142
151
|
- lib/apiary/command/help.rb
|
143
152
|
- lib/apiary/command/preview.rb
|
153
|
+
- lib/apiary/command/publish.rb
|
144
154
|
- lib/apiary/command/runner.rb
|
145
155
|
- lib/apiary/command/version.rb
|
146
156
|
- lib/apiary/version.rb
|
@@ -163,40 +173,32 @@ files:
|
|
163
173
|
- lib/okapi/test.rb
|
164
174
|
- spec/cli_spec.rb
|
165
175
|
- spec/spec_helper.rb
|
166
|
-
has_rdoc: true
|
167
176
|
homepage: http://apiary.io
|
168
|
-
licenses:
|
177
|
+
licenses:
|
169
178
|
- MIT
|
170
179
|
post_install_message:
|
171
180
|
rdoc_options: []
|
172
|
-
|
173
|
-
require_paths:
|
181
|
+
require_paths:
|
174
182
|
- lib
|
175
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
183
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
176
184
|
none: false
|
177
|
-
requirements:
|
178
|
-
- -
|
179
|
-
- !ruby/object:Gem::Version
|
180
|
-
|
181
|
-
|
182
|
-
- 0
|
183
|
-
version: "0"
|
184
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
185
|
+
requirements:
|
186
|
+
- - ! '>='
|
187
|
+
- !ruby/object:Gem::Version
|
188
|
+
version: '0'
|
189
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
185
190
|
none: false
|
186
|
-
requirements:
|
187
|
-
- -
|
188
|
-
- !ruby/object:Gem::Version
|
189
|
-
|
190
|
-
segments:
|
191
|
-
- 0
|
192
|
-
version: "0"
|
191
|
+
requirements:
|
192
|
+
- - ! '>='
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
193
195
|
requirements: []
|
194
|
-
|
195
196
|
rubyforge_project:
|
196
|
-
rubygems_version: 1.
|
197
|
+
rubygems_version: 1.8.24
|
197
198
|
signing_key:
|
198
199
|
specification_version: 3
|
199
200
|
summary: Apiary.io CLI
|
200
|
-
test_files:
|
201
|
+
test_files:
|
201
202
|
- spec/cli_spec.rb
|
202
203
|
- spec/spec_helper.rb
|
204
|
+
has_rdoc:
|