class MarkDApp
Public Instance Methods
force_exit(reason)
click to toggle source
# File lib/markd.rb, line 53 def force_exit(reason) puts reason exit 0 end
init(argv)
click to toggle source
# File lib/markd.rb, line 49 def init(argv) @options = parse_opts argv end
parse_opts(argv)
click to toggle source
# File lib/markd.rb, line 28 def parse_opts(argv) @options = {} OptionParser.new { |opt| opt.on("-v", "--version") { version = File.read "#{APP_ROOT}/VERSION" puts "#{APP_NAME} #{version}" exit(0) } opt.on("-h", "--help") { puts usage exit(0) } opt.on("-o OUTDIR", "--output OUTDIR") { |out_dir| @options[:out_dir] = out_dir } opt.parse! argv } @options end
publish(filename, out_filename)
click to toggle source
# File lib/markd.rb, line 58 def publish(filename, out_filename) force_exit("#{filename} not file or exists") unless File.file? filename out_dir = @options[:out_dir] || "docs" MarkD.new.publish(filename, out_dir, out_filename) end
run(argv)
click to toggle source
# File lib/markd.rb, line 64 def run(argv) init argv argv.each do |filename| # use 'index.html' as output if one input file given out_filename = (argv.size == 1) ? "index.html" : File.basename(filename, ".*") + ".html" publish filename, out_filename end end
usage()
click to toggle source
# File lib/markd.rb, line 16 def usage usage_text = <<-"USAGE" Usage: markd [-o OUTPUT_DIR] markdown Options: -v, [--version] show version -h, [--help] show usage -o, [--output=OUTPUT_DIR] set output directory (default "docs") USAGE end