appmap 0.93.5 → 0.94.1

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: e06f80a7364f75faaa0a8838b5053ea147349c3737b4072003aef809e6e2bbec
4
- data.tar.gz: 004e1d57ebe2a8c1aa718062cec50d1846526e12b6cd014b7780cbb636417500
3
+ metadata.gz: ca46315eb8aa31221cee8a1d656187a4e4355e63f6b2be1d591829dddb76f7e0
4
+ data.tar.gz: d038130a2827f01f573bf69dbe32ab837d7ff68b28dce7a6076a80eee2f4550e
5
5
  SHA512:
6
- metadata.gz: 524637c14e1fb40dc5d8174af904adf7f5f72827d8c2c61689e612602d1d9a15464697ec65c207d295e7a9752af9bdaeedab26ff515e2db3f324bec4bc3de97a
7
- data.tar.gz: 2239720d8ede87ba270e57299dfd63842eee3e07d9426249d647cbcc48095ba6439d796f090b5ab55fd76ba62afd8c3117944db067180d5d0628c9e19fed30e5
6
+ metadata.gz: 58a84ec34e17b22acf37fd0b9f964fb93f82531cb7f800721d33214b1bc434b81e47cbf7202f87ddeade990644d4cc512898125bc59851e82f035f9093c31eb2
7
+ data.tar.gz: a8a0bfa9cf83dc59d6e3848228f602bf8030c01601755a853a55ee4b452a970e2de1c823649da1fc0b557b8b9b6ba24c142f324975a20a222aadc239d37958b1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## [0.94.1](https://github.com/getappmap/appmap-ruby/compare/v0.94.0...v0.94.1) (2022-11-23)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Handle properties of mixed content and repeated values ([4e14eb8](https://github.com/getappmap/appmap-ruby/commit/4e14eb8f4650368b3fdcb3f30be2969df3998e05))
7
+
8
+ # [0.94.0](https://github.com/getappmap/appmap-ruby/compare/v0.93.5...v0.94.0) (2022-11-22)
9
+
10
+
11
+ ### Features
12
+
13
+ * Emit nested return_value.properties ([2c74c68](https://github.com/getappmap/appmap-ruby/commit/2c74c68f9e2a5bcb3f095850c9d520422b63e25f))
14
+
1
15
  ## [0.93.5](https://github.com/getappmap/appmap-ruby/compare/v0.93.4...v0.93.5) (2022-11-08)
2
16
 
3
17
 
data/lib/appmap/event.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'weakref'
4
+ require_relative './value_inspector'
4
5
 
5
6
  module AppMap
6
7
  module Event
@@ -20,6 +21,8 @@ module AppMap
20
21
  MethodEventStruct = Struct.new(:id, :event, :thread_id)
21
22
 
22
23
  class MethodEvent < MethodEventStruct
24
+ extend ValueInspector
25
+
23
26
  MAX_ARRAY_ENUMERATION = 10
24
27
  MAX_HASH_ENUMERATION = 10
25
28
  MAX_STRING_LENGTH = 100
@@ -61,33 +64,12 @@ module AppMap
61
64
  end
62
65
 
63
66
  def add_size(param, value)
64
- # Don't risk calling #size on things like data-access objects, which can and will issue queries for this information.
65
- if value.is_a?(Array) || value.is_a?(Hash)
66
- param[:size] = value.size
67
- end
67
+ size = ValueInspector.detect_size(value)
68
+ param[:size] = size if size
68
69
  end
69
70
 
70
71
  def add_schema(param, value)
71
- begin
72
- if value.respond_to?(:keys)
73
- param[:properties] = value.keys.map { |key| { name: key, class: best_class_name(value[key]) } }
74
- elsif value.respond_to?(:first) && value.first
75
- if value.first != value
76
- add_schema param, value.first
77
- end
78
- end
79
- rescue
80
- warn "Error in add_schema(#{value.class})", $!
81
- end
82
- end
83
-
84
- # Heuristic for dynamically defined class whose name can be nil
85
- def best_class_name(value)
86
- value_cls = value.class
87
- while value_cls && value_cls.name.nil?
88
- value_cls = value_cls.superclass
89
- end
90
- value_cls&.name || 'unknown'
72
+ ValueInspector.detect_schema(value, type_info: param)
91
73
  end
92
74
 
93
75
  def encode_display_string(value)
@@ -0,0 +1,50 @@
1
+ module AppMap
2
+ module ValueInspector
3
+ extend self
4
+
5
+ MAX_DEPTH = 3
6
+
7
+ def detect_size(value)
8
+ # Don't risk calling #size on things like data-access objects, which can and will issue queries for this information.
9
+ if value.is_a?(Array) || value.is_a?(Hash)
10
+ value.size
11
+ end
12
+ end
13
+
14
+ def detect_schema(value, max_depth: MAX_DEPTH, type_info: {}, observed_values: Set.new(), depth: 0)
15
+ return type_info if depth == max_depth
16
+
17
+ if value.respond_to?(:keys)
18
+ return if observed_values.include?(value.object_id)
19
+
20
+ observed_values << value.object_id
21
+
22
+ properties = value.keys.select { |key| key != "" && !key.nil? }.map do |key|
23
+ next_value = value[key]
24
+
25
+ value_schema = begin
26
+ { name: key, class: best_class_name(next_value) }
27
+ rescue
28
+ warn "Error in add_schema(#{next_value.class})", $!
29
+ raise
30
+ end
31
+
32
+ detect_schema(next_value, **{ max_depth: max_depth, type_info: value_schema, observed_values: observed_values, depth: depth + 1 })
33
+ end.compact
34
+ type_info[:properties] = properties unless properties.empty?
35
+ elsif value.respond_to?(:first)
36
+ detect_schema(value.first, **{ max_depth: max_depth, type_info: type_info, observed_values: observed_values, depth: depth + 1 })
37
+ end
38
+ type_info
39
+ end
40
+
41
+ # Heuristic for dynamically defined class whose name can be nil
42
+ def best_class_name(value)
43
+ value_cls = value.class
44
+ while value_cls && value_cls.name.nil?
45
+ value_cls = value_cls.superclass
46
+ end
47
+ value_cls&.name || "unknown"
48
+ end
49
+ end
50
+ end
@@ -3,9 +3,9 @@
3
3
  module AppMap
4
4
  URL = 'https://github.com/applandinc/appmap-ruby'
5
5
 
6
- VERSION = '0.93.5'
6
+ VERSION = '0.94.1'
7
7
 
8
- APPMAP_FORMAT_VERSION = '1.9.0'
8
+ APPMAP_FORMAT_VERSION = '1.10.0'
9
9
 
10
10
  SUPPORTED_RUBY_VERSIONS = %w[2.5 2.6 2.7 3.0 3.1].freeze
11
11
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appmap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.93.5
4
+ version: 0.94.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Gilpin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-11-08 00:00:00.000000000 Z
11
+ date: 2022-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: method_source
@@ -432,6 +432,7 @@ files:
432
432
  - lib/appmap/swagger/stable.rb
433
433
  - lib/appmap/trace.rb
434
434
  - lib/appmap/util.rb
435
+ - lib/appmap/value_inspector.rb
435
436
  - lib/appmap/version.rb
436
437
  - package.json
437
438
  - release.sh