Module: SpecWatchr::Control
- Included in:
- SpecWatchr
- Defined in:
- lib/rspec-rails-watchr.rb
Instance Method Summary collapse
- #abort_watchr! ⇒ Object
- #exit_watchr ⇒ Object
- #reload! ⇒ Object
- #reload_file_list ⇒ Object
- #trap_int! ⇒ Object
Instance Method Details
#abort_watchr! ⇒ Object
82 83 84 85 |
# File 'lib/rspec-rails-watchr.rb', line 82 def abort_watchr! puts '--- Forcing abort...'.white abort("\n") end |
#exit_watchr ⇒ Object
76 77 78 79 80 |
# File 'lib/rspec-rails-watchr.rb', line 76 def exit_watchr @exiting = true puts '--- Exiting...'.white exit end |
#reload! ⇒ Object
87 88 89 90 |
# File 'lib/rspec-rails-watchr.rb', line 87 def reload! # puts ARGV.join(' ') exec('bundle exec watchr') end |
#reload_file_list ⇒ Object
92 93 94 95 96 |
# File 'lib/rspec-rails-watchr.rb', line 92 def reload_file_list require 'shellwords' system "touch #{__FILE__.shellescape}" # puts '--- Watch\'d file list reloaded.'.green end |
#trap_int! ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/rspec-rails-watchr.rb', line 98 def trap_int! # Ctrl-C @interrupted ||= false Signal.trap('INT') { puts ' (Interrupted with CTRL+C)'.red if @interrupted @exiting ? abort_watchr : exit_watchr else @interrupted = true # reload_file_list print '--- What to do now? (q=quit, a=all-specs, r=reload): '.yellow case STDIN.gets.chomp.strip.downcase when 'q'; @interrupted = false; exit_watchr when 'a'; @interrupted = false; rspec_all when 'r'; @interrupted = false; reload! else @interrupted = false puts '--- Bad input, ignored.'.yellow end puts '--- Waiting for changes...'.cyan end } end |