specjour 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.5
1
+ 0.1.6
data/bin/specjour CHANGED
@@ -15,6 +15,10 @@ optparse = OptionParser.new do |opts|
15
15
  options[:batch_size] = n
16
16
  end
17
17
 
18
+ opts.on('-d', '--dispatcher HOSTNAME', "Only run specs from the dispatcher running on this host, i.e. farnsworth.local") do |name|
19
+ options[:registered_dispatcher] = name
20
+ end
21
+
18
22
  opts.on('--do-work OPTIONS', Array, 'INTERNAL USE ONLY') do |args|
19
23
  specs_to_run = args[3..-1]
20
24
  options[:worker_args] = args[0], args[1], args[2], specs_to_run
@@ -37,5 +41,5 @@ if options[:worker_args]
37
41
  options[:worker_args] << options[:batch_size]
38
42
  Specjour::Worker.new(*options[:worker_args]).run
39
43
  else
40
- Specjour::Manager.new(options[:worker_size], options[:batch_size]).start
44
+ Specjour::Manager.new(options).start
41
45
  end
@@ -60,7 +60,7 @@ module Specjour
60
60
 
61
61
  def fetch_manager(uri)
62
62
  manager = DRbObject.new_with_uri(uri.to_s)
63
- unless managers.include?(manager)
63
+ if !managers.include?(manager) && manager.available_for?(hostname)
64
64
  set_up_manager(manager, uri)
65
65
  managers << manager
66
66
  self.worker_size += manager.worker_size
@@ -78,9 +78,14 @@ module Specjour
78
78
  browser.stop unless reply.flags.more_coming?
79
79
  end
80
80
  puts "Managers found: #{managers.size}"
81
+ abort unless managers.size > 0
81
82
  printer.worker_size = worker_size
82
83
  end
83
84
 
85
+ def hostname
86
+ @hostname ||= Socket.gethostname
87
+ end
88
+
84
89
  def printer
85
90
  @printer ||= Printer.new.start
86
91
  end
@@ -107,7 +112,7 @@ module Specjour
107
112
 
108
113
  def set_up_manager(manager, uri)
109
114
  manager.project_name = project_name
110
- manager.dispatcher_uri = URI::Generic.build :scheme => "specjour", :host => printer.hostname, :port => printer.port
115
+ manager.dispatcher_uri = URI::Generic.build :scheme => "specjour", :host => hostname, :port => printer.port
111
116
  end
112
117
 
113
118
  def sync_managers
@@ -3,13 +3,19 @@ module Specjour
3
3
  require 'dnssd'
4
4
  include DRbUndumped
5
5
 
6
- attr_accessor :project_name, :specs_to_run, :dispatcher_uri, :worker_size, :bonjour_service, :batch_size
6
+ attr_accessor :project_name, :specs_to_run, :dispatcher_uri
7
+ attr_reader :worker_size, :batch_size, :registered_dispatcher, :bonjour_service
7
8
 
8
- def initialize(worker_size = 1, batch_size = 1)
9
- @worker_size = worker_size
10
- @batch_size = batch_size
9
+ def initialize(options = {})
10
+ @worker_size = options[:worker_size]
11
+ @batch_size = options[:batch_size]
12
+ @registered_dispatcher = options[:registered_dispatcher]
11
13
  end
12
14
 
15
+ def available_for?(hostname)
16
+ registered_dispatcher ? registered_dispatcher == hostname : true
17
+ end
18
+
13
19
  def bundle_install
14
20
  Dir.chdir(project_path) do
15
21
  unless system('bundle check > /dev/null')
@@ -28,10 +28,6 @@ module Specjour
28
28
  report.add(summary)
29
29
  end
30
30
 
31
- def hostname
32
- @hostname ||= Socket.gethostname
33
- end
34
-
35
31
  protected
36
32
 
37
33
  def disconnecting(client_port)
data/lib/specjour.rb CHANGED
@@ -18,5 +18,5 @@ module Specjour
18
18
  autoload :RsyncDaemon, 'specjour/rsync_daemon'
19
19
  autoload :Worker, 'specjour/worker'
20
20
 
21
- VERSION = "0.1.5".freeze
21
+ VERSION = "0.1.6".freeze
22
22
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 5
9
- version: 0.1.5
8
+ - 6
9
+ version: 0.1.6
10
10
  platform: ruby
11
11
  authors:
12
12
  - Sandro Turriate