apiaryio 0.0.8 → 0.0.9
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.
- data/.gitignore +1 -0
- data/.travis.yml +3 -4
- data/Gemfile +5 -0
- data/README.md +6 -2
- data/apiary.gemspec +4 -3
- data/doc/Apiary.html +7 -7
- data/doc/Apiary/CLI.html +44 -32
- data/doc/Apiary/Command.html +7 -7
- data/doc/Apiary/Command/Fetch.html +572 -0
- data/doc/Apiary/Command/Help.html +16 -11
- data/doc/Apiary/Command/Preview.html +175 -216
- data/doc/Apiary/Command/Publish.html +634 -0
- data/doc/Apiary/Command/Runner.html +8 -9
- data/doc/Apiary/Command/Version.html +7 -8
- data/doc/_index.html +28 -6
- data/doc/class_list.html +3 -2
- data/doc/css/style.css +11 -1
- data/doc/file.README.html +37 -22
- data/doc/file_list.html +2 -1
- data/doc/frames.html +5 -7
- data/doc/index.html +37 -22
- data/doc/js/app.js +7 -2
- data/doc/js/full_list.js +7 -2
- data/doc/method_list.html +112 -89
- data/doc/top-level-namespace.html +5 -5
- data/lib/apiary/command/fetch.rb +79 -0
- data/lib/apiary/command/help.rb +1 -0
- data/lib/apiary/version.rb +1 -1
- data/spec/command/fetch_spec.rb +87 -0
- data/spec/spec_helper.rb +1 -0
- metadata +121 -85
data/doc/js/app.js
CHANGED
|
@@ -78,7 +78,12 @@ function framesInit() {
|
|
|
78
78
|
if (hasFrames) {
|
|
79
79
|
document.body.className = 'frames';
|
|
80
80
|
$('#menu .noframes a').attr('href', document.location);
|
|
81
|
-
|
|
81
|
+
try {
|
|
82
|
+
window.top.document.title = $('html head title').text();
|
|
83
|
+
} catch(error) {
|
|
84
|
+
// some browsers will not allow this when serving from file://
|
|
85
|
+
// but we don't want to stop the world.
|
|
86
|
+
}
|
|
82
87
|
}
|
|
83
88
|
else {
|
|
84
89
|
$('#menu .noframes a').text('frames').attr('href', framesUrl);
|
|
@@ -211,4 +216,4 @@ $(linkSummaries);
|
|
|
211
216
|
$(keyboardShortcuts);
|
|
212
217
|
$(summaryToggle);
|
|
213
218
|
$(fixOutsideWorldLinks);
|
|
214
|
-
$(generateTOC);
|
|
219
|
+
$(generateTOC);
|
data/doc/js/full_list.js
CHANGED
|
@@ -17,6 +17,7 @@ function fullListSearch() {
|
|
|
17
17
|
searchCache = [];
|
|
18
18
|
$('#full_list li').each(function() {
|
|
19
19
|
var link = $(this).find('.object_link a');
|
|
20
|
+
if (link.length === 0) return;
|
|
20
21
|
var fullName = link.attr('title').split(' ')[0];
|
|
21
22
|
searchCache.push({name:link.text(), fullName:fullName, node:$(this), link:link});
|
|
22
23
|
});
|
|
@@ -41,7 +42,7 @@ function fullListSearch() {
|
|
|
41
42
|
$('#full_list li').removeClass('found').each(function() {
|
|
42
43
|
|
|
43
44
|
var link = $(this).find('.object_link a');
|
|
44
|
-
link.text(link.text());
|
|
45
|
+
if (link.length > 0) link.text(link.text());
|
|
45
46
|
});
|
|
46
47
|
if (clicked) {
|
|
47
48
|
clicked.parents('ul').each(function() {
|
|
@@ -111,6 +112,10 @@ function linkList() {
|
|
|
111
112
|
$('#full_list li, #full_list li a:last').click(function(evt) {
|
|
112
113
|
if ($(this).hasClass('toggle')) return true;
|
|
113
114
|
if (this.tagName.toLowerCase() == "li") {
|
|
115
|
+
if ($(this).find('.object_link a').length === 0) {
|
|
116
|
+
$(this).children('a.toggle').click();
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
114
119
|
var toggle = $(this).children('a.toggle');
|
|
115
120
|
if (toggle.size() > 0 && evt.pageX < toggle.offset().left) {
|
|
116
121
|
toggle.click();
|
|
@@ -120,7 +125,7 @@ function linkList() {
|
|
|
120
125
|
if (clicked) clicked.removeClass('clicked');
|
|
121
126
|
var win = window.top.frames.main ? window.top.frames.main : window.parent;
|
|
122
127
|
if (this.tagName.toLowerCase() == "a") {
|
|
123
|
-
clicked = $(this).
|
|
128
|
+
clicked = $(this).parents('li').addClass('clicked');
|
|
124
129
|
win.location = this.href;
|
|
125
130
|
}
|
|
126
131
|
else {
|
data/doc/method_list.html
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
<script type="text/javascript" charset="utf-8" src="js/full_list.js"></script>
|
|
16
16
|
|
|
17
17
|
|
|
18
|
+
<title>Method List</title>
|
|
18
19
|
<base id="base_target" target="_parent" />
|
|
19
20
|
</head>
|
|
20
21
|
<body>
|
|
@@ -47,202 +48,224 @@
|
|
|
47
48
|
|
|
48
49
|
|
|
49
50
|
<li class="r1 ">
|
|
50
|
-
<span class='object_link'><a href="Apiary/Command/
|
|
51
|
-
|
|
52
|
-
<small>Apiary::Command::Preview</small>
|
|
53
|
-
|
|
51
|
+
<span class='object_link'><a href="Apiary/Command/Help.html#banner-class_method" title="Apiary::Command::Help.banner (method)">banner</a></span>
|
|
52
|
+
<small>Apiary::Command::Help</small>
|
|
54
53
|
</li>
|
|
55
54
|
|
|
56
55
|
|
|
57
56
|
<li class="r2 ">
|
|
58
|
-
<span class='object_link'><a href="Apiary/Command/Preview.html#
|
|
59
|
-
|
|
60
|
-
<small>Apiary::Command::Preview</small>
|
|
61
|
-
|
|
57
|
+
<span class='object_link'><a href="Apiary/Command/Preview.html#browser-instance_method" title="Apiary::Command::Preview#browser (method)">#browser</a></span>
|
|
58
|
+
<small>Apiary::Command::Preview</small>
|
|
62
59
|
</li>
|
|
63
60
|
|
|
64
61
|
|
|
65
62
|
<li class="r1 ">
|
|
66
|
-
<span class='object_link'><a href="Apiary/
|
|
67
|
-
|
|
68
|
-
<small>Apiary::Command::Help</small>
|
|
69
|
-
|
|
63
|
+
<span class='object_link'><a href="Apiary/CLI.html#command-instance_method" title="Apiary::CLI#command (method)">#command</a></span>
|
|
64
|
+
<small>Apiary::CLI</small>
|
|
70
65
|
</li>
|
|
71
66
|
|
|
72
67
|
|
|
73
68
|
<li class="r2 ">
|
|
74
|
-
<span class='object_link'><a href="Apiary/Command/
|
|
75
|
-
|
|
76
|
-
<small>Apiary::Command::Preview</small>
|
|
77
|
-
|
|
69
|
+
<span class='object_link'><a href="Apiary/Command/Help.html#commands-class_method" title="Apiary::Command::Help.commands (method)">commands</a></span>
|
|
70
|
+
<small>Apiary::Command::Help</small>
|
|
78
71
|
</li>
|
|
79
72
|
|
|
80
73
|
|
|
81
74
|
<li class="r1 ">
|
|
82
|
-
<span class='object_link'><a href="Apiary/
|
|
83
|
-
|
|
84
|
-
<small>Apiary::CLI</small>
|
|
85
|
-
|
|
75
|
+
<span class='object_link'><a href="Apiary/Command/Fetch.html#execute-class_method" title="Apiary::Command::Fetch.execute (method)">execute</a></span>
|
|
76
|
+
<small>Apiary::Command::Fetch</small>
|
|
86
77
|
</li>
|
|
87
78
|
|
|
88
79
|
|
|
89
80
|
<li class="r2 ">
|
|
90
|
-
<span class='object_link'><a href="Apiary/Command/
|
|
91
|
-
|
|
92
|
-
<small>Apiary::Command::Help</small>
|
|
93
|
-
|
|
81
|
+
<span class='object_link'><a href="Apiary/Command/Preview.html#execute-class_method" title="Apiary::Command::Preview.execute (method)">execute</a></span>
|
|
82
|
+
<small>Apiary::Command::Preview</small>
|
|
94
83
|
</li>
|
|
95
84
|
|
|
96
85
|
|
|
97
86
|
<li class="r1 ">
|
|
98
|
-
<span class='object_link'><a href="Apiary/Command/
|
|
99
|
-
|
|
100
|
-
<small>Apiary::Command::Help</small>
|
|
101
|
-
|
|
87
|
+
<span class='object_link'><a href="Apiary/Command/Version.html#execute-class_method" title="Apiary::Command::Version.execute (method)">execute</a></span>
|
|
88
|
+
<small>Apiary::Command::Version</small>
|
|
102
89
|
</li>
|
|
103
90
|
|
|
104
91
|
|
|
105
92
|
<li class="r2 ">
|
|
106
|
-
<span class='object_link'><a href="Apiary/Command/
|
|
107
|
-
|
|
108
|
-
<small>Apiary::Command::Preview</small>
|
|
109
|
-
|
|
93
|
+
<span class='object_link'><a href="Apiary/Command/Help.html#execute-class_method" title="Apiary::Command::Help.execute (method)">execute</a></span>
|
|
94
|
+
<small>Apiary::Command::Help</small>
|
|
110
95
|
</li>
|
|
111
96
|
|
|
112
97
|
|
|
113
98
|
<li class="r1 ">
|
|
114
|
-
<span class='object_link'><a href="Apiary/Command/
|
|
115
|
-
|
|
116
|
-
<small>Apiary::Command::Version</small>
|
|
117
|
-
|
|
99
|
+
<span class='object_link'><a href="Apiary/Command/Publish.html#execute-class_method" title="Apiary::Command::Publish.execute (method)">execute</a></span>
|
|
100
|
+
<small>Apiary::Command::Publish</small>
|
|
118
101
|
</li>
|
|
119
102
|
|
|
120
103
|
|
|
121
104
|
<li class="r2 ">
|
|
105
|
+
<span class='object_link'><a href="Apiary/Command/Fetch.html#fetch_from_apiary-instance_method" title="Apiary::Command::Fetch#fetch_from_apiary (method)">#fetch_from_apiary</a></span>
|
|
106
|
+
<small>Apiary::Command::Fetch</small>
|
|
107
|
+
</li>
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
<li class="r1 ">
|
|
122
111
|
<span class='object_link'><a href="Apiary/Command/Preview.html#generate_static-instance_method" title="Apiary::Command::Preview#generate_static (method)">#generate_static</a></span>
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
112
|
+
<small>Apiary::Command::Preview</small>
|
|
113
|
+
</li>
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
<li class="r2 ">
|
|
117
|
+
<span class='object_link'><a href="Apiary/Command/Fetch.html#initialize-instance_method" title="Apiary::Command::Fetch#initialize (method)">#initialize</a></span>
|
|
118
|
+
<small>Apiary::Command::Fetch</small>
|
|
126
119
|
</li>
|
|
127
120
|
|
|
128
121
|
|
|
129
122
|
<li class="r1 ">
|
|
130
|
-
<span class='object_link'><a href="Apiary/Command/
|
|
131
|
-
|
|
132
|
-
<small>Apiary::Command::Preview</small>
|
|
133
|
-
|
|
123
|
+
<span class='object_link'><a href="Apiary/Command/Publish.html#initialize-instance_method" title="Apiary::Command::Publish#initialize (method)">#initialize</a></span>
|
|
124
|
+
<small>Apiary::Command::Publish</small>
|
|
134
125
|
</li>
|
|
135
126
|
|
|
136
127
|
|
|
137
128
|
<li class="r2 ">
|
|
138
|
-
<span class='object_link'><a href="Apiary/
|
|
139
|
-
|
|
140
|
-
<small>Apiary::CLI</small>
|
|
141
|
-
|
|
129
|
+
<span class='object_link'><a href="Apiary/Command/Preview.html#initialize-instance_method" title="Apiary::Command::Preview#initialize (method)">#initialize</a></span>
|
|
130
|
+
<small>Apiary::Command::Preview</small>
|
|
142
131
|
</li>
|
|
143
132
|
|
|
144
133
|
|
|
145
134
|
<li class="r1 ">
|
|
135
|
+
<span class='object_link'><a href="Apiary/CLI.html#initialize-instance_method" title="Apiary::CLI#initialize (method)">#initialize</a></span>
|
|
136
|
+
<small>Apiary::CLI</small>
|
|
137
|
+
</li>
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
<li class="r2 ">
|
|
146
141
|
<span class='object_link'><a href="Apiary/Command/Preview.html#open_generated_page-instance_method" title="Apiary::Command::Preview#open_generated_page (method)">#open_generated_page</a></span>
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
142
|
+
<small>Apiary::Command::Preview</small>
|
|
143
|
+
</li>
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
<li class="r1 ">
|
|
147
|
+
<span class='object_link'><a href="Apiary/Command/Fetch.html#options-instance_method" title="Apiary::Command::Fetch#options (method)">#options</a></span>
|
|
148
|
+
<small>Apiary::Command::Fetch</small>
|
|
150
149
|
</li>
|
|
151
150
|
|
|
152
151
|
|
|
153
152
|
<li class="r2 ">
|
|
154
153
|
<span class='object_link'><a href="Apiary/Command/Preview.html#options-instance_method" title="Apiary::Command::Preview#options (method)">#options</a></span>
|
|
155
|
-
|
|
156
|
-
<small>Apiary::Command::Preview</small>
|
|
157
|
-
|
|
154
|
+
<small>Apiary::Command::Preview</small>
|
|
158
155
|
</li>
|
|
159
156
|
|
|
160
157
|
|
|
161
158
|
<li class="r1 ">
|
|
159
|
+
<span class='object_link'><a href="Apiary/Command/Publish.html#options-instance_method" title="Apiary::Command::Publish#options (method)">#options</a></span>
|
|
160
|
+
<small>Apiary::Command::Publish</small>
|
|
161
|
+
</li>
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
<li class="r2 ">
|
|
162
165
|
<span class='object_link'><a href="Apiary/CLI.html#parse_options%21-instance_method" title="Apiary::CLI#parse_options! (method)">#parse_options!</a></span>
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
+
<small>Apiary::CLI</small>
|
|
167
|
+
</li>
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
<li class="r1 ">
|
|
171
|
+
<span class='object_link'><a href="Apiary/Command/Fetch.html#path-instance_method" title="Apiary::Command::Fetch#path (method)">#path</a></span>
|
|
172
|
+
<small>Apiary::Command::Fetch</small>
|
|
166
173
|
</li>
|
|
167
174
|
|
|
168
175
|
|
|
169
176
|
<li class="r2 ">
|
|
170
|
-
<span class='object_link'><a href="Apiary/Command/
|
|
171
|
-
|
|
172
|
-
<small>Apiary::Command::Preview</small>
|
|
173
|
-
|
|
177
|
+
<span class='object_link'><a href="Apiary/Command/Publish.html#path-instance_method" title="Apiary::Command::Publish#path (method)">#path</a></span>
|
|
178
|
+
<small>Apiary::Command::Publish</small>
|
|
174
179
|
</li>
|
|
175
180
|
|
|
176
181
|
|
|
177
182
|
<li class="r1 ">
|
|
183
|
+
<span class='object_link'><a href="Apiary/Command/Preview.html#path-instance_method" title="Apiary::Command::Preview#path (method)">#path</a></span>
|
|
184
|
+
<small>Apiary::Command::Preview</small>
|
|
185
|
+
</li>
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
<li class="r2 ">
|
|
178
189
|
<span class='object_link'><a href="Apiary/Command/Preview.html#preview_path-instance_method" title="Apiary::Command::Preview#preview_path (method)">#preview_path</a></span>
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
190
|
+
<small>Apiary::Command::Preview</small>
|
|
191
|
+
</li>
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
<li class="r1 ">
|
|
195
|
+
<span class='object_link'><a href="Apiary/Command/Publish.html#publish_on_apiary-instance_method" title="Apiary::Command::Publish#publish_on_apiary (method)">#publish_on_apiary</a></span>
|
|
196
|
+
<small>Apiary::Command::Publish</small>
|
|
182
197
|
</li>
|
|
183
198
|
|
|
184
199
|
|
|
185
200
|
<li class="r2 ">
|
|
201
|
+
<span class='object_link'><a href="Apiary/Command/Fetch.html#query_apiary-instance_method" title="Apiary::Command::Fetch#query_apiary (method)">#query_apiary</a></span>
|
|
202
|
+
<small>Apiary::Command::Fetch</small>
|
|
203
|
+
</li>
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
<li class="r1 ">
|
|
186
207
|
<span class='object_link'><a href="Apiary/Command/Preview.html#query_apiary-instance_method" title="Apiary::Command::Preview#query_apiary (method)">#query_apiary</a></span>
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
208
|
+
<small>Apiary::Command::Preview</small>
|
|
209
|
+
</li>
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
<li class="r2 ">
|
|
213
|
+
<span class='object_link'><a href="Apiary/Command/Publish.html#query_apiary-instance_method" title="Apiary::Command::Publish#query_apiary (method)">#query_apiary</a></span>
|
|
214
|
+
<small>Apiary::Command::Publish</small>
|
|
190
215
|
</li>
|
|
191
216
|
|
|
192
217
|
|
|
193
218
|
<li class="r1 ">
|
|
194
219
|
<span class='object_link'><a href="Apiary/Command/Preview.html#rack_app-instance_method" title="Apiary::Command::Preview#rack_app (method)">#rack_app</a></span>
|
|
195
|
-
|
|
196
|
-
<small>Apiary::Command::Preview</small>
|
|
197
|
-
|
|
220
|
+
<small>Apiary::Command::Preview</small>
|
|
198
221
|
</li>
|
|
199
222
|
|
|
200
223
|
|
|
201
224
|
<li class="r2 ">
|
|
202
|
-
<span class='object_link'><a href="Apiary/
|
|
203
|
-
|
|
204
|
-
<small>Apiary::Command::Runner</small>
|
|
205
|
-
|
|
225
|
+
<span class='object_link'><a href="Apiary/CLI.html#run-instance_method" title="Apiary::CLI#run (method)">#run</a></span>
|
|
226
|
+
<small>Apiary::CLI</small>
|
|
206
227
|
</li>
|
|
207
228
|
|
|
208
229
|
|
|
209
230
|
<li class="r1 ">
|
|
210
|
-
<span class='object_link'><a href="Apiary/
|
|
211
|
-
|
|
212
|
-
<small>Apiary::CLI</small>
|
|
213
|
-
|
|
231
|
+
<span class='object_link'><a href="Apiary/Command/Runner.html#run-class_method" title="Apiary::Command::Runner.run (method)">run</a></span>
|
|
232
|
+
<small>Apiary::Command::Runner</small>
|
|
214
233
|
</li>
|
|
215
234
|
|
|
216
235
|
|
|
217
236
|
<li class="r2 ">
|
|
218
237
|
<span class='object_link'><a href="Apiary/Command/Preview.html#run_server-instance_method" title="Apiary::Command::Preview#run_server (method)">#run_server</a></span>
|
|
219
|
-
|
|
220
|
-
<small>Apiary::Command::Preview</small>
|
|
221
|
-
|
|
238
|
+
<small>Apiary::Command::Preview</small>
|
|
222
239
|
</li>
|
|
223
240
|
|
|
224
241
|
|
|
225
242
|
<li class="r1 ">
|
|
226
243
|
<span class='object_link'><a href="Apiary/Command/Preview.html#server-instance_method" title="Apiary::Command::Preview#server (method)">#server</a></span>
|
|
227
|
-
|
|
228
|
-
<small>Apiary::Command::Preview</small>
|
|
229
|
-
|
|
244
|
+
<small>Apiary::Command::Preview</small>
|
|
230
245
|
</li>
|
|
231
246
|
|
|
232
247
|
|
|
233
248
|
<li class="r2 ">
|
|
234
249
|
<span class='object_link'><a href="Apiary/Command/Preview.html#show-instance_method" title="Apiary::Command::Preview#show (method)">#show</a></span>
|
|
235
|
-
|
|
236
|
-
<small>Apiary::Command::Preview</small>
|
|
237
|
-
|
|
250
|
+
<small>Apiary::Command::Preview</small>
|
|
238
251
|
</li>
|
|
239
252
|
|
|
240
253
|
|
|
241
254
|
<li class="r1 ">
|
|
255
|
+
<span class='object_link'><a href="Apiary/Command/Publish.html#validate_apib_file-instance_method" title="Apiary::Command::Publish#validate_apib_file (method)">#validate_apib_file</a></span>
|
|
256
|
+
<small>Apiary::Command::Publish</small>
|
|
257
|
+
</li>
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
<li class="r2 ">
|
|
242
261
|
<span class='object_link'><a href="Apiary/Command/Preview.html#validate_apib_file-instance_method" title="Apiary::Command::Preview#validate_apib_file (method)">#validate_apib_file</a></span>
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
262
|
+
<small>Apiary::Command::Preview</small>
|
|
263
|
+
</li>
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
<li class="r1 ">
|
|
267
|
+
<span class='object_link'><a href="Apiary/Command/Preview.html#write_generated_path-instance_method" title="Apiary::Command::Preview#write_generated_path (method)">#write_generated_path</a></span>
|
|
268
|
+
<small>Apiary::Command::Preview</small>
|
|
246
269
|
</li>
|
|
247
270
|
|
|
248
271
|
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
<title>
|
|
7
7
|
Top Level Namespace
|
|
8
8
|
|
|
9
|
-
— Documentation by YARD 0.8.
|
|
9
|
+
— Documentation by YARD 0.8.7.3
|
|
10
10
|
|
|
11
11
|
</title>
|
|
12
12
|
|
|
13
|
-
<link rel="stylesheet" href="css/style.css" type="text/css"
|
|
13
|
+
<link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
|
|
14
14
|
|
|
15
|
-
<link rel="stylesheet" href="css/common.css" type="text/css"
|
|
15
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
|
|
16
16
|
|
|
17
17
|
<script type="text/javascript" charset="utf-8">
|
|
18
18
|
hasFrames = window.top.frames.main ? true : false;
|
|
@@ -103,9 +103,9 @@
|
|
|
103
103
|
</div>
|
|
104
104
|
|
|
105
105
|
<div id="footer">
|
|
106
|
-
Generated on
|
|
106
|
+
Generated on Sat Jan 25 12:41:41 2014 by
|
|
107
107
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
108
|
-
0.8.
|
|
108
|
+
0.8.7.3 (ruby-2.1.0).
|
|
109
109
|
</div>
|
|
110
110
|
|
|
111
111
|
</body>
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
require 'rest_client'
|
|
3
|
+
require 'rack'
|
|
4
|
+
require 'ostruct'
|
|
5
|
+
require 'json'
|
|
6
|
+
|
|
7
|
+
module Apiary
|
|
8
|
+
module Command
|
|
9
|
+
# Retrieve blueprint from apiary
|
|
10
|
+
class Fetch
|
|
11
|
+
|
|
12
|
+
attr_reader :options
|
|
13
|
+
|
|
14
|
+
# TODO: use OpenStruct to store @options
|
|
15
|
+
def initialize(opts)
|
|
16
|
+
@options = OpenStruct.new(opts)
|
|
17
|
+
@options.path ||= "apiary.apib"
|
|
18
|
+
@options.api_host ||= "api.apiary.io"
|
|
19
|
+
@options.port ||= 8080
|
|
20
|
+
@options.api_name ||= false
|
|
21
|
+
@options.api_key ||= ENV['APIARY_API_KEY']
|
|
22
|
+
@options.headers ||= {
|
|
23
|
+
:accept => "text/html",
|
|
24
|
+
:content_type => "text/plain",
|
|
25
|
+
:authentication => "Token #{@options.api_key}"
|
|
26
|
+
}
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.execute(args)
|
|
30
|
+
response = new(args).fetch_from_apiary
|
|
31
|
+
if response.instance_of? String
|
|
32
|
+
puts response
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def fetch_from_apiary
|
|
37
|
+
unless @options.api_name
|
|
38
|
+
abort "Please provide an api-name option (subdomain part from your http://docs.<api-name>.apiary.io/)"
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
unless @options.api_key
|
|
42
|
+
abort "API key must be provided through environment variable APIARY_API_KEY. Please go to https://login.apiary.io/tokens to obtain it."
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
response = self.query_apiary(@options.api_host, @options.path)
|
|
46
|
+
unless @options.output
|
|
47
|
+
response["code"]
|
|
48
|
+
else
|
|
49
|
+
write_generated_path(response["code"], @options.output)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def path
|
|
54
|
+
@options.path || "#{File.basename(Dir.pwd)}.apib"
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def query_apiary(host, path)
|
|
58
|
+
url = "https://#{host}/blueprint/get/#{@options.api_name}"
|
|
59
|
+
response = RestClient.get url, @options.headers
|
|
60
|
+
unless (200..299).include? response.code
|
|
61
|
+
abort "Request failed with code #{response.code}"
|
|
62
|
+
end
|
|
63
|
+
JSON.parse response.body
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def write_generated_path(data, outfile)
|
|
67
|
+
File.open(outfile, 'w') do |file|
|
|
68
|
+
file.write(data)
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
private
|
|
73
|
+
def api_name
|
|
74
|
+
"-a"
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|