pdfdetach 0.16.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 83aef705306885cd6f45593096fb050f46933b5ef5b486a8e5aa2b929517f6d4
4
+ data.tar.gz: 3e2638da89ed2e8e41e59115105587c9b4b554a2606f7bd5f74195df16f23810
5
+ SHA512:
6
+ metadata.gz: 4c1f6bc18f69d59a0a1ff2eb6f4d07f4960c310c676ae233d54b72228c784a2942d92d45bf61ea0cd4607593cfaf11e5944349848488893e2efead705a6547e1
7
+ data.tar.gz: 50e86695b107a1a3be9ed7e14f146c2a6d2d80418c795fa6d2b936241bcf40d4e776b019f2a15788899b56ae03a989f189bd7c1c8fb85813059cf5266df34918
@@ -0,0 +1,14 @@
1
+ bin/*
2
+ !bin/16.04
3
+ libc.so.6
4
+ libdl.so.2
5
+ libexpat.so.1
6
+ libgcc_s.so.1
7
+ liblzma.so.5
8
+ libm.so.6
9
+ libthread.so.0
10
+ libstdc++.so.6
11
+ libuuid.so.1
12
+ libz.so.1
13
+ libzstd.so.1
14
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rake/testtask'
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << 'test'
8
+ t.libs << 'lib'
9
+ t.test_files = FileList['test/**/*_test.rb']
10
+ end
11
+
12
+ desc 'Run tests'
13
+ task default: :test
Binary file
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'pdfdetach/version'
4
+ require 'pdfdetach/configuration'
5
+ require 'pdfdetach/main'
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ class PDFDetach
5
+ # Catch and configure pdfdetach binary path
6
+ class Configuration
7
+ attr_accessor :binary_path
8
+
9
+ def initialize
10
+ @binary_path = nil
11
+ end
12
+ end
13
+
14
+ # On a initializer or somewhere else in your code, if you want to use a different version or binary
15
+ # instead of the binary provided in this gem, you can assign a path for a binary like this:
16
+ #
17
+ # PDFDetach.configure do |config|
18
+ # config.binary_path = 'path/to/pdfdetach'
19
+ # end
20
+ def self.configure
21
+ yield configuration
22
+ end
23
+
24
+ def self.configuration
25
+ @configuration ||= Configuration.new
26
+ end
27
+ end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'pathname'
4
+
5
+ # PDFDetach is wrapper around poppler's pdfdetach utils command
6
+ #
7
+ class PDFDetach
8
+ # @param filepath [String]
9
+ def initialize(filepath)
10
+ @src = filepath
11
+ @base_path = Pathname.new("#{__dir__}/../../bin/#{LIB_TARGET}").cleanpath
12
+ @binary_path = PDFDetach.configuration.binary_path
13
+ end
14
+
15
+ # @param options [Hash]
16
+ def get_opts(options)
17
+ args = String.new
18
+ args << " -o #{options[:output]} " if options[:output]
19
+ args << " -enc #{options[:encoding]} " if options[:encoding]
20
+ args << " -opw #{options[:owner_password]} " if options[:owner_password]
21
+ args << " -upw #{options[:user_password]} " if options[:user_password]
22
+ args
23
+ end
24
+
25
+ # List all files attached
26
+ #
27
+ # @return [Array]
28
+ #
29
+ def list
30
+ result = run("-list #{@src}")
31
+
32
+ list ||= if result[:ok]
33
+ result[:out].split("\n").map do |line|
34
+ next line.match(/^(\d+): (.+?)$/) { |m| m[2] } if line =~ /^(\d+):/
35
+ end
36
+ else
37
+ []
38
+ end
39
+ list.compact
40
+ end
41
+
42
+ # Save all attached files in the pdf
43
+ #
44
+ # @param options [Hash]
45
+ #
46
+ def saveall(options = {})
47
+ run("-saveall #{get_opts(options)} #{@src}")[:ok]
48
+ end
49
+
50
+ private
51
+
52
+ def run(args)
53
+ output = if @binary_path.nil? || @binary_path&.empty?
54
+ `LD_LIBRARY_PATH=#{@base_path}/lib #{@base_path}/pdfdetach #{args}`
55
+ else
56
+ `#{@binary_path} #{args}`
57
+ end
58
+
59
+ { ok: $?.success?, out: output }
60
+ end
61
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ class PDFDetach
4
+ VERSION = '0.16.1'
5
+ LIB_TARGET = '16.04'
6
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ $:.push File.expand_path('../lib', __FILE__)
4
+ require 'pdfdetach/version'
5
+ require 'pdfdetach/main'
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = 'pdfdetach'
9
+ s.version = PDFDetach::VERSION
10
+ s.authors = ['Alvaro Cabrera']
11
+ s.email = ['pateketrueke@gmail.com']
12
+ s.homepage = 'https://github.com/pateketrueke/pdfdetach'
13
+ s.summary = %(Ruby wrapper for pdfdetach executable)
14
+
15
+ s.description = %{Binaries for pdfdetach (poppler-utils) that runs on Ubuntu}
16
+
17
+ s.require_paths = ['lib']
18
+ s.files = `git ls-files -z`.split("\x0").reject do |f|
19
+ f.match(%r{^(test|spec|features)/})
20
+ end
21
+
22
+ s.add_development_dependency 'minitest'
23
+ end
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pdfdetach
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.16.1
5
+ platform: ruby
6
+ authors:
7
+ - Alvaro Cabrera
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-10-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: minitest
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: Binaries for pdfdetach (poppler-utils) that runs on Ubuntu
28
+ email:
29
+ - pateketrueke@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".gitignore"
35
+ - Gemfile
36
+ - Rakefile
37
+ - bin/16.04/lib/libfontconfig.so.1
38
+ - bin/16.04/lib/libfreetype.so.6
39
+ - bin/16.04/lib/libjbig.so.0
40
+ - bin/16.04/lib/libjpeg.so.8
41
+ - bin/16.04/lib/liblcms2.so.2
42
+ - bin/16.04/lib/libpng12.so.0
43
+ - bin/16.04/lib/libpoppler.so.58
44
+ - bin/16.04/lib/libpthread.so.0
45
+ - bin/16.04/lib/libtiff.so.5
46
+ - bin/16.04/pdfdetach
47
+ - lib/pdfdetach.rb
48
+ - lib/pdfdetach/configuration.rb
49
+ - lib/pdfdetach/main.rb
50
+ - lib/pdfdetach/version.rb
51
+ - pdfdetach.gemspec
52
+ homepage: https://github.com/pateketrueke/pdfdetach
53
+ licenses: []
54
+ metadata: {}
55
+ post_install_message:
56
+ rdoc_options: []
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ requirements: []
70
+ rubygems_version: 3.0.6
71
+ signing_key:
72
+ specification_version: 4
73
+ summary: Ruby wrapper for pdfdetach executable
74
+ test_files: []