html2pdf 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 19ba6778d92b10b6f87f16d3a3cb0c22a8c50a3d
4
- data.tar.gz: 92f96fde362f8cc2ec4a808d34698ab0ee558210
3
+ metadata.gz: 2f8f6a51e86e49c276d81ffec9fa0832ceef8b74
4
+ data.tar.gz: fc555de91188234f96a329805ec8a40e42755cdb
5
5
  SHA512:
6
- metadata.gz: 06131276e8267087977f5ebbe65fd0f08c13de6d287440bce7fd0232b09a40db645e76fd0016d18fd62b258f330bb64bfb7ced3d8772848d0c6550aafef4ab46
7
- data.tar.gz: 377c402bac25aaf905d0893e450295de89259e52557b74087cac7ca0c7b1f8eb177c3d6ca75e34b41bd99a9c1935dfad8fc34e34cb3c5a1ae9f326da59311d43
6
+ metadata.gz: 57b41fe8ec8866f1215853e7dc9089f1b90d9166f2a885213b0bb3c62ce5e215b82bb4534ce03009f7bf7a7113c2eefa14b69517189cc5f96d2e0470269e9690
7
+ data.tar.gz: f4a47caeb6143ef96a99eeec6dd37b486251532bdedda5cd0f60e673d4b51d85be1d0b768dfe48869d162c08bfbe45f1e14e2f14ff842eafd9a84527c8c7780c
data/.gitignore CHANGED
@@ -19,3 +19,4 @@ tmp
19
19
  tags
20
20
  # Custom ignore files
21
21
  html2pdf-output.tar.gz
22
+ .ruby-version
data/.rubocop.yml CHANGED
@@ -1 +1,95 @@
1
- inherit_from: rubocop-todo.yml
1
+ AllCops:
2
+ Include:
3
+ - Gemfile
4
+ - Rakefile
5
+ - bin/*
6
+ - html2pdf.gemspec
7
+ - lib/**/*.rb
8
+ - test/**/*.rb
9
+ # Avoid long parameter lists
10
+ ParameterLists:
11
+ Max: 5
12
+ CountKeywordArgs: true
13
+
14
+ MethodLength:
15
+ CountComments: false
16
+ Max: 15
17
+
18
+ # Avoid more than `Max` levels of nesting.
19
+ BlockNesting:
20
+ Max: 4
21
+
22
+ # Align with the style guide.
23
+ CollectionMethods:
24
+ PreferredMethods:
25
+ collect: 'map'
26
+ inject: 'reduce'
27
+ find: 'detect'
28
+ find_all: 'select'
29
+
30
+ # Do not force public/protected/private keyword to be indented at the same
31
+ # level as the def keyword. My personal preference is to outdent these keywords
32
+ # because I think when scanning code it makes it easier to identify the
33
+ # sections of code and visually separate them. When the keyword is at the same
34
+ # level I think it sort of blends in with the def keywords and makes it harder
35
+ # to scan the code and see where the sections are.
36
+ AccessModifierIndentation:
37
+ Enabled: false
38
+
39
+ # Limit line length
40
+ LineLength:
41
+ Enabled: false
42
+
43
+ # Disable documentation checking until a class needs to be documented once
44
+ Documentation:
45
+ Enabled: false
46
+
47
+ # Enforce Ruby 1.8-compatible hash syntax
48
+ HashSyntax:
49
+ Enabled: true
50
+
51
+ # No spaces inside hash literals
52
+ SpaceInsideHashLiteralBraces:
53
+ EnforcedStyle: no_space
54
+
55
+ # Allow dots at the end of lines
56
+ DotPosition:
57
+ Enabled: false
58
+
59
+ # Don't require magic comment at the top of every file
60
+ Encoding:
61
+ Enabled: false
62
+
63
+ # Enforce outdenting of access modifiers (i.e. public, private, protected)
64
+ AccessModifierIndentation:
65
+ EnforcedStyle: outdent
66
+
67
+ EmptyLinesAroundAccessModifier:
68
+ Enabled: true
69
+
70
+ # Align ends correctly
71
+ EndAlignment:
72
+ AlignWith: variable
73
+
74
+ # Indentation of when/else
75
+ CaseIndentation:
76
+ IndentWhenRelativeTo: end
77
+ IndentOneStep: false
78
+
79
+ DoubleNegation:
80
+ Enabled: false
81
+
82
+ PercentLiteralDelimiters:
83
+ PreferredDelimiters:
84
+ '%': ()
85
+ '%i': ()
86
+ '%q': ()
87
+ '%Q': ()
88
+ '%r': '{}'
89
+ '%s': ()
90
+ '%w': '[]'
91
+ '%W': '[]'
92
+ '%x': ()
93
+
94
+ StringLiterals:
95
+ EnforcedStyle: double_quotes
@@ -1,5 +1,10 @@
1
1
  ### Html2Pdf - Changelogs
2
2
 
3
+ #### 0.1.2
4
+
5
+ - Simplify the CLI
6
+ - Style cleanup with rubocop
7
+
3
8
  #### 0.1.1
4
9
 
5
10
  - Remove 'ghostscript' from the required software in error message
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in code_exporter.gemspec
4
4
  gemspec
data/README.md CHANGED
@@ -39,7 +39,7 @@ Which should give the following output
39
39
 
40
40
  ```
41
41
  Usage:
42
- html2pdf export [OPTIONS]
42
+ html2pdf
43
43
 
44
44
  Options:
45
45
  -b, [--base-dir=BASE_DIR] # Base directory
@@ -54,7 +54,7 @@ Options:
54
54
  - Convert all `xhtml` and `html` from `test/fixtures/samples` directory
55
55
  recursively
56
56
  ```
57
- html2pdf export -b test/fixtures/samples -r
57
+ html2pdf -b test/fixtures/samples -r
58
58
  ```
59
59
  Before the run
60
60
  ```
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
- require 'bundler/gem_tasks'
2
- require 'rake/testtask'
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
3
 
4
- project_name = 'html2pdf'
4
+ project_name = "html2pdf"
5
5
 
6
6
  Rake::TestTask.new do |t|
7
7
  t.libs << "lib/#{project_name}"
@@ -12,20 +12,20 @@ end
12
12
  task default: [:test, :rubocop]
13
13
 
14
14
  task :pry do
15
- require 'pry'
16
- require 'awesome_print'
17
- require_relative './lib/html2pdf'
15
+ require "pry"
16
+ require "awesome_print"
17
+ require_relative "./lib/html2pdf"
18
18
  include Html2Pdf
19
19
  ARGV.clear
20
20
  Pry.start
21
21
  end
22
22
 
23
- require 'rubocop/rake_task'
24
- desc 'Run RuboCop on the lib directory'
23
+ require "rubocop/rake_task"
24
+ desc "Run RuboCop on the lib directory"
25
25
  Rubocop::RakeTask.new(:rubocop) do |task|
26
- task.patterns = ['lib/**/*.rb']
26
+ task.patterns = ["lib/**/*.rb"]
27
27
  # only show the files with failures
28
- task.formatters = ['files']
28
+ task.formatters = ["files"]
29
29
  # don't abort rake on failure
30
30
  task.fail_on_error = false
31
31
  end
data/bin/html2pdf CHANGED
@@ -1,4 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
- require_relative '../lib/html2pdf'
2
+ require_relative "../lib/html2pdf"
3
3
  include Html2Pdf
4
- Html2Pdf::CLI.start(ARGV)
4
+ if ARGV.empty?
5
+ Html2Pdf::CLI.start(%w[usage])
6
+ else
7
+ Html2Pdf::CLI.start(%w[export].concat(ARGV))
8
+ end
data/html2pdf.gemspec CHANGED
@@ -1,41 +1,40 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
2
+ lib = File.expand_path("../lib", __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'html2pdf/version'
4
+ require "html2pdf/version"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = 'html2pdf'
7
+ spec.name = "html2pdf"
8
8
  spec.version = Html2Pdf::VERSION
9
- spec.authors = ['Burin Choomnuan']
10
- spec.email = ['agilecreativity@gmail.com']
9
+ spec.authors = ["Burin Choomnuan"]
10
+ spec.email = ["agilecreativity@gmail.com"]
11
11
  spec.summary = %q(Bulk export list of html or xhtml files to pdfs with 'wkhtmltopdf')
12
12
  spec.description = %q(Export list of html or xhtml files to pdfs with 'wkhtmltopdf')
13
- spec.homepage = 'https://github.com/agilecreativity/html2pdf'
14
- spec.license = 'MIT'
15
- spec.files = Dir.glob('{bin,lib}/**/*') + %w(Gemfile
13
+ spec.homepage = "https://github.com/agilecreativity/html2pdf"
14
+ spec.license = "MIT"
15
+ spec.files = Dir.glob("{bin,lib}/**/*") + %w[Gemfile
16
16
  Rakefile
17
17
  html2pdf.gemspec
18
18
  README.md
19
- CHANGELOGS.md
19
+ CHANGELOG.md
20
20
  LICENSE
21
21
  .rubocop.yml
22
- .gitignore
23
- rubocop-todo.yml)
22
+ .gitignore]
24
23
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
25
- spec.test_files = Dir.glob('{test}/**/*')
26
- spec.require_paths = ['lib']
27
- spec.add_runtime_dependency 'thor', '~> 0.19'
28
- spec.add_runtime_dependency 'agile_utils', '~> 0.1'
29
- spec.add_runtime_dependency 'code_lister', '~> 0.1'
30
- spec.add_development_dependency 'awesome_print', '~> 1.2'
31
- spec.add_development_dependency 'bundler', '~> 1.5'
32
- spec.add_development_dependency 'gem-ctags', '~> 1.0'
33
- spec.add_development_dependency 'guard', '~> 2.6'
34
- spec.add_development_dependency 'guard-minitest', '~> 2.2'
35
- spec.add_development_dependency 'minitest', '~> 5.3'
36
- spec.add_development_dependency 'minitest-spec-context', '~> 0.0.3'
37
- spec.add_development_dependency 'pry', '~> 0.9'
38
- spec.add_development_dependency 'rake', '~> 10.1'
39
- spec.add_development_dependency 'rubocop', '~> 0.20'
40
- spec.add_development_dependency 'yard', '~> 0.8'
24
+ spec.test_files = Dir.glob("{test}/**/*")
25
+ spec.require_paths = ["lib"]
26
+ spec.add_runtime_dependency "thor", "~> 0.19"
27
+ spec.add_runtime_dependency "agile_utils", "~> 0.1"
28
+ spec.add_runtime_dependency "code_lister", "~> 0.1"
29
+ spec.add_development_dependency "awesome_print", "~> 1.2"
30
+ spec.add_development_dependency "bundler", "~> 1.5"
31
+ spec.add_development_dependency "gem-ctags", "~> 1.0"
32
+ spec.add_development_dependency "guard", "~> 2.6"
33
+ spec.add_development_dependency "guard-minitest", "~> 2.2"
34
+ spec.add_development_dependency "minitest", "~> 5.3"
35
+ spec.add_development_dependency "minitest-spec-context", "~> 0.0.3"
36
+ spec.add_development_dependency "pry", "~> 0.9"
37
+ spec.add_development_dependency "rake", "~> 10.1"
38
+ spec.add_development_dependency "rubocop", "~> 0.20"
39
+ spec.add_development_dependency "yard", "~> 0.8"
41
40
  end
data/lib/html2pdf.rb CHANGED
@@ -1,7 +1,7 @@
1
- require 'agile_utils'
2
- require 'code_lister'
3
- require_relative './html2pdf/html2pdf'
4
- require_relative './html2pdf/cli'
5
- require_relative './html2pdf/version'
1
+ require "agile_utils"
2
+ require "code_lister"
3
+ require_relative "./html2pdf/html2pdf"
4
+ require_relative "./html2pdf/cli"
5
+ require_relative "./html2pdf/version"
6
6
  include AgileUtils::Options
7
7
  include CodeLister
data/lib/html2pdf/cli.rb CHANGED
@@ -1,10 +1,10 @@
1
- require 'thor'
2
- require 'tmpdir'
3
- require 'fileutils'
4
- require_relative '../html2pdf'
1
+ require "thor"
2
+ require "tmpdir"
3
+ require "fileutils"
4
+ require_relative "../html2pdf"
5
5
  module Html2Pdf
6
6
  class CLI < Thor
7
- desc 'export', 'export multiple html files to pdfs'
7
+ desc "export", "export multiple html files to pdfs"
8
8
  method_option *AgileUtils::Options::BASE_DIR
9
9
  method_option *AgileUtils::Options::RECURSIVE
10
10
  method_option *AgileUtils::Options::VERSION
@@ -12,7 +12,7 @@ module Html2Pdf
12
12
  opts = options.symbolize_keys
13
13
 
14
14
  unless Html2Pdf.softwares_installed?
15
- fail 'You must have valid `wkhtmltopdf` installation'
15
+ fail "You must have valid `wkhtmltopdf` installation"
16
16
  end
17
17
 
18
18
  if opts[:version]
@@ -21,25 +21,25 @@ module Html2Pdf
21
21
  end
22
22
 
23
23
  input_files = CodeLister.files base_dir: opts[:base_dir],
24
- exts: %w(html xhtml),
24
+ exts: %w[html xhtml],
25
25
  recursive: true
26
26
  elapsed = AgileUtils::FileUtil.time do
27
27
  Html2Pdf.to_pdfs(input_files)
28
28
  end
29
29
 
30
- generated_files = AgileUtils::FileUtil.add_suffix(input_files, 'pdf')
31
- AgileUtils::FileUtil.tar_gzip_files(generated_files, 'html2pdf-output.tar.gz')
30
+ generated_files = AgileUtils::FileUtil.add_suffix(input_files, "pdf")
31
+ AgileUtils::FileUtil.tar_gzip_files(generated_files, "html2pdf-output.tar.gz")
32
32
  AgileUtils::FileUtil.delete(generated_files)
33
33
 
34
34
  puts "Convert files to pdfs took #{elapsed} ms"
35
- puts "Your final output is #{File.absolute_path('html2pdf-output.tar.gz')}"
35
+ puts "Your final output is #{File.absolute_path("html2pdf-output.tar.gz")}"
36
36
  end
37
37
 
38
- desc 'usage', 'Display usage information'
38
+ desc "usage", "Display usage information"
39
39
  def usage
40
40
  puts <<-EOT
41
41
  Usage:
42
- html2pdf export [OPTIONS]
42
+ html2pdf
43
43
 
44
44
  Options:
45
45
  -b, [--base-dir=BASE_DIR] # Base directory
@@ -1,6 +1,6 @@
1
- require 'open3'
2
- require 'fileutils'
3
- require_relative '../html2pdf'
1
+ require "open3"
2
+ require "fileutils"
3
+ require_relative "../html2pdf"
4
4
 
5
5
  module Html2Pdf
6
6
  class << self
@@ -21,29 +21,29 @@ module Html2Pdf
21
21
  def to_pdf(filename)
22
22
  fail "Invalid input file #{filename}" unless File.exist?(filename)
23
23
  command = [
24
- 'wkhtmltopdf',
25
- '--margin-top 4',
26
- '--margin-bottom 4',
27
- '--margin-left 4',
28
- '--margin-right 4',
24
+ "wkhtmltopdf",
25
+ "--margin-top 4",
26
+ "--margin-bottom 4",
27
+ "--margin-left 4",
28
+ "--margin-right 4",
29
29
  '--header-center "[webpage] :: [page]/[topage]"',
30
- '--header-spacing 1',
31
- '--header-font-size 8',
32
- '--header-line',
33
- '--footer-spacing 1',
34
- '--footer-font-size 8',
35
- '--footer-line',
30
+ "--header-spacing 1",
31
+ "--header-font-size 8",
32
+ "--header-line",
33
+ "--footer-spacing 1",
34
+ "--footer-font-size 8",
35
+ "--footer-line",
36
36
  "#{filename}",
37
37
  "#{filename}.pdf",
38
- '> /dev/null']
39
- _stdin, _stderr, status = Open3.capture3(command.join(' '))
38
+ "> /dev/null"]
39
+ _stdin, _stderr, status = Open3.capture3(command.join(" "))
40
40
  fail "Problem processing #{filename}" unless status.success?
41
41
  end
42
42
 
43
43
  # Check and verify that the proper softwares are available.
44
44
  #
45
45
  def softwares_installed?
46
- AgileUtils::Helper.which('wkhtmltopdf')
46
+ AgileUtils::Helper.which("wkhtmltopdf")
47
47
  end
48
48
  end
49
49
  end
@@ -1,3 +1,3 @@
1
1
  module Html2Pdf
2
- VERSION = '0.1.1'
2
+ VERSION = "0.1.2"
3
3
  end
@@ -1,13 +1,13 @@
1
1
  # file: spec/fixtures/demo1.rb
2
2
  # from: https://github.com/radar/guides/blob/master/gem-development/foodie/lib/foodie/food.rb
3
- require 'active_support/inflector'
3
+ require "active_support/inflector"
4
4
  module Foodie
5
5
  class Food
6
6
  def self.portray(food)
7
- if food.downcase == 'broccoli'
8
- 'Gross!'
7
+ if food.downcase == "broccoli"
8
+ "Gross!"
9
9
  else
10
- 'Delicious!'
10
+ "Delicious!"
11
11
  end
12
12
  end
13
13
 
@@ -1,23 +1,23 @@
1
1
  # file: spec/fixtures/demo2.rb
2
2
  # from: https://github.com/radar/guides/blob/master/gem-development/foodie/lib/foodie/cli.rb
3
- require 'thor'
4
- require 'foodie'
5
- require 'foodie/generators/recipe'
3
+ require "thor"
4
+ require "foodie"
5
+ require "foodie/generators/recipe"
6
6
 
7
7
  module Foodie
8
8
  class CLI < Thor
9
- desc 'portray ITEM', 'Determines if a piece of food is gross or delicious'
9
+ desc "portray ITEM", "Determines if a piece of food is gross or delicious"
10
10
  def portray(name)
11
11
  puts Foodie::Food.portray(name)
12
12
  end
13
13
 
14
- desc 'pluralize', 'Pluralizes a word'
14
+ desc "pluralize", "Pluralizes a word"
15
15
  method_option :word, aliases: :word
16
16
  def pluralize
17
17
  puts Foodie::Food.pluralize(options[:word])
18
18
  end
19
19
 
20
- desc 'recipe', 'Generates a recipe scaffold'
20
+ desc "recipe", "Generates a recipe scaffold"
21
21
  def recipe(group, name)
22
22
  Foodie::Generators::Recipe.start([group, name])
23
23
  end
@@ -1,6 +1,6 @@
1
1
  # file: spec/fixtures/sub-dir/demo3.xxx.rb
2
2
  # from: https://github.com/radar/guides/blob/master/gem-development/foodie/lib/foodie/generators/recipe.rb
3
- require 'thor/group'
3
+ require "thor/group"
4
4
  module Foodie
5
5
  module Generators
6
6
  class Recipe < Thor::Group
@@ -9,7 +9,7 @@ module Foodie
9
9
  include Thor::Actions
10
10
 
11
11
  def self.source_root
12
- File.dirname(__FILE__) + '/recipe'
12
+ File.dirname(__FILE__) + "/recipe"
13
13
  end
14
14
 
15
15
  def create_group
@@ -17,7 +17,7 @@ module Foodie
17
17
  end
18
18
 
19
19
  def copy_recipe
20
- template('recipe.txt', "#{group}/#{name}.txt")
20
+ template("recipe.txt", "#{group}/#{name}.txt")
21
21
  end
22
22
  end
23
23
  end
@@ -1,6 +1,6 @@
1
1
  # file: spec/fixtures/sub-dir/demo3.xxx.rb
2
2
  # from: https://github.com/radar/guides/blob/master/gem-development/foodie/lib/foodie.rb
3
- require 'foodie/food'
3
+ require "foodie/food"
4
4
  module Foodie
5
5
  # Your code goes here...
6
6
  end
@@ -1,14 +1,14 @@
1
- require_relative '../../test_helper'
1
+ require_relative "../../test_helper"
2
2
  describe Html2Pdf do
3
- context '#to_pdf' do
4
- it 'raises error on invalid input file' do
5
- assert_raises(RuntimeError) { Html2Pdf.to_pdf('bad-file-name') }
3
+ context "#to_pdf" do
4
+ it "raises error on invalid input file" do
5
+ assert_raises(RuntimeError) { Html2Pdf.to_pdf("bad-file-name") }
6
6
  end
7
7
  end
8
- context '#softwares_installed?' do
9
- it 'raises error if the requirements are not met' do
8
+ context "#softwares_installed?" do
9
+ it "raises error if the requirements are not met" do
10
10
  assert(Html2Pdf.softwares_installed?,
11
- 'Must have valid installation of `wkhtmltopdf`')
11
+ "Must have valid installation of `wkhtmltopdf`")
12
12
  end
13
13
  end
14
14
  end
data/test/test_helper.rb CHANGED
@@ -1,7 +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/html2pdf'
1
+ require "minitest/autorun"
2
+ require "minitest/pride"
3
+ require "minitest-spec-context"
4
+ require "pry"
5
+ require "awesome_print"
6
+ require_relative "../lib/html2pdf"
7
7
  include Html2Pdf
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.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-12 00:00:00.000000000 Z
11
+ date: 2014-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -216,7 +216,7 @@ extra_rdoc_files: []
216
216
  files:
217
217
  - ".gitignore"
218
218
  - ".rubocop.yml"
219
- - CHANGELOGS.md
219
+ - CHANGELOG.md
220
220
  - Gemfile
221
221
  - LICENSE
222
222
  - README.md
@@ -227,7 +227,6 @@ files:
227
227
  - lib/html2pdf/cli.rb
228
228
  - lib/html2pdf/html2pdf.rb
229
229
  - lib/html2pdf/version.rb
230
- - rubocop-todo.yml
231
230
  - test/fixtures/samples/demo1_xxx.rb
232
231
  - test/fixtures/samples/demo1_xxx.rb.xhtml
233
232
  - test/fixtures/samples/demo1_xxx.rb.xhtml.pdf
data/rubocop-todo.yml DELETED
@@ -1,27 +0,0 @@
1
- # This configuration was generated by `rubocop --auto-gen-config`
2
- # on 2014-05-12 23:39:22 +1000 using RuboCop version 0.21.0.
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: 3
9
- AmbiguousOperator:
10
- Enabled: false
11
-
12
- # Offense count: 6
13
- Documentation:
14
- Enabled: false
15
-
16
- # Offense count: 7
17
- LineLength:
18
- Max: 93
19
-
20
- # Offense count: 2
21
- # Configuration parameters: CountComments.
22
- MethodLength:
23
- Max: 19
24
-
25
- # Offense count: 1
26
- RegexpLiteral:
27
- MaxSlashes: 0