pdfs2pdf 0.1.1 → 0.1.2

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: 83ae1e3e9fca1d4df07df80d14b3922da5b49696
4
- data.tar.gz: fcae014da249a1a8b3743c3739a50613d4343b3e
3
+ metadata.gz: 1ceb2f9f7a6a8fc41d1d6f3b246adf6764506e74
4
+ data.tar.gz: 28a4f610e387bc2b698a002d45742635b1d7a751
5
5
  SHA512:
6
- metadata.gz: f21dcaa0b180e265f60a51facf62bb5df68c9d44f16f6a701770096d8fbc6899ad3ccd9ac102a9b72992df2ce8d5b5e3be78002021b265e993d7df358ddd6a11
7
- data.tar.gz: ace3b8d0838f2fb957afc602d29f9bbab518bba0083b692a9b0c6033e37435698892945e08e8a648207534c559584dd3a273460c7e752d9111199134126fda5c
6
+ metadata.gz: ab425500b6d2f1f2310b790a659ff39eb21e20ef8f5c4fce6629dac16d35c428a343e72d076de612f717e04071ea2345e13f887d8ef4d9092fa81e640ded0259
7
+ data.tar.gz: 2111ce959961cf4e0f947171bef478bdebac15432c40c0e0644503c093acdf5fcf967aea898f6e5e4b4964d70c84fb3c831667f00a88dae415502d07fd3bfde5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ### Changelogs
2
2
 
3
+ #### 0.1.2
4
+
5
+ - Re-instate the `--base-dir` option and make relative path work correctly
6
+ - Respect the `--recursive` option
7
+ - Minor code cleanup
8
+
3
9
  #### 0.1.1
4
10
 
5
11
  - Simplify the CLI interface
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  [![Dependency Status](https://gemnasium.com/agilecreativity/pdfs2pdf.png)](https://gemnasium.com/agilecreativity/pdfs2pdf)
5
5
  [![Code Climate](https://codeclimate.com/github/agilecreativity/pdfs2pdf.png)](https://codeclimate.com/github/agilecreativity/pdfs2pdf)
6
6
 
7
- Combine multiple PDF files into a single pdf file with simple bookmarks support using [Ghostscript][].
7
+ Combine multiple PDF files into a single pdf file with combine table of centent using [Ghostscript][].
8
8
 
9
9
  ### What it does?
10
10
 
@@ -39,7 +39,6 @@ When you run the following command:
39
39
 
40
40
  ```
41
41
  gem install pdfs2pdf
42
- # Note: must change to the root of the directory that we want to start from
43
42
  cd ./test/fixtures/samples
44
43
  pdfs2pdf --recursive
45
44
  ```
@@ -75,8 +74,11 @@ Usage:
75
74
  pdfs2pdf
76
75
 
77
76
  Options:
78
- -r, [--recursive], [--no-recursive] # Search for files recursively
79
- -v, [--version], [--no-version] # Display version information
77
+ -b, [--base-dir=BASE_DIR] # Base directory
78
+ # Default: . (current directory)
79
+ -r, [--recursive], [--no-recursive] # Search for files recursively
80
+ # Default: true
81
+ -v, [--version], [--no-version] # Display version information
80
82
 
81
83
  Combine multiple pdfs into one file with bookmarks
82
84
  ```
data/lib/pdfs2pdf/cli.rb CHANGED
@@ -8,21 +8,20 @@ module Pdfs2Pdf
8
8
  include AgileUtils::Options
9
9
  include CodeLister
10
10
  class CLI < Thor
11
- desc "merge", "Combine multiple pdfs into one file with bookmarks"
12
- # method_option *AgileUtils::Options::BASE_DIR
11
+ desc "merge", "Combine multiple pdfs into one file with combined table of content"
12
+ method_option *AgileUtils::Options::BASE_DIR
13
13
  method_option *AgileUtils::Options::RECURSIVE
14
14
  method_option *AgileUtils::Options::VERSION
15
-
16
15
  def merge
17
16
  opts = options.symbolize_keys
18
17
  if opts[:version]
19
18
  puts "You are using Pdfs2Pdf version #{Pdfs2Pdf::VERSION}"
20
19
  exit
21
20
  end
22
- base_dir = File.expand_path(Dir.pwd)
21
+ base_dir = File.expand_path(opts[:base_dir])
23
22
  pdf_files = CodeLister.files base_dir: base_dir,
24
23
  exts: %w[pdf],
25
- recursive: true
24
+ recursive: opts[:recursive]
26
25
  create_pdfmarks(pdf_files, base_dir)
27
26
  merge_pdfs(pdf_files)
28
27
  end
@@ -31,11 +30,18 @@ module Pdfs2Pdf
31
30
  def usage
32
31
  puts <<-EOT
33
32
  Usage:
33
+
34
34
  pdfs2pdf
35
+
35
36
  Options:
36
- -r, [--recursive], [--no-recursive] # Search for files recursively
37
- -v, [--version], [--no-version] # Display version information
38
- Combine multiple pdfs into one file with bookmarks
37
+ -b, [--base-dir=BASE_DIR] # Base directory
38
+ # Default: . (current directory)
39
+ -r, [--recursive], [--no-recursive] # Search for files recursively
40
+ # Default: --recursive
41
+ -v, [--version], [--no-version] # Display version information
42
+
43
+ Combine multiple pdfs into one file with combined table of content
44
+
39
45
  EOT
40
46
  end
41
47
 
@@ -51,11 +57,12 @@ Combine multiple pdfs into one file with bookmarks
51
57
  end
52
58
 
53
59
  def merge_pdfs(pdf_files)
60
+ output_filename = "pdfs2pdf_output.pdf"
54
61
  elapsed = AgileUtils::FileUtil.time do
55
- Pdfs2Pdf.merge_pdfs(pdf_files, "pdfmarks", "pdfs2pdf_output.pdf")
62
+ Pdfs2Pdf.merge_pdfs(pdf_files, "pdfmarks", output_filename)
56
63
  end
57
64
  puts "Combine pdf files took #{elapsed} ms"
58
- puts "Your combined pdf is available at #{File.absolute_path("pdfs2pdf_output.pdf")}"
65
+ puts "Your combined pdf is available at #{File.absolute_path(output_filename)}"
59
66
  end
60
67
  end
61
68
  end
@@ -12,12 +12,13 @@ module Pdfs2Pdf
12
12
  # @param [String] base_dir the base directory
13
13
  # def create_pdfmarks(pdf_files, pdfmarks_file = "pdfmarks", base_dir = Dir.pwd)
14
14
  def create_pdfmarks(pdf_files, pdfmarks_file = "pdfmarks", base_dir)
15
+ FileUtils.chdir(base_dir)
15
16
  File.open(pdfmarks_file, "w") do |out_file|
16
17
  out_file.write(Pdfs2Pdf.configuration.pdfmarks_meta)
17
18
  current_page = 1
18
19
  pdf_files.each do |pdf_file|
19
20
  out_file.write "[ /Page #{current_page} /Title (#{pdf_file}) /OUT pdfmark\n"
20
- current_page += page_count(base_dir, pdf_file)
21
+ current_page += page_count(pdf_file)
21
22
  end
22
23
  end
23
24
  end
@@ -46,8 +47,8 @@ module Pdfs2Pdf
46
47
  # Extract pdf page count using pdf-reader
47
48
  #
48
49
  # @return [Fixnum] the page count of the given pdf file
49
- def page_count(base_dir, pdf_file)
50
- pdf_file = File.expand_path([base_dir, pdf_file].join("/"))
50
+ def page_count(pdf_file)
51
+ pdf_file = File.expand_path(pdf_file)
51
52
  File.open(pdf_file, "rb") do |io|
52
53
  reader = PDF::Reader.new(io)
53
54
  return reader.page_count
@@ -1,3 +1,3 @@
1
1
  module Pdfs2Pdf
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/pdfs2pdf.gemspec CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Pdfs2Pdf::VERSION
9
9
  spec.authors = ["Burin Choomnuan"]
10
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)
11
+ spec.summary = %q(Combine multiple pdf files into a single pdf with combined table of content for quick navigation)
12
+ spec.description = %q(Combine multiple pdf files into a single file with combined table of content for quick navigation)
13
13
  spec.homepage = "https://github.com/agilecreativity/pdfs2pdf"
14
14
  spec.license = "MIT"
15
15
  spec.files = Dir.glob("{bin,lib,config}/**/*") + %w[Gemfile
@@ -3,7 +3,7 @@ describe Pdfs2Pdf do
3
3
  context "#page_count" do
4
4
  it "returns result for valid command" do
5
5
  input_file = "demo1_xxx.rb.xhtml.pdf"
6
- result = Pdfs2Pdf.page_count("./test/fixtures/samples", input_file)
6
+ result = Pdfs2Pdf.page_count("./test/fixtures/samples/#{input_file}")
7
7
  result.must_equal 1
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pdfs2pdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Burin Choomnuan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-17 00:00:00.000000000 Z
11
+ date: 2014-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -206,7 +206,8 @@ dependencies:
206
206
  - - "~>"
207
207
  - !ruby/object:Gem::Version
208
208
  version: '0.8'
209
- description: Combine multiple pdfs into a single file with bookmarks for easy navigation
209
+ description: Combine multiple pdf files into a single file with combined table of
210
+ content for quick navigation
210
211
  email:
211
212
  - agilecreativity@gmail.com
212
213
  executables:
@@ -258,12 +259,13 @@ rubyforge_project:
258
259
  rubygems_version: 2.2.2
259
260
  signing_key:
260
261
  specification_version: 4
261
- summary: Combine multiple pdfs into one pdf with proper bookmarks for easy navigation
262
+ summary: Combine multiple pdf files into a single pdf with combined table of content
263
+ for quick navigation
262
264
  test_files:
263
- - test/fixtures/samples/demo1_xxx.rb.xhtml.pdf
264
- - test/fixtures/samples/demo2_xxx.rb.xhtml.pdf
265
- - test/fixtures/samples/sub_dir/demo3_xxx.rb.xhtml.pdf
266
- - test/fixtures/samples/sub_dir/demo4_xxx.rb.xhtml.pdf
267
265
  - test/lib/pdfs2pdf/test_pdfs2pdf.rb
268
266
  - test/test_helper.rb
267
+ - test/fixtures/samples/demo2_xxx.rb.xhtml.pdf
268
+ - test/fixtures/samples/sub_dir/demo4_xxx.rb.xhtml.pdf
269
+ - test/fixtures/samples/sub_dir/demo3_xxx.rb.xhtml.pdf
270
+ - test/fixtures/samples/demo1_xxx.rb.xhtml.pdf
269
271
  has_rdoc: