haveapi 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.editorconfig +15 -0
  3. data/CHANGELOG +15 -0
  4. data/README.md +66 -47
  5. data/doc/create-client.md +14 -5
  6. data/doc/json-schema.erb +16 -2
  7. data/doc/protocol.md +25 -3
  8. data/doc/protocol.plantuml +14 -8
  9. data/haveapi.gemspec +4 -2
  10. data/lib/haveapi.rb +5 -3
  11. data/lib/haveapi/action.rb +34 -6
  12. data/lib/haveapi/action_state.rb +92 -0
  13. data/lib/haveapi/authentication/basic/provider.rb +7 -0
  14. data/lib/haveapi/authentication/token/provider.rb +5 -0
  15. data/lib/haveapi/client_example.rb +83 -0
  16. data/lib/haveapi/client_examples/curl.rb +86 -0
  17. data/lib/haveapi/client_examples/fs_client.rb +116 -0
  18. data/lib/haveapi/client_examples/http.rb +91 -0
  19. data/lib/haveapi/client_examples/js_client.rb +149 -0
  20. data/lib/haveapi/client_examples/php_client.rb +122 -0
  21. data/lib/haveapi/client_examples/ruby_cli.rb +117 -0
  22. data/lib/haveapi/client_examples/ruby_client.rb +106 -0
  23. data/lib/haveapi/context.rb +3 -2
  24. data/lib/haveapi/example.rb +29 -2
  25. data/lib/haveapi/extensions/action_exceptions.rb +2 -2
  26. data/lib/haveapi/extensions/base.rb +1 -1
  27. data/lib/haveapi/extensions/exception_mailer.rb +339 -0
  28. data/lib/haveapi/hooks.rb +1 -1
  29. data/lib/haveapi/parameters/typed.rb +5 -3
  30. data/lib/haveapi/public/css/highlight.css +99 -0
  31. data/lib/haveapi/public/doc/protocol.png +0 -0
  32. data/lib/haveapi/public/js/highlight.pack.js +2 -0
  33. data/lib/haveapi/public/js/highlighter.js +9 -0
  34. data/lib/haveapi/public/js/main.js +32 -0
  35. data/lib/haveapi/public/js/nojs-tabs.js +196 -0
  36. data/lib/haveapi/resources/action_state.rb +196 -0
  37. data/lib/haveapi/server.rb +96 -27
  38. data/lib/haveapi/version.rb +2 -2
  39. data/lib/haveapi/views/main_layout.erb +14 -0
  40. data/lib/haveapi/views/version_page.erb +187 -13
  41. data/lib/haveapi/views/version_sidebar.erb +37 -3
  42. metadata +49 -5
@@ -1,15 +1,32 @@
1
+ <% def render_auth_nav(methods) %>
2
+ <ul>
3
+ <% methods.each do |method, info| %>
4
+ <li>
5
+ <a href="#auth-<%= method %>"><%= method.to_s.humanize %></a>
6
+ <% if info[:resources] %>
7
+ <ul>
8
+ <% sort_hash(info[:resources]).each do |resource, info| %>
9
+ <% render_resource_nav(resource.to_s, info, "auth-#{method}") %>
10
+ <% end %>
11
+ </ul>
12
+ <% end %>
13
+ </li>
14
+ <% end %>
15
+ </ul>
16
+ <% end %>
17
+
1
18
  <% def render_resource_nav(resource, info, prefix='root') %>
2
19
  <li>
3
20
  <a href="#<%= "#{prefix}-#{resource}" %>">.<%= resource.humanize %></a>
4
21
 
5
22
  <ul>
6
- <% info[:actions].each do |action, info| %>
23
+ <% sort_hash(info[:actions]).each do |action, info| %>
7
24
  <li>
8
25
  <a href="#<%= "#{prefix}-#{resource}-#{action}" %>">#<%= action.capitalize %></a>
9
26
  </li>
10
27
  <% end %>
11
28
 
12
- <% info[:resources].each do |r, i| %>
29
+ <% sort_hash(info[:resources]).each do |r, i| %>
13
30
  <% render_resource_nav(r, i, "#{prefix}-#{resource}") %>
14
31
  <% end %>
15
32
  </ul>
@@ -35,8 +52,25 @@
35
52
  <h1>Contents</h1>
36
53
  <ul class="top-level">
37
54
  <li><a href="#api">API v<%= @v %></a></li>
55
+ <li>
56
+ <a href="#auth">Authentication</a>
57
+ <% render_auth_nav(@help[:authentication]) %>
58
+ </li>
38
59
  <li><a href="#resources">Resources</a></li>
39
- <% @help[:resources].each do |resource, info| %>
60
+ <% sort_hash(@help[:resources]).each do |resource, info| %>
40
61
  <% render_resource_nav(resource, info) %>
41
62
  <% end %>
42
63
  </ul>
64
+
65
+ <h1>Browser</h1>
66
+ <p>
67
+ Browse this API with <a href="https://github.com/vpsfreecz/haveapi-webui">haveapi-webui</a>:
68
+ </p>
69
+ <p>
70
+ <a
71
+ href="https://webui.haveapi.org/v<%= version %>/#<%= urlescape(base_url) %>"
72
+ class="btn btn-default"
73
+ target="_blank">
74
+ Connect
75
+ </a>
76
+ </p>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haveapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jakub Skokan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-18 00:00:00.000000000 Z
11
+ date: 2016-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: require_all
@@ -136,12 +136,41 @@ dependencies:
136
136
  - - ~>
137
137
  - !ruby/object:Gem::Version
138
138
  version: 1.0.2
139
+ - !ruby/object:Gem::Dependency
140
+ name: haveapi-client
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ~>
144
+ - !ruby/object:Gem::Version
145
+ version: 0.6.0
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ~>
151
+ - !ruby/object:Gem::Version
152
+ version: 0.6.0
153
+ - !ruby/object:Gem::Dependency
154
+ name: mail
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - '>='
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - '>='
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
139
167
  description: Framework for creating self-describing APIs
140
168
  email: jakub.skokan@vpsfree.cz
141
169
  executables: []
142
170
  extensions: []
143
171
  extra_rdoc_files: []
144
172
  files:
173
+ - .editorconfig
145
174
  - .gitignore
146
175
  - CHANGELOG
147
176
  - Gemfile
@@ -157,6 +186,7 @@ files:
157
186
  - haveapi.gemspec
158
187
  - lib/haveapi.rb
159
188
  - lib/haveapi/action.rb
189
+ - lib/haveapi/action_state.rb
160
190
  - lib/haveapi/actions/default.rb
161
191
  - lib/haveapi/actions/paginable.rb
162
192
  - lib/haveapi/api.rb
@@ -166,12 +196,21 @@ files:
166
196
  - lib/haveapi/authentication/token/provider.rb
167
197
  - lib/haveapi/authentication/token/resources.rb
168
198
  - lib/haveapi/authorization.rb
199
+ - lib/haveapi/client_example.rb
200
+ - lib/haveapi/client_examples/curl.rb
201
+ - lib/haveapi/client_examples/fs_client.rb
202
+ - lib/haveapi/client_examples/http.rb
203
+ - lib/haveapi/client_examples/js_client.rb
204
+ - lib/haveapi/client_examples/php_client.rb
205
+ - lib/haveapi/client_examples/ruby_cli.rb
206
+ - lib/haveapi/client_examples/ruby_client.rb
169
207
  - lib/haveapi/common.rb
170
208
  - lib/haveapi/context.rb
171
209
  - lib/haveapi/example.rb
172
210
  - lib/haveapi/exceptions.rb
173
211
  - lib/haveapi/extensions/action_exceptions.rb
174
212
  - lib/haveapi/extensions/base.rb
213
+ - lib/haveapi/extensions/exception_mailer.rb
175
214
  - lib/haveapi/hooks.rb
176
215
  - lib/haveapi/metadata.rb
177
216
  - lib/haveapi/model_adapter.rb
@@ -185,10 +224,16 @@ files:
185
224
  - lib/haveapi/params.rb
186
225
  - lib/haveapi/public/css/bootstrap-theme.min.css
187
226
  - lib/haveapi/public/css/bootstrap.min.css
227
+ - lib/haveapi/public/css/highlight.css
188
228
  - lib/haveapi/public/doc/protocol.png
189
229
  - lib/haveapi/public/js/bootstrap.min.js
230
+ - lib/haveapi/public/js/highlight.pack.js
231
+ - lib/haveapi/public/js/highlighter.js
190
232
  - lib/haveapi/public/js/jquery-1.11.1.min.js
233
+ - lib/haveapi/public/js/main.js
234
+ - lib/haveapi/public/js/nojs-tabs.js
191
235
  - lib/haveapi/resource.rb
236
+ - lib/haveapi/resources/action_state.rb
192
237
  - lib/haveapi/route.rb
193
238
  - lib/haveapi/server.rb
194
239
  - lib/haveapi/spec/api_builder.rb
@@ -248,9 +293,9 @@ require_paths:
248
293
  - lib
249
294
  required_ruby_version: !ruby/object:Gem::Requirement
250
295
  requirements:
251
- - - ~>
296
+ - - '>='
252
297
  - !ruby/object:Gem::Version
253
- version: '2.0'
298
+ version: 2.0.0
254
299
  required_rubygems_version: !ruby/object:Gem::Requirement
255
300
  requirements:
256
301
  - - '>='
@@ -263,4 +308,3 @@ signing_key:
263
308
  specification_version: 4
264
309
  summary: Framework for creating self-describing APIs
265
310
  test_files: []
266
- has_rdoc: