Module: GithubExporter
- Defined in:
- lib/github_exporter/cli.rb,
lib/github_exporter/logger.rb,
lib/github_exporter/version.rb,
lib/github_exporter/exporter.rb,
lib/github_exporter/github_exporter.rb
Defined Under Namespace
Constant Summary collapse
- VERSION =
"0.1.6"
- TMP_DIR =
"github_exporter_tmp"
- CustomError =
Class.new(StandardError)
Class Attribute Summary collapse
-
.logger ⇒ Logger
The logger for the project.
Class Method Summary collapse
-
.clone_repository(url, name, path) ⇒ Object
Clone the given repository from github.
- .files_to_htmls(opts) ⇒ Object
-
.htmls_to_pdfs(opts) ⇒ Object
Export list of html files to pdfs using ‘html2pdf` gem.
- .list_extensions(base_dir = ".") ⇒ Object
- .list_files(options = {}) ⇒ Object
-
.pdfs_to_pdf(opts) ⇒ Object
Merge/combine pdfs using ‘pdfs2pdf` gem.
Class Attribute Details
.logger ⇒ Logger
Returns the logger for the project.
6 7 8 |
# File 'lib/github_exporter/logger.rb', line 6 def logger @logger ||= Logger.new STDOUT end |
Class Method Details
.clone_repository(url, name, path) ⇒ Object
Clone the given repository from github
13 14 15 16 |
# File 'lib/github_exporter/github_exporter.rb', line 13 def clone_repository(url, name, path) puts "git clone #{url} #{File.(path)}/#{name}" Git.clone url, name, path: File.(path) end |
.files_to_htmls(opts) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/github_exporter/github_exporter.rb', line 29 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) ⇒ Object
Export list of html files to pdfs using ‘html2pdf` gem
50 51 52 53 54 55 56 57 |
# File 'lib/github_exporter/github_exporter.rb', line 50 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 = ".") ⇒ Object
18 19 20 21 22 23 |
# File 'lib/github_exporter/github_exporter.rb', line 18 def list_extensions(base_dir = ".") extensions = Dir.glob(File.join(File.(base_dir), "**/*")).reduce([]) do |exts, file| exts << File.extname(file) end extensions.sort.uniq.delete_if { |e| e == "" } end |
.list_files(options = {}) ⇒ Object
25 26 27 |
# File 'lib/github_exporter/github_exporter.rb', line 25 def list_files( = {}) CodeLister.files() end |
.pdfs_to_pdf(opts) ⇒ Object
Merge/combine pdfs using ‘pdfs2pdf` gem
60 61 62 63 64 65 66 67 68 |
# File 'lib/github_exporter/github_exporter.rb', line 60 def pdfs_to_pdf(opts) base_dir = base_dir(opts[:base_dir]) Pdfs2Pdf::CLI.start [ "merge", "--base-dir", base_dir, "--recursive" ] end |