Module: Mokuji

Defined in:
lib/mokuji.rb,
lib/mokuji/scanner.rb,
lib/mokuji/version.rb,
lib/mokuji/exporter.rb,
lib/mokuji/converter.rb,
lib/mokuji/validators.rb

Defined Under Namespace

Modules: Validators Classes: Converter, Exporter, Scanner

Constant Summary collapse

LIB_PATH =

Info

Mokuji makes recursive lists of directories and outputs it in html, plain-html, json or plain-text files.

How to use

require ‘mokuji’

Mokuji.make_list import_path, export_path # export path is optional

You could also

Mokuji.configure :hide_dot_files => false Mokuji.make_list import_path # Make a list with the dot files included Mokuji.configure :output_type => ‘json’ Mokuji.make_list import_path # Make another list in the json format

Example with Thor

begin

Mokuji.configure options
Mokuji.make_list import_path, export_path
say "BOOM! DONE!", :green

rescue RuntimeError => error_message

say error_message.to_s, :red

end

File.expand_path File.dirname(__FILE__)
DEFAULTS =
{
  'show_dot_files'   =>  false,     # Scanner options
  'output_type'      =>  'html',   # Converter options
  'list_name'        =>  nil       # Global options
}
VERSION =

{ VERSION }

'1.0.2'

Class Method Summary collapse

Class Method Details

.configurationObject



53
54
55
# File 'lib/mokuji.rb', line 53

def self.configuration
  return @config ||= DEFAULTS.clone
end

.configure(options = {}) ⇒ Object



44
45
46
47
48
49
50
51
# File 'lib/mokuji.rb', line 44

def self.configure options = {}
  Mokuji::Validators.validate_options(options)
  @config = unless @config
    DEFAULTS.merge(options)
  else
    @config.merge(options)
  end
end

.convert(hash) ⇒ Object



70
71
72
# File 'lib/mokuji.rb', line 70

def self.convert hash
  return self.converter.convert(hash)
end

.converterObject



69
# File 'lib/mokuji.rb', line 69

def self.converter; Mokuji::Converter.new; end

.export(string, export_path) ⇒ Object



75
76
77
# File 'lib/mokuji.rb', line 75

def self.export string, export_path
  return self.exporter.export(string, export_path)
end

.exporterObject



74
# File 'lib/mokuji.rb', line 74

def self.exporter; Mokuji::Exporter.new; end

.make_list(import_path, export_path = nil) ⇒ Object



57
58
59
60
61
62
# File 'lib/mokuji.rb', line 57

def self.make_list import_path, export_path = nil
  scan_results = self.scan import_path
  converter_results = self.convert(scan_results)
  export_path ||= import_path
  self.export converter_results, export_path
end

.scan(path) ⇒ Object



65
66
67
# File 'lib/mokuji.rb', line 65

def self.scan path
  return self.scanner.scan(path)
end

.scannerObject



64
# File 'lib/mokuji.rb', line 64

def self.scanner; Mokuji::Scanner.new; end