openstax_api 0.2.1 → 1.0.0

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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjRkYzdkNzdhYzM2MmJmZjIyNWY4NjY0NzhiYTY5MzIzZTRhYjRiMQ==
4
+ MGIwMjBlNDc2YWY3YzVkZjdiYjg0NWNhYTU3ZDY2NTYwZmZhMTFiMw==
5
5
  data.tar.gz: !binary |-
6
- MjkzYTBiZDVkYTU1ZDc5ZGYwYmFmYTgzYWVhYTQxMmIxMGUzNzM5Zg==
6
+ ZmQ0MGZmMWFkMmNiMjM0MGRlZWQyMDE0YThmODgwYmVlMGNhNDJhNQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NWRlYTljNWI5YmQ5MjZiMDEzNzBlOGZkNDJkNGExNmRiODkwMzcwM2ZkNGEw
10
- NmE3NGFhY2MxYjQ2YmQzNmVjOTMxOGEyOTM3NjMwMWVmNWE5M2RlMWYwZDYw
11
- NmVhOWE0NmNjYjdjODBlNjBjMDNhYjdlN2I2M2I5NjRmNDFkMzc=
9
+ NGUwM2NkODE3Njk2MzlhNmY1OGNjZTY0NjkwMDVhYzg0YmI1MmIwNGRiMWMy
10
+ ZDVhNDY1ODIwY2I0OGMyYzNiNzBlODRkMmU4ZjQ2ODMzMWQ1NGZiYWE3ZTUx
11
+ NWY5YjM2ZjQwM2Q0ZWFmYzQzMzhjMmJlNzQyZDIxMTNiZjI2Yzc=
12
12
  data.tar.gz: !binary |-
13
- YjQ0ZTcyM2E5ZTQ2MDg2YzVkMDk1YmNkNjFlMWNmZGQ3NjNiNGQ2YzI4YmZj
14
- ZTFlMzUwYjJlZmU4ZmNmNjM5Mzk3YTUzMWJiMzc1MTZkMWEyYThlYzk3Yjll
15
- M2U5ZWI2OWIwNTI4MmE2YzkwZjkyNjhhMmJjNGEzOWI4ZWRhZmM=
13
+ MzM5MjJmMjgxNTA2ODIwMjEwNmFjMjhlMTA0OTcwMzZlNjIzNDJiYzYwOWUw
14
+ YzlhNGZkMzQ1ZjY4MzhhMTJmOWU0MGIyYjQ1NmUxNmU0MzJkMjg4OGIwMmYy
15
+ YjY2YWQ5OGJjNzczNWYwOGVjMjg2ZWE2YTYxYTEwZjI2NTI0NmE=
@@ -20,26 +20,38 @@ module OpenStax
20
20
  skip_protect_beta if respond_to? :skip_protect_beta
21
21
 
22
22
  skip_before_filter :authenticate_user!
23
+ doorkeeper_for :all, :unless => :application_user_without_token?
24
+ skip_before_filter :verify_authenticity_token,
25
+ :unless => :application_user_without_token?
23
26
 
24
27
  respond_to :json
25
28
  rescue_from Exception, :with => :rescue_from_exception
26
29
 
30
+ # Keep old current_user method so we can use it
31
+ alias_method :current_application_user,
32
+ OpenStax::Api.configuration.current_user_method
33
+
27
34
  # TODO: doorkeeper users (or rather users who have doorkeeper
28
35
  # applications) need to agree to API terms of use (need to have agreed
29
36
  # to it at one time, can't require them to agree when terms change since
30
37
  # their apps are doing the talking) -- this needs more thought
31
38
 
39
+ # TODO: maybe freak out if current_user is anonymous (require we know
40
+ # who person/app is so we can do things like throttling, API terms
41
+ # agreement, etc)
42
+
43
+ # Always return an ApiUser
32
44
  def current_user
33
- @current_user ||= doorkeeper_token ?
34
- User.find(doorkeeper_token.resource_owner_id) :
35
- super
36
- # TODO: maybe freak out if current user is anonymous (require we know
37
- # who person/app is so we can do things like throttling, API terms
38
- # agreement, etc)
45
+ @current_api_user ||= ApiUser.new(doorkeeper_token,
46
+ lambda { current_application_user })
39
47
  end
40
48
 
41
49
  protected
42
50
 
51
+ def application_user_without_token?
52
+ current_application_user && doorkeeper_token.blank?
53
+ end
54
+
43
55
  def rescue_from_exception(exception)
44
56
  # See https://github.com/rack/rack/blob/master/lib/rack/utils.rb#L453 for error names/symbols
45
57
  error = :internal_server_error
@@ -27,7 +27,7 @@ module OpenStax
27
27
  # procs that can get it for us. This could save us some queries.
28
28
 
29
29
  if doorkeeper_token
30
- user_class = OpenStax::Api.configuration.user_class_name.classify.constantize
30
+ user_class = OpenStax::Api.configuration.user_class_name.constantize
31
31
  @application_proc = lambda { doorkeeper_token.application }
32
32
  @user_proc = lambda {
33
33
  doorkeeper_token.resource_owner_id ?
@@ -3,9 +3,10 @@ require 'openstax/api/constraints'
3
3
  module OpenStax
4
4
  module Api
5
5
  module RouteExtensions
6
- def api(version = :v1, default = false)
7
- constraints = Constraints.new(version: version, default: default)
8
- namespace :api, defaults: {format: 'json'} do
6
+ def api(version, options = {})
7
+ constraints = Constraints.new(version: version,
8
+ default: options.delete(:default))
9
+ namespace :api, defaults: {format: 'json'}.merge(options) do
9
10
  scope(module: version,
10
11
  constraints: constraints) { yield }
11
12
  end
@@ -1,5 +1,5 @@
1
1
  module OpenStax
2
2
  module Api
3
- VERSION = "0.2.1"
3
+ VERSION = "1.0.0"
4
4
  end
5
5
  end
data/lib/openstax_api.rb CHANGED
@@ -13,11 +13,30 @@ module OpenStax
13
13
  @configuration ||= Configuration.new
14
14
  end
15
15
 
16
+ ###########################################################################
17
+ #
18
+ # Configuration machinery.
19
+ #
20
+ # To configure OpenStax Api, put the following code in your applications
21
+ # initialization logic (eg. in the config/initializers in a Rails app)
22
+ #
23
+ # OpenStax::Api.configure do |config|
24
+ # config.<parameter name> = <parameter value>
25
+ # ...
26
+ # end
27
+ #
28
+ # user_class_name is a String containing the name of your User model class.
29
+ #
30
+ # current_user_method is a String containing the name of your controller
31
+ # method that returns the current user.
32
+ #
16
33
  class Configuration
17
34
  attr_accessor :user_class_name
35
+ attr_accessor :current_user_method
18
36
 
19
37
  def initialize
20
38
  @user_class_name = 'User'
39
+ @current_user_method = 'current_user'
21
40
  end
22
41
  end
23
42
 
@@ -1,3 +1,7 @@
1
1
  class ApplicationController < ActionController::Base
2
2
  protect_from_forgery
3
+
4
+ def present_user
5
+ @user ||= DummyUser.create
6
+ end
3
7
  end
@@ -1,3 +1,4 @@
1
1
  OpenStax::Api.configure do |config|
2
2
  config.user_class_name = 'DummyUser'
3
+ config.current_user_method = 'present_user'
3
4
  end
Binary file
@@ -199,3 +199,140 @@ Connecting to database specified by database.yml
199
199
   (1.0ms) CREATE TABLE "oauth_applications" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255) NOT NULL, "uid" varchar(255) NOT NULL, "secret" varchar(255) NOT NULL, "redirect_uri" text NOT NULL, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
200
200
   (0.7ms) CREATE UNIQUE INDEX "index_oauth_applications_on_uid" ON "oauth_applications" ("uid")
201
201
   (0.1ms) SELECT version FROM "schema_migrations"
202
+ Connecting to database specified by database.yml
203
+  (1.6ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
204
+  (0.3ms) select sqlite_version(*)
205
+  (0.9ms) DROP TABLE "dummy_users"
206
+  (0.8ms) CREATE TABLE "dummy_users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "username" varchar(255), "password_hash" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
207
+  (0.8ms) DROP TABLE "oauth_access_grants"
208
+  (0.8ms) CREATE TABLE "oauth_access_grants" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "resource_owner_id" integer NOT NULL, "application_id" integer NOT NULL, "token" varchar(255) NOT NULL, "expires_in" integer NOT NULL, "redirect_uri" text NOT NULL, "created_at" datetime NOT NULL, "revoked_at" datetime, "scopes" varchar(255))
209
+  (0.8ms) CREATE UNIQUE INDEX "index_oauth_access_grants_on_token" ON "oauth_access_grants" ("token")
210
+  (1.0ms) DROP TABLE "oauth_access_tokens"
211
+  (0.9ms) CREATE TABLE "oauth_access_tokens" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "resource_owner_id" integer, "application_id" integer, "token" varchar(255) NOT NULL, "refresh_token" varchar(255), "expires_in" integer, "revoked_at" datetime, "created_at" datetime NOT NULL, "scopes" varchar(255)) 
212
+  (0.8ms) CREATE UNIQUE INDEX "index_oauth_access_tokens_on_refresh_token" ON "oauth_access_tokens" ("refresh_token")
213
+  (0.8ms) CREATE INDEX "index_oauth_access_tokens_on_resource_owner_id" ON "oauth_access_tokens" ("resource_owner_id")
214
+  (0.8ms) CREATE UNIQUE INDEX "index_oauth_access_tokens_on_token" ON "oauth_access_tokens" ("token")
215
+  (1.9ms) DROP TABLE "oauth_applications"
216
+  (0.9ms) CREATE TABLE "oauth_applications" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255) NOT NULL, "uid" varchar(255) NOT NULL, "secret" varchar(255) NOT NULL, "redirect_uri" text NOT NULL, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
217
+  (0.8ms) CREATE UNIQUE INDEX "index_oauth_applications_on_uid" ON "oauth_applications" ("uid")
218
+  (0.1ms) SELECT version FROM "schema_migrations"
219
+ Connecting to database specified by database.yml
220
+  (1.5ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
221
+  (0.2ms) select sqlite_version(*)
222
+  (1.8ms) DROP TABLE "dummy_users"
223
+  (1.0ms) CREATE TABLE "dummy_users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "username" varchar(255), "password_hash" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
224
+  (0.9ms) DROP TABLE "oauth_access_grants"
225
+  (0.9ms) CREATE TABLE "oauth_access_grants" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "resource_owner_id" integer NOT NULL, "application_id" integer NOT NULL, "token" varchar(255) NOT NULL, "expires_in" integer NOT NULL, "redirect_uri" text NOT NULL, "created_at" datetime NOT NULL, "revoked_at" datetime, "scopes" varchar(255))
226
+  (0.8ms) CREATE UNIQUE INDEX "index_oauth_access_grants_on_token" ON "oauth_access_grants" ("token")
227
+  (0.9ms) DROP TABLE "oauth_access_tokens"
228
+  (0.8ms) CREATE TABLE "oauth_access_tokens" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "resource_owner_id" integer, "application_id" integer, "token" varchar(255) NOT NULL, "refresh_token" varchar(255), "expires_in" integer, "revoked_at" datetime, "created_at" datetime NOT NULL, "scopes" varchar(255)) 
229
+  (0.8ms) CREATE UNIQUE INDEX "index_oauth_access_tokens_on_refresh_token" ON "oauth_access_tokens" ("refresh_token")
230
+  (0.8ms) CREATE INDEX "index_oauth_access_tokens_on_resource_owner_id" ON "oauth_access_tokens" ("resource_owner_id")
231
+  (0.8ms) CREATE UNIQUE INDEX "index_oauth_access_tokens_on_token" ON "oauth_access_tokens" ("token")
232
+  (0.8ms) DROP TABLE "oauth_applications"
233
+  (0.8ms) CREATE TABLE "oauth_applications" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255) NOT NULL, "uid" varchar(255) NOT NULL, "secret" varchar(255) NOT NULL, "redirect_uri" text NOT NULL, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
234
+  (0.8ms) CREATE UNIQUE INDEX "index_oauth_applications_on_uid" ON "oauth_applications" ("uid")
235
+  (0.1ms) SELECT version FROM "schema_migrations"
236
+ Connecting to database specified by database.yml
237
+ Connecting to database specified by database.yml
238
+  (1.5ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
239
+  (0.2ms) select sqlite_version(*)
240
+  (1.6ms) DROP TABLE "dummy_users"
241
+  (1.0ms) CREATE TABLE "dummy_users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "username" varchar(255), "password_hash" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
242
+  (0.8ms) DROP TABLE "oauth_access_grants"
243
+  (0.8ms) CREATE TABLE "oauth_access_grants" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "resource_owner_id" integer NOT NULL, "application_id" integer NOT NULL, "token" varchar(255) NOT NULL, "expires_in" integer NOT NULL, "redirect_uri" text NOT NULL, "created_at" datetime NOT NULL, "revoked_at" datetime, "scopes" varchar(255))
244
+  (0.8ms) CREATE UNIQUE INDEX "index_oauth_access_grants_on_token" ON "oauth_access_grants" ("token")
245
+  (0.9ms) DROP TABLE "oauth_access_tokens"
246
+  (0.8ms) CREATE TABLE "oauth_access_tokens" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "resource_owner_id" integer, "application_id" integer, "token" varchar(255) NOT NULL, "refresh_token" varchar(255), "expires_in" integer, "revoked_at" datetime, "created_at" datetime NOT NULL, "scopes" varchar(255)) 
247
+  (0.8ms) CREATE UNIQUE INDEX "index_oauth_access_tokens_on_refresh_token" ON "oauth_access_tokens" ("refresh_token")
248
+  (0.8ms) CREATE INDEX "index_oauth_access_tokens_on_resource_owner_id" ON "oauth_access_tokens" ("resource_owner_id")
249
+  (0.8ms) CREATE UNIQUE INDEX "index_oauth_access_tokens_on_token" ON "oauth_access_tokens" ("token")
250
+  (0.8ms) DROP TABLE "oauth_applications"
251
+  (0.8ms) CREATE TABLE "oauth_applications" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255) NOT NULL, "uid" varchar(255) NOT NULL, "secret" varchar(255) NOT NULL, "redirect_uri" text NOT NULL, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
252
+  (0.8ms) CREATE UNIQUE INDEX "index_oauth_applications_on_uid" ON "oauth_applications" ("uid")
253
+  (0.1ms) SELECT version FROM "schema_migrations"
254
+ Connecting to database specified by database.yml
255
+  (1.5ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
256
+  (0.2ms) select sqlite_version(*)
257
+  (1.8ms) DROP TABLE "dummy_users"
258
+  (1.1ms) CREATE TABLE "dummy_users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "username" varchar(255), "password_hash" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
259
+  (0.9ms) DROP TABLE "oauth_access_grants"
260
+  (0.8ms) CREATE TABLE "oauth_access_grants" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "resource_owner_id" integer NOT NULL, "application_id" integer NOT NULL, "token" varchar(255) NOT NULL, "expires_in" integer NOT NULL, "redirect_uri" text NOT NULL, "created_at" datetime NOT NULL, "revoked_at" datetime, "scopes" varchar(255))
261
+  (0.8ms) CREATE UNIQUE INDEX "index_oauth_access_grants_on_token" ON "oauth_access_grants" ("token")
262
+  (0.9ms) DROP TABLE "oauth_access_tokens"
263
+  (0.8ms) CREATE TABLE "oauth_access_tokens" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "resource_owner_id" integer, "application_id" integer, "token" varchar(255) NOT NULL, "refresh_token" varchar(255), "expires_in" integer, "revoked_at" datetime, "created_at" datetime NOT NULL, "scopes" varchar(255)) 
264
+  (0.8ms) CREATE UNIQUE INDEX "index_oauth_access_tokens_on_refresh_token" ON "oauth_access_tokens" ("refresh_token")
265
+  (0.8ms) CREATE INDEX "index_oauth_access_tokens_on_resource_owner_id" ON "oauth_access_tokens" ("resource_owner_id")
266
+  (0.8ms) CREATE UNIQUE INDEX "index_oauth_access_tokens_on_token" ON "oauth_access_tokens" ("token")
267
+  (0.9ms) DROP TABLE "oauth_applications"
268
+  (0.9ms) CREATE TABLE "oauth_applications" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255) NOT NULL, "uid" varchar(255) NOT NULL, "secret" varchar(255) NOT NULL, "redirect_uri" text NOT NULL, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
269
+  (0.7ms) CREATE UNIQUE INDEX "index_oauth_applications_on_uid" ON "oauth_applications" ("uid")
270
+  (0.1ms) SELECT version FROM "schema_migrations"
271
+ Connecting to database specified by database.yml
272
+  (1.5ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
273
+  (0.2ms) select sqlite_version(*)
274
+  (1.5ms) DROP TABLE "dummy_users"
275
+  (0.8ms) CREATE TABLE "dummy_users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "username" varchar(255), "password_hash" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
276
+  (0.6ms) DROP TABLE "oauth_access_grants"
277
+  (0.7ms) CREATE TABLE "oauth_access_grants" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "resource_owner_id" integer NOT NULL, "application_id" integer NOT NULL, "token" varchar(255) NOT NULL, "expires_in" integer NOT NULL, "redirect_uri" text NOT NULL, "created_at" datetime NOT NULL, "revoked_at" datetime, "scopes" varchar(255))
278
+  (0.7ms) CREATE UNIQUE INDEX "index_oauth_access_grants_on_token" ON "oauth_access_grants" ("token")
279
+  (1.0ms) DROP TABLE "oauth_access_tokens"
280
+  (0.8ms) CREATE TABLE "oauth_access_tokens" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "resource_owner_id" integer, "application_id" integer, "token" varchar(255) NOT NULL, "refresh_token" varchar(255), "expires_in" integer, "revoked_at" datetime, "created_at" datetime NOT NULL, "scopes" varchar(255)) 
281
+  (0.8ms) CREATE UNIQUE INDEX "index_oauth_access_tokens_on_refresh_token" ON "oauth_access_tokens" ("refresh_token")
282
+  (0.8ms) CREATE INDEX "index_oauth_access_tokens_on_resource_owner_id" ON "oauth_access_tokens" ("resource_owner_id")
283
+  (0.8ms) CREATE UNIQUE INDEX "index_oauth_access_tokens_on_token" ON "oauth_access_tokens" ("token")
284
+  (0.8ms) DROP TABLE "oauth_applications"
285
+  (0.9ms) CREATE TABLE "oauth_applications" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255) NOT NULL, "uid" varchar(255) NOT NULL, "secret" varchar(255) NOT NULL, "redirect_uri" text NOT NULL, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
286
+  (0.8ms) CREATE UNIQUE INDEX "index_oauth_applications_on_uid" ON "oauth_applications" ("uid")
287
+  (0.1ms) SELECT version FROM "schema_migrations"
288
+ Connecting to database specified by database.yml
289
+  (1.5ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
290
+  (0.2ms) select sqlite_version(*)
291
+  (1.8ms) DROP TABLE "dummy_users"
292
+  (1.1ms) CREATE TABLE "dummy_users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "username" varchar(255), "password_hash" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
293
+  (0.9ms) DROP TABLE "oauth_access_grants"
294
+  (1.0ms) CREATE TABLE "oauth_access_grants" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "resource_owner_id" integer NOT NULL, "application_id" integer NOT NULL, "token" varchar(255) NOT NULL, "expires_in" integer NOT NULL, "redirect_uri" text NOT NULL, "created_at" datetime NOT NULL, "revoked_at" datetime, "scopes" varchar(255))
295
+  (0.8ms) CREATE UNIQUE INDEX "index_oauth_access_grants_on_token" ON "oauth_access_grants" ("token")
296
+  (1.0ms) DROP TABLE "oauth_access_tokens"
297
+  (0.9ms) CREATE TABLE "oauth_access_tokens" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "resource_owner_id" integer, "application_id" integer, "token" varchar(255) NOT NULL, "refresh_token" varchar(255), "expires_in" integer, "revoked_at" datetime, "created_at" datetime NOT NULL, "scopes" varchar(255)) 
298
+  (0.8ms) CREATE UNIQUE INDEX "index_oauth_access_tokens_on_refresh_token" ON "oauth_access_tokens" ("refresh_token")
299
+  (0.8ms) CREATE INDEX "index_oauth_access_tokens_on_resource_owner_id" ON "oauth_access_tokens" ("resource_owner_id")
300
+  (1.0ms) CREATE UNIQUE INDEX "index_oauth_access_tokens_on_token" ON "oauth_access_tokens" ("token")
301
+  (0.8ms) DROP TABLE "oauth_applications"
302
+  (0.8ms) CREATE TABLE "oauth_applications" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255) NOT NULL, "uid" varchar(255) NOT NULL, "secret" varchar(255) NOT NULL, "redirect_uri" text NOT NULL, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
303
+  (0.8ms) CREATE UNIQUE INDEX "index_oauth_applications_on_uid" ON "oauth_applications" ("uid")
304
+  (0.1ms) SELECT version FROM "schema_migrations"
305
+ Connecting to database specified by database.yml
306
+  (1.5ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
307
+  (0.2ms) select sqlite_version(*)
308
+  (1.8ms) DROP TABLE "dummy_users"
309
+  (1.0ms) CREATE TABLE "dummy_users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "username" varchar(255), "password_hash" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
310
+  (0.9ms) DROP TABLE "oauth_access_grants"
311
+  (0.8ms) CREATE TABLE "oauth_access_grants" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "resource_owner_id" integer NOT NULL, "application_id" integer NOT NULL, "token" varchar(255) NOT NULL, "expires_in" integer NOT NULL, "redirect_uri" text NOT NULL, "created_at" datetime NOT NULL, "revoked_at" datetime, "scopes" varchar(255))
312
+  (0.7ms) CREATE UNIQUE INDEX "index_oauth_access_grants_on_token" ON "oauth_access_grants" ("token")
313
+  (0.9ms) DROP TABLE "oauth_access_tokens"
314
+  (0.8ms) CREATE TABLE "oauth_access_tokens" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "resource_owner_id" integer, "application_id" integer, "token" varchar(255) NOT NULL, "refresh_token" varchar(255), "expires_in" integer, "revoked_at" datetime, "created_at" datetime NOT NULL, "scopes" varchar(255)) 
315
+  (0.8ms) CREATE UNIQUE INDEX "index_oauth_access_tokens_on_refresh_token" ON "oauth_access_tokens" ("refresh_token")
316
+  (0.8ms) CREATE INDEX "index_oauth_access_tokens_on_resource_owner_id" ON "oauth_access_tokens" ("resource_owner_id")
317
+  (0.8ms) CREATE UNIQUE INDEX "index_oauth_access_tokens_on_token" ON "oauth_access_tokens" ("token")
318
+  (0.8ms) DROP TABLE "oauth_applications"
319
+  (0.9ms) CREATE TABLE "oauth_applications" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255) NOT NULL, "uid" varchar(255) NOT NULL, "secret" varchar(255) NOT NULL, "redirect_uri" text NOT NULL, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
320
+  (0.8ms) CREATE UNIQUE INDEX "index_oauth_applications_on_uid" ON "oauth_applications" ("uid")
321
+  (0.1ms) SELECT version FROM "schema_migrations"
322
+ Connecting to database specified by database.yml
323
+  (1.5ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
324
+  (0.2ms) select sqlite_version(*)
325
+  (1.9ms) DROP TABLE "dummy_users"
326
+  (1.1ms) CREATE TABLE "dummy_users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "username" varchar(255), "password_hash" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
327
+  (0.9ms) DROP TABLE "oauth_access_grants"
328
+  (0.9ms) CREATE TABLE "oauth_access_grants" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "resource_owner_id" integer NOT NULL, "application_id" integer NOT NULL, "token" varchar(255) NOT NULL, "expires_in" integer NOT NULL, "redirect_uri" text NOT NULL, "created_at" datetime NOT NULL, "revoked_at" datetime, "scopes" varchar(255))
329
+  (0.8ms) CREATE UNIQUE INDEX "index_oauth_access_grants_on_token" ON "oauth_access_grants" ("token")
330
+  (1.0ms) DROP TABLE "oauth_access_tokens"
331
+  (0.8ms) CREATE TABLE "oauth_access_tokens" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "resource_owner_id" integer, "application_id" integer, "token" varchar(255) NOT NULL, "refresh_token" varchar(255), "expires_in" integer, "revoked_at" datetime, "created_at" datetime NOT NULL, "scopes" varchar(255)) 
332
+  (0.8ms) CREATE UNIQUE INDEX "index_oauth_access_tokens_on_refresh_token" ON "oauth_access_tokens" ("refresh_token")
333
+  (0.8ms) CREATE INDEX "index_oauth_access_tokens_on_resource_owner_id" ON "oauth_access_tokens" ("resource_owner_id")
334
+  (0.8ms) CREATE UNIQUE INDEX "index_oauth_access_tokens_on_token" ON "oauth_access_tokens" ("token")
335
+  (0.8ms) DROP TABLE "oauth_applications"
336
+  (0.8ms) CREATE TABLE "oauth_applications" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255) NOT NULL, "uid" varchar(255) NOT NULL, "secret" varchar(255) NOT NULL, "redirect_uri" text NOT NULL, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
337
+  (0.8ms) CREATE UNIQUE INDEX "index_oauth_applications_on_uid" ON "oauth_applications" ("uid")
338
+  (0.1ms) SELECT version FROM "schema_migrations"
@@ -315,3 +315,81 @@ Connecting to database specified by database.yml
315
315
   (4.9ms) rollback transaction
316
316
   (0.1ms) begin transaction
317
317
   (0.1ms) rollback transaction
318
+ Connecting to database specified by database.yml
319
+ Connecting to database specified by database.yml
320
+ Connecting to database specified by database.yml
321
+ Connecting to database specified by database.yml
322
+ Connecting to database specified by database.yml
323
+ Connecting to database specified by database.yml
324
+ Connecting to database specified by database.yml
325
+  (0.5ms) begin transaction
326
+  (0.1ms) rollback transaction
327
+  (0.0ms) begin transaction
328
+  (0.0ms) rollback transaction
329
+  (0.0ms) begin transaction
330
+  (0.1ms) rollback transaction
331
+  (0.0ms) begin transaction
332
+  (0.1ms) SAVEPOINT active_record_1
333
+ SQL (38.6ms) INSERT INTO "dummy_users" ("created_at", "password_hash", "updated_at", "username") VALUES (?, ?, ?, ?) [["created_at", Tue, 15 Apr 2014 00:10:12 UTC +00:00], ["password_hash", nil], ["updated_at", Tue, 15 Apr 2014 00:10:12 UTC +00:00], ["username", nil]]
334
+  (0.1ms) RELEASE SAVEPOINT active_record_1
335
+  (0.5ms) rollback transaction
336
+  (0.1ms) begin transaction
337
+  (0.1ms) SAVEPOINT active_record_1
338
+ SQL (0.5ms) INSERT INTO "dummy_users" ("created_at", "password_hash", "updated_at", "username") VALUES (?, ?, ?, ?) [["created_at", Tue, 15 Apr 2014 00:10:12 UTC +00:00], ["password_hash", nil], ["updated_at", Tue, 15 Apr 2014 00:10:12 UTC +00:00], ["username", nil]]
339
+  (0.1ms) RELEASE SAVEPOINT active_record_1
340
+ DummyUser Load (0.2ms) SELECT "dummy_users".* FROM "dummy_users" WHERE "dummy_users"."id" = ? LIMIT 1 [["id", 1]]
341
+  (0.3ms) rollback transaction
342
+  (0.1ms) begin transaction
343
+  (0.1ms) rollback transaction
344
+  (0.1ms) begin transaction
345
+  (0.1ms) rollback transaction
346
+  (0.0ms) begin transaction
347
+  (0.0ms) rollback transaction
348
+  (0.0ms) begin transaction
349
+  (0.0ms) rollback transaction
350
+  (0.0ms) begin transaction
351
+  (0.0ms) rollback transaction
352
+  (0.0ms) begin transaction
353
+  (0.0ms) rollback transaction
354
+  (0.0ms) begin transaction
355
+  (0.0ms) rollback transaction
356
+  (0.0ms) begin transaction
357
+  (0.0ms) rollback transaction
358
+  (0.0ms) begin transaction
359
+  (0.0ms) rollback transaction
360
+ Connecting to database specified by database.yml
361
+  (0.5ms) begin transaction
362
+  (0.1ms) rollback transaction
363
+  (0.1ms) begin transaction
364
+  (0.0ms) rollback transaction
365
+  (0.0ms) begin transaction
366
+  (0.1ms) rollback transaction
367
+  (0.1ms) begin transaction
368
+  (0.1ms) rollback transaction
369
+  (0.0ms) begin transaction
370
+  (0.0ms) rollback transaction
371
+  (0.0ms) begin transaction
372
+  (0.0ms) rollback transaction
373
+  (0.0ms) begin transaction
374
+  (0.0ms) rollback transaction
375
+  (0.0ms) begin transaction
376
+  (0.0ms) rollback transaction
377
+  (0.0ms) begin transaction
378
+  (0.0ms) rollback transaction
379
+  (0.0ms) begin transaction
380
+  (0.0ms) rollback transaction
381
+  (0.0ms) begin transaction
382
+  (0.0ms) SAVEPOINT active_record_1
383
+ SQL (33.5ms) INSERT INTO "dummy_users" ("created_at", "password_hash", "updated_at", "username") VALUES (?, ?, ?, ?) [["created_at", Tue, 15 Apr 2014 00:20:53 UTC +00:00], ["password_hash", nil], ["updated_at", Tue, 15 Apr 2014 00:20:53 UTC +00:00], ["username", nil]]
384
+  (0.1ms) RELEASE SAVEPOINT active_record_1
385
+ DummyUser Load (0.1ms) SELECT "dummy_users".* FROM "dummy_users" WHERE "dummy_users"."id" = ? LIMIT 1 [["id", 1]]
386
+  (1.1ms) rollback transaction
387
+  (0.7ms) begin transaction
388
+  (0.1ms) SAVEPOINT active_record_1
389
+ SQL (0.5ms) INSERT INTO "dummy_users" ("created_at", "password_hash", "updated_at", "username") VALUES (?, ?, ?, ?) [["created_at", Tue, 15 Apr 2014 00:20:53 UTC +00:00], ["password_hash", nil], ["updated_at", Tue, 15 Apr 2014 00:20:53 UTC +00:00], ["username", nil]]
390
+  (0.1ms) RELEASE SAVEPOINT active_record_1
391
+  (0.3ms) rollback transaction
392
+  (0.1ms) begin transaction
393
+  (0.1ms) rollback transaction
394
+  (0.1ms) begin transaction
395
+  (0.0ms) rollback transaction
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.2.1
4
+ version: 1.0.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-04-10 00:00:00.000000000 Z
12
+ date: 2014-04-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -136,7 +136,6 @@ files:
136
136
  - README.md
137
137
  - Rakefile
138
138
  - app/controllers/openstax/api/v1/api_controller.rb
139
- - app/controllers/openstax/api/v1/oauth_based_api_controller.rb
140
139
  - app/models/openstax/api/api_user.rb
141
140
  - lib/openstax/api/apipie.rb
142
141
  - lib/openstax/api/constraints.rb
@@ -147,10 +146,7 @@ files:
147
146
  - lib/openstax/api/route_extensions.rb
148
147
  - lib/openstax/api/version.rb
149
148
  - lib/openstax_api.rb
150
- - spec/app/controllers/openstax/api/v1/api_controller_spec.rb
151
- - spec/app/controllers/openstax/api/v1/oauth_based_api_controller_spec.rb
152
- - spec/app/models/openstax/api/api_user_spec.rb
153
- - spec/app/representers/openstax/api/v1/representable_schema_printer_spec.rb
149
+ - spec/controllers/openstax/api/v1/api_controller_spec.rb
154
150
  - spec/dummy/README.md
155
151
  - spec/dummy/Rakefile
156
152
  - spec/dummy/app/assets/javascripts/application.js
@@ -194,6 +190,8 @@ files:
194
190
  - spec/lib/openstax/api/doorkeeper_extensions_spec.rb
195
191
  - spec/lib/openstax/api/roar.rb
196
192
  - spec/lib/openstax/api/route_extensions_spec.rb
193
+ - spec/models/openstax/api/api_user_spec.rb
194
+ - spec/representers/openstax/api/v1/representable_schema_printer_spec.rb
197
195
  - spec/spec_helper.rb
198
196
  homepage: https://github.com/openstax/openstax_api
199
197
  licenses:
@@ -220,10 +218,7 @@ signing_key:
220
218
  specification_version: 4
221
219
  summary: API utilities for OpenStax products and tools.
222
220
  test_files:
223
- - spec/app/controllers/openstax/api/v1/api_controller_spec.rb
224
- - spec/app/controllers/openstax/api/v1/oauth_based_api_controller_spec.rb
225
- - spec/app/models/openstax/api/api_user_spec.rb
226
- - spec/app/representers/openstax/api/v1/representable_schema_printer_spec.rb
221
+ - spec/controllers/openstax/api/v1/api_controller_spec.rb
227
222
  - spec/dummy/app/assets/javascripts/application.js
228
223
  - spec/dummy/app/assets/stylesheets/application.css
229
224
  - spec/dummy/app/controllers/application_controller.rb
@@ -267,4 +262,6 @@ test_files:
267
262
  - spec/lib/openstax/api/doorkeeper_extensions_spec.rb
268
263
  - spec/lib/openstax/api/roar.rb
269
264
  - spec/lib/openstax/api/route_extensions_spec.rb
265
+ - spec/models/openstax/api/api_user_spec.rb
266
+ - spec/representers/openstax/api/v1/representable_schema_printer_spec.rb
270
267
  - spec/spec_helper.rb
@@ -1,15 +0,0 @@
1
- module OpenStax
2
- module Api
3
- module V1
4
-
5
- class OauthBasedApiController < ApiController
6
-
7
- def current_user
8
- @current_api_user ||= ApiUser.new(doorkeeper_token, lambda { super })
9
- end
10
-
11
- end
12
-
13
- end
14
- end
15
- end
@@ -1,11 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module OpenStax
4
- module Api
5
- module V1
6
- describe OauthBasedApiController do
7
- # Nothing to test yet
8
- end
9
- end
10
- end
11
- end