#!/usr/bin/env ruby require "trollop" require "rspec" require "ghost_writer" GhostWriter.output_flag = true parser = Trollop::Parser.new do version "ghost_writer v#{GhostWriter::VERSION}" banner <<-EOS Generate API Examples using Controller spec parameters. Usage: ghost_writer [options] where [options] are: EOS opt :output, "Output directory", :type => String opt :format, "Output doc format (default: markdown, availables: markdown, rst)", :type => String opt :clear, "[Caution] Clear Output directory before running specs", :default => false end opts = Trollop::with_standard_exception_handling parser do raise Trollop::HelpNeeded if ARGV.empty? parser.parse ARGV end RSpec.configure do |c| c.include GhostWriter GhostWriter.output_dir = opts[:output] GhostWriter.output_format = opts[:format].to_sym if opts[:format] c.after(:suite) do GhostWriter.generate_api_doc end end if opts[:clear] cmd = "rm -rf doc/#{GhostWriter.output_dir}" puts cmd system(cmd) end require "rspec/autorun"