class Deanswerify::Exec
Kicks off the parsing process by parsing command-line arguments and calling the method that parses each input file.
Public Class Methods
new(args)
click to toggle source
@param args [Array<String>] All command-line arguments
# File lib/deanswerify.rb, line 10 def initialize(args) @args = args @options = {} end
Public Instance Methods
parse()
click to toggle source
Parses the command-line arguments and begins parsing the files.
@see parse!
# File lib/deanswerify.rb, line 26 def parse @opts = OptionParser.new(&method(:set_opts)) @opts.parse!(@args) process_result end
parse!()
click to toggle source
Parses the command-line arguments and begins parsing the files.
@see parse
# File lib/deanswerify.rb, line 18 def parse! parse exit 0 end
process_result()
click to toggle source
Processes the input files, removing all answer blocks
# File lib/deanswerify.rb, line 71 def process_result # Get a list of filenames to parse, and ignore the .git folder files = %x(find #{@options[:directory]} -type f -not -iwholename '*.git*').split("\n") # Parse each file in the filenames array Deanswerify::Parser.parse_files files end
set_opts(opts)
click to toggle source
Takes the command-line arguments and parses them for optparse.
@param opts [OptionParser]
# File lib/deanswerify.rb, line 36 def set_opts(opts) opts.banner = <<EOS deanswerify v#{Deanswerify::VERSION} Description: Parses every file within your current git tree, recursing into subdirectories and laying waste to any text between the following delimiters: I won't be deleted /* SOLUTION */ Text to be deleted Multiline is okay /* END SOLUTION */ Case doesn't matter, and you can do /* solution */ inline /* end solution */ Usage (from within a .git repository): deanswerify [options] Options: EOS # Set default options @options[:directory] = `git rev-parse --show-toplevel`.delete("\n") # opts.on( '-d', '--directory', 'Parse a particular directory' ) do # end opts.on_tail( '-h', '--help', 'Display this screen' ) do puts opts exit end end