Module: Squasher
- Extended by:
- Squasher
- Included in:
- Squasher
- Defined in:
- lib/squasher.rb,
lib/squasher/config.rb,
lib/squasher/render.rb,
lib/squasher/worker.rb,
lib/squasher/cleaner.rb
Defined Under Namespace
Classes: Cleaner, Config, Render, Worker
Instance Method Summary
collapse
Instance Method Details
#ask(*args) ⇒ Object
33
34
35
36
|
# File 'lib/squasher.rb', line 33
def ask(*args)
tell(*args)
$stdin.gets[0].downcase == 'y'
end
|
#clean ⇒ Object
24
25
26
|
# File 'lib/squasher.rb', line 24
def clean
Cleaner.process
end
|
#error(*args) ⇒ Object
45
46
47
48
|
# File 'lib/squasher.rb', line 45
def error(*args)
tell(*args)
exit
end
|
#rake(command, description = nil) ⇒ Object
28
29
30
31
|
# File 'lib/squasher.rb', line 28
def rake(command, description = nil)
tell(description) if description
system("bundle exec rake #{ command }")
end
|
#squash(raw_date, raw_options) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/squasher.rb', line 9
def squash(raw_date, raw_options)
parts = raw_date.to_s.split('/').map(&:to_i)
date = Time.new(*parts)
options = raw_options.map do |o|
o = o.gsub('-', '').to_sym
unless Worker::OPTIONS.include?(o)
tell(:wrong_option, o: o)
error(:usage)
end
o
end
Worker.process(date, options)
end
|
#tell(key, options = {}) ⇒ Object
38
39
40
41
42
43
|
# File 'lib/squasher.rb', line 38
def tell(key, options = {})
message = messages.fetch(key.to_s)
message = message.join("\n") if message.is_a?(Array)
message = colorize(message)
puts message % options
end
|