openstax_api 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/openstax/api/v1/api_controller.rb +9 -145
  3. data/app/controllers/openstax/api/v1/oauth_based_api_controller.rb +0 -2
  4. data/app/models/openstax/api/api_user.rb +5 -4
  5. data/lib/openstax/api/apipie.rb +51 -0
  6. data/lib/{openstax_api → openstax/api}/constraints.rb +0 -0
  7. data/lib/{openstax_api → openstax/api}/doorkeeper_extensions.rb +0 -0
  8. data/lib/{openstax_api → openstax/api}/engine.rb +0 -0
  9. data/lib/openstax/api/representable_schema_printer.rb +83 -0
  10. data/lib/openstax/api/roar.rb +132 -0
  11. data/lib/{openstax_api → openstax/api}/route_extensions.rb +1 -1
  12. data/lib/{openstax_api → openstax/api}/version.rb +1 -1
  13. data/lib/openstax_api.rb +20 -3
  14. data/spec/app/models/openstax/api/api_user_spec.rb +1 -1
  15. data/spec/app/representers/openstax/api/v1/representable_schema_printer_spec.rb +1 -1
  16. data/spec/dummy/app/models/dummy_user.rb +2 -0
  17. data/spec/dummy/app/representers/{user_representer.rb → dummy_user_representer.rb} +1 -1
  18. data/spec/dummy/config/initializers/openstax_api.rb +3 -0
  19. data/spec/dummy/db/development.sqlite3 +0 -0
  20. data/spec/dummy/db/migrate/{1_create_users.rb → 1_create_dummy_users.rb} +2 -2
  21. data/spec/dummy/db/schema.rb +7 -7
  22. data/spec/dummy/db/test.sqlite3 +0 -0
  23. data/spec/dummy/log/development.log +101 -597
  24. data/spec/dummy/log/test.log +62 -3216
  25. data/spec/lib/openstax/api/apipie.rb +11 -0
  26. data/spec/lib/{openstax_api → openstax/api}/constraints_spec.rb +0 -0
  27. data/spec/lib/{openstax_api → openstax/api}/doorkeeper_extensions_spec.rb +0 -0
  28. data/spec/lib/openstax/api/roar.rb +11 -0
  29. data/spec/lib/{openstax_api → openstax/api}/route_extensions_spec.rb +0 -0
  30. metadata +42 -20
  31. data/app/representers/openstax/api/v1/representable_schema_printer.rb +0 -85
  32. data/spec/dummy/app/models/user.rb +0 -2
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ module OpenStax
4
+ module Api
5
+ module V1
6
+ describe Apipie do
7
+ # TODO: Test apipie helpers using dummy app
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ module OpenStax
4
+ module Api
5
+ module V1
6
+ describe Roar do
7
+ # TODO: Test generic REST api methods using dummy app
8
+ end
9
+ end
10
+ end
11
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openstax_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dante Soares
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-03-26 00:00:00.000000000 Z
12
+ date: 2014-04-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -81,6 +81,20 @@ dependencies:
81
81
  - - ">="
82
82
  - !ruby/object:Gem::Version
83
83
  version: 1.0.1
84
+ - !ruby/object:Gem::Dependency
85
+ name: exception_notification
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '4.0'
91
+ type: :runtime
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '4.0'
84
98
  - !ruby/object:Gem::Dependency
85
99
  name: sqlite3
86
100
  requirement: !ruby/object:Gem::Requirement
@@ -124,13 +138,15 @@ files:
124
138
  - app/controllers/openstax/api/v1/api_controller.rb
125
139
  - app/controllers/openstax/api/v1/oauth_based_api_controller.rb
126
140
  - app/models/openstax/api/api_user.rb
127
- - app/representers/openstax/api/v1/representable_schema_printer.rb
141
+ - lib/openstax/api/apipie.rb
142
+ - lib/openstax/api/constraints.rb
143
+ - lib/openstax/api/doorkeeper_extensions.rb
144
+ - lib/openstax/api/engine.rb
145
+ - lib/openstax/api/representable_schema_printer.rb
146
+ - lib/openstax/api/roar.rb
147
+ - lib/openstax/api/route_extensions.rb
148
+ - lib/openstax/api/version.rb
128
149
  - lib/openstax_api.rb
129
- - lib/openstax_api/constraints.rb
130
- - lib/openstax_api/doorkeeper_extensions.rb
131
- - lib/openstax_api/engine.rb
132
- - lib/openstax_api/route_extensions.rb
133
- - lib/openstax_api/version.rb
134
150
  - spec/app/controllers/openstax/api/v1/api_controller_spec.rb
135
151
  - spec/app/controllers/openstax/api/v1/oauth_based_api_controller_spec.rb
136
152
  - spec/app/models/openstax/api/api_user_spec.rb
@@ -141,8 +157,8 @@ files:
141
157
  - spec/dummy/app/assets/stylesheets/application.css
142
158
  - spec/dummy/app/controllers/application_controller.rb
143
159
  - spec/dummy/app/helpers/application_helper.rb
144
- - spec/dummy/app/models/user.rb
145
- - spec/dummy/app/representers/user_representer.rb
160
+ - spec/dummy/app/models/dummy_user.rb
161
+ - spec/dummy/app/representers/dummy_user_representer.rb
146
162
  - spec/dummy/config.ru
147
163
  - spec/dummy/config/application.rb
148
164
  - spec/dummy/config/boot.rb
@@ -155,6 +171,7 @@ files:
155
171
  - spec/dummy/config/initializers/doorkeeper.rb
156
172
  - spec/dummy/config/initializers/inflections.rb
157
173
  - spec/dummy/config/initializers/mime_types.rb
174
+ - spec/dummy/config/initializers/openstax_api.rb
158
175
  - spec/dummy/config/initializers/secret_token.rb
159
176
  - spec/dummy/config/initializers/session_store.rb
160
177
  - spec/dummy/config/initializers/wrap_parameters.rb
@@ -162,7 +179,7 @@ files:
162
179
  - spec/dummy/config/routes.rb
163
180
  - spec/dummy/db/development.sqlite3
164
181
  - spec/dummy/db/migrate/0_create_doorkeeper_tables.rb
165
- - spec/dummy/db/migrate/1_create_users.rb
182
+ - spec/dummy/db/migrate/1_create_dummy_users.rb
166
183
  - spec/dummy/db/schema.rb
167
184
  - spec/dummy/db/test.sqlite3
168
185
  - spec/dummy/log/development.log
@@ -172,9 +189,11 @@ files:
172
189
  - spec/dummy/public/500.html
173
190
  - spec/dummy/public/favicon.ico
174
191
  - spec/dummy/script/rails
175
- - spec/lib/openstax_api/constraints_spec.rb
176
- - spec/lib/openstax_api/doorkeeper_extensions_spec.rb
177
- - spec/lib/openstax_api/route_extensions_spec.rb
192
+ - spec/lib/openstax/api/apipie.rb
193
+ - spec/lib/openstax/api/constraints_spec.rb
194
+ - spec/lib/openstax/api/doorkeeper_extensions_spec.rb
195
+ - spec/lib/openstax/api/roar.rb
196
+ - spec/lib/openstax/api/route_extensions_spec.rb
178
197
  - spec/spec_helper.rb
179
198
  homepage: https://github.com/openstax/openstax_api
180
199
  licenses:
@@ -209,8 +228,8 @@ test_files:
209
228
  - spec/dummy/app/assets/stylesheets/application.css
210
229
  - spec/dummy/app/controllers/application_controller.rb
211
230
  - spec/dummy/app/helpers/application_helper.rb
212
- - spec/dummy/app/models/user.rb
213
- - spec/dummy/app/representers/user_representer.rb
231
+ - spec/dummy/app/models/dummy_user.rb
232
+ - spec/dummy/app/representers/dummy_user_representer.rb
214
233
  - spec/dummy/config/application.rb
215
234
  - spec/dummy/config/boot.rb
216
235
  - spec/dummy/config/database.yml
@@ -222,6 +241,7 @@ test_files:
222
241
  - spec/dummy/config/initializers/doorkeeper.rb
223
242
  - spec/dummy/config/initializers/inflections.rb
224
243
  - spec/dummy/config/initializers/mime_types.rb
244
+ - spec/dummy/config/initializers/openstax_api.rb
225
245
  - spec/dummy/config/initializers/secret_token.rb
226
246
  - spec/dummy/config/initializers/session_store.rb
227
247
  - spec/dummy/config/initializers/wrap_parameters.rb
@@ -230,7 +250,7 @@ test_files:
230
250
  - spec/dummy/config.ru
231
251
  - spec/dummy/db/development.sqlite3
232
252
  - spec/dummy/db/migrate/0_create_doorkeeper_tables.rb
233
- - spec/dummy/db/migrate/1_create_users.rb
253
+ - spec/dummy/db/migrate/1_create_dummy_users.rb
234
254
  - spec/dummy/db/schema.rb
235
255
  - spec/dummy/db/test.sqlite3
236
256
  - spec/dummy/log/development.log
@@ -242,7 +262,9 @@ test_files:
242
262
  - spec/dummy/Rakefile
243
263
  - spec/dummy/README.md
244
264
  - spec/dummy/script/rails
245
- - spec/lib/openstax_api/constraints_spec.rb
246
- - spec/lib/openstax_api/doorkeeper_extensions_spec.rb
247
- - spec/lib/openstax_api/route_extensions_spec.rb
265
+ - spec/lib/openstax/api/apipie.rb
266
+ - spec/lib/openstax/api/constraints_spec.rb
267
+ - spec/lib/openstax/api/doorkeeper_extensions_spec.rb
268
+ - spec/lib/openstax/api/roar.rb
269
+ - spec/lib/openstax/api/route_extensions_spec.rb
248
270
  - spec/spec_helper.rb
@@ -1,85 +0,0 @@
1
- module OpenStax
2
- module Api
3
- module V1
4
- class RepresentableSchemaPrinter
5
-
6
- def self.json(representer, options={})
7
- options[:include] ||= [:readable, :writeable]
8
- options[:indent] ||= ' '
9
-
10
- definitions = {}
11
-
12
- schema = json_schema(representer, definitions, options)
13
- schema[:definitions] = definitions
14
-
15
- json_string = JSON.pretty_generate(schema, {indent: options[:indent]})
16
-
17
- "\nSchema {##{SecureRandom.hex(4)} .schema}\n------\n" +
18
- "<pre class='code'>\n#{json_string}\n</pre>\n"
19
- end
20
-
21
- protected
22
-
23
- def self.json_schema(representer, definitions, options={})
24
- schema = {
25
- # id: schema_id(representer),
26
- # title: schema_title(representer),
27
- type: "object",
28
- properties: {},
29
- required: []
30
- # :$schema => "http://json-schema.org/draft-04/schema#"
31
- }
32
-
33
- representer.representable_attrs.each do |attr|
34
- schema_info = attr.options[:schema_info] || {}
35
-
36
- schema[:required].push(attr.name) if schema_info[:required]
37
-
38
- next unless [options[:include]].flatten.any?{|inc| attr.send(inc.to_s+"?") || schema_info[:required]}
39
-
40
- attr_info = {}
41
-
42
- if attr.options[:collection]
43
- attr_info[:type] = "array"
44
- else
45
- attr_info[:type] = attr.options[:type].to_s.downcase if attr.options[:type]
46
- end
47
-
48
- schema_info.each do |key, value|
49
- next if [:required].include?(key)
50
- value = value.to_s.downcase if key == :type
51
- attr_info[key] = value
52
- end
53
-
54
- decorator = attr.options[:decorator].try(:is_a?, Proc) ? nil : attr.options[:decorator]
55
-
56
- if decorator
57
- relative_schema_id(decorator).tap do |id|
58
- attr_info[:$ref] = "#/definitions/#{id}"
59
- definitions[id] ||= json_schema(decorator, definitions, options)
60
- end
61
- end
62
-
63
- schema[:properties][attr.name.to_sym] = attr_info
64
- end
65
-
66
- schema
67
- end
68
-
69
- def self.schema_title(representer)
70
- representer.name.gsub(/Representer/,'')
71
- end
72
-
73
- def self.schema_id(representer)
74
- "http://#{OpenStax::Api::Engine::MAIN_APP_NAME.to_s}.openstax.org/" +
75
- "#{schema_title(representer).downcase.gsub(/::/,'/')}"
76
- end
77
-
78
- def self.relative_schema_id(representer)
79
- representer.name.gsub(/Representer/,'').downcase.gsub(/::/,'/')
80
- end
81
-
82
- end
83
- end
84
- end
85
- end
@@ -1,2 +0,0 @@
1
- class User < ActiveRecord::Base
2
- end