hiptest-publisher 1.10.0 → 1.10.1

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: 1056cc45510dac48067122241a68934a61085bda
4
- data.tar.gz: 4f3138eeb3df795a6ac4dd5b45187657b35e80ee
3
+ metadata.gz: 2a877b09d5680c92090947262c403126a97a83d8
4
+ data.tar.gz: cd24230a8f4c7222ab715fa7c39ad39c7043e728
5
5
  SHA512:
6
- metadata.gz: ae34a4ca108dcd3c0bfabd34f6369ef1ff52766e2f60d8c9479dbcad15dba913881638f2b5408ccb3fffc1d4b3566c81e530ca2b222b625182a15c1b1db43e9d
7
- data.tar.gz: 7df5447feb46498086727bdbc5cec26358b3da6fc3644f72cc52b2a10f1483f16e6ee8c5bf8f144755a099fb1b0b2bddb782fff8275976540b9414258a11525b
6
+ metadata.gz: d92b261bc905cd83133a3c5beb70a4d8a79a0af30b2bb6561b71a09370663cbd51bd0055095f689d480c7251acb26976c99afe4d9c593d75ac675d76e4d88faf
7
+ data.tar.gz: 9871151e896f7900e13f968495235b21d80cacb9a5d67a9f4ef0181738c48b60f4c54f930c428cbab9252f0136303b911ed45b8140634855d91722e27ec618eb
@@ -1,5 +1,4 @@
1
1
  require 'colorize'
2
- require 'fileutils'
3
2
  require 'json'
4
3
  require 'yaml'
5
4
 
@@ -9,6 +8,7 @@ require 'hiptest-publisher/client'
9
8
  require 'hiptest-publisher/datatable_fixer'
10
9
  require 'hiptest-publisher/diff_displayer'
11
10
  require 'hiptest-publisher/formatters/reporter'
11
+ require 'hiptest-publisher/file_writer'
12
12
  require 'hiptest-publisher/gherkin_adder'
13
13
  require 'hiptest-publisher/handlebars_helper'
14
14
  require 'hiptest-publisher/items_orderer'
@@ -30,6 +30,8 @@ module Hiptest
30
30
  @reporter = Reporter.new(listeners)
31
31
  @cli_options = OptionsParser.parse(args, reporter)
32
32
  @client = Hiptest::Client.new(@cli_options, reporter)
33
+ @file_writer = Hiptest::FileWriter.new(@reporter)
34
+
33
35
  # pass false to prevent hiptest-publisher from exiting, useful when used embedded
34
36
  @exit_on_bad_arguments = exit_on_bad_arguments
35
37
  end
@@ -94,7 +96,7 @@ module Hiptest
94
96
  if @exit_on_bad_arguments == false # means we are embedded in hiptest-publisher
95
97
  raise
96
98
  end
97
- rescue Exception => err
99
+ rescue => err
98
100
  puts ("An error has occured, sorry for the inconvenience.\n" +
99
101
  "Try running the command again with --verbose for detailed output").red
100
102
  reporter.dump_error(err)
@@ -105,21 +107,13 @@ module Hiptest
105
107
  parser = Hiptest::XMLParser.new(xml, reporter)
106
108
  return parser.build_project
107
109
  end
108
- rescue Exception => err
110
+ rescue => err
109
111
  reporter.dump_error(err)
110
112
  end
111
113
 
112
114
  def write_to_file(path, message, ask_overwrite: false)
113
115
  return if ask_overwrite && !overwrite_file?(path)
114
-
115
- reporter.with_status_message "#{message}: #{path}" do
116
- mkdirs_for(path)
117
- File.open(path, 'w') do |file|
118
- file.write(yield)
119
- end
120
- end
121
- rescue Exception => err
122
- reporter.dump_error(err)
116
+ @file_writer.write_to_file(path, message) { yield }
123
117
  end
124
118
 
125
119
  def overwrite_file?(path)
@@ -137,12 +131,6 @@ module Hiptest
137
131
  end
138
132
  end
139
133
 
140
- def mkdirs_for(path)
141
- unless Dir.exists?(File.dirname(path))
142
- FileUtils.mkpath(File.dirname(path))
143
- end
144
- end
145
-
146
134
  def add_listener(listener)
147
135
  reporter.add_listener(listener)
148
136
  end
@@ -192,8 +180,8 @@ module Hiptest
192
180
  end
193
181
 
194
182
  def show_actionwords_diff
195
- Hiptest::DiffDisplayer.new(compute_actionwords_diff, @cli_options, @language_config).display
196
- rescue Exception => err
183
+ Hiptest::DiffDisplayer.new(compute_actionwords_diff, @cli_options, @language_config, @file_writer).display
184
+ rescue => err
197
185
  reporter.dump_error(err)
198
186
  end
199
187
 
@@ -281,7 +269,7 @@ module Hiptest
281
269
  end
282
270
 
283
271
  display_empty_push_help if passed_count == 0
284
- rescue Exception => err
272
+ rescue => err
285
273
  reporter.dump_error(err)
286
274
  end
287
275
 
@@ -1,3 +1,4 @@
1
+ require 'erb'
1
2
  require 'json'
2
3
  require 'net/http'
3
4
  require 'uri'
@@ -43,15 +44,17 @@ module Hiptest
43
44
  options = []
44
45
 
45
46
  mapping.each do |key, filter_name|
46
- value = @cli_options.send(key)
47
+ value = @cli_options[key]
47
48
  next if value.nil? || value.empty?
48
49
 
49
50
  if [:filter_on_scenario_ids, :filter_on_folder_ids, :filter_on_tags].include?(key)
50
- value = value.split(',').map(&:strip).join(',')
51
+ value = value.split(',').map(&:strip).map{ |s| ERB::Util.url_encode(s) }.join(',')
52
+ else
53
+ value = ERB::Util.url_encode(value)
51
54
  end
52
55
 
53
56
  options << "#{filter_name}=#{value}"
54
- if [:filter_on_folder_ids, :filter_on_folder_name].include?(key) && @cli_options.send(:not_recursive)
57
+ if [:filter_on_folder_ids, :filter_on_folder_name].include?(key) && @cli_options[:not_recursive]
55
58
  options << "not_recursive=true"
56
59
  end
57
60
  end
@@ -1,12 +1,14 @@
1
1
  module Hiptest
2
2
  class DiffDisplayer
3
- def initialize(diff, cli_options, language_config)
3
+ def initialize(diff, cli_options, language_config, file_writer)
4
4
  @diff = diff
5
5
  @cli_options = cli_options
6
6
  @language_config = language_config
7
+ @file_writer = file_writer
7
8
  end
8
9
 
9
10
  def display
11
+ return export_as_json if @cli_options.actionwords_diff_json && @cli_options.output_directory
10
12
  return display_as_json if @cli_options.actionwords_diff_json
11
13
  return display_deleted if @cli_options.aw_deleted
12
14
  return display_created if @cli_options.aw_created
@@ -45,6 +47,14 @@ module Hiptest
45
47
  })
46
48
  end
47
49
 
50
+ def export_as_json
51
+ @file_writer.write_to_file(
52
+ "#{@cli_options.output_directory}/actionwords-diff.json",
53
+ "Exporting actionwords diff") {
54
+ JSON.pretty_generate(as_api)
55
+ }
56
+ end
57
+
48
58
  def display_as_json
49
59
  output(JSON.pretty_generate(as_api))
50
60
  end
@@ -0,0 +1,30 @@
1
+ require 'fileutils'
2
+
3
+ module Hiptest
4
+ class FileWriter
5
+ def initialize(reporter)
6
+ @reporter = reporter
7
+ end
8
+
9
+ def write_to_file(path, message)
10
+ @reporter.with_status_message "#{message}: #{path}" do
11
+ mkdirs_for(path)
12
+ content = yield
13
+
14
+ File.open(path, 'w') do |file|
15
+ file.write(content)
16
+ end
17
+ end
18
+ rescue => err
19
+ reporter.dump_error(err)
20
+ end
21
+
22
+ private
23
+
24
+ def mkdirs_for(path)
25
+ unless Dir.exists?(File.dirname(path))
26
+ FileUtils.mkpath(File.dirname(path))
27
+ end
28
+ end
29
+ end
30
+ end
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.10.0
4
+ version: 1.10.1
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-12-01 00:00:00.000000000 Z
11
+ date: 2017-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -253,6 +253,7 @@ files:
253
253
  - lib/hiptest-publisher/client.rb
254
254
  - lib/hiptest-publisher/datatable_fixer.rb
255
255
  - lib/hiptest-publisher/diff_displayer.rb
256
+ - lib/hiptest-publisher/file_writer.rb
256
257
  - lib/hiptest-publisher/formatters/console_formatter.rb
257
258
  - lib/hiptest-publisher/formatters/reporter.rb
258
259
  - lib/hiptest-publisher/gherkin_adder.rb