sbfaulkner-sequel_container 1.0.2 → 1.0.3

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.
@@ -15,22 +15,28 @@ module Sequel
15
15
 
16
16
  class_eval <<-CONTAINED_PATH, __FILE__, __LINE__ + 1
17
17
  def #{object}_path
18
- return if #{object}_data.nil? || #{object}_data.empty?
18
+ return unless #{object}?
19
19
  @#{object}_path ||= write_#{object}
20
20
  end
21
21
  CONTAINED_PATH
22
22
 
23
23
  class_eval <<-CONTAINED_URL, __FILE__, __LINE__ + 1
24
24
  def #{object}_url
25
- return if #{object}_data.nil? || #{object}_data.empty?
25
+ return unless #{object}?
26
26
  @#{object}_path ||= write_#{object}
27
27
  @#{object}_url ||= "/#{container}/\#{id}/\#{#{object}_filename}"
28
28
  end
29
29
  CONTAINED_URL
30
30
 
31
+ class_eval <<-CONTAINED_QUERY, __FILE__, __LINE__ + 1
32
+ def #{object}?
33
+ !#{object}_data.nil?
34
+ end
35
+ CONTAINED_QUERY
36
+
31
37
  class_eval <<-CONTAINED_IMAGE, __FILE__, __LINE__ + 1
32
38
  def #{object}_image?
33
- #{object}_type[0,6] == 'image/'
39
+ #{object}? && #{object}_type[0,6] == 'image/'
34
40
  end
35
41
  CONTAINED_IMAGE
36
42
 
@@ -1,7 +1,7 @@
1
1
  SPEC = Gem::Specification.new do |s|
2
2
  # identify the gem
3
3
  s.name = "sequel_container"
4
- s.version = "1.0.2"
4
+ s.version = "1.0.3"
5
5
  s.author = "S. Brent Faulkner"
6
6
  s.email = "brentf@unwwwired.net"
7
7
  s.homepage = "http://github.com/sbfaulkner/sequel_container"
@@ -32,16 +32,19 @@ class SequelCascadingTest < Test::Unit::TestCase
32
32
  def test_should_create_empty_container
33
33
  company = Company.create
34
34
  assert company.reload
35
+ assert !company.logo?
35
36
  assert_nil company.logo_type
36
37
  assert_nil company.logo_data
37
38
  assert_nil company.logo_path
38
39
  assert_nil company.logo_url
40
+ assert !company.logo_image?
39
41
  end
40
42
 
41
43
  def test_should_contain_image
42
44
  logo = File.read(File.dirname(__FILE__)+'/data/logo.gif')
43
45
  company = Company.create :logo_type => 'image/gif', :logo_data => logo
44
46
  assert company.reload
47
+ assert company.logo?
45
48
  assert company.logo_image?
46
49
  assert_equal logo, company.logo_data
47
50
  assert_equal Dir.tmpdir+"/companies/#{company.id}/logo.gif", company.logo_path
@@ -52,6 +55,7 @@ class SequelCascadingTest < Test::Unit::TestCase
52
55
  bio = File.read(File.dirname(__FILE__)+'/data/bio.txt')
53
56
  company = Company.create :biography_type => 'text/plain', :biography_data => bio
54
57
  assert company.reload
58
+ assert company.biography?
55
59
  assert !company.biography_image?
56
60
  assert_equal bio, company.biography_data
57
61
  assert_equal Dir.tmpdir+"/companies/#{company.id}/biography.txt", company.biography_path
@@ -62,6 +66,7 @@ class SequelCascadingTest < Test::Unit::TestCase
62
66
  bio = File.read(File.dirname(__FILE__)+'/data/bio.html')
63
67
  company = Company.create :biography_type => 'text/html', :biography_data => bio
64
68
  assert company.reload
69
+ assert company.biography?
65
70
  assert !company.biography_image?
66
71
  assert_equal bio, company.biography_data
67
72
  assert_equal Dir.tmpdir+"/companies/#{company.id}/biography.html", company.biography_path
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sbfaulkner-sequel_container
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - S. Brent Faulkner