appmap 0.48.0 → 0.51.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.dockerignore +0 -1
- data/CHANGELOG.md +43 -0
- data/README.md +3 -332
- data/lib/appmap.rb +33 -6
- data/lib/appmap/config.rb +123 -33
- data/lib/appmap/event.rb +1 -1
- data/lib/appmap/hook.rb +15 -30
- data/lib/appmap/minitest.rb +9 -3
- data/lib/appmap/railtie.rb +7 -0
- data/lib/appmap/rspec.rb +9 -3
- data/lib/appmap/util.rb +24 -1
- data/lib/appmap/version.rb +3 -1
- data/spec/abstract_controller_base_spec.rb +57 -18
- data/spec/config_spec.rb +21 -0
- data/spec/fixtures/hook/exception_method.rb +6 -0
- data/spec/fixtures/rails5_users_app/config/application.rb +0 -8
- data/spec/fixtures/rails5_users_app/spec/rails_helper.rb +0 -2
- data/spec/fixtures/rails6_users_app/config/application.rb +0 -8
- data/spec/fixtures/rails6_users_app/spec/rails_helper.rb +0 -2
- data/spec/hook_spec.rb +35 -3
- data/spec/record_net_http_spec.rb +1 -1
- data/test/bundle_vendor_test.rb +35 -0
- data/test/fixtures/bundle_vendor_app/Gemfile +8 -0
- data/test/fixtures/bundle_vendor_app/appmap.yml +4 -0
- data/test/fixtures/bundle_vendor_app/cli.rb +54 -0
- data/test/gem_test.rb +1 -1
- metadata +6 -4
- data/spec/fixtures/rails5_users_app/config/initializers/record_button.rb +0 -3
- data/spec/fixtures/rails6_users_app/config/initializers/record_button.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cbe39a5de48eb36889755224aa85f8d1bee3af0c75a9eb00a28dd8bdc92cc5c0
|
4
|
+
data.tar.gz: 284eae1f685e7fe5f8d897f96027683119fc26d64de03e7be108341fff8783f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a50f7cf525571c964bff72d7da580f9a38cc6eba0f31e03a592cd5cd4b1321cba70a0d3e0e8b4fb22da6bf9e4d50cbc3f5b3d346b52cc8e6749626b71197b8fa
|
7
|
+
data.tar.gz: 7850f7fabe85ea64d1e97f841a1cbd3b944005b7959cd4e75ddca0cc7788bcad7640420ee3b12003387399c332a95d0c90550caa2a0ce065d463f33f0fd416e3
|
data/.dockerignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,46 @@
|
|
1
|
+
# [0.51.0](https://github.com/applandinc/appmap-ruby/compare/v0.50.0...v0.51.0) (2021-06-21)
|
2
|
+
|
3
|
+
|
4
|
+
### Features
|
5
|
+
|
6
|
+
* Provide default appmap.yml settings ([7fa8159](https://github.com/applandinc/appmap-ruby/commit/7fa8159b5020e35f13379017b44906d671e62e64))
|
7
|
+
|
8
|
+
# [0.50.0](https://github.com/applandinc/appmap-ruby/compare/v0.49.0...v0.50.0) (2021-06-17)
|
9
|
+
|
10
|
+
|
11
|
+
### Bug Fixes
|
12
|
+
|
13
|
+
* Remove appmap configuration in test cases which now occurs automatically ([7391c4c](https://github.com/applandinc/appmap-ruby/commit/7391c4c36ed80f98a6b82ccd43f05de488e7cd2f))
|
14
|
+
|
15
|
+
|
16
|
+
### Features
|
17
|
+
|
18
|
+
* Direct minitest and rspec startup messages to the Rails log, when available ([15f6444](https://github.com/applandinc/appmap-ruby/commit/15f6444b0fad3ce7d9e91273b6a1116e470c2a89))
|
19
|
+
* Enroll railtie, rspec, and minitest helpers automatically ([1709374](https://github.com/applandinc/appmap-ruby/commit/1709374ee7b5183482c55cf4c7386266fa517262))
|
20
|
+
* railtie enrolls the app in remote recording ([3a1f8aa](https://github.com/applandinc/appmap-ruby/commit/3a1f8aac1d83c4df04b5da55ed33d418235e348b))
|
21
|
+
|
22
|
+
# [0.49.0](https://github.com/applandinc/appmap-ruby/compare/v0.48.2...v0.49.0) (2021-06-16)
|
23
|
+
|
24
|
+
|
25
|
+
### Features
|
26
|
+
|
27
|
+
* Add refinement to the labels ([6a93396](https://github.com/applandinc/appmap-ruby/commit/6a93396ba73f1b3ed21b4e9e15a2c271af04d866))
|
28
|
+
|
29
|
+
## [0.48.2](https://github.com/applandinc/appmap-ruby/compare/v0.48.1...v0.48.2) (2021-05-26)
|
30
|
+
|
31
|
+
|
32
|
+
### Bug Fixes
|
33
|
+
|
34
|
+
* Correct the method-hooking logic to capture some missing model methods ([be529bd](https://github.com/applandinc/appmap-ruby/commit/be529bdce7d4fdf9f1a2fdd32259d792f29f4f13))
|
35
|
+
|
36
|
+
## [0.48.1](https://github.com/applandinc/appmap-ruby/compare/v0.48.0...v0.48.1) (2021-05-25)
|
37
|
+
|
38
|
+
|
39
|
+
### Bug Fixes
|
40
|
+
|
41
|
+
* Account for bundle path when normalizing source path ([095c278](https://github.com/applandinc/appmap-ruby/commit/095c27818fc8ae8dfa39b30516d37c6dfd642d9c))
|
42
|
+
* Scan exception messages for non-UTF8 characters ([3dcaeae](https://github.com/applandinc/appmap-ruby/commit/3dcaeae44da5e40e432eda41caf5b9ebff5bea12))
|
43
|
+
|
1
44
|
# [0.48.0](https://github.com/applandinc/appmap-ruby/compare/v0.47.1...v0.48.0) (2021-05-19)
|
2
45
|
|
3
46
|
|
data/README.md
CHANGED
@@ -1,17 +1,6 @@
|
|
1
1
|
|
2
2
|
- [About](#about)
|
3
|
-
|
4
|
-
- [Installation](#installation)
|
5
|
-
- [Configuration](#configuration)
|
6
|
-
- [Labels](#labels)
|
7
|
-
- [Running](#running)
|
8
|
-
- [RSpec](#rspec)
|
9
|
-
- [Minitest](#minitest)
|
10
|
-
- [Cucumber](#cucumber)
|
11
|
-
- [Remote recording](#remote-recording)
|
12
|
-
- [AppMap for VSCode](#appmap-for-vscode)
|
13
|
-
- [AppMap Swagger](#appmap-swagger)
|
14
|
-
- [Uploading AppMaps](#uploading-appmaps)
|
3
|
+
- [Usage](#usage)
|
15
4
|
- [Development](#development)
|
16
5
|
- [Internal architecture](#internal-architecture)
|
17
6
|
- [Running tests](#running-tests)
|
@@ -19,7 +8,6 @@
|
|
19
8
|
- [`test/fixtures`](#testfixtures)
|
20
9
|
- [`spec/fixtures`](#specfixtures)
|
21
10
|
|
22
|
-
|
23
11
|
# About
|
24
12
|
|
25
13
|
`appmap-ruby` is a Ruby Gem for recording
|
@@ -29,326 +17,9 @@
|
|
29
17
|
SHA, labels, etc). It's more granular than a performance profile, but it's less
|
30
18
|
granular than a full debug trace. It's designed to be optimal for understanding the design intent and structure of code and key data flows.
|
31
19
|
|
32
|
-
|
33
|
-
|
34
|
-
* Run your tests (RSpec, Minitest, Cucumber) with the environment variable `APPMAP=true`. An AppMap will be generated for each spec.
|
35
|
-
* Run your application server with AppMap remote recording enabled, and use the [AppLand
|
36
|
-
browser extension](https://github.com/applandinc/appland-browser-extension) to start,
|
37
|
-
stop, and upload recordings.
|
38
|
-
* Wrap some code in an `AppMap.record` block, which returns JSON containing the code execution trace.
|
39
|
-
|
40
|
-
Once you have made a recording, there are two ways to view automatically generated diagrams of the AppMaps.
|
41
|
-
|
42
|
-
The first option is to load the diagrams directly in your IDE, using the [AppMap extension for VSCode](https://marketplace.visualstudio.com/items?itemName=appland.appmap).
|
43
|
-
|
44
|
-
The second option is to upload them to the [AppLand server](https://app.land) using the [AppLand CLI](https://github.com/applandinc/appland-cli/releases).
|
45
|
-
|
46
|
-
### Supported versions
|
47
|
-
|
48
|
-
* Ruby 2.5, 2.6, 2.7
|
49
|
-
* Rails 5, 6
|
50
|
-
|
51
|
-
Support for new versions is added frequently, please check back regularly for updates.
|
52
|
-
|
53
|
-
# Installation
|
54
|
-
|
55
|
-
<a href="https://www.loom.com/share/78ab32a312ff4b85aa8827a37f1cb655"> <p>Quick and easy setup of the AppMap gem for Rails - Watch Video</p> <img style="max-width:300px;" src="https://cdn.loom.com/sessions/thumbnails/78ab32a312ff4b85aa8827a37f1cb655-with-play.gif"> </a>
|
56
|
-
|
57
|
-
|
58
|
-
Add `gem 'appmap'` to **beginning** of your Gemfile. We recommend that you add the `appmap` gem to the `:development, :test` group. Your Gemfile should look something like this:
|
59
|
-
|
60
|
-
```
|
61
|
-
source 'https://rubygems.org'
|
62
|
-
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
63
|
-
|
64
|
-
# Optional rubRuby version
|
65
|
-
# ruby '2.7.2'
|
66
|
-
|
67
|
-
group :development, :test do
|
68
|
-
gem 'appmap'
|
69
|
-
end
|
70
|
-
```
|
71
|
-
|
72
|
-
Install with `bundle install`, as usual.
|
73
|
-
|
74
|
-
It's important to add the `appmap` gem before any other gems that you may want to instrument. There is more about this in the section on adding gems to the *appmap.yml*.
|
75
|
-
|
76
|
-
**Railtie**
|
77
|
-
|
78
|
-
If you are using Ruby on Rails, require the railtie after Rails is loaded.
|
79
|
-
|
80
|
-
```
|
81
|
-
# application.rb is a good place to do this, along with all the other railties.
|
82
|
-
# Don't require the railtie in environments that don't bundle the appmap gem.
|
83
|
-
require 'appmap/railtie' if defined?(AppMap).
|
84
|
-
```
|
85
|
-
|
86
|
-
# Configuration
|
87
|
-
|
88
|
-
When you run your program, the `appmap` gem reads configuration settings from `appmap.yml`. Here's a sample configuration
|
89
|
-
file for a typical Rails project:
|
90
|
-
|
91
|
-
```yaml
|
92
|
-
# 'name' should generally be the same as the code repo name.
|
93
|
-
name: my_project
|
94
|
-
packages:
|
95
|
-
- path: app/controllers
|
96
|
-
- path: app/models
|
97
|
-
# Exclude sub-paths within the package path
|
98
|
-
exclude:
|
99
|
-
- concerns/accessor
|
100
|
-
- path: app/jobs
|
101
|
-
- path: app/helpers
|
102
|
-
# Include the gems that you want to see in the dependency maps.
|
103
|
-
# These are just examples.
|
104
|
-
- gem: activerecord
|
105
|
-
- gem: devise
|
106
|
-
- gem: aws-sdk
|
107
|
-
- gem: will_paginate
|
108
|
-
# Global exclusion of a class name
|
109
|
-
exclude:
|
110
|
-
- MyClass
|
111
|
-
- MyClass#my_instance_method
|
112
|
-
- MyClass.my_class_method
|
113
|
-
functions:
|
114
|
-
- packages: myapp
|
115
|
-
class: ControllerHelper
|
116
|
-
function: logged_in_user
|
117
|
-
labels: [ authentication ]
|
118
|
-
```
|
119
|
-
|
120
|
-
* **name** Provides the project name (required)
|
121
|
-
* **packages** A list of source code directories which should be recorded.
|
122
|
-
* **exclude** A list of classes and/or methods to definitively exclude from recording.
|
123
|
-
* **functions** A list of specific functions, scoped by package and class, to record.
|
124
|
-
|
125
|
-
**packages**
|
126
|
-
|
127
|
-
Each entry in the `packages` list is a YAML object which has the following keys:
|
128
|
-
|
129
|
-
* **path** The path to the source code directory. The path may be relative to the current working directory, or it may
|
130
|
-
be an absolute path.
|
131
|
-
* **gem** As an alternative to specifying the path, specify the name of a dependency gem. When using `gem`, don't specify `path`. In your `Gemfile`, the `appmap` gem **must** be listed **before** any gem that you specify in your *appmap.yml*.
|
132
|
-
* **exclude** A list of files and directories which will be ignored. By default, all modules, classes and public
|
133
|
-
functions are inspected. See also: global `exclude` list.
|
134
|
-
* **shallow** When set to `true`, only the first function call entry into a package will be recorded. Subsequent function calls within
|
135
|
-
the same package are not recorded unless code execution leaves the package and re-enters it. Default: `true` when using `gem`,
|
136
|
-
`false` when using `path`.
|
137
|
-
|
138
|
-
**exclude**
|
139
|
-
|
140
|
-
Optional list of fully qualified class and method names. Separate class and method names with period (`.`) for class methods and hash (`#`) for instance methods.
|
141
|
-
|
142
|
-
**functions**
|
143
|
-
|
144
|
-
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
|
145
|
-
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).
|
146
|
-
For functions which are part of the application code, use `@label` or `@labels` in code comments to apply labels.
|
147
|
-
|
148
|
-
# Labels
|
149
|
-
|
150
|
-
The [AppMap data format](https://github.com/applandinc/appmap) provides for class and function `labels`, which can be used to enhance the AppMap visualizations, and to programatically analyze the data.
|
151
|
-
|
152
|
-
You can apply function labels using source code comments in your Ruby code. To apply a labels to a function, add a `@label` or `@labels` line to the comment which immediately precedes a function.
|
153
|
-
|
154
|
-
For example, if you add this comment to your source code:
|
155
|
-
|
156
|
-
```ruby
|
157
|
-
class ApiKey
|
158
|
-
# @labels provider.authentication security
|
159
|
-
def authenticate(key)
|
160
|
-
# logic to verify the key here...
|
161
|
-
end
|
162
|
-
end
|
163
|
-
```
|
164
|
-
|
165
|
-
Then the AppMap metadata section for this function will include:
|
166
|
-
|
167
|
-
```json
|
168
|
-
{
|
169
|
-
"name": "authenticate",
|
170
|
-
"type": "function",
|
171
|
-
"labels": [ "provider.authentication", "security" ]
|
172
|
-
}
|
173
|
-
```
|
174
|
-
|
175
|
-
|
176
|
-
# Running
|
177
|
-
|
178
|
-
## RSpec
|
179
|
-
|
180
|
-
To record RSpec tests, follow these additional steps:
|
181
|
-
|
182
|
-
1) Require `appmap/rspec` in your `spec_helper.rb` before any other classes are loaded.
|
183
|
-
|
184
|
-
```ruby
|
185
|
-
require 'appmap/rspec'
|
186
|
-
```
|
187
|
-
|
188
|
-
Note that `spec_helper.rb` in a Rails project typically loads the application's classes this way:
|
189
|
-
|
190
|
-
```ruby
|
191
|
-
require File.expand_path("../../config/environment", __FILE__)
|
192
|
-
```
|
193
|
-
|
194
|
-
and `appmap/rspec` must be required before this:
|
195
|
-
|
196
|
-
```ruby
|
197
|
-
require 'appmap/rspec'
|
198
|
-
require File.expand_path("../../config/environment", __FILE__)
|
199
|
-
```
|
200
|
-
|
201
|
-
2) Run the tests with the environment variable `APPMAP=true`:
|
202
|
-
|
203
|
-
```sh-session
|
204
|
-
$ APPMAP=true bundle exec rspec
|
205
|
-
```
|
206
|
-
|
207
|
-
Each RSpec test will output an AppMap file into the directory `tmp/appmap/rspec`. For example:
|
208
|
-
|
209
|
-
```
|
210
|
-
$ find tmp/appmap/rspec
|
211
|
-
Hello_says_hello_when_prompted.appmap.json
|
212
|
-
```
|
213
|
-
|
214
|
-
## Minitest
|
215
|
-
|
216
|
-
To record Minitest tests, follow these additional steps:
|
217
|
-
|
218
|
-
1) Require `appmap/minitest` in `test_helper.rb`
|
219
|
-
|
220
|
-
```ruby
|
221
|
-
require 'appmap/minitest'
|
222
|
-
```
|
223
|
-
|
224
|
-
Note that `test_helper.rb` in a Rails project typically loads the application's classes this way:
|
225
|
-
|
226
|
-
```ruby
|
227
|
-
require_relative '../config/environment'
|
228
|
-
```
|
229
|
-
|
230
|
-
and `appmap/minitest` must be required before this:
|
231
|
-
|
232
|
-
```ruby
|
233
|
-
require 'appmap/minitest'
|
234
|
-
require_relative '../config/environment'
|
235
|
-
```
|
236
|
-
|
237
|
-
2) Run your tests as you normally would with the environment variable `APPMAP=true`. For example:
|
238
|
-
|
239
|
-
```
|
240
|
-
$ APPMAP=true bundle exec rake test
|
241
|
-
```
|
242
|
-
|
243
|
-
or
|
244
|
-
|
245
|
-
```
|
246
|
-
$ APPMAP=true bundle exec ruby -Ilib -Itest test/*_test.rb
|
247
|
-
```
|
248
|
-
|
249
|
-
Each Minitest test will output an AppMap file into the directory `tmp/appmap/minitest`. For example:
|
250
|
-
|
251
|
-
```
|
252
|
-
$ find tmp/appmap/minitest
|
253
|
-
Hello_says_hello_when_prompted.appmap.json
|
254
|
-
```
|
255
|
-
|
256
|
-
## Cucumber
|
257
|
-
|
258
|
-
To record Cucumber tests, follow these additional steps:
|
259
|
-
|
260
|
-
1) Require `appmap/cucumber` in `support/env.rb`:
|
261
|
-
|
262
|
-
```ruby
|
263
|
-
require 'appmap/cucumber'
|
264
|
-
```
|
265
|
-
|
266
|
-
Be sure to require it before `config/environment` is required.
|
267
|
-
|
268
|
-
2) Create an `Around` hook in `support/hooks.rb` to record the scenario:
|
269
|
-
|
270
|
-
|
271
|
-
```ruby
|
272
|
-
if AppMap::Cucumber.enabled?
|
273
|
-
Around('not @appmap-disable') do |scenario, block|
|
274
|
-
appmap = AppMap.record do
|
275
|
-
block.call
|
276
|
-
end
|
277
|
-
|
278
|
-
AppMap::Cucumber.write_scenario(scenario, appmap)
|
279
|
-
end
|
280
|
-
end
|
281
|
-
```
|
282
|
-
|
283
|
-
3) Run the tests with the environment variable `APPMAP=true`:
|
284
|
-
|
285
|
-
```sh-session
|
286
|
-
$ APPMAP=true bundle exec cucumber
|
287
|
-
```
|
288
|
-
|
289
|
-
Each Cucumber test will output an AppMap file into the directory `tmp/appmap/cucumber`. For example:
|
290
|
-
|
291
|
-
```
|
292
|
-
$ find tmp/appmap/cucumber
|
293
|
-
Hello_Says_hello_when_prompted.appmap.json
|
294
|
-
```
|
295
|
-
|
296
|
-
## Remote recording
|
297
|
-
|
298
|
-
To manually record ad-hoc AppMaps of your Ruby app, use AppMap remote recording.
|
299
|
-
|
300
|
-
1. Add the AppMap remote recording middleware. For example, in `config/initializers/appmap_remote_recording.rb`:
|
301
|
-
|
302
|
-
```ruby
|
303
|
-
if defined?(AppMap)
|
304
|
-
require 'appmap/middleware/remote_recording'
|
305
|
-
|
306
|
-
Rails.application.config.middleware.insert_after \
|
307
|
-
Rails::Rack::Logger,
|
308
|
-
AppMap::Middleware::RemoteRecording
|
309
|
-
end
|
310
|
-
```
|
311
|
-
|
312
|
-
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
|
-
|
314
|
-
3. Start your Rails application server, with `APPMAP_RECORD=true`. For example:
|
315
|
-
|
316
|
-
```sh-session
|
317
|
-
$ APPMAP_RECORD=true bundle exec rails server
|
318
|
-
```
|
319
|
-
|
320
|
-
4. Start the recording
|
321
|
-
|
322
|
-
Option 1: Open the AppLand browser extension and push `Start`.
|
323
|
-
Option 2: `curl -XPOST localhost:3000/_appmap/record` (be sure and get the port number right)
|
324
|
-
|
325
|
-
5. Use your app. For example, perform a login flow, or run through a manual UI test.
|
326
|
-
|
327
|
-
6. Finish the recording.
|
328
|
-
|
329
|
-
Option 1: Open the AppLand browser extension and push `Stop`. The recording will be transferred to the AppLand website and opened in your browser.
|
330
|
-
Option 2: `curl -XDELETE localhost:3000/_appmap/record > recording.appmap.json` - Saves the recording as a local file.
|
331
|
-
|
332
|
-
|
333
|
-
# AppMap for VSCode
|
334
|
-
|
335
|
-
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:
|
336
|
-
|
337
|
-
* Onboard to code architecture, with no extra work for the team
|
338
|
-
* Conduct code and design reviews using live and accurate data
|
339
|
-
* Troubleshoot hard-to-understand bugs using a "top-down" approach.
|
340
|
-
|
341
|
-
Each interactive diagram links directly to the source code, and the information is easy to share.
|
342
|
-
|
343
|
-
# AppMap Swagger
|
344
|
-
|
345
|
-
[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.
|
346
|
-
|
347
|
-
# Uploading AppMaps
|
348
|
-
|
349
|
-
[https://app.land](https://app.land) can be used to store, analyze, and share AppMaps.
|
20
|
+
# Usage
|
350
21
|
|
351
|
-
|
22
|
+
Visit the [AppMap for Ruby](https://appland.com/docs/reference/appmap-ruby.html) reference page on AppLand.com for a complete reference guide.
|
352
23
|
|
353
24
|
# Development
|
354
25
|
[![Build Status](https://travis-ci.com/applandinc/appmap-ruby.svg?branch=master)](https://travis-ci.com/applandinc/appmap-ruby)
|
data/lib/appmap.rb
CHANGED
@@ -27,7 +27,7 @@ module AppMap
|
|
27
27
|
# Gets the configuration. If there is no configuration, the default
|
28
28
|
# configuration is initialized.
|
29
29
|
def configuration
|
30
|
-
@configuration ||=
|
30
|
+
@configuration ||= initialize_configuration
|
31
31
|
end
|
32
32
|
|
33
33
|
# Sets the configuration. This is only expected to happen once per
|
@@ -38,12 +38,19 @@ module AppMap
|
|
38
38
|
@configuration = config
|
39
39
|
end
|
40
40
|
|
41
|
-
|
41
|
+
def default_config_file_path
|
42
|
+
ENV['APPMAP_CONFIG_FILE'] || 'appmap.yml'
|
43
|
+
end
|
44
|
+
|
45
|
+
# Configures AppMap for recording. Default behavior is to configure from
|
46
|
+
# APPMAP_CONFIG_FILE, or 'appmap.yml'. If no config file is available, a
|
47
|
+
# configuration will be automatically generated and used - and the user is prompted
|
48
|
+
# to create the config file.
|
49
|
+
#
|
42
50
|
# This method also activates the code hooks which record function calls as trace events.
|
43
51
|
# Call this function before the program code is loaded by the Ruby VM, otherwise
|
44
52
|
# the load events won't be seen and the hooks won't activate.
|
45
|
-
def
|
46
|
-
raise "AppMap configuration file #{config_file_path} does not exist" unless ::File.exists?(config_file_path)
|
53
|
+
def initialize_configuration(config_file_path = default_config_file_path)
|
47
54
|
warn "Configuring AppMap from path #{config_file_path}"
|
48
55
|
Config.load_from_file(config_file_path).tap do |configuration|
|
49
56
|
self.configuration = configuration
|
@@ -51,6 +58,14 @@ module AppMap
|
|
51
58
|
end
|
52
59
|
end
|
53
60
|
|
61
|
+
def info(msg)
|
62
|
+
if defined?(::Rails) && defined?(::Rails.logger)
|
63
|
+
::Rails.logger.info msg
|
64
|
+
else
|
65
|
+
warn msg
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
54
69
|
# Used to start tracing, stop tracing, and record events.
|
55
70
|
def tracing
|
56
71
|
@tracing ||= Trace::Tracing.new
|
@@ -97,5 +112,17 @@ module AppMap
|
|
97
112
|
end
|
98
113
|
end
|
99
114
|
|
100
|
-
|
101
|
-
|
115
|
+
if defined?(::Rails::Railtie)
|
116
|
+
require 'appmap/railtie'
|
117
|
+
end
|
118
|
+
|
119
|
+
if defined?(::RSpec)
|
120
|
+
require 'appmap/rspec'
|
121
|
+
end
|
122
|
+
|
123
|
+
# defined?(::Minitest) returns nil...
|
124
|
+
if Gem.loaded_specs['minitest']
|
125
|
+
require 'appmap/minitest'
|
126
|
+
end
|
127
|
+
|
128
|
+
AppMap.initialize_configuration if ENV['APPMAP'] == 'true'
|