appmap 0.35.2 → 0.36.0

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: 9e7d5c58bd3addf395c32591fe468c4a0b0e886d715cb711ffb6c898049455e5
4
- data.tar.gz: 271ac50ee1ebe139ed8e52262a98a13e6b3d471ddcab49316669e66d0b7be57a
3
+ metadata.gz: 102dab80f2d8cffd51fd1377583a1b063078cd77ab7ad4ffdcd20867a084b11b
4
+ data.tar.gz: cbb87144593416f84099cf8a9d8ac18f18d9763dce28277320ae6a99ff59ec58
5
5
  SHA512:
6
- metadata.gz: b84b1d76d8890a72fb376e95c7ab3811814b75e99304d2f1c15bb091cba1aef1e81f7688fd69c35b8c7735fd72167f89c67eeb25f76e54253503be610fff52cc
7
- data.tar.gz: 12b27887ae25d8f91fa6321ea59c222c7ec7d1e2d6a198f6672fa166fcd3c32456fe0d3969dda729d4c4817129a3eb874f8bae0afb5dca6b74253ccf457bd51b
6
+ metadata.gz: a24e2ecb22a654d11e91ef28a7fdd961c178144f474a36e26c70e8e243bac18c13e3c5ff606f5ed2a058ddf6d98f9dbd0678a0f986ddfae4f18ed7524c27d41d
7
+ data.tar.gz: 712cb7e18026aa80135af7ce54a7a8c412362355c0eb6b151a0f05354cf991ebe9402e298d9646b9fab2e5d673d3338a773a0b1b1d0e1846ec3ed970074a1f77
@@ -1,3 +1,8 @@
1
+ # v0.36.0
2
+ * *appmap.yml* package definition may specify `gem`.
3
+ * Skip loading the railtie if `APPMAP_INITIALIZE` environment variable
4
+ is set to `false`.
5
+
1
6
  # v0.35.2
2
7
  * Make sure `MethodEvent#display_string` works when the value's `#to_s` and/or `#inspect`
3
8
  methods have problems.
data/README.md CHANGED
@@ -76,6 +76,7 @@ name: MyProject
76
76
  packages:
77
77
  - path: app/controllers
78
78
  - path: app/models
79
+ - gem: activerecord
79
80
  ```
80
81
 
81
82
  * **name** Provides the project name (required)
@@ -87,6 +88,7 @@ Each entry in the `packages` list is a YAML object which has the following keys:
87
88
 
88
89
  * **path** The path to the source code directory. The path may be relative to the current working directory, or it may
89
90
  be an absolute path.
91
+ * **gem** As an alternative to specifying the path, specify the name of a dependency gem. When using `gem`, don't specify `path`.
90
92
  * **exclude** A list of files and directories which will be ignored. By default, all modules, classes and public
91
93
  functions are inspected.
92
94
 
data/Rakefile CHANGED
@@ -113,7 +113,7 @@ namespace :spec do
113
113
  desc ruby_version
114
114
  task ruby_version, [:specs] => ["compile", "build:fixtures:#{ruby_version}:all"] do |_, task_args|
115
115
  run_specs(ruby_version, task_args)
116
- end.tap do|t|
116
+ end.tap do |t|
117
117
  desc "Run all specs"
118
118
  task :all, [:specs] => t
119
119
  end
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
30
30
  spec.add_dependency 'parser'
31
31
  spec.add_dependency 'rack'
32
32
 
33
- spec.add_development_dependency 'bundler', '~> 1.16'
33
+ spec.add_development_dependency 'bundler', '>= 1.16'
34
34
  spec.add_development_dependency 'minitest', '~> 5.0'
35
35
  spec.add_development_dependency 'pry-byebug'
36
36
  spec.add_development_dependency 'rake', '>= 12.3.3'
data/appmap.yml CHANGED
@@ -1,8 +1,2 @@
1
1
  name: AppMap Rubygem
2
- packages:
3
- - path: lib/appmap
4
- exclude:
5
- - server
6
- - trace
7
-
8
- - path: examples
2
+ packages: []
@@ -83,7 +83,7 @@ module AppMap
83
83
 
84
84
  object_infos = [
85
85
  {
86
- name: package.path,
86
+ name: package.name,
87
87
  type: 'package'
88
88
  }
89
89
  ]
@@ -2,15 +2,39 @@
2
2
 
3
3
  module AppMap
4
4
  class Config
5
- Package = Struct.new(:path, :package_name, :exclude, :labels) do
6
- def initialize(path, package_name: nil, exclude: [], labels: [])
7
- super path, package_name, exclude, labels
5
+ Package = Struct.new(:path, :gem, :package_name, :exclude, :labels) do
6
+ class << self
7
+ def build_from_path(path, package_name: nil, exclude: [], labels: [])
8
+ Package.new(path, nil, package_name, exclude, labels)
9
+ end
10
+
11
+ def build_from_gem(gem, package_name: nil, exclude: [], labels: [])
12
+ gem_paths(gem).map do |gem_path|
13
+ Package.new(gem_path, gem, package_name, exclude, labels)
14
+ end
15
+ end
16
+
17
+ private_class_method :new
18
+
19
+ protected
20
+
21
+ def gem_paths(gem)
22
+ gemspec = Gem.loaded_specs[gem] or raise "Gem #{gem.inspect} not found"
23
+ gemspec.source_paths.map do |path|
24
+ File.join(gemspec.gem_dir, path)
25
+ end
26
+ end
27
+ end
28
+
29
+ def name
30
+ gem || path
8
31
  end
9
32
 
10
33
  def to_h
11
34
  {
12
35
  path: path,
13
36
  package_name: package_name,
37
+ gem: gem,
14
38
  exclude: exclude.blank? ? nil : exclude,
15
39
  labels: labels.blank? ? nil : labels
16
40
  }.compact
@@ -20,29 +44,29 @@ module AppMap
20
44
  Hook = Struct.new(:method_names, :package) do
21
45
  end
22
46
 
23
- OPENSSL_PACKAGE = Package.new('openssl', package_name: 'openssl', labels: %w[security crypto])
47
+ OPENSSL_PACKAGES = Package.build_from_path('openssl', package_name: 'openssl', labels: %w[security crypto])
24
48
 
25
49
  # Methods that should always be hooked, with their containing
26
50
  # package and labels that should be applied to them.
27
51
  HOOKED_METHODS = {
28
- 'ActiveSupport::SecurityUtils' => Hook.new(:secure_compare, Package.new('active_support', package_name: 'active_support', labels: %w[security crypto]))
52
+ 'ActiveSupport::SecurityUtils' => Hook.new(:secure_compare, Package.build_from_path('active_support', package_name: 'active_support', labels: %w[security crypto]))
29
53
  }.freeze
30
54
 
31
55
  BUILTIN_METHODS = {
32
- 'OpenSSL::PKey::PKey' => Hook.new(:sign, OPENSSL_PACKAGE),
33
- 'Digest::Instance' => Hook.new(:digest, OPENSSL_PACKAGE),
34
- 'OpenSSL::X509::Request' => Hook.new(%i[sign verify], OPENSSL_PACKAGE),
35
- 'OpenSSL::PKCS5' => Hook.new(%i[pbkdf2_hmac_sha1 pbkdf2_hmac], OPENSSL_PACKAGE),
36
- 'OpenSSL::Cipher' => Hook.new(%i[encrypt decrypt final], OPENSSL_PACKAGE),
37
- 'OpenSSL::X509::Certificate' => Hook.new(:sign, OPENSSL_PACKAGE),
38
- 'Net::HTTP' => Hook.new(:request, Package.new('net/http', package_name: 'net/http', labels: %w[http io])),
39
- 'Net::SMTP' => Hook.new(:send, Package.new('net/smtp', package_name: 'net/smtp', labels: %w[smtp email io])),
40
- 'Net::POP3' => Hook.new(:mails, Package.new('net/pop3', package_name: 'net/pop', labels: %w[pop pop3 email io])),
41
- 'Net::IMAP' => Hook.new(:send_command, Package.new('net/imap', package_name: 'net/imap', labels: %w[imap email io])),
42
- 'Marshal' => Hook.new(%i[dump load], Package.new('marshal', labels: %w[serialization marshal])),
43
- 'Psych' => Hook.new(%i[dump dump_stream load load_stream parse parse_stream], Package.new('yaml', package_name: 'psych', labels: %w[serialization yaml])),
44
- 'JSON::Ext::Parser' => Hook.new(:parse, Package.new('json', package_name: 'json', labels: %w[serialization json])),
45
- 'JSON::Ext::Generator::State' => Hook.new(:generate, Package.new('json', package_name: 'json', labels: %w[serialization json]))
56
+ 'OpenSSL::PKey::PKey' => Hook.new(:sign, OPENSSL_PACKAGES),
57
+ 'Digest::Instance' => Hook.new(:digest, OPENSSL_PACKAGES),
58
+ 'OpenSSL::X509::Request' => Hook.new(%i[sign verify], OPENSSL_PACKAGES),
59
+ 'OpenSSL::PKCS5' => Hook.new(%i[pbkdf2_hmac_sha1 pbkdf2_hmac], OPENSSL_PACKAGES),
60
+ 'OpenSSL::Cipher' => Hook.new(%i[encrypt decrypt final], OPENSSL_PACKAGES),
61
+ 'OpenSSL::X509::Certificate' => Hook.new(:sign, OPENSSL_PACKAGES),
62
+ 'Net::HTTP' => Hook.new(:request, Package.build_from_path('net/http', package_name: 'net/http', labels: %w[http io])),
63
+ 'Net::SMTP' => Hook.new(:send, Package.build_from_path('net/smtp', package_name: 'net/smtp', labels: %w[smtp email io])),
64
+ 'Net::POP3' => Hook.new(:mails, Package.build_from_path('net/pop3', package_name: 'net/pop', labels: %w[pop pop3 email io])),
65
+ 'Net::IMAP' => Hook.new(:send_command, Package.build_from_path('net/imap', package_name: 'net/imap', labels: %w[imap email io])),
66
+ 'Marshal' => Hook.new(%i[dump load], Package.build_from_path('marshal', labels: %w[serialization marshal])),
67
+ 'Psych' => Hook.new(%i[dump dump_stream load load_stream parse parse_stream], Package.build_from_path('yaml', package_name: 'psych', labels: %w[serialization yaml])),
68
+ 'JSON::Ext::Parser' => Hook.new(:parse, Package.build_from_path('json', package_name: 'json', labels: %w[serialization json])),
69
+ 'JSON::Ext::Generator::State' => Hook.new(:generate, Package.build_from_path('json', package_name: 'json', labels: %w[serialization json]))
46
70
  }.freeze
47
71
 
48
72
  attr_reader :name, :packages
@@ -62,8 +86,16 @@ module AppMap
62
86
  # Loads configuration from a Hash.
63
87
  def load(config_data)
64
88
  packages = (config_data['packages'] || []).map do |package|
65
- Package.new(package['path'], exclude: package['exclude'] || [])
66
- end
89
+ gem = package['gem']
90
+ path = package['path']
91
+ raise 'AppMap package configuration should specify gem or path, not both' if gem && path
92
+
93
+ if gem
94
+ Package.build_from_gem(gem, exclude: package['exclude'] || [])
95
+ else
96
+ [ Package.build_from_path(path, exclude: package['exclude'] || []) ]
97
+ end
98
+ end.flatten
67
99
  Config.new config_data['name'], packages
68
100
  end
69
101
  end
@@ -40,4 +40,4 @@ module AppMap
40
40
  end.call
41
41
  end
42
42
  end
43
- end
43
+ end unless ENV['APPMAP_INITIALIZE'] == 'false'
@@ -3,7 +3,7 @@
3
3
  module AppMap
4
4
  URL = 'https://github.com/applandinc/appmap-ruby'
5
5
 
6
- VERSION = '0.35.2'
6
+ VERSION = '0.36.0'
7
7
 
8
8
  APPMAP_FORMAT_VERSION = '1.2'
9
9
  end
@@ -27,7 +27,7 @@ describe 'AppMap class Hooking', docker: false do
27
27
 
28
28
  def invoke_test_file(file, setup: nil, &block)
29
29
  AppMap.configuration = nil
30
- package = AppMap::Config::Package.new(file)
30
+ package = AppMap::Config::Package.build_from_path(file)
31
31
  config = AppMap::Config.new('hook_spec', [ package ])
32
32
  AppMap.configuration = config
33
33
  tracer = nil
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'appmap', git: 'applandinc/appmap-ruby', branch: `git rev-parse --abbrev-ref HEAD`.strip
4
+ gem 'activesupport'
5
+ gem 'byebug'
6
+ gem 'minitest'
@@ -0,0 +1,3 @@
1
+ name: gem_test
2
+ packages:
3
+ - gem: activesupport
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'appmap/minitest'
5
+ require 'minitest/autorun'
6
+ require 'active_support'
7
+ require 'active_support/core_ext'
8
+
9
+ class ToParamTest < ::Minitest::Test
10
+ def test_to_param
11
+ # record use of a core extension
12
+ assert_equal 'my+id', 'my+id'.to_param
13
+ end
14
+ end
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'test_helper'
5
+ require 'English'
6
+
7
+ class MinitestTest < Minitest::Test
8
+ def perform_gem_test(test_name)
9
+ Bundler.with_clean_env do
10
+ Dir.chdir 'test/fixtures/gem_test' do
11
+ FileUtils.rm_rf 'tmp'
12
+ system 'bundle config --local local.appmap ../../..'
13
+ system 'bundle'
14
+ system({ 'APPMAP' => 'true' }, %(bundle exec ruby -Ilib -Itest test/#{test_name}_test.rb))
15
+
16
+ yield
17
+ end
18
+ end
19
+ end
20
+
21
+ def test_record_gem
22
+ perform_gem_test 'to_param' do
23
+ appmap_file = 'tmp/appmap/minitest/To_param_to_param.appmap.json'
24
+ appmap = JSON.parse(File.read(appmap_file))
25
+ events = appmap['events']
26
+ assert_equal 2, events.size
27
+ assert_equal 'call', events.first['event']
28
+ assert_equal 'to_param', events.first['method_id']
29
+ assert_equal "#{Gem.loaded_specs['activesupport'].gem_dir}/lib/active_support/core_ext/object/to_query.rb", events.first['path']
30
+ assert_equal 'return', events.second['event']
31
+ assert_equal 1, events.second['parent_id']
32
+ end
33
+ end
34
+ end
@@ -5,7 +5,7 @@ require 'test_helper'
5
5
  require 'English'
6
6
 
7
7
  class MinitestTest < Minitest::Test
8
- def perform_test(test_name)
8
+ def perform_minitest_test(test_name)
9
9
  Bundler.with_clean_env do
10
10
  Dir.chdir 'test/fixtures/minitest_recorder' do
11
11
  FileUtils.rm_rf 'tmp'
@@ -19,7 +19,7 @@ class MinitestTest < Minitest::Test
19
19
  end
20
20
 
21
21
  def test_hello
22
- perform_test 'hello' do
22
+ perform_minitest_test 'hello' do
23
23
  appmap_file = 'tmp/appmap/minitest/Hello_hello.appmap.json'
24
24
 
25
25
  assert File.file?(appmap_file), 'appmap output file does not exist'
@@ -11,7 +11,7 @@ class OpenSSLTest < Minitest::Test
11
11
  FileUtils.rm_rf 'tmp'
12
12
  system 'bundle config --local local.appmap ../../..'
13
13
  system 'bundle'
14
- system({ 'APPMAP' => 'true', 'DEBUG' => 'true' }, %(bundle exec ruby lib/openssl_#{test_name}.rb))
14
+ system({ 'APPMAP' => 'true' }, %(bundle exec ruby lib/openssl_#{test_name}.rb))
15
15
 
16
16
  yield
17
17
  end
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.35.2
4
+ version: 0.36.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Gilpin
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-01 00:00:00.000000000 Z
11
+ date: 2020-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -84,14 +84,14 @@ dependencies:
84
84
  name: bundler
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '1.16'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '1.16'
97
97
  - !ruby/object:Gem::Dependency
@@ -290,7 +290,7 @@ dependencies:
290
290
  - - ">="
291
291
  - !ruby/object:Gem::Version
292
292
  version: '0'
293
- description:
293
+ description:
294
294
  email:
295
295
  - kgilpin@gmail.com
296
296
  executables:
@@ -303,7 +303,6 @@ files:
303
303
  - ".gitignore"
304
304
  - ".rbenv-gemsets"
305
305
  - ".rubocop.yml"
306
- - ".ruby-version"
307
306
  - ".travis.yml"
308
307
  - CHANGELOG.md
309
308
  - Dockerfile.appmap
@@ -545,6 +544,9 @@ files:
545
544
  - test/fixtures/cucumber_recorder/features/support/hooks.rb
546
545
  - test/fixtures/cucumber_recorder/features/support/steps.rb
547
546
  - test/fixtures/cucumber_recorder/lib/hello.rb
547
+ - test/fixtures/gem_test/Gemfile
548
+ - test/fixtures/gem_test/appmap.yml
549
+ - test/fixtures/gem_test/test/to_param_test.rb
548
550
  - test/fixtures/minitest_recorder/Gemfile
549
551
  - test/fixtures/minitest_recorder/appmap.yml
550
552
  - test/fixtures/minitest_recorder/lib/hello.rb
@@ -562,6 +564,7 @@ files:
562
564
  - test/fixtures/rspec_recorder/spec/decorated_hello_spec.rb
563
565
  - test/fixtures/rspec_recorder/spec/labeled_hello_spec.rb
564
566
  - test/fixtures/rspec_recorder/spec/plain_hello_spec.rb
567
+ - test/gem_test.rb
565
568
  - test/minitest_test.rb
566
569
  - test/openssl_test.rb
567
570
  - test/record_process_test.rb
@@ -571,7 +574,7 @@ homepage: https://github.com/applandinc/appmap-ruby
571
574
  licenses:
572
575
  - MIT
573
576
  metadata: {}
574
- post_install_message:
577
+ post_install_message:
575
578
  rdoc_options: []
576
579
  require_paths:
577
580
  - lib
@@ -587,7 +590,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
587
590
  version: '0'
588
591
  requirements: []
589
592
  rubygems_version: 3.0.3
590
- signing_key:
593
+ signing_key:
591
594
  specification_version: 4
592
595
  summary: Record the operation of a Ruby program, using the AppLand 'AppMap' format.
593
596
  test_files: []
@@ -1 +0,0 @@
1
- 2.6.2