Class: WeaselDiesel::CLI

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

Overview

Since:

  • 0.0.3

Instance Method Summary collapse

Instance Method Details

#generate_doc(source_path, destination_path = "doc") ⇒ Object

Since:

  • 0.0.3



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/weasel_diesel/cli.rb', line 10

def generate_doc(source_path, destination_path="doc")
  api_files = Dir.glob(File.join(destination_root, source_path, "**", "*.rb"))
  if api_files.empty?
    puts "No ruby files in source_path: #{File.join(destination_root, source_path)}"
    return
  end
  api_files.each do |api|
    require api
  end

  require 'fileutils'
  destination = File.join(destination_root, destination_path)
  FileUtils.mkdir_p(destination) unless File.exist?(destination)
  File.open("#{destination}/index.html", "w"){|f| f << doc_template.result(binding)}
  puts "Documentation available there: #{destination}/index.html"
  `open #{destination}/index.html` if RUBY_PLATFORM =~ /darwin/ && !ENV['DONT_OPEN']
end