appmap 0.34.2 → 0.34.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 81605d2c95140e963991e04af89235ee903cce0e3a86b2477f0f80961704e2d6
4
- data.tar.gz: 7e526d9ffbc559bb3968b8a973dcd757147676d17a5028f737192fd8956d1b43
3
+ metadata.gz: a3a509a94faa2a85ff11702ae55ab3df975f04416d93d169b0a24989fd520b9d
4
+ data.tar.gz: 3895b9c788413f85738ba487e717bf48e4dfc2e8c0792f30c6f9f6ba7dc5e9c8
5
5
  SHA512:
6
- metadata.gz: 6a34ba2662d48a7e0083e16d6abe4693b57711f9ac0020da6631ca6c40172aeb8f3ef734edd504cec00f2f437742e45fc0cf631b425cb960c9d51239556bc461
7
- data.tar.gz: 156f126aac6f63e819c175d6b4d481679cbced9184007871c12fb174f187198afd8e7788befc4ab0ff35b10293e1e163eee25a985b35bd93853c03aa8268d192
6
+ metadata.gz: 07fe201395cad27e731402b5b2ff0efd653056dad16b9301657034df0b6e7fd3a205768ef3656874f55109edfc4d788d752f8bc73f4ff6874c815104547ce281
7
+ data.tar.gz: cbbd1551c352519954e9ddc9dd27279d6d232663fb67fd5ed4369a603a382f140593aa195aa08f35a57b0a14d38bef07bfef0aa7bd942d660a865fb3682d500d
@@ -1,3 +1,13 @@
1
+ # v0.34.4
2
+ * Make sure `AppMap:Rails::SQLExaminer::ActiveRecordExaminer.server_version` only calls
3
+ `ActiveRecord::Base.connection.database_version` if it's available.
4
+ * Fix `AppMap:Rails::SQLExaminer::ActiveRecordExaminer.database_type` returns `:postgres`
5
+ in all supported versions of Rails.
6
+
7
+ # v0.34.3
8
+ * Fix a crash in `singleton_method_owner_name` that occurred if `__attached__.class` returned
9
+ something other than a `Module` or a `Class`.
10
+
1
11
  # v0.34.2
2
12
  * Add an extension that gets the name of the owner of a singleton method without calling
3
13
  any methods that may have been redefined (e.g. `#to_s` or `.name`).
@@ -46,4 +46,5 @@ Gem::Specification.new do |spec|
46
46
  spec.add_development_dependency 'selenium-webdriver'
47
47
  spec.add_development_dependency 'webdrivers', '~> 4.0'
48
48
  spec.add_development_dependency 'timecop'
49
+ spec.add_development_dependency 'hashie'
49
50
  end
@@ -15,7 +15,17 @@ static VALUE singleton_method_owner_name(VALUE klass, VALUE method)
15
15
  if (!CLASS_OR_MODULE_P(attached)) {
16
16
  attached = rb_funcall(attached, rb_intern("class"), 0);
17
17
  }
18
- return rb_mod_name(attached);
18
+
19
+ // Did __attached__.class return an object that's a Module or a
20
+ // Class?
21
+ if (CLASS_OR_MODULE_P(attached)) {
22
+ // Yup, get it's name
23
+ return rb_mod_name(attached);
24
+ }
25
+
26
+ // Nope (which seems weird, but whatever). Fall back to calling
27
+ // #to_s on the method's owner and hope for the best.
28
+ return rb_funcall(owner, rb_intern("to_s"), 0);
19
29
  }
20
30
 
21
31
  void Init_appmap() {
@@ -73,20 +73,15 @@ module AppMap
73
73
 
74
74
  class ActiveRecordExaminer
75
75
  def server_version
76
- case database_type
77
- when :postgres
78
- ActiveRecord::Base.connection.postgresql_version
79
- when :sqlite
80
- ActiveRecord::Base.connection.database_version.to_s
81
- else
82
- warn "Unable to determine database version for #{database_type.inspect}"
83
- end
76
+ ActiveRecord::Base.connection.try(:database_version) ||\
77
+ warn("Unable to determine database version for #{database_type.inspect}")
84
78
  end
85
79
 
86
80
  def database_type
87
- return :postgres if ActiveRecord::Base.connection.respond_to?(:postgresql_version)
81
+ type = ActiveRecord::Base.connection.adapter_name.downcase.to_sym
82
+ type = :postgres if type == :postgresql
88
83
 
89
- ActiveRecord::Base.connection.adapter_name.downcase.to_sym
84
+ type
90
85
  end
91
86
 
92
87
  def execute_query(sql)
@@ -36,6 +36,23 @@ module AppMap
36
36
  [ fname, extension ].join
37
37
  end
38
38
 
39
+ # sanitize_paths removes ephemeral values from objects with
40
+ # embedded paths (e.g. an event or a classmap), making events
41
+ # easier to compare across runs.
42
+ def sanitize_paths(h)
43
+ require 'hashie'
44
+ h.extend(Hashie::Extensions::DeepLocate)
45
+ keys = %i(path location)
46
+ entries = h.deep_locate ->(k,v,o) {
47
+ next unless keys.include?(k)
48
+
49
+ fix = ->(v) {v.gsub(%r{#{Gem.dir}/gems/.*(?=lib)}, '')}
50
+ keys.each {|k| o[k] = fix.(o[k]) if o[k] }
51
+ }
52
+
53
+ h
54
+ end
55
+
39
56
  # sanitize_event removes ephemeral values from an event, making
40
57
  # events easier to compare across runs.
41
58
  def sanitize_event(event, &block)
@@ -49,7 +66,7 @@ module AppMap
49
66
 
50
67
  case event[:event]
51
68
  when :call
52
- event[:path] = event[:path].gsub(Gem.dir + '/', '')
69
+ sanitize_paths(event)
53
70
  end
54
71
 
55
72
  event
@@ -3,7 +3,7 @@
3
3
  module AppMap
4
4
  URL = 'https://github.com/applandinc/appmap-ruby'
5
5
 
6
- VERSION = '0.34.2'
6
+ VERSION = '0.34.4'
7
7
 
8
8
  APPMAP_FORMAT_VERSION = '1.2'
9
9
  end
@@ -22,7 +22,7 @@ describe 'AppMap class Hooking', docker: false do
22
22
  while tracer.event?
23
23
  events << tracer.next_event.to_h
24
24
  end
25
- end.map(&AppMap::Util.method(:sanitize_event)).to_yaml
25
+ end.map(&AppMap::Util.method(:sanitize_event))
26
26
  end
27
27
 
28
28
  def invoke_test_file(file, setup: nil, &block)
@@ -50,7 +50,7 @@ describe 'AppMap class Hooking', docker: false do
50
50
  def test_hook_behavior(file, events_yaml, setup: nil, &block)
51
51
  config, tracer = invoke_test_file(file, setup: setup, &block)
52
52
 
53
- events = collect_events(tracer)
53
+ events = collect_events(tracer).to_yaml
54
54
 
55
55
  expect(Diffy::Diff.new(events_yaml, events).to_s).to eq('')
56
56
 
@@ -500,7 +500,7 @@ describe 'AppMap class Hooking', docker: false do
500
500
  :event: :call
501
501
  :defined_class: ActiveSupport::SecurityUtils
502
502
  :method_id: secure_compare
503
- :path: gems/activesupport-6.0.3.2/lib/active_support/security_utils.rb
503
+ :path: lib/active_support/security_utils.rb
504
504
  :lineno: 26
505
505
  :static: true
506
506
  :parameters:
@@ -598,7 +598,7 @@ describe 'AppMap class Hooking', docker: false do
598
598
  :children:
599
599
  - :name: secure_compare
600
600
  :type: function
601
- :location: gems/activesupport-6.0.3.2/lib/active_support/security_utils.rb:26
601
+ :location: lib/active_support/security_utils.rb:26
602
602
  :static: true
603
603
  :labels:
604
604
  - security
@@ -624,7 +624,7 @@ describe 'AppMap class Hooking', docker: false do
624
624
  config, tracer = invoke_test_file 'spec/fixtures/hook/compare.rb' do
625
625
  expect(Compare.compare('string', 'string')).to be_truthy
626
626
  end
627
- cm = AppMap::ClassMap.build_from_methods(config, tracer.event_methods)
627
+ cm = AppMap::Util.sanitize_paths(AppMap::ClassMap.build_from_methods(config, tracer.event_methods))
628
628
  entry = cm[1][:children][0][:children][0][:children][0]
629
629
  # Sanity check, make sure we got the right one
630
630
  expect(entry[:name]).to eq('secure_compare')
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.34.2
4
+ version: 0.34.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Gilpin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-04 00:00:00.000000000 Z
11
+ date: 2020-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -276,6 +276,20 @@ dependencies:
276
276
  - - ">="
277
277
  - !ruby/object:Gem::Version
278
278
  version: '0'
279
+ - !ruby/object:Gem::Dependency
280
+ name: hashie
281
+ requirement: !ruby/object:Gem::Requirement
282
+ requirements:
283
+ - - ">="
284
+ - !ruby/object:Gem::Version
285
+ version: '0'
286
+ type: :development
287
+ prerelease: false
288
+ version_requirements: !ruby/object:Gem::Requirement
289
+ requirements:
290
+ - - ">="
291
+ - !ruby/object:Gem::Version
292
+ version: '0'
279
293
  description:
280
294
  email:
281
295
  - kgilpin@gmail.com