cucumber-messages 0.0.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,45 +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
- # Makes an underscored, lowercase form from the expression in the string.
12
- #
13
- # underscore('GherkinDocument') # => "gherkin_document"
14
- #
15
- # This is a simplified version of the Ruby on Rails implementation
16
- # https://github.com/rails/rails/blob/v6.1.3.2/activesupport/lib/active_support/inflector/methods.rb#L92
17
- ##
18
- def underscore(term)
19
- return term unless /[A-Z-]/.match?(term)
20
-
21
- word = term.gsub(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2')
22
- word.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
23
- word.tr!("-", "_")
24
- word.downcase!
25
- word
26
- end
27
-
28
- ##
29
- # Converts strings to UpperCamelCase.
30
- #
31
- # camelize('gherkin_document') # => "GherkinDocument"
32
- #
33
- # This is a simplified version of the Ruby on Rails implementation
34
- # https://github.com/rails/rails/blob/v6.1.3.2/activesupport/lib/active_support/inflector/methods.rb#L69
35
- ##
36
- def camelize(term)
37
- camelized = term.to_s
38
- camelized.gsub!(/(?:_|(\/))([a-z\d]*)/i) { "#{$1}#{$2.capitalize}" }
39
- camelized
40
- end
41
- end
42
- end
43
- end
44
- end
45
- end
@@ -1,11 +0,0 @@
1
- require 'cucumber/messages/message/deserialization'
2
- require 'cucumber/messages/message/serialization'
3
-
4
- module Cucumber
5
- module Messages
6
- class Message
7
- include Cucumber::Messages::Message::Deserialization
8
- include Cucumber::Messages::Message::Serialization
9
- end
10
- end
11
- 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