Class: Source2Epub::Exporter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Constructor for Executor

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`



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/source2epub/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"
  @command     = opts[:command]
  @repo_name   = project_name(url)
  @epub_title  = opts[:epub_title] || @repo_name
  @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.



16
17
18
# File 'lib/source2epub/exporter.rb', line 16

def base_dir
  @base_dir
end

#commandObject (readonly)

Returns the value of attribute command.



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

def command
  @command
end

#epub_titleObject (readonly)

Returns the value of attribute epub_title.



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

def epub_title
  @epub_title
end

#extsObject (readonly)

Returns the value of attribute exts.



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

def exts
  @exts
end

#non_extsObject (readonly)

Returns the value of attribute non_exts.



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

def non_exts
  @non_exts
end

#output_pathObject (readonly)

Returns the value of attribute output_path.



16
17
18
# File 'lib/source2epub/exporter.rb', line 16

def output_path
  @output_path
end

#repo_nameObject (readonly)

Returns the value of attribute repo_name.



16
17
18
# File 'lib/source2epub/exporter.rb', line 16

def repo_name
  @repo_name
end

#themeObject (readonly)

Returns the value of attribute theme.



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

def theme
  @theme
end

#urlObject (readonly)

Returns the value of attribute url.



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

def url
  @url
end

Instance Method Details

#exportObject

Print and export the source from a given URL to an epub file



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

def export
  clone
  puts "FYI: list of extensions: #{all_extensions}"
  # Note: if we are using the '--command', it will be empty list by default
  puts "FYI: list of all files : #{all_files}" unless all_files.empty?
  files2htmls
  htmls2epub
  copy_output
  cleanup
end