imgkit 1.3.10 → 1.4.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/Gemfile.lock +1 -1
- data/lib/imgkit/configuration.rb +15 -3
- data/lib/imgkit/version.rb +1 -1
- data/spec/configuration_spec.rb +59 -0
- metadata +6 -4
data/Gemfile.lock
CHANGED
data/lib/imgkit/configuration.rb
CHANGED
@@ -1,13 +1,25 @@
|
|
1
1
|
class IMGKit
|
2
2
|
class Configuration
|
3
|
-
|
3
|
+
attr_writer :wkhtmltoimage
|
4
|
+
attr_accessor :meta_tag_prefix, :default_options, :default_format
|
4
5
|
|
5
6
|
def initialize
|
6
7
|
@meta_tag_prefix = 'imgkit-'
|
7
8
|
@default_options = {:height => 1000}
|
8
9
|
@default_format = :jpg
|
9
|
-
|
10
|
-
|
10
|
+
end
|
11
|
+
|
12
|
+
def wkhtmltoimage
|
13
|
+
@wkhtmltoimage ||= begin
|
14
|
+
path = (using_bundler? ? `bundle exec which wkhtmltoimage` : `which wkhtmltoimage`).chomp
|
15
|
+
path = '/usr/local/bin/wkhtmltoimage' if path.strip.empty? # Fallback
|
16
|
+
path
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
def using_bundler?
|
22
|
+
defined?(Bundler::GemfileError)
|
11
23
|
end
|
12
24
|
end
|
13
25
|
|
data/lib/imgkit/version.rb
CHANGED
@@ -0,0 +1,59 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe IMGKit::Configuration do
|
4
|
+
describe "#wkhtmltoimage" do
|
5
|
+
context "system version exists" do
|
6
|
+
let(:system_path) { "/path/to/wkhtmltoimage\n" }
|
7
|
+
|
8
|
+
before(:each) do
|
9
|
+
subject.stub :` => system_path
|
10
|
+
end
|
11
|
+
|
12
|
+
context "with Bundler" do
|
13
|
+
before(:each) do
|
14
|
+
subject.stub :using_bundler? => true
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should return the result of `bundle exec which wkhtmltoimage` with whitespace stripped" do
|
18
|
+
subject.should_receive(:`).with("bundle exec which wkhtmltoimage")
|
19
|
+
subject.wkhtmltoimage.should == system_path.chomp
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "without Bundler" do
|
24
|
+
before(:each) do
|
25
|
+
subject.stub :using_bundler? => false
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should return the result of `which wkhtmltoimage` with whitespace stripped" do
|
29
|
+
subject.should_receive(:`).with("which wkhtmltoimage")
|
30
|
+
subject.wkhtmltoimage.should == system_path.chomp
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context "system version does not exist" do
|
36
|
+
before(:each) do
|
37
|
+
subject.stub :` => "\n"
|
38
|
+
subject.stub :using_bundler? => false
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should return the fallback path" do
|
42
|
+
subject.wkhtmltoimage.should == "/usr/local/bin/wkhtmltoimage"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context "set explicitly" do
|
47
|
+
let(:explicit_path) { "/explicit/path/to/wkhtmltoimage" }
|
48
|
+
|
49
|
+
before(:each) do
|
50
|
+
subject.wkhtmltoimage = explicit_path
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should not check the system version and return the explicit path" do
|
54
|
+
subject.should_not_receive(:`)
|
55
|
+
subject.wkhtmltoimage.should == explicit_path
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: imgkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
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:
|
12
|
+
date: 2014-02-14 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Uses wkhtmltoimage to create Images using HTML
|
15
15
|
email: christopher.continanza@gmail.com
|
@@ -35,6 +35,7 @@ files:
|
|
35
35
|
- lib/imgkit/imgkit.rb
|
36
36
|
- lib/imgkit/source.rb
|
37
37
|
- lib/imgkit/version.rb
|
38
|
+
- spec/configuration_spec.rb
|
38
39
|
- spec/error_binary
|
39
40
|
- spec/fixtures/example.css
|
40
41
|
- spec/fixtures/example.html
|
@@ -61,7 +62,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
61
62
|
version: '0'
|
62
63
|
segments:
|
63
64
|
- 0
|
64
|
-
hash: -
|
65
|
+
hash: -2785353123807079228
|
65
66
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
67
|
none: false
|
67
68
|
requirements:
|
@@ -70,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
71
|
version: '0'
|
71
72
|
segments:
|
72
73
|
- 0
|
73
|
-
hash: -
|
74
|
+
hash: -2785353123807079228
|
74
75
|
requirements: []
|
75
76
|
rubyforge_project: imgkit
|
76
77
|
rubygems_version: 1.8.23
|
@@ -78,6 +79,7 @@ signing_key:
|
|
78
79
|
specification_version: 3
|
79
80
|
summary: HTML+CSS -> JPG
|
80
81
|
test_files:
|
82
|
+
- spec/configuration_spec.rb
|
81
83
|
- spec/error_binary
|
82
84
|
- spec/fixtures/example.css
|
83
85
|
- spec/fixtures/example.html
|