Module: Specwrk

Defined in:
lib/specwrk.rb,
lib/specwrk/cli.rb,
lib/specwrk/ipc.rb,
lib/specwrk/web.rb,
lib/specwrk/client.rb,
lib/specwrk/worker.rb,
lib/specwrk/version.rb,
lib/specwrk/watcher.rb,
lib/specwrk/web/app.rb,
lib/specwrk/web/auth.rb,
lib/specwrk/seed_loop.rb,
lib/specwrk/store/base.rb,
lib/specwrk/web/logger.rb,
lib/specwrk/cli_reporter.rb,
lib/specwrk/list_examples.rb,
lib/specwrk/worker/executor.rb,
lib/specwrk/store/serializer.rb,
lib/specwrk/web/endpoints/pop.rb,
lib/specwrk/store/base_adapter.rb,
lib/specwrk/store/bucket_store.rb,
lib/specwrk/store/file_adapter.rb,
lib/specwrk/store/worker_store.rb,
lib/specwrk/web/endpoints/base.rb,
lib/specwrk/web/endpoints/seed.rb,
lib/specwrk/store/pending_store.rb,
lib/specwrk/store/memory_adapter.rb,
lib/specwrk/web/endpoints/health.rb,
lib/specwrk/web/endpoints/report.rb,
lib/specwrk/store/completed_store.rb,
lib/specwrk/web/endpoints/popable.rb,
lib/specwrk/worker/null_formatter.rb,
lib/specwrk/store/processing_store.rb,
lib/specwrk/web/endpoints/shutdown.rb,
lib/specwrk/web/endpoints/heartbeat.rb,
lib/specwrk/worker/progress_formatter.rb,
lib/specwrk/worker/completion_formatter.rb,
lib/specwrk/web/endpoints/complete_and_pop.rb

Defined Under Namespace

Modules: CLI Classes: BucketStore, CLIReporter, Client, CompletedStore, IPC, ListExamples, PendingStore, ProcessingStore, SeedLoop, Store, Watcher, Web, Worker, WorkerStore

Constant Summary collapse

Error =
Class.new(StandardError)
ClientError =

HTTP Client Errors

Class.new(Error)
UnhandledResponseError =
Class.new(ClientError)
WaitingForSeedError =
Class.new(ClientError)
NoMoreExamplesError =
Class.new(ClientError)
CompletedAllExamplesError =
Class.new(ClientError)
VERSION =
"0.19.3"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.force_quitObject

Returns the value of attribute force_quit.



19
20
21
# File 'lib/specwrk.rb', line 19

def force_quit
  @force_quit
end

.net_httpObject

Returns the value of attribute net_http.



19
20
21
# File 'lib/specwrk.rb', line 19

def net_http
  @net_http
end

.starting_pidObject (readonly)

Returns the value of attribute starting_pid.



20
21
22
# File 'lib/specwrk.rb', line 20

def starting_pid
  @starting_pid
end

Class Method Details

.human_readable_duration(total_seconds, precision: 2) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/specwrk.rb', line 42

def human_readable_duration(total_seconds, precision: 2)
  secs = total_seconds.to_f
  hours = (secs / 3600).to_i
  mins = ((secs % 3600) / 60).to_i
  seconds = secs % 60

  parts = []
  parts << "#{hours}h" if hours.positive?
  parts << "#{mins}m" if mins.positive?
  if seconds.positive?
    sec_str = format("%0.#{precision}f", seconds).sub(/\.?0+$/, "")
    parts << "#{sec_str}s"
  end
  parts.join(" ")
end

.wait_for_pids_exit(pids) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/specwrk.rb', line 22

def wait_for_pids_exit(pids)
  exited_pids = {}

  loop do
    pids.each do |pid|
      next if exited_pids.key? pid

      _, status = Process.waitpid2(pid, Process::WNOHANG)
      exited_pids[pid] = status.exitstatus if status&.exitstatus
    rescue Errno::ECHILD
      exited_pids[pid] = 1
    end

    break if exited_pids.keys.length == pids.length
    sleep 0.1
  end

  exited_pids
end