pdfunite 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +5 -0
- data/LICENSE +22 -0
- data/README.md +1 -8
- data/lib/pdfunite.rb +20 -2
- data/lib/pdfunite/version.rb +1 -1
- metadata +4 -3
- data/Gemfile +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aec7840f94b79b8e0f9dbe6c6e6b5f3b5240e1c3
|
4
|
+
data.tar.gz: ba5134602e29d237580b079d525da4d264399d59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8459093ce02a57d73bdabef10bcd46f33eaca580dfc054ea9f12a3611f426c060a9d56f68c730b3f21ab97ec583129b002d9fe283ed4cddfa427d3269da898e7
|
7
|
+
data.tar.gz: f7876915782be2775cb7cc4cb739037448bb812a2a6f179cba12c9f6b5e643b626073d89cc92277819ee56a65d3d419596eccdb78626777ed28d23546ba4b521
|
data/CHANGELOG
ADDED
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
|
data/lib/pdfunite.rb
CHANGED
@@ -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(
|
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
|
-
|
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
|
data/lib/pdfunite/version.rb
CHANGED
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.
|
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-
|
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
|
-
-
|
104
|
+
- CHANGELOG
|
105
|
+
- LICENSE
|
105
106
|
- README.md
|
106
107
|
- Rakefile
|
107
108
|
- lib/pdfunite.rb
|
data/Gemfile
DELETED