imgkit 1.6.0 → 1.6.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b6db8c1811095b219f1f7a4fabf5c8cd17f1185e
4
- data.tar.gz: 934d7ca922cf72789af64fb78c13e82721c8f8ed
3
+ metadata.gz: 4a5ed8f0be7c4decfabdf2d979460cb8697f2b05
4
+ data.tar.gz: 7e1b079b97fc5f9f71c3d1e62d242aa1ab3177db
5
5
  SHA512:
6
- metadata.gz: 85fd2c927e505b17de2dd6d5f965fdf02e27d6a330a14fa2504e9518f46c5dbb7d5b595140557eb1da587bce7263d13d6b2a2a7a1d9d6f783d13053d2b303e46
7
- data.tar.gz: 7eb58a359bbbe0ed8e7e8833f025f9a51a5d4b2bad9082ad12237dc75a64982e1757739fef9e675fb24a2b0af73c10323ed2f2236d9bee50cf2d5105e74ff786
6
+ metadata.gz: 941f53f2c3fb7391999e54c81fcf036f6f1e94929f056a5d1979d8372865134fa120305ccbd2563c0b689bae8d2a826717933480e3405f4c36da40ac9d8f4f37
7
+ data.tar.gz: 0a407a93a60d9007edda86266bc373614cde9a614419c41d9cee98983ab1f688bf005c6bd8dbdf7b6859cdc7456e0d6b8abf94bf013478f14d203708ed3e7f32
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- imgkit (1.6.0)
4
+ imgkit (1.6.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/bin/imgkit CHANGED
@@ -9,7 +9,7 @@ require 'imgkit/version'
9
9
  GOOGLE_CODE_URL = ENV['GOOGLE_CODE_URL'] || "http://code.google.com/p/wkhtmltopdf/downloads/list?can=1"
10
10
 
11
11
  def detect_architecture
12
- case arch = Config::CONFIG['arch']
12
+ case arch = RbConfig::CONFIG['arch']
13
13
  when /x86_64-linux/i
14
14
  'amd64'
15
15
  when /linux/i
@@ -33,7 +33,7 @@ def cleanup(install_to)
33
33
  end
34
34
 
35
35
  def download_wkhtmltoimage(arch)
36
- if ENV['BZIP']
36
+ if ENV['BZIP']
37
37
  download = "wkhtmltoimage-0.10.0_beta4-static-#{arch}.tar.bz2"
38
38
  url = "http://wkhtmltopdf.googlecode.com/files/wkhtmltoimage-0.10.0_beta4-static-#{arch}.tar.bz2"
39
39
  else
@@ -43,7 +43,7 @@ def download_wkhtmltoimage(arch)
43
43
  url = "http://wkhtmltopdf.googlecode.com/files/#{download}"
44
44
  end
45
45
  puts "Downloading #{download} from #{url}"
46
-
46
+
47
47
  `curl #{url} > #{download}`
48
48
  download
49
49
  end
@@ -77,9 +77,9 @@ OptionParser.new do |parser|
77
77
  @command = Proc.new do
78
78
  architecture = ENV['ARCHITECTURE'] || detect_architecture
79
79
  install_to = ENV['TO'] ? ENV['TO']+'/wkhtmltoimage' : IMGKit.configuration.wkhtmltoimage
80
-
80
+
81
81
  Dir.chdir '/tmp'
82
-
82
+
83
83
  cleanup(install_to)
84
84
  download = download_wkhtmltoimage(architecture)
85
85
  install(download, architecture, install_to)
@@ -45,7 +45,7 @@ class IMGKit
45
45
  raise NoExecutableError.new unless File.exists?(IMGKit.configuration.wkhtmltoimage)
46
46
  end
47
47
 
48
- def command
48
+ def command(output_file = nil)
49
49
  args = [executable]
50
50
  args += normalize_options(@options).to_a.flatten.compact
51
51
 
@@ -55,7 +55,12 @@ class IMGKit
55
55
  args << @source.to_s
56
56
  end
57
57
 
58
- args << '-' # Read IMG from stdout
58
+ if output_file
59
+ args << output_file.to_s
60
+ else
61
+ args << '-' # Read IMG from stdout
62
+ end
63
+
59
64
  args
60
65
  end
61
66
 
@@ -101,23 +106,22 @@ class IMGKit
101
106
  end
102
107
  end
103
108
 
104
- def to_img(format = nil)
109
+ def to_img(format = nil, path = nil)
105
110
  append_stylesheets
106
111
  append_javascripts
107
112
  set_format(format)
108
113
 
109
114
  opts = @source.html? ? {:stdin_data => @source.to_s} : {}
110
- result, stderr = capture3(*(command + [opts]))
115
+ result, stderr = capture3(*(command(path) + [opts]))
111
116
  result.force_encoding("ASCII-8BIT") if result.respond_to? :force_encoding
112
-
113
- raise CommandFailedError.new(command.join(' '), stderr) if result.size == 0
117
+ raise CommandFailedError.new(command.join(' '), stderr) if path.nil? and result.size == 0
114
118
  result
115
119
  end
116
120
 
117
121
  def to_file(path)
118
122
  format = File.extname(path).gsub(/^\./,'').to_sym
119
- set_format(format)
120
- File.open(path,'w:ASCII-8BIT') {|file| file << self.to_img}
123
+ self.to_img(format, path)
124
+ File.new(path)
121
125
  end
122
126
 
123
127
  def method_missing(name, *args, &block)
@@ -1,3 +1,3 @@
1
1
  class IMGKit
2
- VERSION = "1.6.0"
2
+ VERSION = "1.6.1"
3
3
  end
@@ -282,12 +282,11 @@ describe IMGKit do
282
282
  File.delete(@file_path) if File.exist?(@file_path)
283
283
  end
284
284
 
285
- it "should create a file with the result of :to_img as content" do
285
+ it "should create a binary file" do
286
286
  imgkit = IMGKit.new('html', :quality => 50)
287
- imgkit.expects(:to_img).returns('CONTENT')
288
287
  file = imgkit.to_file(@file_path)
289
288
  file.should be_instance_of(File)
290
- File.read(file.path).should == 'CONTENT'
289
+ File.exists?(file.path).should be_true
291
290
  end
292
291
 
293
292
  IMGKit::KNOWN_FORMATS.each do |format|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imgkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - csquared
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-17 00:00:00.000000000 Z
11
+ date: 2015-05-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Uses wkhtmltoimage to create Images using HTML
14
14
  email: christopher.continanza@gmail.com
@@ -17,11 +17,11 @@ executables:
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
- - ".document"
21
- - ".gitignore"
22
- - ".rspec"
23
- - ".rvmrc"
24
- - ".travis.yml"
20
+ - .document
21
+ - .gitignore
22
+ - .rspec
23
+ - .rvmrc
24
+ - .travis.yml
25
25
  - Gemfile
26
26
  - Gemfile.lock
27
27
  - LICENSE
@@ -65,17 +65,17 @@ require_paths:
65
65
  - lib
66
66
  required_ruby_version: !ruby/object:Gem::Requirement
67
67
  requirements:
68
- - - ">="
68
+ - - '>='
69
69
  - !ruby/object:Gem::Version
70
70
  version: '0'
71
71
  required_rubygems_version: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - '>='
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  requirements: []
77
77
  rubyforge_project: imgkit
78
- rubygems_version: 2.2.2
78
+ rubygems_version: 2.0.14
79
79
  signing_key:
80
80
  specification_version: 4
81
81
  summary: HTML+CSS -> JPG