rookout 0.1.36 → 0.1.39

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rookout/augs/actions/action_run_processor.rb +1 -0
  3. data/lib/rookout/augs/aug.rb +3 -5
  4. data/lib/rookout/augs/aug_factory.rb +40 -16
  5. data/lib/rookout/augs/aug_rate_limiter.rb +35 -36
  6. data/lib/rookout/augs/limits_manager.rb +31 -0
  7. data/lib/rookout/augs/locations/location_file_line.rb +5 -1
  8. data/lib/rookout/com_ws/agent_com_ws.rb +4 -3
  9. data/lib/rookout/com_ws/envelope_wrapper.rb +7 -5
  10. data/lib/rookout/com_ws/git.rb +1 -1
  11. data/lib/rookout/com_ws/information.rb +2 -1
  12. data/lib/rookout/com_ws/output.rb +13 -7
  13. data/lib/rookout/commit.rb +1 -1
  14. data/lib/rookout/config.rb +55 -17
  15. data/lib/rookout/exceptions.rb +12 -9
  16. data/lib/rookout/interface.rb +9 -8
  17. data/lib/rookout/logger.rb +13 -7
  18. data/lib/rookout/processor/namespace_serializer.rb +1 -1
  19. data/lib/rookout/processor/namespace_serializer2.rb +26 -12
  20. data/lib/rookout/processor/namespaces/container_namespace.rb +1 -0
  21. data/lib/rookout/processor/namespaces/frame_namespace.rb +2 -3
  22. data/lib/rookout/processor/namespaces/namespace.rb +1 -0
  23. data/lib/rookout/processor/namespaces/noop_namespace.rb +0 -4
  24. data/lib/rookout/processor/namespaces/ruby_object_namespace.rb +31 -16
  25. data/lib/rookout/processor/namespaces/ruby_object_serializer.rb +9 -7
  26. data/lib/rookout/processor/namespaces/ruby_utils_namespace.rb +0 -4
  27. data/lib/rookout/processor/namespaces/stack_namespace.rb +1 -0
  28. data/lib/rookout/processor/namespaces/traceback_namespace.rb +4 -1
  29. data/lib/rookout/processor/operations/set_operation.rb +2 -0
  30. data/lib/rookout/processor/paths/arithmetic_path.rb +3 -1
  31. data/lib/rookout/processor/paths/canopy/actions.rb +5 -1
  32. data/lib/rookout/processor/paths/canopy/consts.rb +6 -4
  33. data/lib/rookout/processor/paths/canopy/markers.rb +15 -5
  34. data/lib/rookout/processor/processor_factory.rb +0 -2
  35. data/lib/rookout/processor/rook_error.rb +3 -1
  36. data/lib/rookout/rookout_singleton.rb +3 -2
  37. data/lib/rookout/sanitizer.rb +22 -0
  38. data/lib/rookout/services/position.rb +3 -2
  39. data/lib/rookout/services/tracer.rb +2 -2
  40. data/lib/rookout/utils.rb +7 -1
  41. data/lib/rookout/version.rb +1 -1
  42. data/lib/rookout.rb +4 -0
  43. metadata +41 -11
@@ -66,7 +66,7 @@ module Rookout
66
66
 
67
67
  arguments.each do |argument|
68
68
  if argument.is_a? Exception
69
- @formatted_message += "\n" + argument.message + "\n" + argument.backtrace.join("\n\t")
69
+ @formatted_message += "\n#{argument.message}\n#{argument.backtrace.join "\n\t"}"
70
70
  end
71
71
  end
72
72
 
@@ -74,7 +74,13 @@ module Rookout
74
74
  set_caller
75
75
  end
76
76
 
77
- attr_reader :level, :time, :filename, :lineno, :message, :formatted_message, :arguments
77
+ attr_reader :level
78
+ attr_reader :time
79
+ attr_reader :filename
80
+ attr_reader :lineno
81
+ attr_reader :message
82
+ attr_reader :formatted_message
83
+ attr_reader :arguments
78
84
 
79
85
  def format
80
86
  "#{@time} #{Process.pid}:#{Thread.current.name}-" \
@@ -137,19 +143,19 @@ module Rookout
137
143
  file = nil
138
144
 
139
145
  if Config.debug
140
- STDERR.puts "[Rookout] Failed to open log file: #{log_file_path}"
141
- STDERR.puts e.backtrace
146
+ $stderr.puts "[Rookout] Failed to open log file: #{log_file_path}"
147
+ $stderr.puts e.backtrace
142
148
  end
143
149
  end
144
150
 
145
- ->(record) { file.write record.format + "\n" if file }
151
+ ->(record) { file.write "#{record.format}\n" if file }
146
152
  end
147
153
 
148
154
  def calculate_log_file_path
149
155
  return Config.logger_filename if absolute_path? Config.logger_filename
150
156
 
151
157
  if RUBY_PLATFORM.include? "darwin"
152
- File.join ENV["HOME"], Config.logger_filename
158
+ File.join Dir.home, Config.logger_filename
153
159
  elsif RUBY_PLATFORM.match?(/cygwin|mswin|mingw|bccwin|wince|emx/)
154
160
  File.join ENV["USERPROFILE"], Config.logger_filename
155
161
  else
@@ -158,7 +164,7 @@ module Rookout
158
164
  end
159
165
 
160
166
  def new_stderr_handler
161
- ->(record) { STDERR.puts record.format }
167
+ ->(record) { $stderr.puts record.format }
162
168
  end
163
169
 
164
170
  def new_remote_handler
@@ -7,7 +7,7 @@ module Rookout
7
7
 
8
8
  module_function
9
9
 
10
- def dump namespace, log_errors = true
10
+ def dump namespace, log_errors
11
11
  namespace.dump log_errors
12
12
  rescue StandardError => e
13
13
  message = "Failed to serialize namespace"
@@ -9,12 +9,20 @@ module Rookout
9
9
  require_relative "./namespaces/container_namespace"
10
10
  require_relative "./namespaces/traceback_namespace"
11
11
 
12
+ begin
13
+ require "hashie/mash"
14
+ MASH = ::Hashie::Mash
15
+ rescue LoadError
16
+ MASH = nil
17
+ end
18
+
12
19
  def initialize
13
20
  @string_cache = {}
14
21
  @estimated_pending_bytes = 0
15
22
  end
16
23
 
17
- attr_reader :string_cache, :estimated_pending_bytes
24
+ attr_reader :string_cache
25
+ attr_reader :estimated_pending_bytes
18
26
 
19
27
  def get_string_index_in_cache str
20
28
  if @string_cache.key? str
@@ -35,13 +43,16 @@ module Rookout
35
43
  variant.variant_type_max_depth = (type << 1) | 1
36
44
  end
37
45
 
38
- def dump namespace, log_errors = true
39
- if namespace.is_a? Namespaces::RubyObjectNamespace
46
+ def dump namespace, log_errors
47
+ case namespace
48
+ when Namespaces::RubyObjectNamespace
40
49
  dump_ruby_object_namespace namespace, log_errors
41
- elsif namespace.is_a? Namespaces::ContainerNamespace
50
+ when Namespaces::ContainerNamespace
42
51
  dump_container_namespace namespace, log_errors
43
- elsif namespace.is_a? Namespaces::TracebackNamespace
52
+ when Namespaces::TracebackNamespace
44
53
  dump_traceback_namespace namespace
54
+ else
55
+ raise NotImplementedError
45
56
  end
46
57
  rescue StandardError => e
47
58
  message = "Failed to serialize namespace"
@@ -80,6 +91,7 @@ module Rookout
80
91
  # rubocop:disable Metrics/AbcSize
81
92
  # rubocop:disable Metrics/PerceivedComplexity
82
93
  # rubocop:disable Metrics/CyclomaticComplexity
94
+ # rubocop:disable Style/ClassEqualityComparison
83
95
  def unsafe_dump_object obj, current_depth, config, log_object_errors
84
96
  variant = Com::Rookout::Variant2.new original_type_index_in_cache: get_string_index_in_cache(obj.class.to_s)
85
97
 
@@ -93,7 +105,7 @@ module Rookout
93
105
  dump_time obj, variant
94
106
  elsif obj.class == Array
95
107
  dump_array obj, variant, current_depth, config, log_object_errors
96
- elsif obj.class == Hash
108
+ elsif obj.class == Hash || (!MASH.nil? && obj.is_a?(MASH))
97
109
  dump_hash obj, variant, current_depth, config, log_object_errors
98
110
  elsif obj.is_a? Exception
99
111
  dump_exception obj, variant, current_depth, config, log_object_errors
@@ -105,6 +117,7 @@ module Rookout
105
117
 
106
118
  variant
107
119
  end
120
+ # rubocop:enable Style/ClassEqualityComparison
108
121
  # rubocop:enable Metrics/AbcSize
109
122
  # rubocop:enable Metrics/PerceivedComplexity
110
123
  # rubocop:enable Metrics/CyclomaticComplexity
@@ -120,20 +133,21 @@ module Rookout
120
133
  INT64_MAX = (1 << 63) - 1
121
134
 
122
135
  def dump_numeric obj, variant, config
123
- if obj == true
136
+ case obj
137
+ when true
124
138
  dump_variant_type variant, Com::Rookout::Variant::Type::VARIANT_LONG
125
139
  variant.long_value = 1
126
- elsif obj == false
140
+ when false
127
141
  dump_variant_type variant, Com::Rookout::Variant::Type::VARIANT_LONG
128
142
  variant.long_value = 0
129
- elsif obj.is_a? Integer
143
+ when Integer
130
144
  dump_integer obj, variant
131
- elsif obj.is_a? Float
145
+ when Float
132
146
  dump_variant_type variant, Com::Rookout::Variant::Type::VARIANT_DOUBLE
133
147
  variant.double_value = obj.to_f
134
- elsif obj.is_a? BigDecimal
148
+ when BigDecimal
135
149
  dump_string obj.to_s, variant, config # TODO: NS: This might cut the decimal value, is that ok?
136
- elsif obj.is_a? Complex
150
+ when Complex
137
151
  dump_variant_type variant, Com::Rookout::Variant::Type::VARIANT_COMPLEX
138
152
  variant.complex_value = Com::Rookout::Variant::Complex.new real: obj.real.to_f,
139
153
  imaginary: obj.imaginary.to_f
@@ -11,6 +11,7 @@ module Rookout
11
11
 
12
12
  class ContainerNamespace < Namespace
13
13
  def initialize hash = {}
14
+ super()
14
15
  @hash = hash
15
16
  end
16
17
 
@@ -8,6 +8,7 @@ module Rookout
8
8
 
9
9
  class FrameNamespace < Namespace
10
10
  def initialize binding
11
+ super()
11
12
  @binding = binding
12
13
  end
13
14
 
@@ -19,14 +20,12 @@ module Rookout
19
20
 
20
21
  def call_method name, args
21
22
  case name
22
- when "filename"
23
+ when "filename", "module"
23
24
  RubyObjectNamespace.new @binding.source_location[0]
24
25
  when "line"
25
26
  RubyObjectNamespace.new @binding.source_location[1]
26
27
  when "function"
27
28
  RubyObjectNamespace.new @binding.eval("__method__").to_s
28
- when "module"
29
- RubyObjectNamespace.new @binding.source_location[0]
30
29
  when "locals"
31
30
  locals args
32
31
  when "dump"
@@ -3,6 +3,7 @@ module Rookout
3
3
  module Namespaces
4
4
  class Namespace
5
5
  require_relative "../../exceptions"
6
+
6
7
  def call_method name, _args
7
8
  raise Exceptions::RookMethodNotFound.new(self.class.to_s, name)
8
9
  end
@@ -7,10 +7,6 @@ module Rookout
7
7
  require_relative "../../protobuf/variant_pb"
8
8
 
9
9
  class NoopNamespace < Namespace
10
- def initialize
11
- super
12
- end
13
-
14
10
  def call_method _name, _args
15
11
  Rookout::Processor::Namespaces::RubyObjectNamespace.new nil
16
12
  end
@@ -17,7 +17,10 @@ module Rookout
17
17
  @max_string = max_string
18
18
  end
19
19
 
20
- attr_reader :max_depth, :max_width, :max_collection_depth, :max_string
20
+ attr_reader :max_depth
21
+ attr_reader :max_width
22
+ attr_reader :max_collection_depth
23
+ attr_reader :max_string
21
24
  end
22
25
 
23
26
  OBJECT_DUMP_CONFIG_STRICT = ObjectDumpConfig.new 2, 10, 2, 128
@@ -37,12 +40,14 @@ module Rookout
37
40
  class RubyObjectNamespace < Namespace
38
41
  include RubyObjectSerializer
39
42
 
40
- def initialize obj, dump_config = OBJECT_DUMP_CONFIG_DEFAULT
43
+ def initialize obj, dump_config = nil
44
+ super()
41
45
  @obj = obj
42
- @dump_config = dump_config
46
+ @dump_config = dump_config || OBJECT_DUMP_CONFIG_DEFAULT
43
47
  end
44
48
 
45
- attr_reader :obj, :dump_config
49
+ attr_reader :obj
50
+ attr_reader :dump_config
46
51
 
47
52
  def tailor_limits!
48
53
  if @obj.is_a? String
@@ -62,18 +67,11 @@ module Rookout
62
67
  end
63
68
 
64
69
  def read_key key
65
- if @obj.is_a?(Array) || @obj.is_a?(String)
66
- key_int = key.to_i
67
- return RubyObjectNamespace.new @obj[key_int] if key_int >= 0 && key_int < @obj.length
68
- raise Exceptions::RookKeyNotFound, key
69
-
70
- elsif @obj.is_a? Hash
71
- return RubyObjectNamespace.new @obj[key] if @obj.key? key
72
- return RubyObjectNamespace.new @obj[key.to_sym] if @obj.key? key.to_s.to_sym
73
-
74
- @obj.each { |it, value| return RubyObjectNamespace.new value if it.to_s == key }
75
-
76
- raise Exceptions::RookKeyNotFound, key
70
+ case @obj
71
+ when Array, String
72
+ read_key_as_int key
73
+ when Hash
74
+ read_key_from_hash key
77
75
  else
78
76
  raise Exceptions::RookInvalidObjectForAccess.new(@obj.class.to_s, "ReadKey")
79
77
  end
@@ -94,6 +92,23 @@ module Rookout
94
92
  dump_raw_object @obj, 0, @dump_config, log_object_errors
95
93
  end
96
94
  end
95
+
96
+ private
97
+
98
+ def read_key_as_int key
99
+ key_int = key.to_i
100
+ return RubyObjectNamespace.new @obj[key_int] if key_int >= 0 && key_int < @obj.length
101
+ raise Exceptions::RookKeyNotFound, key
102
+ end
103
+
104
+ def read_key_from_hash key
105
+ return RubyObjectNamespace.new @obj[key] if @obj.key? key
106
+ return RubyObjectNamespace.new @obj[key.to_sym] if @obj.key? key.to_s.to_sym
107
+
108
+ @obj.each { |it, value| return RubyObjectNamespace.new value if it.to_s == key }
109
+
110
+ raise Exceptions::RookKeyNotFound, key
111
+ end
97
112
  end
98
113
  end
99
114
  end
@@ -24,6 +24,7 @@ module Rookout
24
24
 
25
25
  # rubocop:disable Metrics/PerceivedComplexity
26
26
  # rubocop:disable Metrics/CyclomaticComplexity
27
+ # rubocop:disable Style/ClassEqualityComparison
27
28
  def unsafe_dump_object obj, current_depth, config, log_object_errors
28
29
  variant = create_base_variant obj, current_depth, config, log_object_errors
29
30
 
@@ -49,7 +50,7 @@ module Rookout
49
50
 
50
51
  variant
51
52
  end
52
-
53
+ # rubocop:enable Style/ClassEqualityComparison
53
54
  # rubocop:enable Metrics/CyclomaticComplexity
54
55
  # rubocop:enable Metrics/PerceivedComplexity
55
56
 
@@ -83,23 +84,24 @@ module Rookout
83
84
  INT64_MAX = (1 << 63) - 1
84
85
 
85
86
  def dump_numeric obj, variant
86
- if obj == true
87
+ case obj
88
+ when true
87
89
  variant.variant_type = :VARIANT_INT
88
90
  variant.int_value = 1
89
- elsif obj == false
91
+ when false
90
92
  variant.variant_type = :VARIANT_INT
91
93
  variant.int_value = 0
92
- elsif obj.is_a? Integer
94
+ when Integer
93
95
  dump_integer obj, variant
94
- elsif obj.is_a? Float
96
+ when Float
95
97
  variant.variant_type = :VARIANT_DOUBLE
96
98
  variant.double_value = obj.to_f
97
- elsif obj.is_a? BigDecimal
99
+ when BigDecimal
98
100
  serialized_decimal = obj.to_s
99
101
  variant.variant_type = :VARIANT_STRING
100
102
  variant.string_value = Com::Rookout::Variant::String.new value: serialized_decimal,
101
103
  original_size: serialized_decimal.length
102
- elsif obj.is_a? Complex
104
+ when Complex
103
105
  variant.variant_type = :VARIANT_COMPLEX
104
106
  variant.complex_value = Com::Rookout::Variant::Complex.new real: obj.real.to_f,
105
107
  imaginary: obj.imaginary.to_f
@@ -9,10 +9,6 @@ module Rookout
9
9
  require_relative "ruby_object_namespace"
10
10
 
11
11
  class RubyUtilsNamespace < Namespace
12
- def initialize
13
- super
14
- end
15
-
16
12
  def call_method name, args
17
13
  case name
18
14
  when "exception"
@@ -7,6 +7,7 @@ module Rookout
7
7
 
8
8
  class StackNamespace < Namespace
9
9
  def initialize backtrace, offset = 0
10
+ super()
10
11
  @backtrace = backtrace
11
12
  @offset = offset
12
13
  end
@@ -8,12 +8,15 @@ module Rookout
8
8
 
9
9
  class TracebackNamespace < Namespace
10
10
  def initialize backtrace, offset, depth
11
+ super()
11
12
  @backtrace = backtrace
12
13
  @offset = offset
13
14
  @depth = depth
14
15
  end
15
16
 
16
- attr_reader :backtrace, :offset, :depth
17
+ attr_reader :backtrace
18
+ attr_reader :offset
19
+ attr_reader :depth
17
20
 
18
21
  def read_key key
19
22
  FrameNamespace.new @backtrace[key + @offset]
@@ -11,6 +11,8 @@ module Rookout
11
11
 
12
12
  class SetOperation < Operation
13
13
  def initialize configuration, factory
14
+ super()
15
+
14
16
  @paths = []
15
17
 
16
18
  configuration["paths"].each do |key, value|
@@ -13,6 +13,8 @@ module Rookout
13
13
 
14
14
  class ArithmeticPath < Path
15
15
  def initialize path
16
+ super()
17
+
16
18
  if path.is_a? Hash
17
19
  path = path["path"] || path[:path]
18
20
  end
@@ -20,7 +22,7 @@ module Rookout
20
22
  @raw_path = path
21
23
 
22
24
  if path.start_with?("NOT(") && path.end_with?(")")
23
- @path = path["NOT(".length..-2]
25
+ @path = path[("NOT(".length)..-2]
24
26
  @negation = true
25
27
  else
26
28
  @path = path
@@ -79,6 +79,8 @@ module Rookout
79
79
  end
80
80
 
81
81
  # rubocop:disable Metrics/AbcSize
82
+ # rubocop:disable Metrics/CyclomaticComplexity
83
+ # rubocop:disable Metrics/PerceivedComplexity
82
84
  def make_comp_exp _input, _start, _finish, elements
83
85
  # We can assume the following: atom ( opt_ atom )*
84
86
  # the first (which must be) will be simple atom
@@ -108,7 +110,7 @@ module Rookout
108
110
  flat_elements.each_with_index do |e, index|
109
111
  if e.is_a?(Opt) && e.level == level
110
112
  result = e.execute_operation flat_elements[index - 1], flat_elements[index + 1]
111
- flat_elements = flat_elements[0...index - 1] + [result] + flat_elements[index + 2..-1]
113
+ flat_elements = flat_elements[0...index - 1] + [result] + flat_elements[index + 2..]
112
114
  restart_scan = true
113
115
  break
114
116
  end
@@ -122,6 +124,8 @@ module Rookout
122
124
 
123
125
  flat_elements[0]
124
126
  end
127
+ # rubocop:enable Metrics/PerceivedComplexity
128
+ # rubocop:enable Metrics/CyclomaticComplexity
125
129
  # rubocop:enable Metrics/AbcSize
126
130
 
127
131
  def make_opt _input, _start, _finish, elements
@@ -50,9 +50,10 @@ module Rookout
50
50
  # If it's a dict, scan the keys, compensating for additional abstraction
51
51
  if b.is_a? Hash
52
52
  b.each_key do |key|
53
- if key.is_a? ObjectMarker
53
+ case key
54
+ when ObjectMarker
54
55
  return true if key.obj == a
55
- elsif key == a
56
+ when a
56
57
  return true
57
58
  end
58
59
  end
@@ -62,9 +63,10 @@ module Rookout
62
63
  # If it's an array, scan the value, compensating for additional abstraction
63
64
  if b.is_a? Array
64
65
  b.each do |value|
65
- if value.is_a? ObjectMarker
66
+ case value
67
+ when ObjectMarker
66
68
  return true if value.obj == a
67
- elsif value == a
69
+ when a
68
70
  return true
69
71
  end
70
72
  end
@@ -7,7 +7,11 @@ module Rookout
7
7
  require_relative "../../../exceptions"
8
8
  require_relative "../../namespaces/container_namespace"
9
9
 
10
- class Marker; end
10
+ # rubocop:disable Lint/EmptyClass
11
+ class Marker
12
+ # Empty base class
13
+ end
14
+ # rubocop:enable Lint/EmptyClass
11
15
 
12
16
  class Operation < Marker
13
17
  def read _namespace, _create
@@ -21,6 +25,7 @@ module Rookout
21
25
 
22
26
  class FunctionOperation < Operation
23
27
  def initialize name, args
28
+ super()
24
29
  @name = name
25
30
  @args = args
26
31
  end
@@ -32,6 +37,7 @@ module Rookout
32
37
 
33
38
  class AttributeOperation < Operation
34
39
  def initialize name
40
+ super()
35
41
  @name = name
36
42
  end
37
43
 
@@ -49,6 +55,7 @@ module Rookout
49
55
 
50
56
  class LookupOperation < Operation
51
57
  def initialize text
58
+ super()
52
59
  if (text.start_with?("'") && text.end_with?("'")) || (text.start_with?("\"") && text.end_with?("\""))
53
60
  @key = text[1...-1]
54
61
  else
@@ -63,11 +70,13 @@ module Rookout
63
70
 
64
71
  class ObjectMarker < Marker
65
72
  def initialize text, obj
73
+ super()
66
74
  @text = text
67
75
  @obj = obj
68
76
  end
69
77
 
70
- attr_reader :text, :obj
78
+ attr_reader :text
79
+ attr_reader :obj
71
80
 
72
81
  def to_s
73
82
  @obj.to_s
@@ -136,6 +145,8 @@ module Rookout
136
145
 
137
146
  class Opt < Marker
138
147
  def initialize opt
148
+ super()
149
+
139
150
  @opt = opt
140
151
  @level = nil
141
152
 
@@ -160,9 +171,8 @@ module Rookout
160
171
  return
161
172
  end
162
173
 
163
- unless first_obj.nil?
164
- raise Exceptions::RookNonPrimitiveObjectType, first_obj.class.to_s unless
165
- PRIMITIVES.include? first_obj.class
174
+ if !first_obj.nil? && !(PRIMITIVES.include? first_obj.class)
175
+ raise Exceptions::RookNonPrimitiveObjectType, first_obj.class.to_s
166
176
  end
167
177
 
168
178
  return if second_obj.nil?
@@ -5,8 +5,6 @@ module Rookout
5
5
  require_relative "paths/arithmetic_path"
6
6
 
7
7
  class ProcessorFactory
8
- def initialize; end
9
-
10
8
  def create_operation configuration
11
9
  Operations::SetOperation.new configuration, self
12
10
  end
@@ -24,7 +24,9 @@ module Rookout
24
24
  end
25
25
  end
26
26
 
27
- attr_reader :message, :exception, :parameters
27
+ attr_reader :message
28
+ attr_reader :exception
29
+ attr_reader :parameters
28
30
 
29
31
  def dumps
30
32
  parameters = NamespaceSerializer.dump Namespaces::RubyObjectNamespace.new(@parameters), false
@@ -82,9 +82,10 @@ module Rookout
82
82
  private
83
83
 
84
84
  def check_version_supported
85
- raise Exceptions:: RookVersionNotSupported.new("platform", RUBY_ENGINE) unless RUBY_ENGINE == "ruby"
85
+ raise Exceptions::RookVersionNotSupported.new("platform", RUBY_ENGINE) unless RUBY_ENGINE == "ruby"
86
86
  raise Exceptions::RookVersionNotSupported.new("version", RUBY_VERSION) unless
87
- RUBY_VERSION.start_with?("2.7") || RUBY_VERSION.start_with?("2.6")
87
+ RUBY_VERSION.start_with?("2.7") || RUBY_VERSION.start_with?("2.6") ||
88
+ RUBY_VERSION.start_with?("3.0") || RUBY_VERSION.start_with?("3.1")
88
89
  end
89
90
  end
90
91
  end
@@ -0,0 +1,22 @@
1
+ require "set"
2
+ module Rookout
3
+ class Sanitizer
4
+ @@blacklisted_properties = Set["labels", "ROOKOUT_LABELS"]
5
+
6
+ def self.sanitize_object! obj
7
+ obj.each_key do |key|
8
+ if obj[key].is_a?(String) && !@@blacklisted_properties.include?(key.to_s)
9
+ obj[key] = obj[key].strip
10
+ end
11
+ end
12
+ end
13
+
14
+ def self.sanitize_properties!
15
+ ENV.each do |key, val|
16
+ if key.start_with?("ROOKOUT_") && !@@blacklisted_properties.include?(key.to_s)
17
+ ENV[key] = val.strip
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -11,7 +11,8 @@ module Rookout
11
11
  @method = method
12
12
  end
13
13
 
14
- attr_reader :lineno, :method
14
+ attr_reader :lineno
15
+ attr_reader :method
15
16
  end
16
17
 
17
18
  class PositionResolver
@@ -54,7 +55,7 @@ module Rookout
54
55
  end
55
56
 
56
57
  def clear_augs
57
- @augs.values.each do |aug_id|
58
+ @augs.each_value do |aug_id|
58
59
  remove_aug aug_id
59
60
  end
60
61
 
@@ -26,7 +26,7 @@ module Rookout
26
26
 
27
27
  # We add and remove a dummy trace point to re-align the tracing mechanism as a result of some bug in adding
28
28
  # a breakpoint
29
- dummy_trace_point = TracePoint.new(:line) {}
29
+ dummy_trace_point = TracePoint.new(:line) {} # Dummy
30
30
  dummy_trace_point.enable target: position.method, target_line: position.lineno
31
31
  dummy_trace_point.disable
32
32
 
@@ -53,7 +53,7 @@ module Rookout
53
53
  end
54
54
 
55
55
  def clear_augs
56
- @augs.values.each do |aug_id|
56
+ @augs.each_value do |aug_id|
57
57
  remove_aug aug_id
58
58
  end
59
59
 
data/lib/rookout/utils.rb CHANGED
@@ -15,6 +15,12 @@ module Utils
15
15
  def time_to_nanoseconds time_obj
16
16
  secs = time_obj.to_i
17
17
  nsecs = time_obj.nsec
18
- (10**9) * secs + nsecs
18
+ ((10**9) * secs) + nsecs
19
+ end
20
+ end
21
+
22
+ class String
23
+ def is_number?
24
+ to_f.to_s == self || to_i.to_s == self
19
25
  end
20
26
  end
@@ -1,3 +1,3 @@
1
1
  module Rookout
2
- VERSION = "0.1.36".freeze
2
+ VERSION = "0.1.39".freeze
3
3
  end
data/lib/rookout.rb CHANGED
@@ -2,6 +2,10 @@ module Rookout
2
2
  module_function
3
3
 
4
4
  def start options = {}
5
+ require_relative "rookout/sanitizer"
6
+ Sanitizer.sanitize_object! options
7
+ Sanitizer.sanitize_properties!
8
+
5
9
  require_relative "rookout/interface"
6
10
  Interface.instance.start options
7
11
  end