Class: Swat::UI::RspecSetup::StatsCollector

Inherits:
Object
  • Object
show all
Defined in:
lib/swat/ui/stats_collector.rb

Defined Under Namespace

Classes: Stub

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStatsCollector

Returns a new instance of StatsCollector.



7
8
9
10
11
12
13
14
15
# File 'lib/swat/ui/stats_collector.rb', line 7

def initialize
  @revision = Revision.add(
      current_namespace.merge(threads_count: current_threads_count, name: current_revision_name)
  )
  @logger = TarvitHelpers::ConditionalLogger.new do
    !!ENV['SWAT_DEBUG']
  end
  @logger.puts 'Results Transferring in ON.'
end

Class Method Details

.createObject



17
18
19
20
21
22
23
# File 'lib/swat/ui/stats_collector.rb', line 17

def self.create
  if collection_available?
    new
  else
    Stub.new
  end
end

Instance Method Details

#collect_case(notification) ⇒ Object



25
26
27
28
29
# File 'lib/swat/ui/stats_collector.rb', line 25

def collect_case(notification)
  @logger.print "test '#{notification.location}' #{ notification.[:execution_result].status } -->.."
  TestCase.collect(current_namespace, notification, thread_id: current_thread_id, time: @revision.time)
  @logger.print "..!"
end

#collect_ended_thread(notification) ⇒ Object



40
41
42
43
44
45
46
47
# File 'lib/swat/ui/stats_collector.rb', line 40

def collect_ended_thread(notification)
  @logger.print "thread ended -->.."
  @revision.collect_ended_thread(notification,
    thread_id: current_thread_id,
    thread_name: current_thread_name,
  )
  @logger.print "..!"
end

#collect_started_thread(notification) ⇒ Object



31
32
33
34
35
36
37
38
# File 'lib/swat/ui/stats_collector.rb', line 31

def collect_started_thread(notification)
  @logger.print "thread started -->.."
  @revision.collect_started_thread(notification,
       thread_id: current_thread_id,
       thread_name: current_thread_name
  )
  @logger.print "..!"
end

#collection_available?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/swat/ui/stats_collector.rb', line 59

def collection_available?
  self.class.collection_available?
end

#current_namespaceObject



49
50
51
52
53
54
55
56
57
# File 'lib/swat/ui/stats_collector.rb', line 49

def current_namespace
  {
      branch: current_branch,
      user: user,
      time: current_revision_time,
      name: name,
      threads_count: current_threads_count,
  }
end