Module: Hiptest::RenderContextMaker

Included in:
Renderer
Defined in:
lib/hiptest-publisher/render_context_maker.rb

Instance Method Summary collapse

Instance Method Details

#walk_actionword(aw) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/hiptest-publisher/render_context_maker.rb', line 25

def walk_actionword(aw)
  walk_item(aw).merge(
    chunks: aw.chunks || [],
    extra_inlined_parameters: aw.extra_inlined_parameters || [],
    has_free_text_parameter?: aw.children[:parameters].select(&:free_text?).count > 0,
    has_datatable_parameter?: aw.children[:parameters].select(&:datatable?).count > 0,
    uniq_name: aw.uniq_name,
    has_library?: (aw.parent.is_a? Hiptest::Nodes::Library) ? true : false,
    library_name: aw.parent.nil? ? '' : aw.parent.children[:name]
  )
end

#walk_actionwords(aws) ⇒ Object



37
38
39
40
41
42
# File 'lib/hiptest-publisher/render_context_maker.rb', line 37

def walk_actionwords(aws)
  project = aws.parent
  {
    uses_library?: project.nil? ? false : project.has_libraries?
  }
end

#walk_call(c) ⇒ Object



100
101
102
103
104
105
106
107
108
109
# File 'lib/hiptest-publisher/render_context_maker.rb', line 100

def walk_call(c)
  {
    has_arguments?: !c.children[:arguments].empty?,
    has_annotation?: !c.children[:annotation].nil?,
    in_actionword?: c.parent.is_a?(Hiptest::Nodes::Actionword),
    in_datatabled_scenario?: c.parent.is_a?(Hiptest::Nodes::Scenario) && has_datasets?(c.parent),
    chunks: c.chunks || [],
    extra_inlined_arguments: c.extra_inlined_arguments || []
  }
end

#walk_dataset(dataset) ⇒ Object



63
64
65
66
67
68
# File 'lib/hiptest-publisher/render_context_maker.rb', line 63

def walk_dataset(dataset)
  datatable = dataset.parent
  {
    scenario_name: datatable.parent.children[:name]
  }
end

#walk_folder(folder) ⇒ Object



44
45
46
47
48
49
50
51
52
# File 'lib/hiptest-publisher/render_context_maker.rb', line 44

def walk_folder(folder)
  walk_relative_item(folder).merge(
    self_name: folder.children[:name],
    has_tags?: !folder.children[:tags].empty?,
    has_step?: has_step?(folder),
    is_empty?: folder.children[:body].empty?,
    datatables_present?: datatable_present?(folder)
  )
end

#walk_ifthen(it) ⇒ Object



120
121
122
123
124
# File 'lib/hiptest-publisher/render_context_maker.rb', line 120

def walk_ifthen(it)
  {
    has_else?: !it.children[:else].empty?
  }
end

#walk_item(item) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/hiptest-publisher/render_context_maker.rb', line 3

def walk_item(item)
  {
    has_description?: !item.children[:description].nil? && !item.children[:description].empty?,
    has_parameters?: !item.children[:parameters].empty?,
    has_tags?: !item.children[:tags].empty?,
    has_step?: has_step?(item),
    is_empty?: item.children[:body].empty?,
    declared_variables: item.declared_variables_names,
    raw_parameter_names: item.children[:parameters].map {|p| p.children[:name] },
    self_name: item.children[:name]
  }
end

#walk_libraries(libraries) ⇒ Object



156
157
158
159
160
# File 'lib/hiptest-publisher/render_context_maker.rb', line 156

def walk_libraries(libraries)
  {
    library_names: libraries.children[:libraries].map {|lib| lib.children[:name]}
  }
end

#walk_parameter(p) ⇒ Object



126
127
128
129
130
131
132
133
# File 'lib/hiptest-publisher/render_context_maker.rb', line 126

def walk_parameter(p)
  {
    is_free_text?: p.free_text?,
    is_datatable?: p.datatable?,
    is_bool?: p.children[:type] == :bool,
    has_default_value?: !p.children[:default].nil?
  }
end

#walk_relative_item(item) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/hiptest-publisher/render_context_maker.rb', line 16

def walk_relative_item(item)
  relative_package = @context.relative_path.split('/')[0...-1].join('.')
  relative_package = ".#{relative_package}" unless relative_package.empty?
  {
    needs_to_import_actionwords?: @context.relative_path.count('/') > 0,
    relative_package: relative_package,
  }
end

#walk_scenario(scenario) ⇒ Object



54
55
56
57
58
59
60
61
# File 'lib/hiptest-publisher/render_context_maker.rb', line 54

def walk_scenario(scenario)
  walk_item(scenario).merge(walk_relative_item(scenario)).merge(
    project_name: scenario.parent.parent.children[:name],
    has_datasets?: has_datasets?(scenario),
    has_annotations?: has_annotations?(scenario),
    uniq_name: scenario.children[:name]
  )
end

#walk_scenarios(scenarios) ⇒ Object



70
71
72
73
74
75
76
77
# File 'lib/hiptest-publisher/render_context_maker.rb', line 70

def walk_scenarios(scenarios)
  project = scenarios.parent
  {
    project_name: project.children[:name],
    self_name: project.children[:name],
    datatables_present?: datatable_present?(scenarios)
  }
end

#walk_tag(t) ⇒ Object



135
136
137
138
139
# File 'lib/hiptest-publisher/render_context_maker.rb', line 135

def walk_tag(t)
  {
    has_value?: !t.children[:value].nil?
  }
end

#walk_template(t) ⇒ Object



141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/hiptest-publisher/render_context_maker.rb', line 141

def walk_template(t)
  treated = t.children[:chunks].map do |chunk|
    {
      is_variable?: chunk.is_a?(Hiptest::Nodes::Variable),
      raw: chunk
    }
  end
  variable_names = treated.map {|item| item[:raw].children[:name] if item[:is_variable?]}.compact

  {
    treated_chunks: treated,
    variable_names: variable_names
  }
end

#walk_test(test) ⇒ Object



79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/hiptest-publisher/render_context_maker.rb', line 79

def walk_test(test)
  {
    has_description?: !test.children[:description].nil? && !test.children[:description].empty?,
    has_parameters?: false,
    has_tags?: !test.children[:tags].empty?,
    has_step?: has_step?(test),
    is_empty?: test.children[:body].empty?,
    has_datasets?: false,
    project_name: test.parent.parent.children[:name],
    self_name: test.children[:name]
  }
end

#walk_tests(tests) ⇒ Object



92
93
94
95
96
97
98
# File 'lib/hiptest-publisher/render_context_maker.rb', line 92

def walk_tests(tests)
  project = tests.parent
  {
    project_name: project.children[:name],
    self_name: project.children[:name]
  }
end

#walk_uidcall(uidcall) ⇒ Object



111
112
113
114
115
116
117
118
# File 'lib/hiptest-publisher/render_context_maker.rb', line 111

def walk_uidcall(uidcall)
  {
    has_library?: !uidcall.children[:library_name].nil?,
    has_annotation?: !uidcall.children[:annotation].nil?,
    in_actionword?: uidcall.parent.is_a?(Hiptest::Nodes::Actionword),
    chunks: uidcall.chunks || []
  }
end