Class: Guard::Konacha::Runner
- Inherits:
-
Object
- Object
- Guard::Konacha::Runner
- Defined in:
- lib/guard/konacha/runner.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ :run_all_on_start => true, :notification => true, :rails_environment_file => './config/environment' }
Instance Attribute Summary collapse
-
#formatter ⇒ Object
readonly
Returns the value of attribute formatter.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Runner
constructor
A new instance of Runner.
- #run(paths = ['']) ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Runner
Returns a new instance of Runner.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/guard/konacha/runner.rb', line 13 def initialize(={}) @options = DEFAULT_OPTIONS.merge() # Require project's rails environment file to load Konacha # configuration require_rails_environment raise "Konacha not loaded" unless defined? ::Konacha # Custom formatter to handle multiple runs @formatter = Formatter.new ::Konacha.config.formatters = [@formatter] # Reusable session to increase performance @session = Capybara::Session.new(::Konacha.driver, Server.new) ::Konacha.mode = :runner UI.info "Guard::Konacha Initialized" end |
Instance Attribute Details
#formatter ⇒ Object (readonly)
Returns the value of attribute formatter.
11 12 13 |
# File 'lib/guard/konacha/runner.rb', line 11 def formatter @formatter end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
11 12 13 |
# File 'lib/guard/konacha/runner.rb', line 11 def @options end |
Instance Method Details
#run(paths = ['']) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/guard/konacha/runner.rb', line 37 def run(paths = ['']) formatter.reset paths.each do |path| if path.empty? or File.exists? real_path path runner.run konacha_path(path) end end formatter.write_summary notify rescue => e UI.error(e) end |
#start ⇒ Object
33 34 35 |
# File 'lib/guard/konacha/runner.rb', line 33 def start run if [:run_all_on_start] end |