kosher 0.16.0 → 0.17.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,2 @@
1
1
  rvm:
2
- - 1.9.2
3
2
  - 1.9.3
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
1
  source 'http://rubygems.org'
2
2
  gemspec
3
+
3
4
  gem 'pry' unless ENV['CI']
5
+ gem 'rake'
data/README.md CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  [![travis](http://travis-ci.org/hakanensari/kosher.png)](http://travis-ci.org/hakanensari/kosher)
4
4
 
5
- I filter things.
5
+ A filter.
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
13
13
 
14
14
  {
15
15
  'certainty' => '~> 0.2',
16
- 'money' => '~> 3.7',
17
- 'structure' => '~> 0.22'
16
+ 'money' => '~> 4.0',
17
+ 'structure' => '~> 0.24'
18
18
  }.each do |lib, version|
19
19
  s.add_runtime_dependency lib, version
20
20
  end
@@ -2,15 +2,8 @@ require 'certainty'
2
2
  require 'money'
3
3
  require 'structure'
4
4
 
5
- class Structure
6
- end
7
-
8
- module Kosher
9
- autoload :Condition, 'kosher/condition'
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'
@@ -0,0 +1,15 @@
1
+ module Kosher
2
+ class Condition < Structure
3
+ key :description
4
+ key :grade
5
+ key :kosher, default: false
6
+
7
+ def kosher?
8
+ Boolean(kosher)
9
+ end
10
+
11
+ def new?
12
+ grade == 1
13
+ end
14
+ end
15
+ end
@@ -2,14 +2,11 @@ module Kosher
2
2
  class Offer < Structure
3
3
  include Comparable
4
4
 
5
- key :kosher, Boolean
6
- key :new, Boolean
7
- key :shipping, Shipping
8
- key :seller
9
- key :unit, Unit
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
@@ -0,0 +1,11 @@
1
+ module Kosher
2
+ class Seller < Structure
3
+ key :location
4
+ key :name
5
+ key :kosher, default: false
6
+
7
+ def kosher?
8
+ Boolean(kosher)
9
+ end
10
+ end
11
+ end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Kosher
2
- VERSION = '0.16.0'
2
+ VERSION = '0.17.0'
3
3
  end
@@ -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 test_prices
12
- unit = Unit.new(cents: 100, currency: 'USD')
13
- assert_equal '$1.00', unit.price.format
12
+ def test_new_condition
13
+ condition = Condition.new
14
14
 
15
- ship = Shipping.new(cents: 100, currency: 'USD')
16
- assert_equal '$1.00', ship.cost.format
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 '$2.00', offer.price.format
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.16.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: 2011-10-27 00:00:00.000000000 Z
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: &70249913314080 !ruby/object:Gem::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: *70249913314080
24
+ version_requirements: *70278985306100
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: money
27
- requirement: &70249913313320 !ruby/object:Gem::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: '3.7'
32
+ version: '4.0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70249913313320
35
+ version_requirements: *70278985305620
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: structure
38
- requirement: &70249913312280 !ruby/object:Gem::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.22'
43
+ version: '0.24'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70249913312280
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.10
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: