appmap 0.43.0 → 0.47.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.releaserc.yml +11 -0
- data/.travis.yml +33 -2
- data/CHANGELOG.md +44 -0
- data/README.md +66 -11
- data/README_CI.md +29 -0
- data/Rakefile +4 -2
- data/appmap.gemspec +5 -3
- data/lib/appmap.rb +3 -7
- data/lib/appmap/class_map.rb +11 -22
- data/lib/appmap/command/record.rb +1 -1
- data/lib/appmap/config.rb +180 -67
- data/lib/appmap/cucumber.rb +1 -1
- data/lib/appmap/event.rb +29 -28
- data/lib/appmap/handler/function.rb +19 -0
- data/lib/appmap/handler/net_http.rb +107 -0
- data/lib/appmap/handler/rails/request_handler.rb +124 -0
- data/lib/appmap/handler/rails/sql_handler.rb +152 -0
- data/lib/appmap/handler/rails/template.rb +149 -0
- data/lib/appmap/hook.rb +111 -70
- data/lib/appmap/hook/method.rb +6 -8
- data/lib/appmap/middleware/remote_recording.rb +1 -1
- data/lib/appmap/minitest.rb +22 -20
- data/lib/appmap/railtie.rb +5 -5
- data/lib/appmap/record.rb +1 -1
- data/lib/appmap/rspec.rb +22 -21
- data/lib/appmap/trace.rb +47 -6
- data/lib/appmap/util.rb +57 -2
- data/lib/appmap/version.rb +2 -2
- data/package-lock.json +3 -3
- data/release.sh +17 -0
- data/spec/abstract_controller_base_spec.rb +76 -15
- data/spec/class_map_spec.rb +5 -13
- data/spec/config_spec.rb +33 -1
- data/spec/fixtures/hook/custom_instance_method.rb +11 -0
- data/spec/fixtures/hook/method_named_call.rb +11 -0
- data/spec/hook_spec.rb +143 -22
- data/spec/record_net_http_spec.rb +160 -0
- data/spec/spec_helper.rb +10 -0
- data/spec/util_spec.rb +18 -1
- data/test/expectations/openssl_test_key_sign1.json +2 -4
- data/test/gem_test.rb +1 -1
- data/test/rspec_test.rb +0 -13
- metadata +20 -14
- data/exe/appmap +0 -154
- data/lib/appmap/rails/request_handler.rb +0 -140
- data/lib/appmap/rails/sql_handler.rb +0 -150
- data/test/cli_test.rb +0 -116
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1f2b43daf0437ceb6073a64272148ca9168c4ac781c01e2e73c36259a3bcc7b
|
4
|
+
data.tar.gz: 2a7275d2be15d2bfcf0c2dfc898807212840506c3692232b2d049bc771a4a3b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5000bdc938facaa5e181de6e3d6023c6a1b1a1e48a260545ae3245236bf271e22ab6462c16d1c73fb44b4e9bc4e6533f8be12428e2d7ff9e1c06f65ec1992bf7
|
7
|
+
data.tar.gz: 10db3cd34b1f9eb5f81070607d12b6a714b12735ac25828df4c6a3e50d0efa354ad9ff9206bc42cd2d7ccb61ffef83f663d41b3896928f0fd9bdd1e53ed4e543
|
data/.releaserc.yml
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
plugins:
|
2
|
+
- '@semantic-release/commit-analyzer'
|
3
|
+
- '@semantic-release/release-notes-generator'
|
4
|
+
- '@semantic-release/changelog'
|
5
|
+
- 'semantic-release-rubygem'
|
6
|
+
- - '@semantic-release/git'
|
7
|
+
- assets:
|
8
|
+
- CHANGELOG.md
|
9
|
+
- appmap.gemspec
|
10
|
+
- lib/appmap/version.rb
|
11
|
+
- '@semantic-release/github'
|
data/.travis.yml
CHANGED
@@ -13,11 +13,42 @@ services:
|
|
13
13
|
# necessary.
|
14
14
|
before_script:
|
15
15
|
- unset RAILS_ENV
|
16
|
-
|
16
|
+
|
17
|
+
cache:
|
18
|
+
bundler: true
|
19
|
+
|
20
|
+
before_install:
|
21
|
+
# see https://blog.travis-ci.com/docker-rate-limits
|
22
|
+
# and also https://www.docker.com/blog/what-you-need-to-know-about-upcoming-docker-hub-rate-limiting/
|
23
|
+
# if we do not use authorized account,
|
24
|
+
# the pulls-per-IP quota is shared with other Travis users
|
25
|
+
- >
|
26
|
+
if [ ! -z "$DOCKERHUB_PASSWORD" ] && [ ! -z "$DOCKERHUB_USERNAME" ]; then
|
27
|
+
echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin ;
|
28
|
+
fi
|
29
|
+
|
30
|
+
|
31
|
+
# GEM_ALTERNATIVE_NAME only needed for deployment
|
17
32
|
jobs:
|
18
33
|
include:
|
19
34
|
- stage: test
|
20
35
|
script:
|
21
36
|
- mkdir tmp
|
22
|
-
- bundle exec rake test
|
37
|
+
- GEM_ALTERNATIVE_NAME='' bundle exec rake test
|
38
|
+
|
23
39
|
|
40
|
+
before_deploy:
|
41
|
+
- |
|
42
|
+
nvm install --lts \
|
43
|
+
&& nvm use --lts \
|
44
|
+
&& npm i -g \
|
45
|
+
semantic-release \
|
46
|
+
@semantic-release/git \
|
47
|
+
@semantic-release/changelog \
|
48
|
+
semantic-release-rubygem
|
49
|
+
|
50
|
+
deploy:
|
51
|
+
- provider: script
|
52
|
+
script: ./release.sh
|
53
|
+
on:
|
54
|
+
branch: master
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,47 @@
|
|
1
|
+
# [0.47.0](https://github.com/applandinc/appmap-ruby/compare/v0.46.0...v0.47.0) (2021-05-13)
|
2
|
+
|
3
|
+
|
4
|
+
### Features
|
5
|
+
|
6
|
+
* Emit swagger-style normalized paths instead of Rails-style ones ([5a93cd7](https://github.com/applandinc/appmap-ruby/commit/5a93cd7096ca195146a84a6733c7d502dbcd0272))
|
7
|
+
|
8
|
+
# [0.46.0](https://github.com/applandinc/appmap-ruby/compare/v0.45.1...v0.46.0) (2021-05-12)
|
9
|
+
|
10
|
+
|
11
|
+
### Features
|
12
|
+
|
13
|
+
* Record view template rendering events and template paths ([973b258](https://github.com/applandinc/appmap-ruby/commit/973b2581b6e2d4e15a1b93331e4e95a88678faae))
|
14
|
+
|
15
|
+
## [0.45.1](https://github.com/applandinc/appmap-ruby/compare/v0.45.0...v0.45.1) (2021-05-04)
|
16
|
+
|
17
|
+
|
18
|
+
### Bug Fixes
|
19
|
+
|
20
|
+
* Optimize instrumentation and load time ([db4a8ce](https://github.com/applandinc/appmap-ruby/commit/db4a8ceed4103a52caafa46626c66f33fbfeac27))
|
21
|
+
|
22
|
+
# [0.45.0](https://github.com/applandinc/appmap-ruby/compare/v0.44.0...v0.45.0) (2021-05-03)
|
23
|
+
|
24
|
+
|
25
|
+
### Bug Fixes
|
26
|
+
|
27
|
+
* Properly name status_code in HTTP server response ([556e87c](https://github.com/applandinc/appmap-ruby/commit/556e87c9a7bf214f6b8714add4f77448fd223d33))
|
28
|
+
|
29
|
+
|
30
|
+
### Features
|
31
|
+
|
32
|
+
* Record http_client_request and http_client_response ([1db32ae](https://github.com/applandinc/appmap-ruby/commit/1db32ae0d26a7f1400b6b814d25b13368f06c158))
|
33
|
+
* Update AppMap format version to 1.5.0 ([061705e](https://github.com/applandinc/appmap-ruby/commit/061705e4619cb881e8edd022ef835183e399e127))
|
34
|
+
* **build:** add deployment via `semantic-release` with automatic publication to rubygems ([9f183de](https://github.com/applandinc/appmap-ruby/commit/9f183de13f405900000c3da979c3a8a5b6e34a24))
|
35
|
+
|
36
|
+
# v0.44.0
|
37
|
+
|
38
|
+
* Support recording and labeling of indivudal functions via `functions:` section in *appmap.yml*.
|
39
|
+
* Remove deprecated `exe/appmap`.
|
40
|
+
* Add `test_status` and `exception` fields to AppMap metadata.
|
41
|
+
* Write AppMap file atomically, by writing to a temp file first and then moving it into place.
|
42
|
+
* Remove printing of `Inventory.json` file.
|
43
|
+
* Remove source code from `classMap`.
|
44
|
+
|
1
45
|
# v0.43.0
|
2
46
|
|
3
47
|
* Record `name` and `class` of each entry in Hash-like parameters, messages, and return values.
|
data/README.md
CHANGED
@@ -9,10 +9,11 @@
|
|
9
9
|
- [Minitest](#minitest)
|
10
10
|
- [Cucumber](#cucumber)
|
11
11
|
- [Remote recording](#remote-recording)
|
12
|
-
- [Server process recording](#server-process-recording)
|
13
12
|
- [AppMap for VSCode](#appmap-for-vscode)
|
13
|
+
- [AppMap Swagger](#appmap-swagger)
|
14
14
|
- [Uploading AppMaps](#uploading-appmaps)
|
15
15
|
- [Development](#development)
|
16
|
+
- [Internal architecture](#internal-architecture)
|
16
17
|
- [Running tests](#running-tests)
|
17
18
|
- [Using fixture apps](#using-fixture-apps)
|
18
19
|
- [`test/fixtures`](#testfixtures)
|
@@ -109,6 +110,9 @@ name: my_project
|
|
109
110
|
packages:
|
110
111
|
- path: app/controllers
|
111
112
|
- path: app/models
|
113
|
+
# Exclude sub-paths within the package path
|
114
|
+
exclude:
|
115
|
+
- concerns/accessor
|
112
116
|
- path: app/jobs
|
113
117
|
- path: app/helpers
|
114
118
|
# Include the gems that you want to see in the dependency maps.
|
@@ -117,15 +121,22 @@ packages:
|
|
117
121
|
- gem: devise
|
118
122
|
- gem: aws-sdk
|
119
123
|
- gem: will_paginate
|
124
|
+
# Global exclusion of a class name
|
120
125
|
exclude:
|
121
126
|
- MyClass
|
122
127
|
- MyClass#my_instance_method
|
123
128
|
- MyClass.my_class_method
|
129
|
+
functions:
|
130
|
+
- packages: myapp
|
131
|
+
class: ControllerHelper
|
132
|
+
function: logged_in_user
|
133
|
+
labels: [ authentication ]
|
124
134
|
```
|
125
135
|
|
126
136
|
* **name** Provides the project name (required)
|
127
137
|
* **packages** A list of source code directories which should be recorded.
|
128
138
|
* **exclude** A list of classes and/or methods to definitively exclude from recording.
|
139
|
+
* **functions** A list of specific functions, scoped by package and class, to record.
|
129
140
|
|
130
141
|
**packages**
|
131
142
|
|
@@ -144,6 +155,11 @@ Each entry in the `packages` list is a YAML object which has the following keys:
|
|
144
155
|
|
145
156
|
Optional list of fully qualified class and method names. Separate class and method names with period (`.`) for class methods and hash (`#`) for instance methods.
|
146
157
|
|
158
|
+
**functions**
|
159
|
+
|
160
|
+
Optional list of `class, function` pairs. The `package` name is used to place the function within the class map, and does not have to match
|
161
|
+
the folder or gem name. The primary use of `functions` is to apply specific labels to functions whose source code is not accessible (e.g., it's in a Gem).
|
162
|
+
For functions which are part of the application code, use `@label` or `@labels` in code comments to apply labels.
|
147
163
|
|
148
164
|
# Labels
|
149
165
|
|
@@ -309,29 +325,40 @@ if defined?(AppMap)
|
|
309
325
|
end
|
310
326
|
```
|
311
327
|
|
312
|
-
2. Download and unpack the [AppLand browser extension](https://github.com/applandinc/appland-browser-extension). Install into Chrome using `chrome://extensions/`. Turn on "Developer Mode" and then load the extension using the "Load unpacked" button.
|
328
|
+
2. (optional) Download and unpack the [AppLand browser extension](https://github.com/applandinc/appland-browser-extension). Install into Chrome using `chrome://extensions/`. Turn on "Developer Mode" and then load the extension using the "Load unpacked" button.
|
313
329
|
|
314
|
-
3. Start your Rails application server
|
330
|
+
3. Start your Rails application server, with `APPMAP_RECORD=true`. For example:
|
315
331
|
|
316
332
|
```sh-session
|
317
|
-
$ bundle exec rails server
|
333
|
+
$ APPMAP_RECORD=true bundle exec rails server
|
318
334
|
```
|
319
335
|
|
320
|
-
4.
|
336
|
+
4. Start the recording
|
321
337
|
|
322
|
-
|
338
|
+
Option 1: Open the AppLand browser extension and push `Start`.
|
339
|
+
Option 2: `curl -XPOST localhost:3000/_appmap/record` (be sure and get the port number right)
|
323
340
|
|
324
|
-
|
341
|
+
5. Use your app. For example, perform a login flow, or run through a manual UI test.
|
325
342
|
|
326
|
-
|
343
|
+
6. Finish the recording.
|
327
344
|
|
328
|
-
|
345
|
+
Option 1: Open the AppLand browser extension and push `Stop`. The recording will be transferred to the AppLand website and opened in your browser.
|
346
|
+
Option 2: `curl -XDELETE localhost:3000/_appmap/record > recording.appmap.json` - Saves the recording as a local file.
|
329
347
|
|
330
|
-
Be sure and set `WEB_CONCURRENCY=1`, if you are using a webserver that can run multiple processes. You only want there to be one process while you are recording, otherwise they will both try and write *appmap.json* and one of them will clobber the other.
|
331
348
|
|
332
349
|
# AppMap for VSCode
|
333
350
|
|
334
|
-
The [AppMap extension for VSCode](https://marketplace.visualstudio.com/items?itemName=appland.appmap)
|
351
|
+
The [AppMap extension for VSCode](https://marketplace.visualstudio.com/items?itemName=appland.appmap) helps you navigate your code more efficiently with interactive, accurate software architecture diagrams right in your IDE. In less than two minutes you can go from installing the AppMap extension to exploring maps of your code's architecture. AppMap helps you:
|
352
|
+
|
353
|
+
* Onboard to code architecture, with no extra work for the team
|
354
|
+
* Conduct code and design reviews using live and accurate data
|
355
|
+
* Troubleshoot hard-to-understand bugs using a "top-down" approach.
|
356
|
+
|
357
|
+
Each interactive diagram links directly to the source code, and the information is easy to share.
|
358
|
+
|
359
|
+
# AppMap Swagger
|
360
|
+
|
361
|
+
[appmap_swagger](https://github.com/applandinc/appmap_swagger-ruby) is a tool to generate Swagger files from AppMap data. With `appmap_swagger`, you can add Swagger to your Ruby or Ruby on Rails project, with no need to write or modify code. Use the Swagger UI to interact with your web services API as you build it, and use diffs of Swagger to perform code review of web service changes.
|
335
362
|
|
336
363
|
# Uploading AppMaps
|
337
364
|
|
@@ -342,6 +369,34 @@ For instructions on uploading, see the documentation of the [AppLand CLI](https:
|
|
342
369
|
# Development
|
343
370
|
[![Build Status](https://travis-ci.com/applandinc/appmap-ruby.svg?branch=master)](https://travis-ci.com/applandinc/appmap-ruby)
|
344
371
|
|
372
|
+
## Internal architecture
|
373
|
+
|
374
|
+
**Configuration**
|
375
|
+
|
376
|
+
*appmap.yml* is loaded into an `AppMap::Config`.
|
377
|
+
|
378
|
+
**Hooking**
|
379
|
+
|
380
|
+
Once configuration is loaded, `AppMap::Hook` is enabled. "Hooking" refers to the process of replacing a method
|
381
|
+
with a "hooked" version of the method. The hooked method checks to see if tracing is enabled. If so, it wraps the original
|
382
|
+
method with calls that record the parameters and return value.
|
383
|
+
|
384
|
+
**Builtins**
|
385
|
+
|
386
|
+
`Hook` begins by iterating over builtin classes and modules defined in the `Config`. Builtins include code
|
387
|
+
like `openssl` and `net/http`. This code is not dependent on any external libraries being present, and
|
388
|
+
`appmap` cannot guarantee that it will be loaded before builtins. Therefore, it's necessary to require it and
|
389
|
+
hook it by looking up the classes and modules as constants in the `Object` namespace.
|
390
|
+
|
391
|
+
**User code and gems**
|
392
|
+
|
393
|
+
After hooking builtins, `Hook` attaches a [TracePoint](https://ruby-doc.org/core-2.6/TracePoint.html) to `:begin` events.
|
394
|
+
This TracePoint is notified each time a new class or module is being evaluated. When this happens, `Hook` uses the `Config`
|
395
|
+
to determine whether any code within the evaluated file is configured for hooking. If so, a `TracePoint` is attached to
|
396
|
+
`:end` events. Each `:end` event is fired when a class or module definition is completed. When this happens, the `Hook` enumerates
|
397
|
+
the public methods of the class or module, hooking the ones that are targeted by the `Config`. Once the `:end` TracePoint leaves
|
398
|
+
the scope of the `:begin`, the `:end` TracePoint is disabled.
|
399
|
+
|
345
400
|
## Running tests
|
346
401
|
|
347
402
|
Before running tests, configure `local.appmap` to point to your local `appmap-ruby` directory.
|
data/README_CI.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Configuration variables:
|
2
|
+
|
3
|
+
* `GH_TOKEN`: used by `semantic-release` to push changes to Github and manage releases
|
4
|
+
* `GEM_HOST_API_KEY`: rubygems API key
|
5
|
+
* `GEM_ALTERNATIVE_NAME` (optional): used for testing of CI flows,
|
6
|
+
to avoid publication of test releases under official package name
|
7
|
+
* `DOCKERHUB\_USERNAME`, `DOCKERHUB_PASSWORD`: optional dockerhub credentials,
|
8
|
+
to avoid throttling of dockerhub anonymous pulls
|
9
|
+
|
10
|
+
Note: for security reasons, it's better to use dedicated (not personal)
|
11
|
+
Dockerhub account,
|
12
|
+
and also use [access tokens](https://docs.docker.com/docker-hub/access-tokens/)
|
13
|
+
instead of primary password
|
14
|
+
|
15
|
+
# Release command
|
16
|
+
|
17
|
+
`./release.sh`
|
18
|
+
|
19
|
+
Bash wrapper script is used merely as a launcher of `semantic-release`
|
20
|
+
with extra logic to explicitly determine git url from `TRAVIS_REPO_SLUG` \
|
21
|
+
variable if its defined (otherwise git url is taken from `package.json`,
|
22
|
+
which breaks CI on forked repos).
|
23
|
+
|
24
|
+
# CI flow
|
25
|
+
|
26
|
+
1. Test happens using current version number specified in `lib/appmap/version.rb`, then `release.sh` launches `semantic-release` to do the rest
|
27
|
+
2. The version number is increased (including modicication of `version.rb`)
|
28
|
+
3. Gem is published under new version number
|
29
|
+
4. Github release is created with the new version number
|
data/Rakefile
CHANGED
@@ -37,7 +37,8 @@ end
|
|
37
37
|
|
38
38
|
def build_base_image(ruby_version)
|
39
39
|
run_cmd "docker build" \
|
40
|
-
" --build-arg RUBY_VERSION=#{ruby_version}
|
40
|
+
" --build-arg RUBY_VERSION=#{ruby_version}" \
|
41
|
+
" --build-arg GEM_VERSION=#{GEM_VERSION}" \
|
41
42
|
" -t appmap:#{GEM_VERSION} -f Dockerfile.appmap ."
|
42
43
|
end
|
43
44
|
|
@@ -46,7 +47,7 @@ def build_app_image(app, ruby_version)
|
|
46
47
|
run_cmd( {"RUBY_VERSION" => ruby_version, "GEM_VERSION" => GEM_VERSION},
|
47
48
|
" docker-compose build" \
|
48
49
|
" --build-arg RUBY_VERSION=#{ruby_version}" \
|
49
|
-
" --build-arg GEM_VERSION=#{GEM_VERSION}")
|
50
|
+
" --build-arg GEM_VERSION=#{GEM_VERSION}" )
|
50
51
|
end
|
51
52
|
end
|
52
53
|
|
@@ -138,3 +139,4 @@ task spec: %i[spec:all]
|
|
138
139
|
task test: %i[spec:all minitest]
|
139
140
|
|
140
141
|
task default: :test
|
142
|
+
|
data/appmap.gemspec
CHANGED
@@ -4,8 +4,12 @@ lib = File.expand_path('lib', __dir__)
|
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
5
|
require 'appmap/version'
|
6
6
|
|
7
|
+
|
8
|
+
|
7
9
|
Gem::Specification.new do |spec|
|
8
|
-
|
10
|
+
# ability to parameterize gem name is added intentionally,
|
11
|
+
# to support the possibility of unofficial releases, e.g. during CI tests
|
12
|
+
spec.name = (ENV['GEM_ALTERNATIVE_NAME'].to_s.empty? ? 'appmap' : ENV["GEM_ALTERNATIVE_NAME"] )
|
9
13
|
spec.version = AppMap::VERSION
|
10
14
|
spec.authors = ['Kevin Gilpin']
|
11
15
|
spec.email = ['kgilpin@gmail.com']
|
@@ -20,8 +24,6 @@ Gem::Specification.new do |spec|
|
|
20
24
|
")
|
21
25
|
spec.extensions << "ext/appmap/extconf.rb"
|
22
26
|
|
23
|
-
spec.bindir = 'exe'
|
24
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
27
|
spec.require_paths = ['lib']
|
26
28
|
|
27
29
|
spec.add_dependency 'activesupport'
|
data/lib/appmap.rb
CHANGED
@@ -43,6 +43,7 @@ module AppMap
|
|
43
43
|
# Call this function before the program code is loaded by the Ruby VM, otherwise
|
44
44
|
# the load events won't be seen and the hooks won't activate.
|
45
45
|
def initialize(config_file_path = 'appmap.yml')
|
46
|
+
raise "AppMap configuration file #{config_file_path} does not exist" unless ::File.exists?(config_file_path)
|
46
47
|
warn "Configuring AppMap from path #{config_file_path}"
|
47
48
|
Config.load_from_file(config_file_path).tap do |configuration|
|
48
49
|
self.configuration = configuration
|
@@ -50,11 +51,6 @@ module AppMap
|
|
50
51
|
end
|
51
52
|
end
|
52
53
|
|
53
|
-
# Whether to include source and comments in all class maps.
|
54
|
-
def include_source?
|
55
|
-
ENV['APPMAP_SOURCE'] == 'true'
|
56
|
-
end
|
57
|
-
|
58
54
|
# Used to start tracing, stop tracing, and record events.
|
59
55
|
def tracing
|
60
56
|
@tracing ||= Trace::Tracing.new
|
@@ -88,8 +84,8 @@ module AppMap
|
|
88
84
|
end
|
89
85
|
|
90
86
|
# Builds a class map from a config and a list of Ruby methods.
|
91
|
-
def class_map(methods
|
92
|
-
ClassMap.build_from_methods(methods
|
87
|
+
def class_map(methods)
|
88
|
+
ClassMap.build_from_methods(methods)
|
93
89
|
end
|
94
90
|
|
95
91
|
# Returns default metadata detected from the Ruby system and from the
|
data/lib/appmap/class_map.rb
CHANGED
@@ -71,27 +71,24 @@ module AppMap
|
|
71
71
|
end
|
72
72
|
|
73
73
|
class << self
|
74
|
-
def build_from_methods(methods
|
74
|
+
def build_from_methods(methods)
|
75
75
|
root = Types::Root.new
|
76
76
|
methods.each do |method|
|
77
|
-
add_function root, method
|
77
|
+
add_function root, method
|
78
78
|
end
|
79
79
|
root.children.map(&:to_h)
|
80
80
|
end
|
81
81
|
|
82
82
|
protected
|
83
83
|
|
84
|
-
def add_function(root, method
|
85
|
-
package = method.package
|
86
|
-
static = method.static
|
87
|
-
|
84
|
+
def add_function(root, method)
|
88
85
|
object_infos = [
|
89
86
|
{
|
90
|
-
name: package
|
87
|
+
name: method.package,
|
91
88
|
type: 'package'
|
92
89
|
}
|
93
90
|
]
|
94
|
-
object_infos += method.
|
91
|
+
object_infos += method.class_name.split('::').map do |name|
|
95
92
|
{
|
96
93
|
name: name,
|
97
94
|
type: 'class'
|
@@ -100,7 +97,7 @@ module AppMap
|
|
100
97
|
function_info = {
|
101
98
|
name: method.name,
|
102
99
|
type: 'function',
|
103
|
-
static: static
|
100
|
+
static: method.static
|
104
101
|
}
|
105
102
|
location = method.source_location
|
106
103
|
|
@@ -108,23 +105,15 @@ module AppMap
|
|
108
105
|
if location
|
109
106
|
location_file, lineno = location
|
110
107
|
location_file = location_file[Dir.pwd.length + 1..-1] if location_file.index(Dir.pwd) == 0
|
111
|
-
[ location_file, lineno ].join(':')
|
108
|
+
[ location_file, lineno ].compact.join(':')
|
112
109
|
else
|
113
|
-
[ method.
|
110
|
+
[ method.class_name, method.static ? '.' : '#', method.name ].join
|
114
111
|
end
|
115
112
|
|
116
|
-
|
117
|
-
|
118
|
-
rescue MethodSource::SourceNotFoundError
|
119
|
-
[ nil, nil, ]
|
120
|
-
end
|
121
|
-
|
122
|
-
if include_source
|
123
|
-
function_info[:source] = source unless source.blank?
|
124
|
-
function_info[:comment] = comment unless comment.blank?
|
125
|
-
end
|
113
|
+
comment = method.comment
|
114
|
+
function_info[:comment] = comment unless comment.blank?
|
126
115
|
|
127
|
-
function_info[:labels] = parse_labels(comment) + (
|
116
|
+
function_info[:labels] = parse_labels(comment) + (method.labels || [])
|
128
117
|
object_infos << function_info
|
129
118
|
|
130
119
|
parent = root
|