class Spectator::ERunner

This is the class that implements the main loop of spectator-emacs. To run spectator-emacs, just create a new ERunner object.

Public Class Methods

new(options={}) { |self| ... } click to toggle source

Creates a new instance of ERunner. This implements the main loop of `spectator-emacs`. See the {file:README.md} for examples on how to customize the default behavior. @param [Hash] options possible options are:

##### :enotify_port (Fixnum)
the port the Enotify host is listening to.
##### :enotify_host`({String})
the host name or IP address where Enotify is running.
##### :notification_messages ({Hash})
a hash with keys `:success, :failure, :pending` containing the
relative modeline *icons* strings.
Defaults to `{:success => "S", :failure => "F", :pending => "P"}`.
##### :notification_face ({Hash})
A hash table with keys `:success, :failure, :pending` containing
the faces to apply to the notification *icon* in the Emacs modeline.
Values must be {Symbol}s, like for example `:font_lock_constant_face`
in order to use Emacs' `font-lock-warning-face`.
##### :report_buffer_mode ({String})
The major mode to use for the report buffer on emacs.
It must be specified in the same way as an emacs magic comment, i.e.
without the trailing "-mode".
For example, if you are using RspecOrgFormatter, and you want to use
org-mode to display the report, specify `"org"`.
Defaults to

   ```
   {:success => :\':success\', :failure => :\':failure\', :pending => :\':warning\'}
   ```

@yield [ERunner] Gives a reference of the ERunner object just created to the block

Use this block when you need to customize the behavior of spectator-emacs.
For example, if you need a custom summary extraction method, you can create
the runner object as follows in your `.spectator-emacs` script:

```ruby
@runner = ERunner.new do |runner|
  def runner.extract_rspec_summary(output)
    ## your summary extraction code here
    ## ...
  end
end
```
Calls superclass method
# File lib/spectator/emacs.rb, line 447
def initialize(options={}, &block)
  @default_options = {
    :enotify_port => 5000,
    :enotify_host => 'localhost',
    :notification_messages => {:failure => "F", :success => "S", :pending => "P", :error => "E"},
    :notification_face => {
      :failure => :failure.keyword,
      :success => :success.keyword,
      :pending => :warning.keyword,
      :error   => :error
    }
  }
  options = @default_options.merge options
  @cli_args = ARGV.to_a
  puts "======= OPTIONS ======="
  options.each {|k, v| puts "#{k} => #{v}"}
  @enotify_host = options[:enotify_host]
  @report_buffer_mode = options[:report_buffer_mode]
  @enotify_port = options[:enotify_port]
  @notification_messages = options[:notification_messages]
  @notification_face = options[:notification_face]
  @enotify_slot_id = options[:slot_id] ||
    ((File.basename Dir.pwd).split('_').map {|s| s.capitalize}).join.gsub('-','/')
  check_if_bundle_needed
  enotify_connect
  yield self  if block_given?
  # TODO: load .spectator-emacs
  # contents = File::read('.spectator-emacs')
  # eval(contents)
  super()
end