Class: Bolt::Listener
- Inherits:
-
Object
- Object
- Bolt::Listener
- Defined in:
- lib/bolt/listener.rb
Instance Attribute Summary collapse
-
#notifier ⇒ Object
Returns the value of attribute notifier.
-
#runner ⇒ Object
Returns the value of attribute runner.
-
#selected ⇒ Object
Returns the value of attribute selected.
Instance Method Summary collapse
-
#handle(updated_files) ⇒ Object
handle updated files found by specific listener.
-
#initialize ⇒ Listener
constructor
Constructor TODO: move most of this code to Bolt.start.
-
#listener ⇒ Object
Pick a listener to launch.
- #os ⇒ Object
Constructor Details
#initialize ⇒ Listener
Constructor TODO: move most of this code to Bolt.start
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/bolt/listener.rb', line 14 def initialize # find appropriate listener listener $stdout.puts "** Using #{listener.class} " if Bolt.verbose? # attach a notifier self.notifier = Bolt::Notifier.new.selected # attach a mapper self.runner = Bolt::Runner.new.selected self.runner.notifier = self.notifier # attach the notifier to listener listener.notifier = self.notifier # attach runner mappings to listener to avoid searching in all files listener.mappings = self.runner.class::MAPPINGS # attach listener wrapper listener.parent = self end |
Instance Attribute Details
#notifier ⇒ Object
Returns the value of attribute notifier.
10 11 12 |
# File 'lib/bolt/listener.rb', line 10 def notifier @notifier end |
#runner ⇒ Object
Returns the value of attribute runner.
10 11 12 |
# File 'lib/bolt/listener.rb', line 10 def runner @runner end |
#selected ⇒ Object
Returns the value of attribute selected.
10 11 12 |
# File 'lib/bolt/listener.rb', line 10 def selected @selected end |
Instance Method Details
#handle(updated_files) ⇒ Object
handle updated files found by specific listener
39 40 41 42 43 44 45 |
# File 'lib/bolt/listener.rb', line 39 def handle(updated_files) # notifier.spotted(updated_files.first) # send them to mapper Runners.files = updated_files runner.handle(updated_files.first) # run appropriate tests in runner end |
#listener ⇒ Object
Pick a listener to launch
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/bolt/listener.rb', line 53 def listener return selected if selected if Bolt['listener'] and ['generic', 'osx'].include?(Bolt['listener']) self.selected= Bolt::Listeners::Generic.new if Bolt['listener'] == 'generic' self.selected= Bolt::Listeners::Osx.start if Bolt['listener'] == 'osx' $stdout.puts "** Found listener setting in .bolt" if Bolt.verbose? return self.selected end $stdout.puts "** Determining listener..." if Bolt.verbose? os_string = os self.selected= Bolt::Listeners::Generic.new self.selected= Bolt::Listeners::Osx.start if os_string.include?("darwin") # TODO: # self.selected= Bolt::Listeners::Windows.new if os_string.include?("mswin") # self.selected= Bolt::Listeners::Linux.new if os_string.include?("linux") selected end |
#os ⇒ Object
47 48 49 50 |
# File 'lib/bolt/listener.rb', line 47 def os # TODO: os identification via RUBY_PLATFORM is flawed as it will return 'java' in jruby. Look for a different solution os_string = RUBY_PLATFORM.downcase end |