Class: Lurker::Cli

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/lurker/cli.rb

Overview

A Thor definition for an lurker to HTML conversion operation

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#contentObject

Returns the value of attribute content.



19
20
21
# File 'lib/lurker/cli.rb', line 19

def content
  @content
end

#origin_pathObject

Returns the value of attribute origin_path.



19
20
21
# File 'lib/lurker/cli.rb', line 19

def origin_path
  @origin_path
end

Class Method Details

.precompiled_static_rootObject



25
26
27
# File 'lib/lurker/cli.rb', line 25

def self.precompiled_static_root
  File.expand_path("../templates/public", __FILE__)
end

.source_rootObject



21
22
23
# File 'lib/lurker/cli.rb', line 21

def self.source_root
  File.expand_path("../templates", __FILE__)
end

Instance Method Details

#convert(lurker_path = Lurker::DEFAULT_SERVICE_PATH) ⇒ Object

Raises:



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/lurker/cli.rb', line 38

def convert(lurker_path=Lurker::DEFAULT_SERVICE_PATH)
  say_status nil, "Converting lurker to #{options[:format]}"

  self.content = get_content(options[:content])
  self.origin_path = File.expand_path(lurker_path)
  raise Lurker::NotFound.new(origin_path) unless has_valid_origin?
  say_status :using, lurker_path

  self.destination_root = output_path
  raise Lurker::NotADirectory.new(output_path) unless has_valid_destination?
  say_status :inside, output_path

  if options[:rails]
    require "#{Dir.pwd}/config/environment"
  end

  if options[:format] == 'pdf'
    convert_to_pdf
  else
    convert_to_html
  end
end