pdfunite 0.1.0 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 89773309019915428c104ddf686d5a3d2cf35606
4
- data.tar.gz: 8e0a20e7120789a152724fb2463081a70006f571
3
+ metadata.gz: aec7840f94b79b8e0f9dbe6c6e6b5f3b5240e1c3
4
+ data.tar.gz: ba5134602e29d237580b079d525da4d264399d59
5
5
  SHA512:
6
- metadata.gz: dc388270803c5927874755b242736257468d87cae8cf7c2762a143510d7b9bb2d0b2e30be7684a6b271e203f404d19f2621be088c6269be6d62e4d316c7d741b
7
- data.tar.gz: cd4f0501cbafa5179d1255dc3e540ec8b22356fc14cfa3dde56135a84aa50103b4860e035e528458f41df46dc08f18d1c993bf29745d2a5893b354f030e36480
6
+ metadata.gz: 8459093ce02a57d73bdabef10bcd46f33eaca580dfc054ea9f12a3611f426c060a9d56f68c730b3f21ab97ec583129b002d9fe283ed4cddfa427d3269da898e7
7
+ data.tar.gz: f7876915782be2775cb7cc4cb739037448bb812a2a6f179cba12c9f6b5e643b626073d89cc92277819ee56a65d3d419596eccdb78626777ed28d23546ba4b521
@@ -0,0 +1,5 @@
1
+ 0.2.0 - Nov 27, 2014
2
+
3
+ * added Pdfunite.binary configuration option
4
+
5
+
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Matthias Grosser
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
data/README.md CHANGED
@@ -30,15 +30,8 @@ gem 'pdfunite'
30
30
  ```ruby
31
31
  # Join existing PDF files
32
32
  pdf_data = Pdfunite.join('file1.pdf', 'file2.pdf', 'file3.pdf')
33
+ File.open('joined.pdf', 'wb') { f << pdf_data }
33
34
 
34
35
  # Join PDF binary data provided by a collection of objects
35
36
  pdf_data = Pdfunite.join(objects) { |obj| obj.to_pdf }
36
37
  ```
37
-
38
- ## Contributing
39
-
40
- 1. Fork it ( https://github.com/[my-github-username]/pdfunite/fork )
41
- 2. Create your feature branch (`git checkout -b my-new-feature`)
42
- 3. Commit your changes (`git commit -am 'Add some feature'`)
43
- 4. Push to the branch (`git push origin my-new-feature`)
44
- 5. Create a new Pull Request
@@ -1,10 +1,13 @@
1
1
  require 'pdfunite/version'
2
+ require 'tmpdir'
2
3
  require 'pathname'
3
4
  require 'cocaine'
4
5
  require 'logger'
5
6
 
6
7
  module Pdfunite
7
8
 
9
+ class BinaryNotFound < StandardError; end
10
+
8
11
  class << self
9
12
 
10
13
  @@logger = nil
@@ -18,6 +21,17 @@ module Pdfunite
18
21
  @@logger
19
22
  end
20
23
 
24
+ @@binary = 'pdfunite'
25
+
26
+ # You can set a custom pdfunite binary here
27
+ def binary=(binary)
28
+ @@binary = binary
29
+ end
30
+
31
+ def binary
32
+ @@binary
33
+ end
34
+
21
35
  #
22
36
  # Join PDF files or PDF data
23
37
  #
@@ -35,9 +49,13 @@ module Pdfunite
35
49
  tmpfile.open('wb') { |f| f << data }
36
50
  hsh.update(:"f_#{idx}" => tmpfile.realpath.to_s)
37
51
  end
38
- cmdline = Cocaine::CommandLine.new('pdfunite', "#{files.keys.map(&:inspect).join(' ')} :outfile", logger: Pdfunite.logger || Logger.new(STDOUT))
52
+ cmdline = Cocaine::CommandLine.new(binary, "#{files.keys.map(&:inspect).join(' ')} :outfile", logger: Pdfunite.logger || Logger.new(STDOUT))
39
53
  outfile = tmpdir.join('output.pdf')
40
- cmdline.run(files.merge(outfile: outfile.to_s))
54
+ begin
55
+ cmdline.run(files.merge(outfile: outfile.to_s))
56
+ rescue Cocaine::CommandNotFoundError
57
+ raise BinaryNotFound, "The pdfunite executable could not be found at #{binary.inspect}. Check the pdfunite README for more info."
58
+ end
41
59
  output = outfile.binread
42
60
  end
43
61
  output
@@ -1,3 +1,3 @@
1
1
  module Pdfunite
2
- VERSION = "0.1.0"
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pdfunite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthias Grosser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-10 00:00:00.000000000 Z
11
+ date: 2014-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocaine
@@ -101,7 +101,8 @@ executables: []
101
101
  extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
- - Gemfile
104
+ - CHANGELOG
105
+ - LICENSE
105
106
  - README.md
106
107
  - Rakefile
107
108
  - lib/pdfunite.rb
data/Gemfile DELETED
@@ -1,3 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec