thumbkit 0.0.6 → 0.0.7
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/Gemfile.lock +56 -0
- data/README.md +5 -1
- data/lib/thumbkit/processor/image.rb +11 -2
- data/lib/thumbkit/processor.rb +14 -3
- data/lib/thumbkit/version.rb +1 -1
- data/lib/thumbkit.rb +1 -1
- data/spec/fixtures/with spaces.png +0 -0
- metadata +23 -37
- data/.gitignore +0 -13
- data/spec/spec_helper.rb +0 -51
- data/spec/thumbkit/options_spec.rb +0 -40
- data/spec/thumbkit/processor/audio_spec.rb +0 -57
- data/spec/thumbkit/processor/collection_spec.rb +0 -81
- data/spec/thumbkit/processor/image_spec.rb +0 -109
- data/spec/thumbkit/processor/text_spec.rb +0 -129
- data/spec/thumbkit/processor_spec.rb +0 -47
- data/spec/thumbkit_spec.rb +0 -47
- data/thumbkit.gemspec +0 -18
data/Gemfile.lock
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
GIT
|
2
|
+
remote: https://github.com/amiel/waveform
|
3
|
+
revision: d3a4a905b624cf601f81c93235e952539985f612
|
4
|
+
branch: thumbkit
|
5
|
+
specs:
|
6
|
+
waveform (0.0.4.custom)
|
7
|
+
chunky_png
|
8
|
+
ruby-audio
|
9
|
+
|
10
|
+
PATH
|
11
|
+
remote: .
|
12
|
+
specs:
|
13
|
+
thumbkit (0.0.6)
|
14
|
+
|
15
|
+
GEM
|
16
|
+
remote: https://rubygems.org/
|
17
|
+
specs:
|
18
|
+
chunky_png (1.2.5)
|
19
|
+
diff-lcs (1.1.3)
|
20
|
+
ffi (1.0.11)
|
21
|
+
guard (1.0.1)
|
22
|
+
ffi (>= 0.5.0)
|
23
|
+
thor (~> 0.14.6)
|
24
|
+
guard-bundler (0.1.3)
|
25
|
+
bundler (>= 1.0.0)
|
26
|
+
guard (>= 0.2.2)
|
27
|
+
guard-rspec (0.7.0)
|
28
|
+
guard (>= 0.10.0)
|
29
|
+
mini_magick (3.4)
|
30
|
+
subexec (~> 0.2.1)
|
31
|
+
oily_png (1.0.2)
|
32
|
+
chunky_png (~> 1.2.1)
|
33
|
+
rspec (2.9.0)
|
34
|
+
rspec-core (~> 2.9.0)
|
35
|
+
rspec-expectations (~> 2.9.0)
|
36
|
+
rspec-mocks (~> 2.9.0)
|
37
|
+
rspec-core (2.9.0)
|
38
|
+
rspec-expectations (2.9.1)
|
39
|
+
diff-lcs (~> 1.1.3)
|
40
|
+
rspec-mocks (2.9.0)
|
41
|
+
ruby-audio (1.6.1)
|
42
|
+
subexec (0.2.1)
|
43
|
+
thor (0.14.6)
|
44
|
+
|
45
|
+
PLATFORMS
|
46
|
+
ruby
|
47
|
+
|
48
|
+
DEPENDENCIES
|
49
|
+
guard
|
50
|
+
guard-bundler
|
51
|
+
guard-rspec
|
52
|
+
mini_magick
|
53
|
+
oily_png
|
54
|
+
rspec
|
55
|
+
thumbkit!
|
56
|
+
waveform!
|
data/README.md
CHANGED
@@ -80,6 +80,10 @@ other than .wav files.
|
|
80
80
|
|
81
81
|
See https://github.com/benalavi/waveform for more on requirements.
|
82
82
|
|
83
|
+
$ brew install ffmpeg # Optional for mp3
|
84
|
+
$ brew install libsndfile
|
85
|
+
|
86
|
+
|
83
87
|
NOTE: As of 0.0.3 waveform fails on mono files
|
84
88
|
([benalavi/waveform#4](https://github.com/benalavi/waveform/issues/4),
|
85
89
|
[benalavi/waveform#5](https://github.com/benalavi/waveform/issues/5)).
|
@@ -88,6 +92,7 @@ I've forked and fixed the issue (see
|
|
88
92
|
fix gets merged in you can use https://github.com/amiel/waveform/tree/thumbkit.
|
89
93
|
Like so:
|
90
94
|
|
95
|
+
|
91
96
|
```ruby
|
92
97
|
gem 'thumbkit'
|
93
98
|
gem 'waveform', git: 'https://github.com/amiel/waveform', branch: 'thumbkit'
|
@@ -257,7 +262,6 @@ Thumbkit.processors['doc'] = 'Doc'
|
|
257
262
|
* Maybe use filemagic/mime-type if available
|
258
263
|
* Paperclip processor
|
259
264
|
* Processors:
|
260
|
-
* Composite
|
261
265
|
* HTML
|
262
266
|
* PDF
|
263
267
|
* Video
|
@@ -16,8 +16,17 @@ class Thumbkit::Processor::Image < Thumbkit::Processor
|
|
16
16
|
# Public to allow customization
|
17
17
|
def format_conversions
|
18
18
|
@_format_conversions ||= {
|
19
|
-
'cr2'
|
20
|
-
'
|
19
|
+
'cr2' => 'jpg', # Canon RAW
|
20
|
+
'crw' => 'jpg', # Canon RAW
|
21
|
+
'dng' => 'jpg', # Adobe Digital Negative
|
22
|
+
'nef' => 'jpg', # Nikon RAW
|
23
|
+
'nrw' => 'jpg', # Nikon RAW
|
24
|
+
'psd' => 'jpg',
|
25
|
+
'raw' => 'jpg',
|
26
|
+
'sr2' => 'jpg', # Sony RAW
|
27
|
+
'srf' => 'jpg', # Sony RAW
|
28
|
+
'cr2' => 'jpg',
|
29
|
+
'raw' => 'jpg',
|
21
30
|
}
|
22
31
|
end
|
23
32
|
|
data/lib/thumbkit/processor.rb
CHANGED
@@ -6,12 +6,23 @@ class Thumbkit::Processor
|
|
6
6
|
|
7
7
|
def self.processors
|
8
8
|
@processors ||= {
|
9
|
-
'
|
9
|
+
'bmp' => 'Image',
|
10
|
+
'cr2' => 'Image', # Canon RAW
|
11
|
+
'crw' => 'Image', # Canon RAW
|
12
|
+
'dng' => 'Image', # Adobe Digital Negative
|
13
|
+
'gif' => 'Image',
|
10
14
|
'jpg' => 'Image',
|
11
15
|
'jpeg' => 'Image',
|
12
|
-
'
|
13
|
-
'
|
16
|
+
'nef' => 'Image', # Nikon RAW
|
17
|
+
'nrw' => 'Image', # Nikon RAW
|
18
|
+
'png' => 'Image',
|
19
|
+
'psd' => 'Image',
|
14
20
|
'raw' => 'Image',
|
21
|
+
'sr2' => 'Image', # Sony RAW
|
22
|
+
'srf' => 'Image', # Sony RAW
|
23
|
+
'tif' => 'Image',
|
24
|
+
'tiff' => 'Image',
|
25
|
+
'yuv' => 'Image',
|
15
26
|
'txt' => 'Text',
|
16
27
|
'md' => 'Text',
|
17
28
|
'rb' => 'Text',
|
data/lib/thumbkit/version.rb
CHANGED
data/lib/thumbkit.rb
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thumbkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-05-
|
12
|
+
date: 2012-05-16 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Thumbkit makes thumbnails!
|
15
15
|
email:
|
@@ -18,42 +18,35 @@ executables: []
|
|
18
18
|
extensions: []
|
19
19
|
extra_rdoc_files: []
|
20
20
|
files:
|
21
|
-
- .gitignore
|
22
|
-
- Gemfile
|
23
|
-
- Guardfile
|
24
|
-
- LICENSE
|
25
|
-
- README.md
|
26
|
-
- Rakefile
|
27
|
-
- lib/thumbkit.rb
|
28
|
-
- lib/thumbkit/adapters.rb
|
29
21
|
- lib/thumbkit/adapters/carrierwave.rb
|
22
|
+
- lib/thumbkit/adapters.rb
|
30
23
|
- lib/thumbkit/options.rb
|
31
|
-
- lib/thumbkit/processor.rb
|
32
24
|
- lib/thumbkit/processor/audio.rb
|
33
25
|
- lib/thumbkit/processor/collection.rb
|
34
26
|
- lib/thumbkit/processor/image.rb
|
35
27
|
- lib/thumbkit/processor/text.rb
|
28
|
+
- lib/thumbkit/processor.rb
|
36
29
|
- lib/thumbkit/version.rb
|
30
|
+
- lib/thumbkit.rb
|
31
|
+
- Gemfile
|
32
|
+
- Gemfile.lock
|
33
|
+
- Guardfile
|
34
|
+
- LICENSE
|
35
|
+
- Rakefile
|
36
|
+
- README.md
|
37
37
|
- spec/fixtures/16Hz-20kHz-Exp-1f-5sec.mp3
|
38
|
-
- spec/fixtures/OMG_UPPERCASE.PNG
|
39
|
-
- spec/fixtures/OMG_UPPERCASE_TEXT.TXT
|
40
38
|
- spec/fixtures/arabic.txt
|
41
39
|
- spec/fixtures/greek.txt
|
42
40
|
- spec/fixtures/hebrew.txt
|
43
|
-
- spec/fixtures/jpg_file.jpg
|
44
|
-
- spec/fixtures/png_file.png
|
45
41
|
- spec/fixtures/text_file.txt
|
46
|
-
- spec/
|
47
|
-
- spec/
|
48
|
-
- spec/
|
49
|
-
- spec/
|
50
|
-
- spec/
|
51
|
-
- spec/thumbkit/processor/text_spec.rb
|
52
|
-
- spec/thumbkit/processor_spec.rb
|
53
|
-
- spec/thumbkit_spec.rb
|
54
|
-
- thumbkit.gemspec
|
42
|
+
- spec/fixtures/png_file.png
|
43
|
+
- spec/fixtures/with spaces.png
|
44
|
+
- spec/fixtures/OMG_UPPERCASE.PNG
|
45
|
+
- spec/fixtures/OMG_UPPERCASE_TEXT.TXT
|
46
|
+
- spec/fixtures/jpg_file.jpg
|
55
47
|
homepage: http://github.com/carnesmedia/thumbkit
|
56
|
-
licenses:
|
48
|
+
licenses:
|
49
|
+
- MIT
|
57
50
|
post_install_message:
|
58
51
|
rdoc_options: []
|
59
52
|
require_paths:
|
@@ -78,20 +71,13 @@ specification_version: 3
|
|
78
71
|
summary: Thumbkit makes thumbnails from a variety of media types.
|
79
72
|
test_files:
|
80
73
|
- spec/fixtures/16Hz-20kHz-Exp-1f-5sec.mp3
|
81
|
-
- spec/fixtures/OMG_UPPERCASE.PNG
|
82
|
-
- spec/fixtures/OMG_UPPERCASE_TEXT.TXT
|
83
74
|
- spec/fixtures/arabic.txt
|
84
75
|
- spec/fixtures/greek.txt
|
85
76
|
- spec/fixtures/hebrew.txt
|
86
|
-
- spec/fixtures/jpg_file.jpg
|
87
|
-
- spec/fixtures/png_file.png
|
88
77
|
- spec/fixtures/text_file.txt
|
89
|
-
- spec/
|
90
|
-
- spec/
|
91
|
-
- spec/
|
92
|
-
- spec/
|
93
|
-
- spec/
|
94
|
-
- spec/thumbkit/processor/text_spec.rb
|
95
|
-
- spec/thumbkit/processor_spec.rb
|
96
|
-
- spec/thumbkit_spec.rb
|
78
|
+
- spec/fixtures/png_file.png
|
79
|
+
- spec/fixtures/with spaces.png
|
80
|
+
- spec/fixtures/OMG_UPPERCASE.PNG
|
81
|
+
- spec/fixtures/OMG_UPPERCASE_TEXT.TXT
|
82
|
+
- spec/fixtures/jpg_file.jpg
|
97
83
|
has_rdoc:
|
data/.gitignore
DELETED
data/spec/spec_helper.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
require 'thumbkit'
|
2
|
-
require 'fileutils'
|
3
|
-
|
4
|
-
module Helpers
|
5
|
-
|
6
|
-
def path_to_fixture(fixture_name)
|
7
|
-
Pathname.new("spec/fixtures").join(fixture_name).expand_path
|
8
|
-
end
|
9
|
-
|
10
|
-
def tmp_path
|
11
|
-
Pathname.new("spec/tmp")
|
12
|
-
end
|
13
|
-
|
14
|
-
def path_for_output(outfile = '')
|
15
|
-
tmp_path.join(outfile).expand_path
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
module ImageMacros
|
20
|
-
def its_size_should_be(size)
|
21
|
-
it "its size should be #{ size }" do
|
22
|
-
r = `identify -ping -quiet -format "%wx%h" "#{subject}"`.chomp
|
23
|
-
r.should == size
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def its_mimetype_should_be(mime)
|
28
|
-
it "its mime type should be #{ mime }" do
|
29
|
-
m = `file --mime-type -n -N "#{ subject }"|cut -d' ' -f2`.chomp
|
30
|
-
m.should == mime
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
RSpec.configure do |config|
|
36
|
-
config.extend ImageMacros
|
37
|
-
config.include Helpers
|
38
|
-
|
39
|
-
def mkdir_safe(dir)
|
40
|
-
Dir.mkdir(dir)
|
41
|
-
rescue Errno::EEXIST
|
42
|
-
# Great, it's already there.
|
43
|
-
end
|
44
|
-
|
45
|
-
config.around(:each) do |example|
|
46
|
-
mkdir_safe tmp_path.to_s
|
47
|
-
example.run
|
48
|
-
FileUtils.rm_rf(tmp_path.to_s) unless File.exist?(tmp_path.join('.keep').to_s)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Thumbkit::Options do
|
4
|
-
describe '#merge' do
|
5
|
-
it "does a deep merge" do
|
6
|
-
h1 = { x: { y: [4, 5, 6], z: [7, 8, 9], a: 'abar' } }
|
7
|
-
h2 = { x: { y: [1, 2, 3], z: 'xyz', b: { c: 'd' } } }
|
8
|
-
defaults = Thumbkit::Options.new(h1)
|
9
|
-
defaults.merge(h2).should == {
|
10
|
-
x: {
|
11
|
-
y: [1, 2, 3],
|
12
|
-
z: 'xyz',
|
13
|
-
a: 'abar',
|
14
|
-
b: { c: 'd' },
|
15
|
-
}
|
16
|
-
}
|
17
|
-
end
|
18
|
-
|
19
|
-
it "does an even deeper merge" do
|
20
|
-
# NOTE: These options resemble, but don't actually reflect the available
|
21
|
-
# options for Thumbkit.
|
22
|
-
h1 = { colors: { background: 'blue' }, font: { family: { name: 'Helvetica', weight: 'bold' } } }
|
23
|
-
h2 = { colors: { foreground: 'black' }, font: { family: { weight: 'light', transform: 'small-caps' } } }
|
24
|
-
defaults = Thumbkit::Options.new(h1)
|
25
|
-
defaults.merge(h2).should == {
|
26
|
-
colors: {
|
27
|
-
background: 'blue',
|
28
|
-
foreground: 'black',
|
29
|
-
},
|
30
|
-
font: {
|
31
|
-
family: {
|
32
|
-
name: 'Helvetica',
|
33
|
-
weight: 'light',
|
34
|
-
transform: 'small-caps',
|
35
|
-
}
|
36
|
-
}
|
37
|
-
}
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Thumbkit::Processor::Audio do
|
4
|
-
|
5
|
-
let(:fixture) { '16Hz-20kHz-Exp-1f-5sec.mp3' }
|
6
|
-
let(:path) { File.expand_path(path_to_fixture(fixture)) }
|
7
|
-
let(:outfile) { nil }
|
8
|
-
let(:options) { {} }
|
9
|
-
let(:processor) { Thumbkit::Processor::Audio.new(path, outfile, options) }
|
10
|
-
subject { processor }
|
11
|
-
|
12
|
-
its(:path) { should == path }
|
13
|
-
|
14
|
-
describe '#auto_outflie' do
|
15
|
-
subject { processor.outfile }
|
16
|
-
context 'when nothing specified' do
|
17
|
-
it { should == File.expand_path(path_to_fixture('16Hz-20kHz-Exp-1f-5sec.png')) }
|
18
|
-
end
|
19
|
-
|
20
|
-
# context 'with an extensionless outfile' do
|
21
|
-
# let(:outfile) { 'foo.' }
|
22
|
-
# it { should == 'foo.png' }
|
23
|
-
# end
|
24
|
-
|
25
|
-
# Not sure what to do in this case. Waveform just outputs a png file no
|
26
|
-
# matter what...
|
27
|
-
#
|
28
|
-
# context 'with a jpg specified' do
|
29
|
-
# let(:outfile) { path_for_output('audio-test.jpg').to_s }
|
30
|
-
# before { processor.write }
|
31
|
-
# it { should == path_for_output('audio_test.jpg').to_s }
|
32
|
-
# end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe '#write' do
|
36
|
-
let(:outfile) { path_for_output('audio-test.png').to_s }
|
37
|
-
subject { processor.write }
|
38
|
-
|
39
|
-
it 'returns the path of the outfile' do
|
40
|
-
subject.should == outfile
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'writes a file' do
|
44
|
-
File.should exist(subject)
|
45
|
-
end
|
46
|
-
|
47
|
-
its_size_should_be('200x200')
|
48
|
-
|
49
|
-
context 'with size settings' do
|
50
|
-
let(:outfile) { path_for_output('audio-test-300x250.png').to_s }
|
51
|
-
# Let's change a few settings for manual inspection
|
52
|
-
let(:options) { { width: 300, height: 250, colors: { background: :transparent, foreground: '#ffeecc' } } }
|
53
|
-
|
54
|
-
its_size_should_be('300x250')
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
@@ -1,81 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Thumbkit::Processor::Collection do
|
4
|
-
|
5
|
-
let(:fixtures) {
|
6
|
-
['png_file.png', 'text_file.txt', 'jpg_file.jpg', '16Hz-20kHz-Exp-1f-5sec.mp3']
|
7
|
-
}
|
8
|
-
let(:paths) { fixtures.map { |fixture| File.expand_path(path_to_fixture(fixture)) } }
|
9
|
-
let(:options) { {} }
|
10
|
-
let(:processor) { Thumbkit::Processor::Collection.new(paths, outfile, options) }
|
11
|
-
subject { processor }
|
12
|
-
|
13
|
-
describe '#determine_outfile' do
|
14
|
-
let(:outfile) { nil }
|
15
|
-
it 'raises an error' do
|
16
|
-
expect { processor.determine_outfile }.to raise_error(ArgumentError)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe '#collection' do
|
21
|
-
let(:outfile) { path_for_output('collection.png').to_s }
|
22
|
-
subject { processor.collection }
|
23
|
-
|
24
|
-
it 'returns an array of ThumbkitS' do
|
25
|
-
subject.should be_kind_of(Array)
|
26
|
-
subject.each { |e| e.should be_kind_of(Thumbkit) }
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'there are 4 of them' do
|
30
|
-
subject.size.should == 4
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'they haz the right paths' do
|
34
|
-
subject.map(&:path).should == paths
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
describe '#write' do
|
39
|
-
let(:outfile) { path_for_output('collection.png').to_s }
|
40
|
-
subject { processor.write }
|
41
|
-
|
42
|
-
it 'returns the path of the outfile' do
|
43
|
-
subject.should == outfile
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'writes a file' do
|
47
|
-
File.should exist(subject)
|
48
|
-
end
|
49
|
-
|
50
|
-
its_size_should_be('200x200')
|
51
|
-
its_mimetype_should_be('image/png')
|
52
|
-
|
53
|
-
context 'with only 3 sources' do
|
54
|
-
let(:outfile) { path_for_output('collection-3.png').to_s }
|
55
|
-
let(:fixtures) {
|
56
|
-
['png_file.png', 'text_file.txt', 'jpg_file.jpg']
|
57
|
-
}
|
58
|
-
|
59
|
-
it 'writes a file' do
|
60
|
-
File.should exist(subject)
|
61
|
-
end
|
62
|
-
|
63
|
-
its_size_should_be('200x200')
|
64
|
-
its_mimetype_should_be('image/png')
|
65
|
-
end
|
66
|
-
|
67
|
-
context 'with only 5 sources' do
|
68
|
-
let(:outfile) { path_for_output('collection-5.png').to_s }
|
69
|
-
let(:fixtures) {
|
70
|
-
['16Hz-20kHz-Exp-1f-5sec.mp3', 'arabic.txt', 'png_file.png', 'text_file.txt', 'jpg_file.jpg']
|
71
|
-
}
|
72
|
-
|
73
|
-
it 'writes a file' do
|
74
|
-
File.should exist(subject)
|
75
|
-
end
|
76
|
-
|
77
|
-
its_size_should_be('200x200')
|
78
|
-
its_mimetype_should_be('image/png')
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
@@ -1,109 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Thumbkit::Processor::Image do
|
4
|
-
|
5
|
-
let(:fixture) { 'png_file.png' }
|
6
|
-
let(:path) { File.expand_path(path_to_fixture(fixture)) }
|
7
|
-
let(:outfile) { nil }
|
8
|
-
let(:options) { {} }
|
9
|
-
let(:processor) { Thumbkit::Processor::Image.new(path, outfile, options) }
|
10
|
-
subject { processor }
|
11
|
-
|
12
|
-
its(:path) { should == path }
|
13
|
-
|
14
|
-
describe '#auto_outflie' do
|
15
|
-
subject { processor.outfile }
|
16
|
-
context 'when nothing specified' do
|
17
|
-
it { should == File.expand_path(path_to_fixture('png_file.png')) }
|
18
|
-
|
19
|
-
context 'when the fixture is a jpeg' do
|
20
|
-
let(:fixture) { 'jpg_file.jpg' }
|
21
|
-
it { should == File.expand_path(path_to_fixture('jpg_file.jpg')) }
|
22
|
-
end
|
23
|
-
|
24
|
-
context 'when the fixture is a cr2' do
|
25
|
-
let(:fixture) { 'IMAGE_RAW_EXAMPLE.CR2' }
|
26
|
-
it { should == File.expand_path(path_to_fixture('IMAGE_RAW_EXAMPLE.jpg')) }
|
27
|
-
end
|
28
|
-
|
29
|
-
context 'with an uppercase file' do
|
30
|
-
let(:fixture) { 'OMG_UPPERCASE.PNG' }
|
31
|
-
it { should == File.expand_path(path_to_fixture('OMG_UPPERCASE.png')) }
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
# context 'with an extensionless outfile' do
|
36
|
-
# let(:outfile) { 'foo.' }
|
37
|
-
# it { should == 'foo.png' }
|
38
|
-
# end
|
39
|
-
end
|
40
|
-
|
41
|
-
describe '#write' do
|
42
|
-
let(:outfile) { path_for_output('png_file.png').to_s }
|
43
|
-
subject { processor.write }
|
44
|
-
|
45
|
-
it 'returns the path of the outfile' do
|
46
|
-
subject.should == outfile
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'writes a file' do
|
50
|
-
File.should exist(subject)
|
51
|
-
end
|
52
|
-
|
53
|
-
its_size_should_be('200x200')
|
54
|
-
its_mimetype_should_be('image/png')
|
55
|
-
|
56
|
-
context 'with size settings' do
|
57
|
-
let(:outfile) { path_for_output('resize_test_300x250.png').to_s }
|
58
|
-
# Let's change a few settings for manual inspection
|
59
|
-
let(:options) { { width: 300, height: 250 } }
|
60
|
-
|
61
|
-
its_size_should_be('300x250')
|
62
|
-
its_mimetype_should_be('image/png')
|
63
|
-
end
|
64
|
-
|
65
|
-
context 'with size and gravity settings' do
|
66
|
-
let(:outfile) { path_for_output('resize_test_southwest_300x100.png').to_s }
|
67
|
-
# Let's change a few settings for manual inspection
|
68
|
-
let(:options) { { width: 300, height: 100, gravity: 'SouthWest' } }
|
69
|
-
|
70
|
-
its_size_should_be('300x100')
|
71
|
-
its_mimetype_should_be('image/png')
|
72
|
-
end
|
73
|
-
|
74
|
-
|
75
|
-
context 'with size settings larger than the image' do
|
76
|
-
let(:outfile) { path_for_output('resize_test_600x600.png').to_s }
|
77
|
-
# Let's change a few settings for manual inspection
|
78
|
-
let(:options) { { width: 600, height: 600 } }
|
79
|
-
|
80
|
-
its_size_should_be('600x600')
|
81
|
-
its_mimetype_should_be('image/png')
|
82
|
-
end
|
83
|
-
|
84
|
-
context 'with a jpg file' do
|
85
|
-
let(:outfile) { path_for_output('jpg_file.jpg').to_s }
|
86
|
-
it { should == path_for_output('jpg_file.jpg').to_s }
|
87
|
-
its_size_should_be('200x200')
|
88
|
-
its_mimetype_should_be('image/jpeg')
|
89
|
-
end
|
90
|
-
|
91
|
-
context 'with an uppercase file' do
|
92
|
-
let(:fixture) { path_to_fixture('OMG_UPPERCASE.PNG') }
|
93
|
-
let(:outfile) { path_for_output('OMG_UPPERCASE.png').to_s }
|
94
|
-
it { should == path_for_output('OMG_UPPERCASE.png').to_s }
|
95
|
-
its_size_should_be('200x200')
|
96
|
-
its_mimetype_should_be('image/png')
|
97
|
-
end
|
98
|
-
|
99
|
-
|
100
|
-
# Extremely SLOW
|
101
|
-
# context 'with a raw file' do
|
102
|
-
# let(:fixture) { 'IMG_RAW_EXAMPLE.CR2' }
|
103
|
-
# let(:outfile) { path_for_output('IMAGE_RAW_EXAMPLE.jpg').to_s }
|
104
|
-
# it { should == path_for_output('IMAGE_RAW_EXAMPLE.jpg').to_s }
|
105
|
-
# its_size_should_be('200x200')
|
106
|
-
# its_mimetype_should_be('image/jpeg')
|
107
|
-
# end
|
108
|
-
end
|
109
|
-
end
|
@@ -1,129 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Thumbkit::Processor::Text do
|
4
|
-
|
5
|
-
let(:fixture) { 'text_file.txt' }
|
6
|
-
let(:path) { File.expand_path(path_to_fixture(fixture)) }
|
7
|
-
let(:outfile) { nil }
|
8
|
-
let(:options) { {} }
|
9
|
-
let(:processor) { Thumbkit::Processor::Text.new(path, outfile, options) }
|
10
|
-
subject { processor }
|
11
|
-
|
12
|
-
its(:path) { should == path }
|
13
|
-
|
14
|
-
|
15
|
-
describe '#auto_outflie' do
|
16
|
-
subject { processor.outfile }
|
17
|
-
context 'when nothing specified' do
|
18
|
-
it { should == File.expand_path(path_to_fixture('text_file.png')) }
|
19
|
-
end
|
20
|
-
|
21
|
-
# context 'with an extensionless outfile' do
|
22
|
-
# let(:outfile) { 'foo.' }
|
23
|
-
# it { should == 'foo.png' }
|
24
|
-
# end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe '#write' do
|
28
|
-
let(:outfile) { path_for_output('text-test.png').to_s }
|
29
|
-
subject { processor.write }
|
30
|
-
|
31
|
-
it 'returns the path of the outfile' do
|
32
|
-
subject.should == outfile
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'returns the name of the outfile' do
|
36
|
-
File.basename(subject).should == 'text-test.png'
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'writes a file' do
|
40
|
-
File.should exist(subject)
|
41
|
-
end
|
42
|
-
|
43
|
-
it "doesn't have label in the metadata" do
|
44
|
-
result = `identify -verbose #{ subject }|grep label:`.chomp
|
45
|
-
result.should be_empty
|
46
|
-
end
|
47
|
-
|
48
|
-
its_size_should_be('200x200')
|
49
|
-
its_mimetype_should_be('image/png')
|
50
|
-
|
51
|
-
context 'with size settings' do
|
52
|
-
let(:outfile) { path_for_output('text-test-300x250.png').to_s }
|
53
|
-
# Let's change a few settings for manual inspection
|
54
|
-
let(:options) { { width: 300, height: 250, colors: { background: :transparent, foreground: '#334455' } } }
|
55
|
-
|
56
|
-
its_size_should_be('300x250')
|
57
|
-
its_mimetype_should_be('image/png')
|
58
|
-
# Manually check the file to verify colors
|
59
|
-
end
|
60
|
-
|
61
|
-
context 'with gravity settings' do
|
62
|
-
let(:outfile) { path_for_output('text-test-northeast-150x250.png').to_s }
|
63
|
-
# Let's change a few settings for manual inspection
|
64
|
-
let(:options) { {
|
65
|
-
width: 150, height: 250, gravity: 'NorthEast',
|
66
|
-
colors: { background: :transparent, foreground: '#334455' }
|
67
|
-
} }
|
68
|
-
|
69
|
-
its_size_should_be('150x250')
|
70
|
-
its_mimetype_should_be('image/png')
|
71
|
-
# Manually check the file to verify colors and gravity
|
72
|
-
end
|
73
|
-
|
74
|
-
context 'with some greek letters' do
|
75
|
-
let(:fixture) { 'greek.txt' }
|
76
|
-
let(:options) { { width: 400, height: 400 } }
|
77
|
-
let(:outfile) { path_for_output('greek.png').to_s }
|
78
|
-
it('writes a file') { File.should exist(subject) }
|
79
|
-
it('autodetects left-to-right') { processor.__send__(:direction).should == 'left-to-right' }
|
80
|
-
its_size_should_be('400x400')
|
81
|
-
its_mimetype_should_be('image/png')
|
82
|
-
# Manually check the file to verify unicode stuff worked
|
83
|
-
end
|
84
|
-
|
85
|
-
context 'with an arabic file' do
|
86
|
-
let(:options) { { font: { direction: :auto } } }
|
87
|
-
let(:fixture) { 'arabic.txt' }
|
88
|
-
let(:outfile) { path_for_output('arabic.png').to_s }
|
89
|
-
it('writes a file') { File.should exist(subject) }
|
90
|
-
it('autodetects right-to-left') { processor.__send__(:direction).should == 'right-to-left' }
|
91
|
-
its_size_should_be('200x200')
|
92
|
-
its_mimetype_should_be('image/png')
|
93
|
-
# Manually check the file to verify unicode stuff and right-to-left worked
|
94
|
-
end
|
95
|
-
|
96
|
-
context 'with an hebrew file' do
|
97
|
-
let(:options) { { font: { direction: 'right-to-left', size: '12' }, width: 400 } }
|
98
|
-
let(:fixture) { 'hebrew.txt' }
|
99
|
-
let(:outfile) { path_for_output('hebrew.png').to_s }
|
100
|
-
it('writes a file') { File.should exist(subject) }
|
101
|
-
it('is right-to-left') { processor.__send__(:direction).should == 'right-to-left' }
|
102
|
-
its_size_should_be('400x200')
|
103
|
-
its_mimetype_should_be('image/png')
|
104
|
-
# Manually check the file to verify unicode stuff and right-to-left worked
|
105
|
-
end
|
106
|
-
|
107
|
-
context 'with an uppercase filename' do
|
108
|
-
let(:options) { { } }
|
109
|
-
let(:fixture) { 'OMG_UPPERCASE_TEXT.TXT' }
|
110
|
-
let(:outfile) { path_for_output('OMG_UPPERCASE_TEXT.PNG').to_s }
|
111
|
-
it('writes a file') { File.should exist(subject) }
|
112
|
-
its_size_should_be('200x200')
|
113
|
-
its_mimetype_should_be('image/png')
|
114
|
-
end
|
115
|
-
|
116
|
-
|
117
|
-
context 'with an arabic file to output to jpg' do
|
118
|
-
let(:options) { { width: 600, height: 400 } }
|
119
|
-
let(:fixture) { 'arabic.txt' }
|
120
|
-
let(:outfile) { path_for_output('arabic.jpg').to_s }
|
121
|
-
it('writes a file') { File.should exist(subject) }
|
122
|
-
it('autodetects right-to-left') { processor.__send__(:direction).should == 'right-to-left' }
|
123
|
-
its_size_should_be('600x400')
|
124
|
-
its_mimetype_should_be('image/jpeg')
|
125
|
-
# Manually check the file to verify unicode stuff and right-to-left worked
|
126
|
-
end
|
127
|
-
|
128
|
-
end
|
129
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Thumbkit::Processor do
|
4
|
-
describe '.processor_for' do
|
5
|
-
subject { Thumbkit::Processor.processor_for(extension) }
|
6
|
-
context 'for a .txt' do
|
7
|
-
let(:extension) { 'txt' }
|
8
|
-
it { should == Thumbkit::Processor::Text }
|
9
|
-
end
|
10
|
-
|
11
|
-
context 'for a .mp3' do
|
12
|
-
let(:extension) { 'mp3' }
|
13
|
-
it { should == Thumbkit::Processor::Audio }
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
describe '.force_extension' do
|
18
|
-
let(:extension) { 'png' }
|
19
|
-
subject { Thumbkit::Processor.force_extension path, extension }
|
20
|
-
context 'given an mp3 file' do
|
21
|
-
let(:path) { 'foo/bar/blah.mp3' }
|
22
|
-
it { should == 'foo/bar/blah.png' }
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe '#initialize' do
|
27
|
-
let(:options) { {} }
|
28
|
-
subject { Thumbkit::Processor.new('infile.png', 'outfile.png', options) }
|
29
|
-
|
30
|
-
context 'with no options' do
|
31
|
-
its(:options) { should == Thumbkit.defaults }
|
32
|
-
end
|
33
|
-
|
34
|
-
context 'with some overrides' do
|
35
|
-
let(:options) { { width: 250, height: 250 } }
|
36
|
-
|
37
|
-
it 'overrides the options' do
|
38
|
-
subject.options[:width].should == 250
|
39
|
-
subject.options[:height].should == 250
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'but leaves others' do
|
43
|
-
subject.options[:colors].should == Thumbkit.defaults[:colors]
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
data/spec/thumbkit_spec.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Thumbkit do
|
4
|
-
context 'a .txt file' do
|
5
|
-
subject { Thumbkit.new path_to_fixture('text_file.txt') }
|
6
|
-
|
7
|
-
its(:filename) { should == 'text_file.txt' }
|
8
|
-
its(:path) { should == File.expand_path(path_to_fixture('text_file.txt')) }
|
9
|
-
its(:processor) { should == Thumbkit::Processor::Text }
|
10
|
-
its(:type) { should == 'txt' }
|
11
|
-
end
|
12
|
-
|
13
|
-
context 'with a .mp3 file' do
|
14
|
-
subject { Thumbkit.new path_to_fixture('16Hz-20kHz-Exp-1f-5sec.mp3') }
|
15
|
-
|
16
|
-
its(:filename) { should == '16Hz-20kHz-Exp-1f-5sec.mp3' }
|
17
|
-
its(:path) { should == File.expand_path(path_to_fixture('16Hz-20kHz-Exp-1f-5sec.mp3')) }
|
18
|
-
its(:processor) { should == Thumbkit::Processor::Audio }
|
19
|
-
its(:type) { should == 'mp3' }
|
20
|
-
end
|
21
|
-
|
22
|
-
context 'with an array' do
|
23
|
-
let(:files) { [path_to_fixture('16Hz-20kHz-Exp-1f-5sec.mp3'), path_to_fixture('text_file.txt')] }
|
24
|
-
subject { Thumbkit.new files }
|
25
|
-
|
26
|
-
its(:processor) { should == Thumbkit::Processor::Collection }
|
27
|
-
end
|
28
|
-
|
29
|
-
context 'with an unknown extension' do
|
30
|
-
subject { Thumbkit.new 'this_extension.no_exist_i_promise' }
|
31
|
-
it 'raises an ArgumentError' do
|
32
|
-
expect { subject }.to raise_error(ArgumentError)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe Thumbkit, '.defaults' do
|
38
|
-
subject { Thumbkit.defaults }
|
39
|
-
|
40
|
-
it 'returns defaults for colors' do
|
41
|
-
subject.should have_key(:colors)
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'returns defaults for font' do
|
45
|
-
subject.should have_key(:font)
|
46
|
-
end
|
47
|
-
end
|
data/thumbkit.gemspec
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
require File.expand_path('../lib/thumbkit/version', __FILE__)
|
3
|
-
|
4
|
-
Gem::Specification.new do |gem|
|
5
|
-
gem.authors = ["Amiel Martin"]
|
6
|
-
gem.email = ["amiel@carnesmedia.com"]
|
7
|
-
gem.description = %q{Thumbkit makes thumbnails!}
|
8
|
-
gem.summary = %q{Thumbkit makes thumbnails from a variety of media types.}
|
9
|
-
gem.homepage = "http://github.com/carnesmedia/thumbkit"
|
10
|
-
|
11
|
-
# TODO: Remove dependency on git
|
12
|
-
gem.files = `git ls-files`.split($\)
|
13
|
-
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
14
|
-
gem.test_files = gem.files.grep(%r{^(spec)/})
|
15
|
-
gem.name = "thumbkit"
|
16
|
-
gem.require_paths = ["lib"]
|
17
|
-
gem.version = Thumbkit::VERSION
|
18
|
-
end
|