kosher 0.2.19 → 0.2.20

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,3 +1,6 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
+ gem 'rspec', '~> 2.5.0'
4
+ gem 'ruby-debug19', '~> 0.11.6'
5
+
3
6
  gemspec
data/kosher.gemspec CHANGED
@@ -9,14 +9,12 @@ Gem::Specification.new do |s|
9
9
  s.authors = ['Paper Cavalier']
10
10
  s.email = 'code@papercavalier.com'
11
11
  s.homepage = 'https://rubygems.org/gems/kosher'
12
- s.summary = %q{A somewhat overengineered attempt to abstract bookdealing into a set of models}
13
- s.description = %q{Kosher is a somewhat overengineered attempt to abstract bookdealing into a set of models.}
12
+ s.summary = %q{A somewhat overengineered attempt to abstract bookselling into a set of models}
13
+ s.description = %q{Kosher is a somewhat overengineered attempt to abstract bookselling into a set of models.}
14
14
 
15
15
  s.rubyforge_project = 'kosher'
16
16
 
17
17
  s.add_dependency('money', '~> 3.6.1')
18
- s.add_development_dependency('rspec', '~> 2.5.0')
19
- s.add_development_dependency('ruby-debug19', '~> 0.11.6')
20
18
 
21
19
  s.files = `git ls-files`.split("\n")
22
20
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -0,0 +1,4 @@
1
+ module Kosher
2
+ class HumanReadable < Struct.new(:price, :description)
3
+ end
4
+ end
data/lib/kosher/offer.rb CHANGED
@@ -1,31 +1,48 @@
1
1
  module Kosher
2
- class Offer < Struct.new(:id, :item, :seller, :shipping)
2
+
3
+ # A used or new offer of a book by a dealer or store.
4
+ class Offer < Struct.new(:id, :item, :seller, :shipping, :human_readable)
3
5
  include Comparable
4
6
 
5
7
  class << self
8
+
9
+ # The base currency.
6
10
  attr_accessor :base_currency
7
11
  end
8
12
 
9
13
  self.base_currency = 'EUR'
10
14
 
15
+ # Compares offer with another offer.
16
+ #
17
+ # A kosher offer is better than an unkosher offer. If both offers are
18
+ # kosher or unkosher, a lower-priced offer is better.
11
19
  def <=>(other)
12
- if self.kosher? != other.kosher?
13
- self.kosher? ? -1 : 1
20
+ if kosher? != other.kosher?
21
+ kosher? ? -1 : 1
14
22
  else
15
- self.price.exchange_to(base_currency) <=> other.price.exchange_to(base_currency)
23
+ exchanged_price <=> other.exchanged_price
16
24
  end
17
25
  end
18
26
 
19
- def base_currency
20
- self.class.base_currency
27
+ # The price exchanged to the base currency.
28
+ def exchanged_price
29
+ price.exchange_to(base_currency)
21
30
  end
22
31
 
32
+ # Returns whether the offer is kosher.
23
33
  def kosher?
24
34
  item.kosher? && seller.kosher? && shipping.kosher?
25
35
  end
26
36
 
37
+ # The total price, including the shipping cost.
27
38
  def price
28
39
  item.price + shipping.cost
29
40
  end
41
+
42
+ private
43
+
44
+ def base_currency
45
+ self.class.base_currency
46
+ end
30
47
  end
31
48
  end
@@ -1,3 +1,3 @@
1
1
  module Kosher
2
- VERSION = '0.2.19'
2
+ VERSION = '0.2.20'
3
3
  end
data/lib/kosher.rb CHANGED
@@ -8,6 +8,7 @@ require 'kosher/condition'
8
8
  require 'kosher/description'
9
9
  require 'kosher/item'
10
10
  require 'kosher/location'
11
+ require 'kosher/human_readable'
11
12
  require 'kosher/offer'
12
13
  require 'kosher/seller'
13
14
  require 'kosher/shipping'
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ module Kosher
4
+ describe HumanReadable
5
+ end
@@ -11,7 +11,7 @@ module Kosher
11
11
 
12
12
  describe "#base_currency" do
13
13
  it "defaults to EUR" do
14
- @offer.base_currency.should eql 'EUR'
14
+ @offer.send(:base_currency).should eql 'EUR'
15
15
  end
16
16
  end
17
17
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: kosher
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.19
5
+ version: 0.2.20
6
6
  platform: ruby
7
7
  authors:
8
8
  - Paper Cavalier
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-03-19 00:00:00 +00:00
13
+ date: 2011-04-01 00:00:00 +01:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -24,29 +24,7 @@ dependencies:
24
24
  version: 3.6.1
25
25
  type: :runtime
26
26
  version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
28
- name: rspec
29
- prerelease: false
30
- requirement: &id002 !ruby/object:Gem::Requirement
31
- none: false
32
- requirements:
33
- - - ~>
34
- - !ruby/object:Gem::Version
35
- version: 2.5.0
36
- type: :development
37
- version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
39
- name: ruby-debug19
40
- prerelease: false
41
- requirement: &id003 !ruby/object:Gem::Requirement
42
- none: false
43
- requirements:
44
- - - ~>
45
- - !ruby/object:Gem::Version
46
- version: 0.11.6
47
- type: :development
48
- version_requirements: *id003
49
- description: Kosher is a somewhat overengineered attempt to abstract bookdealing into a set of models.
27
+ description: Kosher is a somewhat overengineered attempt to abstract bookselling into a set of models.
50
28
  email: code@papercavalier.com
51
29
  executables: []
52
30
 
@@ -66,6 +44,7 @@ files:
66
44
  - lib/kosher/book.rb
67
45
  - lib/kosher/condition.rb
68
46
  - lib/kosher/description.rb
47
+ - lib/kosher/human_readable.rb
69
48
  - lib/kosher/item.rb
70
49
  - lib/kosher/location.rb
71
50
  - lib/kosher/offer.rb
@@ -77,6 +56,7 @@ files:
77
56
  - spec/kosher/book_spec.rb
78
57
  - spec/kosher/condition_spec.rb
79
58
  - spec/kosher/description_spec.rb
59
+ - spec/kosher/human_readable_spec.rb
80
60
  - spec/kosher/item_spec.rb
81
61
  - spec/kosher/location_spec.rb
82
62
  - spec/kosher/offer_spec.rb
@@ -110,12 +90,13 @@ rubyforge_project: kosher
110
90
  rubygems_version: 1.5.2
111
91
  signing_key:
112
92
  specification_version: 3
113
- summary: A somewhat overengineered attempt to abstract bookdealing into a set of models
93
+ summary: A somewhat overengineered attempt to abstract bookselling into a set of models
114
94
  test_files:
115
95
  - spec/kosher/availability_spec.rb
116
96
  - spec/kosher/book_spec.rb
117
97
  - spec/kosher/condition_spec.rb
118
98
  - spec/kosher/description_spec.rb
99
+ - spec/kosher/human_readable_spec.rb
119
100
  - spec/kosher/item_spec.rb
120
101
  - spec/kosher/location_spec.rb
121
102
  - spec/kosher/offer_spec.rb