robinboening-fleximage 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. data/CHANGELOG.rdoc +14 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +257 -0
  4. data/Rakefile +49 -0
  5. data/VERSION +1 -0
  6. data/autotest.rb +5 -0
  7. data/fleximage.gemspec +179 -0
  8. data/init.rb +1 -0
  9. data/lib/dsl_accessor.rb +52 -0
  10. data/lib/fleximage.rb +56 -0
  11. data/lib/fleximage/aviary_controller.rb +75 -0
  12. data/lib/fleximage/blank.rb +70 -0
  13. data/lib/fleximage/helper.rb +41 -0
  14. data/lib/fleximage/image_proxy.rb +69 -0
  15. data/lib/fleximage/legacy_view.rb +63 -0
  16. data/lib/fleximage/model.rb +711 -0
  17. data/lib/fleximage/operator/background.rb +62 -0
  18. data/lib/fleximage/operator/base.rb +189 -0
  19. data/lib/fleximage/operator/border.rb +50 -0
  20. data/lib/fleximage/operator/crop.rb +58 -0
  21. data/lib/fleximage/operator/image_overlay.rb +85 -0
  22. data/lib/fleximage/operator/resize.rb +92 -0
  23. data/lib/fleximage/operator/shadow.rb +87 -0
  24. data/lib/fleximage/operator/text.rb +104 -0
  25. data/lib/fleximage/operator/trim.rb +14 -0
  26. data/lib/fleximage/operator/unsharp_mask.rb +36 -0
  27. data/lib/fleximage/rmagick_image_patch.rb +5 -0
  28. data/lib/fleximage/view.rb +57 -0
  29. data/tasks/fleximage_tasks.rake +154 -0
  30. data/test/fixtures/100x1.jpg +0 -0
  31. data/test/fixtures/100x100.jpg +0 -0
  32. data/test/fixtures/1x1.jpg +0 -0
  33. data/test/fixtures/1x100.jpg +0 -0
  34. data/test/fixtures/cmyk.jpg +0 -0
  35. data/test/fixtures/not_a_photo.xml +1 -0
  36. data/test/fixtures/photo.jpg +0 -0
  37. data/test/mock_file.rb +21 -0
  38. data/test/rails_root/app/controllers/application.rb +10 -0
  39. data/test/rails_root/app/controllers/avatars_controller.rb +85 -0
  40. data/test/rails_root/app/controllers/photo_bares_controller.rb +85 -0
  41. data/test/rails_root/app/controllers/photo_dbs_controller.rb +85 -0
  42. data/test/rails_root/app/controllers/photo_files_controller.rb +85 -0
  43. data/test/rails_root/app/helpers/application_helper.rb +3 -0
  44. data/test/rails_root/app/helpers/avatars_helper.rb +2 -0
  45. data/test/rails_root/app/helpers/photo_bares_helper.rb +2 -0
  46. data/test/rails_root/app/helpers/photo_dbs_helper.rb +2 -0
  47. data/test/rails_root/app/helpers/photo_files_helper.rb +2 -0
  48. data/test/rails_root/app/locales/de.yml +7 -0
  49. data/test/rails_root/app/locales/en.yml +8 -0
  50. data/test/rails_root/app/models/abstract.rb +8 -0
  51. data/test/rails_root/app/models/avatar.rb +4 -0
  52. data/test/rails_root/app/models/photo_bare.rb +7 -0
  53. data/test/rails_root/app/models/photo_custom_error.rb +10 -0
  54. data/test/rails_root/app/models/photo_db.rb +3 -0
  55. data/test/rails_root/app/models/photo_file.rb +3 -0
  56. data/test/rails_root/app/models/photo_s3.rb +5 -0
  57. data/test/rails_root/app/views/avatars/edit.html.erb +17 -0
  58. data/test/rails_root/app/views/avatars/index.html.erb +20 -0
  59. data/test/rails_root/app/views/avatars/new.html.erb +16 -0
  60. data/test/rails_root/app/views/avatars/show.html.erb +8 -0
  61. data/test/rails_root/app/views/layouts/avatars.html.erb +17 -0
  62. data/test/rails_root/app/views/layouts/photo_bares.html.erb +17 -0
  63. data/test/rails_root/app/views/layouts/photo_dbs.html.erb +17 -0
  64. data/test/rails_root/app/views/layouts/photo_files.html.erb +17 -0
  65. data/test/rails_root/app/views/photo_bares/edit.html.erb +12 -0
  66. data/test/rails_root/app/views/photo_bares/index.html.erb +18 -0
  67. data/test/rails_root/app/views/photo_bares/new.html.erb +11 -0
  68. data/test/rails_root/app/views/photo_bares/show.html.erb +3 -0
  69. data/test/rails_root/app/views/photo_dbs/edit.html.erb +32 -0
  70. data/test/rails_root/app/views/photo_dbs/index.html.erb +26 -0
  71. data/test/rails_root/app/views/photo_dbs/new.html.erb +31 -0
  72. data/test/rails_root/app/views/photo_dbs/show.html.erb +23 -0
  73. data/test/rails_root/app/views/photo_files/edit.html.erb +27 -0
  74. data/test/rails_root/app/views/photo_files/index.html.erb +24 -0
  75. data/test/rails_root/app/views/photo_files/new.html.erb +26 -0
  76. data/test/rails_root/app/views/photo_files/show.html.erb +18 -0
  77. data/test/rails_root/config/boot.rb +109 -0
  78. data/test/rails_root/config/database.yml +7 -0
  79. data/test/rails_root/config/environment.rb +66 -0
  80. data/test/rails_root/config/environments/development.rb +18 -0
  81. data/test/rails_root/config/environments/production.rb +19 -0
  82. data/test/rails_root/config/environments/sqlite3.rb +0 -0
  83. data/test/rails_root/config/environments/test.rb +22 -0
  84. data/test/rails_root/config/initializers/inflections.rb +10 -0
  85. data/test/rails_root/config/initializers/load_translations.rb +4 -0
  86. data/test/rails_root/config/initializers/mime_types.rb +5 -0
  87. data/test/rails_root/config/routes.rb +43 -0
  88. data/test/rails_root/db/migrate/001_create_photo_files.rb +16 -0
  89. data/test/rails_root/db/migrate/002_create_photo_dbs.rb +16 -0
  90. data/test/rails_root/db/migrate/003_create_photo_bares.rb +12 -0
  91. data/test/rails_root/db/migrate/004_create_avatars.rb +13 -0
  92. data/test/rails_root/db/migrate/005_create_photo_s3s.rb +12 -0
  93. data/test/rails_root/public/.htaccess +40 -0
  94. data/test/rails_root/public/404.html +30 -0
  95. data/test/rails_root/public/422.html +30 -0
  96. data/test/rails_root/public/500.html +30 -0
  97. data/test/rails_root/public/dispatch.cgi +10 -0
  98. data/test/rails_root/public/dispatch.fcgi +24 -0
  99. data/test/rails_root/public/dispatch.rb +10 -0
  100. data/test/rails_root/public/favicon.ico +0 -0
  101. data/test/rails_root/public/images/rails.png +0 -0
  102. data/test/rails_root/public/index.html +277 -0
  103. data/test/rails_root/public/javascripts/application.js +2 -0
  104. data/test/rails_root/public/javascripts/controls.js +963 -0
  105. data/test/rails_root/public/javascripts/dragdrop.js +972 -0
  106. data/test/rails_root/public/javascripts/effects.js +1120 -0
  107. data/test/rails_root/public/javascripts/prototype.js +4225 -0
  108. data/test/rails_root/public/robots.txt +5 -0
  109. data/test/rails_root/public/stylesheets/scaffold.css +74 -0
  110. data/test/rails_root/vendor/plugins/fleximage/init.rb +2 -0
  111. data/test/s3_stubs.rb +7 -0
  112. data/test/test_helper.rb +82 -0
  113. data/test/unit/abstract_test.rb +20 -0
  114. data/test/unit/basic_model_test.rb +40 -0
  115. data/test/unit/blank_test.rb +23 -0
  116. data/test/unit/default_image_path_option_test.rb +16 -0
  117. data/test/unit/dsl_accessor_test.rb +120 -0
  118. data/test/unit/file_upload_from_local_test.rb +31 -0
  119. data/test/unit/file_upload_from_strings_test.rb +23 -0
  120. data/test/unit/file_upload_from_url_test.rb +35 -0
  121. data/test/unit/file_upload_to_db_test.rb +41 -0
  122. data/test/unit/has_store_test.rb +4 -0
  123. data/test/unit/i18n_messages_test.rb +49 -0
  124. data/test/unit/image_directory_option_test.rb +20 -0
  125. data/test/unit/image_proxy_test.rb +17 -0
  126. data/test/unit/image_storage_format_option_test.rb +31 -0
  127. data/test/unit/magic_columns_test.rb +34 -0
  128. data/test/unit/minimum_image_size_test.rb +56 -0
  129. data/test/unit/operator_base_test.rb +124 -0
  130. data/test/unit/operator_resize_test.rb +18 -0
  131. data/test/unit/preprocess_image_option_test.rb +21 -0
  132. data/test/unit/require_image_option_test.rb +30 -0
  133. data/test/unit/temp_image_test.rb +23 -0
  134. data/test/unit/use_creation_date_based_directories_option_test.rb +16 -0
  135. metadata +258 -0
@@ -0,0 +1,21 @@
1
+ require File.dirname(__FILE__) + '/../../test/test_helper'
2
+
3
+ class FleximagePreprocessImageOptionTest < Test::Unit::TestCase
4
+ def test_should_resize_image_on_upload
5
+ PhotoDb.preprocess_image do |image|
6
+ image.resize '50x50', :crop => true
7
+ end
8
+
9
+ p = PhotoDb.new(:image_file => files(:photo))
10
+ assert p.save, 'Record expected to be allowed to save'
11
+
12
+ assert_equal 50, p.load_image.columns
13
+ assert_equal 50, p.load_image.rows
14
+
15
+ assert_equal 50, p.image_height
16
+ assert_equal 50, p.image_width
17
+
18
+ ensure
19
+ PhotoDb.preprocess_image_operation = nil
20
+ end
21
+ end
@@ -0,0 +1,30 @@
1
+ require File.dirname(__FILE__) + '/../../test/test_helper'
2
+
3
+ class ValidatedPhoto < ActiveRecord::Base
4
+ set_table_name :photo_dbs
5
+ acts_as_fleximage
6
+
7
+ def validate
8
+ # overiding the validate method
9
+ end
10
+ end
11
+
12
+ class FleximageRequireImageOptionTest < Test::Unit::TestCase
13
+ def test_should_require_image_by_default
14
+ p = PhotoBare.new
15
+ assert !p.save, 'Record expected to not be allowed to save'
16
+ end
17
+
18
+ def test_should_disable_image_requirement
19
+ PhotoBare.require_image = false
20
+ p = PhotoBare.new
21
+ assert p.save, 'Record expected to be allowed to save'
22
+ ensure
23
+ PhotoBare.require_image = true
24
+ end
25
+
26
+ def test_should_require_image_when_validate_is_overriden
27
+ p = ValidatedPhoto.new
28
+ assert !p.save, 'Record expected to not be allowed to save'
29
+ end
30
+ end
@@ -0,0 +1,23 @@
1
+ require File.dirname(__FILE__) + '/../../test/test_helper'
2
+
3
+ class FleximageTempImageTest < Test::Unit::TestCase
4
+ def test_should_save_and_use_a_temp_image
5
+ a1 = Avatar.new(:image_file => files(:photo))
6
+ assert !a1.save
7
+ assert_match /^\d+_\d+$/, a1.image_file_temp
8
+ assert File.exists?("#{RAILS_ROOT}/tmp/fleximage/#{a1.image_file_temp}")
9
+ temp_file_path = a1.image_file_temp
10
+
11
+ a2 = Avatar.new(:username => 'Alex Wayne', :image_file_temp => temp_file_path)
12
+
13
+ assert a2.save
14
+ assert File.exists?(a2.file_path)
15
+ assert !File.exists?("#{RAILS_ROOT}/tmp/fleximage/#{temp_file_path}")
16
+ end
17
+
18
+ def test_should_prevent_directory_traversal_attacks
19
+ a1 = Avatar.new(:image_file_temp => '../fleximage/photo.jpg')
20
+ assert !a1.save
21
+ assert_equal nil, a1.image_file_temp
22
+ end
23
+ end
@@ -0,0 +1,16 @@
1
+ require File.dirname(__FILE__) + '/../../test/test_helper'
2
+
3
+ class FleximageUseCreationDateBasedDirectoriesOptionTest < Test::Unit::TestCase
4
+ def test_should_store_images_with_creation_date_based_directories
5
+ p = PhotoBare.create(:image_file => files(:photo))
6
+ assert_match %r{public/uploads/\d+/\d+/\d+/\d+}, p.file_path
7
+ end
8
+
9
+ def test_should_store_images_without_creation_date_based_directories
10
+ PhotoBare.use_creation_date_based_directories = false
11
+ p = PhotoBare.create(:image_file => files(:photo))
12
+ assert_no_match %r{public/uploads/\d+/\d+/\d+/\d+}, p.file_path
13
+ ensure
14
+ PhotoBare.use_creation_date_based_directories = true
15
+ end
16
+ end
metadata ADDED
@@ -0,0 +1,258 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: robinboening-fleximage
3
+ version: !ruby/object:Gem::Version
4
+ hash: 31
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 4
10
+ version: 1.0.4
11
+ platform: ruby
12
+ authors:
13
+ - Ahmed Adam
14
+ - Alex Wayne
15
+ - Andrew White
16
+ - JJ Buckley
17
+ - Jason Lee
18
+ - Joshua Abbott
19
+ - Koji Ando
20
+ - Kouhei Sutou
21
+ - Lasse Jansen
22
+ - "Lo\xC3\xAFc Guitaut"
23
+ - Martin Vielsmaier
24
+ - "Robin B\xC3\xB6ning"
25
+ - Squeegy
26
+ - Vannoy
27
+ - ralph
28
+ autorequire:
29
+ bindir: bin
30
+ cert_chain: []
31
+
32
+ date: 2011-05-29 00:00:00 Z
33
+ dependencies:
34
+ - !ruby/object:Gem::Dependency
35
+ name: rmagick
36
+ prerelease: false
37
+ requirement: &id001 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 0
45
+ version: "0"
46
+ type: :runtime
47
+ version_requirements: *id001
48
+ - !ruby/object:Gem::Dependency
49
+ name: aws-s3
50
+ prerelease: false
51
+ requirement: &id002 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ hash: 3
57
+ segments:
58
+ - 0
59
+ version: "0"
60
+ type: :runtime
61
+ version_requirements: *id002
62
+ - !ruby/object:Gem::Dependency
63
+ name: rails
64
+ prerelease: false
65
+ requirement: &id003 !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - "="
69
+ - !ruby/object:Gem::Version
70
+ hash: 3
71
+ segments:
72
+ - 2
73
+ - 2
74
+ - 2
75
+ version: 2.2.2
76
+ type: :development
77
+ version_requirements: *id003
78
+ description: |
79
+ Fleximage is a Rails plugin that tries to make image uploading and rendering
80
+ super easy.
81
+
82
+ email: robin.boening@nethosting4you.de
83
+ executables: []
84
+
85
+ extensions: []
86
+
87
+ extra_rdoc_files:
88
+ - README.rdoc
89
+ files:
90
+ - CHANGELOG.rdoc
91
+ - MIT-LICENSE
92
+ - README.rdoc
93
+ - Rakefile
94
+ - VERSION
95
+ - autotest.rb
96
+ - fleximage.gemspec
97
+ - init.rb
98
+ - lib/dsl_accessor.rb
99
+ - lib/fleximage.rb
100
+ - lib/fleximage/aviary_controller.rb
101
+ - lib/fleximage/blank.rb
102
+ - lib/fleximage/helper.rb
103
+ - lib/fleximage/image_proxy.rb
104
+ - lib/fleximage/legacy_view.rb
105
+ - lib/fleximage/model.rb
106
+ - lib/fleximage/operator/background.rb
107
+ - lib/fleximage/operator/base.rb
108
+ - lib/fleximage/operator/border.rb
109
+ - lib/fleximage/operator/crop.rb
110
+ - lib/fleximage/operator/image_overlay.rb
111
+ - lib/fleximage/operator/resize.rb
112
+ - lib/fleximage/operator/shadow.rb
113
+ - lib/fleximage/operator/text.rb
114
+ - lib/fleximage/operator/trim.rb
115
+ - lib/fleximage/operator/unsharp_mask.rb
116
+ - lib/fleximage/rmagick_image_patch.rb
117
+ - lib/fleximage/view.rb
118
+ - tasks/fleximage_tasks.rake
119
+ - test/fixtures/100x1.jpg
120
+ - test/fixtures/100x100.jpg
121
+ - test/fixtures/1x1.jpg
122
+ - test/fixtures/1x100.jpg
123
+ - test/fixtures/cmyk.jpg
124
+ - test/fixtures/not_a_photo.xml
125
+ - test/fixtures/photo.jpg
126
+ - test/mock_file.rb
127
+ - test/rails_root/app/controllers/application.rb
128
+ - test/rails_root/app/controllers/avatars_controller.rb
129
+ - test/rails_root/app/controllers/photo_bares_controller.rb
130
+ - test/rails_root/app/controllers/photo_dbs_controller.rb
131
+ - test/rails_root/app/controllers/photo_files_controller.rb
132
+ - test/rails_root/app/helpers/application_helper.rb
133
+ - test/rails_root/app/helpers/avatars_helper.rb
134
+ - test/rails_root/app/helpers/photo_bares_helper.rb
135
+ - test/rails_root/app/helpers/photo_dbs_helper.rb
136
+ - test/rails_root/app/helpers/photo_files_helper.rb
137
+ - test/rails_root/app/locales/de.yml
138
+ - test/rails_root/app/locales/en.yml
139
+ - test/rails_root/app/models/abstract.rb
140
+ - test/rails_root/app/models/avatar.rb
141
+ - test/rails_root/app/models/photo_bare.rb
142
+ - test/rails_root/app/models/photo_custom_error.rb
143
+ - test/rails_root/app/models/photo_db.rb
144
+ - test/rails_root/app/models/photo_file.rb
145
+ - test/rails_root/app/models/photo_s3.rb
146
+ - test/rails_root/app/views/avatars/edit.html.erb
147
+ - test/rails_root/app/views/avatars/index.html.erb
148
+ - test/rails_root/app/views/avatars/new.html.erb
149
+ - test/rails_root/app/views/avatars/show.html.erb
150
+ - test/rails_root/app/views/layouts/avatars.html.erb
151
+ - test/rails_root/app/views/layouts/photo_bares.html.erb
152
+ - test/rails_root/app/views/layouts/photo_dbs.html.erb
153
+ - test/rails_root/app/views/layouts/photo_files.html.erb
154
+ - test/rails_root/app/views/photo_bares/edit.html.erb
155
+ - test/rails_root/app/views/photo_bares/index.html.erb
156
+ - test/rails_root/app/views/photo_bares/new.html.erb
157
+ - test/rails_root/app/views/photo_bares/show.html.erb
158
+ - test/rails_root/app/views/photo_dbs/edit.html.erb
159
+ - test/rails_root/app/views/photo_dbs/index.html.erb
160
+ - test/rails_root/app/views/photo_dbs/new.html.erb
161
+ - test/rails_root/app/views/photo_dbs/show.html.erb
162
+ - test/rails_root/app/views/photo_files/edit.html.erb
163
+ - test/rails_root/app/views/photo_files/index.html.erb
164
+ - test/rails_root/app/views/photo_files/new.html.erb
165
+ - test/rails_root/app/views/photo_files/show.html.erb
166
+ - test/rails_root/config/boot.rb
167
+ - test/rails_root/config/database.yml
168
+ - test/rails_root/config/environment.rb
169
+ - test/rails_root/config/environments/development.rb
170
+ - test/rails_root/config/environments/production.rb
171
+ - test/rails_root/config/environments/sqlite3.rb
172
+ - test/rails_root/config/environments/test.rb
173
+ - test/rails_root/config/initializers/inflections.rb
174
+ - test/rails_root/config/initializers/load_translations.rb
175
+ - test/rails_root/config/initializers/mime_types.rb
176
+ - test/rails_root/config/routes.rb
177
+ - test/rails_root/db/migrate/001_create_photo_files.rb
178
+ - test/rails_root/db/migrate/002_create_photo_dbs.rb
179
+ - test/rails_root/db/migrate/003_create_photo_bares.rb
180
+ - test/rails_root/db/migrate/004_create_avatars.rb
181
+ - test/rails_root/db/migrate/005_create_photo_s3s.rb
182
+ - test/rails_root/public/.htaccess
183
+ - test/rails_root/public/404.html
184
+ - test/rails_root/public/422.html
185
+ - test/rails_root/public/500.html
186
+ - test/rails_root/public/dispatch.cgi
187
+ - test/rails_root/public/dispatch.fcgi
188
+ - test/rails_root/public/dispatch.rb
189
+ - test/rails_root/public/favicon.ico
190
+ - test/rails_root/public/images/rails.png
191
+ - test/rails_root/public/index.html
192
+ - test/rails_root/public/javascripts/application.js
193
+ - test/rails_root/public/javascripts/controls.js
194
+ - test/rails_root/public/javascripts/dragdrop.js
195
+ - test/rails_root/public/javascripts/effects.js
196
+ - test/rails_root/public/javascripts/prototype.js
197
+ - test/rails_root/public/robots.txt
198
+ - test/rails_root/public/stylesheets/scaffold.css
199
+ - test/rails_root/vendor/plugins/fleximage/init.rb
200
+ - test/s3_stubs.rb
201
+ - test/test_helper.rb
202
+ - test/unit/abstract_test.rb
203
+ - test/unit/basic_model_test.rb
204
+ - test/unit/blank_test.rb
205
+ - test/unit/default_image_path_option_test.rb
206
+ - test/unit/dsl_accessor_test.rb
207
+ - test/unit/file_upload_from_local_test.rb
208
+ - test/unit/file_upload_from_strings_test.rb
209
+ - test/unit/file_upload_from_url_test.rb
210
+ - test/unit/file_upload_to_db_test.rb
211
+ - test/unit/has_store_test.rb
212
+ - test/unit/i18n_messages_test.rb
213
+ - test/unit/image_directory_option_test.rb
214
+ - test/unit/image_proxy_test.rb
215
+ - test/unit/image_storage_format_option_test.rb
216
+ - test/unit/magic_columns_test.rb
217
+ - test/unit/minimum_image_size_test.rb
218
+ - test/unit/operator_base_test.rb
219
+ - test/unit/operator_resize_test.rb
220
+ - test/unit/preprocess_image_option_test.rb
221
+ - test/unit/require_image_option_test.rb
222
+ - test/unit/temp_image_test.rb
223
+ - test/unit/use_creation_date_based_directories_option_test.rb
224
+ homepage: http://github.com/robinboening/fleximage
225
+ licenses: []
226
+
227
+ post_install_message:
228
+ rdoc_options: []
229
+
230
+ require_paths:
231
+ - lib
232
+ required_ruby_version: !ruby/object:Gem::Requirement
233
+ none: false
234
+ requirements:
235
+ - - ">="
236
+ - !ruby/object:Gem::Version
237
+ hash: 3
238
+ segments:
239
+ - 0
240
+ version: "0"
241
+ required_rubygems_version: !ruby/object:Gem::Requirement
242
+ none: false
243
+ requirements:
244
+ - - ">="
245
+ - !ruby/object:Gem::Version
246
+ hash: 3
247
+ segments:
248
+ - 0
249
+ version: "0"
250
+ requirements: []
251
+
252
+ rubyforge_project:
253
+ rubygems_version: 1.8.4
254
+ signing_key:
255
+ specification_version: 3
256
+ summary: Rails plugin for uploading images as resources, with support for resizing, text stamping, and other special effects.
257
+ test_files: []
258
+