appmap 0.48.2 → 0.51.2

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: 455ac48f4acf31694cb571912703f62b95687b8b833be0ced7b8ab5008c3960b
4
- data.tar.gz: 272c68f804affe1a461ec504475b95d1c7968e506644442437a45dd28ff7d664
3
+ metadata.gz: 194f53c7e13b466fef13720503fe9f8c1ee149af724884224ce03753cc0d658f
4
+ data.tar.gz: e9c7d5578da6d9e80d9c06e70deaa32fe7da785ab94840a09739e474601a8cac
5
5
  SHA512:
6
- metadata.gz: 3bfbb562490380393c669aaeb2813389a52bf18f8e769f69a496ffe9fc26a493d9f55cfa161926d26deca370b1e18f99896eb0e269e59cbd6647801b7238c565
7
- data.tar.gz: ba4b69852fc4be1850b5fd20c713e21799848bd32a251cdcc3bae87e4bf25605621dccc381e32018397ff52bbc442859065d8f1d8313211c135c1a9fb3ecb6d7
6
+ metadata.gz: 82da50065460e83bbbd0f35bdce8e04924d9e0388f1da9ba30cea0637594dce2d8dc3a9364c55e1492924e73dfb91cf163eac7fe7028e4b48eb5cb3c34a96c92
7
+ data.tar.gz: 96198ca1c1f3c5bdcd4d75ce275f8e76a39ff9c36cbaf314c642d91dac54403426a28b54c5a478a58295560af804dc3f44ac33ff9b1b710b1d401fab4c72cb75
data/CHANGELOG.md CHANGED
@@ -1,3 +1,48 @@
1
+ ## [0.51.2](https://github.com/applandinc/appmap-ruby/compare/v0.51.1...v0.51.2) (2021-06-22)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Be less verbose when logging config messages ([fba2fd0](https://github.com/applandinc/appmap-ruby/commit/fba2fd01dbb7b1830194b49285654d6657d1c786))
7
+ * Method objects must support eql? and hash to ensure they are unique in a Set ([f4d5b11](https://github.com/applandinc/appmap-ruby/commit/f4d5b11db90aa50bdd1f768e039927833e83c30f))
8
+ * Require rails, then appmap/railtie ([07967a1](https://github.com/applandinc/appmap-ruby/commit/07967a14609891544a7dd874c648b7ef5a505f21))
9
+ * Use a hybrid strategy to auto-requiring appmap modules ([6fb09b8](https://github.com/applandinc/appmap-ruby/commit/6fb09b8c0bd55b1e29967d459ce1e2bd5b1ba9fe))
10
+
11
+ ## [0.51.1](https://github.com/applandinc/appmap-ruby/compare/v0.51.0...v0.51.1) (2021-06-21)
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * Add missing require 'yaml' ([1187a02](https://github.com/applandinc/appmap-ruby/commit/1187a023243caaab8cd48de5cbbddefa361636ad))
17
+
18
+ # [0.51.0](https://github.com/applandinc/appmap-ruby/compare/v0.50.0...v0.51.0) (2021-06-21)
19
+
20
+
21
+ ### Features
22
+
23
+ * Provide default appmap.yml settings ([7fa8159](https://github.com/applandinc/appmap-ruby/commit/7fa8159b5020e35f13379017b44906d671e62e64))
24
+
25
+ # [0.50.0](https://github.com/applandinc/appmap-ruby/compare/v0.49.0...v0.50.0) (2021-06-17)
26
+
27
+
28
+ ### Bug Fixes
29
+
30
+ * Remove appmap configuration in test cases which now occurs automatically ([7391c4c](https://github.com/applandinc/appmap-ruby/commit/7391c4c36ed80f98a6b82ccd43f05de488e7cd2f))
31
+
32
+
33
+ ### Features
34
+
35
+ * Direct minitest and rspec startup messages to the Rails log, when available ([15f6444](https://github.com/applandinc/appmap-ruby/commit/15f6444b0fad3ce7d9e91273b6a1116e470c2a89))
36
+ * Enroll railtie, rspec, and minitest helpers automatically ([1709374](https://github.com/applandinc/appmap-ruby/commit/1709374ee7b5183482c55cf4c7386266fa517262))
37
+ * railtie enrolls the app in remote recording ([3a1f8aa](https://github.com/applandinc/appmap-ruby/commit/3a1f8aac1d83c4df04b5da55ed33d418235e348b))
38
+
39
+ # [0.49.0](https://github.com/applandinc/appmap-ruby/compare/v0.48.2...v0.49.0) (2021-06-16)
40
+
41
+
42
+ ### Features
43
+
44
+ * Add refinement to the labels ([6a93396](https://github.com/applandinc/appmap-ruby/commit/6a93396ba73f1b3ed21b4e9e15a2c271af04d866))
45
+
1
46
  ## [0.48.2](https://github.com/applandinc/appmap-ruby/compare/v0.48.1...v0.48.2) (2021-05-26)
2
47
 
3
48
 
data/README.md CHANGED
@@ -1,17 +1,6 @@
1
1
 
2
2
  - [About](#about)
3
- - [Supported versions](#supported-versions)
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
- There are several ways to record AppMaps of your Ruby program using the `appmap` gem:
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=true`. For example:
315
-
316
- ```sh-session
317
- $ APPMAP=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
- For instructions on uploading, see the documentation of the [AppLand CLI](https://github.com/applandinc/appland-cli).
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/appmap.gemspec CHANGED
@@ -22,6 +22,9 @@ Gem::Specification.new do |spec|
22
22
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
23
  spec.files = `git ls-files --no-deleted`.split("
24
24
  ")
25
+ spec.bindir = 'exe'
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+
25
28
  spec.extensions << "ext/appmap/extconf.rb"
26
29
 
27
30
  spec.require_paths = ['lib']
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'gli'
5
+
6
+ require 'appmap'
7
+
8
+ class App
9
+ extend GLI::App
10
+
11
+ program_desc 'CLI tool to be used by IDEs for AppMap setup and configuration'
12
+
13
+ version AppMap::VERSION
14
+
15
+ subcommand_option_handling :normal
16
+ arguments :strict
17
+ preserve_argv true
18
+
19
+ desc 'AppMap configuration file name'
20
+ default_value ENV['APPMAP_CONFIG'] || AppMap::DEFAULT_CONFIG_FILE_PATH
21
+ arg_name 'filename'
22
+ flag %i[c config]
23
+
24
+ desc 'Creates base configuration file for the current project'
25
+ command :init do |c|
26
+ c.action do
27
+ require 'appmap/command/init'
28
+ AppMap::Command::Init.new(@config_file).perform
29
+ end
30
+ end
31
+
32
+ pre do |global, _, _, _|
33
+ @config_file = global[:config]
34
+ @config = interpret_config_option(@config_file) if File.exist?(@config_file)
35
+ true
36
+ end
37
+
38
+ class << self
39
+ protected
40
+
41
+ def interpret_config_option(fname)
42
+ AppMap::Config.load_from_file fname
43
+ end
44
+ end
45
+ end
46
+
47
+ exit App.run(ARGV)