Module: Ensurable
- Defined in:
- lib/ensurable.rb,
lib/ensurable/now.rb,
lib/ensurables/git.rb,
lib/ensurables/redis.rb,
lib/ensurable/version.rb
Defined Under Namespace
Modules: Now Classes: Git, NotInstalled, NotRunning, Redis
Constant Summary collapse
- VERSION =
"0.0.2"
Class Method Summary collapse
-
.ensure(file = nil) { ... } ⇒ Object
Ensures that the given programs are installed/running.
-
.installed(prog) ⇒ Object
Ensures the the given program needs to be installed on the local system.
-
.running(prog) ⇒ Object
Ensures that the given program is running on the local system.
Class Method Details
.ensure(file = nil) { ... } ⇒ Object
Ensures that the given programs are installed/running.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ensurable.rb', line 14 def ensure(file = nil, &bloc) abortables = [] begin abortables << Rails.env rescue NameError, NoMethodError end abortables << ENV['RAILS_ENV'] abortables << ENV['RACK_ENV'] if abortables.any? {|a| a == 'production'} $stderr.puts("Ensurable gem is not meant for use in production, nooping.") return end if file instance_eval file.read else instance_eval &bloc end end |
.installed(prog) ⇒ Object
Ensures the the given program needs to be installed on the local system
41 42 43 44 45 46 |
# File 'lib/ensurable.rb', line 41 def installed(prog) # Would be nice to have a nicer fail mechanism if the constant doesn't exist klass = const_get(prog.capitalize) raise NotInstalled.new("Looks like you don't have #{prog} installed.") unless klass.new.installed? end |
.running(prog) ⇒ Object
Ensures that the given program is running on the local system
52 53 54 55 56 |
# File 'lib/ensurable.rb', line 52 def running(prog) klass = const_get(prog.capitalize) raise NotRunning.new("Looks like you don't have #{prog} running.") unless klass.new.running? end |