mongoid_rateable 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MjJmNGJjOTgyYTAzMzFmNjdjNzgwNDdhNjc5NjFmMDE0MDg2MWRkYg==
5
+ data.tar.gz: !binary |-
6
+ NzU5OTFmNGNhYTg3Zjg4OTE2MTUzN2ZmM2YzMzIxNjQxZjc1YTZjZg==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ Y2Y5NzE0OWU1MGEwZGI0MmNlOGE5NWUyNjMzN2I4ZmNhYTQ1YTQ1MWUzMzc1
10
+ NmFjZDZkZTYxMmI1NTVlNTc2ODhjMTM3ZDIxY2M1M2Q0MzEzOGE1ZmUwOGM2
11
+ NjU0ZWQ0ZTRkZjBhZjA0NzBjYzU2MjBlNWQzY2M3MDNiYWU2ZjQ=
12
+ data.tar.gz: !binary |-
13
+ ZDI5NTI1ODVkNTY4MjIxOWJjZTg0OGEyZTI4MWNhMmFlZjI3ZGYzMDFkNzk0
14
+ YzkzMTRlMzE1OTBiMTFiNTJjYzkzNjNlMjkyMDljMDE0OTEyZDk2ODdiOTNh
15
+ YWFmZjE4ZjRkYjQ3MDI0ZjY2OGZlYmY2NzIyMTdmODgwM2UzNjM=
data/.travis.yml ADDED
@@ -0,0 +1 @@
1
+ services: mongodb
data/Gemfile CHANGED
@@ -1,13 +1,13 @@
1
- source "http://rubygems.org"
1
+ source 'http://rubygems.org'
2
2
 
3
- gem "mongoid", ">= 3.0"
3
+ gem 'mongoid', '~> 3.0'
4
4
 
5
5
  group :development do
6
- gem "bundler"
7
- gem "jeweler", ">= 1.6.2"
8
- gem "simplecov", '>= 0.4.0', :require => false
9
- gem "rdoc", ">= 0"
10
- gem "rspec", ">= 2.0.0"
11
- gem "database_cleaner"
6
+ gem 'bundler', '~> 1'
7
+ gem 'jeweler', '~> 1.6'
8
+ gem 'simplecov', '~> 0.4', :require => false
9
+ gem 'rdoc', '~> 3'
10
+ gem 'rspec', '~> 2.0'
11
+ gem 'database_cleaner', '~> 0'
12
12
  end
13
13
 
data/Gemfile.lock CHANGED
@@ -1,55 +1,85 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- activemodel (3.2.7)
5
- activesupport (= 3.2.7)
4
+ activemodel (3.2.18)
5
+ activesupport (= 3.2.18)
6
6
  builder (~> 3.0.0)
7
- activesupport (3.2.7)
8
- i18n (~> 0.6)
7
+ activesupport (3.2.18)
8
+ i18n (~> 0.6, >= 0.6.4)
9
9
  multi_json (~> 1.0)
10
- builder (3.0.0)
11
- database_cleaner (0.8.0)
12
- diff-lcs (1.1.3)
13
- git (1.2.5)
14
- i18n (0.6.0)
15
- jeweler (1.6.4)
10
+ addressable (2.3.6)
11
+ builder (3.0.4)
12
+ database_cleaner (0.9.1)
13
+ diff-lcs (1.2.5)
14
+ docile (1.1.5)
15
+ faraday (0.8.9)
16
+ multipart-post (~> 1.2.0)
17
+ git (1.2.7)
18
+ github_api (0.10.1)
19
+ addressable
20
+ faraday (~> 0.8.1)
21
+ hashie (>= 1.2)
22
+ multi_json (~> 1.4)
23
+ nokogiri (~> 1.5.2)
24
+ oauth2
25
+ hashie (3.0.0)
26
+ highline (1.6.21)
27
+ i18n (0.6.9)
28
+ jeweler (1.8.8)
29
+ builder
16
30
  bundler (~> 1.0)
17
31
  git (>= 1.2.5)
32
+ github_api (= 0.10.1)
33
+ highline (>= 1.6.15)
34
+ nokogiri (= 1.5.10)
18
35
  rake
19
- json (1.7.4)
20
- mongoid (3.0.3)
21
- activemodel (~> 3.1)
22
- moped (~> 1.1)
36
+ rdoc
37
+ json (1.8.1)
38
+ jwt (1.0.0)
39
+ mongoid (3.1.6)
40
+ activemodel (~> 3.2)
41
+ moped (~> 1.4)
23
42
  origin (~> 1.0)
24
- tzinfo (~> 0.3.22)
25
- moped (1.2.0)
26
- multi_json (1.3.6)
27
- origin (1.0.4)
28
- rake (0.9.2.2)
29
- rdoc (3.12)
43
+ tzinfo (~> 0.3.29)
44
+ moped (1.5.2)
45
+ multi_json (1.10.1)
46
+ multi_xml (0.5.5)
47
+ multipart-post (1.2.0)
48
+ nokogiri (1.5.10)
49
+ oauth2 (0.9.4)
50
+ faraday (>= 0.8, < 0.10)
51
+ jwt (~> 1.0)
52
+ multi_json (~> 1.3)
53
+ multi_xml (~> 0.5)
54
+ rack (~> 1.2)
55
+ origin (1.1.0)
56
+ rack (1.5.2)
57
+ rake (10.3.2)
58
+ rdoc (3.12.2)
30
59
  json (~> 1.4)
31
- rspec (2.11.0)
32
- rspec-core (~> 2.11.0)
33
- rspec-expectations (~> 2.11.0)
34
- rspec-mocks (~> 2.11.0)
35
- rspec-core (2.11.1)
36
- rspec-expectations (2.11.2)
37
- diff-lcs (~> 1.1.3)
38
- rspec-mocks (2.11.1)
39
- simplecov (0.6.4)
40
- multi_json (~> 1.0)
41
- simplecov-html (~> 0.5.3)
42
- simplecov-html (0.5.3)
43
- tzinfo (0.3.33)
60
+ rspec (2.99.0)
61
+ rspec-core (~> 2.99.0)
62
+ rspec-expectations (~> 2.99.0)
63
+ rspec-mocks (~> 2.99.0)
64
+ rspec-core (2.99.1)
65
+ rspec-expectations (2.99.1)
66
+ diff-lcs (>= 1.1.3, < 2.0)
67
+ rspec-mocks (2.99.1)
68
+ simplecov (0.8.2)
69
+ docile (~> 1.1.0)
70
+ multi_json
71
+ simplecov-html (~> 0.8.0)
72
+ simplecov-html (0.8.0)
73
+ tzinfo (0.3.39)
44
74
 
45
75
  PLATFORMS
46
76
  ruby
47
77
 
48
78
  DEPENDENCIES
49
- bundler
50
- database_cleaner
51
- jeweler (>= 1.6.2)
52
- mongoid (>= 3.0)
53
- rdoc
54
- rspec (>= 2.0.0)
55
- simplecov (>= 0.4.0)
79
+ bundler (~> 1)
80
+ database_cleaner (~> 0)
81
+ jeweler (~> 1.6)
82
+ mongoid (~> 3.0)
83
+ rdoc (~> 3)
84
+ rspec (~> 2.0)
85
+ simplecov (~> 0.4)
data/README.rdoc CHANGED
@@ -7,6 +7,11 @@ Provides fields and methods for the *rating* manipulation on Mongoid documents
7
7
  Lastest version of Mongoid:Rateable requires mongoid 3.
8
8
  If you need a mongoid 2 support, look at mongoid_rateable 0.1.7.
9
9
 
10
+ == Support us
11
+
12
+
13
+ {<img src="http://api.flattr.com/button/flattr-badge-large.png" />}[https://flattr.com/submit/auto?user_id=proton&url=https://github.com/proton/mongoid_rateable/&title=MongoidRateable&language=&tags=github&category=software]
14
+
10
15
  == Installation
11
16
 
12
17
  Add to Gemfile:
@@ -157,4 +162,4 @@ You can get most rated and highest rated posts:
157
162
  == Copyright
158
163
 
159
164
  Copyright (c) 2011 Peter Savichev (proton). See LICENSE.txt for
160
- further details.
165
+ further details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.3.2
@@ -9,7 +9,6 @@ module Mongoid
9
9
  def rateable options = {}
10
10
  class_eval do
11
11
  self.send :include, Mongoid::Rateable
12
- puts "options: #{options}"
13
12
  self.rate_config options
14
13
  end
15
14
  end
@@ -23,7 +22,7 @@ module Mongoid
23
22
  field :rating_delta, type: Float, default: 0.0
24
23
  field :weighted_rate_count, type: Integer, default: 0
25
24
 
26
- embeds_many :rating_marks, :as => :rateable
25
+ embeds_many :rating_marks, :as => :rateable, cascade_callbacks: true
27
26
 
28
27
  index({"rating_marks.rater_id" => 1, "rating_marks.rater_class" => 1})
29
28
 
@@ -1,3 +1,3 @@
1
1
  module MongoidRateable
2
- VERSION = '0.2.0'
2
+ VERSION = '0.3.2'
3
3
  end
@@ -2,14 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
+ # stub: mongoid_rateable 0.3.2 ruby lib
5
6
 
6
7
  Gem::Specification.new do |s|
7
8
  s.name = "mongoid_rateable"
8
- s.version = "0.3.1"
9
+ s.version = "0.3.2"
9
10
 
10
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
11
13
  s.authors = ["Peter Savichev (proton)"]
12
- s.date = "2012-12-07"
14
+ s.date = "2014-06-21"
13
15
  s.description = "Provides fields and methods for the rating manipulation on Mongoid documents."
14
16
  s.email = "psavichev@gmail.com"
15
17
  s.extra_rdoc_files = [
@@ -20,6 +22,7 @@ Gem::Specification.new do |s|
20
22
  s.files = [
21
23
  ".rspec",
22
24
  ".rvmrc",
25
+ ".travis.yml",
23
26
  "CHANGELOG.md",
24
27
  "Gemfile",
25
28
  "Gemfile.lock",
@@ -42,38 +45,37 @@ Gem::Specification.new do |s|
42
45
  ]
43
46
  s.homepage = "http://github.com/proton/mongoid_rateable"
44
47
  s.licenses = ["MIT"]
45
- s.require_paths = ["lib"]
46
- s.rubygems_version = "1.8.18"
48
+ s.rubygems_version = "2.2.2"
47
49
  s.summary = "Rating functionality for Mongoid documents"
48
50
 
49
51
  if s.respond_to? :specification_version then
50
- s.specification_version = 3
52
+ s.specification_version = 4
51
53
 
52
54
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
53
- s.add_runtime_dependency(%q<mongoid>, [">= 3.0"])
54
- s.add_development_dependency(%q<bundler>, [">= 0"])
55
- s.add_development_dependency(%q<jeweler>, [">= 1.6.2"])
56
- s.add_development_dependency(%q<simplecov>, [">= 0.4.0"])
57
- s.add_development_dependency(%q<rdoc>, [">= 0"])
58
- s.add_development_dependency(%q<rspec>, [">= 2.0.0"])
59
- s.add_development_dependency(%q<database_cleaner>, [">= 0"])
55
+ s.add_runtime_dependency(%q<mongoid>, ["~> 3.0"])
56
+ s.add_development_dependency(%q<bundler>, ["~> 1"])
57
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6"])
58
+ s.add_development_dependency(%q<simplecov>, ["~> 0.4"])
59
+ s.add_development_dependency(%q<rdoc>, ["~> 3"])
60
+ s.add_development_dependency(%q<rspec>, ["~> 2.0"])
61
+ s.add_development_dependency(%q<database_cleaner>, ["~> 0"])
60
62
  else
61
- s.add_dependency(%q<mongoid>, [">= 3.0"])
62
- s.add_dependency(%q<bundler>, [">= 0"])
63
- s.add_dependency(%q<jeweler>, [">= 1.6.2"])
64
- s.add_dependency(%q<simplecov>, [">= 0.4.0"])
65
- s.add_dependency(%q<rdoc>, [">= 0"])
66
- s.add_dependency(%q<rspec>, [">= 2.0.0"])
67
- s.add_dependency(%q<database_cleaner>, [">= 0"])
63
+ s.add_dependency(%q<mongoid>, ["~> 3.0"])
64
+ s.add_dependency(%q<bundler>, ["~> 1"])
65
+ s.add_dependency(%q<jeweler>, ["~> 1.6"])
66
+ s.add_dependency(%q<simplecov>, ["~> 0.4"])
67
+ s.add_dependency(%q<rdoc>, ["~> 3"])
68
+ s.add_dependency(%q<rspec>, ["~> 2.0"])
69
+ s.add_dependency(%q<database_cleaner>, ["~> 0"])
68
70
  end
69
71
  else
70
- s.add_dependency(%q<mongoid>, [">= 3.0"])
71
- s.add_dependency(%q<bundler>, [">= 0"])
72
- s.add_dependency(%q<jeweler>, [">= 1.6.2"])
73
- s.add_dependency(%q<simplecov>, [">= 0.4.0"])
74
- s.add_dependency(%q<rdoc>, [">= 0"])
75
- s.add_dependency(%q<rspec>, [">= 2.0.0"])
76
- s.add_dependency(%q<database_cleaner>, [">= 0"])
72
+ s.add_dependency(%q<mongoid>, ["~> 3.0"])
73
+ s.add_dependency(%q<bundler>, ["~> 1"])
74
+ s.add_dependency(%q<jeweler>, ["~> 1.6"])
75
+ s.add_dependency(%q<simplecov>, ["~> 0.4"])
76
+ s.add_dependency(%q<rdoc>, ["~> 3"])
77
+ s.add_dependency(%q<rspec>, ["~> 2.0"])
78
+ s.add_dependency(%q<database_cleaner>, ["~> 0"])
77
79
  end
78
80
  end
79
81
 
@@ -57,24 +57,19 @@ describe Post do
57
57
  @post.rates.should eql 5
58
58
  end
59
59
 
60
- it "should not raise exception if rate_value in rating range" do
61
- lambda { @article.rate 1, @sally }.should_not raise_error
60
+ context "when rate_value in rating range" do
61
+ it { expect { @article.rate 1, @sally }.not_to raise_error }
62
62
  end
63
63
 
64
- it "should raise exception if rate_value not in rating range" do
65
- lambda { @article.rate 7, @sally }.should raise_error(ArgumentError)
64
+ context "when rate_value not in rating range" do
65
+ it { expect { @article.rate 7, @sally }.to raise_error(ArgumentError) }
66
66
  end
67
67
 
68
- #TODO: Rewrite for random values
69
68
  describe "when using negative values" do
70
- it "should work properly for -3" do
71
- @post.rate -3, @sally
72
- @post.rates.should eql -2
73
- end
74
- it "should work properly for -1 with weight 3" do
75
- @post.rate -1, @sally, 3
76
- @post.rates.should eql -2
77
- end
69
+ let(:num) { -rand(1..100) }
70
+
71
+ it { expect { @post.rate num, @sally }.to change { @post.rates }.by(num) }
72
+ it { expect { @post.rate -1, @sally, -num }.to change { @post.rates }.by(num) }
78
73
  end
79
74
  end
80
75
 
@@ -273,6 +268,10 @@ describe Post do
273
268
  describe "#unweighted_rating" do
274
269
  specify { @f_post.unweighted_rating.should eq -1.0 }
275
270
  end
271
+
272
+ describe "rating timestamps" do
273
+ specify { @f_post.rating_marks.first.created_at.should_not be_nil }
274
+ end
276
275
  end
277
276
 
278
277
  describe "#rate_and_save" do
@@ -510,24 +509,19 @@ describe Comment do
510
509
  @comment1.rates.should eql 5
511
510
  end
512
511
 
513
- it "should not raise exception if rate_value in rating range" do
514
- lambda { @comment1.rate 1, @sally }.should_not raise_error
512
+ context "when rate_value in rating range" do
513
+ it { expect { @comment1.rate 1, @sally }.not_to raise_error }
515
514
  end
516
-
517
- it "should raise exception if rate_value not in rating range" do
518
- lambda { @comment1.rate 9, @sally }.should raise_error(ArgumentError)
515
+
516
+ context "when rate_value not in rating range" do
517
+ it { expect { @comment1.rate 9, @sally }.to raise_error(ArgumentError) }
519
518
  end
520
519
 
521
- #TODO: Rewrite for random values
522
520
  describe "when using negative values" do
523
- it "should work properly for -3" do
524
- @comment1.rate -3, @sally
525
- @comment1.rates.should eql -1
526
- end
527
- it "should work properly for -1 with weight 3" do
528
- @comment1.rate -1, @sally, 3
529
- @comment1.rates.should eql -1
530
- end
521
+ let(:num) { -rand(1..5) }
522
+
523
+ it { expect { @comment1.rate num, @sally }.to change { @comment1.rates }.by(num) }
524
+ it { expect { @comment1.rate -1, @sally, -num }.to change { @comment1.rates }.by(num) }
531
525
  end
532
526
  end
533
527
 
metadata CHANGED
@@ -1,126 +1,111 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid_rateable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
5
- prerelease:
4
+ version: 0.3.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Peter Savichev (proton)
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-12-07 00:00:00.000000000 Z
11
+ date: 2014-06-21 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: mongoid
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'
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'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: bundler
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ~>
36
32
  - !ruby/object:Gem::Version
37
- version: '0'
33
+ version: '1'
38
34
  type: :development
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
- version: '0'
40
+ version: '1'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: jeweler
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ~>
52
46
  - !ruby/object:Gem::Version
53
- version: 1.6.2
47
+ version: '1.6'
54
48
  type: :development
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
- version: 1.6.2
54
+ version: '1.6'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: simplecov
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - ~>
68
60
  - !ruby/object:Gem::Version
69
- version: 0.4.0
61
+ version: '0.4'
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
- version: 0.4.0
68
+ version: '0.4'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rdoc
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - ~>
84
74
  - !ruby/object:Gem::Version
85
- version: '0'
75
+ version: '3'
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
- version: '0'
82
+ version: '3'
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: rspec
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>='
87
+ - - ~>
100
88
  - !ruby/object:Gem::Version
101
- version: 2.0.0
89
+ version: '2.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
- version: 2.0.0
96
+ version: '2.0'
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: database_cleaner
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
- - - ! '>='
101
+ - - ~>
116
102
  - !ruby/object:Gem::Version
117
103
  version: '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: '0'
126
111
  description: Provides fields and methods for the rating manipulation on Mongoid documents.
@@ -134,6 +119,7 @@ extra_rdoc_files:
134
119
  files:
135
120
  - .rspec
136
121
  - .rvmrc
122
+ - .travis.yml
137
123
  - CHANGELOG.md
138
124
  - Gemfile
139
125
  - Gemfile.lock
@@ -156,29 +142,25 @@ files:
156
142
  homepage: http://github.com/proton/mongoid_rateable
157
143
  licenses:
158
144
  - MIT
145
+ metadata: {}
159
146
  post_install_message:
160
147
  rdoc_options: []
161
148
  require_paths:
162
149
  - lib
163
150
  required_ruby_version: !ruby/object:Gem::Requirement
164
- none: false
165
151
  requirements:
166
152
  - - ! '>='
167
153
  - !ruby/object:Gem::Version
168
154
  version: '0'
169
- segments:
170
- - 0
171
- hash: -55772387
172
155
  required_rubygems_version: !ruby/object:Gem::Requirement
173
- none: false
174
156
  requirements:
175
157
  - - ! '>='
176
158
  - !ruby/object:Gem::Version
177
159
  version: '0'
178
160
  requirements: []
179
161
  rubyforge_project:
180
- rubygems_version: 1.8.18
162
+ rubygems_version: 2.2.2
181
163
  signing_key:
182
- specification_version: 3
164
+ specification_version: 4
183
165
  summary: Rating functionality for Mongoid documents
184
166
  test_files: []