pdfs2pdf 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,23 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ # ctags
19
+ tags
20
+ # generated file
21
+ final_output.pdf
22
+ output.tar.gz
23
+ TODOs.md
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/.rubocop.yml ADDED
@@ -0,0 +1 @@
1
+ inherit_from: rubocop-todo.yml
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 1.9.3
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in code_exporter.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,13 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+ guard 'minitest' do
4
+ # with Minitest::Unit
5
+ watch(%r|^test/(.*)\/?test_(.*)\.rb|)
6
+ watch(%r|^lib/(.*)([^/]+)\.rb|) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
7
+ watch(%r|^test/test_helper\.rb|) { "test" }
8
+
9
+ # with Minitest::Spec
10
+ # watch(%r|^spec/(.*)_spec\.rb|)
11
+ # watch(%r|^lib/(.*)([^/]+)\.rb|) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
12
+ # watch(%r|^spec/spec_helper\.rb|) { "spec" }
13
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Burin Choomnuan
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,148 @@
1
+ ## Pdfs2Pdf
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/pdfs2pdf.svg)](http://badge.fury.io/rb/pdfs2pfs)
4
+
5
+ Combine multiple PDF files into one file with simple bookmarks support.
6
+
7
+ The gem rely on the power of great opensource projects such as
8
+
9
+ - [Ghostscript][] - for combining multiple pdf files
10
+ - [Wkhtmltopdf][] - for converting file to PDF
11
+
12
+ and it is built on top of my other gems
13
+
14
+ - [agile_utils][] gem
15
+ - [code_lister][] gem
16
+
17
+ ## What it does?
18
+
19
+ Says you have the follow pdf files (included inside the test fixtures)
20
+
21
+ ```
22
+ ./test/fixtures/samples/demo1_xxx.rb.xhtml.pdf
23
+ ./test/fixtures/samples/demo2_xxx.rb.xhtml.pdf
24
+ ./test/fixtures/samples/sub_dir/demo3_xxx.rb.xhtml.pdf
25
+ ./test/fixtures/samples/sub_dir/demo4_xxx.rb.xhtml.pdf
26
+ ```
27
+ Which have the following content:
28
+
29
+ - File: `./test/fixtures/samples/demo1_xxx.rb.xhtml.pdf`
30
+
31
+ ![](https://github.com/agilecreativity/pdfs2pdf/raw/master/demo1.png)
32
+
33
+ - File: `./test/fixtures/samples/demo2_xxx.rb.xhtml.pdf`
34
+
35
+ ![](https://github.com/agilecreativity/pdfs2pdf/raw/master/demo2.png)
36
+
37
+ - File: `./test/fixtures/samples/sub_dir/demo3_xxx.rb.xhtml.pdf`
38
+
39
+ ![](https://github.com/agilecreativity/pdfs2pdf/raw/master/demo3.png)
40
+
41
+ - File: `./test/fixtures/samples/sub_dir/demo4_xxx.rb.xhtml.pdf`
42
+
43
+ ![](https://github.com/agilecreativity/pdfs2pdf/raw/master/demo4.png)
44
+
45
+ When you run the following command:
46
+
47
+ ```
48
+ gem install pdfs2pdf
49
+ git clone https://github.com/agilecreativity/pdfs2pdf.git
50
+ cd pdfs2pdf
51
+ rbenv local 2.1.1 # if you use rbenv as your ruby manager
52
+ rbenv rehash
53
+ pdfs2pdf merge --base-dir ./test/fixtures/samples
54
+ ```
55
+
56
+ Will produce the result like the following
57
+
58
+ - File: `final_output.pdf` (excepted screenshot)
59
+
60
+ ![](https://github.com/agilecreativity/pdfs2pdf/raw/master/final_output.png)
61
+
62
+ - File: `final_output.pdf` (actual pdf)
63
+
64
+ ![](https://github.com/agilecreativity/pdfs2pdf/raw/master/final_output.pdf)
65
+
66
+ ### Requirments
67
+
68
+ ### Mandatory Requirement
69
+
70
+ - [Ghostscript][]
71
+ - [Wkhtmltopdf][]
72
+
73
+ ## Usage
74
+
75
+ ```sh
76
+ gem install pdfs2pdf
77
+ ```
78
+ For list of usage type
79
+
80
+ ```sh
81
+ pdfs2pdf help
82
+ ```
83
+ Which should give the following options
84
+
85
+ ```
86
+ Commands:
87
+ pdfs2pdf help [COMMAND] # Describe available commands or one specific command
88
+ pdfs2pdf merge # Combine multiple pdfs into one file with bookmarks
89
+ pdfs2pdf usage # Display usage information
90
+ ```
91
+
92
+ Help on `merge` command just type `pdfs2pdf help merge`.
93
+
94
+ Which should produce the following guide.
95
+
96
+ ```
97
+ Usage:
98
+ pdfs2pdf merge [OPTIONS]
99
+
100
+ Options:
101
+ -b, [--base-dir=BASE_DIR] # Base directory
102
+ # Default: . (current directory)
103
+ -n, [--inc-words=one two three] # List of words to be included in the result
104
+ -n, [--exc-words=one two three] # List of words to be included in the result
105
+ -i, [--ignore-case], [--no-ignore-case] # Match case insensitively
106
+ # Default: true
107
+ -r, [--recursive], [--no-recursive] # Search for files recursively
108
+ # Default: true
109
+ -v, [--version], [--no-version] # Display version information
110
+
111
+ Combine multiple pdf files into one file with bookmarks
112
+ ```
113
+
114
+ To combine multiple pdfs just try something like
115
+
116
+ ```
117
+ pdfs2pdf merge --base-dir ./test/fixtures/samples
118
+ ```
119
+ This will merge all the pdf files from `test/fixtures/samples` and generate the
120
+ `final_output.pdf` in the current directory.
121
+
122
+ ### Known Issues
123
+
124
+ - The directory that contains the pdf files must only contain the
125
+ letters, numbers and/or underscore characters. Any other characters like
126
+ `-` (dash) may caused the 'pdfmarks' file to produce incorrect bookmarks.
127
+
128
+ * Solution: try rename your folder to 'something_with_underscore' but not
129
+ 'something-with-dash' before running the command.
130
+
131
+ ### Changelogs
132
+
133
+ #### 0.0.1
134
+
135
+ - Initial release
136
+
137
+ ### Contributing
138
+
139
+ 1. Fork it ( http://github.com/agilecreativity/pdfs2pdf/fork )
140
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
141
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
142
+ 4. Push to the branch (`git push origin my-new-feature`)
143
+ 5. Create new Pull Request
144
+
145
+ [Ghostscript]: http://www.ghostscript.com/
146
+ [Wkhtmltopdf]: http://wkhtmltopdf.org/
147
+ [agile_utils]: https://github.com/agilecreativity/agile_utils
148
+ [code_lister]: https://github.com/agilecreativity/code_lister
data/Rakefile ADDED
@@ -0,0 +1,30 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ project_name = 'pdfs2pdf'
5
+ Rake::TestTask.new do |t|
6
+ t.libs << "lib/#{project_name}"
7
+ t.test_files = FileList["test/lib/#{project_name}/test_*.rb"]
8
+ t.verbose = true
9
+ end
10
+
11
+ task default: :test
12
+
13
+ task :pry do
14
+ require 'pry'
15
+ require 'awesome_print'
16
+ require_relative './lib/pdfs2pdf'
17
+ include Pdfs2Pdf
18
+ ARGV.clear
19
+ Pry.start
20
+ end
21
+
22
+ require 'rubocop/rake_task'
23
+ desc 'Run RuboCop on the lib directory'
24
+ Rubocop::RakeTask.new(:rubocop) do |task|
25
+ task.patterns = ['lib/**/*.rb']
26
+ # only show the files with failures
27
+ task.formatters = ['files']
28
+ # don't abort rake on failure
29
+ task.fail_on_error = false
30
+ end
data/bin/pdfs2pdf ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../lib/pdfs2pdf'
3
+ include Pdfs2Pdf
4
+ Pdfs2Pdf::CLI.start(ARGV)
data/demo1.png ADDED
Binary file
data/demo2.png ADDED
Binary file
data/demo3.png ADDED
Binary file
data/demo4.png ADDED
Binary file
data/final_output.png ADDED
Binary file
@@ -0,0 +1,74 @@
1
+ require 'thor'
2
+ require 'tmpdir'
3
+ require 'fileutils'
4
+ require_relative '../pdfs2pdf'
5
+ require_relative './utils'
6
+
7
+ module Pdfs2Pdf
8
+ include AgileUtils::Options
9
+ include CodeLister
10
+ class CLI < Thor
11
+ desc 'merge', 'Combine multiple pdfs into one file with bookmarks'
12
+ method_option *AgileUtils::Options::BASE_DIR
13
+ method_option *AgileUtils::Options::INC_WORDS
14
+ method_option *AgileUtils::Options::EXC_WORDS
15
+ method_option *AgileUtils::Options::IGNORE_CASE
16
+ method_option *AgileUtils::Options::RECURSIVE
17
+ method_option *AgileUtils::Options::VERSION
18
+
19
+ def merge
20
+ pdf_files = CodeLister.files base_dir: options[:base_dir],
21
+ exts: %w(pdf),
22
+ recursive: true
23
+ create_pdfmarks(pdf_files, options[:base_dir])
24
+ merge_pdfs(pdf_files)
25
+ end
26
+
27
+ desc 'usage', 'Display usage information'
28
+ def usage
29
+ puts <<-EOT
30
+ Usage:
31
+ pdfs2pdf merge [OPTIONS]
32
+
33
+ Options:
34
+ -b, [--base-dir=BASE_DIR] # Base directory
35
+ # Default: . (current directory)
36
+ -n, [--inc-words=one two three] # List of words to be included in the result
37
+ -n, [--exc-words=one two three] # List of words to be included in the result
38
+ -i, [--ignore-case], [--no-ignore-case] # Match case insensitively
39
+ # Default: true
40
+ -r, [--recursive], [--no-recursive] # Search for files recursively
41
+ # Default: true
42
+ -v, [--version], [--no-version] # Display version information
43
+
44
+ Combind multiple pdfs into one file with bookmarks
45
+ EOT
46
+ end
47
+
48
+ default_task :usage
49
+
50
+ private
51
+
52
+ def create_pdfmarks(page_list, base_dir)
53
+ elapsed = AgileUtils::FileUtil.time do
54
+ Pdfs2Pdf::Utils.create_pdfmarks(page_list, 'pdfmarks', base_dir)
55
+ end
56
+ puts "Create pdfmarks took #{elapsed} ms"
57
+ end
58
+
59
+ def merge_pdfs(pdf_files)
60
+ elapsed = AgileUtils::FileUtil.time do
61
+ Pdfs2Pdf::Utils.merge_pdfs(pdf_files, 'pdfmarks', 'final_output.pdf')
62
+ end
63
+ puts "Combine pdf files took #{elapsed} ms"
64
+ puts "Your combine pdf is available at #{File.absolute_path('final_output.pdf')}"
65
+ end
66
+ end
67
+ end
68
+
69
+ if __FILE__ == $PROGRAM_NAME
70
+ include Pdfs2Pdf
71
+ # TODO: make it work with File.expand_path('~/Dropbox/ebooks/')
72
+ # File.expand_path('~') # => '/home/bchoomnuan'
73
+ # File.expand_path('.') # => '/home/bchoomnuan/.../pdfs2pdf'
74
+ end
@@ -0,0 +1,118 @@
1
+ require 'open3'
2
+ require 'fileutils'
3
+ require 'pdf-reader'
4
+ require_relative '../pdfs2pdf'
5
+ module Pdfs2Pdf
6
+ module Utils
7
+ class << self
8
+ # Batch convert to pdf using `wkhtmltopdf` tool
9
+ #
10
+ # @param [Array<String>] files the input file list
11
+ # @param [String] base_dir the base directory
12
+ def to_pdfs(files)
13
+ files.each_with_index do |file, index|
14
+ puts "Convert file #{index + 1} of #{files.size} : #{file}"
15
+ to_pdf(file)
16
+ end
17
+ end
18
+
19
+ # Convert '*.xhtml' or '*.html' to pdf
20
+ #
21
+ # @param filename input filename
22
+ def to_pdf(filename)
23
+ # @todo allow the options to be passed in so that we can use different theme
24
+ # '--no-background'
25
+ fail "Invalid input file #{filename}" unless File.exist?(filename)
26
+ command = [
27
+ 'wkhtmltopdf',
28
+ '--margin-top 4',
29
+ '--margin-bottom 4',
30
+ '--margin-left 4',
31
+ '--margin-right 4',
32
+ # Note: working correctly but long URL
33
+ '--header-center "[webpage] :: [page]/[topage]"',
34
+ # TODO: not yet working properly
35
+ # "--header-center #{filename.gsub(base_dir,File.basename(base_dir))} \"[page]/[topage]\"",
36
+ # "--header-center #{filename} \"[page]/[topage]\"",
37
+ '--header-spacing 1',
38
+ '--header-font-size 8',
39
+ '--header-line',
40
+ '--footer-spacing 1',
41
+ '--footer-font-size 8',
42
+ '--footer-line',
43
+ "#{filename}",
44
+ "#{filename}.pdf",
45
+ '> /dev/null']
46
+ _stdin, _stderr, status = Open3.capture3(command.join(' '))
47
+ puts "FYI: to_pdf command: #{command.join(' ')}"
48
+ # Note: may be log it and continue
49
+ fail "Problem processing #{filename}" unless status.success?
50
+ end
51
+
52
+ # Create the 'pdfmarks' file for use with 'gs' utility
53
+ #
54
+ # @param [Array<String>] pdf_files the input file list (pdf)
55
+ # @param [String] output_file the output filename default to 'pdfmarks'
56
+ # @param [String] base_dir the base directory (TODO: review this code!)
57
+ def create_pdfmarks(pdf_files, pdfmarks_file = 'pdfmarks', base_dir = Dir.pwd)
58
+ File.open(pdfmarks_file, 'w') do |out_file|
59
+ out_file.write(title)
60
+ current_page = 1
61
+ pdf_files.each do |pdf_file|
62
+ filename = if base_dir
63
+ # remove the base_directory from the full path
64
+ pdf_file.gsub(base_dir, File.basename(pdf_file))
65
+ else
66
+ pdf_file
67
+ end
68
+ out_file.write "[ /Page #{current_page} /Title (#{filename}) /OUT pdfmark\n"
69
+ current_page += Pdfs2Pdf::Utils.page_count(pdf_file)
70
+ end
71
+ end
72
+ end
73
+
74
+ # Simple title for use in 'pdfmarks' file
75
+ #
76
+ # @todo allow the customization.
77
+ def title
78
+ <<-END.gsub(/^\s+\|/, '')
79
+ |[ /Title (My Sample Book)
80
+ | /Author (Agile Creativity)
81
+ | /Keywords (fun, witty, interesting)
82
+ | /DOCINFO pdfmark
83
+ END
84
+ end
85
+
86
+ # Merge list of files using 'gs' command
87
+ #
88
+ # @param [Array<String>] list input file list
89
+ # @param [String] pdfmarks the pdfmarks file default to 'pdfmarks'
90
+ # @param [String] output_file the output pdf file
91
+ def merge_pdfs(list, pdfmarks = 'pdfmarks', output_file = 'output.pdf')
92
+ # puts "FYI: merge_pdfs: your list: #{list}"
93
+ _stdin, _stderr, status = Open3.capture3(
94
+ 'gs',
95
+ '-q',
96
+ '-dNOPAUSE',
97
+ '-dBATCH',
98
+ '-sDEVICE=pdfwrite',
99
+ '-sPAPERSIZE=a4',
100
+ "-sOutputFile=#{output_file}",
101
+ *list,
102
+ pdfmarks)
103
+ fail 'Problem in merge_pdfs' unless status.success?
104
+ end
105
+
106
+ # Extract pdf page count using pdf-reader
107
+ #
108
+ # @return [Fixnum] the page count of the given pdf file
109
+ def page_count(pdf_file)
110
+ File.open(pdf_file, 'rb') do |io|
111
+ reader = PDF::Reader.new(io)
112
+ return reader.page_count
113
+ end
114
+ fail "Problem getting the page count for #{pdf_file}"
115
+ end
116
+ end
117
+ end
118
+ end
@@ -0,0 +1,3 @@
1
+ module Pdfs2Pdf
2
+ VERSION = '0.0.1'
3
+ end
data/lib/pdfs2pdf.rb ADDED
@@ -0,0 +1,9 @@
1
+ require 'agile_utils'
2
+ require 'code_lister'
3
+ require_relative 'pdfs2pdf/version'
4
+ require_relative 'pdfs2pdf/cli'
5
+ require_relative 'pdfs2pdf/utils'
6
+ include AgileUtils::Options
7
+ include CodeLister
8
+ include Pdfs2Pdf
9
+ include Pdfs2Pdf::Utils
data/pdfmarks ADDED
@@ -0,0 +1,8 @@
1
+ [ /Title (My Sample Book)
2
+ /Author (Agile Creativity)
3
+ /Keywords (fun, witty, interesting)
4
+ /DOCINFO pdfmark
5
+ [ /Page 1 /Title (demo1_xxx.rb.xhtml.pdf/demo1_xxx.rb.xhtml.pdf) /OUT pdfmark
6
+ [ /Page 2 /Title (demo2_xxx.rb.xhtml.pdf/demo2_xxx.rb.xhtml.pdf) /OUT pdfmark
7
+ [ /Page 3 /Title (demo3_xxx.rb.xhtml.pdf/sub_dir/demo3_xxx.rb.xhtml.pdf) /OUT pdfmark
8
+ [ /Page 4 /Title (demo4_xxx.rb.xhtml.pdf/sub_dir/demo4_xxx.rb.xhtml.pdf) /OUT pdfmark
data/pdfs2pdf.gemspec ADDED
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'pdfs2pdf/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'pdfs2pdf'
8
+ spec.version = Pdfs2Pdf::VERSION
9
+ spec.authors = ['Burin Choomnuan']
10
+ spec.email = ['agilecreativity@gmail.com']
11
+ spec.summary = %q{Combine multiple pdfs into one pdf with proper bookmarks for easy navigation}
12
+ spec.description = %q{Combine multiple pdfs into a single file with bookmarks for easy navigation}
13
+ spec.homepage = 'https://github.com/agilecreativity/pdfs2pdf'
14
+ spec.license = 'MIT'
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+ spec.add_runtime_dependency 'thor'
20
+ spec.add_runtime_dependency 'agile_utils', '~> 0.0.4'
21
+ spec.add_runtime_dependency 'code_lister', '~> 0.0.6'
22
+ spec.add_runtime_dependency 'pdf-reader', '~> 1.3.3'
23
+ spec.add_development_dependency 'bundler', '~> 1.5'
24
+ spec.add_development_dependency 'gem-ctags', '~> 1.0'
25
+ spec.add_development_dependency 'guard-minitest', '~> 2.2'
26
+ spec.add_development_dependency 'minitest', '~> 4.2'
27
+ spec.add_development_dependency 'minitest-spec-context', '~> 0.0.3'
28
+ spec.add_development_dependency 'pry', '~> 0.9'
29
+ spec.add_development_dependency 'rake', '~> 10.1'
30
+ spec.add_development_dependency 'rubocop', '~> 0.20'
31
+ spec.add_development_dependency 'yard', '~> 0.8'
32
+ end
data/rubocop-todo.yml ADDED
@@ -0,0 +1,84 @@
1
+ # This configuration was generated by `rubocop --auto-gen-config`
2
+ # on 2014-04-23 20:34:48 +1000 using RuboCop version 0.20.1.
3
+ # The point is for the user to remove these configuration records
4
+ # one by one as the offenses are removed from the code base.
5
+ # Note that changes in the inspected code, or installation of new
6
+ # versions of RuboCop, may require this file to be generated again.
7
+
8
+ # Offense count: 9
9
+ AmbiguousOperator:
10
+ Enabled: false
11
+
12
+ # Offense count: 1
13
+ # Cop supports --auto-correct.
14
+ # Configuration parameters: PreferredMethods.
15
+ CollectionMethods:
16
+ Enabled: false
17
+
18
+ # Offense count: 1
19
+ CyclomaticComplexity:
20
+ Max: 7
21
+
22
+ # Offense count: 5
23
+ Documentation:
24
+ Enabled: false
25
+
26
+ # Offense count: 1
27
+ # Cop supports --auto-correct.
28
+ EmptyLinesAroundBody:
29
+ Enabled: true
30
+
31
+ # Offense count: 1
32
+ # Cop supports --auto-correct.
33
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
34
+ HashSyntax:
35
+ Enabled: true
36
+
37
+ # Offense count: 4
38
+ # Cop supports --auto-correct.
39
+ LeadingCommentSpace:
40
+ Enabled: true
41
+
42
+ # Offense count: 18
43
+ LineLength:
44
+ Max: 108
45
+
46
+ # Offense count: 8
47
+ # Configuration parameters: CountComments.
48
+ MethodLength:
49
+ Max: 30
50
+
51
+ # Offense count: 1
52
+ # Cop supports --auto-correct.
53
+ SpaceAfterComma:
54
+ Enabled: true
55
+
56
+ # Offense count: 1
57
+ # Cop supports --auto-correct.
58
+ # Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
59
+ SpaceInsideBlockBraces:
60
+ Enabled: true
61
+
62
+ # Offense count: 1
63
+ # Cop supports --auto-correct.
64
+ SpecialGlobalVars:
65
+ Enabled: true
66
+
67
+ # Offense count: 16
68
+ # Cop supports --auto-correct.
69
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
70
+ StringLiterals:
71
+ Enabled: false
72
+
73
+ # Offense count: 1
74
+ UnreachableCode:
75
+ Enabled: true
76
+
77
+ # Offense count: 1
78
+ UselessAssignment:
79
+ Enabled: false
80
+
81
+ # Offense count: 1
82
+ # Cop supports --auto-correct.
83
+ WordArray:
84
+ MinSize: 2
@@ -0,0 +1,10 @@
1
+ require_relative '../../test_helper'
2
+ describe Pdfs2Pdf::Utils do
3
+ context '#page_count' do
4
+ it 'returns result for valid command' do
5
+ input_file = 'test/fixtures/samples/demo1_xxx.rb.xhtml.pdf'
6
+ result = Pdfs2Pdf::Utils.page_count(input_file)
7
+ result.must_equal 1
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,7 @@
1
+ require 'minitest/autorun'
2
+ require 'minitest/pride'
3
+ require 'minitest-spec-context'
4
+ require 'pry'
5
+ require 'awesome_print'
6
+ require_relative '../lib/pdfs2pdf'
7
+ include Pdfs2Pdf
metadata ADDED
@@ -0,0 +1,290 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pdfs2pdf
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Burin Choomnuan
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-04-24 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: thor
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: agile_utils
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 0.0.4
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 0.0.4
46
+ - !ruby/object:Gem::Dependency
47
+ name: code_lister
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 0.0.6
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.0.6
62
+ - !ruby/object:Gem::Dependency
63
+ name: pdf-reader
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 1.3.3
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 1.3.3
78
+ - !ruby/object:Gem::Dependency
79
+ name: bundler
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: '1.5'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '1.5'
94
+ - !ruby/object:Gem::Dependency
95
+ name: gem-ctags
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: '1.0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: '1.0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: guard-minitest
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: '2.2'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: '2.2'
126
+ - !ruby/object:Gem::Dependency
127
+ name: minitest
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ~>
132
+ - !ruby/object:Gem::Version
133
+ version: '4.2'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ~>
140
+ - !ruby/object:Gem::Version
141
+ version: '4.2'
142
+ - !ruby/object:Gem::Dependency
143
+ name: minitest-spec-context
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ~>
148
+ - !ruby/object:Gem::Version
149
+ version: 0.0.3
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ~>
156
+ - !ruby/object:Gem::Version
157
+ version: 0.0.3
158
+ - !ruby/object:Gem::Dependency
159
+ name: pry
160
+ requirement: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ~>
164
+ - !ruby/object:Gem::Version
165
+ version: '0.9'
166
+ type: :development
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ~>
172
+ - !ruby/object:Gem::Version
173
+ version: '0.9'
174
+ - !ruby/object:Gem::Dependency
175
+ name: rake
176
+ requirement: !ruby/object:Gem::Requirement
177
+ none: false
178
+ requirements:
179
+ - - ~>
180
+ - !ruby/object:Gem::Version
181
+ version: '10.1'
182
+ type: :development
183
+ prerelease: false
184
+ version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
186
+ requirements:
187
+ - - ~>
188
+ - !ruby/object:Gem::Version
189
+ version: '10.1'
190
+ - !ruby/object:Gem::Dependency
191
+ name: rubocop
192
+ requirement: !ruby/object:Gem::Requirement
193
+ none: false
194
+ requirements:
195
+ - - ~>
196
+ - !ruby/object:Gem::Version
197
+ version: '0.20'
198
+ type: :development
199
+ prerelease: false
200
+ version_requirements: !ruby/object:Gem::Requirement
201
+ none: false
202
+ requirements:
203
+ - - ~>
204
+ - !ruby/object:Gem::Version
205
+ version: '0.20'
206
+ - !ruby/object:Gem::Dependency
207
+ name: yard
208
+ requirement: !ruby/object:Gem::Requirement
209
+ none: false
210
+ requirements:
211
+ - - ~>
212
+ - !ruby/object:Gem::Version
213
+ version: '0.8'
214
+ type: :development
215
+ prerelease: false
216
+ version_requirements: !ruby/object:Gem::Requirement
217
+ none: false
218
+ requirements:
219
+ - - ~>
220
+ - !ruby/object:Gem::Version
221
+ version: '0.8'
222
+ description: Combine multiple pdfs into a single file with bookmarks for easy navigation
223
+ email:
224
+ - agilecreativity@gmail.com
225
+ executables:
226
+ - pdfs2pdf
227
+ extensions: []
228
+ extra_rdoc_files: []
229
+ files:
230
+ - .gitignore
231
+ - .rspec
232
+ - .rubocop.yml
233
+ - .ruby-version
234
+ - Gemfile
235
+ - Guardfile
236
+ - LICENSE.txt
237
+ - README.md
238
+ - Rakefile
239
+ - bin/pdfs2pdf
240
+ - demo1.png
241
+ - demo2.png
242
+ - demo3.png
243
+ - demo4.png
244
+ - final_output.png
245
+ - lib/pdfs2pdf.rb
246
+ - lib/pdfs2pdf/cli.rb
247
+ - lib/pdfs2pdf/utils.rb
248
+ - lib/pdfs2pdf/version.rb
249
+ - pdfmarks
250
+ - pdfs2pdf.gemspec
251
+ - rubocop-todo.yml
252
+ - test/fixtures/samples/demo1_xxx.rb.xhtml.pdf
253
+ - test/fixtures/samples/demo2_xxx.rb.xhtml.pdf
254
+ - test/fixtures/samples/sub_dir/demo3_xxx.rb.xhtml.pdf
255
+ - test/fixtures/samples/sub_dir/demo4_xxx.rb.xhtml.pdf
256
+ - test/lib/pdfs2pdf/test_pdfs2pdf.rb
257
+ - test/test_helper.rb
258
+ homepage: https://github.com/agilecreativity/pdfs2pdf
259
+ licenses:
260
+ - MIT
261
+ post_install_message:
262
+ rdoc_options: []
263
+ require_paths:
264
+ - lib
265
+ required_ruby_version: !ruby/object:Gem::Requirement
266
+ none: false
267
+ requirements:
268
+ - - ! '>='
269
+ - !ruby/object:Gem::Version
270
+ version: '0'
271
+ required_rubygems_version: !ruby/object:Gem::Requirement
272
+ none: false
273
+ requirements:
274
+ - - ! '>='
275
+ - !ruby/object:Gem::Version
276
+ version: '0'
277
+ requirements: []
278
+ rubyforge_project:
279
+ rubygems_version: 1.8.23
280
+ signing_key:
281
+ specification_version: 3
282
+ summary: Combine multiple pdfs into one pdf with proper bookmarks for easy navigation
283
+ test_files:
284
+ - test/fixtures/samples/demo1_xxx.rb.xhtml.pdf
285
+ - test/fixtures/samples/demo2_xxx.rb.xhtml.pdf
286
+ - test/fixtures/samples/sub_dir/demo3_xxx.rb.xhtml.pdf
287
+ - test/fixtures/samples/sub_dir/demo4_xxx.rb.xhtml.pdf
288
+ - test/lib/pdfs2pdf/test_pdfs2pdf.rb
289
+ - test/test_helper.rb
290
+ has_rdoc: