hiptest-publisher 2.0.0 → 2.1.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
- SHA1:
3
- metadata.gz: 36283085bf8b4776b1a854fed8a9dc0c96d7e84a
4
- data.tar.gz: 040bc62f36aaa7b1aa54b354ba205ce4bc2660d6
2
+ SHA256:
3
+ metadata.gz: 92594c83a779b66b0e20d2b894a1509199fecee0b47afee44e57284f37eb094c
4
+ data.tar.gz: 410db2501af2e304eb3135ed3302f36a453d1cc292789e423bc0757e0d6e5720
5
5
  SHA512:
6
- metadata.gz: 88d3eba37283240cd6632fef52cdc0bd55fda0544428bf29b92cc648760e0ef59c06bbfecf863773e6bbba626f08d17de4d6efec4aabfe07a4cb93e93dec7e80
7
- data.tar.gz: f8d676bc23cc00e1428c64b9f1f41b33c269feffbfe0afd3f27c6ba353bfd4d27fee1024eddf2bd568d53526a6f63e9be531504a694ca492b18727a6c9083b77
6
+ metadata.gz: c781fd1c8ce9ca8f9a857e6e5989fde3c033f1014479dbf324fcc26157190daa90c410735bb8b2529ce336f46e80115d0d45319de19b9b79fa5f0e5898daa1a8
7
+ data.tar.gz: 40ea3a9a05459ab6d796757196da3bece8a39f160f53b0c9338eebc032a7797bca8eb4030eb2fb98e3b970143f44edf65267b6120b869b3eaf698bc0086c1a5a
data/README.md CHANGED
@@ -148,6 +148,7 @@ Specific options:
148
148
  --not-recursive Used in conjunction with filter-on-folder-ids or filter-on-folder-name: only exports those folders, not their children (default: false)
149
149
  --check-version Check if a new release of hiptest-publisher is available (default: false)
150
150
  --force Force overwrite of existing files (do not apply to test files) (default: false)
151
+ --[no-]color Force [un]use of ANSI color in text output
151
152
  -v, --verbose Run verbosely (default: false)
152
153
  -H, --languages-help Show languages and framework options
153
154
  -h, --help Show this message
@@ -168,6 +168,7 @@ en:
168
168
  aw_renamed: Output signatures of renamed action words
169
169
  aw_signature_changed: Output signatures of action words for which signature changed
170
170
  check_version: Check if a new release of hiptest-publisher is available
171
+ color: Force [un]use of ANSI color in text output
171
172
  config: Configuration file
172
173
  empty_folders: Export empty folders
173
174
  execution_environment: Name of the execution environment
@@ -86,12 +86,12 @@ module Hiptest
86
86
  @client.fetch_project_export
87
87
  rescue ClientError => err
88
88
  # This should not be an error that needs reporting to an exception monitoring app
89
- puts err.message.yellow
89
+ reporter.show_error(err.message)
90
90
  if @exit_on_bad_arguments == false # means we are embedded in hiptest-publisher
91
91
  raise
92
92
  end
93
93
  rescue => err
94
- puts I18n.t("errors.default").red
94
+ reporter.show_failure(I18n.t("errors.default"))
95
95
  reporter.dump_error(err)
96
96
  end
97
97
 
@@ -113,10 +113,8 @@ module Hiptest
113
113
  return true unless File.file?(path)
114
114
  return true if @cli_options.force_overwrite
115
115
 
116
- if $stdout.isatty
117
- STDOUT.print "\n"
118
- STDOUT.print "[#{"?".yellow}] #{I18n.t('overwrite.ask_confirmation', path: path)}"
119
- answer = $stdin.gets.chomp.downcase.strip
116
+ if $stdout.tty?
117
+ answer = reporter.ask(I18n.t('overwrite.ask_confirmation', path: path))
120
118
  return ['y', 'yes'].include?(answer)
121
119
  else
122
120
  reporter.warning_message(I18n.t('overwrite.warning_message', path: path))
@@ -5,26 +5,35 @@ require 'hiptest-publisher/utils'
5
5
  class ConsoleFormatter
6
6
  attr_reader :verbose
7
7
 
8
- def initialize(verbose)
8
+ def initialize(verbose, color: nil)
9
9
  @verbose = verbose
10
+ @color = color.nil? ? tty? : color
10
11
  @immediate_verbose = true
11
12
  @verbose_messages = []
12
13
  end
13
14
 
14
15
  def dump_error(error, message = nil)
15
16
  return unless verbose
16
- puts message.blue if message
17
+ puts colorize(message, :blue) if message
17
18
  line = "-" * 80
18
- puts line.yellow
19
- puts "#{error.class.name}: #{error.message}".red
20
- puts "#{error.backtrace.map {|l| " #{l}\n"}.join}".yellow
21
- puts line.yellow
19
+ puts colorize(line, :yellow)
20
+ puts colorize("#{error.class.name}: #{error.message}", :red)
21
+ puts colorize("#{error.backtrace.map {|l| " #{l}\n"}.join}", :yellow)
22
+ puts colorize(line, :yellow)
23
+ end
24
+
25
+ def show_error(message)
26
+ STDOUT.print colorize(message, :yellow)
27
+ end
28
+
29
+ def show_failure(message)
30
+ STDOUT.print(colorize(message, :red))
22
31
  end
23
32
 
24
33
  def show_options(options, message = nil)
25
34
  return unless verbose
26
35
  message ||= I18n.t(:verbose_header, version: hiptest_publisher_version)
27
- puts message.yellow
36
+ puts colorize(message, :yellow)
28
37
  options.each { |k, v| puts " - #{k}: #{v.inspect}" }
29
38
  end
30
39
 
@@ -42,18 +51,18 @@ class ConsoleFormatter
42
51
  output = STDOUT
43
52
 
44
53
  if status == :success
45
- status_icon = "v".green
54
+ status_icon = colorize("v", :green)
46
55
  elsif status == :warning
47
- status_icon = "?".yellow
56
+ status_icon = colorize("?", :yellow)
48
57
  elsif status == :failure
49
- status_icon = "x".red
58
+ status_icon = colorize("x", :red)
50
59
  output = STDERR
51
60
  end
52
61
  if status
53
62
  @immediate_verbose = true
54
63
  cursor_offset = ""
55
64
  else
56
- return unless $stdout.tty?
65
+ return unless tty?
57
66
  rows, columns = IO.console.winsize
58
67
  return if columns == 0
59
68
  @immediate_verbose = false
@@ -68,4 +77,24 @@ class ConsoleFormatter
68
77
  @verbose_messages.clear
69
78
  end
70
79
  end
80
+
81
+ def ask(question)
82
+ return unless tty?
83
+ STDOUT.print "[#{colorize('?', :yellow)}] #{question}"
84
+ return $stdin.gets.chomp.downcase.strip
85
+ end
86
+
87
+ def colored?
88
+ @color
89
+ end
90
+
91
+ private
92
+
93
+ def tty?
94
+ $stdout.tty?
95
+ end
96
+
97
+ def colorize(txt, color)
98
+ colored? ? txt.send(color) : txt
99
+ end
71
100
  end
@@ -11,6 +11,14 @@ class Reporter
11
11
  notify(:dump_error, error, message)
12
12
  end
13
13
 
14
+ def show_error(message)
15
+ notify(:show_error, message)
16
+ end
17
+
18
+ def show_failure(message)
19
+ notify(:show_failure, message)
20
+ end
21
+
14
22
  def show_options(options, message = nil)
15
23
  notify(:show_options, options, message)
16
24
  end
@@ -48,6 +56,12 @@ class Reporter
48
56
  end
49
57
  nil
50
58
  end
59
+
60
+ def ask(question)
61
+ askable_listener = @listeners.find { |l| l.respond_to?(:ask) }
62
+ return nil if askable_listener.nil?
63
+ return askable_listener.ask(question)
64
+ end
51
65
  end
52
66
 
53
67
  class NullReporter
@@ -263,6 +263,7 @@ class OptionsParser
263
263
  Option.new(nil, 'meta=META', '', String, I18n.t('options.meta'), :meta),
264
264
  Option.new(nil, 'check-version', false, nil, I18n.t('options.check_version'), :check_version),
265
265
  Option.new(nil, 'force', false, nil, I18n.t('options.force_overwrite'), :force_overwrite),
266
+ Option.new(nil, '[no-]color', nil, nil, I18n.t('options.color'), :color),
266
267
  Option.new('v', 'verbose', false, nil, I18n.t('options.verbose'), :verbose)
267
268
  ]
268
269
  end
@@ -294,7 +295,7 @@ class OptionsParser
294
295
 
295
296
  args << "--help" if args.empty?
296
297
  opt_parser.parse!(args)
297
- reporter.add_listener(ConsoleFormatter.new(options.verbose))
298
+ reporter.add_listener(ConsoleFormatter.new(options.verbose, color: options.color))
298
299
  FileConfigParser.update_options(options, reporter)
299
300
 
300
301
  reporter.show_options(options.marshal_dump)
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hiptest-publisher
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.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: 2019-12-02 00:00:00.000000000 Z
11
+ date: 2020-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: 0.7.5
20
17
  - - "~>"
21
18
  - !ruby/object:Gem::Version
22
19
  version: '0.7'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.7.5
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: 0.7.5
30
27
  - - "~>"
31
28
  - !ruby/object:Gem::Version
32
29
  version: '0.7'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.7.5
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: parseconfig
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - ">="
38
- - !ruby/object:Gem::Version
39
- version: 1.0.4
40
37
  - - "~>"
41
38
  - !ruby/object:Gem::Version
42
39
  version: '1.0'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 1.0.4
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - ">="
48
- - !ruby/object:Gem::Version
49
- version: 1.0.4
50
47
  - - "~>"
51
48
  - !ruby/object:Gem::Version
52
49
  version: '1.0'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 1.0.4
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: i18n
55
55
  requirement: !ruby/object:Gem::Requirement
@@ -88,22 +88,22 @@ dependencies:
88
88
  name: multipart-post
89
89
  requirement: !ruby/object:Gem::Requirement
90
90
  requirements:
91
- - - ">="
92
- - !ruby/object:Gem::Version
93
- version: 2.1.1
94
91
  - - "~>"
95
92
  - !ruby/object:Gem::Version
96
93
  version: '2.1'
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 2.1.1
97
97
  type: :runtime
98
98
  prerelease: false
99
99
  version_requirements: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: 2.1.1
104
101
  - - "~>"
105
102
  - !ruby/object:Gem::Version
106
103
  version: '2.1'
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: 2.1.1
107
107
  - !ruby/object:Gem::Dependency
108
108
  name: ruby_version
109
109
  requirement: !ruby/object:Gem::Requirement
@@ -192,22 +192,22 @@ dependencies:
192
192
  name: codeclimate-test-reporter
193
193
  requirement: !ruby/object:Gem::Requirement
194
194
  requirements:
195
- - - ">="
196
- - !ruby/object:Gem::Version
197
- version: 0.4.6
198
195
  - - "~>"
199
196
  - !ruby/object:Gem::Version
200
197
  version: '0.4'
198
+ - - ">="
199
+ - !ruby/object:Gem::Version
200
+ version: 0.4.6
201
201
  type: :development
202
202
  prerelease: false
203
203
  version_requirements: !ruby/object:Gem::Requirement
204
204
  requirements:
205
- - - ">="
206
- - !ruby/object:Gem::Version
207
- version: 0.4.6
208
205
  - - "~>"
209
206
  - !ruby/object:Gem::Version
210
207
  version: '0.4'
208
+ - - ">="
209
+ - !ruby/object:Gem::Version
210
+ version: 0.4.6
211
211
  - !ruby/object:Gem::Dependency
212
212
  name: i18n-tasks
213
213
  requirement: !ruby/object:Gem::Requirement
@@ -748,8 +748,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
748
748
  - !ruby/object:Gem::Version
749
749
  version: '0'
750
750
  requirements: []
751
- rubyforge_project:
752
- rubygems_version: 2.6.10
751
+ rubygems_version: 3.0.1
753
752
  signing_key:
754
753
  specification_version: 4
755
754
  summary: Export your tests from HipTest into executable tests.