Skip to content

Commit f1cb087

Browse files
committed
fix: Add missing imports and remove deprecation warnings
1 parent 26e34ca commit f1cb087

File tree

7 files changed

+20
-4
lines changed

7 files changed

+20
-4
lines changed

appmap.gemspec

+1
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,5 @@ Gem::Specification.new do |spec|
5454
spec.add_development_dependency 'webdrivers', '~> 4.0'
5555
spec.add_development_dependency 'timecop'
5656
spec.add_development_dependency 'hashie'
57+
spec.add_development_dependency 'webrick'
5758
end

lib/appmap/handler/net_http.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class << self
8282
def request_headers(request)
8383
{}.tap do |headers|
8484
request.each_header do |k,v|
85-
key = [ 'HTTP', k.underscore.upcase ].join('_')
85+
key = [ 'HTTP', Util.underscore(k).upcase ].join('_')
8686
headers[key] = v
8787
end
8888
end

lib/appmap/handler/rails/template.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ def handle_return(call_event_id, elapsed, return_value, exception)
146146
class RenderHandler
147147
class << self
148148
def handle_call(defined_class, hook_method, receiver, args)
149-
context, options = args
149+
# context, options
150+
_, options = args
150151

151152
warn "Renderer: #{options}" if LOG
152153

lib/appmap/hook.rb

-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ def trace_location(trace_point)
9999
end
100100

101101
def trace_end(trace_point)
102-
location = trace_location(trace_point)
103102
warn "Class or module ends at location #{trace_location(trace_point)}" if Hook::LOG || Hook::LOG_HOOK
104103

105104
path = trace_point.path

lib/appmap/trace.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# frozen_string_literal: true
22

3+
require 'delegate'
4+
35
module AppMap
46
module Trace
57
class RubyMethod < SimpleDelegator

lib/appmap/util.rb

+13-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def swaggerize_path(path)
124124
path = path.split('(.')[0]
125125
tokens = path.split('/')
126126
tokens.map do |token|
127-
token.gsub /^:(.*)/, '{\1}'
127+
token.gsub(/^:(.*)/, '{\1}')
128128
end.join('/')
129129
end
130130

@@ -154,6 +154,18 @@ def classify(word)
154154
word.split(/[\-_]/).map(&:capitalize).join
155155
end
156156

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+
157169
def deep_dup(hash)
158170
# This is a simple way to avoid the need for deep_dup from activesupport.
159171
Marshal.load(Marshal.dump(hash))

spec/record_net_http_spec.rb

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
require 'spec_helper'
22
require 'diffy'
33
require 'rack'
4+
require 'webrick'
45
require 'rack/handler/webrick'
56

67
class HelloWorldApp

0 commit comments

Comments
 (0)