Class: Autocuke::Runtime
- Inherits:
-
Object
- Object
- Autocuke::Runtime
- Defined in:
- lib/autocuke/runtime.rb
Instance Attribute Summary collapse
-
#current_file ⇒ Object
Returns the value of attribute current_file.
-
#files ⇒ Object
Returns the value of attribute files.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
-
#handler ⇒ Object
Overwrite for custom handlers.
-
#initialize(options) ⇒ Runtime
constructor
A new instance of Runtime.
-
#log ⇒ Object
Logs the root and file list.
-
#run! ⇒ Object
Starts the EM reactor and watches each of the runtime’s files Raises an Autocuke::NoFileError if the list of files is empty.
-
#stop! ⇒ Object
Stops the EM reactor.
-
#watch(file) ⇒ Object
Adds a file to EM’s file watch list.
-
#watch_feature_files ⇒ Object
Adds each of the runtime’s files to EM’s file watch list.
Constructor Details
#initialize(options) ⇒ Runtime
Returns a new instance of Runtime.
10 11 12 13 14 |
# File 'lib/autocuke/runtime.rb', line 10 def initialize() @options = @root = .root @files ||= Dir[File.join(.root, "**/*.feature")] end |
Instance Attribute Details
#current_file ⇒ Object
Returns the value of attribute current_file.
8 9 10 |
# File 'lib/autocuke/runtime.rb', line 8 def current_file @current_file end |
#files ⇒ Object
Returns the value of attribute files.
8 9 10 |
# File 'lib/autocuke/runtime.rb', line 8 def files @files end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/autocuke/runtime.rb', line 7 def @options end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
7 8 9 |
# File 'lib/autocuke/runtime.rb', line 7 def root @root end |
Instance Method Details
#handler ⇒ Object
Overwrite for custom handlers
60 61 62 |
# File 'lib/autocuke/runtime.rb', line 60 def handler Autocuke::Handler end |
#log ⇒ Object
Logs the root and file list
37 38 39 40 41 42 43 44 45 |
# File 'lib/autocuke/runtime.rb', line 37 def log puts "Root Set To:" puts root puts puts "Watching files:" puts "-" * 88 puts files puts end |
#run! ⇒ Object
Starts the EM reactor and watches each of the runtime’s files Raises an Autocuke::NoFileError if the list of files is empty
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/autocuke/runtime.rb', line 18 def run! raise Autocuke::NoFileError.new("No files given to watch!") if files.empty? log if .verbose # file watching requires kqueue on OSX EM.kqueue = true if EM.kqueue? EM.run { watch_feature_files puts "autocuke is up and running!" trap "SIGINT", proc{ puts "\nbye-bye!" exit } } end |
#stop! ⇒ Object
Stops the EM reactor
65 66 67 |
# File 'lib/autocuke/runtime.rb', line 65 def stop! EM.stop end |
#watch(file) ⇒ Object
Adds a file to EM’s file watch list
55 56 57 |
# File 'lib/autocuke/runtime.rb', line 55 def watch(file) EM.watch_file(File.(file), handler) end |
#watch_feature_files ⇒ Object
Adds each of the runtime’s files to EM’s file watch list
48 49 50 51 52 |
# File 'lib/autocuke/runtime.rb', line 48 def watch_feature_files files.each do |file| watch(file) end end |