Module: Squatch

Defined in:
lib/squatch.rb,
lib/squatch/base.rb,
lib/squatch/version.rb

Defined Under Namespace

Modules: Base

Constant Summary collapse

VERSION =
"0.5.0"

Class Method Summary collapse

Class Method Details

.prepare(data) ⇒ Object



39
40
41
42
43
44
45
46
# File 'lib/squatch.rb', line 39

def prepare(data)
  options = Hash[:data, data]

  puts "Specify file type (ie css or js):"
  options[:ext] = gets.strip

  Squatch::Base.squatch(options)
end

.run(arguments) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/squatch.rb', line 8

def run(arguments)
  unless arguments.empty? || !arguments[0].include?('-')
    optparser = OptionParser.new do|opts|
      opts.banner = "Usage: squatch -command [FILE/DIR]"

      opts.on('-h', '--help', 'Display this help') do
        puts optparser
        exit
      end
      opts.on('-v', '--version', 'Display current gem version') do
        puts "Squatch-#{VERSION}"
      end
      opts.on('-f', '--file FILE', 'Squatch FILE in place') do |file|
        prepare(file)
      end
      opts.on('-F', '--folder DIR', 'Squatch files from DIR in place') do |dir|
        prepare(dir)
      end
    end
    
    begin optparser.parse!(arguments)
    rescue OptionParser::ParseError => error
      puts "#{error}"
      puts optparser
      exit
    end
  else
    puts `squatch -h`
  end
end