hiptest-publisher 1.7.1 → 1.8.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: cbf06f33fd45da518c5dc43230bdd7a5abb4b0cc
4
- data.tar.gz: db096131dcc315d0bd4e6574a5d68d5f7bd4cfa5
3
+ metadata.gz: 7060a45b500229208b1aab41f027f613a16cfaeb
4
+ data.tar.gz: 5e2e1810d7b3d7ced4b7f60fb4396b9fd9e636aa
5
5
  SHA512:
6
- metadata.gz: ecb29328f321937b055e0709897ae9a3eb134717bd59dd15fcc813d48423d477cd1233448d9b9c0bdf39c42ad203f1c191e334e307a9e968de03f48fb9f20f9e
7
- data.tar.gz: b1ef4cf7748c99d9dc8b98446dcd3741f1ac10f998f214e52925ab8cbb0a5ab54d730dddfc5f75836f739f7beaa97452190749cf78872e4c475877dc090d7c97
6
+ metadata.gz: f5070ded6342524ea605b5cb9a44344fecbfb09efb34a943929775638dd782e76764b2eec229779c1d48bef7e0a9fa9aa2cffa35bd8ca4bd6bcd0f152820532c
7
+ data.tar.gz: 47c9e6af92a1d2838477959a629a3742abe86a6e50cc3a08ee74749d5f54daa6afcc99e33cb1dd866608621e76e3d9c0d610565fd1790f3af12e37451bc19d1b
@@ -18,7 +18,6 @@ require 'hiptest-publisher/signature_exporter'
18
18
  require 'hiptest-publisher/signature_differ'
19
19
  require 'hiptest-publisher/items_orderer'
20
20
 
21
-
22
21
  module Hiptest
23
22
  class Publisher
24
23
  attr_reader :reporter
@@ -106,7 +105,9 @@ module Hiptest
106
105
  reporter.dump_error(err)
107
106
  end
108
107
 
109
- def write_to_file(path, message)
108
+ def write_to_file(path, message, ask_overwrite: false)
109
+ return if ask_overwrite && !overwrite_file?(path)
110
+
110
111
  reporter.with_status_message "#{message}: #{path}" do
111
112
  mkdirs_for(path)
112
113
  File.open(path, 'w') do |file|
@@ -117,6 +118,21 @@ module Hiptest
117
118
  reporter.dump_error(err)
118
119
  end
119
120
 
121
+ def overwrite_file?(path)
122
+ return true unless File.file?(path)
123
+ return true if @cli_options.force_overwrite
124
+
125
+ if $stdout.isatty
126
+ puts ""
127
+ STDOUT.print "[#{"?".yellow}] File #{path} exists, do you want to overwrite it? [y/N] "
128
+ answer = $stdin.gets.chomp.downcase.strip
129
+ return ['y', 'yes'].include?(answer)
130
+ else
131
+ reporter.notify(:show_status_message, "File #{path} already exists, skipping. Use --force to overwrite it.", :warning)
132
+ return false
133
+ end
134
+ end
135
+
120
136
  def mkdirs_for(path)
121
137
  unless Dir.exists?(File.dirname(path))
122
138
  FileUtils.mkpath(File.dirname(path))
@@ -127,20 +143,23 @@ module Hiptest
127
143
  reporter.add_listener(listener)
128
144
  end
129
145
 
130
- def write_node_to_file(path, node, context, message)
131
- write_to_file(path, message) do
146
+ def write_node_to_file(path, node, context, message, ask_overwrite: false)
147
+ write_to_file(path, message, ask_overwrite: ask_overwrite) do
132
148
  Hiptest::Renderer.render(node, context)
133
149
  end
134
150
  end
135
151
 
136
152
  def export_files
137
153
  @language_config.language_group_configs.each do |language_group_config|
154
+ ask_overwrite = language_group_config[:group_name] == 'actionwords'
155
+
138
156
  language_group_config.each_node_rendering_context(@project) do |node_rendering_context|
139
157
  write_node_to_file(
140
158
  node_rendering_context.path,
141
159
  node_rendering_context.node,
142
160
  node_rendering_context,
143
161
  "Exporting #{node_rendering_context.description}",
162
+ ask_overwrite: ask_overwrite
144
163
  )
145
164
  end
146
165
  end
@@ -151,7 +170,8 @@ module Hiptest
151
170
 
152
171
  write_to_file(
153
172
  "#{@cli_options.output_directory}/actionwords_signature.yaml",
154
- "Exporting actionword signature"
173
+ "Exporting actionword signature",
174
+ ask_overwrite: true
155
175
  ) { Hiptest::SignatureExporter.export_actionwords(@project).to_yaml }
156
176
  end
157
177
 
@@ -41,6 +41,8 @@ class ConsoleFormatter
41
41
 
42
42
  if status == :success
43
43
  status_icon = "v".green
44
+ elsif status == :warning
45
+ status_icon = "?".yellow
44
46
  elsif status == :failure
45
47
  status_icon = "x".red
46
48
  output = STDERR
@@ -242,6 +242,7 @@ class OptionsParser
242
242
  Option.new(nil, 'filter-on-status=STATUS', '', String, "Filter on test status in last build (use in conjunction with a test run)", :filter_on_status),
243
243
  Option.new(nil, 'not-recursive', false, nil, "Used in conjunction with filter-on-folder-ids or filter-on-folder-name: only exports those folders, not their children", :not_recursive),
244
244
  Option.new(nil, 'check-version', false, nil, "Check if a new release of hiptest-publisher is available", :check_version),
245
+ Option.new(nil, 'force', false, nil, "Force overwrite of existing files (do not apply to test files)", :force_overwrite),
245
246
  Option.new('v', 'verbose', false, nil, "Run verbosely", :verbose)
246
247
  ]
247
248
  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.7.1
4
+ version: 1.8.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-10-16 00:00:00.000000000 Z
11
+ date: 2017-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize