fetcher-mongoid-models 0.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.
- data/Gemfile +3 -0
- data/Gemfile.lock +50 -0
- data/README.rest +33 -0
- data/Rakefile +11 -0
- data/app/models/column.rb +10 -0
- data/app/models/filter.rb +14 -0
- data/app/models/person_user.rb +20 -0
- data/app/models/source.rb +14 -0
- data/app/models/user.rb +12 -0
- data/config/main.yml +6 -0
- data/fetcher-mongoid-models.gemspec +22 -0
- data/lib/fetcher/mongoid/models/db.rb +16 -0
- data/lib/fetcher/mongoid/models/version.rb +7 -0
- data/lib/fetcher-mongoid-models.rb +5 -0
- data/lib/models.rb +8 -0
- data/spec/fetcher/mongoid/models/db_spec.rb +19 -0
- data/spec/models/column_spec.rb +35 -0
- data/spec/models/filter_spec.rb +41 -0
- data/spec/models/person_user_spec.rb +26 -0
- data/spec/models/source_spec.rb +40 -0
- data/spec/models/user_spec.rb +23 -0
- data/spec/spec_helper.rb +3 -0
- metadata +124 -0
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
fetcher-mongoid-models (0.0.0)
|
5
|
+
mongoid
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activemodel (3.2.9)
|
11
|
+
activesupport (= 3.2.9)
|
12
|
+
builder (~> 3.0.0)
|
13
|
+
activesupport (3.2.9)
|
14
|
+
i18n (~> 0.6)
|
15
|
+
multi_json (~> 1.0)
|
16
|
+
builder (3.0.4)
|
17
|
+
coderay (1.0.8)
|
18
|
+
diff-lcs (1.1.3)
|
19
|
+
i18n (0.6.1)
|
20
|
+
method_source (0.8.1)
|
21
|
+
mongoid (3.0.14)
|
22
|
+
activemodel (~> 3.1)
|
23
|
+
moped (~> 1.1)
|
24
|
+
origin (~> 1.0)
|
25
|
+
tzinfo (~> 0.3.22)
|
26
|
+
moped (1.3.1)
|
27
|
+
multi_json (1.5.0)
|
28
|
+
origin (1.0.11)
|
29
|
+
pry (0.9.10)
|
30
|
+
coderay (~> 1.0.5)
|
31
|
+
method_source (~> 0.8)
|
32
|
+
slop (~> 3.3.1)
|
33
|
+
rspec (2.12.0)
|
34
|
+
rspec-core (~> 2.12.0)
|
35
|
+
rspec-expectations (~> 2.12.0)
|
36
|
+
rspec-mocks (~> 2.12.0)
|
37
|
+
rspec-core (2.12.2)
|
38
|
+
rspec-expectations (2.12.0)
|
39
|
+
diff-lcs (~> 1.1.3)
|
40
|
+
rspec-mocks (2.12.0)
|
41
|
+
slop (3.3.3)
|
42
|
+
tzinfo (0.3.35)
|
43
|
+
|
44
|
+
PLATFORMS
|
45
|
+
ruby
|
46
|
+
|
47
|
+
DEPENDENCIES
|
48
|
+
fetcher-mongoid-models!
|
49
|
+
pry
|
50
|
+
rspec
|
data/README.rest
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
Usage examples
|
2
|
+
|
3
|
+
In folder config is a examples of a configuration file, for more information go to
|
4
|
+
|
5
|
+
http://mongoid.org/en/mongoid/docs/installation.html
|
6
|
+
|
7
|
+
Example 1:
|
8
|
+
|
9
|
+
Fetcher::Mongoid::Models::DB.new path_to_config_file
|
10
|
+
|
11
|
+
u = User.new
|
12
|
+
u.login = "hola soy tomy"
|
13
|
+
u.save
|
14
|
+
|
15
|
+
User.find(u._id)
|
16
|
+
|
17
|
+
Example 2:
|
18
|
+
|
19
|
+
I have a Valid Column and a Filter
|
20
|
+
The filter is valid only if it references a valid column, to make this you need to make:
|
21
|
+
|
22
|
+
Fetcher::Mongoid::Models::DB.new path_to_config_file
|
23
|
+
|
24
|
+
column = Column.new
|
25
|
+
column.save
|
26
|
+
f = Filter.new :Column => column
|
27
|
+
Filter::Column_id = column._id
|
28
|
+
f.save #<- this will return true
|
29
|
+
|
30
|
+
We need to set the Filter::Column_id to let the Filters know to wich column it will belongs_to
|
31
|
+
|
32
|
+
|
33
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "mongoid"
|
2
|
+
|
3
|
+
class Filter
|
4
|
+
include Mongoid::Document
|
5
|
+
store_in collection: "Filter"
|
6
|
+
field :type
|
7
|
+
field :property
|
8
|
+
field :operator
|
9
|
+
field :value, type: Array
|
10
|
+
belongs_to :Column
|
11
|
+
|
12
|
+
validates :Column_id, :presence => { :message => :required }
|
13
|
+
validates :Column, :presence => { :message => :required, :if => :Column_id }
|
14
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "mongoid"
|
2
|
+
|
3
|
+
class PersonUser
|
4
|
+
include Mongoid::Document
|
5
|
+
store_in collection: "PersonUser"
|
6
|
+
field :provider, type: Array
|
7
|
+
field :additionalType, type: Array
|
8
|
+
field :itemId, type: Array
|
9
|
+
field :name, type: Array
|
10
|
+
field :userDateRegistered, type: Array
|
11
|
+
field :description, type: Array
|
12
|
+
field :url, type: Array
|
13
|
+
field :accessToken, type: String
|
14
|
+
field :accessSecret, type: String
|
15
|
+
belongs_to :User
|
16
|
+
has_many :Filter
|
17
|
+
has_many :Source
|
18
|
+
|
19
|
+
validates :accessToken, allow_nil: false, presence: true
|
20
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "mongoid"
|
2
|
+
|
3
|
+
class Source
|
4
|
+
include Mongoid::Document
|
5
|
+
store_in collection: "Source"
|
6
|
+
field :streamArgument, type: Array
|
7
|
+
field :provider
|
8
|
+
field :endpoint
|
9
|
+
field :viewer, type: Integer
|
10
|
+
belongs_to :Column
|
11
|
+
|
12
|
+
validates :Column_id, :presence => { :message => :required }
|
13
|
+
validates :Column, :presence => { :message => :required, :if => :Column_id }
|
14
|
+
end
|
data/app/models/user.rb
ADDED
data/config/main.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/fetcher/mongoid/models/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Olivier Ducroux","Tomas Mehdi"]
|
6
|
+
gem.email = ["ducrouxolivier@gmail.com", "tomymehdi@gmail.com"]
|
7
|
+
gem.description = %q{Fetcher Mongoid Models}
|
8
|
+
gem.summary = %q{Fetcher Mongodb Models}
|
9
|
+
gem.homepage = "http://github.com/Fetcher/fetcher-mongoid-models"
|
10
|
+
|
11
|
+
gem.add_dependency 'mongoid'
|
12
|
+
|
13
|
+
gem.add_development_dependency 'rspec'
|
14
|
+
gem.add_development_dependency 'pry'
|
15
|
+
|
16
|
+
gem.files = `git ls-files`.split($\)
|
17
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
|
+
gem.name = "fetcher-mongoid-models"
|
20
|
+
gem.require_paths = ["lib"]
|
21
|
+
gem.version = Fetcher::Mongoid::Models::VERSION
|
22
|
+
end
|
data/lib/models.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Fetcher::Mongoid::Models::Db' do
|
4
|
+
describe '.new' do
|
5
|
+
context 'call Fetcher::Mongoid::Models::Db.new' do
|
6
|
+
it 'should call ::Mongoid.load!' do
|
7
|
+
valid_path = "./config/main.yml"
|
8
|
+
::Mongoid.should_receive(:load!).with(valid_path,:development)
|
9
|
+
Fetcher::Mongoid::Models::Db.new valid_path
|
10
|
+
end
|
11
|
+
it 'should raise an exception when a invalid configuration path is passed' do
|
12
|
+
invalid_path = "caca_path"
|
13
|
+
expect{
|
14
|
+
Fetcher::Mongoid::Models::Db.new valid_path
|
15
|
+
}.to raise_error NameError
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
|
4
|
+
describe 'Fetcher::Mongoid::Models::Db' do
|
5
|
+
context 'When I create a column' do
|
6
|
+
|
7
|
+
before do
|
8
|
+
Fetcher::Mongoid::Models::Db.new "./config/main.yml"
|
9
|
+
@column = Column.new
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should return true when insert it empty' do
|
13
|
+
@column.save.should == true
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should return true when insert with a Filter that is in the Db and i can get the filter back' do
|
17
|
+
@column.save
|
18
|
+
f = Filter.new :Column => @column
|
19
|
+
Filter::Column_id = @column._id
|
20
|
+
f.save
|
21
|
+
|
22
|
+
@column.Filter.push f
|
23
|
+
@column.save.should == true
|
24
|
+
|
25
|
+
aux_filter = Column.find(@column._id).Filter
|
26
|
+
aux_filter.first.should == f
|
27
|
+
f.remove
|
28
|
+
end
|
29
|
+
|
30
|
+
after do
|
31
|
+
@column.remove
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
|
4
|
+
describe 'Fetcher::Mongoid::Models::Db' do
|
5
|
+
context 'When I create a filter' do
|
6
|
+
|
7
|
+
before do
|
8
|
+
Fetcher::Mongoid::Models::Db.new "./config/main.yml"
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:filter) {Filter.new}
|
12
|
+
let(:column) {Column.new}
|
13
|
+
|
14
|
+
it 'should return false when inserted without a Column' do
|
15
|
+
expect {
|
16
|
+
filter.save
|
17
|
+
}.to raise_error NameError, "uninitialized constant Filter::Column_id"
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should return false when inserted with a Column that is not in the db' do
|
21
|
+
filter.Column = column
|
22
|
+
expect {
|
23
|
+
filter.save
|
24
|
+
}.to raise_error NameError, "uninitialized constant Filter::Column_id"
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should return true when inserted with a valid Column' do
|
28
|
+
column.save
|
29
|
+
f = Filter.new :Column => column
|
30
|
+
Filter::Column_id = column._id
|
31
|
+
f.save.should == true
|
32
|
+
column.remove
|
33
|
+
f.remove
|
34
|
+
end
|
35
|
+
|
36
|
+
after do
|
37
|
+
filter.remove
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "Fetcher::Mongoid::Models::Db" do
|
4
|
+
context "when i create a PersonUser" do
|
5
|
+
|
6
|
+
before do
|
7
|
+
Fetcher::Mongoid::Models::Db.new "./config/main.yml"
|
8
|
+
end
|
9
|
+
|
10
|
+
let(:personuser) {PersonUser.new}
|
11
|
+
|
12
|
+
it "should return false when inserted without an access token" do
|
13
|
+
personuser.save.should == false
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should return true when inserted with an access token" do
|
17
|
+
personuser.accessToken = "askjhdla654654kjsdhlaksdjhlkasjdh65464"
|
18
|
+
personuser.save.should == true
|
19
|
+
end
|
20
|
+
|
21
|
+
after do
|
22
|
+
personuser.remove
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
|
4
|
+
describe 'Fetcher::Mongoid::Models::Db' do
|
5
|
+
context 'When I create a source' do
|
6
|
+
before do
|
7
|
+
Fetcher::Mongoid::Models::Db.new "./config/main.yml"
|
8
|
+
@source = Source.new
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should return false when insert without a Column' do
|
12
|
+
expect {
|
13
|
+
@source.save
|
14
|
+
}.to raise_error NameError, "uninitialized constant Source::Column_id"
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should return false when insert with a Column that is not in the db' do
|
18
|
+
column = Column.new
|
19
|
+
@source.Column = column
|
20
|
+
expect {
|
21
|
+
@source.save
|
22
|
+
}.to raise_error NameError, "uninitialized constant Source::Column_id"
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should return true when insert with a valid Column' do
|
26
|
+
column = Column.new
|
27
|
+
column.save
|
28
|
+
s = Source.new :Column => column
|
29
|
+
Source::Column_id = column._id
|
30
|
+
s.save.should == true
|
31
|
+
column.remove
|
32
|
+
s.remove
|
33
|
+
end
|
34
|
+
|
35
|
+
after do
|
36
|
+
@source.remove
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "Fetcher::Mongoid::Models::Db" do
|
4
|
+
context "when i create a user" do
|
5
|
+
|
6
|
+
before do
|
7
|
+
Fetcher::Mongoid::Models::Db.new "./config/main.yml"
|
8
|
+
end
|
9
|
+
|
10
|
+
let(:user) {User.new}
|
11
|
+
|
12
|
+
it "should return true when inserted in database" do
|
13
|
+
user.save.should be_true
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
after do
|
19
|
+
user.remove
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fetcher-mongoid-models
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Olivier Ducroux
|
9
|
+
- Tomas Mehdi
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2012-12-17 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: mongoid
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '0'
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: rspec
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
type: :development
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: pry
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
description: Fetcher Mongoid Models
|
64
|
+
email:
|
65
|
+
- ducrouxolivier@gmail.com
|
66
|
+
- tomymehdi@gmail.com
|
67
|
+
executables: []
|
68
|
+
extensions: []
|
69
|
+
extra_rdoc_files: []
|
70
|
+
files:
|
71
|
+
- Gemfile
|
72
|
+
- Gemfile.lock
|
73
|
+
- README.rest
|
74
|
+
- Rakefile
|
75
|
+
- app/models/column.rb
|
76
|
+
- app/models/filter.rb
|
77
|
+
- app/models/person_user.rb
|
78
|
+
- app/models/source.rb
|
79
|
+
- app/models/user.rb
|
80
|
+
- config/main.yml
|
81
|
+
- fetcher-mongoid-models.gemspec
|
82
|
+
- lib/fetcher-mongoid-models.rb
|
83
|
+
- lib/fetcher/mongoid/models/db.rb
|
84
|
+
- lib/fetcher/mongoid/models/version.rb
|
85
|
+
- lib/models.rb
|
86
|
+
- spec/fetcher/mongoid/models/db_spec.rb
|
87
|
+
- spec/models/column_spec.rb
|
88
|
+
- spec/models/filter_spec.rb
|
89
|
+
- spec/models/person_user_spec.rb
|
90
|
+
- spec/models/source_spec.rb
|
91
|
+
- spec/models/user_spec.rb
|
92
|
+
- spec/spec_helper.rb
|
93
|
+
homepage: http://github.com/Fetcher/fetcher-mongoid-models
|
94
|
+
licenses: []
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options: []
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
none: false
|
101
|
+
requirements:
|
102
|
+
- - ! '>='
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - ! '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
requirements: []
|
112
|
+
rubyforge_project:
|
113
|
+
rubygems_version: 1.8.24
|
114
|
+
signing_key:
|
115
|
+
specification_version: 3
|
116
|
+
summary: Fetcher Mongodb Models
|
117
|
+
test_files:
|
118
|
+
- spec/fetcher/mongoid/models/db_spec.rb
|
119
|
+
- spec/models/column_spec.rb
|
120
|
+
- spec/models/filter_spec.rb
|
121
|
+
- spec/models/person_user_spec.rb
|
122
|
+
- spec/models/source_spec.rb
|
123
|
+
- spec/models/user_spec.rb
|
124
|
+
- spec/spec_helper.rb
|