Module: Source2Epub

Defined in:
lib/source2epub/cli.rb,
lib/config/source2epub.rb,
lib/source2epub/version.rb,
lib/source2epub/exporter.rb,
lib/source2epub/source2epub.rb,
lib/source2epub/configuration.rb

Defined Under Namespace

Classes: CLI, Configuration, Exporter

Constant Summary collapse

VERSION =
"0.2.8"
TMP_DIR =
"source2epub_tmp"
CustomError =
Class.new(StandardError)

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationObject

Configure Source2Epub someplace sensible, like

‘config/initializers/source2epub.rb’

Source2Epub.configure do |config|

config.creator = ".."

end



25
26
27
# File 'lib/source2epub/configuration.rb', line 25

def configuration
  @configuration
end

Class Method Details

.clone_repository(url, name, path) ⇒ Object

Clone the given repository from github

Parameters:

  • url (String)

    the github repository url like ‘github.com/schacon/ruby-git.git

  • name (String)

    the output name to be used

  • path (String)

    the output directory



10
11
12
13
# File 'lib/source2epub/source2epub.rb', line 10

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

.configure {|configuration| ... } ⇒ Object

Yields:



29
30
31
# File 'lib/source2epub/configuration.rb', line 29

def configure
  yield(configuration)
end

.files_to_htmls(opts) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/source2epub/source2epub.rb', line 26

def files_to_htmls(opts)
  base_dir = base_dir(opts[:base_dir])
  unless File.exist?(base_dir) && File.directory?(base_dir)
    fail "Starting directory must be valid, and exist"
  end

  exts     = opts[:exts]     || []
  non_exts = opts[:non_exts] || []
  theme    = opts.fetch(:theme, "default")
  command  = opts[:command]

  if command
    args = [
      "print",
      "--base-dir",
      base_dir,
      "--command",
      command,
      "--theme",
      theme
    ]
  else
    args = [
      "print",
      "--base-dir",
      base_dir,
      "--exts",
      exts,
      "--theme",
      theme,
      "--recursive"
    ]
    args.concat(["--non-exts"]).concat(non_exts) unless non_exts.empty?
  end
  VimPrinter::CLI.start(args)
end

.list_extensions(base_dir = ".") ⇒ Object



15
16
17
18
19
20
# File 'lib/source2epub/source2epub.rb', line 15

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 = {}) ⇒ Object



22
23
24
# File 'lib/source2epub/source2epub.rb', line 22

def list_files(options = {})
  CodeLister.files(options)
end

.update_configObject



3
4
5
6
7
8
9
10
# File 'lib/config/source2epub.rb', line 3

def update_config
  Source2Epub.configure do |config|
    config.creator        = "Burin C"
    config.publisher      = "Burin C"
    config.published_date = "2014-06-23" # TODO: get the current date
    config.identifier     = "https://agilecreativity.com/"
  end
end