Sha256: 0a730ce0f4c0ba67f262a019f8c3b14c190a2262552f195a0e27553394d3e1fa
Contents?: true
Size: 1017 Bytes
Versions: 4
Compression:
Stored size: 1017 Bytes
Contents
require 'optparse' module Stowaway class Options DEFAULT_FILE_TYPES = %w{.jpg .gif .png .ico .js .css} attr_reader :path, :file_types def initialize(argv) @file_types = DEFAULT_FILE_TYPES @argv = argv parse end private def parse OptionParser.new do |opts| opts.banner = "Usage: stowaway [ options ] path/to/site" parse_types(opts) parse_help(opts) begin @argv = ["-h"] if @argv.empty? opts.parse!(@argv) rescue OptionParser::ParseError => e STDERR.puts e.message, "\n", opts exit(-1) end @path = @argv[0] end end def parse_types opts opts.on("-t", "--types <TYPES>", String, "File types to search for (ex: .jpg .gif)") do |ext| @file_types = ext.split(' ') end end def parse_help opts opts.on("-h", "--help", "Show this message") do puts opts exit end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
stowaway-0.2.5 | lib/stowaway/options.rb |
stowaway-0.2.2 | lib/stowaway/options.rb |
stowaway-0.2.0 | lib/stowaway/options.rb |
stowaway-0.1.10 | lib/stowaway/options.rb |