cucumber-messages 0.0.0 → 1.0.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.
data/messages.proto ADDED
@@ -0,0 +1,243 @@
1
+ syntax = "proto3";
2
+ import "google/protobuf/timestamp.proto";
3
+ package io.cucumber.messages;
4
+ option ruby_package = "Cucumber.Messages";
5
+ option go_package = "messages";
6
+
7
+ // All messages sent between processes must be of type Wrapper
8
+ message Wrapper {
9
+ oneof message {
10
+ Source source = 1;
11
+ GherkinDocument gherkinDocument = 2;
12
+ Pickle pickle = 3;
13
+ Attachment attachment = 4;
14
+ TestCaseStarted testCaseStarted = 5;
15
+ TestStepStarted testStepStarted = 6;
16
+ TestStepFinished testStepFinished = 7;
17
+ TestCaseFinished testCaseFinished = 8;
18
+ }
19
+ }
20
+
21
+ ////// Source
22
+
23
+ message SourceReference {
24
+ string uri = 1;
25
+ Location location = 2;
26
+ }
27
+
28
+ message Location {
29
+ uint32 line = 1;
30
+ uint32 column = 2;
31
+ }
32
+
33
+ message Attachment {
34
+ SourceReference source = 1;
35
+ string data = 2;
36
+ Media media = 3;
37
+ }
38
+
39
+ message Media {
40
+ string encoding = 1;
41
+ string content_type = 2;
42
+ }
43
+
44
+ message Source {
45
+ string uri = 1;
46
+ string data = 2;
47
+ Media media = 3;
48
+ }
49
+
50
+ ////// Gherkin
51
+
52
+ message GherkinDocument {
53
+ string uri = 1;
54
+ Feature feature = 2;
55
+ repeated Comment comments = 3;
56
+ }
57
+
58
+ message Feature {
59
+ Location location = 1;
60
+ repeated Tag tags = 2;
61
+ string language = 3;
62
+ string keyword = 4;
63
+ string name = 5;
64
+ string description = 6;
65
+ repeated FeatureChild children = 7;
66
+ }
67
+
68
+ message FeatureChild {
69
+ oneof value {
70
+ Rule rule = 1;
71
+ Background background = 2;
72
+ Scenario scenario = 3;
73
+ }
74
+ }
75
+
76
+ message Rule {
77
+ Location location = 1;
78
+ string keyword = 2;
79
+ string name = 3;
80
+ string description = 4;
81
+ repeated RuleChild children = 5;
82
+ }
83
+
84
+ message RuleChild {
85
+ oneof value {
86
+ Background background = 1;
87
+ Scenario scenario = 2;
88
+ }
89
+ }
90
+
91
+ message Background {
92
+ Location location = 1;
93
+ string keyword = 2;
94
+ string name = 3;
95
+ string description = 4;
96
+ repeated Step steps = 5;
97
+ }
98
+
99
+ message Scenario {
100
+ Location location = 1;
101
+ repeated Tag tags = 2;
102
+ string keyword = 3;
103
+ string name = 4;
104
+ string description = 5;
105
+ repeated Step steps = 6;
106
+ repeated Examples examples = 7;
107
+ }
108
+
109
+ message Comment {
110
+ Location location = 1;
111
+ string text = 2;
112
+ }
113
+
114
+ message DataTable {
115
+ Location location = 1;
116
+ repeated TableRow rows = 2;
117
+ }
118
+
119
+ message DocString {
120
+ Location location = 1;
121
+ string content_type = 2;
122
+ string content = 3;
123
+ string delimiter = 4;
124
+ }
125
+
126
+ message Examples {
127
+ Location location = 1;
128
+ repeated Tag tags = 2;
129
+ string keyword = 3;
130
+ string name = 4;
131
+ string description = 5;
132
+ TableRow table_header = 6;
133
+ repeated TableRow table_body = 7;
134
+ }
135
+
136
+ message Step {
137
+ Location location = 1;
138
+ string keyword = 2;
139
+ string text = 3;
140
+ oneof argument {
141
+ DocString doc_string = 5;
142
+ DataTable data_table = 6;
143
+ }
144
+ }
145
+
146
+ message TableCell {
147
+ Location location = 1;
148
+ string value = 2;
149
+ }
150
+
151
+ message TableRow {
152
+ Location location = 1;
153
+ repeated TableCell cells = 2;
154
+ }
155
+
156
+ message Tag {
157
+ Location location = 1;
158
+ string name = 2;
159
+ }
160
+
161
+ ////// Pickles
162
+
163
+ message Pickle {
164
+ string id = 1;
165
+ string uri = 2;
166
+ string name = 3;
167
+ string language = 4;
168
+ repeated PickleStep steps = 5;
169
+ repeated PickleTag tags = 6;
170
+ repeated Location locations = 7;
171
+ }
172
+
173
+ message PickleStep {
174
+ string text = 1;
175
+ repeated Location locations = 2;
176
+ oneof argument {
177
+ PickleDocString doc_string = 3;
178
+ PickleTable data_table = 4;
179
+ }
180
+ }
181
+
182
+ message PickleDocString {
183
+ Location location = 1;
184
+ string contentType = 2;
185
+ string content = 3;
186
+ }
187
+
188
+ message PickleTable {
189
+ repeated PickleTableRow rows = 1;
190
+ }
191
+
192
+ message PickleTableCell {
193
+ Location location = 1;
194
+ string value = 2;
195
+ }
196
+
197
+ message PickleTableRow {
198
+ repeated PickleTableCell cells = 1;
199
+ }
200
+
201
+ message PickleTag {
202
+ Location location = 1;
203
+ string name = 2;
204
+ }
205
+
206
+ ////// Results
207
+
208
+ message TestCaseStarted {
209
+ string pickleId = 1;
210
+ google.protobuf.Timestamp timestamp = 2;
211
+ }
212
+
213
+ message TestCaseFinished {
214
+ string pickleId = 1;
215
+ google.protobuf.Timestamp timestamp = 2;
216
+ }
217
+
218
+ message TestStepStarted {
219
+ string pickleId = 1;
220
+ uint32 index = 2;
221
+ google.protobuf.Timestamp timestamp = 3;
222
+ }
223
+
224
+ message TestStepFinished {
225
+ string pickleId = 1;
226
+ uint32 index = 2;
227
+ TestResult testResult = 3;
228
+ google.protobuf.Timestamp timestamp = 4;
229
+ }
230
+
231
+ message TestResult {
232
+ Status status = 1;
233
+ string message = 2;
234
+ }
235
+
236
+ enum Status {
237
+ AMBIGUOUS = 0;
238
+ FAILED = 1;
239
+ PASSED = 2;
240
+ PENDING = 3;
241
+ SKIPPED = 4;
242
+ UNDEFINED = 5;
243
+ }
@@ -0,0 +1,74 @@
1
+ # frozen_string_literal: true
2
+ # With thanks to @myronmarston
3
+ # https://github.com/vcr/vcr/blob/master/spec/capture_warnings.rb
4
+
5
+ module CaptureWarnings
6
+ def report_warnings(&block)
7
+ current_dir = Dir.pwd
8
+ warnings, errors = capture_error(&block).partition { |line| line.include?('warning') }
9
+ project_warnings, other_warnings = warnings.uniq.partition { |line| line.include?(current_dir) }
10
+
11
+ if errors.any?
12
+ puts errors.join("\n")
13
+ end
14
+
15
+ if other_warnings.any?
16
+ puts "#{ other_warnings.count } warnings detected, set VIEW_OTHER_WARNINGS=true to see them."
17
+ print_warnings('other', other_warnings) if ENV['VIEW_OTHER_WARNINGS']
18
+ end
19
+
20
+ # Until they fix https://bugs.ruby-lang.org/issues/10661
21
+ if RUBY_VERSION == "2.2.0"
22
+ project_warnings = project_warnings.reject { |w| w =~ /warning: possible reference to past scope/ }
23
+ end
24
+
25
+ if project_warnings.any?
26
+ puts "#{ project_warnings.count } warnings detected"
27
+ print_warnings('cucumber-expressions', project_warnings)
28
+ fail "Please remove all cucumber-expressions warnings."
29
+ end
30
+
31
+ ensure_system_exit_if_required
32
+ end
33
+
34
+ def capture_error(&block)
35
+ old_stderr = STDERR.clone
36
+ pipe_r, pipe_w = IO.pipe
37
+ pipe_r.sync = true
38
+ error = String.new
39
+ reader = Thread.new do
40
+ begin
41
+ loop do
42
+ error << pipe_r.readpartial(1024)
43
+ end
44
+ rescue EOFError
45
+ end
46
+ end
47
+ STDERR.reopen(pipe_w)
48
+ block.call
49
+ ensure
50
+ capture_system_exit
51
+ STDERR.reopen(old_stderr)
52
+ pipe_w.close
53
+ reader.join
54
+ return error.split("\n")
55
+ end
56
+
57
+ def print_warnings(type, warnings)
58
+ puts
59
+ puts "-" * 30 + " #{type} warnings: " + "-" * 30
60
+ puts
61
+ puts warnings.join("\n")
62
+ puts
63
+ puts "-" * 75
64
+ puts
65
+ end
66
+
67
+ def ensure_system_exit_if_required
68
+ raise @system_exit if @system_exit
69
+ end
70
+
71
+ def capture_system_exit
72
+ @system_exit = $!
73
+ end
74
+ end
data/spec/coverage.rb ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+ require 'simplecov'
3
+ formatters = [ SimpleCov::Formatter::HTMLFormatter ]
4
+
5
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(*formatters)
6
+ SimpleCov.add_filter 'spec/'
7
+ SimpleCov.start
@@ -0,0 +1,23 @@
1
+ require 'cucumber/messages_pb'
2
+ require 'json'
3
+
4
+ module Cucumber
5
+ module Messages
6
+ describe Messages do
7
+ it "builds a pickle doc string" do
8
+ location = Location.new(line: 10, column: 20)
9
+ pickle_doc_tring = PickleDocString.new(
10
+ location: location,
11
+ contentType: 'text/plain',
12
+ content: 'some\ncontent\n'
13
+ )
14
+ expect(JSON.parse(PickleDocString.encode_json(pickle_doc_tring)))
15
+ .to(eq(
16
+ 'location' => { 'line' => 10, 'column' => 20 },
17
+ 'contentType' => 'text/plain',
18
+ 'content' => 'some\ncontent\n'
19
+ ))
20
+ end
21
+ end
22
+ end
23
+ end
metadata CHANGED
@@ -1,118 +1,114 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucumber-messages
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aslak Hellesøy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-25 00:00:00.000000000 Z
11
+ date: 2018-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: cucumber-compatibility-kit
14
+ name: google-protobuf
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: '12.0'
20
- type: :development
19
+ version: 3.6.1
20
+ type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: '12.0'
26
+ version: 3.6.1
27
27
  - !ruby/object:Gem::Dependency
28
- name: rake
28
+ name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '13.0'
34
31
  - - ">="
35
32
  - !ruby/object:Gem::Version
36
- version: 13.0.6
33
+ version: '0'
37
34
  type: :development
38
35
  prerelease: false
39
36
  version_requirements: !ruby/object:Gem::Requirement
40
37
  requirements:
41
- - - "~>"
42
- - !ruby/object:Gem::Version
43
- version: '13.0'
44
38
  - - ">="
45
39
  - !ruby/object:Gem::Version
46
- version: 13.0.6
40
+ version: '0'
47
41
  - !ruby/object:Gem::Dependency
48
- name: rspec
42
+ name: rake
49
43
  requirement: !ruby/object:Gem::Requirement
50
44
  requirements:
51
45
  - - "~>"
52
46
  - !ruby/object:Gem::Version
53
- version: '3.12'
47
+ version: '12.3'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
51
  requirements:
58
52
  - - "~>"
59
53
  - !ruby/object:Gem::Version
60
- version: '3.12'
54
+ version: '12.3'
61
55
  - !ruby/object:Gem::Dependency
62
- name: rubocop
56
+ name: rspec
63
57
  requirement: !ruby/object:Gem::Requirement
64
58
  requirements:
65
59
  - - "~>"
66
60
  - !ruby/object:Gem::Version
67
- version: 1.28.0
61
+ version: '3.7'
68
62
  type: :development
69
63
  prerelease: false
70
64
  version_requirements: !ruby/object:Gem::Requirement
71
65
  requirements:
72
66
  - - "~>"
73
67
  - !ruby/object:Gem::Version
74
- version: 1.28.0
68
+ version: '3.7'
75
69
  - !ruby/object:Gem::Dependency
76
- name: rubocop-rspec
70
+ name: coveralls
77
71
  requirement: !ruby/object:Gem::Requirement
78
72
  requirements:
79
- - - "~>"
73
+ - - ">="
80
74
  - !ruby/object:Gem::Version
81
- version: 2.5.0
75
+ version: '0'
82
76
  type: :development
83
77
  prerelease: false
84
78
  version_requirements: !ruby/object:Gem::Requirement
85
79
  requirements:
86
- - - "~>"
80
+ - - ">="
87
81
  - !ruby/object:Gem::Version
88
- version: 2.5.0
89
- description: JSON schema-based messages for Cucumber's inter-process communication
82
+ version: '0'
83
+ description: Protocol Buffer messages for Cucumber's inter-process communication
90
84
  email: cukes@googlegroups.com
91
85
  executables: []
92
86
  extensions: []
93
87
  extra_rdoc_files: []
94
88
  files:
89
+ - ".github/ISSUE_TEMPLATE.md"
90
+ - ".github/PULL_REQUEST_TEMPLATE.md"
91
+ - ".rspec"
92
+ - ".rsync"
93
+ - ".subrepo"
94
+ - ".travis.yml"
95
+ - Gemfile
96
+ - LICENSE
97
+ - Makefile
95
98
  - README.md
96
- - VERSION
97
- - lib/cucumber/messages.deserializers.rb
98
- - lib/cucumber/messages.dtos.rb
99
+ - Rakefile
100
+ - cucumber-messages.gemspec
101
+ - default.mk
99
102
  - lib/cucumber/messages.rb
100
- - lib/cucumber/messages/id_generator.rb
101
- - lib/cucumber/messages/message.rb
102
- - lib/cucumber/messages/message/deserialization.rb
103
- - lib/cucumber/messages/message/serialization.rb
104
- - lib/cucumber/messages/message/utils.rb
105
- - lib/cucumber/messages/ndjson_to_message_enumerator.rb
106
- - lib/cucumber/messages/time_conversion.rb
107
- homepage: https://github.com/cucumber/messages-ruby#readme
103
+ - lib/cucumber/messages_pb.rb
104
+ - messages.proto
105
+ - spec/capture_warnings.rb
106
+ - spec/coverage.rb
107
+ - spec/cucumber/messages/messages_spec.rb
108
+ homepage: https://github.com/cucumber/cucumber-messages-ruby#readme
108
109
  licenses:
109
110
  - MIT
110
- metadata:
111
- bug_tracker_uri: https://github.com/cucumber/messages/issues
112
- changelog_uri: https://github.com/cucumber/messages/blob/main/CHANGELOG.md
113
- documentation_uri: https://www.rubydoc.info/github/cucumber/messages
114
- mailing_list_uri: https://groups.google.com/forum/#!forum/cukes
115
- source_code_uri: https://github.com/cucumber/messages
111
+ metadata: {}
116
112
  post_install_message:
117
113
  rdoc_options:
118
114
  - "--charset=UTF-8"
@@ -122,15 +118,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
122
118
  requirements:
123
119
  - - ">="
124
120
  - !ruby/object:Gem::Version
125
- version: '2.5'
121
+ version: 1.9.3
126
122
  required_rubygems_version: !ruby/object:Gem::Requirement
127
123
  requirements:
128
124
  - - ">="
129
125
  - !ruby/object:Gem::Version
130
- version: 3.0.0
126
+ version: '0'
131
127
  requirements: []
132
- rubygems_version: 3.4.10
128
+ rubyforge_project:
129
+ rubygems_version: 2.7.6
133
130
  signing_key:
134
131
  specification_version: 4
135
- summary: cucumber-messages-0.0.0
136
- test_files: []
132
+ summary: cucumber-messages-1.0.0
133
+ test_files:
134
+ - spec/capture_warnings.rb
135
+ - spec/coverage.rb
136
+ - spec/cucumber/messages/messages_spec.rb
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.0.0
@@ -1,24 +0,0 @@
1
- require 'securerandom'
2
-
3
- module Cucumber
4
- module Messages
5
- module IdGenerator
6
- class Incrementing
7
- def initialize
8
- @index = -1
9
- end
10
-
11
- def new_id
12
- @index += 1
13
- @index.to_s
14
- end
15
- end
16
-
17
- class UUID
18
- def new_id
19
- SecureRandom.uuid
20
- end
21
- end
22
- end
23
- end
24
- end
@@ -1,37 +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
- # Returns a new Message - or messages into an array - deserialized from the given json document.
17
- # CamelCased keys are properly converted to snake_cased attributes in the process
18
- #
19
- # Cucumber::Messages::Duration.from_json('{"seconds":1,"nanos":42}') # => #<Cucumber::Messages::Duration:0x00007efda134c290 @seconds=1, @nanos=42>
20
- # Cucumber::Messages::PickleTag.from_json('{"name":"foo","astNodeId":"abc-def"}') # => #<Cucumber::Messages::PickleTag:0x00007efda138cdb8 @name="foo", @ast_node_id="abc-def">
21
- #
22
- # It is recursive so embedded messages are also processed.
23
- #
24
- # json_string = { location: { line: 2 }, text: "comment" }.to_json
25
- # Cucumber::Messages::Comment.from_json(json_string) # => #<Cucumber::Messages::Comment:0x00007efda6abf888 @location=#<Cucumber::Messages::Location:0x00007efda6abf978 @line=2, @column=nil>, @text="comment">
26
- #
27
- # json_string = { uri: 'file:///...', comments: [{text: 'text comment'}, {text: 'another comment'}]}.to_json
28
- # Cucumber::Messages::GherkinDocument.from_json(json_string) # => #<Cucumber::Messages::GherkinDocument:0x00007efda11e6a90 ... @comments=[#<Cucumber::Messages::Comment:0x00007efda11e6e50 ..., #<Cucumber::Messages::Comment:0x00007efda11e6b58 ...>]>
29
- ##
30
- def from_json(json_string)
31
- from_h(JSON.parse(json_string, { symbolize_names: true }))
32
- end
33
- end
34
- end
35
- end
36
- end
37
- end
@@ -1,70 +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
- # Returns a new Hash formed from the message attributes
12
- # If +camelize:+ keyword parameter is set to true, then keys will be camelized
13
- # If +reject_nil_values:+ keyword parameter is set to true, resulting hash won't include nil values
14
- #
15
- # Cucumber::Messages::Duration.new(seconds: 1, nanos: 42).to_h # => { seconds: 1, nanos: 42 }
16
- # Cucumber::Messages::PickleTag.new(name: 'foo', ast_node_id: 'abc-def').to_h(camelize: true) # => { name: 'foo', astNodeId: 'abc-def' }
17
- # Cucumber::Messages::PickleTag.new(name: 'foo', ast_node_id: nil).to_h(reject_nil_values: true) # => { name: 'foo' }
18
- #
19
- # It is recursive so embedded messages are also processed
20
- #
21
- # location = Cucumber::Messages::Location.new(line: 2)
22
- # Cucumber::Messages::Comment.new(location: location, text: 'comment').to_h # => { location: { line: 2, :column: nil }, text: "comment" }
23
- ##
24
- def to_h(camelize: false, reject_nil_values: false)
25
- resulting_hash = self.instance_variables.map do |variable_name|
26
- h_key = variable_name[1..-1]
27
- h_key = Cucumber::Messages::Message.camelize(h_key) if camelize
28
-
29
- h_value = prepare_value(
30
- self.instance_variable_get(variable_name),
31
- camelize: camelize,
32
- reject_nil_values: reject_nil_values
33
- )
34
-
35
- [ h_key.to_sym, h_value ]
36
- end.to_h
37
-
38
- resulting_hash.reject! { |_, value| value.nil? } if reject_nil_values
39
- resulting_hash
40
- end
41
-
42
- ##
43
- # Generates a JSON document from the message.
44
- # Keys are camelized during the process. Null values are not part of the json document.
45
- #
46
- # Cucumber::Messages::Duration.new(seconds: 1, nanos: 42).to_json # => '{"seconds":1,"nanos":42}'
47
- # Cucumber::Messages::PickleTag.new(name: 'foo', ast_node_id: 'abc-def').to_json # => '{"name":"foo","astNodeId":"abc-def"}'
48
- # Cucumber::Messages::PickleTag.new(name: 'foo', ast_node_id: nil).to_json # => '{"name":"foo"}'
49
- #
50
- # As #to_h, the method is recursive
51
- #
52
- # location = Cucumber::Messages::Location.new(line: 2)
53
- # Cucumber::Messages::Comment.new(location: location, text: 'comment').to_json # => '{"location":{"line":2,"column":null},"text":"comment"}'
54
- ##
55
- def to_json
56
- to_h(camelize: true, reject_nil_values: true).to_json
57
- end
58
-
59
- private
60
-
61
- def prepare_value(value, camelize:, reject_nil_values:)
62
- return value.to_h(camelize: camelize, reject_nil_values: reject_nil_values) if value.is_a?(Cucumber::Messages::Message)
63
- return value.map { |v| prepare_value(v, camelize: camelize, reject_nil_values: reject_nil_values) } if value.is_a?(Array)
64
-
65
- value
66
- end
67
- end
68
- end
69
- end
70
- end