muve 0.1.0 → 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 +4 -4
- data/.gitignore +1 -0
- data/Gemfile +0 -2
- data/README.md +33 -0
- data/lib/muve/store.rb +0 -2
- data/lib/muve/version.rb +1 -1
- metadata +3 -5
- data/lib/muve/store/mongo.rb +0 -50
- data/spec/adaptor/mongo_spec.rb +0 -52
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4f36cfe27c1f7f7ed994364976bc49c15c7e677
|
4
|
+
data.tar.gz: 3115d65888228e346e5d079367aa18867ee19b78
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb4d0e4eddf27e19af900241cfc184d003b2ec84ed833d12bdfa7fe91bfd7f3623ab4f196d12b883b69e868584ec390eced54711f2fbddb64d4726702d0b3b8f
|
7
|
+
data.tar.gz: 6ad01f4ad7c17805edb36165bfe8b223bb430ef6c1baf2d0421e6269acfa9e974193a3db5256b812244acde4f0f221b99da6bc4ef1d6eb36d155a4bbf7790e63
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/README.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# Muve
|
2
|
+
|
3
|
+
[](http://badge.fury.io/rb/muve)
|
4
|
+
|
5
|
+
The Muve gem is designed to allow for the quick implementation of the
|
6
|
+
Muvement API logic into a project. At the very moment this is very
|
7
|
+
experimental and subject to massive changes which is why I wouldn't recommend
|
8
|
+
others to use this gem as yet :wink:.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
gem 'muve'
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install muve
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Contributing
|
28
|
+
|
29
|
+
1. Fork it ( https://github.com/[my-github-username]/muve/fork )
|
30
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
31
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
32
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
33
|
+
5. Create a new Pull Request
|
data/lib/muve/store.rb
CHANGED
data/lib/muve/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: muve
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Asabina
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Basic helpers to be used with Muvement
|
14
14
|
email:
|
@@ -20,6 +20,7 @@ files:
|
|
20
20
|
- ".gitignore"
|
21
21
|
- Gemfile
|
22
22
|
- LICENSE.txt
|
23
|
+
- README.md
|
23
24
|
- Rakefile
|
24
25
|
- lib/muve.rb
|
25
26
|
- lib/muve/errors.rb
|
@@ -28,11 +29,9 @@ files:
|
|
28
29
|
- lib/muve/model.rb
|
29
30
|
- lib/muve/movement.rb
|
30
31
|
- lib/muve/store.rb
|
31
|
-
- lib/muve/store/mongo.rb
|
32
32
|
- lib/muve/traveller.rb
|
33
33
|
- lib/muve/version.rb
|
34
34
|
- muve.gemspec
|
35
|
-
- spec/adaptor/mongo_spec.rb
|
36
35
|
- spec/factories.rb
|
37
36
|
- spec/helper_spec.rb
|
38
37
|
- spec/location_spec.rb
|
@@ -67,7 +66,6 @@ signing_key:
|
|
67
66
|
specification_version: 4
|
68
67
|
summary: muve gem
|
69
68
|
test_files:
|
70
|
-
- spec/adaptor/mongo_spec.rb
|
71
69
|
- spec/factories.rb
|
72
70
|
- spec/helper_spec.rb
|
73
71
|
- spec/location_spec.rb
|
data/lib/muve/store/mongo.rb
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
module Muve
|
2
|
-
module Store
|
3
|
-
class Mongo
|
4
|
-
require 'mongo'
|
5
|
-
|
6
|
-
extend Muve::Store
|
7
|
-
|
8
|
-
def self.create(resource, details)
|
9
|
-
raise MuveInvalidAttributes, "invalid update data" unless details.kind_of? Hash
|
10
|
-
resource.database[resource.container].insert(details)
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.fetch(resource, id, details={})
|
14
|
-
# TODO: discover a solution that works for situations where database
|
15
|
-
# driver returns string keys as well as symbol keys
|
16
|
-
details = {} unless details.kind_of? Hash
|
17
|
-
result = resource.database[resource.container].find_one(details.merge(_id: id))
|
18
|
-
result = Helper.symbolize_keys(result)
|
19
|
-
result[:id] = result.delete(:_id)
|
20
|
-
result
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.find(resource, details)
|
24
|
-
details = {} unless details.kind_of? Hash
|
25
|
-
Enumerator.new do |result|
|
26
|
-
resource.database[resource.container].find(details).each do |item|
|
27
|
-
item = Helper.symbolize_keys(item)
|
28
|
-
item[:id] = item.delete(:_id)
|
29
|
-
result << item
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def self.update(resource, id, details)
|
35
|
-
raise MuveInvalidAttributes, "invalid update data" unless details.kind_of? Hash
|
36
|
-
# TODO: raise error if details is not valid
|
37
|
-
resource.database[resource.container].find_and_modify(
|
38
|
-
query: { _id: id },
|
39
|
-
update: details
|
40
|
-
)
|
41
|
-
end
|
42
|
-
|
43
|
-
def self.delete(resource, id, details=nil)
|
44
|
-
details = {} unless details.kind_of? Hash
|
45
|
-
details = details.merge(_id: id) if id
|
46
|
-
resource.database[resource.container].remove(details)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
data/spec/adaptor/mongo_spec.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'Mongo Adaptor' do
|
4
|
-
let(:connection) { Mongo::MongoClient.new }
|
5
|
-
let(:database) { connection.db('muve_test') }
|
6
|
-
before do
|
7
|
-
class Place
|
8
|
-
include Muve::Model
|
9
|
-
|
10
|
-
def self.container
|
11
|
-
'places'
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
Muve.init(connection, database)
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'writes model data to the store' do
|
19
|
-
expect{
|
20
|
-
Muve::Store::Mongo.create(Place, {
|
21
|
-
city: Faker::Address.city,
|
22
|
-
street: Faker::Address.street_name,
|
23
|
-
building: Faker::Address.building_number
|
24
|
-
})
|
25
|
-
}.to change{database['places'].count}.by(1)
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'writes modifications to the store' do
|
29
|
-
id = database['places'].insert(name: Faker::Venue.name)
|
30
|
-
new_name = Faker::Venue.name
|
31
|
-
|
32
|
-
expect{
|
33
|
-
Muve::Store::Mongo.update(Place, id, { name: new_name })
|
34
|
-
}.to change{database['places'].find_one(_id: id)['name']}.to(new_name)
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'finds a resource from store' do
|
38
|
-
id = database['places'].insert(name: Faker::Venue.name)
|
39
|
-
expect(Muve::Store::Mongo.get(Place, id)[:id]).to eq(id)
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'finds multiple resources from store' do
|
43
|
-
expect(Muve::Store::Mongo.find(Place, {})).to be_a(Enumerable)
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'extracts a resource from every result in a multiple resource set' do
|
47
|
-
Muve::Store::Mongo.find(Place, {}).take(3).each do |result|
|
48
|
-
attributes = result.keys.map{ |i| i.to_s }
|
49
|
-
expect(attributes).to include('id', 'city', 'street', 'building')
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|