html2pdf 0.0.2 → 0.0.3

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: f1558eb0b691dbc0d701b5deb1ef3e6dd34de627
4
- data.tar.gz: c8c19bd55f2a00b1912b4b60d7a8d7ce5a698be6
3
+ metadata.gz: 19a61c7bd4f22b786d9777df4ee6c4a8e4472909
4
+ data.tar.gz: 072d2a948be11cebe5db643191ef944c3c5c9b98
5
5
  SHA512:
6
- metadata.gz: f976f3e348cc3b0e08e0544212a6cf5fe143993875a76c8a58b1726645757357a32984324fc489b1e161487cec968fba0a490063809a69ad57dda2ad3c4a7083
7
- data.tar.gz: d9204c0d1b265740950a242b24075cf4a4e1c4da2fe04d9757a7a6d9bb130a9214c2d6f07eefebd553a0b5765f87893c20037da5567c9ea09f3b88fbce8f5792
6
+ metadata.gz: 4e87aee9d33e577da87392e304044d9dcc254979029d660f6c7c791262968a37106709e067f3f5506a5dbe6fd52321e165bc7a7efd4281531a77d546d6361e65
7
+ data.tar.gz: bad0571fd68a34029d11ba3a1759918a7da89f6584d53c1bc7e3c3b13a0cecf7b578f250347df7d5d63b3ebdf6231ad42939dc57b153bb44ca4dc0ab751ffb0d
data/.gitignore CHANGED
@@ -17,5 +17,7 @@ test/version_tmp
17
17
  tmp
18
18
  # ctags
19
19
  tags
20
- # generated file
20
+ # Custom ignore files
21
21
  output.tar.gz
22
+ html2pdf-output.tar.gz
23
+ changelogs.txt
data/README.md CHANGED
@@ -32,7 +32,9 @@ For list of usage type
32
32
  ```sh
33
33
  html2pdf
34
34
  ```
35
+
35
36
  Which should give the following options
37
+
36
38
  ```
37
39
  Usage:
38
40
  html2pdf export [OPTIONS]
@@ -48,12 +50,13 @@ Options:
48
50
  # Default: true
49
51
  -v, [--version], [--no-version] # Display version information
50
52
  ```
53
+
51
54
  ### Example Usage
52
55
 
53
56
  - Convert all `xhtml` and `html` from `test/fixtures/samples` directory
54
57
  recursively
55
58
  ```
56
- html2pdf -b test/fixtures/samples -e html xhtml -r
59
+ html2pdf -b test/fixtures/samples -r
57
60
  ```
58
61
  Before the run
59
62
  ```
@@ -65,16 +68,16 @@ test/fixtures/samples/
65
68
  └── demo4_xxx.rb.xhtml
66
69
  ```
67
70
  After the above command is executed:
71
+
72
+ You should get the output `html2pdf-output.tar.gz`
73
+ which contain the pdf version of the input files above.
74
+ e.g.
75
+
68
76
  ```
69
- test/fixtures/samples/
70
- ├── demo1_xxx.rb.xhtml
71
77
  ├── demo1_xxx.rb.xhtml.pdf
72
- ├── demo2_xxx.rb.xhtml
73
78
  ├── demo2_xxx.rb.xhtml.pdf
74
79
  └── sub_dir
75
- ├── demo3_xxx.rb.xhtml
76
80
  ├── demo3_xxx.rb.xhtml.pdf
77
- ├── demo4_xxx.rb.xhtml
78
81
  └── demo4_xxx.rb.xhtml.pdf
79
82
  ```
80
83
 
@@ -92,9 +95,18 @@ the pdf version of it.
92
95
 
93
96
  ### Changelogs
94
97
 
98
+ #### 0.0.3
99
+
100
+ - Update [agile_utils][] to 0.0.8
101
+ - Update [code_lister][] to 0.0.7
102
+ - Compress generated pdf files to one single tar.gzip file
103
+ - Fix bug in softwares_installed? method
104
+ - Remove the TODOs.md
105
+
95
106
  #### 0.0.2
96
107
 
97
108
  - Use [agile_utils][] to 0.0.5
109
+
98
110
  - Fix minor error when using --version
99
111
 
100
112
  #### 0.0.1
data/html2pdf.gemspec CHANGED
@@ -18,8 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.require_paths = ["lib"]
19
19
 
20
20
  spec.add_runtime_dependency 'thor'
21
- spec.add_runtime_dependency 'agile_utils', '~> 0.0.5'
22
- spec.add_runtime_dependency 'code_lister', '~> 0.0.6'
21
+ spec.add_runtime_dependency 'agile_utils', '~> 0.0.8'
22
+ spec.add_runtime_dependency 'code_lister', '~> 0.0.7'
23
23
 
24
24
  spec.add_development_dependency 'awesome_print', '~> 1.2'
25
25
  spec.add_development_dependency 'bundler', '~> 1.5'
data/lib/html2pdf/cli.rb CHANGED
@@ -4,7 +4,7 @@ require 'fileutils'
4
4
  require_relative '../html2pdf'
5
5
  module Html2Pdf
6
6
  class CLI < Thor
7
- desc 'export', 'export html files to pdfs'
7
+ desc 'export', 'export multiple html files to pdfs'
8
8
 
9
9
  method_option *AgileUtils::Options::BASE_DIR
10
10
  method_option *AgileUtils::Options::INC_WORDS
@@ -16,7 +16,7 @@ module Html2Pdf
16
16
  def export
17
17
  opts = options.symbolize_keys
18
18
 
19
- unless Html2Pdf::Utils.required_softwares?
19
+ unless Html2Pdf::Utils.softwares_installed?
20
20
  fail 'You must have valid `wkhtmltopdf` and `ghostscript` installation'
21
21
  end
22
22
 
@@ -31,7 +31,13 @@ module Html2Pdf
31
31
  elapsed = AgileUtils::FileUtil.time do
32
32
  Html2Pdf::Utils.to_pdfs(input_files)
33
33
  end
34
+
35
+ generated_files = AgileUtils::FileUtil.add_suffix(input_files, 'pdf')
36
+ AgileUtils::FileUtil.tar_gzip_files(generated_files, 'html2pdf-output.tar.gz')
37
+ AgileUtils::FileUtil.delete(generated_files)
38
+
34
39
  puts "Convert files to pdfs took #{elapsed} ms"
40
+ puts "Your final output is #{File.absolute_path('html2pdf-output.tar.gz')}"
35
41
  end
36
42
 
37
43
  desc 'usage', 'Display usage information'
@@ -51,7 +57,7 @@ Options:
51
57
  # Default: true
52
58
  -v, [--version], [--no-version] # Display version information
53
59
 
54
- export html files to pdfs
60
+ export multiple html files to pdfs
55
61
  EOT
56
62
  end
57
63
 
@@ -20,10 +20,6 @@ module Html2Pdf
20
20
  #
21
21
  # @param filename input filename
22
22
  def to_pdf(filename)
23
- # see: http://madalgo.au.dk/~jakobt/wkhtmltoxdoc/wkhtmltopdf_0.10.0_rc2-doc.html#Footers And Headers
24
- # - may be only allow "*.html" and "*.xhtml"
25
- # - allow the options to be passed in so that we can use different theme
26
- # '--no-background'
27
23
  fail "Invalid input file #{filename}" unless File.exist?(filename)
28
24
  command = [
29
25
  'wkhtmltopdf',
@@ -31,16 +27,10 @@ module Html2Pdf
31
27
  '--margin-bottom 4',
32
28
  '--margin-left 4',
33
29
  '--margin-right 4',
34
- # Note: working correctly but long URL
35
30
  '--header-center "[webpage] :: [page]/[topage]"',
36
- # header section
37
- # TODO: not yet working properly
38
- # "--header-center #{filename.gsub(base_dir,File.basename(base_dir))} \"[page]/[topage]\"",
39
- # "--header-center #{filename} \"[page]/[topage]\"",
40
31
  '--header-spacing 1',
41
32
  '--header-font-size 8',
42
33
  '--header-line',
43
- # footer section
44
34
  '--footer-spacing 1',
45
35
  '--footer-font-size 8',
46
36
  '--footer-line',
@@ -48,15 +38,13 @@ module Html2Pdf
48
38
  "#{filename}.pdf",
49
39
  '> /dev/null']
50
40
  _stdin, _stderr, status = Open3.capture3(command.join(' '))
51
- # puts "FYI: to_pdf command: #{command.join(' ')}"
52
- # Note: may be log it and continue
53
41
  fail "Problem processing #{filename}" unless status.success?
54
42
  end
55
43
 
56
44
  # Check and verify that the proper softwares are available.
57
45
  #
58
- def required_softwares?
59
- AgileUtils::Helper.which('gs') && AgileUtils::Helper.which('gs')
46
+ def softwares_installed?
47
+ AgileUtils::Helper.which('wkhtmltopdf') && AgileUtils::Helper.which('gs')
60
48
  end
61
49
  end
62
50
  end
@@ -1,3 +1,3 @@
1
1
  module Html2Pdf
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
@@ -5,10 +5,10 @@ describe Html2Pdf::Utils do
5
5
  assert_raises(RuntimeError) { Html2Pdf::Utils.to_pdf('bad-file-name') }
6
6
  end
7
7
  end
8
- context '#have_required_softwares' do
8
+ context '#softwares_installed?' do
9
9
  it 'raises error if the requirements are not met' do
10
- assert(Html2Pdf::Utils.required_softwares?,
11
- 'Must have valid installation of `wkhtmltopdf` and `ghostscript`')
10
+ assert(Html2Pdf::Utils.softwares_installed?,
11
+ 'Must have valid installation of `wkhtmltopdf` and `ghostscript`')
12
12
  end
13
13
  end
14
14
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html2pdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
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-04-25 00:00:00.000000000 Z
11
+ date: 2014-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -30,28 +30,28 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.0.5
33
+ version: 0.0.8
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.0.5
40
+ version: 0.0.8
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: code_lister
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.0.6
47
+ version: 0.0.7
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.0.6
54
+ version: 0.0.7
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: awesome_print
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -236,7 +236,6 @@ files:
236
236
  - LICENSE.txt
237
237
  - README.md
238
238
  - Rakefile
239
- - TODOs.md
240
239
  - bin/html2pdf
241
240
  - html2pdf.gemspec
242
241
  - lib/html2pdf.rb
data/TODOs.md DELETED
@@ -1,13 +0,0 @@
1
- ### TODOs
2
-
3
- - Remove the options that need to be default
4
- e.g. `--exts xhtml html` should be default and should not be changed by user.
5
-
6
- - Find minitest related to file-system test so that the code can be hooked to
7
- [TravisCI][]
8
-
9
- - Add test using [minitest-filesystem][]
10
-
11
- - Add more tests
12
-
13
- [minitest-filesystem]: https://github.com/stefanozanella/minitest-filesystem