Class: Specjour::Loader

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

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

#initialize(options = {}) ⇒ Loader

Returns a new instance of Loader.



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

#printer_uriObject (readonly)

Returns the value of attribute printer_uri.



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

def printer_uri
  @printer_uri
end

#project_pathObject (readonly)

Returns the value of attribute project_path.



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

def project_path
  @project_path
end

#quietObject (readonly)

Returns the value of attribute quiet.



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

def quiet
  @quiet
end

#taskObject (readonly)

Returns the value of attribute task.



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

def task
  @task
end

#test_pathsObject (readonly)

Returns the value of attribute test_paths.



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

def test_paths
  @test_paths
end

#worker_pidsObject (readonly)

Returns the value of attribute worker_pids.



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

def worker_pids
  @worker_pids
end

#worker_sizeObject (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

#feature_filesObject



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["features/**/*.feature"]
    else
      Dir["**/*.feature"]
    end
  end
end

#spec_filesObject



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["spec/**/*_spec.rb"]
    else
      Dir["**/*_spec.rb"]
    end
  end
end

#startObject



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