paperclip-phantom_svg 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/paperclip_processors/phantom_processor.rb +10 -10
- data/paperclip-phantom_svg.gemspec +4 -5
- data/spec/paperclip-phantom_svg_spec.rb +31 -4
- metadata +8 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11b6ff07a800f3e087db6fdaa382bf963af8560b
|
4
|
+
data.tar.gz: f981a80c4846d2d3a38fad42d94042cf6a297b1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86e8f206b5fb1c4d3b3cd7de9fa93ce92208b25977bdce08c1eedc7ae437e17e4967870cdbd6419b36037cdd97efadb3f80d186f64e6968980f0ed79a86b3f99
|
7
|
+
data.tar.gz: 67581f3e54e163b517c4271d04b26bbd18039cf920c5215f1997dc81032289c2835b138fb366a1cdc37adef81ec3434769961bd323625da3a0dab63eb78f3b62
|
@@ -4,7 +4,7 @@ require 'paperclip'
|
|
4
4
|
module Paperclip
|
5
5
|
# Phantom SVG processor for Paperclip
|
6
6
|
class PhantomProcessor < Processor
|
7
|
-
attr_accessor :format, :height, :width, :dst
|
7
|
+
attr_accessor :format, :height, :width, :dst, :file
|
8
8
|
def initialize(file, options = {}, attachment = nil)
|
9
9
|
super
|
10
10
|
@format = options.fetch(:format, :svg)
|
@@ -28,20 +28,20 @@ module Paperclip
|
|
28
28
|
private
|
29
29
|
|
30
30
|
def _create_svg
|
31
|
-
@dst = Tempfile.new([@output_name, '.svg']).tap do |
|
31
|
+
@dst = Tempfile.new([@output_name, '.svg']).tap do |dst|
|
32
32
|
Paperclip.log "[PhantomSVG] Creating SVG #{@output_name}" if @whiny
|
33
|
-
@svg.height =
|
34
|
-
@svg.width =
|
35
|
-
@svg.save_svg(
|
33
|
+
@svg.height = height
|
34
|
+
@svg.width = width
|
35
|
+
@svg.save_svg(dst.path)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
39
|
def _create_png
|
40
|
-
@dst = Tempfile.new([@output_name, '.png']).tap do |
|
41
|
-
Paperclip.log "[PhantomSVG] Creating
|
42
|
-
@svg.height =
|
43
|
-
@svg.width =
|
44
|
-
@svg.save_apng(
|
40
|
+
@dst = Tempfile.new([@output_name, '.png']).tap do |dst|
|
41
|
+
Paperclip.log "[PhantomSVG] Creating PNG #{@output_name} @ #{@height}x#{@width}" if @whiny
|
42
|
+
@svg.height = height
|
43
|
+
@svg.width = width
|
44
|
+
@svg.save_apng(dst.path)
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.platform = Gem::Platform::RUBY
|
3
3
|
s.name = 'paperclip-phantom_svg'
|
4
|
-
s.version = '0.0.
|
5
|
-
s.license = 'LGPL-3
|
4
|
+
s.version = '0.0.3'
|
5
|
+
s.license = 'LGPL-3'
|
6
6
|
s.summary = 'SVG and Raster (primarily PNG) conerters for Paperclip' \
|
7
7
|
' that don\'t suck so much.'
|
8
8
|
s.description = 'Hight end SVG conversion suite for Paperclip. ' \
|
@@ -17,10 +17,9 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.test_files = s.files.grep(/^spec\//)
|
18
18
|
s.require_paths = ['lib']
|
19
19
|
|
20
|
-
s.add_dependency 'paperclip'
|
21
|
-
s.add_dependency 'phantom_svg'
|
20
|
+
s.add_dependency 'paperclip', '~> 4.2'
|
21
|
+
s.add_dependency 'phantom_svg' '~> 1.1'
|
22
22
|
|
23
|
-
s.add_development_dependency 'bundler'
|
24
23
|
s.add_development_dependency 'rspec'
|
25
24
|
s.add_development_dependency 'activerecord'
|
26
25
|
s.add_development_dependency 'sqlite3'
|
@@ -3,6 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe Paperclip::PhantomProcessor do
|
4
4
|
before(:all) do
|
5
5
|
clear_tmp
|
6
|
+
FileUtils::mkdir_p 'tmp/'
|
6
7
|
end
|
7
8
|
|
8
9
|
let(:svg_source) { File.new(fixture_file('compiled.svg')) }
|
@@ -30,6 +31,7 @@ describe Paperclip::PhantomProcessor do
|
|
30
31
|
processor = Paperclip::PhantomProcessor.new(svg_source, test_options_svg)
|
31
32
|
expect(processor.make).to be_an_instance_of(Paperclip::Tempfile)
|
32
33
|
expect(File).to exist(processor.dst.path)
|
34
|
+
FileUtils.copy(processor.dst.path, 'tmp/')
|
33
35
|
end
|
34
36
|
end
|
35
37
|
|
@@ -38,40 +40,65 @@ describe Paperclip::PhantomProcessor do
|
|
38
40
|
processor = Paperclip::PhantomProcessor.new(svg_source, test_options_png)
|
39
41
|
expect(processor.make).to be_an_instance_of(Paperclip::Tempfile)
|
40
42
|
expect(File).to exist(processor.dst.path)
|
43
|
+
FileUtils.copy(processor.dst.path, 'tmp/')
|
41
44
|
end
|
42
45
|
end
|
43
46
|
|
44
47
|
describe '.make({format: :png, height: 64})' do
|
45
|
-
it 'saves a PNG from an SVG' do
|
48
|
+
it 'saves a PNG with height only specefied from an SVG' do
|
46
49
|
processor = Paperclip::PhantomProcessor.new(svg_source, test_options_png_h)
|
47
50
|
expect(processor.make).to be_an_instance_of(Paperclip::Tempfile)
|
48
51
|
expect(File).to exist(processor.dst.path)
|
52
|
+
FileUtils.copy(processor.dst.path, 'tmp/')
|
49
53
|
end
|
50
54
|
end
|
51
55
|
end
|
52
56
|
|
53
57
|
context 'with an animated PNG source' do
|
54
58
|
describe '.make({format: :svg})' do
|
55
|
-
it 'saves an SVG from
|
59
|
+
it 'saves an SVG from a PNG' do
|
56
60
|
processor = Paperclip::PhantomProcessor.new(png_source, test_options_svg)
|
57
61
|
expect(processor.make).to be_an_instance_of(Paperclip::Tempfile)
|
58
62
|
expect(File).to exist(processor.dst.path)
|
63
|
+
FileUtils.copy(processor.dst.path, 'tmp/')
|
59
64
|
end
|
60
65
|
end
|
61
66
|
|
62
67
|
describe '.make({format: :png, height: 128, width: 128})' do
|
63
|
-
it 'saves a PNG from an
|
68
|
+
it 'saves a PNG from an PNG' do
|
64
69
|
processor = Paperclip::PhantomProcessor.new(png_source, test_options_png)
|
65
70
|
expect(processor.make).to be_an_instance_of(Paperclip::Tempfile)
|
66
71
|
expect(File).to exist(processor.dst.path)
|
72
|
+
FileUtils.copy(processor.dst.path, 'tmp/')
|
67
73
|
end
|
68
74
|
end
|
69
75
|
|
70
76
|
describe '.make({format: :png, height: 64})' do
|
71
|
-
it 'saves a PNG from
|
77
|
+
it 'saves a PNG with only height specified from a PNG' do
|
72
78
|
processor = Paperclip::PhantomProcessor.new(png_source, test_options_png_h)
|
73
79
|
expect(processor.make).to be_an_instance_of(Paperclip::Tempfile)
|
74
80
|
expect(File).to exist(processor.dst.path)
|
81
|
+
FileUtils.copy(processor.dst.path, 'tmp/')
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe '.make({format: :png, height: 12, width: 12})' do
|
86
|
+
it 'saves a small PNG from a PNG' do
|
87
|
+
processor = Paperclip::PhantomProcessor.new(png_source,
|
88
|
+
{ format: :png, height: 12, width: 12 })
|
89
|
+
expect(processor.make).to be_an_instance_of(Paperclip::Tempfile)
|
90
|
+
expect(File).to exist(processor.dst.path)
|
91
|
+
FileUtils.copy(processor.dst.path, 'tmp/')
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe '.make({format: :svg, height: 12, width: 12})' do
|
96
|
+
it 'saves a small SVG from a PNG' do
|
97
|
+
processor = Paperclip::PhantomProcessor.new(png_source,
|
98
|
+
{ format: :svg, height: 12, width: 12 })
|
99
|
+
expect(processor.make).to be_an_instance_of(Paperclip::Tempfile)
|
100
|
+
expect(File).to exist(processor.dst.path)
|
101
|
+
FileUtils.copy(processor.dst.path, 'tmp/')
|
75
102
|
end
|
76
103
|
end
|
77
104
|
end
|
metadata
CHANGED
@@ -1,31 +1,31 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paperclip-phantom_svg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rei Kagetsuki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09
|
11
|
+
date: 2014-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: paperclip
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '4.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '4.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name: phantom_svg
|
28
|
+
name: phantom_svg~> 1.1
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
@@ -38,20 +38,6 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: bundler
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: rspec
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -118,7 +104,7 @@ files:
|
|
118
104
|
- spec/spec_helper.rb
|
119
105
|
homepage: http://github.com/Genshin/phantom_svg-paperclip-processor
|
120
106
|
licenses:
|
121
|
-
- LGPL-3
|
107
|
+
- LGPL-3
|
122
108
|
metadata: {}
|
123
109
|
post_install_message:
|
124
110
|
rdoc_options: []
|
@@ -146,4 +132,3 @@ test_files:
|
|
146
132
|
- spec/fixtures/compiled.svg
|
147
133
|
- spec/paperclip-phantom_svg_spec.rb
|
148
134
|
- spec/spec_helper.rb
|
149
|
-
has_rdoc:
|