Class: Fdoc::Cli

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

Overview

A Thor definition for an fdoc to HTML conversion operation

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#origin_pathObject

Returns the value of attribute origin_path.



16
17
18
# File 'lib/fdoc/cli.rb', line 16

def origin_path
  @origin_path
end

Class Method Details

.source_rootObject



18
19
20
# File 'lib/fdoc/cli.rb', line 18

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

Instance Method Details

#convert(fdoc_path) ⇒ Object

Raises:



25
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
# File 'lib/fdoc/cli.rb', line 25

def convert(fdoc_path)
  say_status nil, "Converting fdoc to HTML"

  self.origin_path = File.expand_path(fdoc_path)
  raise Fdoc::NotFound.new(origin_path) unless has_valid_origin?
  say_status :using, fdoc_path

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

  in_root do
    copy_file("styles.css")
    create_file("index.html", meta_presenter.to_html) if has_meta_service?
  end

  service_presenters.each do |service_presenter|
    inside_service_presenter(service_presenter) do
      create_file("index.html", service_presenter.to_html)

      service_presenter.endpoints.each do |endpoint_prefix_group|
        endpoint_prefix_group.each do |endpoint|
          create_file(endpoint.url, endpoint.to_html)
        end
      end
    end
  end
end