Skip to content

Commit 140a674

Browse files
committed
feat: Make activesupport a runtime dependency
1 parent 7863b7b commit 140a674

File tree

7 files changed

+8
-107
lines changed

7 files changed

+8
-107
lines changed

appmap.gemspec

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@ Gem::Specification.new do |spec|
2727
spec.extensions << "ext/appmap/extconf.rb"
2828
spec.require_paths = ['lib']
2929

30-
spec.add_dependency 'activesupport'
3130
spec.add_dependency 'method_source'
3231
spec.add_dependency 'rack'
3332
spec.add_dependency 'reverse_markdown'
3433

34+
spec.add_runtime_dependency 'activesupport'
35+
3536
spec.add_development_dependency 'bundler', '>= 1.16'
3637
spec.add_development_dependency 'minitest', '~> 5.15'
3738
spec.add_development_dependency 'pry-byebug'

lib/appmap.rb

-7
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,6 @@
2020
# - appmap/swagger (Rake task)
2121
# - appmap/depends (Rake task)
2222

23-
begin
24-
require 'active_support'
25-
require 'active_support/core_ext'
26-
rescue NameError
27-
warn 'active_support is not available. AppMap execution will continue optimistically without it...'
28-
end
29-
3023
require 'appmap/version'
3124
require 'appmap/agent'
3225

lib/appmap/config.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def build_from_builtin(path, shallow: false, require_name: nil, exclude: [], lab
7272
# Builds a package for gem. Generally corresponds to a `gem:` entry in appmap.yml. Also used when mapping
7373
# a builtin.
7474
def build_from_gem(gem, shallow: true, require_name: nil, exclude: [], labels: [], optional: false, force: false)
75-
if !force && %w[method_source activesupport].member?(gem)
75+
if !force && %w[method_source].member?(gem)
7676
warn "WARNING: #{gem} cannot be AppMapped because it is a dependency of the appmap gem"
7777
return
7878
end

lib/appmap/util.rb

+1
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ def underscore(camel_cased_word)
193193
end
194194

195195
def deep_dup(hash)
196+
require 'active_support/core_ext'
196197
hash.deep_dup
197198
end
198199

spec/config_spec.rb

+3-4
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@
5252
"description" => "Generate Swagger from AppMaps"
5353
})
5454
expect(config.as_json['hook_paths']).to eq([
55-
"pkg",
56-
"#{Gem.loaded_specs['activesupport'].gem_dir}"
55+
"pkg"
5756
])
5857
expect(config.as_json['exclude']).to eq([])
5958
expect(config.as_json['functions'].map(&:deep_stringify_keys)).to eq([
@@ -99,8 +98,8 @@
9998
]
10099
}
101100
])
102-
expect(config.as_json['gem_hooks']).to have_key('ActiveSupport::Callbacks::CallbackSequence')
103-
expect(config.as_json['gem_hooks']['ActiveSupport::Callbacks::CallbackSequence'].map(&:deep_stringify_keys)).to eq([
101+
expect(config.as_json['builtin_hooks']).to have_key('ActiveSupport::Callbacks::CallbackSequence')
102+
expect(config.as_json['builtin_hooks']['ActiveSupport::Callbacks::CallbackSequence'].map(&:deep_stringify_keys)).to eq([
104103
{
105104
"package" => "activesupport",
106105
"method_names" => [

spec/hook_spec.rb

+1-94
Original file line numberDiff line numberDiff line change
@@ -890,100 +890,6 @@ def test_hook_behavior(file, events_yaml, setup: nil, &block)
890890

891891
context 'ActiveSupport::SecurityUtils.secure_compare' do
892892
it 'is hooked' do
893-
events_yaml = <<~YAML
894-
---
895-
- :id: 1
896-
:event: :call
897-
:defined_class: Compare
898-
:method_id: compare
899-
:path: spec/fixtures/hook/compare.rb
900-
:lineno: 4
901-
:static: true
902-
:parameters:
903-
- :name: :s1
904-
:class: String
905-
:value: string
906-
:kind: :req
907-
- :name: :s2
908-
:class: String
909-
:value: string
910-
:kind: :req
911-
:receiver:
912-
:class: Class
913-
:value: Compare
914-
- :id: 2
915-
:event: :call
916-
:defined_class: ActiveSupport::SecurityUtils
917-
:method_id: secure_compare
918-
:path: lib/active_support/security_utils.rb
919-
:lineno: 26
920-
:static: true
921-
:parameters:
922-
- :name: :a
923-
:class: String
924-
:value: string
925-
:kind: :req
926-
- :name: :b
927-
:class: String
928-
:value: string
929-
:kind: :req
930-
:receiver:
931-
:class: Module
932-
:value: ActiveSupport::SecurityUtils
933-
- :id: 3
934-
:event: :call
935-
:defined_class: Digest::Instance
936-
:method_id: digest
937-
:path: Digest::Instance#digest
938-
:static: false
939-
:parameters:
940-
- :name: arg
941-
:class: Array
942-
:value: '["string"]'
943-
:kind: :rest
944-
:receiver:
945-
:class: Digest::SHA256
946-
:value: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
947-
- :id: 4
948-
:event: :return
949-
:parent_id: 3
950-
:return_value:
951-
:class: String
952-
:value: "G2__)__qc____X____3_].\\x02y__.___/_"
953-
- :id: 5
954-
:event: :call
955-
:defined_class: Digest::Instance
956-
:method_id: digest
957-
:path: Digest::Instance#digest
958-
:static: false
959-
:parameters:
960-
- :name: arg
961-
:class: Array
962-
:value: '["string"]'
963-
:kind: :rest
964-
:receiver:
965-
:class: Digest::SHA256
966-
:value: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
967-
- :id: 6
968-
:event: :return
969-
:parent_id: 5
970-
:return_value:
971-
:class: String
972-
:value: "G2__)__qc____X____3_].\\x02y__.___/_"
973-
- :id: 7
974-
:event: :return
975-
:parent_id: 2
976-
:return_value:
977-
:class: TrueClass
978-
:value: 'true'
979-
- :id: 8
980-
:event: :return
981-
:parent_id: 1
982-
:return_value:
983-
:class: TrueClass
984-
:value: 'true'
985-
YAML
986-
987893
_, _, events = test_hook_behavior 'spec/fixtures/hook/compare.rb', nil do
988894
expect(Compare.compare('string', 'string')).to be_truthy
989895
end
@@ -1078,6 +984,7 @@ def secure_compare(a, b)
1078984
_, tracer = invoke_test_file 'spec/fixtures/hook/compare.rb' do
1079985
expect(Compare.compare('string', 'string')).to be_truthy
1080986
end
987+
1081988
cm = AppMap::Util.sanitize_paths(AppMap::ClassMap.build_from_methods(tracer.event_methods))
1082989
entry = cm[1][:children][0][:children][0][:children][0]
1083990
# Sanity check, make sure we got the right one

0 commit comments

Comments
 (0)