appmap 0.54.0 → 0.54.1

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: a00ec7ef6ec83aebf28d11c8004c89885ae32562ef6384c6c7880ca09d380027
4
- data.tar.gz: a16129c01467f043eb18786ea8f3cae2df65226b924e6f85b40614f7d563e8a1
3
+ metadata.gz: 8b56559bdbc9f98b310e94efce7e6eaa45bedbf4e7fffaa2c8a09167b5985d64
4
+ data.tar.gz: 72762bf8b3e9352d13841ce33bf61c4ebc77fc5db445c76333f8c910b0e37e0e
5
5
  SHA512:
6
- metadata.gz: daeec49a1a7e46fa5d5f572755725d766a2c37e00f8013d93ac1cde6d7dcff504633b4ca74cbbc94c9a3d355bc221d795970e0af393be29557f03d8fbe06114a
7
- data.tar.gz: f1c8b85f2e9224604f3138c208dbcff0dbb939aa1038834a8ca761b290b5f07086023857881dd4c14c37644a9ae403108ba059c4a337796ea7ecab0e6b2826bb
6
+ metadata.gz: 79a3f92811ad61cd4e7f52c3d72b4e2277772a0e25789cccc50b63f069c43f78d2492ed37d43b073a98b0debcfc60d5d21af776d1bd6d445783c18f7ffefde81
7
+ data.tar.gz: 73a14b0bde0abba5463fd2068bd88290a1f97a673174b5732a892a867ae77af7a13e8e0374a2a07655c76b49c647005d4624501568f40f932bac868ec019e1e6
data/.travis.yml CHANGED
@@ -1,5 +1,10 @@
1
1
  language: ruby
2
2
 
3
+ rbenv:
4
+ - 2.5
5
+ - 2.6
6
+ - 2.7
7
+
3
8
  addons:
4
9
  apt:
5
10
  packages:
@@ -38,7 +43,6 @@ jobs:
38
43
  - mkdir tmp
39
44
  - GEM_ALTERNATIVE_NAME='' bundle exec rake test
40
45
 
41
-
42
46
  before_deploy:
43
47
  - |
44
48
  nvm install --lts \
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [0.54.1](https://github.com/applandinc/appmap-ruby/compare/v0.54.0...v0.54.1) (2021-06-25)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Add missing imports and remove deprecation warnings ([f1cb087](https://github.com/applandinc/appmap-ruby/commit/f1cb087f80cad88093227ebf8b4a4cd574853667))
7
+ * Workaround Ruby bug in 2.7.3 with kwrest ([26e34ca](https://github.com/applandinc/appmap-ruby/commit/26e34ca421fdae6602b27fee5653c8fe26b3793b))
8
+
1
9
  # [0.54.0](https://github.com/applandinc/appmap-ruby/compare/v0.53.0...v0.54.0) (2021-06-24)
2
10
 
3
11
 
data/Rakefile CHANGED
@@ -6,8 +6,7 @@ require 'rake/testtask'
6
6
  require 'rdoc/task'
7
7
 
8
8
  require 'open3'
9
-
10
- require "rake/extensiontask"
9
+ require 'rake/extensiontask'
11
10
 
12
11
  desc 'build the native extension'
13
12
  Rake::ExtensionTask.new("appmap") do |ext|
@@ -26,7 +25,7 @@ namespace 'gem' do
26
25
  # ~/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/gem_helper.rb:39:in `install'
27
26
  def build_gem
28
27
  # Ensure that NPM packages are installed before building.
29
- sh('yarn install --prod'.shellsplit)
28
+ sh('yarn install --prod')
30
29
 
31
30
  default_build_gem
32
31
  end
@@ -34,7 +33,17 @@ namespace 'gem' do
34
33
  end
35
34
  end
36
35
 
37
- RUBY_VERSIONS=%w[2.5 2.6 2.7]
36
+ RUBY_VERSIONS=%w[2.5 2.6 2.7].select do |version|
37
+ travis_ruby_version = ENV['TRAVIS_RUBY_VERSION']
38
+ next true unless travis_ruby_version
39
+
40
+ if travis_ruby_version.index(version) == 0
41
+ warn "Testing Ruby version #{version}, since it matches TRAVIS_RUBY_VERSION=#{travis_ruby_version}"
42
+ next true
43
+ end
44
+
45
+ false
46
+ end
38
47
  FIXTURE_APPS=%w[rack_users_app rails6_users_app rails5_users_app]
39
48
 
40
49
  def run_cmd(*cmd)
data/appmap.gemspec CHANGED
@@ -54,4 +54,5 @@ Gem::Specification.new do |spec|
54
54
  spec.add_development_dependency 'webdrivers', '~> 4.0'
55
55
  spec.add_development_dependency 'timecop'
56
56
  spec.add_development_dependency 'hashie'
57
+ spec.add_development_dependency 'webrick'
57
58
  end
@@ -82,7 +82,7 @@ module AppMap
82
82
  def request_headers(request)
83
83
  {}.tap do |headers|
84
84
  request.each_header do |k,v|
85
- key = [ 'HTTP', k.underscore.upcase ].join('_')
85
+ key = [ 'HTTP', Util.underscore(k).upcase ].join('_')
86
86
  headers[key] = v
87
87
  end
88
88
  end
@@ -146,7 +146,8 @@ module AppMap
146
146
  class RenderHandler
147
147
  class << self
148
148
  def handle_call(defined_class, hook_method, receiver, args)
149
- context, options = args
149
+ # context, options
150
+ _, options = args
150
151
 
151
152
  warn "Renderer: #{options}" if LOG
152
153
 
data/lib/appmap/hook.rb CHANGED
@@ -99,7 +99,6 @@ module AppMap
99
99
  end
100
100
 
101
101
  def trace_end(trace_point)
102
- location = trace_location(trace_point)
103
102
  warn "Class or module ends at location #{trace_location(trace_point)}" if Hook::LOG || Hook::LOG_HOOK
104
103
 
105
104
  path = trace_point.path
@@ -18,6 +18,8 @@ module AppMap
18
18
  TIME_NOW = Time.method(:now)
19
19
  private_constant :TIME_NOW
20
20
 
21
+ ARRAY_OF_EMPTY_HASH = [{}.freeze].freeze
22
+
21
23
  def initialize(hook_package, hook_class, hook_method)
22
24
  @hook_package = hook_package
23
25
  @hook_class = hook_class
@@ -45,42 +47,48 @@ module AppMap
45
47
  after_hook = self.method(:after_hook)
46
48
  with_disabled_hook = self.method(:with_disabled_hook)
47
49
 
48
- hook_method_def = nil
49
- hook_class.instance_eval do
50
- hook_method_def = Proc.new do |*args, &block|
51
- instance_method = hook_method.bind(self).to_proc
52
- call_instance_method = -> { instance_method.call(*args, &block) }
50
+ hook_method_def = Proc.new do |*args, &block|
51
+ instance_method = hook_method.bind(self).to_proc
52
+ call_instance_method = -> {
53
+ # https://github.com/applandinc/appmap-ruby/issues/153
54
+ if Util.ruby_minor_version >= 2.7 && args == ARRAY_OF_EMPTY_HASH && hook_method.arity == 1
55
+ instance_method.call({}, &block)
56
+ else
57
+ instance_method.call(*args, &block)
58
+ end
59
+ }
53
60
 
54
- # We may not have gotten the class for the method during
55
- # initialization (e.g. for a singleton method on an embedded
56
- # struct), so make sure we have it now.
57
- defined_class, = Hook.qualify_method_name(hook_method) unless defined_class
61
+ # We may not have gotten the class for the method during
62
+ # initialization (e.g. for a singleton method on an embedded
63
+ # struct), so make sure we have it now.
64
+ defined_class, = Hook.qualify_method_name(hook_method) unless defined_class
58
65
 
59
- reentrant = Thread.current[HOOK_DISABLE_KEY]
60
- disabled_by_shallow_flag = \
61
- -> { hook_package&.shallow? && AppMap.tracing.last_package_for_current_thread == hook_package }
66
+ reentrant = Thread.current[HOOK_DISABLE_KEY]
67
+ disabled_by_shallow_flag = \
68
+ -> { hook_package&.shallow? && AppMap.tracing.last_package_for_current_thread == hook_package }
62
69
 
63
- enabled = true if AppMap.tracing.enabled? && !reentrant && !disabled_by_shallow_flag.call
70
+ enabled = true if AppMap.tracing.enabled? && !reentrant && !disabled_by_shallow_flag.call
64
71
 
65
- return call_instance_method.call unless enabled
72
+ return call_instance_method.call unless enabled
66
73
 
67
- call_event, start_time = with_disabled_hook.call do
68
- before_hook.call(self, defined_class, args)
69
- end
70
- return_value = nil
71
- exception = nil
72
- begin
73
- return_value = call_instance_method.call
74
- rescue
75
- exception = $ERROR_INFO
76
- raise
77
- ensure
78
- with_disabled_hook.call do
79
- after_hook.call(self, call_event, start_time, return_value, exception) if call_event
80
- end
74
+ call_event, start_time = with_disabled_hook.call do
75
+ before_hook.call(self, defined_class, args)
76
+ end
77
+ return_value = nil
78
+ exception = nil
79
+ begin
80
+ return_value = call_instance_method.call
81
+ rescue
82
+ exception = $ERROR_INFO
83
+ raise
84
+ ensure
85
+ with_disabled_hook.call do
86
+ after_hook.call(self, call_event, start_time, return_value, exception) if call_event
81
87
  end
82
88
  end
83
89
  end
90
+ hook_method_def = hook_method_def.ruby2_keywords if hook_method_def.respond_to?(:ruby2_keywords)
91
+
84
92
  hook_class.define_method_with_arity(hook_method.name, hook_method.arity, hook_method_def)
85
93
  end
86
94
 
data/lib/appmap/trace.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'delegate'
4
+
3
5
  module AppMap
4
6
  module Trace
5
7
  class RubyMethod < SimpleDelegator
data/lib/appmap/util.rb CHANGED
@@ -124,7 +124,7 @@ module AppMap
124
124
  path = path.split('(.')[0]
125
125
  tokens = path.split('/')
126
126
  tokens.map do |token|
127
- token.gsub /^:(.*)/, '{\1}'
127
+ token.gsub(/^:(.*)/, '{\1}')
128
128
  end.join('/')
129
129
  end
130
130
 
@@ -154,6 +154,18 @@ module AppMap
154
154
  word.split(/[\-_]/).map(&:capitalize).join
155
155
  end
156
156
 
157
+ # https://api.rubyonrails.org/v6.1.3.2/classes/ActiveSupport/Inflector.html#method-i-underscore
158
+ def underscore(camel_cased_word)
159
+ return camel_cased_word unless /[A-Z-]|::/.match?(camel_cased_word)
160
+ word = camel_cased_word.to_s.gsub("::", "/")
161
+ # word.gsub!(inflections.acronyms_underscore_regex) { "#{$1 && '_' }#{$2.downcase}" }
162
+ word.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2')
163
+ word.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
164
+ word.tr!("-", "_")
165
+ word.downcase!
166
+ word
167
+ end
168
+
157
169
  def deep_dup(hash)
158
170
  # This is a simple way to avoid the need for deep_dup from activesupport.
159
171
  Marshal.load(Marshal.dump(hash))
@@ -178,6 +190,10 @@ module AppMap
178
190
  warn msg
179
191
  end
180
192
  end
193
+
194
+ def ruby_minor_version
195
+ @ruby_minor_version ||= RUBY_VERSION.split('.')[0..1].join('.').to_f
196
+ end
181
197
  end
182
198
  end
183
199
  end
@@ -3,7 +3,7 @@
3
3
  module AppMap
4
4
  URL = 'https://github.com/applandinc/appmap-ruby'
5
5
 
6
- VERSION = '0.54.0'
6
+ VERSION = '0.54.1'
7
7
 
8
8
  APPMAP_FORMAT_VERSION = '1.5.1'
9
9
 
@@ -0,0 +1,11 @@
1
+ class Kwargs
2
+ class << self
3
+ def no_kwargs(args)
4
+ args
5
+ end
6
+
7
+ def has_kwrest_calls_no_kwargs(args, **kwargs)
8
+ no_kwargs(**kwargs)
9
+ end
10
+ end
11
+ end
data/spec/hook_spec.rb CHANGED
@@ -985,4 +985,13 @@ describe 'AppMap class Hooking', docker: false do
985
985
  expect(InstanceMethod.new.method(:say_echo).arity).to be(1)
986
986
  end
987
987
  end
988
+
989
+ describe 'kwargs handling' do
990
+ # https://github.com/applandinc/appmap-ruby/issues/153
991
+ it 'empty hash for **kwrest can be proxied as a regular function argument', github_issue: 153 do
992
+ invoke_test_file 'spec/fixtures/hook/kwargs.rb' do
993
+ expect(Kwargs.has_kwrest_calls_no_kwargs(nil, {})).to eq({})
994
+ end
995
+ end
996
+ end
988
997
  end
@@ -1,6 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'diffy'
3
3
  require 'rack'
4
+ require 'webrick'
4
5
  require 'rack/handler/webrick'
5
6
 
6
7
  class HelloWorldApp
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.54.0
4
+ version: 0.54.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: 2021-06-24 00:00:00.000000000 Z
11
+ date: 2021-06-25 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: webrick
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
@@ -364,6 +378,7 @@ files:
364
378
  - spec/fixtures/hook/exception_method.rb
365
379
  - spec/fixtures/hook/exclude.rb
366
380
  - spec/fixtures/hook/instance_method.rb
381
+ - spec/fixtures/hook/kwargs.rb
367
382
  - spec/fixtures/hook/labels.rb
368
383
  - spec/fixtures/hook/method_named_call.rb
369
384
  - spec/fixtures/hook/revoke_api_key.appmap.json