rack-mongoid_adapter 0.0.1
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 +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +103 -0
- data/Rakefile +1 -0
- data/lib/rack/mongoid_adapter/controllers/base.rb +65 -0
- data/lib/rack/mongoid_adapter/controllers/create_controller.rb +19 -0
- data/lib/rack/mongoid_adapter/controllers/destroy_controller.rb +24 -0
- data/lib/rack/mongoid_adapter/controllers/index_controller.rb +13 -0
- data/lib/rack/mongoid_adapter/controllers/show_controller.rb +25 -0
- data/lib/rack/mongoid_adapter/controllers/single_resource_controller.rb +24 -0
- data/lib/rack/mongoid_adapter/controllers/update_controller.rb +27 -0
- data/lib/rack/mongoid_adapter/version.rb +5 -0
- data/lib/rack/mongoid_adapter.rb +55 -0
- data/lib/rack-mongoid_adapter.rb +1 -0
- data/rack-mongoid_adapter.gemspec +30 -0
- data/spec/config/mongoid.yml +6 -0
- data/spec/rack/mongoid_adapter_spec.rb +148 -0
- data/spec/spec_helper.rb +17 -0
- metadata +221 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d729b10b99a641d5ce49303bbe71325eb59a9701
|
4
|
+
data.tar.gz: fb6323b7d5d935c8c6a50d71cd0564322bb255ae
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7330079aed1a4d7401548a4e75b697a1f48e928e2b7ad449c1f092bd7c4c6438a79337ea0ce40c015d1c83b147a5ab44c611425c0ccedc792fb831dea0cff76b
|
7
|
+
data.tar.gz: a89e4e991c6e74df10d25c504291569996f22724f2377844da87c1b386097401c08a50ccb6b6a3ddbd8dcc1795fc236f36ba50719d5e2e164eeff6b6989e745f
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Ryo Nakamura
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
# Rack::MongoidAdapter
|
2
|
+
Provides RESTful interface for MongoDB as a rack middleware.
|
3
|
+
|
4
|
+
## Usage
|
5
|
+
Here is the simplest example for Heroku with MongoLab plugin.
|
6
|
+
|
7
|
+
### Operation
|
8
|
+
```
|
9
|
+
# settings
|
10
|
+
$ mkdir config
|
11
|
+
$ vi config/mongoid.yml
|
12
|
+
$ vi config.ru
|
13
|
+
$ vi Gemfile
|
14
|
+
$ bundle install
|
15
|
+
$ git init
|
16
|
+
$ git add .
|
17
|
+
$ git commit -m "Initial commit"
|
18
|
+
$ heroku create my-test-app
|
19
|
+
$ heroku addons:add mongolab
|
20
|
+
$ git push heroku master
|
21
|
+
```
|
22
|
+
|
23
|
+
### Code
|
24
|
+
```yaml
|
25
|
+
# config/mongoid.yml
|
26
|
+
development:
|
27
|
+
sessions:
|
28
|
+
default:
|
29
|
+
database: default
|
30
|
+
hosts:
|
31
|
+
- localhost:27017
|
32
|
+
|
33
|
+
production:
|
34
|
+
sessions:
|
35
|
+
default:
|
36
|
+
uri: <%= ENV["MONGOLAB_URI"] %>
|
37
|
+
```
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
# config.ru
|
41
|
+
require "rack/mongoid_adapter"
|
42
|
+
run Rack::MongoidAdapter
|
43
|
+
```
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
# Gemfile
|
47
|
+
source "https://rubygems.org"
|
48
|
+
gem "rack-mongoid_adapter"
|
49
|
+
```
|
50
|
+
|
51
|
+
### POST /{resource_type} - Create a new entry
|
52
|
+
```
|
53
|
+
$ curl http://my-test-app.herokuapp.com/entries -d "attributes[foo]=bar" -i
|
54
|
+
HTTP/1.1 201 Created
|
55
|
+
Date: Thu, 06 Mar 2014 14:55:23 GMT
|
56
|
+
Server: WEBrick/1.3.1 (Ruby/2.0.0/2014-02-24)
|
57
|
+
Content-Length: 46
|
58
|
+
Connection: keep-alive
|
59
|
+
|
60
|
+
{"foo":"bar","_id":"53188c5b3536340002000000"}
|
61
|
+
```
|
62
|
+
|
63
|
+
### GET /{resource_type} - Get all entries
|
64
|
+
```
|
65
|
+
$ curl http://my-test-app.herokuapp.com/entries -i
|
66
|
+
HTTP/1.1 200 OK
|
67
|
+
Date: Thu, 06 Mar 2014 14:56:33 GMT
|
68
|
+
Server: WEBrick/1.3.1 (Ruby/2.0.0/2014-02-24)
|
69
|
+
Content-Length: 48
|
70
|
+
Connection: keep-alive
|
71
|
+
|
72
|
+
[{"foo":"bar","_id":"53188c5b3536340002000000"}]
|
73
|
+
```
|
74
|
+
|
75
|
+
### GET /{resource_type}/{id} - Get the entry
|
76
|
+
```
|
77
|
+
$ curl http://my-test-app.herokuapp.com/entries/53188c5b3536340002000000 -i
|
78
|
+
HTTP/1.1 200 OK
|
79
|
+
Date: Thu, 06 Mar 2014 14:57:35 GMT
|
80
|
+
Server: WEBrick/1.3.1 (Ruby/2.0.0/2014-02-24)
|
81
|
+
Content-Length: 46
|
82
|
+
Connection: keep-alive
|
83
|
+
|
84
|
+
{"foo":"bar","_id":"53188c5b3536340002000000"}
|
85
|
+
```
|
86
|
+
|
87
|
+
### PUT /{resource_type}/{id} - Update the entry
|
88
|
+
```
|
89
|
+
$ curl http://my-test-app.herokuapp.com/entries/53188c5b3536340002000000 -X PUT -d "attributes[foo]=baz" -i
|
90
|
+
HTTP/1.1 204 No Content
|
91
|
+
Date: Thu, 06 Mar 2014 14:59:04 GMT
|
92
|
+
Server: WEBrick/1.3.1 (Ruby/2.0.0/2014-02-24)
|
93
|
+
Connection: keep-alive
|
94
|
+
```
|
95
|
+
|
96
|
+
### DELETE /{resource_type}/{id} - Delete the entry
|
97
|
+
```
|
98
|
+
$ curl http://my-test-app.herokuapp.com/entries/53188c5b3536340002000000 -X DELETE -i
|
99
|
+
HTTP/1.1 204 No Content
|
100
|
+
Date: Thu, 06 Mar 2014 14:59:50 GMT
|
101
|
+
Server: WEBrick/1.3.1 (Ruby/2.0.0/2014-02-24)
|
102
|
+
Connection: keep-alive
|
103
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module Rack
|
2
|
+
class MongoidAdapter
|
3
|
+
module Controllers
|
4
|
+
class Base
|
5
|
+
class << self
|
6
|
+
def call(env)
|
7
|
+
new(env).call
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
attr_reader :env
|
12
|
+
|
13
|
+
def initialize(env)
|
14
|
+
@env = env
|
15
|
+
end
|
16
|
+
|
17
|
+
def call
|
18
|
+
response.to_a
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def response_status
|
24
|
+
200
|
25
|
+
end
|
26
|
+
|
27
|
+
def response_header
|
28
|
+
{}
|
29
|
+
end
|
30
|
+
|
31
|
+
def response_body
|
32
|
+
raise NotImplementedError
|
33
|
+
end
|
34
|
+
|
35
|
+
def response_body_for_not_found
|
36
|
+
{ message: "Not found" }.to_json
|
37
|
+
end
|
38
|
+
|
39
|
+
def request
|
40
|
+
@request ||= Rack::Request.new(env)
|
41
|
+
end
|
42
|
+
|
43
|
+
def response
|
44
|
+
@response ||= Rack::Response.new([response_body], response_status, response_header)
|
45
|
+
end
|
46
|
+
|
47
|
+
def resource_type
|
48
|
+
request.params["resource_type"]
|
49
|
+
end
|
50
|
+
|
51
|
+
def connection
|
52
|
+
::Mongoid.default_session[resource_type]
|
53
|
+
end
|
54
|
+
|
55
|
+
def params
|
56
|
+
request.params
|
57
|
+
end
|
58
|
+
|
59
|
+
def given_attributes
|
60
|
+
params["attributes"]
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Rack
|
2
|
+
class MongoidAdapter
|
3
|
+
module Controllers
|
4
|
+
class CreateController < Base
|
5
|
+
private
|
6
|
+
|
7
|
+
def response_status
|
8
|
+
201
|
9
|
+
end
|
10
|
+
|
11
|
+
def response_body
|
12
|
+
attributes = given_attributes.merge(_id: BSON::ObjectId.new.to_s)
|
13
|
+
connection.insert(attributes)
|
14
|
+
attributes.to_json
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Rack
|
2
|
+
class MongoidAdapter
|
3
|
+
module Controllers
|
4
|
+
class DestroyController < SingleResourceController
|
5
|
+
def response_status
|
6
|
+
if resource
|
7
|
+
204
|
8
|
+
else
|
9
|
+
404
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def response_body
|
14
|
+
if resource
|
15
|
+
connection.find(_id: id).remove
|
16
|
+
""
|
17
|
+
else
|
18
|
+
response_body_for_not_found
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Rack
|
2
|
+
class MongoidAdapter
|
3
|
+
module Controllers
|
4
|
+
class ShowController < SingleResourceController
|
5
|
+
private
|
6
|
+
|
7
|
+
def response_status
|
8
|
+
if resource
|
9
|
+
200
|
10
|
+
else
|
11
|
+
404
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def response_body
|
16
|
+
if resource
|
17
|
+
resource.to_json
|
18
|
+
else
|
19
|
+
response_body_for_not_found
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Rack
|
2
|
+
class MongoidAdapter
|
3
|
+
module Controllers
|
4
|
+
class SingleResourceController < Base
|
5
|
+
include Mem
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
def id
|
10
|
+
request.params["id"]
|
11
|
+
end
|
12
|
+
|
13
|
+
def find_resource
|
14
|
+
connection.find(_id: id).first
|
15
|
+
end
|
16
|
+
|
17
|
+
def resource
|
18
|
+
find_resource
|
19
|
+
end
|
20
|
+
memoize :resource
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Rack
|
2
|
+
class MongoidAdapter
|
3
|
+
module Controllers
|
4
|
+
class UpdateController < SingleResourceController
|
5
|
+
private
|
6
|
+
|
7
|
+
def response_status
|
8
|
+
if resource
|
9
|
+
204
|
10
|
+
else
|
11
|
+
404
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def response_body
|
16
|
+
if resource
|
17
|
+
attributes = resource.merge(given_attributes)
|
18
|
+
connection.find(_id: id).update(attributes)
|
19
|
+
""
|
20
|
+
else
|
21
|
+
response_body_for_not_found
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require "mem"
|
2
|
+
require "mongoid"
|
3
|
+
require "rack"
|
4
|
+
require "rack-multiplexer"
|
5
|
+
require "rack/mongoid_adapter/controllers/base"
|
6
|
+
require "rack/mongoid_adapter/controllers/single_resource_controller"
|
7
|
+
require "rack/mongoid_adapter/controllers/create_controller"
|
8
|
+
require "rack/mongoid_adapter/controllers/destroy_controller"
|
9
|
+
require "rack/mongoid_adapter/controllers/index_controller"
|
10
|
+
require "rack/mongoid_adapter/controllers/show_controller"
|
11
|
+
require "rack/mongoid_adapter/controllers/update_controller"
|
12
|
+
require "rack/mongoid_adapter/version"
|
13
|
+
|
14
|
+
module Rack
|
15
|
+
class MongoidAdapter
|
16
|
+
DEFAULT_MONGOID_CONFIGURATION_PATH = "config/mongoid.yml"
|
17
|
+
|
18
|
+
class << self
|
19
|
+
def call(env)
|
20
|
+
configure_mongoid_unless_configured
|
21
|
+
instance.call(env)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def instance
|
27
|
+
@instance ||= new
|
28
|
+
end
|
29
|
+
|
30
|
+
def configure_mongoid_unless_configured
|
31
|
+
Mongoid.load!(DEFAULT_MONGOID_CONFIGURATION_PATH) unless Mongoid.configured?
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def initialize(app = nil)
|
36
|
+
@app = app
|
37
|
+
end
|
38
|
+
|
39
|
+
def call(env)
|
40
|
+
router.call(env)
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def router
|
46
|
+
@router ||= Rack::Multiplexer.new(@app) do
|
47
|
+
get "/:resource_type", Controllers::IndexController
|
48
|
+
get "/:resource_type/:id", Controllers::ShowController
|
49
|
+
post "/:resource_type", Controllers::CreateController
|
50
|
+
put "/:resource_type/:id", Controllers::UpdateController
|
51
|
+
delete "/:resource_type/:id", Controllers::DestroyController
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require "rack/mongoid_adapter"
|
@@ -0,0 +1,30 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "rack/mongoid_adapter/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "rack-mongoid_adapter"
|
7
|
+
spec.version = Rack::MongoidAdapter::VERSION
|
8
|
+
spec.authors = ["Ryo Nakamura"]
|
9
|
+
spec.email = ["r7kamura@gmail.com"]
|
10
|
+
spec.summary = "A rack application working as an adapter for Mongoid"
|
11
|
+
spec.homepage = "https://github.com/r7kamura/rack-mongoid_adapter"
|
12
|
+
spec.license = "MIT"
|
13
|
+
|
14
|
+
spec.files = `git ls-files -z`.split("\x0")
|
15
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
16
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_dependency "bson_ext", ">= 1.5.1"
|
20
|
+
spec.add_dependency "mem", ">= 0.0.5"
|
21
|
+
spec.add_dependency "mongoid", ">= 4.0.0.alpha2"
|
22
|
+
spec.add_dependency "rack"
|
23
|
+
spec.add_dependency "rack-multiplexer", ">= 0.0.6"
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
25
|
+
spec.add_development_dependency "pry", "0.9.12.6"
|
26
|
+
spec.add_development_dependency "rack-test", "0.6.2"
|
27
|
+
spec.add_development_dependency "rake"
|
28
|
+
spec.add_development_dependency "rspec", "2.14.1"
|
29
|
+
spec.add_development_dependency "rspec-json_matcher", "0.1.3"
|
30
|
+
end
|
@@ -0,0 +1,148 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Rack::MongoidAdapter do
|
4
|
+
include Rack::Test::Methods
|
5
|
+
|
6
|
+
subject do
|
7
|
+
send method, path, params, env
|
8
|
+
response.status
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:app) do
|
12
|
+
described_class.new
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:params) do
|
16
|
+
{}
|
17
|
+
end
|
18
|
+
|
19
|
+
let(:env) do
|
20
|
+
{}
|
21
|
+
end
|
22
|
+
|
23
|
+
let(:response) do
|
24
|
+
last_response
|
25
|
+
end
|
26
|
+
|
27
|
+
let(:connection) do
|
28
|
+
double
|
29
|
+
end
|
30
|
+
|
31
|
+
let(:id) do
|
32
|
+
resource["_id"]
|
33
|
+
end
|
34
|
+
|
35
|
+
let(:resource_type) do
|
36
|
+
"recipes"
|
37
|
+
end
|
38
|
+
|
39
|
+
let(:resource) do
|
40
|
+
post "/#{resource_type}", { attributes: { name: "test" } }, env
|
41
|
+
JSON.parse(last_response.body)
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "GET /:resource_type" do
|
45
|
+
let(:method) do
|
46
|
+
:get
|
47
|
+
end
|
48
|
+
|
49
|
+
let(:path) do
|
50
|
+
"/#{resource_type}"
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
context "with valid condition" do
|
55
|
+
it "returns 200 with an array of resources" do
|
56
|
+
should == 200
|
57
|
+
response.body.should be_json_as(Array)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "GET /:resource_type/:id" do
|
63
|
+
let(:method) do
|
64
|
+
:get
|
65
|
+
end
|
66
|
+
|
67
|
+
let(:path) do
|
68
|
+
"/#{resource_type}/#{id}"
|
69
|
+
end
|
70
|
+
|
71
|
+
context "when resource is not found" do
|
72
|
+
let(:id) do
|
73
|
+
BSON::ObjectId.new.to_s
|
74
|
+
end
|
75
|
+
|
76
|
+
it "returns 404" do
|
77
|
+
should == 404
|
78
|
+
response.body.should be_json
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
context "with valid condition" do
|
83
|
+
it "returns 200 with a resource" do
|
84
|
+
should == 200
|
85
|
+
response.body.should be_json_as(resource)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe "POST /:resource_type" do
|
91
|
+
before do
|
92
|
+
params[:attributes] = { name: "test" }
|
93
|
+
end
|
94
|
+
|
95
|
+
let(:method) do
|
96
|
+
:post
|
97
|
+
end
|
98
|
+
|
99
|
+
let(:path) do
|
100
|
+
"/#{resource_type}"
|
101
|
+
end
|
102
|
+
|
103
|
+
context "with valid condition" do
|
104
|
+
it "returns 201 with a newly-created resource" do
|
105
|
+
should == 201
|
106
|
+
response.body.should be_json_as(params[:attributes].merge(_id: String))
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe "PUT /:resource_type/:id" do
|
112
|
+
before do
|
113
|
+
params[:attributes] = { name: "test" }
|
114
|
+
end
|
115
|
+
|
116
|
+
let(:method) do
|
117
|
+
:put
|
118
|
+
end
|
119
|
+
|
120
|
+
let(:path) do
|
121
|
+
"/#{resource_type}/#{id}"
|
122
|
+
end
|
123
|
+
|
124
|
+
context "with valid condition" do
|
125
|
+
it "returns 204" do
|
126
|
+
should == 204
|
127
|
+
response.body.should be_empty
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
describe "DELETE /:resource_type/:id" do
|
133
|
+
let(:method) do
|
134
|
+
:delete
|
135
|
+
end
|
136
|
+
|
137
|
+
let(:path) do
|
138
|
+
"/#{resource_type}/#{id}"
|
139
|
+
end
|
140
|
+
|
141
|
+
context "with valid condition" do
|
142
|
+
it "returns 204" do
|
143
|
+
should == 204
|
144
|
+
response.body.should be_empty
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
|
2
|
+
require "rack/mongoid_adapter"
|
3
|
+
require "rack/test"
|
4
|
+
require "rspec/json_matcher"
|
5
|
+
|
6
|
+
ENV["RACK_ENV"] ||= "test"
|
7
|
+
Mongoid.load!(File.expand_path("../config/mongoid.yml", __FILE__))
|
8
|
+
|
9
|
+
RSpec.configure do |config|
|
10
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
11
|
+
config.run_all_when_everything_filtered = true
|
12
|
+
config.filter_run :focus
|
13
|
+
config.include RSpec::JsonMatcher
|
14
|
+
end
|
15
|
+
|
16
|
+
# Fix for awesome-print
|
17
|
+
Moped::BSON = BSON
|
metadata
ADDED
@@ -0,0 +1,221 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rack-mongoid_adapter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ryo Nakamura
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-03-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bson_ext
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.5.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.5.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: mem
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.0.5
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.0.5
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: mongoid
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 4.0.0.alpha2
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 4.0.0.alpha2
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rack
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rack-multiplexer
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.0.6
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.0.6
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: bundler
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.5'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.5'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pry
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.9.12.6
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.9.12.6
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rack-test
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.6.2
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 0.6.2
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rake
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rspec
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - '='
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 2.14.1
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - '='
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 2.14.1
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: rspec-json_matcher
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - '='
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 0.1.3
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - '='
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 0.1.3
|
167
|
+
description:
|
168
|
+
email:
|
169
|
+
- r7kamura@gmail.com
|
170
|
+
executables: []
|
171
|
+
extensions: []
|
172
|
+
extra_rdoc_files: []
|
173
|
+
files:
|
174
|
+
- .gitignore
|
175
|
+
- Gemfile
|
176
|
+
- LICENSE.txt
|
177
|
+
- README.md
|
178
|
+
- Rakefile
|
179
|
+
- lib/rack-mongoid_adapter.rb
|
180
|
+
- lib/rack/mongoid_adapter.rb
|
181
|
+
- lib/rack/mongoid_adapter/controllers/base.rb
|
182
|
+
- lib/rack/mongoid_adapter/controllers/create_controller.rb
|
183
|
+
- lib/rack/mongoid_adapter/controllers/destroy_controller.rb
|
184
|
+
- lib/rack/mongoid_adapter/controllers/index_controller.rb
|
185
|
+
- lib/rack/mongoid_adapter/controllers/show_controller.rb
|
186
|
+
- lib/rack/mongoid_adapter/controllers/single_resource_controller.rb
|
187
|
+
- lib/rack/mongoid_adapter/controllers/update_controller.rb
|
188
|
+
- lib/rack/mongoid_adapter/version.rb
|
189
|
+
- rack-mongoid_adapter.gemspec
|
190
|
+
- spec/config/mongoid.yml
|
191
|
+
- spec/rack/mongoid_adapter_spec.rb
|
192
|
+
- spec/spec_helper.rb
|
193
|
+
homepage: https://github.com/r7kamura/rack-mongoid_adapter
|
194
|
+
licenses:
|
195
|
+
- MIT
|
196
|
+
metadata: {}
|
197
|
+
post_install_message:
|
198
|
+
rdoc_options: []
|
199
|
+
require_paths:
|
200
|
+
- lib
|
201
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
202
|
+
requirements:
|
203
|
+
- - '>='
|
204
|
+
- !ruby/object:Gem::Version
|
205
|
+
version: '0'
|
206
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
207
|
+
requirements:
|
208
|
+
- - '>='
|
209
|
+
- !ruby/object:Gem::Version
|
210
|
+
version: '0'
|
211
|
+
requirements: []
|
212
|
+
rubyforge_project:
|
213
|
+
rubygems_version: 2.0.3
|
214
|
+
signing_key:
|
215
|
+
specification_version: 4
|
216
|
+
summary: A rack application working as an adapter for Mongoid
|
217
|
+
test_files:
|
218
|
+
- spec/config/mongoid.yml
|
219
|
+
- spec/rack/mongoid_adapter_spec.rb
|
220
|
+
- spec/spec_helper.rb
|
221
|
+
has_rdoc:
|