Class: Beg
- Inherits:
-
Object
- Object
- Beg
- Defined in:
- lib/beg.rb
Instance Attribute Summary collapse
-
#argv ⇒ Object
Returns the value of attribute argv.
Class Method Summary collapse
Instance Method Summary collapse
- #color(num, str) ⇒ Object
-
#initialize(argv = []) ⇒ Beg
constructor
A new instance of Beg.
- #run ⇒ Object
- #run_poor_man_style ⇒ Object
- #run_with_guardfile ⇒ Object
- #verbose_system(cmd) ⇒ Object
Constructor Details
#initialize(argv = []) ⇒ Beg
Returns a new instance of Beg.
8 |
# File 'lib/beg.rb', line 8 def initialize argv = []; @argv = argv end |
Instance Attribute Details
#argv ⇒ Object
Returns the value of attribute argv.
2 3 4 |
# File 'lib/beg.rb', line 2 def argv @argv end |
Class Method Details
Instance Method Details
#color(num, str) ⇒ Object
35 36 37 |
# File 'lib/beg.rb', line 35 def color num, str "\e[%dm%s\e[0m" % [num, str] end |
#run ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/beg.rb', line 10 def run if File.exists? 'Guardfile' run_with_guardfile else run_poor_man_style end end |
#run_poor_man_style ⇒ Object
22 23 24 25 26 27 |
# File 'lib/beg.rb', line 22 def run_poor_man_style loop do verbose_system ['inotifywait'] + Dir.glob('**/*.rb') verbose_system %w(bundle exec rake test) end end |
#run_with_guardfile ⇒ Object
18 19 20 |
# File 'lib/beg.rb', line 18 def run_with_guardfile verbose_system %w(bundle exec guard) + @argv end |
#verbose_system(cmd) ⇒ Object
29 30 31 32 33 |
# File 'lib/beg.rb', line 29 def verbose_system cmd str = color 36, cmd.join(' ') puts "Running: " + str system *cmd end |