Class: Specjour::Loader

Inherits:
Object
  • Object
show all
Includes:
Fork, Protocol
Defined in:
lib/specjour/loader.rb

Constant Summary

Constant Summary

Constants included from Protocol

Protocol::TERMINATOR, Protocol::TERMINATOR_REGEXP

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods included from Fork

#fork, #fork_quietly

Methods included from Protocol

#dump_object, #load_object

Constructor Details

- (Loader) initialize(options = {})



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/specjour/loader.rb', line 8

def initialize(options = {})
  @options = options
  @printer_uri = options[:printer_uri]
  @test_paths = options[:test_paths]
  @worker_size = options[:worker_size]
  @task = options[:task]
  @quiet = options[:quiet]
  @project_path = options[:project_path]
  @worker_pids = []
  Dir.chdir project_path
  Specjour.load_custom_hooks
end

Instance Attribute Details

- (Object) printer_uri (readonly)

Returns the value of attribute printer_uri



6
7
8
# File 'lib/specjour/loader.rb', line 6

def printer_uri
  @printer_uri
end

- (Object) project_path (readonly)

Returns the value of attribute project_path



6
7
8
# File 'lib/specjour/loader.rb', line 6

def project_path
  @project_path
end

- (Object) quiet (readonly)

Returns the value of attribute quiet



6
7
8
# File 'lib/specjour/loader.rb', line 6

def quiet
  @quiet
end

- (Object) task (readonly)

Returns the value of attribute task



6
7
8
# File 'lib/specjour/loader.rb', line 6

def task
  @task
end

- (Object) test_paths (readonly)

Returns the value of attribute test_paths



6
7
8
# File 'lib/specjour/loader.rb', line 6

def test_paths
  @test_paths
end

- (Object) worker_pids (readonly)

Returns the value of attribute worker_pids



6
7
8
# File 'lib/specjour/loader.rb', line 6

def worker_pids
  @worker_pids
end

- (Object) worker_size (readonly)

Returns the value of attribute worker_size



6
7
8
# File 'lib/specjour/loader.rb', line 6

def worker_size
  @worker_size
end

Instance Method Details

- (Object) feature_files



48
49
50
51
52
53
54
55
56
# File 'lib/specjour/loader.rb', line 48

def feature_files
  @feature_files ||= file_collector(feature_paths) do |path|
    if path == project_path
      Dir["#{path}/features/**/*.feature"]
    else
      Dir["#{path}/**/*.feature"]
    end
  end
end

- (Object) spec_files



38
39
40
41
42
43
44
45
46
# File 'lib/specjour/loader.rb', line 38

def spec_files
  @spec_files ||= file_collector(spec_paths) do |path|
    if path == project_path
      Dir["#{path}/spec/**/*_spec.rb"]
    else
      Dir["#{path}/**/*_spec.rb"]
    end
  end
end

- (Object) start



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/specjour/loader.rb', line 21

def start
  load_app
  Configuration.after_load.call
  (1..worker_size).each do |index|
    worker_pids << fork do
      Worker.new(
        :number => index,
        :printer_uri => printer_uri,
        :quiet => quiet
      ).send(task)
    end
  end
  Process.waitall
ensure
  kill_worker_processes
end