has_image 0.4.0.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 725cd9078e85deec963877d58fad024692fcea5f
4
+ data.tar.gz: e996c97cfaff0be72126cac58b18bf2c83b1da67
5
+ SHA512:
6
+ metadata.gz: 0c48d4e99796f7c95a8af21eb173c0b5aaf4b77a8bd6f45845f7eb0fa5ff8151b2a1ae98f08e02fce20971488d42286443e73f55a3a8c3a06b3dec6842132a41
7
+ data.tar.gz: 8db70533b67e2e5dbce98338c84afbe94c0347723d4cc86cf0dbd689653cf305fb1c39a706b42696408a4701a1560b6f0a4c7ea29e5da40dd7aeed6333be380f
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # has\_image - An Image attachment library for Active Record
2
2
 
3
+ ** THIS LIBRARY IS NO LONGER MAINTAINED OR SUPPORTED **
4
+
3
5
  The has\_image library extends Active Record to allow Rails applications to have
4
6
  attached images. It is very small and lightweight: it only requires one column
5
7
  in your model to store the uploaded image's file name.
@@ -6,7 +6,6 @@ unless "".respond_to? :to_param
6
6
  require "active_support/core_ext/object/blank"
7
7
  require "active_support/core_ext/object/to_param"
8
8
  require "active_support/core_ext/numeric/bytes"
9
- require "active_support/core_ext/class/inheritable_attributes"
10
9
  end
11
10
 
12
11
  require 'has_image/processor'
@@ -69,7 +68,7 @@ require 'has_image/view_helpers'
69
68
  # directory. Add something like this to your config/environments/test.rb:
70
69
  #
71
70
  # config.after_initialize do
72
- # MyClass.has_image_options[:base_path] = File.join(RAILS_ROOT, "tmp")
71
+ # MyClass.has_image_options[:base_path] = Rails.root.join("tmp")
73
72
  # end
74
73
  #
75
74
  # If you want to stub out calls to has_image so that your tests don't do
@@ -122,7 +121,7 @@ module HasImage
122
121
  # * :max_size => 12.megabytes,
123
122
  # * :min_size => 4.kilobytes,
124
123
  # * :path_prefix => klass.table_name,
125
- # * :base_path => File.join(RAILS_ROOT, 'public'),
124
+ # * :base_path => Rails.root.join('public'),
126
125
  # * :column => :has_image_file,
127
126
  # * :convert_to => "JPEG",
128
127
  # * :output_quality => "85",
@@ -138,7 +137,7 @@ module HasImage
138
137
  :max_size => 12.megabytes,
139
138
  :min_size => 4.kilobytes,
140
139
  :path_prefix => klass.table_name,
141
- :base_path => File.join(RAILS_ROOT, 'public'),
140
+ :base_path => Rails.root.join('public'),
142
141
  :column => :has_image_file,
143
142
  :convert_to => "JPEG",
144
143
  :output_quality => "85",
@@ -170,14 +169,14 @@ module HasImage
170
169
  def has_image(options = {})
171
170
  options.assert_valid_keys(HasImage.default_options_for(self).keys)
172
171
  options = HasImage.default_options_for(self).merge(options)
173
- class_inheritable_accessor :has_image_options
174
- write_inheritable_attribute(:has_image_options, options)
172
+ class_attribute :has_image_options
173
+ self.has_image_options = options
175
174
 
176
175
  after_create :install_images
177
176
  after_save :update_images
178
177
  after_destroy :remove_images
179
178
 
180
- validate_on_create :image_data_valid?
179
+ validate :image_data_valid?, :on => :create
181
180
 
182
181
  include ModelInstanceMethods
183
182
  extend ModelClassMethods
@@ -78,7 +78,7 @@ module HasImage
78
78
  rescue MiniMagick::Invalid
79
79
  raise ProcessorError.new("#{path} doesn't look like an image file.")
80
80
  ensure
81
- image.tempfile.close! if defined?(image) && image
81
+ image.tempfile.close! if defined?(image) && image && image.repond_to?(:tempfile)
82
82
  end
83
83
  end
84
84
  end
@@ -11,8 +11,8 @@ module HasImage
11
11
  # storage mechanism for Amazon AWS, Photobucket, DBFile, SFTP, or whatever
12
12
  # you want.
13
13
  class Storage
14
- class_inheritable_accessor :thumbnail_separator
15
- write_inheritable_attribute :thumbnail_separator, '_'
14
+ class_attribute :thumbnail_separator
15
+ self.thumbnail_separator = '_'
16
16
 
17
17
  attr_accessor :image_data, :options, :temp_file
18
18
 
@@ -62,7 +62,7 @@ module HasImage
62
62
  @temp_file = image_data
63
63
  else
64
64
  image_data.rewind
65
- @temp_file = Tempfile.new 'has_image_data_%s' % Storage.generated_file_name
65
+ @temp_file = Tempfile.new 'has_image_data_%s' % Storage.generated_file_name, :encoding => 'ascii-8bit'
66
66
  @temp_file.write(image_data.read)
67
67
  end
68
68
  end
@@ -1,3 +1,3 @@
1
1
  module HasImage
2
- VERSION = "0.4.0.1"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -9,12 +9,12 @@ class ComplexPicTest < Test::Unit::TestCase
9
9
  # Note: Be sure to not set the whole options hash in your tests below
10
10
  ComplexPic.has_image_options = HasImage.default_options_for(ComplexPic)
11
11
  ComplexPic.has_image_options[:column] = :filename
12
- ComplexPic.has_image_options[:base_path] = File.join(RAILS_ROOT, 'tmp')
12
+ ComplexPic.has_image_options[:base_path] = Rails.root.join('tmp')
13
13
  ComplexPic.has_image_options[:resize_to] = nil
14
14
  end
15
15
 
16
16
  def teardown
17
- FileUtils.rm_rf(File.join(RAILS_ROOT, 'tmp', 'complex_pics'))
17
+ FileUtils.rm_rf(Rails.root.join('tmp', 'complex_pics'))
18
18
  end
19
19
 
20
20
  def test_should_save_width_to_db_on_create
@@ -13,11 +13,11 @@ class PicTest < Test::Unit::TestCase
13
13
  def setup
14
14
  # Note: Be sure to not set the whole options hash in your tests below
15
15
  Pic.has_image_options = HasImage.default_options_for(Pic)
16
- Pic.has_image_options[:base_path] = File.join(RAILS_ROOT, 'tmp')
16
+ Pic.has_image_options[:base_path] = Rails.root.join('tmp')
17
17
  end
18
18
 
19
19
  def teardown
20
- FileUtils.rm_rf(File.join(RAILS_ROOT, 'tmp', 'pics'))
20
+ FileUtils.rm_rf(Rails.root.join('tmp', 'pics'))
21
21
  end
22
22
 
23
23
  def test_should_be_valid
@@ -7,11 +7,17 @@ require 'mocha'
7
7
  require "active_record"
8
8
  require "logger"
9
9
  require "rack/test"
10
+ require "pathname"
10
11
 
11
12
  $LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
12
13
  require "has_image"
13
14
 
14
- RAILS_ROOT = File.join(File.dirname(__FILE__), '..', 'tmp')
15
+ module Rails
16
+ extend self
17
+ def root
18
+ Pathname(File.join(File.dirname(__FILE__), '..', 'tmp'))
19
+ end
20
+ end
15
21
 
16
22
  ActiveRecord::Base.logger = Logger.new($stdout) if ENV["LOG"]
17
23
  ActiveRecord::Migration.verbose = false
metadata CHANGED
@@ -1,91 +1,81 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: has_image
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 4
8
- - 0
9
- - 1
10
- version: 0.4.0.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.0
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Norman Clarke
14
- - "Adri\xC3\xA1n Mugnolo"
8
+ - Adrián Mugnolo
15
9
  autorequire:
16
10
  bindir: bin
17
11
  cert_chain: []
18
-
19
- date: 2010-09-29 00:00:00 -03:00
20
- default_executable:
21
- dependencies:
22
- - !ruby/object:Gem::Dependency
12
+ date: 2010-09-29 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
23
15
  name: mini_magick
24
- prerelease: false
25
- requirement: &id001 !ruby/object:Gem::Requirement
26
- none: false
27
- requirements:
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
28
18
  - - ~>
29
- - !ruby/object:Gem::Version
30
- segments:
31
- - 2
32
- - 1
33
- version: "2.1"
19
+ - !ruby/object:Gem::Version
20
+ version: '2.1'
34
21
  type: :runtime
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- name: activesupport
38
22
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
40
- none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- segments:
45
- - 2
46
- - 1
47
- version: "2.1"
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ version: '2.1'
28
+ - !ruby/object:Gem::Dependency
29
+ name: activesupport
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '2.1'
48
35
  type: :runtime
49
- version_requirements: *id002
50
- - !ruby/object:Gem::Dependency
51
- name: activerecord
52
36
  prerelease: false
53
- requirement: &id003 !ruby/object:Gem::Requirement
54
- none: false
55
- requirements:
56
- - - ">="
57
- - !ruby/object:Gem::Version
58
- segments:
59
- - 2
60
- - 1
61
- version: "2.1"
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '2.1'
42
+ - !ruby/object:Gem::Dependency
43
+ name: activerecord
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '2.1'
62
49
  type: :runtime
63
- version_requirements: *id003
64
- - !ruby/object:Gem::Dependency
65
- name: mocha
66
50
  prerelease: false
67
- requirement: &id004 !ruby/object:Gem::Requirement
68
- none: false
69
- requirements:
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '2.1'
56
+ - !ruby/object:Gem::Dependency
57
+ name: mocha
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
70
60
  - - ~>
71
- - !ruby/object:Gem::Version
72
- segments:
73
- - 0
74
- - 9
75
- version: "0.9"
61
+ - !ruby/object:Gem::Version
62
+ version: '0.9'
76
63
  type: :development
77
- version_requirements: *id004
78
- description: Has_image is a Ruby on Rails gem/plugin that allows you to attach images to Active Record models.
79
- email:
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '0.9'
70
+ description: Has_image is a Ruby on Rails gem/plugin that allows you to attach images
71
+ to Active Record models.
72
+ email:
80
73
  - norman@njclarke.com
81
74
  - adrian@mugnolo.com
82
75
  executables: []
83
-
84
76
  extensions: []
85
-
86
77
  extra_rdoc_files: []
87
-
88
- files:
78
+ files:
89
79
  - lib/has_image/processor.rb
90
80
  - lib/has_image/railtie.rb
91
81
  - lib/has_image/storage.rb
@@ -104,37 +94,28 @@ files:
104
94
  - test/processor_test.rb
105
95
  - test/storage_test.rb
106
96
  - test/test_helper.rb
107
- has_rdoc: true
108
97
  homepage: http://github.com/norman/has_image
109
98
  licenses: []
110
-
99
+ metadata: {}
111
100
  post_install_message:
112
101
  rdoc_options: []
113
-
114
- require_paths:
102
+ require_paths:
115
103
  - lib
116
- required_ruby_version: !ruby/object:Gem::Requirement
117
- none: false
118
- requirements:
119
- - - ">="
120
- - !ruby/object:Gem::Version
121
- segments:
122
- - 0
123
- version: "0"
124
- required_rubygems_version: !ruby/object:Gem::Requirement
125
- none: false
126
- requirements:
127
- - - ">="
128
- - !ruby/object:Gem::Version
129
- segments:
130
- - 0
131
- version: "0"
104
+ required_ruby_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - '>='
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - '>='
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
132
114
  requirements: []
133
-
134
115
  rubyforge_project: has-image
135
- rubygems_version: 1.3.7
116
+ rubygems_version: 2.0.3
136
117
  signing_key:
137
- specification_version: 3
118
+ specification_version: 4
138
119
  summary: Lets you attach images with thumbnails to Active Record models.
139
120
  test_files: []
140
-
121
+ has_rdoc: true