kosher 0.16.0 → 0.17.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +0 -1
- data/Gemfile +2 -0
- data/README.md +1 -1
- data/kosher.gemspec +2 -2
- data/lib/kosher.rb +5 -12
- data/lib/kosher/condition.rb +15 -0
- data/lib/kosher/offer.rb +9 -8
- data/lib/kosher/seller.rb +11 -0
- data/lib/kosher/shipping.rb +12 -0
- data/lib/kosher/version.rb +1 -1
- data/test/kosher_test.rb +36 -6
- metadata +14 -11
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
data/kosher.gemspec
CHANGED
data/lib/kosher.rb
CHANGED
@@ -2,15 +2,8 @@ require 'certainty'
|
|
2
2
|
require 'money'
|
3
3
|
require 'structure'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
autoload :Filter, 'kosher/filter'
|
11
|
-
autoload :Offer, 'kosher/offer'
|
12
|
-
autoload :Price, 'kosher/price'
|
13
|
-
autoload :Seller, 'kosher/seller'
|
14
|
-
autoload :Shipping, 'kosher/shipping'
|
15
|
-
autoload :Unit, 'kosher/unit'
|
16
|
-
end
|
5
|
+
require 'kosher/condition'
|
6
|
+
require 'kosher/offer'
|
7
|
+
require 'kosher/seller'
|
8
|
+
require 'kosher/shipping'
|
9
|
+
require 'kosher/unit'
|
data/lib/kosher/offer.rb
CHANGED
@@ -2,14 +2,11 @@ module Kosher
|
|
2
2
|
class Offer < Structure
|
3
3
|
include Comparable
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
alias kosher? kosher
|
12
|
-
alias new? new
|
5
|
+
one :condition
|
6
|
+
one :shipping
|
7
|
+
one :seller
|
8
|
+
one :unit
|
9
|
+
one :venue
|
13
10
|
|
14
11
|
def <=>(other)
|
15
12
|
if kosher? != other.kosher?
|
@@ -19,6 +16,10 @@ module Kosher
|
|
19
16
|
end
|
20
17
|
end
|
21
18
|
|
19
|
+
def kosher?
|
20
|
+
condition.kosher? && seller.kosher? && shipping.kosher?
|
21
|
+
end
|
22
|
+
|
22
23
|
def price
|
23
24
|
unit.price + shipping.cost
|
24
25
|
end
|
data/lib/kosher/shipping.rb
CHANGED
@@ -1,10 +1,22 @@
|
|
1
1
|
module Kosher
|
2
2
|
class Shipping < Structure
|
3
|
+
key :available, default: true
|
3
4
|
key :cents, Integer
|
4
5
|
key :currency
|
6
|
+
key :fast, default: false
|
7
|
+
|
8
|
+
def available?
|
9
|
+
Boolean(available)
|
10
|
+
end
|
5
11
|
|
6
12
|
def cost
|
7
13
|
Money.new(cents, currency)
|
8
14
|
end
|
15
|
+
|
16
|
+
def fast?
|
17
|
+
Boolean(fast)
|
18
|
+
end
|
19
|
+
|
20
|
+
alias kosher? available?
|
9
21
|
end
|
10
22
|
end
|
data/lib/kosher/version.rb
CHANGED
data/test/kosher_test.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'minitest/autorun'
|
2
2
|
require_relative '../lib/kosher'
|
3
|
+
|
3
4
|
begin
|
4
5
|
require 'pry'
|
5
6
|
rescue LoadError
|
@@ -8,14 +9,43 @@ end
|
|
8
9
|
include Kosher
|
9
10
|
|
10
11
|
class TestKosher < MiniTest::Unit::TestCase
|
11
|
-
def
|
12
|
-
|
13
|
-
assert_equal '$1.00', unit.price.format
|
12
|
+
def test_new_condition
|
13
|
+
condition = Condition.new
|
14
14
|
|
15
|
-
|
16
|
-
|
15
|
+
condition.grade = 1
|
16
|
+
assert condition.new?
|
17
17
|
|
18
|
+
condition.grade = 2
|
19
|
+
refute condition.new?
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_fast_shipping
|
23
|
+
shipping = Shipping.new
|
24
|
+
refute shipping.fast?
|
25
|
+
|
26
|
+
shipping.fast = true
|
27
|
+
assert shipping.fast?
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_kosher_offer
|
31
|
+
condition = Condition.new
|
32
|
+
seller = Seller.new
|
33
|
+
shipping = Shipping.new
|
34
|
+
offer = Offer.new(condition: condition,
|
35
|
+
seller: seller,
|
36
|
+
shipping: shipping)
|
37
|
+
refute offer.kosher?
|
38
|
+
|
39
|
+
condition.kosher = true
|
40
|
+
seller.kosher = true
|
41
|
+
assert offer.kosher?
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_offer_price
|
45
|
+
unit = Unit.new(cents: 100, currency: 'USD')
|
46
|
+
ship = Shipping.new(cents: 100, currency: 'USD')
|
18
47
|
offer = Offer.new(unit: unit, shipping: ship)
|
19
|
-
assert_equal
|
48
|
+
assert_equal 200, offer.price.cents
|
49
|
+
assert_equal 'USD', offer.price.currency.iso_code
|
20
50
|
end
|
21
51
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kosher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.17.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-01-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: certainty
|
16
|
-
requirement: &
|
16
|
+
requirement: &70278985306100 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,29 +21,29 @@ dependencies:
|
|
21
21
|
version: '0.2'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70278985306100
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: money
|
27
|
-
requirement: &
|
27
|
+
requirement: &70278985305620 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '4.0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70278985305620
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: structure
|
38
|
-
requirement: &
|
38
|
+
requirement: &70278985305180 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: '0.
|
43
|
+
version: '0.24'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70278985305180
|
47
47
|
description:
|
48
48
|
email: code@papercavalier.com
|
49
49
|
executables: []
|
@@ -58,7 +58,9 @@ files:
|
|
58
58
|
- Rakefile
|
59
59
|
- kosher.gemspec
|
60
60
|
- lib/kosher.rb
|
61
|
+
- lib/kosher/condition.rb
|
61
62
|
- lib/kosher/offer.rb
|
63
|
+
- lib/kosher/seller.rb
|
62
64
|
- lib/kosher/shipping.rb
|
63
65
|
- lib/kosher/unit.rb
|
64
66
|
- lib/kosher/version.rb
|
@@ -83,9 +85,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
85
|
version: '0'
|
84
86
|
requirements: []
|
85
87
|
rubyforge_project:
|
86
|
-
rubygems_version: 1.8.
|
88
|
+
rubygems_version: 1.8.11
|
87
89
|
signing_key:
|
88
90
|
specification_version: 3
|
89
91
|
summary: A filter
|
90
92
|
test_files:
|
91
93
|
- test/kosher_test.rb
|
94
|
+
has_rdoc:
|