hypdf 1.0.12 → 1.0.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 073c9668467f61419dc4cd6a9b4c19230a24660d
4
- data.tar.gz: ac21441bfb6f8ef8dd8f2a0a64199a727391beb3
3
+ metadata.gz: 7806e0a3f5245e1f8f0ef3c8ec093a2e62a937d0
4
+ data.tar.gz: 212ddeafa0f0de0458609b903da27870bd46524a
5
5
  SHA512:
6
- metadata.gz: 413d7493756b729f80ad893282e51372ff6c05ec9b123c7f3d21acd15ea4c75413ca96f9b6437004f5b742a25ae96603abd5af9592652f6113c4218840a247fe
7
- data.tar.gz: b7eeaeadfdb50a9999ba79ef2793e5cb078c3a34d32cca651ed644a39c6f7d191cd11932fcdef0d52a08b13553a75985faf31d21f2d0ac80c2f37143596ff840
6
+ metadata.gz: d997c49f90c1997041db28a384e88de3b0a29d6e1df2a4a0cc20d1d7330bfe6e8d906e64db072422ddaf1dbc4e3f080c0d0b2e18673027005594823874a7c6c3
7
+ data.tar.gz: 357310b16bc18629c16168d14ed28c4293da82f7f2ca273d3c3f5850c73bc8b7fa5725cd0fe86190952169b41335104ee97c4aa64901f07e1278741c1ac014a1
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ spec/environment.rb
data/hypdf.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |gem|
10
10
  gem.email = ["up.redfield@gmail.com"]
11
11
  gem.description = %q{Ruby wrapper around the HyPDF API}
12
12
  gem.summary = %q{Ruby wrapper around the HyPDF API}
13
- gem.homepage = "https://www.hypdf.com"
13
+ gem.homepage = "https://bitbucket.org/quantumgears/hypdf_gem"
14
14
  gem.license = "MIT"
15
15
 
16
16
  gem.files = `git ls-files`.split($/)
@@ -19,4 +19,5 @@ Gem::Specification.new do |gem|
19
19
  gem.require_paths = ["lib"]
20
20
  gem.add_dependency "httparty", "~> 0.13"
21
21
  gem.add_dependency "httmultiparty", "~> 0.3"
22
+ gem.add_development_dependency "rspec"
22
23
  end
data/lib/hypdf.rb CHANGED
@@ -80,8 +80,8 @@ class HyPDF
80
80
 
81
81
  def pdfunite(*params)
82
82
  options = params.last.is_a?(Hash) ? params.delete_at(-1) : {}
83
- params.each_with_index do |path, index|
84
- options.merge!("file_#{index}" => File.new(path))
83
+ params.each_with_index do |param, index|
84
+ options.merge!("file_#{index}" => file_for(param, index))
85
85
  end
86
86
  response = request('pdfunite', options).body
87
87
 
@@ -92,8 +92,40 @@ class HyPDF
92
92
  end
93
93
  end
94
94
 
95
+ def readform(file, options = {})
96
+ options.merge!(file: File.new(file))
97
+ JSON.parse(request('readform', options).body)
98
+ end
99
+
100
+ def fillform(file, options = {})
101
+ options.merge!(file: File.new(file))
102
+ response = request('fillform', options).body
103
+
104
+ if options[:bucket].nil?
105
+ {pdf: response}
106
+ else
107
+ JSON.parse(response, symbolize_names: true)
108
+ end
109
+ end
110
+
95
111
  private
96
112
 
113
+ def file_for(param, index)
114
+ if pdf_header?(param)
115
+ uploadable_file(param, "file_#{index}.pdf")
116
+ else
117
+ File.new(param)
118
+ end
119
+ end
120
+
121
+ def pdf_header?(arg)
122
+ arg.is_a?(String) && arg.start_with?('%PDF-')
123
+ end
124
+
125
+ def uploadable_file(string, filename)
126
+ UploadIO.new(StringIO.new(string), 'application/octet-stream', filename)
127
+ end
128
+
97
129
  def request(method, body)
98
130
  body[:user] ||= ENV["HYPDF_USER"]
99
131
  body[:password] ||= ENV["HYPDF_PASSWORD"]
data/lib/hypdf/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class HyPDF
2
- VERSION = "1.0.12"
2
+ VERSION = "1.0.13"
3
3
  end
data/spec/hypdf_spec.rb CHANGED
@@ -1,7 +1,21 @@
1
1
  require 'spec_helper'
2
+ require 'environment' if File.exists?(File.expand_path('../environment.rb', __FILE__)) # sets HYPDF_USER and HYPDF_PASSWORD environment variables
2
3
 
3
4
  describe HyPDF do
4
5
  it 'should have a version number' do
5
- HyPDF::VERSION.should_not be_nil
6
+ expect(HyPDF::VERSION).to_not be_nil
7
+ end
8
+
9
+ let(:html) { '<!DOCTYPE html><html><head></head><body>This is some text</body></html>' }
10
+ let(:hypdf) { HyPDF.htmltopdf(html, test: true) }
11
+
12
+ it 'should create pdf from html' do
13
+ expect(hypdf).to include(pages: 1)
14
+ end
15
+
16
+ let(:pdf) { hypdf[:pdf].force_encoding('UTF-8') }
17
+
18
+ it 'should concatenate two pdfs' do
19
+ expect(HyPDF.pdfunite(pdf, pdf, test: true)).to have_key(:pdf)
6
20
  end
7
21
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hypdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.12
4
+ version: 1.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - redfield
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-28 00:00:00.000000000 Z
11
+ date: 2016-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
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'
41
55
  description: Ruby wrapper around the HyPDF API
42
56
  email:
43
57
  - up.redfield@gmail.com
@@ -57,7 +71,7 @@ files:
57
71
  - lib/hypdf/version.rb
58
72
  - spec/hypdf_spec.rb
59
73
  - spec/spec_helper.rb
60
- homepage: https://www.hypdf.com
74
+ homepage: https://bitbucket.org/quantumgears/hypdf_gem
61
75
  licenses:
62
76
  - MIT
63
77
  metadata: {}