allure-ruby-commons 2.21.1 → 2.22.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
  SHA256:
3
- metadata.gz: 2f5c3dfee7eb45d47e68dd2b3e6cea65eee99c6a65d5f26155ef63f047b2e8a6
4
- data.tar.gz: 364026c97cd8be435807e5aff89a525015b79db8817b01ec7b847cdf942dca6b
3
+ metadata.gz: '099ba3dddaa422aadd6805174b9ea6355be15b89b0587baf39d379dfda0763ad'
4
+ data.tar.gz: 066eb591f740c700e09f712b86b83c28bac6fd903321d8643426872a0ba61bbe
5
5
  SHA512:
6
- metadata.gz: b8d8a79fe660235dba902c1f0d1a86c799848944a645f52e2548b24fbc3e68f9c6b11ee64e57007370efde535d90580a3626cd5576179baa696147eaf1ea2e59
7
- data.tar.gz: bcfa0e762321315471a07bca0925ebfde15606875036b4a1fb0e30e1eba99725c32fa7bb69cfece308ce2f5ff299b09f1008639624d2cd6cc901e85a47f88692
6
+ metadata.gz: c6f36b3ecdc794f0ddb952e125a9cd55600763478038dd7634ff40e7131f75f246a726bf189871f6581a4a051b5c095b605ffcc464389dcb8538eed5bcdf3cf5
7
+ data.tar.gz: 94efb6010db9cbca76f4136567a6c4330108ec6b2d140f36d007dcb5c64ae53fd5ed4dd05cb7184119af04d894f4eea1f5da78238bf7377c823e947d614edd56
@@ -28,6 +28,7 @@ module Allure
28
28
  define_method(:load_json) do |json|
29
29
  Oj.load_file(json, symbol_keys: true)
30
30
  rescue Oj::ParseError
31
+ Allure.configuration.logger.error("Failed to parse json: #{json}")
31
32
  nil
32
33
  end
33
34
  rescue LoadError
@@ -40,6 +41,7 @@ module Allure
40
41
  define_method(:load_json) do |json|
41
42
  JSON.parse(File.read(json), symbolize_names: true)
42
43
  rescue JSON::ParserError
44
+ Allure.configuration.logger.error("Failed to parse json: #{json}")
43
45
  nil
44
46
  end
45
47
  end
@@ -6,9 +6,9 @@ module Allure
6
6
  # Return object hash represantation
7
7
  # @return [Hash]
8
8
  def to_hash
9
- instance_variables.each_with_object({}) do |var, map|
10
- key = camelcase(var.to_s.delete_prefix("@"))
11
- value = instance_variable_get(var)
9
+ json_attributes.each_with_object({}) do |attribute, map|
10
+ key = camelcase(attribute)
11
+ value = send(attribute) # fetch via reader for dynamically generated attributes
12
12
  map[key] = value unless value.nil?
13
13
  end
14
14
  end
@@ -33,7 +33,7 @@ module Allure
33
33
  # Object state
34
34
  # @return [Array]
35
35
  def state
36
- instance_variables.map { |var| instance_variable_get(var) }
36
+ json_attributes.map { |attribute| send(attribute) }
37
37
  end
38
38
 
39
39
  private
@@ -45,5 +45,12 @@ module Allure
45
45
  str = str.gsub(/(?:_+)([a-z])/) { Regexp.last_match(1).upcase }
46
46
  str.gsub(/(\A|\s)([A-Z])/) { Regexp.last_match(1) + Regexp.last_match(2).downcase }
47
47
  end
48
+
49
+ # Json attribute names
50
+ #
51
+ # @return [Array<String>]
52
+ def json_attributes
53
+ @json_attributes ||= instance_variables.map { |attribute| attribute.to_s.delete_prefix("@") }
54
+ end
48
55
  end
49
56
  end
@@ -15,5 +15,7 @@ module Allure
15
15
  @message_regex = message_regex
16
16
  @trace_regex = trace_regex
17
17
  end
18
+
19
+ attr_reader :name, :matched_statuses, :message_regex, :trace_regex
18
20
  end
19
21
  end
@@ -24,7 +24,7 @@ module Allure
24
24
 
25
25
  @name = options[:name]
26
26
  @uuid = uuid
27
- @history_id = Digest::MD5.hexdigest("#{history_id}#{environment}")
27
+ @history_id = history_id
28
28
  @full_name = options[:full_name] || "Unnamed"
29
29
  @labels = options[:labels] || []
30
30
  @links = options[:links] || []
@@ -32,9 +32,26 @@ module Allure
32
32
  end
33
33
 
34
34
  attr_accessor :uuid,
35
- :history_id,
36
35
  :full_name,
37
36
  :labels,
38
37
  :links
38
+
39
+ attr_writer :history_id
40
+
41
+ # History id
42
+ #
43
+ # @return [String]
44
+ def history_id
45
+ Digest::MD5.hexdigest("#{@history_id}#{parameters_string}")
46
+ end
47
+
48
+ private
49
+
50
+ # All parameters string
51
+ #
52
+ # @return [String]
53
+ def parameters_string
54
+ parameters.map { |p| "#{p.name}=#{p.value}" }.join(";")
55
+ end
39
56
  end
40
57
  end
@@ -14,6 +14,15 @@ module Allure
14
14
  @links = []
15
15
  end
16
16
 
17
- attr_accessor :uuid, :name, :description, :description_html, :start, :stop, :children, :befores, :afters, :links
17
+ attr_accessor :uuid,
18
+ :name,
19
+ :description,
20
+ :description_html,
21
+ :start,
22
+ :stop,
23
+ :children,
24
+ :befores,
25
+ :afters,
26
+ :links
18
27
  end
19
28
  end
@@ -28,7 +28,25 @@ module Allure
28
28
  #
29
29
  # @return [Array<Hash>]
30
30
  def tests
31
- @tests ||= load_json(ENV[TESTPLAN_PATH])&.fetch(:tests) if ENV[TESTPLAN_PATH]
31
+ @tests ||= load_json(test_plan_path)&.fetch(:tests) if test_plan_path
32
+ end
33
+
34
+ # Fetch test plan path
35
+ #
36
+ # @return [<String, nil>]
37
+ def test_plan_path
38
+ return @test_plan_path if defined?(@test_plan_path)
39
+
40
+ @test_plan_path = ENV[TESTPLAN_PATH].then do |path|
41
+ next unless path
42
+ next path if File.file?(path)
43
+
44
+ json = File.join(path, "testplan.json")
45
+ next json if File.exist?(json)
46
+
47
+ Allure.configuration.logger.warn("'ALLURE_TESTPLAN_PATH' env var is set, but no testplan.json found!")
48
+ nil
49
+ end
32
50
  end
33
51
  end
34
52
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: allure-ruby-commons
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.21.1
4
+ version: 2.22.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrejs Cunskis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-29 00:00:00.000000000 Z
11
+ date: 2023-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mime-types
@@ -133,14 +133,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
133
133
  requirements:
134
134
  - - ">="
135
135
  - !ruby/object:Gem::Version
136
- version: 2.7.0
136
+ version: 3.0.0
137
137
  required_rubygems_version: !ruby/object:Gem::Requirement
138
138
  requirements:
139
139
  - - ">="
140
140
  - !ruby/object:Gem::Version
141
141
  version: '0'
142
142
  requirements: []
143
- rubygems_version: 3.3.7
143
+ rubygems_version: 3.4.10
144
144
  signing_key:
145
145
  specification_version: 4
146
146
  summary: Common library for allure results generation