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,
lib/squasher/version.rb
Defined Under Namespace
Classes: Cleaner, Config, Render, Worker
Constant Summary
collapse
- VERSION =
"0.8.0"
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
10
11
12
|
# File 'lib/squasher.rb', line 10
def config
@config
end
|
Instance Method Details
#ask(*args) ⇒ Object
36
37
38
39
|
# File 'lib/squasher.rb', line 36
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
52
53
54
55
|
# File 'lib/squasher.rb', line 52
def error(*args)
tell(*args)
abort
end
|
#print(message, options = {}) ⇒ Object
48
49
50
|
# File 'lib/squasher.rb', line 48
def print(message, options = {})
puts options.empty? ? message : message % options
end
|
#rake(command, description = nil) ⇒ Object
28
29
30
31
32
33
34
|
# File 'lib/squasher.rb', line 28
def rake(command, description = nil)
tell(description) if description
config.in_app_root do
env = { 'RAILS_ENV' => 'development', 'DISABLE_DATABASE_ENVIRONMENT_CHECK' => '1' }
system(env, "bundle exec rake #{ command }")
end
end
|
#setup(options) ⇒ Object
14
15
16
|
# File 'lib/squasher.rb', line 14
def setup(options)
options.each { |(k, v)| config.set(k, v) }
end
|
#squash(raw_date) ⇒ Object
18
19
20
21
22
|
# File 'lib/squasher.rb', line 18
def squash(raw_date)
parts = raw_date.to_s.split('/').map(&:to_i)
date = Time.new(*parts)
Worker.process(date)
end
|
#tell(key, options = {}) ⇒ Object
41
42
43
44
45
46
|
# File 'lib/squasher.rb', line 41
def tell(key, options = {})
message = messages.fetch(key.to_s)
message = message.join("\n") if message.is_a?(Array)
message = colorize(message)
print(message, options)
end
|