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 CHANGED
@@ -1,8 +1,4 @@
1
1
  source 'http://rubygems.org'
2
-
3
2
  gemspec
4
3
  gem 'rake'
5
-
6
- unless ENV['CI']
7
- gem 'ruby-debug19', :platforms => :mri_19
8
- end
4
+ gem 'pry' unless ENV['CI']
data/lib/kosher/filter.rb CHANGED
@@ -5,7 +5,8 @@ module Kosher
5
5
  end
6
6
 
7
7
  def kosher?
8
- validate!
8
+ raise_error_if_invalid
9
+
9
10
  kosher
10
11
  end
11
12
  end
data/lib/kosher/offer.rb CHANGED
@@ -1,5 +1,3 @@
1
- require 'certainty'
2
-
3
1
  require 'kosher/filter'
4
2
  require 'kosher/price'
5
3
 
@@ -31,7 +29,8 @@ module Kosher
31
29
  end
32
30
 
33
31
  def kosher?
34
- validate!
32
+ raise_error_if_invalid
33
+
35
34
  [seller, shipping, detail].all?(&:kosher?)
36
35
  end
37
36
 
data/lib/kosher/price.rb CHANGED
@@ -1,5 +1,3 @@
1
- require 'money'
2
-
3
1
  module Kosher
4
2
  module Price
5
3
  def self.included(base)
@@ -1,3 +1,3 @@
1
1
  module Kosher
2
- VERSION = '0.13.0'
2
+ VERSION = '0.14.0'
3
3
  end
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
- module Kosher
5
- class NotValid < StandardError
6
+ class Structure
7
+ class InvalidRecord < StandardError
6
8
  def initialize(record)
7
- super(record.errors.full_messages.join(', '))
9
+ msg = record.errors.full_messages.join(', ')
10
+ super msg
8
11
  end
9
12
  end
10
- end
11
13
 
12
- class Structure
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 validate!
18
- raise NotValid.new(self) unless valid?
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 'ruby-debug'
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(NotValid) { Detail.new.kosher? }
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(NotValid) { Shipping.new.kosher? }
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(NotValid) { Seller.new.kosher? }
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(NotValid) { Offer.new.kosher? }
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.13.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-08-27 00:00:00.000000000Z
12
+ date: 2011-09-01 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel
16
- requirement: &70322729328200 !ruby/object:Gem::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: *70322729328200
24
+ version_requirements: *70220208537540
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: certainty
27
- requirement: &70322729327560 !ruby/object:Gem::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: *70322729327560
35
+ version_requirements: *70220208537060
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: money
38
- requirement: &70322729326860 !ruby/object:Gem::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: *70322729326860
46
+ version_requirements: *70220208536620
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: structure
49
- requirement: &70322729326360 !ruby/object:Gem::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: *70322729326360
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: -2784991868490813803
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: -2784991868490813803
106
+ hash: 2912901122408052777
107
107
  requirements: []
108
108
  rubyforge_project:
109
109
  rubygems_version: 1.8.6