recommendable 2.0.3 → 2.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/recommendable.rb +1 -0
- data/lib/recommendable/configuration.rb +1 -1
- data/lib/recommendable/helpers/queriers.rb +4 -0
- data/lib/recommendable/orm/sequel.rb +7 -0
- data/lib/recommendable/ratable.rb +12 -3
- data/lib/recommendable/rater.rb +13 -2
- data/lib/recommendable/rater/bookmarker.rb +1 -1
- data/lib/recommendable/rater/disliker.rb +1 -1
- data/lib/recommendable/rater/hider.rb +1 -1
- data/lib/recommendable/rater/liker.rb +1 -1
- data/lib/recommendable/version.rb +1 -1
- metadata +28 -48
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 07fcec48e728616ac9731c2eaef4e763daa25585
|
4
|
+
data.tar.gz: c4b6aa9598500b23b50c2b94bd611d5092ea453a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e27c4646cd1f26fc25f1380189c618034e2fe440ae2c85f7e7c2629c7d1be0b892465f4fd32f122538c29989e9754faee84a5f7a8921ddaee9cc660b752ad530
|
7
|
+
data.tar.gz: 058cc8e715b3e8a0dd03b926d505b57ca079e2e67d26985dc4ac58e8d1c66a9702a46ec9ac850779ea242b152a858502a32ed74eb2284dfc287e841f4caef9a1
|
data/lib/recommendable.rb
CHANGED
@@ -45,3 +45,4 @@ require 'recommendable/orm/active_record' if defined?(ActiveRecord::Base)
|
|
45
45
|
require 'recommendable/orm/data_mapper' if defined?(DataMapper::Resource)
|
46
46
|
require 'recommendable/orm/mongoid' if defined?(Mongoid::Document)
|
47
47
|
require 'recommendable/orm/mongo_mapper' if defined?(MongoMapper::Document)
|
48
|
+
require 'recommendable/orm/sequel' if defined?(Sequel::Model)
|
@@ -2,7 +2,7 @@ require 'redis'
|
|
2
2
|
|
3
3
|
module Recommendable
|
4
4
|
class Configuration
|
5
|
-
# The ORM you are using. Currently supported: `:activerecord`, `:mongoid`, and `:datamapper`
|
5
|
+
# The ORM you are using. Currently supported: `:activerecord`, `:mongoid`, ':sequel', ':mongo-mapper' and `:datamapper`
|
6
6
|
attr_accessor :orm
|
7
7
|
|
8
8
|
# Recommendable's connection to Redis
|
@@ -14,13 +14,22 @@ module Recommendable
|
|
14
14
|
class_eval do
|
15
15
|
include Likable
|
16
16
|
include Dislikable
|
17
|
-
|
18
|
-
|
17
|
+
|
18
|
+
case
|
19
|
+
when defined?(Sequel::Model) && ancestors.include?(Sequel::Model)
|
20
|
+
def before_destroy() super and remove_from_recommendable! end
|
21
|
+
when defined?(ActiveRecord::Base) && ancestors.include?(ActiveRecord::Base),
|
22
|
+
defined?(Mongoid::Document) && ancestors.include?(Mongoid::Document),
|
23
|
+
defined?(MongoMapper::Document) && ancestors.include?(MongoMapper::Document),
|
24
|
+
defined?(MongoMapper::EmbeddedDocument) && ancestors.include?(MongoMapper::EmbeddedDocument)
|
19
25
|
before_destroy :remove_from_recommendable!
|
20
|
-
|
26
|
+
when defined?(DataMapper::Resource) && ancestors.include?(DataMapper::Resource)
|
21
27
|
before :destroy, :remove_from_recommendable!
|
28
|
+
else
|
29
|
+
warn "Model #{self} is not using a supported ORM. You must handle removal from Redis manually when destroying instances."
|
22
30
|
end
|
23
31
|
|
32
|
+
|
24
33
|
# Whether or not items belonging to this class can be recommended.
|
25
34
|
#
|
26
35
|
# @return true if a user class `recommends :this`
|
data/lib/recommendable/rater.rb
CHANGED
@@ -26,10 +26,21 @@ module Recommendable
|
|
26
26
|
include Recommender
|
27
27
|
include Hooks
|
28
28
|
|
29
|
-
|
29
|
+
case
|
30
|
+
when defined?(Sequel::Model) && ancestors.include?(Sequel::Model)
|
31
|
+
def before_destroy
|
32
|
+
super
|
33
|
+
remove_from_recommendable!
|
34
|
+
end
|
35
|
+
when defined?(ActiveRecord::Base) && ancestors.include?(ActiveRecord::Base),
|
36
|
+
defined?(Mongoid::Document) && ancestors.include?(Mongoid::Document),
|
37
|
+
defined?(MongoMapper::Document) && ancestors.include?(MongoMapper::Document),
|
38
|
+
defined?(MongoMapper::EmbeddedDocument) && ancestors.include?(MongoMapper::EmbeddedDocument)
|
30
39
|
before_destroy :remove_from_recommendable!
|
31
|
-
|
40
|
+
when defined?(DataMapper::Resource) && ancestors.include?(DataMapper::Resource)
|
32
41
|
before :destroy, :remove_from_recommendable!
|
42
|
+
else
|
43
|
+
warn "Model #{self} is not using a supported ORM. You must handle removal from Redis manually when destroying instances."
|
33
44
|
end
|
34
45
|
|
35
46
|
define_hooks :before_like, :after_like, :before_unlike, :after_unlike,
|
@@ -71,7 +71,7 @@ module Recommendable
|
|
71
71
|
# @private
|
72
72
|
def bookmarked_ids_for(klass)
|
73
73
|
ids = Recommendable.redis.smembers(Recommendable::Helpers::RedisKeyMapper.bookmarked_set_for(klass, id))
|
74
|
-
ids.map!(&:to_i) if [:active_record, :data_mapper].include?(Recommendable.config.orm)
|
74
|
+
ids.map!(&:to_i) if [:active_record, :data_mapper, :sequel].include?(Recommendable.config.orm)
|
75
75
|
ids
|
76
76
|
end
|
77
77
|
|
@@ -74,7 +74,7 @@ module Recommendable
|
|
74
74
|
# @private
|
75
75
|
def disliked_ids_for(klass)
|
76
76
|
ids = Recommendable.redis.smembers(Recommendable::Helpers::RedisKeyMapper.disliked_set_for(klass, id))
|
77
|
-
ids.map!(&:to_i) if [:active_record, :data_mapper].include?(Recommendable.config.orm)
|
77
|
+
ids.map!(&:to_i) if [:active_record, :data_mapper, :sequel].include?(Recommendable.config.orm)
|
78
78
|
ids
|
79
79
|
end
|
80
80
|
|
@@ -72,7 +72,7 @@ module Recommendable
|
|
72
72
|
# @private
|
73
73
|
def hidden_ids_for(klass)
|
74
74
|
ids = Recommendable.redis.smembers(Recommendable::Helpers::RedisKeyMapper.hidden_set_for(klass, id))
|
75
|
-
ids.map!(&:to_i) if [:active_record, :data_mapper].include?(Recommendable.config.orm)
|
75
|
+
ids.map!(&:to_i) if [:active_record, :data_mapper, :sequel].include?(Recommendable.config.orm)
|
76
76
|
ids
|
77
77
|
end
|
78
78
|
|
@@ -74,7 +74,7 @@ module Recommendable
|
|
74
74
|
# @private
|
75
75
|
def liked_ids_for(klass)
|
76
76
|
ids = Recommendable.redis.smembers(Recommendable::Helpers::RedisKeyMapper.liked_set_for(klass, id))
|
77
|
-
ids.map!(&:to_i) if [:active_record, :data_mapper].include?(Recommendable.config.orm)
|
77
|
+
ids.map!(&:to_i) if [:active_record, :data_mapper, :sequel].include?(Recommendable.config.orm)
|
78
78
|
ids
|
79
79
|
end
|
80
80
|
|
metadata
CHANGED
@@ -1,163 +1,143 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: recommendable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
5
|
-
prerelease:
|
4
|
+
version: 2.0.4
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- David Celis
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
11
|
+
date: 2013-02-25 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: activesupport
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 3.0.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: 3.0.0
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: redis
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: 2.2.0
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: 2.2.0
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: hooks
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - '>='
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: 0.2.1
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - '>='
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: 0.2.1
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: minitest
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - '>='
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: '0'
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - '>='
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: '0'
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: miniskirt
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- -
|
73
|
+
- - '>='
|
84
74
|
- !ruby/object:Gem::Version
|
85
75
|
version: '0'
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- -
|
80
|
+
- - '>='
|
92
81
|
- !ruby/object:Gem::Version
|
93
82
|
version: '0'
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: yard
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
|
-
- -
|
87
|
+
- - '>='
|
100
88
|
- !ruby/object:Gem::Version
|
101
89
|
version: '0'
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
|
-
- -
|
94
|
+
- - '>='
|
108
95
|
- !ruby/object:Gem::Version
|
109
96
|
version: '0'
|
110
97
|
- !ruby/object:Gem::Dependency
|
111
98
|
name: rails
|
112
99
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
100
|
requirements:
|
115
|
-
- -
|
101
|
+
- - '>='
|
116
102
|
- !ruby/object:Gem::Version
|
117
103
|
version: 3.1.0
|
118
104
|
type: :development
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
107
|
requirements:
|
123
|
-
- -
|
108
|
+
- - '>='
|
124
109
|
- !ruby/object:Gem::Version
|
125
110
|
version: 3.1.0
|
126
111
|
- !ruby/object:Gem::Dependency
|
127
112
|
name: sqlite3
|
128
113
|
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
114
|
requirements:
|
131
|
-
- -
|
115
|
+
- - '>='
|
132
116
|
- !ruby/object:Gem::Version
|
133
117
|
version: '0'
|
134
118
|
type: :development
|
135
119
|
prerelease: false
|
136
120
|
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
121
|
requirements:
|
139
|
-
- -
|
122
|
+
- - '>='
|
140
123
|
- !ruby/object:Gem::Version
|
141
124
|
version: '0'
|
142
125
|
- !ruby/object:Gem::Dependency
|
143
126
|
name: database_cleaner
|
144
127
|
requirement: !ruby/object:Gem::Requirement
|
145
|
-
none: false
|
146
128
|
requirements:
|
147
|
-
- -
|
129
|
+
- - '>='
|
148
130
|
- !ruby/object:Gem::Version
|
149
131
|
version: '0'
|
150
132
|
type: :development
|
151
133
|
prerelease: false
|
152
134
|
version_requirements: !ruby/object:Gem::Requirement
|
153
|
-
none: false
|
154
135
|
requirements:
|
155
|
-
- -
|
136
|
+
- - '>='
|
156
137
|
- !ruby/object:Gem::Version
|
157
138
|
version: '0'
|
158
|
-
description:
|
159
|
-
|
160
|
-
'
|
139
|
+
description: |
|
140
|
+
A Like/Dislike recommendation engine for Ruby apps using Redis.
|
161
141
|
email:
|
162
142
|
- david@davidcelis.com
|
163
143
|
executables: []
|
@@ -173,6 +153,7 @@ files:
|
|
173
153
|
- lib/recommendable/orm/data_mapper.rb
|
174
154
|
- lib/recommendable/orm/mongo_mapper.rb
|
175
155
|
- lib/recommendable/orm/mongoid.rb
|
156
|
+
- lib/recommendable/orm/sequel.rb
|
176
157
|
- lib/recommendable/ratable/dislikable.rb
|
177
158
|
- lib/recommendable/ratable/likable.rb
|
178
159
|
- lib/recommendable/ratable.rb
|
@@ -190,27 +171,26 @@ files:
|
|
190
171
|
- lib/recommendable.rb
|
191
172
|
homepage: https://github.com/davidcelis/recommendable
|
192
173
|
licenses: []
|
174
|
+
metadata: {}
|
193
175
|
post_install_message:
|
194
176
|
rdoc_options: []
|
195
177
|
require_paths:
|
196
178
|
- lib
|
197
179
|
required_ruby_version: !ruby/object:Gem::Requirement
|
198
|
-
none: false
|
199
180
|
requirements:
|
200
|
-
- -
|
181
|
+
- - '>='
|
201
182
|
- !ruby/object:Gem::Version
|
202
183
|
version: '0'
|
203
184
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
204
|
-
none: false
|
205
185
|
requirements:
|
206
|
-
- -
|
186
|
+
- - '>='
|
207
187
|
- !ruby/object:Gem::Version
|
208
188
|
version: '0'
|
209
189
|
requirements: []
|
210
190
|
rubyforge_project:
|
211
|
-
rubygems_version:
|
191
|
+
rubygems_version: 2.0.0
|
212
192
|
signing_key:
|
213
|
-
specification_version:
|
193
|
+
specification_version: 4
|
214
194
|
summary: A Like/Dislike recommendation engine for Ruby apps using Redis
|
215
195
|
test_files: []
|
216
196
|
has_rdoc: yard
|