module Source2Pdf
Constants
- CustomError
- TMP_DIR
- VERSION
Public Class Methods
clone_repository(url, name, path)
click to toggle source
Clone the given repository from git repository
@param [String] url the github repository url like 'github.com/schacon/ruby-git.git' @param [String] name the output name to be used @param [String] path the output directory
# File lib/source2pdf/source2pdf.rb, line 9 def clone_repository(url, name, path) puts "git clone #{url} #{File.expand_path(path)}/#{name}" Git.clone url, name, path: File.expand_path(path) end
files_to_htmls(opts)
click to toggle source
# File lib/source2pdf/source2pdf.rb, line 25 def files_to_htmls(opts) base_dir = base_dir(opts[:base_dir]) exts = opts[:exts] || [] non_exts = opts[:non_exts] || [] args = [ "print", "--base-dir", base_dir, "--exts", exts, "--theme", opts.fetch(:theme, "default"), "--recursive" ] args.concat(["--non-exts"]).concat(non_exts) unless non_exts.empty? puts "FYI: input options for VimPrinter : #{args}" VimPrinter::CLI.start(args) end
htmls_to_pdfs(opts)
click to toggle source
Export list of html files to pdfs using `html2pdf` gem
# File lib/source2pdf/source2pdf.rb, line 46 def htmls_to_pdfs(opts) base_dir = base_dir(opts[:base_dir]) Html2Pdf::CLI.start [ "export", "--base-dir", base_dir, "--recursive"] end
list_extensions(base_dir = ".")
click to toggle source
# File lib/source2pdf/source2pdf.rb, line 14 def list_extensions(base_dir = ".") extensions = Dir.glob(File.join(File.expand_path(base_dir), "**/*")).reduce([]) do |exts, file| exts << File.extname(file) end extensions.sort.uniq.delete_if { |e| e == "" } end
list_files(options = {})
click to toggle source
# File lib/source2pdf/source2pdf.rb, line 21 def list_files(options = {}) CodeLister.files(options) end
pdfs_to_pdf(opts)
click to toggle source
Merge/combine pdfs using `pdfs2pdf` gem
# File lib/source2pdf/source2pdf.rb, line 56 def pdfs_to_pdf(opts) base_dir = base_dir(opts[:base_dir]) Pdfs2Pdf::CLI.start [ "merge", "--base-dir", base_dir, "--recursive" ] end
Private Class Methods
base_dir(dir_name)
click to toggle source
Always expand the directory name so that '~' or '.' is expanded correctly
# File lib/source2pdf/source2pdf.rb, line 69 def base_dir(dir_name) File.expand_path(dir_name) end