Class: Bolt::Listener

Inherits:
Object
  • Object
show all
Defined in:
lib/bolt/listener.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeListener

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

#notifierObject

Returns the value of attribute notifier.



10
11
12
# File 'lib/bolt/listener.rb', line 10

def notifier
  @notifier
end

#runnerObject

Returns the value of attribute runner.



10
11
12
# File 'lib/bolt/listener.rb', line 10

def runner
  @runner
end

#selectedObject

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

#listenerObject

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

#osObject



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