rs_voteable_mongo 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +22 -0
- data/CHANGELOG.rdoc +6 -0
- data/README.rdoc +6 -41
- data/gemfiles/mongoid-3.0.gemfile +5 -0
- data/gemfiles/mongoid-3.1.gemfile +5 -0
- data/gemfiles/mongoid-4.0.gemfile +5 -0
- data/lib/rs_votable_mongo.rb +1 -1
- data/lib/voteable_mongo/version.rb +1 -1
- data/lib/voteable_mongo/voteable.rb +1 -6
- data/voteable_mongo.gemspec +6 -5
- metadata +37 -5
- data/.watchr +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45ea1fbc2dc83f8f83c9dadf76f0e0d7aeae55fc
|
4
|
+
data.tar.gz: 588254e5dc81a3010ece1972a6a1f1d06f4da705
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7088a5fae13d3ef1f1a71e0febde84fb4cff8784df77302552eea0d1d40b006cff7e463cf71f6272b46ff9c11eb0a47ed0d1772fb57430fbfc379fe6aa4e4478
|
7
|
+
data.tar.gz: c93b9c107594da322e980b86d4ba0690ef31c45350596e99bddcca54b11945168e64243df28e7c3bff24013dca35e33b1a82425a45fcc6efc0d7d301c49fbd02
|
data/.travis.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
services: mongodb
|
2
|
+
|
3
|
+
notifications:
|
4
|
+
email: false
|
5
|
+
|
6
|
+
language: ruby
|
7
|
+
rvm:
|
8
|
+
- 1.9.3
|
9
|
+
- 2.0.0
|
10
|
+
- jruby-19mode
|
11
|
+
- rbx-19mode
|
12
|
+
|
13
|
+
gemfile:
|
14
|
+
- Gemfile
|
15
|
+
- gemfiles/mongoid-3.0.gemfile
|
16
|
+
- gemfiles/mongoid-3.1.gemfile
|
17
|
+
- gemfiles/mongoid-4.0.gemfile
|
18
|
+
|
19
|
+
matrix:
|
20
|
+
exclude:
|
21
|
+
- rvm: rbx-19mode
|
22
|
+
gemfile: gemfiles/mongoid-4.0.gemfile
|
data/CHANGELOG.rdoc
CHANGED
data/README.rdoc
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
= Voteable Mongo (for Mongoid 3 / 4)
|
2
2
|
|
3
|
+
{<img src="https://travis-ci.org/rs-pro/voteable_mongo.png?branch=master" alt="Build Status" />}[https://travis-ci.org/rs-pro/voteable_mongo]
|
4
|
+
{<img src="https://gemnasium.com/rs-pro/voteable_mongo.png" alt="Dependency Status" />}[https://gemnasium.com/rs-pro/voteable_mongo]
|
5
|
+
{<img src="https://badge.fury.io/rb/rs_voteable_mongo.png" alt="Gem Version" />}[http://badge.fury.io/rb/rs_voteable_mongo]
|
6
|
+
|
3
7
|
voteable_mongo allows you to make your Mongoid::Document or MongoMapper::Document objects voteable and tabulate votes count and votes point for you. For instance, in a forum, a user can vote up (or down) on a post or a comment. It's optimized for speed by using only ONE database request per collection to validate, update, and retrieve updated data.
|
4
8
|
|
5
9
|
Initial idea based on http://cookbook.mongodb.org/patterns/votes.
|
6
10
|
|
7
|
-
Sample app at https://github.com/vinova/simple_qa.
|
8
|
-
|
9
|
-
Wonder how fast voteable_mongo is compare to other SQL & MongoDB solutions?
|
10
|
-
Visit benchmarks at https://github.com/vinova/voteable_benchmarks
|
11
|
-
|
12
11
|
== Why voteable_mongo?
|
13
12
|
|
14
13
|
There are various solutions for up / down voting problem (1[https://github.com/medihack/make_voteable], 2[https://github.com/brady8/thumbs_up], 3[https://github.com/icaruswings/mm-voteable], 4[https://github.com/jcoene/mongoid_voteable], ...). Most of them using additional votes table (SQL) or votes collection (MongoDB) to store votes and do data tabulation on that votes table or votes collection.
|
@@ -29,6 +28,7 @@ So use voteable_mongo for less maintain cost, data integrity and save database r
|
|
29
28
|
* http://www.naiku.net
|
30
29
|
* http://www.amorveneris.com
|
31
30
|
* http://zheye.org
|
31
|
+
* http://megalyrics.ru
|
32
32
|
|
33
33
|
== Installation
|
34
34
|
|
@@ -81,41 +81,6 @@ user.rb
|
|
81
81
|
end
|
82
82
|
|
83
83
|
|
84
|
-
== MongoMapper
|
85
|
-
post.rb
|
86
|
-
|
87
|
-
class Post
|
88
|
-
include MongoMapper::Document
|
89
|
-
include Mongo::Voteable
|
90
|
-
|
91
|
-
# set points for each vote
|
92
|
-
voteable self, :up => +1, :down => -1
|
93
|
-
|
94
|
-
many :comments
|
95
|
-
end
|
96
|
-
|
97
|
-
comment.rb
|
98
|
-
|
99
|
-
require 'post'
|
100
|
-
|
101
|
-
class Comment
|
102
|
-
include MongoMapper::Document
|
103
|
-
include Mongo::Voteable
|
104
|
-
|
105
|
-
belongs_to :post
|
106
|
-
|
107
|
-
voteable self, :up => +1, :down => -3
|
108
|
-
voteable Post, :up => +2, :down => -1
|
109
|
-
end
|
110
|
-
|
111
|
-
user.rb
|
112
|
-
|
113
|
-
class User
|
114
|
-
include MongoMapper::Document
|
115
|
-
include Mongo::Voter
|
116
|
-
end
|
117
|
-
|
118
|
-
|
119
84
|
=== Make a vote
|
120
85
|
|
121
86
|
@user.vote(@post, :up)
|
@@ -205,7 +170,7 @@ Ruby
|
|
205
170
|
|
206
171
|
== Credits
|
207
172
|
* Alex Nguyen - Author
|
208
|
-
* Contributors[https://github.com/
|
173
|
+
* Contributors[https://github.com/rs-pro/voteable_mongo/contributors]
|
209
174
|
|
210
175
|
Copyright (c) 2010-2011 Vinova Pte Ltd
|
211
176
|
|
data/lib/rs_votable_mongo.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require '
|
1
|
+
require 'voteable_mongo'
|
@@ -16,12 +16,7 @@ module Mongo
|
|
16
16
|
|
17
17
|
included do
|
18
18
|
include Mongo::Voteable::Voting
|
19
|
-
|
20
|
-
if defined?(Mongoid) && defined?(field)
|
21
|
-
include Mongo::Voteable::Integrations::Mongoid
|
22
|
-
elsif defined?(MongoMapper)
|
23
|
-
include Mongo::Voteable::Integrations::MongoMapper
|
24
|
-
end
|
19
|
+
include Mongo::Voteable::Integrations::Mongoid
|
25
20
|
|
26
21
|
scope :voted_by, lambda { |voter|
|
27
22
|
voter_id = Helpers.get_mongo_id(voter)
|
data/voteable_mongo.gemspec
CHANGED
@@ -11,14 +11,15 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.homepage = 'https://github.com/rs-pro/voteable_mongo'
|
12
12
|
s.summary = %q{Add up / down voting ability to Mongoid documents}
|
13
13
|
s.description = %q{Add up / down voting ability to Mongoid documents. Optimized for speed by using only ONE request to MongoDB to validate, update, and retrieve updated data.}
|
14
|
-
|
15
|
-
s.add_dependency "mongoid", [">= 3.0", "< 5.0"]
|
16
|
-
s.add_development_dependency 'rspec', '~> 2.14.1'
|
17
|
-
|
18
|
-
s.rubyforge_project = 'voteable_mongo'
|
14
|
+
s.license = "MIT"
|
19
15
|
|
20
16
|
s.files = `git ls-files`.split("\n")
|
21
17
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
22
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
23
19
|
s.require_paths = ['lib']
|
20
|
+
|
21
|
+
s.add_dependency "mongoid", [">= 3.0", "< 5.0"]
|
22
|
+
s.add_development_dependency 'rspec', '~> 2.14.1'
|
23
|
+
s.add_development_dependency "bundler", "~> 1.3"
|
24
|
+
s.add_development_dependency "rake"
|
24
25
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rs_voteable_mongo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- RocketScience
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-10-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mongoid
|
@@ -45,6 +45,34 @@ dependencies:
|
|
45
45
|
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 2.14.1
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: bundler
|
50
|
+
requirement: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.3'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rake
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
type: :development
|
70
|
+
prerelease: false
|
71
|
+
version_requirements: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
48
76
|
description: Add up / down voting ability to Mongoid documents. Optimized for speed
|
49
77
|
by using only ONE request to MongoDB to validate, update, and retrieve updated data.
|
50
78
|
email:
|
@@ -57,12 +85,15 @@ files:
|
|
57
85
|
- .gitignore
|
58
86
|
- .ruby-gemset
|
59
87
|
- .ruby-version
|
60
|
-
- .
|
88
|
+
- .travis.yml
|
61
89
|
- CHANGELOG.rdoc
|
62
90
|
- Gemfile
|
63
91
|
- README.rdoc
|
64
92
|
- Rakefile
|
65
93
|
- TODO
|
94
|
+
- gemfiles/mongoid-3.0.gemfile
|
95
|
+
- gemfiles/mongoid-3.1.gemfile
|
96
|
+
- gemfiles/mongoid-4.0.gemfile
|
66
97
|
- lib/rs_votable_mongo.rb
|
67
98
|
- lib/voteable_mongo.rb
|
68
99
|
- lib/voteable_mongo/helpers.rb
|
@@ -85,7 +116,8 @@ files:
|
|
85
116
|
- spec/voteable_mongo/voter_spec.rb
|
86
117
|
- voteable_mongo.gemspec
|
87
118
|
homepage: https://github.com/rs-pro/voteable_mongo
|
88
|
-
licenses:
|
119
|
+
licenses:
|
120
|
+
- MIT
|
89
121
|
metadata: {}
|
90
122
|
post_install_message:
|
91
123
|
rdoc_options: []
|
@@ -102,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
134
|
- !ruby/object:Gem::Version
|
103
135
|
version: '0'
|
104
136
|
requirements: []
|
105
|
-
rubyforge_project:
|
137
|
+
rubyforge_project:
|
106
138
|
rubygems_version: 2.0.6
|
107
139
|
signing_key:
|
108
140
|
specification_version: 4
|
data/.watchr
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
# vim:set filetype=ruby:
|
2
|
-
def run(cmd)
|
3
|
-
puts cmd
|
4
|
-
system cmd
|
5
|
-
end
|
6
|
-
|
7
|
-
def spec(file)
|
8
|
-
if File.exists?(file)
|
9
|
-
run("rspec #{file}")
|
10
|
-
else
|
11
|
-
puts("Spec: #{file} does not exist.")
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
watch("spec/.*/*_spec\.rb") do |match|
|
16
|
-
puts(match[0])
|
17
|
-
spec(match[0])
|
18
|
-
end
|
19
|
-
|
20
|
-
watch("lib/(.*/.*)\.rb") do |match|
|
21
|
-
puts(match[1])
|
22
|
-
spec("spec/#{match[1]}_spec.rb")
|
23
|
-
end
|