kosher 0.13.0 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -5
- data/lib/kosher/filter.rb +2 -1
- data/lib/kosher/offer.rb +2 -3
- data/lib/kosher/price.rb +0 -2
- data/lib/kosher/version.rb +1 -1
- data/lib/kosher.rb +14 -7
- data/test/kosher_test.rb +5 -8
- metadata +12 -12
data/Gemfile
CHANGED
data/lib/kosher/filter.rb
CHANGED
data/lib/kosher/offer.rb
CHANGED
data/lib/kosher/price.rb
CHANGED
data/lib/kosher/version.rb
CHANGED
data/lib/kosher.rb
CHANGED
@@ -1,21 +1,28 @@
|
|
1
1
|
require 'active_model'
|
2
|
+
require 'certainty'
|
3
|
+
require 'money'
|
2
4
|
require 'structure'
|
3
5
|
|
4
|
-
|
5
|
-
class
|
6
|
+
class Structure
|
7
|
+
class InvalidRecord < StandardError
|
6
8
|
def initialize(record)
|
7
|
-
|
9
|
+
msg = record.errors.full_messages.join(', ')
|
10
|
+
super msg
|
8
11
|
end
|
9
12
|
end
|
10
|
-
end
|
11
13
|
|
12
|
-
|
14
|
+
include ActiveModel::Conversion
|
13
15
|
include ActiveModel::Validations
|
16
|
+
extend ActiveModel::Naming
|
17
|
+
|
18
|
+
def persisted?
|
19
|
+
false
|
20
|
+
end
|
14
21
|
|
15
22
|
private
|
16
23
|
|
17
|
-
def
|
18
|
-
raise
|
24
|
+
def raise_error_if_invalid
|
25
|
+
raise InvalidRecord.new(self) if invalid?
|
19
26
|
end
|
20
27
|
end
|
21
28
|
|
data/test/kosher_test.rb
CHANGED
@@ -4,7 +4,7 @@ require 'minitest/autorun'
|
|
4
4
|
require_relative '../lib/kosher'
|
5
5
|
|
6
6
|
begin
|
7
|
-
require '
|
7
|
+
require 'pry'
|
8
8
|
rescue LoadError
|
9
9
|
end
|
10
10
|
|
@@ -35,21 +35,21 @@ class TestKosher < MiniTest::Unit::TestCase
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def test_validation
|
38
|
-
assert_raises(
|
38
|
+
assert_raises(Structure::InvalidRecord) { Detail.new.kosher? }
|
39
39
|
detail = Detail.new(:condition => 1)
|
40
40
|
assert detail.kosher?
|
41
41
|
|
42
|
-
assert_raises(
|
42
|
+
assert_raises(Structure::InvalidRecord) { Shipping.new.kosher? }
|
43
43
|
shipping = Shipping.new(:available => true,
|
44
44
|
:cents => 100,
|
45
45
|
:currency => 'USD')
|
46
46
|
assert shipping.kosher?
|
47
47
|
|
48
|
-
assert_raises(
|
48
|
+
assert_raises(Structure::InvalidRecord) { Seller.new.kosher? }
|
49
49
|
seller = Seller.new(:name => 'John Doe')
|
50
50
|
assert seller.kosher?
|
51
51
|
|
52
|
-
assert_raises(
|
52
|
+
assert_raises(Structure::InvalidRecord) { Offer.new.kosher? }
|
53
53
|
offer = Offer.new(:detail => detail,
|
54
54
|
:shipping => shipping,
|
55
55
|
:seller => seller,
|
@@ -62,9 +62,6 @@ class TestKosher < MiniTest::Unit::TestCase
|
|
62
62
|
assert_kind_of Venue, Venue.first
|
63
63
|
assert 'Amazon.com', Venue.find(1).name
|
64
64
|
assert_nil Venue.find(0)
|
65
|
-
end
|
66
|
-
|
67
|
-
def test_amazon_venues
|
68
65
|
assert_equal 8, Venue.amazon.size
|
69
66
|
end
|
70
67
|
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.14.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-
|
12
|
+
date: 2011-09-01 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
16
|
-
requirement: &
|
16
|
+
requirement: &70220208537540 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '3.0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70220208537540
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: certainty
|
27
|
-
requirement: &
|
27
|
+
requirement: &70220208537060 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0.2'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70220208537060
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: money
|
38
|
-
requirement: &
|
38
|
+
requirement: &70220208536620 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '3.7'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70220208536620
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: structure
|
49
|
-
requirement: &
|
49
|
+
requirement: &70220208536180 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '0.19'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70220208536180
|
58
58
|
description: Online selling, abstracted
|
59
59
|
email: code@papercavalier.com
|
60
60
|
executables: []
|
@@ -94,7 +94,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
94
94
|
version: '0'
|
95
95
|
segments:
|
96
96
|
- 0
|
97
|
-
hash:
|
97
|
+
hash: 2912901122408052777
|
98
98
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
99
|
none: false
|
100
100
|
requirements:
|
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
103
|
version: '0'
|
104
104
|
segments:
|
105
105
|
- 0
|
106
|
-
hash:
|
106
|
+
hash: 2912901122408052777
|
107
107
|
requirements: []
|
108
108
|
rubyforge_project:
|
109
109
|
rubygems_version: 1.8.6
|