Class: Fitting::Action

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

Defined Under Namespace

Classes: Empty, NotFound, Skip

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(action) ⇒ Action

Returns a new instance of Action.



18
19
20
# File 'lib/fitting/action.rb', line 18

def initialize(action)
  @action = action
end

Class Method Details

.allObject



26
27
28
# File 'lib/fitting/action.rb', line 26

def self.all
  []
end

.find!(actions, log) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/fitting/action.rb', line 30

def self.find!(actions, log)
  host = Fitting::Host.find!(log)
  host.cover!

  prefix = Fitting::Prefix.find(host: host, log: log)
  prefix.cover!

  new(prefix.actions.find!(log))
rescue Fitting::Report::Actions::Empty,
  Fitting::Host::Skip,
  Fitting::Prefix::Skip
  raise Skip
rescue Fitting::Report::Combinations::Empty,
  Fitting::Report::Combinations::NotFound
  raise Skip
rescue Fitting::Host::NotFound,
  Fitting::Prefix::NotFound,
  Fitting::Report::Actions::NotFound,
  Fitting::Report::Responses::NotFound => e
  raise NotFound.new(e.message, log)
end

.report(actions) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/fitting/action.rb', line 73

def self.report(actions)
  all = 0
  cover = 0

  # prefixes.to_a.map do |prefix|
  #   all += 1
  #   break unless prefix.cover?
  #   cover += 1
  #   prefix.actions.to_a.map do |action|
  #     all += 1
  #     break unless action.cover?
  #     cover += 1
  #     action.responses.to_a.map do |response|
  #       all += 1
  #       break unless action.cover?
  #       cover += 1
  #       response.combinations.to_a.map do |combination|
  #         all += 1
  #         break unless combination.cover?
  #         cover += 1
  #       end
  #     end
  #   end
  # end

  puts
  puts "Coverage #{(cover.to_f / all.to_f * 100).round(2)}%"
  exit 1 unless false

  exit 0
end

Instance Method Details

#actionObject



22
23
24
# File 'lib/fitting/action.rb', line 22

def action
  @action
end

#cover!(log) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/fitting/action.rb', line 52

def cover!(log)
  action.cover!

  response = action.responses.find!(log)
  response.cover!

  combination = response.combinations.find!(log)
  combination.cover!

  print "\e[32m.\e[0m"
rescue Fitting::Report::Actions::Empty,
  Fitting::Host::Skip,
  Fitting::Prefix::Skip
rescue Fitting::Report::Combinations::Empty,
  Fitting::Report::Combinations::NotFound
rescue Fitting::Host::NotFound,
  Fitting::Prefix::NotFound,
  Fitting::Report::Actions::NotFound,
  Fitting::Report::Responses::NotFound => e
end