Class: GithubExporter::Exporter

Inherits:
Object
  • Object
show all
Defined in:
lib/github_exporter/exporter.rb

Overview

rubocop:disable ClassLength, MethodLength

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, opts = {}) ⇒ Exporter

The initializer for Exporter

Parameters:

  • url (String)

    the input URL like github.com/opal/opal.git or just the immediate folder name

  • opts (Hash<Symbol,Object>) (defaults to: {})

    the option hash

Options Hash (opts):

  • :exts (Array<String>)

    the list of file extension to be used

  • :non_exts (Array<String>)

    the list of file without extension to be used

  • :theme (String)

    the colorscheme to use with ‘vim_printer`

  • :output_name (String)

    the output filename if any



29
30
31
32
33
34
35
36
37
38
# File 'lib/github_exporter/exporter.rb', line 29

def initialize(url, opts = {})
  @url         = url
  @base_dir    = Dir.pwd
  @exts        = opts[:exts]     || []
  @non_exts    = opts[:non_exts] || []
  @theme       = opts[:theme]    || "default"
  @repo_name   = project_name(url)
  @output_path = File.expand_path([base_dir, repo_name].join(File::SEPARATOR))
  @output_name = pdf_filename(opts[:output_name]) || "#{@repo_name}.pdf"
end

Instance Attribute Details

#base_dirObject (readonly)

Returns the value of attribute base_dir.



15
16
17
# File 'lib/github_exporter/exporter.rb', line 15

def base_dir
  @base_dir
end

#extsObject (readonly)

Returns the value of attribute exts.



9
10
11
# File 'lib/github_exporter/exporter.rb', line 9

def exts
  @exts
end

#non_extsObject (readonly)

Returns the value of attribute non_exts.



9
10
11
# File 'lib/github_exporter/exporter.rb', line 9

def non_exts
  @non_exts
end

#output_nameObject (readonly)

Returns the value of attribute output_name.



9
10
11
# File 'lib/github_exporter/exporter.rb', line 9

def output_name
  @output_name
end

#output_pathObject (readonly)

Returns the value of attribute output_path.



15
16
17
# File 'lib/github_exporter/exporter.rb', line 15

def output_path
  @output_path
end

#repo_nameObject (readonly)

Returns the value of attribute repo_name.



15
16
17
# File 'lib/github_exporter/exporter.rb', line 15

def repo_name
  @repo_name
end

#themeObject (readonly)

Returns the value of attribute theme.



9
10
11
# File 'lib/github_exporter/exporter.rb', line 9

def theme
  @theme
end

#urlObject (readonly)

Returns the value of attribute url.



9
10
11
# File 'lib/github_exporter/exporter.rb', line 9

def url
  @url
end

Instance Method Details

#exportObject

Print and export the source from a given URL to a pdf



41
42
43
44
45
46
47
48
49
50
# File 'lib/github_exporter/exporter.rb', line 41

def export
  clone
  puts "FYI: list of extensions: #{all_extensions}"
  puts "FYI: list of all files : #{all_files}"
  files2htmls
  htmls2pdfs
  pdfs2pdf
  copy_output
  cleanup
end

#to_sObject



52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/github_exporter/exporter.rb', line 52

def to_s
  "    url         : \#{url}\n    base_dir    : \#{base_dir}\n    exts        : \#{exts}\n    non_exts    : \#{non_exts}\n    repo_name   : \#{repo_name}\n    theme       : \#{theme}\n    output_path : \#{output_path}\n    output_name : \#{output_name}\n EOT\nend\n"