cucumber-messages 22.0.0 → 27.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +2 -2
  3. data/README.md +1 -0
  4. data/VERSION +1 -1
  5. data/lib/cucumber/messages/attachment.rb +131 -0
  6. data/lib/cucumber/messages/attachment_content_encoding.rb +11 -0
  7. data/lib/cucumber/messages/background.rb +64 -0
  8. data/lib/cucumber/messages/ci.rb +62 -0
  9. data/lib/cucumber/messages/comment.rb +50 -0
  10. data/lib/cucumber/messages/data_table.rb +41 -0
  11. data/lib/cucumber/messages/doc_string.rb +51 -0
  12. data/lib/cucumber/messages/duration.rb +50 -0
  13. data/lib/cucumber/messages/envelope.rb +134 -0
  14. data/lib/cucumber/messages/examples.rb +74 -0
  15. data/lib/cucumber/messages/exception.rb +57 -0
  16. data/lib/cucumber/messages/feature.rb +87 -0
  17. data/lib/cucumber/messages/feature_child.rb +49 -0
  18. data/lib/cucumber/messages/gherkin_document.rb +62 -0
  19. data/lib/cucumber/messages/git.rb +54 -0
  20. data/lib/cucumber/messages/group.rb +46 -0
  21. data/lib/cucumber/messages/helpers/id_generator/incrementing.rb +20 -0
  22. data/lib/cucumber/messages/helpers/id_generator/uuid.rb +17 -0
  23. data/lib/cucumber/messages/helpers/id_generator.rb +4 -0
  24. data/lib/cucumber/messages/helpers/ndjson_to_message_enumerator.rb +30 -0
  25. data/lib/cucumber/messages/helpers/time_conversion.rb +31 -0
  26. data/lib/cucumber/messages/hook.rb +56 -0
  27. data/lib/cucumber/messages/hook_type.rb +15 -0
  28. data/lib/cucumber/messages/java_method.rb +46 -0
  29. data/lib/cucumber/messages/java_stack_trace_element.rb +46 -0
  30. data/lib/cucumber/messages/location.rb +44 -0
  31. data/lib/cucumber/messages/message.rb +93 -5
  32. data/lib/cucumber/messages/meta.rb +81 -0
  33. data/lib/cucumber/messages/parameter_type.rb +64 -0
  34. data/lib/cucumber/messages/parse_error.rb +41 -0
  35. data/lib/cucumber/messages/pickle.rb +107 -0
  36. data/lib/cucumber/messages/pickle_doc_string.rb +41 -0
  37. data/lib/cucumber/messages/pickle_step.rb +71 -0
  38. data/lib/cucumber/messages/pickle_step_argument.rb +43 -0
  39. data/lib/cucumber/messages/pickle_step_type.rb +13 -0
  40. data/lib/cucumber/messages/pickle_table.rb +36 -0
  41. data/lib/cucumber/messages/pickle_table_cell.rb +36 -0
  42. data/lib/cucumber/messages/pickle_table_row.rb +36 -0
  43. data/lib/cucumber/messages/pickle_tag.rb +47 -0
  44. data/lib/cucumber/messages/product.rb +49 -0
  45. data/lib/cucumber/messages/rule.rb +72 -0
  46. data/lib/cucumber/messages/rule_child.rb +44 -0
  47. data/lib/cucumber/messages/scenario.rb +74 -0
  48. data/lib/cucumber/messages/source.rb +63 -0
  49. data/lib/cucumber/messages/source_media_type.rb +11 -0
  50. data/lib/cucumber/messages/source_reference.rb +55 -0
  51. data/lib/cucumber/messages/step.rb +80 -0
  52. data/lib/cucumber/messages/step_definition.rb +46 -0
  53. data/lib/cucumber/messages/step_definition_pattern.rb +41 -0
  54. data/lib/cucumber/messages/step_definition_pattern_type.rb +11 -0
  55. data/lib/cucumber/messages/step_keyword_type.rb +14 -0
  56. data/lib/cucumber/messages/step_match_argument.rb +54 -0
  57. data/lib/cucumber/messages/step_match_arguments_list.rb +36 -0
  58. data/lib/cucumber/messages/table_cell.rb +49 -0
  59. data/lib/cucumber/messages/table_row.rb +54 -0
  60. data/lib/cucumber/messages/tag.rb +58 -0
  61. data/lib/cucumber/messages/test_case.rb +62 -0
  62. data/lib/cucumber/messages/test_case_finished.rb +46 -0
  63. data/lib/cucumber/messages/test_case_started.rb +69 -0
  64. data/lib/cucumber/messages/test_run_finished.rb +68 -0
  65. data/lib/cucumber/messages/test_run_hook_finished.rb +49 -0
  66. data/lib/cucumber/messages/test_run_hook_started.rb +60 -0
  67. data/lib/cucumber/messages/test_run_started.rb +41 -0
  68. data/lib/cucumber/messages/test_step.rb +74 -0
  69. data/lib/cucumber/messages/test_step_finished.rb +51 -0
  70. data/lib/cucumber/messages/test_step_result.rb +57 -0
  71. data/lib/cucumber/messages/test_step_result_status.rb +16 -0
  72. data/lib/cucumber/messages/test_step_started.rb +46 -0
  73. data/lib/cucumber/messages/timestamp.rb +52 -0
  74. data/lib/cucumber/messages/undefined_parameter_type.rb +41 -0
  75. data/lib/cucumber/messages.rb +9 -5
  76. metadata +140 -61
  77. data/lib/cucumber/messages/id_generator.rb +0 -24
  78. data/lib/cucumber/messages/message/deserialization.rb +0 -39
  79. data/lib/cucumber/messages/message/serialization.rb +0 -73
  80. data/lib/cucumber/messages/message/utils.rb +0 -46
  81. data/lib/cucumber/messages/ndjson_to_message_enumerator.rb +0 -21
  82. data/lib/cucumber/messages/time_conversion.rb +0 -33
  83. data/lib/cucumber/messages.deserializers.rb +0 -1207
  84. data/lib/cucumber/messages.dtos.rb +0 -2000
  85. data/spec/capture_warnings.rb +0 -74
  86. data/spec/cucumber/messages/acceptance_spec.rb +0 -33
  87. data/spec/cucumber/messages/id_generator_spec.rb +0 -29
  88. data/spec/cucumber/messages/message/deserialization_spec.rb +0 -30
  89. data/spec/cucumber/messages/message/dummy_messages.rb +0 -38
  90. data/spec/cucumber/messages/message/serialization_spec.rb +0 -89
  91. data/spec/cucumber/messages/message/utils_spec.rb +0 -30
  92. data/spec/cucumber/messages/ndjson_serialization_spec.rb +0 -56
  93. data/spec/cucumber/messages/time_conversion_spec.rb +0 -41
  94. data/spec/cucumber/messages/version_spec.rb +0 -11
@@ -1,39 +0,0 @@
1
- require 'cucumber/messages/message/utils'
2
- require 'json'
3
-
4
- module Cucumber
5
- module Messages
6
- class Message
7
- include Cucumber::Messages::Message::Utils
8
-
9
- module Deserialization
10
- def self.included(other)
11
- other.extend(ClassMethods)
12
- end
13
-
14
- module ClassMethods
15
-
16
- ##
17
- # Returns a new Message - or messages into an array - deserialized from the given json document.
18
- # CamelCased keys are properly converted to snake_cased attributes in the process
19
- #
20
- # Cucumber::Messages::Duration.from_json('{"seconds":1,"nanos":42}') # => #<Cucumber::Messages::Duration:0x00007efda134c290 @seconds=1, @nanos=42>
21
- # Cucumber::Messages::PickleTag.from_json('{"name":"foo","astNodeId":"abc-def"}') # => #<Cucumber::Messages::PickleTag:0x00007efda138cdb8 @name="foo", @ast_node_id="abc-def">
22
- #
23
- # It is recursive so embedded messages are also processed.
24
- #
25
- # json_string = { location: { line: 2 }, text: "comment" }.to_json
26
- # Cucumber::Messages::Comment.from_json(json_string) # => #<Cucumber::Messages::Comment:0x00007efda6abf888 @location=#<Cucumber::Messages::Location:0x00007efda6abf978 @line=2, @column=nil>, @text="comment">
27
- #
28
- # json_string = { uri: 'file:///...', comments: [{text: 'text comment'}, {text: 'another comment'}]}.to_json
29
- # Cucumber::Messages::GherkinDocument.from_json(json_string) # => #<Cucumber::Messages::GherkinDocument:0x00007efda11e6a90 ... @comments=[#<Cucumber::Messages::Comment:0x00007efda11e6e50 ..., #<Cucumber::Messages::Comment:0x00007efda11e6b58 ...>]>
30
- #
31
-
32
- def from_json(json_string)
33
- from_h(JSON.parse(json_string, { symbolize_names: true }))
34
- end
35
- end
36
- end
37
- end
38
- end
39
- end
@@ -1,73 +0,0 @@
1
- require 'cucumber/messages/message/utils'
2
- require 'json'
3
-
4
- module Cucumber
5
- module Messages
6
- class Message
7
- include Cucumber::Messages::Message::Utils
8
-
9
- module Serialization
10
-
11
- ##
12
- # Returns a new Hash formed from the message attributes
13
- # If +camelize:+ keyword parameter is set to true, then keys will be camelized
14
- # If +reject_nil_values:+ keyword parameter is set to true, resulting hash won't include nil values
15
- #
16
- # Cucumber::Messages::Duration.new(seconds: 1, nanos: 42).to_h # => { seconds: 1, nanos: 42 }
17
- # Cucumber::Messages::PickleTag.new(name: 'foo', ast_node_id: 'abc-def').to_h(camelize: true) # => { name: 'foo', astNodeId: 'abc-def' }
18
- # Cucumber::Messages::PickleTag.new(name: 'foo', ast_node_id: nil).to_h(reject_nil_values: true) # => { name: 'foo' }
19
- #
20
- # It is recursive so embedded messages are also processed
21
- #
22
- # location = Cucumber::Messages::Location.new(line: 2)
23
- # Cucumber::Messages::Comment.new(location: location, text: 'comment').to_h # => { location: { line: 2, :column: nil }, text: "comment" }
24
- #
25
-
26
- def to_h(camelize: false, reject_nil_values: false)
27
- resulting_hash = self.instance_variables.map do |variable_name|
28
- h_key = variable_name[1..-1]
29
- h_key = Cucumber::Messages::Message.camelize(h_key) if camelize
30
-
31
- h_value = prepare_value(
32
- self.instance_variable_get(variable_name),
33
- camelize: camelize,
34
- reject_nil_values: reject_nil_values
35
- )
36
-
37
- [ h_key.to_sym, h_value ]
38
- end.to_h
39
-
40
- resulting_hash.reject! { |_, value| value.nil? } if reject_nil_values
41
- resulting_hash
42
- end
43
-
44
- ##
45
- # Generates a JSON document from the message.
46
- # Keys are camelized during the process. Null values are not part of the json document.
47
- #
48
- # Cucumber::Messages::Duration.new(seconds: 1, nanos: 42).to_json # => '{"seconds":1,"nanos":42}'
49
- # Cucumber::Messages::PickleTag.new(name: 'foo', ast_node_id: 'abc-def').to_json # => '{"name":"foo","astNodeId":"abc-def"}'
50
- # Cucumber::Messages::PickleTag.new(name: 'foo', ast_node_id: nil).to_json # => '{"name":"foo"}'
51
- #
52
- # As #to_h, the method is recursive
53
- #
54
- # location = Cucumber::Messages::Location.new(line: 2)
55
- # Cucumber::Messages::Comment.new(location: location, text: 'comment').to_json # => '{"location":{"line":2,"column":null},"text":"comment"}'
56
- #
57
-
58
- def to_json
59
- to_h(camelize: true, reject_nil_values: true).to_json
60
- end
61
-
62
- private
63
-
64
- def prepare_value(value, camelize:, reject_nil_values:)
65
- return value.to_h(camelize: camelize, reject_nil_values: reject_nil_values) if value.is_a?(Cucumber::Messages::Message)
66
- return value.map { |v| prepare_value(v, camelize: camelize, reject_nil_values: reject_nil_values) } if value.is_a?(Array)
67
-
68
- value
69
- end
70
- end
71
- end
72
- end
73
- end
@@ -1,46 +0,0 @@
1
- module Cucumber
2
- module Messages
3
- class Message
4
- module Utils
5
- def self.included(other)
6
- other.extend(ClassMethods)
7
- end
8
-
9
- module ClassMethods
10
-
11
- ##
12
- # Makes an underscored, lowercase form from the expression in the string.
13
- #
14
- # underscore('GherkinDocument') # => "gherkin_document"
15
- #
16
- # This is a simplified version of the Ruby on Rails implementation
17
- # https://github.com/rails/rails/blob/v6.1.3.2/activesupport/lib/active_support/inflector/methods.rb#L92
18
-
19
- def underscore(term)
20
- return term unless /[A-Z-]/.match?(term)
21
-
22
- word = term.gsub(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2')
23
- word.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
24
- word.tr!("-", "_")
25
- word.downcase!
26
- word
27
- end
28
-
29
- ##
30
- # Converts strings to UpperCamelCase.
31
- #
32
- # camelize('gherkin_document') # => "GherkinDocument"
33
- #
34
- # This is a simplified version of the Ruby on Rails implementation
35
- # https://github.com/rails/rails/blob/v6.1.3.2/activesupport/lib/active_support/inflector/methods.rb#L69
36
-
37
- def camelize(term)
38
- camelized = term.to_s
39
- camelized.gsub!(/(?:_|(\/))([a-z\d]*)/i) { "#{$1}#{$2.capitalize}" }
40
- camelized
41
- end
42
- end
43
- end
44
- end
45
- end
46
- end
@@ -1,21 +0,0 @@
1
- require 'cucumber/messages.deserializers'
2
-
3
- module Cucumber
4
- module Messages
5
- class NdjsonToMessageEnumerator < Enumerator
6
- def initialize(io)
7
- super() do |yielder|
8
- io.each_line do |line|
9
- next if line.strip.empty?
10
- begin
11
- m = Envelope.from_json(line)
12
- rescue => e
13
- raise "Not JSON: #{line.strip}"
14
- end
15
- yielder.yield(m)
16
- end
17
- end
18
- end
19
- end
20
- end
21
- end
@@ -1,33 +0,0 @@
1
- module Cucumber
2
- module Messages
3
- module TimeConversion
4
- NANOSECONDS_PER_SECOND = 1000000000
5
-
6
- def time_to_timestamp(time)
7
- {
8
- 'seconds' => time.to_i,
9
- 'nanos' => time.nsec
10
- }
11
- end
12
-
13
- def timestamp_to_time(timestamp)
14
- Time.at(timestamp['seconds'] + timestamp['nanos'].to_f / NANOSECONDS_PER_SECOND)
15
- end
16
-
17
- def seconds_to_duration(seconds_float)
18
- seconds, second_modulus = seconds_float.divmod(1)
19
- nanos = second_modulus * NANOSECONDS_PER_SECOND
20
- {
21
- 'seconds' => seconds,
22
- 'nanos' => nanos.to_i
23
- }
24
- end
25
-
26
- def duration_to_seconds(duration)
27
- seconds_part = duration['seconds']
28
- nanos_part = duration['nanos'].to_f / NANOSECONDS_PER_SECOND
29
- seconds_part + nanos_part
30
- end
31
- end
32
- end
33
- end