Module: SpecWatchr::Control
- Included in:
- SpecWatchr
- Defined in:
- lib/rspec-rails-watchr-emacs.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
221 222 223 224 |
# File 'lib/rspec-rails-watchr-emacs.rb', line 221 def abort_watchr! puts '--- Forcing abort...'.white abort("\n") end |
#exit_watchr ⇒ Object
215 216 217 218 219 |
# File 'lib/rspec-rails-watchr-emacs.rb', line 215 def exit_watchr @exiting = true puts '--- Exiting...'.white exit end |
#reload! ⇒ Object
226 227 228 229 |
# File 'lib/rspec-rails-watchr-emacs.rb', line 226 def reload! # puts ARGV.join(' ') exec('bundle exec watchr') end |
#reload_file_list ⇒ Object
231 232 233 234 235 |
# File 'lib/rspec-rails-watchr-emacs.rb', line 231 def reload_file_list require 'shellwords' system "touch #{__FILE__.shellescape}" # puts '--- Watch\'d file list reloaded.'.green end |
#trap_int! ⇒ Object
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 |
# File 'lib/rspec-rails-watchr-emacs.rb', line 237 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 |