hiptest-publisher 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hiptest-publisher.rb +14 -6
- data/lib/hiptest-publisher/formatters/console_formatter.rb +25 -0
- data/lib/hiptest-publisher/formatters/reporter.rb +28 -0
- data/lib/hiptest-publisher/options_parser.rb +7 -10
- data/lib/hiptest-publisher/utils.rb +1 -9
- data/lib/hiptest-publisher/xml_parser.rb +6 -7
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb180aab27561c616c4d10b1593c31e5765fb97b
|
4
|
+
data.tar.gz: 586b13fb3e4c2a5de599898600704cfafa8779da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e835abd1107cc0b1b54d8bc402359e4b56fe4251950c4cef4c80494d480fa3cb90683e66cfe1a50c3177d27aa31a773d2bb55a7c1606fb8d24dd297603783fa7
|
7
|
+
data.tar.gz: 70a1ce1c7bc5484856c59a14ae5bb7d8abfe596af718624c6efcf4b18fa897b91b03300459c9378ae70a9803d2ad8e2c2b8ddf072318ad2a6c15208adea7d983
|
data/lib/hiptest-publisher.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'colorize'
|
2
2
|
require 'yaml'
|
3
3
|
|
4
|
+
require 'hiptest-publisher/formatters/reporter'
|
4
5
|
require 'hiptest-publisher/string'
|
5
6
|
require 'hiptest-publisher/utils'
|
6
7
|
require 'hiptest-publisher/options_parser'
|
@@ -13,8 +14,11 @@ require 'hiptest-publisher/signature_differ'
|
|
13
14
|
|
14
15
|
module Hiptest
|
15
16
|
class Publisher
|
17
|
+
attr_reader :reporter
|
18
|
+
|
16
19
|
def initialize(args)
|
17
|
-
@
|
20
|
+
@reporter = Reporter.new
|
21
|
+
@options = OptionsParser.parse(args, reporter)
|
18
22
|
end
|
19
23
|
|
20
24
|
def run
|
@@ -50,12 +54,12 @@ module Hiptest
|
|
50
54
|
rescue Exception => err
|
51
55
|
show_status_message "Fetching data from Hiptest", :failure
|
52
56
|
puts "Unable to open the file, please check that the token is correct".red
|
53
|
-
|
57
|
+
reporter.dump_error(err)
|
54
58
|
end
|
55
59
|
|
56
60
|
def get_project(xml)
|
57
61
|
show_status_message "Extracting data"
|
58
|
-
parser = Hiptest::XMLParser.new(xml,
|
62
|
+
parser = Hiptest::XMLParser.new(xml, reporter)
|
59
63
|
show_status_message "Extracting data", :success
|
60
64
|
|
61
65
|
return parser.build_project
|
@@ -72,10 +76,14 @@ module Hiptest
|
|
72
76
|
show_status_message status_message, :success
|
73
77
|
rescue Exception => err
|
74
78
|
show_status_message status_message, :failure
|
75
|
-
|
79
|
+
reporter.dump_error(err)
|
76
80
|
end
|
77
81
|
end
|
78
82
|
|
83
|
+
def add_listener(listener)
|
84
|
+
reporter.add_listener(listener)
|
85
|
+
end
|
86
|
+
|
79
87
|
def write_node_to_file(path, node, context, message)
|
80
88
|
write_to_file(path, message) do
|
81
89
|
Hiptest::Renderer.render(node, @options.language, context)
|
@@ -148,7 +156,7 @@ module Hiptest
|
|
148
156
|
show_status_message("Loading previous definition", :success)
|
149
157
|
rescue Exception => err
|
150
158
|
show_status_message("Loading previous definition", :failure)
|
151
|
-
|
159
|
+
reporter.dump_error(err)
|
152
160
|
end
|
153
161
|
|
154
162
|
@language_config = LanguageConfigParser.new(@options)
|
@@ -251,7 +259,7 @@ module Hiptest
|
|
251
259
|
show_status_message(status_message, :success)
|
252
260
|
rescue Exception => err
|
253
261
|
show_status_message(status_message, :failure)
|
254
|
-
|
262
|
+
reporter.dump_error(err)
|
255
263
|
end
|
256
264
|
end
|
257
265
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'hiptest-publisher/utils'
|
2
|
+
|
3
|
+
class ConsoleFormatter
|
4
|
+
attr_reader :verbose
|
5
|
+
|
6
|
+
def initialize(verbose)
|
7
|
+
@verbose = verbose
|
8
|
+
end
|
9
|
+
|
10
|
+
def dump_error(error, message = nil)
|
11
|
+
return unless verbose
|
12
|
+
puts message.blue if message
|
13
|
+
line = "-" * 80
|
14
|
+
puts line.yellow
|
15
|
+
puts "#{error.class.name}: #{error.message}".red
|
16
|
+
puts "#{error.backtrace.map {|l| " #{l}\n"}.join}".yellow
|
17
|
+
puts line.yellow
|
18
|
+
end
|
19
|
+
|
20
|
+
def show_options(options)
|
21
|
+
return unless verbose
|
22
|
+
puts "Running Hiptest-publisher #{hiptest_publisher_version} with:".yellow
|
23
|
+
options.each { |k, v| puts " - #{k}: #{v}".white }
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
class Reporter
|
4
|
+
def initialize
|
5
|
+
@listeners = []
|
6
|
+
end
|
7
|
+
|
8
|
+
def add_listener(listener)
|
9
|
+
@listeners << listener
|
10
|
+
end
|
11
|
+
|
12
|
+
def dump_error(error, message = nil)
|
13
|
+
@listeners.each do |listener|
|
14
|
+
listener.dump_error(error, message)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def show_options(options)
|
19
|
+
@listeners.each do |listener|
|
20
|
+
listener.show_options(options)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class NullReporter
|
26
|
+
def method_missing(*args)
|
27
|
+
end
|
28
|
+
end
|
@@ -2,10 +2,11 @@ require 'optparse'
|
|
2
2
|
require 'parseconfig'
|
3
3
|
require 'ostruct'
|
4
4
|
|
5
|
+
require 'hiptest-publisher/formatters/console_formatter'
|
5
6
|
require 'hiptest-publisher/utils'
|
6
7
|
|
7
8
|
class FileConfigParser
|
8
|
-
def self.update_options(options)
|
9
|
+
def self.update_options(options, reporter)
|
9
10
|
config = ParseConfig.new(options.config)
|
10
11
|
config.get_params.each do |param|
|
11
12
|
options.send("#{param}=", config[param])
|
@@ -13,7 +14,7 @@ class FileConfigParser
|
|
13
14
|
options
|
14
15
|
|
15
16
|
rescue Exception => err
|
16
|
-
|
17
|
+
reporter.dump_error(err)
|
17
18
|
options
|
18
19
|
end
|
19
20
|
end
|
@@ -98,7 +99,7 @@ class OptionsParser
|
|
98
99
|
]
|
99
100
|
end
|
100
101
|
|
101
|
-
def self.parse(args)
|
102
|
+
def self.parse(args, reporter)
|
102
103
|
options = OpenStruct.new
|
103
104
|
opt_parser = OptionParser.new do |opts|
|
104
105
|
opts.version = hiptest_publisher_version if hiptest_publisher_version
|
@@ -138,17 +139,13 @@ class OptionsParser
|
|
138
139
|
end
|
139
140
|
|
140
141
|
opt_parser.parse!(args)
|
141
|
-
|
142
|
+
reporter.add_listener(ConsoleFormatter.new(options.verbose))
|
143
|
+
FileConfigParser.update_options(options, reporter)
|
142
144
|
|
143
|
-
show_options(options)
|
145
|
+
reporter.show_options(options.marshal_dump)
|
144
146
|
options
|
145
147
|
end
|
146
148
|
|
147
|
-
def self.show_options(options)
|
148
|
-
puts "Running Hiptest-publisher with:".yellow
|
149
|
-
options.marshal_dump.each { |k, v| puts " - #{k}: #{v}".white }
|
150
|
-
end
|
151
|
-
|
152
149
|
def self.make_language_option(lang, framework = '')
|
153
150
|
lang_opt = "--language=#{lang.downcase.gsub(' ', '')}"
|
154
151
|
framework_opt = "--framework=#{framework.downcase.gsub(' ', '')}"
|
@@ -12,7 +12,7 @@ end
|
|
12
12
|
def hiptest_publisher_version
|
13
13
|
Gem.loaded_specs['hiptest-publisher'].version.to_s
|
14
14
|
rescue
|
15
|
-
File.read("#{hiptest_publisher_path}/VERSION") if File.exists?("#{hiptest_publisher_path}/VERSION")
|
15
|
+
File.read("#{hiptest_publisher_path}/VERSION").strip if File.exists?("#{hiptest_publisher_path}/VERSION")
|
16
16
|
end
|
17
17
|
|
18
18
|
def pluralize(count, singular)
|
@@ -44,14 +44,6 @@ def fetch_project_export(options)
|
|
44
44
|
open(url, :ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE)
|
45
45
|
end
|
46
46
|
|
47
|
-
def trace_exception(exception)
|
48
|
-
line = "-" * 80
|
49
|
-
puts line.yellow
|
50
|
-
puts "#{exception.class.name}: #{exception.message}".red
|
51
|
-
puts "#{exception.backtrace.map {|l| " #{l}\n"}.join}".yellow
|
52
|
-
puts line.yellow
|
53
|
-
end
|
54
|
-
|
55
47
|
def show_status_message(message, status=nil)
|
56
48
|
status_icon = " "
|
57
49
|
line_end = status.nil? ? "" : "\n"
|
@@ -3,15 +3,16 @@ require 'colorize'
|
|
3
3
|
|
4
4
|
require_relative 'nodes'
|
5
5
|
require_relative 'utils'
|
6
|
+
require_relative 'formatters/reporter'
|
6
7
|
|
7
8
|
module Hiptest
|
8
9
|
class XMLParser
|
9
10
|
attr_reader :project
|
10
11
|
|
11
|
-
def initialize(source,
|
12
|
+
def initialize(source, reporter = nil)
|
12
13
|
@source = source
|
13
14
|
@xml = Nokogiri::XML(source)
|
14
|
-
@
|
15
|
+
@reporter = reporter || NullReporter.new
|
15
16
|
end
|
16
17
|
|
17
18
|
def build_nullliteral(value = nil)
|
@@ -317,11 +318,9 @@ module Hiptest
|
|
317
318
|
return default_node.new
|
318
319
|
end
|
319
320
|
self.send("build_#{node.name}", node)
|
320
|
-
rescue
|
321
|
-
|
322
|
-
|
323
|
-
trace_exception(exception)
|
324
|
-
end
|
321
|
+
rescue => error
|
322
|
+
@reporter.dump_error(error, "Unable to build: \n#{node}")
|
323
|
+
nil
|
325
324
|
end
|
326
325
|
|
327
326
|
def build_node_list(l, container_class=nil)
|
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: 0.5.
|
4
|
+
version: 0.5.3
|
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: 2015-06-
|
11
|
+
date: 2015-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -260,6 +260,8 @@ files:
|
|
260
260
|
- lib/hiptest-publisher.rb
|
261
261
|
- lib/hiptest-publisher/actionword_indexer.rb
|
262
262
|
- lib/hiptest-publisher/call_arguments_adder.rb
|
263
|
+
- lib/hiptest-publisher/formatters/console_formatter.rb
|
264
|
+
- lib/hiptest-publisher/formatters/reporter.rb
|
263
265
|
- lib/hiptest-publisher/gherkin_adder.rb
|
264
266
|
- lib/hiptest-publisher/handlebars_helper.rb
|
265
267
|
- lib/hiptest-publisher/nodes.rb
|
@@ -514,7 +516,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
514
516
|
version: '0'
|
515
517
|
requirements: []
|
516
518
|
rubyforge_project:
|
517
|
-
rubygems_version: 2.4.
|
519
|
+
rubygems_version: 2.4.5
|
518
520
|
signing_key:
|
519
521
|
specification_version: 4
|
520
522
|
summary: Export your tests from Hiptest into executable tests.
|