Module: Compressit

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

Defined Under Namespace

Modules: Base

Constant Summary collapse

VERSION =
"1.1.3"

Class Method Summary collapse

Class Method Details

.prepare(data) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/compressit.rb', line 39

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

  puts "Specify a version (ex. x.x.x):"
  options[:version] = gets.strip

  puts "css/js:"
  options[:ext] = gets.strip

  Compressit::Base.compressit(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/compressit.rb', line 8

def run(arguments)
  unless arguments.empty? || !arguments[0].include?('-')
    optparser = OptionParser.new do|opts|
      opts.banner = "Usage: compressit -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 "Compressit-#{VERSION}"
      end
      opts.on('-f', '--file FILE', 'Compress FILE in place') do |file|
        prepare(file)
      end
      opts.on('-F', '--files DIR', 'Compress files from DIR into DIR/compressed') do |dir|
        prepare(dir)
      end
    end
    
    begin optparser.parse!(arguments)
    rescue OptionParser::ParseError => error
      puts "#{error}"
      puts optparser
      exit
    end
  else
    puts `compressit -h`
  end
end