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

Constructor for Executor

Parameters:

  • url (String)

    the input URL like github.com/opal/opal.git or just the immediat 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 theme to use for ‘vim_printer`



25
26
27
28
29
30
31
32
33
# File 'lib/github_exporter/exporter.rb', line 25

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))
end

Instance Attribute Details

#base_dirObject (readonly)

Returns the value of attribute base_dir.



13
14
15
# File 'lib/github_exporter/exporter.rb', line 13

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_pathObject (readonly)

Returns the value of attribute output_path.



13
14
15
# File 'lib/github_exporter/exporter.rb', line 13

def output_path
  @output_path
end

#repo_nameObject (readonly)

Returns the value of attribute repo_name.



13
14
15
# File 'lib/github_exporter/exporter.rb', line 13

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



36
37
38
39
40
41
42
43
44
45
# File 'lib/github_exporter/exporter.rb', line 36

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



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/github_exporter/exporter.rb', line 47

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 EOT\nend\n"