kosher 0.2.19 → 0.2.20
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/Gemfile +3 -0
- data/kosher.gemspec +2 -4
- data/lib/kosher/human_readable.rb +4 -0
- data/lib/kosher/offer.rb +23 -6
- data/lib/kosher/version.rb +1 -1
- data/lib/kosher.rb +1 -0
- data/spec/kosher/human_readable_spec.rb +5 -0
- data/spec/kosher/offer_spec.rb +1 -1
- metadata +7 -26
data/Gemfile
CHANGED
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
|
13
|
-
s.description = %q{Kosher is a somewhat overengineered attempt to abstract
|
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")
|
data/lib/kosher/offer.rb
CHANGED
@@ -1,31 +1,48 @@
|
|
1
1
|
module Kosher
|
2
|
-
|
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
|
13
|
-
|
20
|
+
if kosher? != other.kosher?
|
21
|
+
kosher? ? -1 : 1
|
14
22
|
else
|
15
|
-
|
23
|
+
exchanged_price <=> other.exchanged_price
|
16
24
|
end
|
17
25
|
end
|
18
26
|
|
19
|
-
|
20
|
-
|
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
|
data/lib/kosher/version.rb
CHANGED
data/lib/kosher.rb
CHANGED
data/spec/kosher/offer_spec.rb
CHANGED
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.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-
|
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
|
-
|
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
|
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
|