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
# 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
  )
end

#walk_actionwords(aws) ⇒ Object



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

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
110
# 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?,
    is_shared?: !c.children[:library_name].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



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

def walk_dataset(dataset)
  datatable = dataset.parent
  {
    scenario_name: datatable.parent.children[:name],
    has_tags?: !datatable.parent.children[:tags].empty?,
    tags: datatable.parent.children[:tags].map {|tag| @rendered[tag]}
  }
end

#walk_folder(folder) ⇒ Object



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

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



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

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



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

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

#walk_libraryactionword(aw) ⇒ Object



148
149
150
151
152
# File 'lib/hiptest-publisher/render_context_maker.rb', line 148

def walk_libraryactionword(aw)
  walk_actionword(aw).merge(
    library_name: aw.parent.children[:name]
  )
end

#walk_parameter(p) ⇒ Object



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

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



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

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



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

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

#walk_template(t) ⇒ Object



133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/hiptest-publisher/render_context_maker.rb', line 133

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