ibham 0.1.3 → 0.1.4
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/CHANGELOG.md +5 -1
- data/README.md +7 -7
- data/lib/ibham/acts_as_voteable.rb +3 -3
- data/lib/ibham/version.rb +1 -1
- data/spec/modules/acts_as_voteable_spec.rb +4 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ce92be3e70882f8ed9a7dcdb32fac289e369f16
|
4
|
+
data.tar.gz: 2416dbbf7db79a5f118e1d0cb2bd9a36322b7244
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28c0d2b9c5b68346eed325c839748afd884f3dd7a80ca088f9f84caa41404e117fb43ed753ac5cc32837e830f528ed114364535496f0fb85d6316c09edf4eba7
|
7
|
+
data.tar.gz: 1d0fbe3db0de1e7be9c97938c8ea7b99e2246c78ec871adee857c927e84f35f532755c1e9ed747527956a4deed2a6684bc4faa46605726499ab0555556e53c71
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -42,8 +42,8 @@ The user can cast votes in the following ways:
|
|
42
42
|
user = User.create
|
43
43
|
item = Item.create
|
44
44
|
|
45
|
-
user.vote_up(item)
|
46
|
-
user.vote_down(item)
|
45
|
+
user.vote_up(item) # Adds a positive vote
|
46
|
+
user.vote_down(item) # Adds a negative vote
|
47
47
|
|
48
48
|
Since a user can cast only one vote per item, to check if the user can
|
49
49
|
cast vote for an item:
|
@@ -54,13 +54,13 @@ cast vote for an item:
|
|
54
54
|
|
55
55
|
To retrieve the votes:
|
56
56
|
|
57
|
-
item.up_votes
|
58
|
-
item.down_votes
|
57
|
+
item.up_votes # Returns the total number of positive votes
|
58
|
+
item.down_votes # Returns the total number of negative votes
|
59
59
|
|
60
|
-
item.up_percentage
|
61
|
-
item.down_percentage
|
60
|
+
item.up_percentage # Returns the percentage of positive votes
|
61
|
+
item.down_percentage # Returns the percentage of negative votes
|
62
62
|
|
63
|
-
item.
|
63
|
+
item.vote_sum # Retuns the result of votes
|
64
64
|
|
65
65
|
For more information visit [the documentation
|
66
66
|
page](http://rubydoc.info/github/bloc40/ibham/master/frames).
|
@@ -80,11 +80,11 @@ module Ibham
|
|
80
80
|
votes.where(value: -ALLOWED_VALUE).map(&:voter)
|
81
81
|
end
|
82
82
|
|
83
|
-
# To get the result of the votes, call <tt>
|
83
|
+
# To get the result of the votes, call <tt>vote_sum</tt> on the
|
84
84
|
# voteable object.
|
85
85
|
#
|
86
|
-
# item.
|
87
|
-
def
|
86
|
+
# item.vote_sum
|
87
|
+
def vote_sum
|
88
88
|
votes.sum(:value)
|
89
89
|
end
|
90
90
|
end
|
data/lib/ibham/version.rb
CHANGED
@@ -67,10 +67,10 @@ describe 'ActsAsVoteable' do
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
-
describe '#
|
71
|
-
it 'returns the
|
72
|
-
item.
|
73
|
-
item2.
|
70
|
+
describe '#vote_sum' do
|
71
|
+
it 'returns the sum of the votes per item' do
|
72
|
+
item.vote_sum.must_equal 1
|
73
|
+
item2.vote_sum.must_equal -1
|
74
74
|
end
|
75
75
|
end
|
76
76
|
end
|