tvdeyen-fleximage 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,7 +7,6 @@ require 'RMagick' unless defined?(Magick)
7
7
  # Apply a few RMagick patches
8
8
  require 'fleximage/rmagick_image_patch'
9
9
 
10
- # Load dsl_accessor from lib
11
10
  require 'dsl_accessor'
12
11
 
13
12
  # Load Operators
@@ -53,5 +52,5 @@ ActionController::Base.class_eval{ include Fleximage::AviaryController }
53
52
 
54
53
  # Register mime types
55
54
  Mime::Type.register "image/jpeg", :jpg, ["image/pjpeg"], ["jpeg"]
56
- Mime::Type.register "image/gif", :gif
57
- Mime::Type.register "image/png", :png
55
+ Mime::Type.register "image/gif", :gif if Rails.version.to_f <= 3.1
56
+ Mime::Type.register "image/png", :png if Rails.version.to_f <= 3.1
@@ -119,7 +119,7 @@ module Fleximage
119
119
  # Put uploads from different days into different subdirectories
120
120
  dsl_accessor :use_creation_date_based_directories, :default => true
121
121
 
122
- # The format are master images are stored in
122
+ # The format that master images are stored in
123
123
  dsl_accessor :image_storage_format, :default => Proc.new { :png }
124
124
 
125
125
  # Require a valid image. Defaults to true. Set to false if its ok to have no image for
@@ -166,13 +166,13 @@ module Fleximage
166
166
  # Image too small message
167
167
  # Should include {{minimum}}
168
168
  def self.image_too_small_message(str = nil)
169
- fb = "is too small (Minimum: {{minimum}})"
169
+ fb = "is too small (Minimum: %{minimum})"
170
170
  if str.nil?
171
171
  minimum_size = Fleximage::Operator::Base.size_to_xy(validates_image_size).join('x')
172
172
  if @image_too_small_message
173
- @image_too_small_message.gsub("{{minimum}}", minimum_size)
173
+ @image_too_small_message.gsub("%{minimum}", minimum_size)
174
174
  else
175
- translate_error_message("image_too_small", fb.gsub("{{minimum}}", minimum_size), :minimum => minimum_size)
175
+ translate_error_message("image_too_small", fb.gsub("%{minimum}", minimum_size), :minimum => minimum_size)
176
176
  end
177
177
  else
178
178
  @image_too_small_message = str
@@ -0,0 +1,3 @@
1
+ module Fleximage
2
+ VERSION = '1.2.0'
3
+ end
@@ -4,4 +4,4 @@ de:
4
4
  messages:
5
5
  missing_image: ist erforderlich
6
6
  invalid_image: war nicht lesbar
7
- image_too_small: "ist zu klein (Minimalgröße: {{minimum}})"
7
+ image_too_small: "ist zu klein (Minimalgröße: %{minimum})"
@@ -5,4 +5,4 @@ en:
5
5
  photo_custom_error:
6
6
  missing_image: needs to be attached
7
7
  invalid_image: seems to be broken
8
- image_too_small: "must be bigger (min. size: {{minimum}})"
8
+ image_too_small: "must be bigger (min. size: %{minimum})"
@@ -5,6 +5,6 @@ class PhotoCustomError < ActiveRecord::Base
5
5
  validates_image_size '2x2'
6
6
  missing_image_message "needs to be attached"
7
7
  invalid_image_message "seems to be broken"
8
- image_too_small_message "must be bigger (min. size: {{minimum}})"
8
+ image_too_small_message "must be bigger (min. size: %{minimum})"
9
9
  end
10
10
  end
@@ -9,12 +9,7 @@ silence_warnings { RAILS_ENV = ENV['RAILS_ENV'] }
9
9
  # Run the migrations
10
10
  ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate")
11
11
 
12
- # Setup the fixtures path
13
- Test::Unit::TestCase.fixture_path = File.dirname(__FILE__) + "/fixtures/"
14
- $LOAD_PATH.unshift(Test::Unit::TestCase.fixture_path)
15
-
16
12
  require File.dirname(__FILE__) + '/mock_file'
17
- require File.dirname(__FILE__) + '/s3_stubs'
18
13
  require 'open-uri'
19
14
 
20
15
  unless Magick::QuantumDepth == 16
@@ -31,9 +26,6 @@ class Test::Unit::TestCase #:nodoc:
31
26
  Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, table_names)
32
27
  end
33
28
  end
34
-
35
- self.use_transactional_fixtures = true
36
- self.use_instantiated_fixtures = false
37
29
 
38
30
  def files(name)
39
31
  case name
@@ -33,8 +33,4 @@ class FleximageBasicModelTest < Test::Unit::TestCase
33
33
  p = PhotoBare.create(:image_file => files(:photo))
34
34
  assert_equal '/tmp', p.directory_path
35
35
  end
36
-
37
- def test_should_confirm_presence_of_a_store_when_using_s3
38
- assert PhotoS3.has_store?
39
- end
40
36
  end
@@ -10,14 +10,14 @@ class FleximageFileUploadFromLocalTest < Test::Unit::TestCase
10
10
  p = PhotoBare.new
11
11
  assert !p.save, 'Record expected to not be allowed to save'
12
12
  assert_equal 1, p.errors.size
13
- assert_equal 'is required', p.errors.on(:image_file)
13
+ assert_equal 'is required', p.errors.messages[:image_file].join()
14
14
  end
15
15
 
16
16
  def test_should_require_an_valid_image
17
17
  p = PhotoBare.new(:image_file => files(:not_a_photo))
18
18
  assert !p.save, 'Record expected to not be allowed to save'
19
19
  assert_equal 1, p.errors.size
20
- assert_equal 'was not a readable image', p.errors.on(:image_file)
20
+ assert_equal 'was not a readable image', p.errors.messages[:image_file].join()
21
21
  end
22
22
 
23
23
  def test_should_correct_colorspace_and_dpi
@@ -12,7 +12,7 @@ class FleximageFileUploadFromUrlTest < Test::Unit::TestCase
12
12
  p = PhotoBare.new(:image_file_url => 'http://www.google.com/')
13
13
  assert !p.save, 'Record expected to be invalid after upload via URL'
14
14
  assert_equal 1, p.errors.size
15
- assert_equal 'was not a readable image', p.errors.on(:image_file_url)
15
+ assert_equal 'was not a readable image', p.errors.messages[:image_file_url].join()
16
16
  rescue SocketError
17
17
  print '!'
18
18
  end
@@ -21,7 +21,7 @@ class FleximageFileUploadFromUrlTest < Test::Unit::TestCase
21
21
  p = PhotoBare.new(:image_file_url => 'foo')
22
22
  assert !p.save, 'Record expected to be invalid after upload via URL'
23
23
  assert_equal 1, p.errors.size
24
- assert_equal 'was not a readable image', p.errors.on(:image_file_url)
24
+ assert_equal 'was not a readable image', p.errors.messages[:image_file_url].join()
25
25
  rescue SocketError
26
26
  print '!'
27
27
  end
@@ -14,14 +14,14 @@ class FleximageFileUploadToDbTest < Test::Unit::TestCase
14
14
  p = PhotoDb.new
15
15
  assert !p.save, 'Record expected to not be allowed to save'
16
16
  assert_equal 1, p.errors.size
17
- assert_equal 'is required', p.errors.on(:image_file)
17
+ assert_equal 'is required', p.errors.messages[:image_file].join()
18
18
  end
19
19
 
20
20
  def test_should_require_an_valid_image
21
21
  p = PhotoDb.new(:image_file => files(:not_a_photo))
22
22
  assert !p.save, 'Record expected to not be allowed to save'
23
23
  assert_equal 1, p.errors.size
24
- assert_equal 'was not a readable image', p.errors.on(:image_file)
24
+ assert_equal 'was not a readable image', p.errors.messages[:image_file].join()
25
25
  end
26
26
 
27
27
  def test_should_retrieve_a_stored_image
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  require File.dirname(__FILE__) + '/../../test/test_helper'
2
4
 
3
5
 
@@ -5,30 +7,30 @@ class I18nMessagesTest < Test::Unit::TestCase
5
7
  def test_should_have_default_message
6
8
  p = PhotoBare.new
7
9
  p.save
8
- assert_equal "is required", p.errors["image_file"]
10
+ assert_equal "is required", p.errors["image_file"].join()
9
11
 
10
12
  p = PhotoBare.new(:image_file => files(:not_a_photo))
11
13
  p.save
12
- assert_equal "was not a readable image", p.errors["image_file"]
14
+ assert_equal "was not a readable image", p.errors["image_file"].join()
13
15
 
14
16
  p = PhotoBare.new(:image_file => files(:i1x1))
15
17
  p.save
16
- assert_equal "is too small (Minimum: 2x2)", p.errors["image_file"]
18
+ assert_equal "is too small (Minimum: 2x2)", p.errors["image_file"].join()
17
19
  end
18
20
 
19
21
  def test_should_have_german_message
20
22
  I18n.locale = "de"
21
23
  p = PhotoBare.new
22
24
  p.save
23
- assert_equal "ist erforderlich", p.errors["image_file"]
25
+ assert_equal "ist erforderlich", p.errors["image_file"].join()
24
26
 
25
27
  p = PhotoBare.new(:image_file => files(:not_a_photo))
26
28
  p.save
27
- assert_equal "war nicht lesbar", p.errors["image_file"]
29
+ assert_equal "war nicht lesbar", p.errors["image_file"].join()
28
30
 
29
31
  p = PhotoBare.new(:image_file => files(:i1x1))
30
32
  p.save
31
- assert_equal "ist zu klein (Minimalgröße: 2x2)", p.errors["image_file"]
33
+ assert_equal "ist zu klein (Minimalgröße: 2x2)", p.errors["image_file"].join()
32
34
  ensure
33
35
  I18n.locale = "en"
34
36
  end
@@ -36,14 +38,14 @@ class I18nMessagesTest < Test::Unit::TestCase
36
38
  def test_should_have_model_specific_message
37
39
  p = PhotoCustomError.new
38
40
  assert !p.save
39
- assert_equal "needs to be attached", p.errors["image_file"]
41
+ assert_equal "needs to be attached", p.errors["image_file"].join()
40
42
 
41
43
  p = PhotoCustomError.new(:image_file => files(:not_a_photo))
42
44
  p.save
43
- assert_equal "seems to be broken", p.errors["image_file"]
45
+ assert_equal "seems to be broken", p.errors["image_file"].join()
44
46
 
45
47
  p = PhotoCustomError.new(:image_file => files(:i1x1))
46
48
  assert !p.save
47
- assert_equal "must be bigger (min. size: 2x2)", p.errors["image_file"]
49
+ assert_equal "must be bigger (min. size: 2x2)", p.errors["image_file"].join()
48
50
  end
49
51
  end
@@ -26,7 +26,7 @@ class MinimumImageSizeTest < Test::Unit::TestCase
26
26
  def test_should_not_save_small_image
27
27
  p = BigPhoto.new(:image_file => files(:i1x1))
28
28
  assert !p.save
29
- assert p.errors["image_file"].match(/is too small/)
29
+ assert p.errors["image_file"].join().match(/is too small/)
30
30
  end
31
31
 
32
32
  def test_should_save_big_image
@@ -51,6 +51,6 @@ class MinimumImageSizeTest < Test::Unit::TestCase
51
51
  def test_should_include_minimum_dimensions_in_message
52
52
  p = BigPhoto.new(:image_file => files(:i1x1))
53
53
  p.save
54
- assert_equal "is too small (Minimum: 80x60)", p.errors["image_file"]
54
+ assert_equal "is too small (Minimum: 80x60)", p.errors["image_file"].join()
55
55
  end
56
56
  end
@@ -1,12 +1,13 @@
1
1
  # -*- encoding: utf-8 -*-
2
+ require File.join(File.dirname(__FILE__), 'lib/fleximage/version')
2
3
 
3
4
  Gem::Specification.new do |s|
4
5
  s.name = "tvdeyen-fleximage"
5
- s.version = "1.1.1"
6
+ s.version = Fleximage::VERSION
6
7
 
7
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Ahmed Adam", "Alex Wayne", "Andrew White", "Carsten Fregin", "Duccio", "Fernando Kosh", "Heiner Wohner", "JJ Buckley", "Jason Lee", "Joshua Abbott", "Koji Ando", "Kouhei Sutou", "Lasse Jansen", "Lo\u{ef}c Guitaut", "Markus Schwed", "Martin Vielsmaier", "Squeegy", "Thomas von Deyen", "Vannoy", "Wolfgang Klinger", "Wolfgang K\u{f6}lbl", "josei", "masche842", "ralph"]
9
- s.date = "2012-02-15"
9
+ s.authors = `git log --format='%aN' | sort -u`.split("\n")
10
+ s.date = "2012-04-06"
10
11
  s.description = "Fleximage is a Rails plugin that tries to make image uploading and rendering\nsuper easy.\n"
11
12
  s.email = "tvdeyen@gmail.com"
12
13
  s.extra_rdoc_files = [
@@ -19,6 +20,7 @@ Gem::Specification.new do |s|
19
20
  s.rubygems_version = "1.8.10"
20
21
  s.summary = "Rails plugin for uploading images as resources, with support for resizing, text stamping, and other special effects."
21
22
 
22
- s.add_runtime_dependency(%q<rmagick>, [">= 0"])
23
+ s.add_runtime_dependency(%q<rmagick>, [">= 2"])
24
+ s.add_runtime_dependency(%q<dsl_accessor>, ["~> 0.4.0"])
23
25
  s.add_development_dependency(%q<rails>, ["~> 3.2.1"])
24
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tvdeyen-fleximage
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -32,22 +32,33 @@ authors:
32
32
  autorequire:
33
33
  bindir: bin
34
34
  cert_chain: []
35
- date: 2012-02-15 00:00:00.000000000 Z
35
+ date: 2012-04-06 00:00:00.000000000 Z
36
36
  dependencies:
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: rmagick
39
- requirement: &70293806355060 !ruby/object:Gem::Requirement
39
+ requirement: &70108112024400 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
43
43
  - !ruby/object:Gem::Version
44
- version: '0'
44
+ version: '2'
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *70293806355060
47
+ version_requirements: *70108112024400
48
+ - !ruby/object:Gem::Dependency
49
+ name: dsl_accessor
50
+ requirement: &70108112023660 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ~>
54
+ - !ruby/object:Gem::Version
55
+ version: 0.4.0
56
+ type: :runtime
57
+ prerelease: false
58
+ version_requirements: *70108112023660
48
59
  - !ruby/object:Gem::Dependency
49
60
  name: rails
50
- requirement: &70293806354560 !ruby/object:Gem::Requirement
61
+ requirement: &70108112022880 !ruby/object:Gem::Requirement
51
62
  none: false
52
63
  requirements:
53
64
  - - ~>
@@ -55,7 +66,7 @@ dependencies:
55
66
  version: 3.2.1
56
67
  type: :development
57
68
  prerelease: false
58
- version_requirements: *70293806354560
69
+ version_requirements: *70108112022880
59
70
  description: ! 'Fleximage is a Rails plugin that tries to make image uploading and
60
71
  rendering
61
72
 
@@ -74,10 +85,8 @@ files:
74
85
  - MIT-LICENSE
75
86
  - README.rdoc
76
87
  - Rakefile
77
- - VERSION
78
88
  - autotest.rb
79
89
  - init.rb
80
- - lib/dsl_accessor.rb
81
90
  - lib/fleximage.rb
82
91
  - lib/fleximage/aviary_controller.rb
83
92
  - lib/fleximage/blank.rb
@@ -97,6 +106,7 @@ files:
97
106
  - lib/fleximage/operator/unsharp_mask.rb
98
107
  - lib/fleximage/rails3_view.rb
99
108
  - lib/fleximage/rmagick_image_patch.rb
109
+ - lib/fleximage/version.rb
100
110
  - lib/fleximage/view.rb
101
111
  - lib/tasks/fleximage_tasks.rake
102
112
  - test/fixtures/100x1.jpg
@@ -194,13 +204,11 @@ files:
194
204
  - test/rails_root/public/robots.txt
195
205
  - test/rails_root/public/stylesheets/scaffold.css
196
206
  - test/rails_root/script/rails
197
- - test/rails_root/vendor/plugins/fleximage/init.rb
198
207
  - test/test_helper.rb
199
208
  - test/unit/abstract_test.rb
200
209
  - test/unit/basic_model_test.rb
201
210
  - test/unit/blank_test.rb
202
211
  - test/unit/default_image_path_option_test.rb
203
- - test/unit/dsl_accessor_test.rb
204
212
  - test/unit/file_upload_from_local_test.rb
205
213
  - test/unit/file_upload_from_strings_test.rb
206
214
  - test/unit/file_upload_from_url_test.rb
@@ -233,7 +241,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
233
241
  version: '0'
234
242
  segments:
235
243
  - 0
236
- hash: 3475540245412168316
244
+ hash: -1294711722270480675
237
245
  required_rubygems_version: !ruby/object:Gem::Requirement
238
246
  none: false
239
247
  requirements:
@@ -242,7 +250,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
242
250
  version: '0'
243
251
  requirements: []
244
252
  rubyforge_project:
245
- rubygems_version: 1.8.16
253
+ rubygems_version: 1.8.15
246
254
  signing_key:
247
255
  specification_version: 3
248
256
  summary: Rails plugin for uploading images as resources, with support for resizing,
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 1.1.0
@@ -1,55 +0,0 @@
1
- require 'active_support' unless defined?(ActiveSupport)
2
-
3
- class Class
4
- def dsl_accessor(name, options = {})
5
- raise TypeError, "DSL Error: options should be a hash. but got `#{options.class}'" unless options.is_a?(Hash)
6
- writer = options[:writer] || options[:setter]
7
- writer =
8
- case writer
9
- when NilClass then Proc.new{|value| value}
10
- when Symbol then Proc.new{|value| __send__(writer, value)}
11
- when Proc then writer
12
- else raise TypeError, "DSL Error: writer should be a symbol or proc. but got `#{options[:writer].class}'"
13
- end
14
- class_attribute :"#{name}_writer"
15
- class_attribute :"#{name}_value"
16
- self.send(:"#{name}_writer=", writer)
17
-
18
- default =
19
- case options[:default]
20
- when NilClass then nil
21
- when [] then Proc.new{[]}
22
- when {} then Proc.new{{}}
23
- when Symbol then Proc.new{__send__(options[:default])}
24
- when Proc then options[:default]
25
- else Proc.new{options[:default]}
26
- end
27
- class_attribute :"#{name}_default"
28
- self.send(:"#{name}_default=", default)
29
-
30
- self.class.class_eval do
31
- define_method("#{name}=") do |value|
32
- writer = self.send(:"#{name}_writer")
33
- value = writer.call(value) if writer
34
- self.send(:"#{name}_value=", value)
35
- end
36
-
37
- define_method(name) do |*values|
38
- if values.empty?
39
- # getter method
40
- key = :"#{name}"
41
- if !self.respond_to?(key)
42
- default = self.send(:"#{name}_default")
43
- value = default ? default.call(self) : nil
44
- self.send("#{name}_value=", value)
45
- end
46
- self.send("#{key}_value")
47
- else
48
- # setter method
49
- __send__("#{name}_value=", *values)
50
- end
51
- end
52
- end
53
- end
54
- end
55
-
@@ -1,2 +0,0 @@
1
- init_path = "#{Rails.root}/../../init.rb"
2
- silence_warnings { eval(IO.read(init_path), binding, init_path) }
@@ -1,120 +0,0 @@
1
- require File.dirname(__FILE__) + '/../test_helper.rb'
2
-
3
- class DslAccessorTest < Test::Unit::TestCase
4
- class CoolActiveRecord
5
- dsl_accessor :primary_key
6
- dsl_accessor :table_name
7
- end
8
-
9
- class Item < CoolActiveRecord
10
- end
11
-
12
- class LegacyItem < CoolActiveRecord
13
- primary_key :itcd
14
- table_name :item
15
- end
16
-
17
-
18
- def test_accessor_without_initialization
19
- assert_equal nil, Item.primary_key
20
- assert_equal nil, Item.table_name
21
-
22
- Item.primary_key :itcd
23
- Item.table_name :item
24
-
25
- assert_equal :itcd, Item.primary_key
26
- assert_equal :item, Item.table_name
27
- end
28
-
29
- def test_accessor_with_initialization
30
- assert_equal :itcd, LegacyItem.primary_key
31
- assert_equal :item, LegacyItem.table_name
32
-
33
- LegacyItem.primary_key :item_id
34
- LegacyItem.table_name :item_table
35
-
36
- assert_equal :item_id, LegacyItem.primary_key
37
- assert_equal :item_table, LegacyItem.table_name
38
- end
39
- end
40
-
41
-
42
- class DslDefaultAccessorTest < Test::Unit::TestCase
43
-
44
- class CoolActiveRecord
45
- dsl_accessor :primary_key, :default=>"id"
46
- dsl_accessor :table_name, :default=>proc{|klass| klass.name.demodulize.underscore.pluralize}
47
- end
48
-
49
- class Item < CoolActiveRecord
50
- end
51
-
52
- class User < CoolActiveRecord
53
- end
54
-
55
- class Folder
56
- dsl_accessor :array_folder, :default=>[]
57
- dsl_accessor :hash_folder, :default=>{}
58
- end
59
-
60
- class SubFolder < Folder
61
- end
62
-
63
- def test_default_accessor_with_string
64
- assert_equal "id", Item.primary_key
65
- assert_equal "id", User.primary_key
66
- end
67
-
68
- def test_default_accessor_with_proc
69
- assert_equal "items", Item.table_name
70
- assert_equal "users", User.table_name
71
- end
72
-
73
- def test_default_accessor_should_duplicate_empty_array_or_hash
74
- Folder.array_folder << 1
75
- Folder.hash_folder[:name] = "maiha"
76
-
77
- assert_equal([1], Folder.array_folder)
78
- assert_equal({:name=>"maiha"}, Folder.hash_folder)
79
-
80
- assert_equal([], SubFolder.array_folder)
81
- assert_equal({}, SubFolder.hash_folder)
82
- end
83
- end
84
-
85
-
86
- class DslOverwritenDefaultAccessorTest < Test::Unit::TestCase
87
- class CoolActiveRecord
88
- dsl_accessor :primary_key, :default=>"id"
89
- dsl_accessor :table_name, :default=>proc{|klass| klass.name.demodulize.underscore.pluralize}
90
- end
91
-
92
- class Item < CoolActiveRecord
93
- primary_key :item_id
94
- table_name :item_table
95
- end
96
-
97
- def test_overwrite_default_accessor
98
- assert_equal :item_id, Item.primary_key
99
- assert_equal :item_table, Item.table_name
100
- end
101
- end
102
-
103
-
104
- class DslWriterAccessorTest < Test::Unit::TestCase
105
- class Item
106
- dsl_accessor :primary_key, :writer=>proc{|value| value.to_s}
107
- end
108
-
109
- def test_string_writer
110
- assert_equal "", Item.primary_key
111
-
112
- Item.primary_key :id
113
- assert_equal "id", Item.primary_key
114
-
115
- Item.primary_key "id"
116
- assert_equal "id", Item.primary_key
117
- end
118
- end
119
-
120
-