hiptest-publisher 1.9.2 → 1.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1dd144d9f192a260569659d26360bf10a0c34992
4
- data.tar.gz: 30d6081b77bd1226a55eff65398ea20a48ceeafd
3
+ metadata.gz: 1056cc45510dac48067122241a68934a61085bda
4
+ data.tar.gz: 4f3138eeb3df795a6ac4dd5b45187657b35e80ee
5
5
  SHA512:
6
- metadata.gz: 4cf3971eea3f78f5ac5eee01e6c8faf6963e658374f84ab65f674e9f7aabaea9167b99b8e0b6506ee8e0e21929eaab054510d5c426dd8d5e3f2b11427e6828ce
7
- data.tar.gz: d77ea86b848d94276ecc5bc37313755a1206acca9464b02ae2a087ffba9f12f75e64a17a4d1e3c9c10489e53325c7c5a28a17d5343f9c32ee47e1fd1325b3b56
6
+ metadata.gz: ae34a4ca108dcd3c0bfabd34f6369ef1ff52766e2f60d8c9479dbcad15dba913881638f2b5408ccb3fffc1d4b3566c81e530ca2b222b625182a15c1b1db43e9d
7
+ data.tar.gz: 7df5447feb46498086727bdbc5cec26358b3da6fc3644f72cc52b2a10f1483f16e6ee8c5bf8f144755a099fb1b0b2bddb782fff8275976540b9414258a11525b
@@ -7,6 +7,7 @@ require 'hiptest-publisher/call_arguments_adder'
7
7
  require 'hiptest-publisher/cli_options_checker'
8
8
  require 'hiptest-publisher/client'
9
9
  require 'hiptest-publisher/datatable_fixer'
10
+ require 'hiptest-publisher/diff_displayer'
10
11
  require 'hiptest-publisher/formatters/reporter'
11
12
  require 'hiptest-publisher/gherkin_adder'
12
13
  require 'hiptest-publisher/handlebars_helper'
@@ -21,7 +22,6 @@ require 'hiptest-publisher/string'
21
22
  require 'hiptest-publisher/utils'
22
23
  require 'hiptest-publisher/xml_parser'
23
24
 
24
-
25
25
  module Hiptest
26
26
  class Publisher
27
27
  attr_reader :reporter
@@ -179,7 +179,7 @@ module Hiptest
179
179
  ) { Hiptest::SignatureExporter.export_actionwords(@project).to_yaml }
180
180
  end
181
181
 
182
- def show_actionwords_diff
182
+ def compute_actionwords_diff
183
183
  old = nil
184
184
  reporter.with_status_message "Loading previous definition" do
185
185
  old = YAML.load_file("#{@cli_options.output_directory}/actionwords_signature.yaml")
@@ -189,101 +189,14 @@ module Hiptest
189
189
 
190
190
  current = Hiptest::SignatureExporter.export_actionwords(@project, true)
191
191
  diff = Hiptest::SignatureDiffer.diff( old, current)
192
+ end
192
193
 
193
- if @cli_options.aw_deleted
194
- return if diff[:deleted].nil?
195
-
196
- diff[:deleted].map {|deleted|
197
- puts @language_config.name_action_word(deleted[:name])
198
- }
199
- return
200
- end
201
-
202
- if @cli_options.aw_created
203
- print_updated_aws(diff[:created])
204
- return
205
- end
206
-
207
- if @cli_options.aw_renamed
208
- return if diff[:renamed].nil?
209
-
210
- diff[:renamed].map {|renamed|
211
- puts "#{@language_config.name_action_word(renamed[:name])}\t#{@language_config.name_action_word(renamed[:new_name])}"
212
- }
213
- return
214
- end
215
-
216
- if @cli_options.aw_signature_changed
217
- print_updated_aws(diff[:signature_changed])
218
- return
219
- end
220
-
221
- if @cli_options.aw_definition_changed
222
- print_updated_aws(diff[:definition_changed])
223
- return
224
- end
225
-
226
- command_line = @cli_options.command_line_used(exclude: [:actionwords_diff])
227
-
228
- unless diff[:deleted].nil?
229
- puts "#{pluralize(diff[:deleted].length, "action word")} deleted,"
230
- puts "run '#{command_line} --show-actionwords-deleted' to list the #{pluralize_word(diff[:deleted].length, "name")} in the code"
231
- puts diff[:deleted].map {|d| "- #{d[:name]}"}.join("\n")
232
- puts ""
233
- end
234
-
235
- unless diff[:created].nil?
236
- puts "#{pluralize(diff[:created].length, "action word")} created,"
237
- puts "run '#{command_line} --show-actionwords-created' to get the #{pluralize_word(diff[:created].length, "definition")}"
238
-
239
- puts diff[:created].map {|c| "- #{c[:name]}"}.join("\n")
240
- puts ""
241
- end
242
-
243
- unless diff[:renamed].nil?
244
- puts "#{pluralize(diff[:renamed].length, "action word")} renamed,"
245
- puts "run '#{command_line} --show-actionwords-renamed' to get the new #{pluralize_word(diff[:renamed].length, "name")}"
246
- puts diff[:renamed].map {|r| "- #{r[:name]} => #{r[:new_name]}"}.join("\n")
247
- puts ""
248
- end
249
-
250
- unless diff[:signature_changed].nil?
251
- puts "#{pluralize(diff[:signature_changed].length, "action word")} which signature changed,"
252
- puts "run '#{command_line} --show-actionwords-signature-changed' to get the new #{pluralize_word(diff[:signature_changed].length, "signature")}"
253
- puts diff[:signature_changed].map {|c| "- #{c[:name]}"}.join("\n")
254
- puts ""
255
- end
256
-
257
- unless diff[:definition_changed].nil?
258
- puts "#{pluralize(diff[:definition_changed].length, "action word")} which definition changed:"
259
- puts "run '#{command_line} --show-actionwords-definition-changed' to get the new #{pluralize_word(diff[:definition_changed].length, "definition")}"
260
- puts diff[:definition_changed].map {|c| "- #{c[:name]}"}.join("\n")
261
- puts ""
262
- end
263
-
264
- if diff.empty?
265
- puts "No action words changed"
266
- puts ""
267
- end
194
+ def show_actionwords_diff
195
+ Hiptest::DiffDisplayer.new(compute_actionwords_diff, @cli_options, @language_config).display
268
196
  rescue Exception => err
269
197
  reporter.dump_error(err)
270
198
  end
271
199
 
272
- def print_updated_aws(actionwords)
273
- return if actionwords.nil?
274
-
275
- @language_config.language_group_configs.select { |language_group_config|
276
- language_group_config[:group_name] == "actionwords"
277
- }.each do |language_group_config|
278
- actionwords.each do |actionword|
279
- node_rendering_context = language_group_config.build_node_rendering_context(actionword[:node])
280
- puts actionword[:node].render(node_rendering_context)
281
- puts ""
282
- end
283
- end
284
- return
285
- end
286
-
287
200
  def analyze_project_data
288
201
  return if @project_data_analyzed
289
202
  reporter.with_status_message "Analyzing data" do
@@ -0,0 +1,177 @@
1
+ module Hiptest
2
+ class DiffDisplayer
3
+ def initialize(diff, cli_options, language_config)
4
+ @diff = diff
5
+ @cli_options = cli_options
6
+ @language_config = language_config
7
+ end
8
+
9
+ def display
10
+ return display_as_json if @cli_options.actionwords_diff_json
11
+ return display_deleted if @cli_options.aw_deleted
12
+ return display_created if @cli_options.aw_created
13
+ return display_renamed if @cli_options.aw_renamed
14
+ return display_signature_changed if @cli_options.aw_signature_changed
15
+ return display_definition_changed if @cli_options.aw_definition_changed
16
+
17
+ display_summary
18
+ end
19
+
20
+ def display_created
21
+ return display_skeletons(@diff[:created])
22
+ end
23
+
24
+ def display_renamed
25
+ return if @diff[:renamed].nil?
26
+
27
+ output(@diff[:renamed].map {|renamed|
28
+ "#{@language_config.name_action_word(renamed[:name])}\t#{@language_config.name_action_word(renamed[:new_name])}"
29
+ })
30
+ end
31
+
32
+ def display_signature_changed
33
+ display_skeletons(@diff[:signature_changed])
34
+ end
35
+
36
+ def display_definition_changed
37
+ display_skeletons(@diff[:definition_changed])
38
+ end
39
+
40
+ def display_deleted
41
+ return if @diff[:deleted].nil?
42
+
43
+ output(@diff[:deleted].map {|deleted|
44
+ @language_config.name_action_word(deleted[:name])
45
+ })
46
+ end
47
+
48
+ def display_as_json
49
+ output(JSON.pretty_generate(as_api))
50
+ end
51
+
52
+ def as_api
53
+ data = {}
54
+
55
+ data[:deleted] = @diff[:deleted].map {|aw|
56
+ {
57
+ name: aw[:name],
58
+ name_in_code: @language_config.name_action_word(aw[:name])
59
+ }
60
+ } unless @diff[:deleted].nil?
61
+
62
+ data[:created] = @diff[:created].map {|aw|
63
+ {
64
+ name: aw[:name],
65
+ skeleton: actionword_skeleton(aw)
66
+ }
67
+ } unless @diff[:created].nil?
68
+
69
+ data[:renamed] = @diff[:renamed].map {|aw|
70
+ {
71
+ name: aw[:name],
72
+ old_name: @language_config.name_action_word(aw[:name]),
73
+ new_name: @language_config.name_action_word(aw[:new_name])
74
+ }
75
+ } unless @diff[:renamed].nil?
76
+
77
+ data[:signature_changed] = @diff[:signature_changed].map {|aw|
78
+ {
79
+ name: aw[:name],
80
+ skeleton: actionword_skeleton(aw)
81
+ }
82
+ } unless @diff[:signature_changed].nil?
83
+
84
+
85
+ data[:definition_changed] = @diff[:definition_changed].map {|aw|
86
+ {
87
+ name: aw[:name],
88
+ skeleton: actionword_skeleton(aw)
89
+ }
90
+ } unless @diff[:definition_changed].nil?
91
+
92
+ return data
93
+ end
94
+
95
+ def display_summary
96
+ command_line = @cli_options.command_line_used(exclude: [:actionwords_diff])
97
+
98
+ unless @diff[:deleted].nil?
99
+ output([
100
+ "#{pluralize(@diff[:deleted].length, "action word")} deleted,",
101
+ "run '#{command_line} --show-actionwords-deleted' to list the #{pluralize_word(@diff[:deleted].length, "name")} in the code",
102
+ displayable_list(@diff[:deleted])
103
+ ])
104
+ end
105
+
106
+ unless @diff[:created].nil?
107
+ output([
108
+ "#{pluralize(@diff[:created].length, "action word")} created,",
109
+ "run '#{command_line} --show-actionwords-created' to get the #{pluralize_word(@diff[:created].length, "definition")}",
110
+ displayable_list(@diff[:created])
111
+ ])
112
+ end
113
+
114
+ unless @diff[:renamed].nil?
115
+ output([
116
+ "#{pluralize(@diff[:renamed].length, "action word")} renamed,",
117
+ "run '#{command_line} --show-actionwords-renamed' to get the new #{pluralize_word(@diff[:renamed].length, "name")}",
118
+ displayable_list(@diff[:renamed])
119
+ ])
120
+ end
121
+
122
+ unless @diff[:signature_changed].nil?
123
+ output([
124
+ "#{pluralize(@diff[:signature_changed].length, "action word")} which signature changed,",
125
+ "run '#{command_line} --show-actionwords-signature-changed' to get the new #{pluralize_word(@diff[:signature_changed].length, "signature")}",
126
+ displayable_list(@diff[:signature_changed])
127
+ ])
128
+ end
129
+
130
+ unless @diff[:definition_changed].nil?
131
+ output([
132
+ "#{pluralize(@diff[:definition_changed].length, "action word")} which definition changed:",
133
+ "run '#{command_line} --show-actionwords-definition-changed' to get the new #{pluralize_word(@diff[:definition_changed].length, "definition")}",
134
+ displayable_list(@diff[:definition_changed])
135
+ ])
136
+ end
137
+
138
+ if @diff.empty?
139
+ output("No action words changed")
140
+ end
141
+ end
142
+
143
+ private
144
+
145
+ def output(lines, add_empty_line: true)
146
+ lines = [lines] unless lines.is_a? Array
147
+
148
+ puts lines.join("\n")
149
+ puts "" if add_empty_line
150
+ end
151
+
152
+ def displayable_list(actionwords)
153
+ actionwords.map {|c| "- #{c[:name]}"}.join("\n")
154
+ end
155
+
156
+ def actionword_skeleton(actionword)
157
+ return if actionwords_group_config.nil?
158
+
159
+ node_rendering_context = actionwords_group_config.build_node_rendering_context(actionword[:node])
160
+ actionword[:node].render(node_rendering_context)
161
+ end
162
+
163
+ def display_skeletons(actionwords)
164
+ return if actionwords.nil?
165
+
166
+ actionwords.each do |actionword|
167
+ output(actionword_skeleton(actionword))
168
+ end
169
+ end
170
+
171
+ def actionwords_group_config
172
+ @actionwords_group_config ||= @language_config.language_group_configs.select { |language_group_config|
173
+ language_group_config[:group_name] == "actionwords"
174
+ }.first
175
+ end
176
+ end
177
+ end
@@ -7,6 +7,8 @@ require 'pathname'
7
7
  require 'hiptest-publisher/formatters/console_formatter'
8
8
  require 'hiptest-publisher/renderer_addons'
9
9
  require 'hiptest-publisher/utils'
10
+ require 'hiptest-publisher/handlebars_helper'
11
+
10
12
 
11
13
  class FileConfigParser
12
14
  FALSY_VALUE_PATTERN = /\A(false|no|0)\Z/i
@@ -90,11 +92,12 @@ class CliOptions < OpenStruct
90
92
  hash ||= {}
91
93
  hash[:language] ||= ""
92
94
  hash[:framework] ||= ""
95
+
93
96
  super(__cli_args: Set.new, __config_args: Set.new, **hash)
94
97
  end
95
98
 
96
99
  def actionwords_diff?
97
- actionwords_diff || aw_deleted || aw_created || aw_renamed || aw_signature_changed || aw_definition_changed
100
+ actionwords_diff || actionwords_diff_json || aw_deleted || aw_created || aw_renamed || aw_signature_changed || aw_definition_changed
98
101
  end
99
102
 
100
103
  def push?
@@ -218,6 +221,7 @@ class OptionsParser
218
221
  Option.new(nil, 'actionwords-only', false, nil, "(deprecated) alias for --only=actionwords", :actionwords_only),
219
222
  Option.new(nil, 'actionwords-signature', false, nil, "Export actionwords signature", :actionwords_signature),
220
223
  Option.new(nil, 'show-actionwords-diff', false, nil, "Show actionwords diff since last update (summary)", :actionwords_diff),
224
+ Option.new(nil, 'show-actionwords-diff-as-json', false, nil, "Show actionwords diff since last update (JSON output)", :actionwords_diff_json),
221
225
  Option.new(nil, 'show-actionwords-deleted', false, nil, "Output signature of deleted action words", :aw_deleted),
222
226
  Option.new(nil, 'show-actionwords-created', false, nil, "Output code for new action words", :aw_created),
223
227
  Option.new(nil, 'show-actionwords-renamed', false, nil, "Output signatures of renamed action words", :aw_renamed),
@@ -679,11 +683,15 @@ class LanguageConfigParser
679
683
  end
680
684
 
681
685
  def name_action_word(name)
682
- name.send(@config['actionwords']['naming_convention'])
686
+ name.send(get_key_from_group('actionwords', 'naming_convention'))
683
687
  end
684
688
 
685
689
  private
686
690
 
691
+ def get_key_from_group(group, key)
692
+ @config[group][key] || @config['_common'][key]
693
+ end
694
+
687
695
  def group_config(group_name)
688
696
  if @config[group_name]
689
697
  key_values = @config[group_name].map { |key, value| [key.to_sym, value] }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hiptest-publisher
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.2
4
+ version: 1.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiptest R&D
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-15 00:00:00.000000000 Z
11
+ date: 2017-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -252,6 +252,7 @@ files:
252
252
  - lib/hiptest-publisher/cli_options_checker.rb
253
253
  - lib/hiptest-publisher/client.rb
254
254
  - lib/hiptest-publisher/datatable_fixer.rb
255
+ - lib/hiptest-publisher/diff_displayer.rb
255
256
  - lib/hiptest-publisher/formatters/console_formatter.rb
256
257
  - lib/hiptest-publisher/formatters/reporter.rb
257
258
  - lib/hiptest-publisher/gherkin_adder.rb
@@ -626,7 +627,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
626
627
  version: '0'
627
628
  requirements: []
628
629
  rubyforge_project:
629
- rubygems_version: 2.5.1
630
+ rubygems_version: 2.6.10
630
631
  signing_key:
631
632
  specification_version: 4
632
633
  summary: Export your tests from Hiptest into executable tests.