sbfaulkner-sequel_container 1.1.1 → 1.2.0

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/README.markdown CHANGED
@@ -33,15 +33,18 @@ Install the gem(s):
33
33
 
34
34
  ## CHANGES
35
35
 
36
+ ### 1.2.0
37
+
38
+ - added assignment method
39
+ - automatically store image width and height for image content types
40
+
36
41
  ### 1.1.0
37
42
 
38
43
  - added support for :url option on contains to specify custom url path
39
44
 
40
45
  ## TODO
41
46
 
42
- - include logic for image width and height
43
- - better assignment support (i.e. don't require separate assignment of type and data)
44
- - publish in sequel www/pages/plugins
47
+ - support for assignment other than from rack/sinatra?
45
48
  - other containment types... e.g. filesystem, s3, git?
46
49
 
47
50
  ## Legal
@@ -1,4 +1,5 @@
1
1
  require 'tmpdir'
2
+ require 'image_size'
2
3
 
3
4
  module Sequel
4
5
  module Plugins
@@ -41,6 +42,19 @@ module Sequel
41
42
  end
42
43
  CONTAINED_URL
43
44
 
45
+ class_eval <<-CONTAINED_ASSIGNMENT, __FILE__, __LINE__ + 1
46
+ def #{object}=(value)
47
+ return if value.nil?
48
+ self.#{object}_type = content_type = value[:type]
49
+ self.#{object}_data = data = value[:tempfile].read
50
+ if content_type =~ /^image\\\/.*/
51
+ size = ImageSize.new(data)
52
+ self.#{object}_height = size.height
53
+ self.#{object}_width = size.width
54
+ end
55
+ end
56
+ CONTAINED_ASSIGNMENT
57
+
44
58
  class_eval <<-CONTAINED_QUERY, __FILE__, __LINE__ + 1
45
59
  def #{object}?
46
60
  !#{object}_type.nil? && !#{object}_type.empty?
@@ -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.1.1"
4
+ s.version = "1.2.0"
5
5
  s.author = "S. Brent Faulkner"
6
6
  s.email = "brentf@unwwwired.net"
7
7
  s.homepage = "http://github.com/sbfaulkner/sequel_container"
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.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - S. Brent Faulkner
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-03 00:00:00 -08:00
12
+ date: 2009-02-05 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency