Class: CheckList::Results

Inherits:
Object
  • Object
show all
Defined in:
lib/results.rb

Overview

Class to build the selection menu

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Results

Returns a new instance of Results.



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

def initialize(opts)
  @ref = nil
  @opts = opts
  @results_array = []
  @results = {}
  process_opts
end

Instance Attribute Details

#resultsObject (readonly)

Returns the value of attribute results.



15
16
17
# File 'lib/results.rb', line 15

def results
  @results
end

Instance Method Details

#process_optsObject



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/results.rb', line 25

def process_opts
    return @ref = @opts[:ref] unless @opts[:ref].nil?

    @ref = 'main'
    begin
        branch = CheckList::Helpers.system_cmd("git status | grep 'On branch'")
        @ref = branch.chomp.gsub(/On branch /, '')
    rescue StandardError
        CheckList::Helpers.log 'Error with branch, using default'
    end
    @ref
end

#process_resultsObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/results.rb', line 49

def process_results
  CheckList::Helpers.clear

  begin
      create_results_list
      create_tasks
      add_sub_tasks
      update_tasks
      CheckList::ResultsPublisher.new(@results)
      CheckList::DisplayResults.new(@results)
  rescue CheckList::Exceptions::InvalidListError => e
      CheckList::Helpers.log "Invalid List: #{e}"
      CheckList::Helpers.leave
  rescue StandardError => e
      CheckList::Helpers.log "Error: #{e}"
      CheckList::Helpers.leave
  end
end

#process_value(list, value, task, sub_task) ⇒ Object



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

def process_value(list, value, task, sub_task)
    result = {
      'list': list['name'],
      'task': task['name'],
      'subTask': sub_task['name'],
      'value': value,
      'timestamp': CheckList::Config.time_now
    }
    @results_array.push result
end