Class: Fitting::Report::Prefix

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

Constant Summary collapse

KEYS =
{
  'openapi2' => :openapi2_json_path,
  'openapi3' => :openapi3_yaml_path,
  'drafter' => :drafter_yaml_path,
  'crafter' => :crafter_yaml_path,
  'tomogram' => :tomogram_json_path
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(schema_paths: nil, type: nil, name: '', skip: false, only: []) ⇒ Prefix

Returns a new instance of Prefix.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fitting/report/prefix.rb', line 16

def initialize(schema_paths: nil, type: nil, name: '', skip: false, only: [])
  @name = name
  @tests = Fitting::Report::Tests.new([])
  @skip = skip
  return if skip

  @actions = Fitting::Report::Actions.new([])

  schema_paths.each do |path|
    tomogram = Tomograph::Tomogram.new(prefix: name, KEYS[type] => path)

    tomogram.to_a.filter! { |action| only.include?("#{action.method} #{action.path}") } if only.present?

    @actions.push(Fitting::Report::Actions.new(tomogram))
  end
end

Instance Attribute Details

#actionsObject (readonly)

Returns the value of attribute actions.



14
15
16
# File 'lib/fitting/report/prefix.rb', line 14

def actions
  @actions
end

#nameObject (readonly)

Returns the value of attribute name.



14
15
16
# File 'lib/fitting/report/prefix.rb', line 14

def name
  @name
end

#testsObject (readonly)

Returns the value of attribute tests.



14
15
16
# File 'lib/fitting/report/prefix.rb', line 14

def tests
  @tests
end

Instance Method Details

#add_test(test) ⇒ Object



53
54
55
# File 'lib/fitting/report/prefix.rb', line 53

def add_test(test)
  @tests.push(test)
end

#detailsObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/fitting/report/prefix.rb', line 37

def details
  if @skip
    {
      name: @name,
      tests_size: @tests.size,
      actions: { tests_without_actions: [], actions_details: [] }
    }
  else
    {
      name: @name,
      tests_size: @tests.size,
      actions: @actions.details(self)
    }
  end
end

#skip?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/fitting/report/prefix.rb', line 33

def skip?
  @skip
end