Module: Fasten::Support::State

Included in:
Runner, Task, Worker
Defined in:
lib/fasten/support/state.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#difObject

Returns the value of attribute dif.



6
7
8
# File 'lib/fasten/support/state.rb', line 6

def dif
  @dif
end

#errorObject

Returns the value of attribute error.



6
7
8
# File 'lib/fasten/support/state.rb', line 6

def error
  @error
end

#finObject

Returns the value of attribute fin.



6
7
8
# File 'lib/fasten/support/state.rb', line 6

def fin
  @fin
end

#iniObject

Returns the value of attribute ini.



6
7
8
# File 'lib/fasten/support/state.rb', line 6

def ini
  @ini
end

#runnerObject

Returns the value of attribute runner.



6
7
8
# File 'lib/fasten/support/state.rb', line 6

def runner
  @runner
end

#stateObject



9
10
11
# File 'lib/fasten/support/state.rb', line 9

def state
  @state || :IDLE
end

Instance Method Details

#depsObject



49
50
51
52
53
54
55
# File 'lib/fasten/support/state.rb', line 49

def deps
  return @deps if defined? @deps

  str = deps_str

  @deps = str && Digest::SHA1.hexdigest(str)
end

#deps_strObject



57
58
59
60
61
62
63
# File 'lib/fasten/support/state.rb', line 57

def deps_str
  if is_a? Fasten::Task
    deps_str_task
  elsif is_a? Fasten::Runner
    deps_str_runner
  end
end

#deps_str_runnerObject



75
76
77
78
79
# File 'lib/fasten/support/state.rb', line 75

def deps_str_runner
  tasks.sort_by(&:name).map do |task|
    [task.name, task.deps_str].compact.join(': ')
  end.join("\n")
end

#deps_str_taskObject



65
66
67
68
69
70
71
72
73
# File 'lib/fasten/support/state.rb', line 65

def deps_str_task
  if after.is_a? Array
    after.sort_by do |task|
      task.is_a?(Fasten::Task) ? task.name : task
    end&.join(', ')
  else
    after
  end
end

#idle?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/fasten/support/state.rb', line 17

def idle?
  state == :IDLE
end

#last_avgObject



41
42
43
# File 'lib/fasten/support/state.rb', line 41

def last_avg
  @last_avg ||= last_stat['avg']
end

#last_errObject



45
46
47
# File 'lib/fasten/support/state.rb', line 45

def last_err
  @last_err ||= last_stat['err']
end

#last_statObject



33
34
35
36
37
38
39
# File 'lib/fasten/support/state.rb', line 33

def last_stat
  return @last_stat if defined? @last_stat

  return {} unless @runner

  @last_stat = runner.stats_last(self)
end

#paused?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/fasten/support/state.rb', line 25

def paused?
  state == :PAUSED
end

#pausing?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/fasten/support/state.rb', line 21

def pausing?
  state == :PAUSING
end

#quitting?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/fasten/support/state.rb', line 29

def quitting?
  state == :QUITTING
end

#running?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/fasten/support/state.rb', line 13

def running?
  state == :RUNNING
end