bulldog 0.1.1 → 0.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/CHANGELOG +7 -0
- data/lib/bulldog/attachment/base.rb +3 -6
- data/lib/bulldog/attachment/has_dimensions.rb +43 -34
- data/lib/bulldog/attachment/image.rb +5 -26
- data/lib/bulldog/attachment/pdf.rb +3 -28
- data/lib/bulldog/attachment/video.rb +48 -45
- data/lib/bulldog/style.rb +28 -1
- data/lib/bulldog/version.rb +1 -1
- data/spec/data/3-bytes.txt +1 -0
- data/spec/data/4-bytes.txt +1 -0
- data/spec/data/5-bytes.txt +1 -0
- data/spec/data/6-bytes.txt +1 -0
- data/spec/data/test-20x10.jpg +0 -0
- data/spec/data/test-20x10.pdf +0 -0
- data/spec/data/test-20x10x1.mov +0 -0
- data/spec/data/test-40x30.jpg +0 -0
- data/spec/data/test-40x30.pdf +0 -0
- data/spec/data/test-40x30x1.mov +0 -0
- data/spec/helpers/files.rb +123 -0
- data/spec/integration/lifecycle_hooks_spec.rb +1 -1
- data/spec/integration/processing_image_attachments.rb +1 -13
- data/spec/macros/attachment/has_dimensions_spec.rb +313 -0
- data/spec/spec_helper.rb +3 -4
- data/spec/unit/attachment/base_spec.rb +25 -45
- data/spec/unit/attachment/image_spec.rb +48 -171
- data/spec/unit/attachment/maybe_spec.rb +4 -12
- data/spec/unit/attachment/pdf_spec.rb +18 -136
- data/spec/unit/attachment/video_spec.rb +98 -170
- data/spec/unit/attachment_spec.rb +1 -1
- data/spec/unit/has_attachment_spec.rb +29 -26
- data/spec/unit/interpolation_spec.rb +2 -2
- data/spec/unit/processor/ffmpeg_spec.rb +3 -3
- data/spec/unit/processor/image_magick_spec.rb +1 -1
- data/spec/unit/processor/one_shot_spec.rb +1 -1
- data/spec/unit/stream_spec.rb +3 -3
- data/spec/unit/style_spec.rb +40 -0
- data/spec/unit/validations_spec.rb +33 -33
- metadata +28 -8
- data/spec/helpers/temporary_directory.rb +0 -25
- data/spec/helpers/test_upload_files.rb +0 -108
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
version: 0.2.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- George Ogata
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-07-14 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -108,24 +108,34 @@ files:
|
|
108
108
|
- lib/bulldog.rb
|
109
109
|
- rails/init.rb
|
110
110
|
- rails/rails.rb
|
111
|
+
- spec/data/3-bytes.txt
|
112
|
+
- spec/data/4-bytes.txt
|
113
|
+
- spec/data/5-bytes.txt
|
114
|
+
- spec/data/6-bytes.txt
|
111
115
|
- spec/data/empty.txt
|
116
|
+
- spec/data/test-20x10.jpg
|
117
|
+
- spec/data/test-20x10.pdf
|
118
|
+
- spec/data/test-20x10x1.mov
|
119
|
+
- spec/data/test-40x30.jpg
|
120
|
+
- spec/data/test-40x30.pdf
|
121
|
+
- spec/data/test-40x30x1.mov
|
112
122
|
- spec/data/test.jpg
|
113
123
|
- spec/data/test.mov
|
114
124
|
- spec/data/test.ogg
|
115
125
|
- spec/data/test.pdf
|
116
126
|
- spec/data/test.png
|
117
127
|
- spec/data/test2.jpg
|
128
|
+
- spec/helpers/files.rb
|
118
129
|
- spec/helpers/image_creation.rb
|
119
|
-
- spec/helpers/temporary_directory.rb
|
120
130
|
- spec/helpers/temporary_models.rb
|
121
131
|
- spec/helpers/temporary_values.rb
|
122
|
-
- spec/helpers/test_upload_files.rb
|
123
132
|
- spec/helpers/time_travel.rb
|
124
133
|
- spec/integration/data/test.jpg
|
125
134
|
- spec/integration/lifecycle_hooks_spec.rb
|
126
135
|
- spec/integration/processing_image_attachments.rb
|
127
136
|
- spec/integration/processing_video_attachments_spec.rb
|
128
137
|
- spec/integration/saving_an_attachment_spec.rb
|
138
|
+
- spec/macros/attachment/has_dimensions_spec.rb
|
129
139
|
- spec/matchers/file_operations.rb
|
130
140
|
- spec/spec_helper.rb
|
131
141
|
- spec/unit/attachment/base_spec.rb
|
@@ -180,24 +190,34 @@ signing_key:
|
|
180
190
|
specification_version: 3
|
181
191
|
summary: A heavy-duty paperclip. File attachments for ActiveRecord.
|
182
192
|
test_files:
|
193
|
+
- spec/data/3-bytes.txt
|
194
|
+
- spec/data/4-bytes.txt
|
195
|
+
- spec/data/5-bytes.txt
|
196
|
+
- spec/data/6-bytes.txt
|
183
197
|
- spec/data/empty.txt
|
198
|
+
- spec/data/test-20x10.jpg
|
199
|
+
- spec/data/test-20x10.pdf
|
200
|
+
- spec/data/test-20x10x1.mov
|
201
|
+
- spec/data/test-40x30.jpg
|
202
|
+
- spec/data/test-40x30.pdf
|
203
|
+
- spec/data/test-40x30x1.mov
|
184
204
|
- spec/data/test.jpg
|
185
205
|
- spec/data/test.mov
|
186
206
|
- spec/data/test.ogg
|
187
207
|
- spec/data/test.pdf
|
188
208
|
- spec/data/test.png
|
189
209
|
- spec/data/test2.jpg
|
210
|
+
- spec/helpers/files.rb
|
190
211
|
- spec/helpers/image_creation.rb
|
191
|
-
- spec/helpers/temporary_directory.rb
|
192
212
|
- spec/helpers/temporary_models.rb
|
193
213
|
- spec/helpers/temporary_values.rb
|
194
|
-
- spec/helpers/test_upload_files.rb
|
195
214
|
- spec/helpers/time_travel.rb
|
196
215
|
- spec/integration/data/test.jpg
|
197
216
|
- spec/integration/lifecycle_hooks_spec.rb
|
198
217
|
- spec/integration/processing_image_attachments.rb
|
199
218
|
- spec/integration/processing_video_attachments_spec.rb
|
200
219
|
- spec/integration/saving_an_attachment_spec.rb
|
220
|
+
- spec/macros/attachment/has_dimensions_spec.rb
|
201
221
|
- spec/matchers/file_operations.rb
|
202
222
|
- spec/spec_helper.rb
|
203
223
|
- spec/unit/attachment/base_spec.rb
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module TemporaryDirectory
|
2
|
-
def self.included(mod)
|
3
|
-
mod.before{init_temporary_directory}
|
4
|
-
mod.after{remove_temporary_directory}
|
5
|
-
end
|
6
|
-
|
7
|
-
def temporary_directory
|
8
|
-
"#{ROOT}/spec/tmp"
|
9
|
-
end
|
10
|
-
|
11
|
-
private # ---------------------------------------------------------
|
12
|
-
|
13
|
-
def init_temporary_directory
|
14
|
-
remove_temporary_directory
|
15
|
-
FileUtils.mkdir_p(temporary_directory)
|
16
|
-
|
17
|
-
# When an attachment is deleted, it deletes empty ancestral
|
18
|
-
# directories. Don't delete past the temporary directory.
|
19
|
-
FileUtils.touch "#{temporary_directory}/.do_not_delete"
|
20
|
-
end
|
21
|
-
|
22
|
-
def remove_temporary_directory
|
23
|
-
FileUtils.rm_rf(temporary_directory)
|
24
|
-
end
|
25
|
-
end
|
@@ -1,108 +0,0 @@
|
|
1
|
-
module TestUploadFiles
|
2
|
-
def self.included(mod)
|
3
|
-
mod.before{init_test_upload_files}
|
4
|
-
mod.after{close_test_upload_files}
|
5
|
-
end
|
6
|
-
|
7
|
-
def autoclose(file)
|
8
|
-
@files_to_close << file
|
9
|
-
file
|
10
|
-
end
|
11
|
-
|
12
|
-
def small_uploaded_file(path=unused_temp_path, test_file='test.jpg')
|
13
|
-
content = content_for_uploaded_file(test_file)
|
14
|
-
io = ActionController::UploadedStringIO.new(content)
|
15
|
-
io.original_path = path
|
16
|
-
io.content_type = Rack::Mime::MIME_TYPES[File.extname(path)]
|
17
|
-
io
|
18
|
-
end
|
19
|
-
|
20
|
-
def large_uploaded_file(path=unused_temp_path, test_file='test.jpg')
|
21
|
-
content = content_for_uploaded_file(test_file)
|
22
|
-
file = ActionController::UploadedTempfile.new(path)
|
23
|
-
file.write(content)
|
24
|
-
file.rewind
|
25
|
-
file.original_path = path
|
26
|
-
file.content_type = Rack::Mime::MIME_TYPES[File.extname(path)]
|
27
|
-
autoclose(file)
|
28
|
-
end
|
29
|
-
|
30
|
-
def uploaded_file_with_content(basename, content)
|
31
|
-
io = ActionController::UploadedStringIO.new(content)
|
32
|
-
io.original_path = basename
|
33
|
-
io.content_type = Rack::Mime::MIME_TYPES[File.extname(basename)]
|
34
|
-
io
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_file(basename)
|
38
|
-
path = test_path(basename)
|
39
|
-
file = open(path)
|
40
|
-
autoclose(file)
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_path(basename)
|
44
|
-
"#{ROOT}/spec/data/#{basename}"
|
45
|
-
end
|
46
|
-
|
47
|
-
# For when it doesn't matter if it's small or large.
|
48
|
-
alias uploaded_file small_uploaded_file
|
49
|
-
|
50
|
-
def test_image_file(basename='test.jpg')
|
51
|
-
path = test_image_path(basename)
|
52
|
-
file = open(path)
|
53
|
-
autoclose(file)
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_image_path(basename='test.jpg')
|
57
|
-
test_path(basename)
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_video_file(basename='test.mov')
|
61
|
-
path = test_video_path(basename)
|
62
|
-
file = open(path)
|
63
|
-
autoclose(file)
|
64
|
-
end
|
65
|
-
|
66
|
-
def test_video_path(basename='test.mov')
|
67
|
-
test_path(basename)
|
68
|
-
end
|
69
|
-
|
70
|
-
def test_pdf_file(basename='test.pdf')
|
71
|
-
path = test_pdf_path(basename)
|
72
|
-
file = open(path)
|
73
|
-
autoclose(file)
|
74
|
-
end
|
75
|
-
|
76
|
-
def test_pdf_path(basename='test.pdf')
|
77
|
-
test_path(basename)
|
78
|
-
end
|
79
|
-
|
80
|
-
def test_empty_file
|
81
|
-
file = open(test_path('empty.txt'))
|
82
|
-
autoclose(file)
|
83
|
-
end
|
84
|
-
|
85
|
-
private # ---------------------------------------------------------
|
86
|
-
|
87
|
-
def init_test_upload_files
|
88
|
-
@files_to_close = []
|
89
|
-
end
|
90
|
-
|
91
|
-
def close_test_upload_files
|
92
|
-
@files_to_close.each(&:close)
|
93
|
-
end
|
94
|
-
|
95
|
-
def content_for_uploaded_file(test_file)
|
96
|
-
path = test_path("test#{File.extname(test_file)}")
|
97
|
-
File.read(path)
|
98
|
-
end
|
99
|
-
|
100
|
-
def unused_temp_path
|
101
|
-
i = 0
|
102
|
-
path = nil
|
103
|
-
begin
|
104
|
-
path = File.join(temporary_directory, "test-#{i}.jpg")
|
105
|
-
end while File.exist?(path)
|
106
|
-
path
|
107
|
-
end
|
108
|
-
end
|