Module: Sidekick
- Defined in:
- lib/sidekick.rb
Defined Under Namespace
Modules: Helpers, Triggers
Constant Summary
collapse
- Context =
The .sidekick file is evaluated in the Sidekick::Context module, which exposes DSL style methods by extending Sidekick::Triggers and Sidekick::Helpers.
Module.new
Class Method Summary
collapse
Class Method Details
.ensure_config_exists(path) ⇒ Object
78
79
80
81
82
83
84
85
|
# File 'lib/sidekick.rb', line 78
def self.ensure_config_exists(path)
unless File.exists?(path)
puts 'Generate new sidekick file? (Y/n)'
gets =~ /^N|n/ ? exit :
FileUtils.cp(File.expand_path('../template',
__FILE__), path)
end
end
|
.run!(path = '.sidekick') ⇒ Object
Sidekick.run! reads and applies the .sidekick file, wrapping the setup phase inside ‘EM.run { .. }`, thus starting the event loop.
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/sidekick.rb', line 67
def self.run!(path='.sidekick')
ensure_config_exists(path)
Signal.trap(:INT) { stop }
EventMachine.run do
Context.module_eval(
open(path) {|f| f.read }, path )
end
end
|
.stop(msg = nil) ⇒ Object
87
88
89
90
|
# File 'lib/sidekick.rb', line 87
def self.stop(msg=nil)
EventMachine.stop
puts "\n#{msg}" if msg
end
|