kosher 0.2.11 → 0.2.12
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/lib/kosher/availability.rb +4 -8
- data/lib/kosher/condition.rb +4 -8
- data/lib/kosher/seller.rb +15 -13
- data/lib/kosher/threshold.rb +21 -0
- data/lib/kosher/version.rb +1 -1
- data/lib/kosher.rb +2 -0
- data/spec/kosher/availability_spec.rb +1 -1
- data/spec/kosher/condition_spec.rb +1 -1
- data/spec/kosher/seller_spec.rb +3 -3
- metadata +2 -1
data/lib/kosher/availability.rb
CHANGED
@@ -1,15 +1,11 @@
|
|
1
1
|
module Kosher
|
2
2
|
class Availability < Struct.new(:hours)
|
3
|
-
|
4
|
-
hours <= threshold
|
5
|
-
end
|
3
|
+
include Threshold
|
6
4
|
|
7
|
-
|
8
|
-
@threshold ||= 48
|
9
|
-
end
|
5
|
+
THRESHOLD = 48
|
10
6
|
|
11
|
-
def
|
12
|
-
|
7
|
+
def kosher?
|
8
|
+
hours <= threshold
|
13
9
|
end
|
14
10
|
end
|
15
11
|
end
|
data/lib/kosher/condition.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
module Kosher
|
2
2
|
class Condition < Struct.new(:grade)
|
3
|
+
include Threshold
|
4
|
+
|
5
|
+
THRESHOLD = 4
|
6
|
+
|
3
7
|
def kosher?
|
4
8
|
grade <= threshold
|
5
9
|
end
|
@@ -8,14 +12,6 @@ module Kosher
|
|
8
12
|
grade == 1
|
9
13
|
end
|
10
14
|
|
11
|
-
def threshold
|
12
|
-
@threshold ||= 4
|
13
|
-
end
|
14
|
-
|
15
|
-
def threshold=(grade)
|
16
|
-
@threshold = grade
|
17
|
-
end
|
18
|
-
|
19
15
|
def used?
|
20
16
|
!new?
|
21
17
|
end
|
data/lib/kosher/seller.rb
CHANGED
@@ -1,27 +1,29 @@
|
|
1
1
|
module Kosher
|
2
2
|
class Seller < Struct.new(:id, :name, :rating, :location)
|
3
|
-
|
4
|
-
|
3
|
+
include Threshold
|
4
|
+
|
5
|
+
THRESHOLD = 4.8
|
6
|
+
|
7
|
+
class << self
|
8
|
+
def blacklist
|
9
|
+
@blacklist ||= []
|
10
|
+
end
|
11
|
+
|
12
|
+
def blacklist=(ids)
|
13
|
+
@blacklist = ids
|
14
|
+
end
|
5
15
|
end
|
6
16
|
|
7
|
-
def blacklist
|
8
|
-
|
17
|
+
def blacklist
|
18
|
+
self.class.blacklist
|
9
19
|
end
|
10
20
|
|
11
21
|
def blacklisted?
|
12
|
-
blacklist.include?
|
22
|
+
blacklist.include?(id)
|
13
23
|
end
|
14
24
|
|
15
25
|
def kosher?
|
16
26
|
!blacklisted? && (rating.to_f == 0.0 || rating >= threshold)
|
17
27
|
end
|
18
|
-
|
19
|
-
def threshold
|
20
|
-
@threshold ||= 4.8
|
21
|
-
end
|
22
|
-
|
23
|
-
def threshold=(rating)
|
24
|
-
@threshold = rating
|
25
|
-
end
|
26
28
|
end
|
27
29
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Kosher
|
2
|
+
module Threshold
|
3
|
+
def self.included(klass)
|
4
|
+
klass.extend(ClassMethods)
|
5
|
+
end
|
6
|
+
|
7
|
+
def threshold
|
8
|
+
self.class.threshold
|
9
|
+
end
|
10
|
+
|
11
|
+
module ClassMethods
|
12
|
+
def threshold
|
13
|
+
@threshold ||= THRESHOLD
|
14
|
+
end
|
15
|
+
|
16
|
+
def threshold=(value)
|
17
|
+
@threshold = value
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/kosher/version.rb
CHANGED
data/lib/kosher.rb
CHANGED
data/spec/kosher/seller_spec.rb
CHANGED
@@ -14,7 +14,7 @@ module Kosher
|
|
14
14
|
|
15
15
|
describe "#blacklisted?" do
|
16
16
|
before do
|
17
|
-
|
17
|
+
Seller.blacklist = ['foo']
|
18
18
|
end
|
19
19
|
|
20
20
|
it "returns true if the seller is blacklisted" do
|
@@ -30,7 +30,7 @@ module Kosher
|
|
30
30
|
|
31
31
|
describe "#kosher?" do
|
32
32
|
before do
|
33
|
-
|
33
|
+
Seller.threshold = 4.8
|
34
34
|
end
|
35
35
|
|
36
36
|
it "returns true if rating is 0.0" do
|
@@ -54,7 +54,7 @@ module Kosher
|
|
54
54
|
|
55
55
|
it "returns false if seller is blacklisted" do
|
56
56
|
@seller.id = ['foo']
|
57
|
-
|
57
|
+
Seller.blacklist = [@seller.id]
|
58
58
|
@seller.should_not be_kosher
|
59
59
|
end
|
60
60
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: kosher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.2.
|
5
|
+
version: 0.2.12
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Paper Cavalier
|
@@ -71,6 +71,7 @@ files:
|
|
71
71
|
- lib/kosher/seller.rb
|
72
72
|
- lib/kosher/shipping.rb
|
73
73
|
- lib/kosher/snapshot.rb
|
74
|
+
- lib/kosher/threshold.rb
|
74
75
|
- lib/kosher/version.rb
|
75
76
|
- spec/kosher/availability_spec.rb
|
76
77
|
- spec/kosher/condition_spec.rb
|