appmap 0.25.2 → 0.26.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +6 -11
- data/exe/appmap +0 -56
- data/lib/appmap/middleware/remote_recording.rb +0 -1
- data/lib/appmap/version.rb +1 -1
- data/test/cli_test.rb +0 -13
- metadata +2 -3
- data/lib/appmap/command/upload.rb +0 -101
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75d21c5ea95115ab89fb0dd6674a601d19455473f787344d07f7a935aec58aec
|
4
|
+
data.tar.gz: 9d76905534e5c3277c318376708224f318f6357ab41647a6a14a82edf63cbe54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6ca34edd66c0cec51119cc2af49ea5824c91023e54ac1507493eebc3ef39d8308db2b013fdd83d9a1102fc3f6f791dbcec5cf7c75a0cda409d4ade695739815
|
7
|
+
data.tar.gz: 3e5ff519cc8ce4964771806f20258590b607a48a497bb4f100a72ce31f0b40305542315ac3ecfdf1ec5b92723c30369041707327fdf2bf0ac35a5f526e77a969
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
|
12
12
|
# About
|
13
13
|
|
14
|
-
`appmap-ruby` is a Ruby Gem for recording
|
14
|
+
`appmap-ruby` is a Ruby Gem for recording
|
15
15
|
[AppMaps](https://github.com/applandinc/appmap) of your code.
|
16
16
|
"AppMap" is a data format which records code structure (modules, classes, and methods), code execution events
|
17
17
|
(function calls and returns), and code metadata (repo name, repo URL, commit
|
@@ -25,8 +25,10 @@ There are several ways to record AppMaps of your Ruby program using the `appmap`
|
|
25
25
|
browser extension to start, stop, and upload recordings.
|
26
26
|
* Run the command `appmap record <program>` to record the entire execution of a program.
|
27
27
|
|
28
|
-
|
29
|
-
upload them to the AppLand
|
28
|
+
Once you have recorded some AppMaps (for example, by running RSpec tests), you use the `appland upload` command
|
29
|
+
to upload them to the AppLand server. This command, and some others, is provided
|
30
|
+
by the [AppLand CLI](https://github.com/applandinc/appland-cli/releases), to
|
31
|
+
Then, on the [AppLand website](https://app.land), you can
|
30
32
|
visualize the design of your code and share links with collaborators.
|
31
33
|
|
32
34
|
# Testing
|
@@ -179,14 +181,7 @@ Note that using this method is kind of a blunt instrument. Recording RSpecs and
|
|
179
181
|
|
180
182
|
# Uploading AppMaps
|
181
183
|
|
182
|
-
|
183
|
-
|
184
|
-
```sh-session
|
185
|
-
$ ./bin/appmap upload tmp/appmap/rspec/*
|
186
|
-
Uploading "tmp/appmap/rspec/Hello_app_says_hello_when_prompted.appmap.json"
|
187
|
-
Scenario Id: 4da4f267-bdea-48e8-bf67-f39463844230
|
188
|
-
Batch Id: a116f1df-ee57-4bde-8eef-851af0f3d7bc
|
189
|
-
```
|
184
|
+
For instructions on uploading, see the documentation of the [AppLand CLI](https://github.com/applandinc/appland-cli).
|
190
185
|
|
191
186
|
# Build status
|
192
187
|
[![Build Status](https://travis-ci.org/applandinc/appmap-ruby.svg?branch=master)](https://travis-ci.org/applandinc/appmap-ruby)
|
data/exe/appmap
CHANGED
@@ -125,62 +125,6 @@ module AppMap
|
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
128
|
-
desc 'Upload a scenario file to AppLand.'
|
129
|
-
arg_name 'filename'
|
130
|
-
command :upload do |c|
|
131
|
-
output_file_flag(c, default_value: '-')
|
132
|
-
|
133
|
-
c.desc 'Whether to open the new scenario in the browser'
|
134
|
-
c.default_value true
|
135
|
-
c.switch [:open]
|
136
|
-
|
137
|
-
c.desc 'AppLand website URL'
|
138
|
-
c.default_value ENV['APPLAND_URL'] || 'https://appland-staging.herokuapp.com'
|
139
|
-
c.flag :url
|
140
|
-
|
141
|
-
# TODO: This will be replaced with proper login
|
142
|
-
c.desc 'User id to own the scenario'
|
143
|
-
c.default_value(ENV['APPLAND_USER'])
|
144
|
-
c.flag :user
|
145
|
-
|
146
|
-
c.desc 'Organization id to own the scenario'
|
147
|
-
c.default_value(ENV['APPLAND_ORG'])
|
148
|
-
c.flag :org
|
149
|
-
|
150
|
-
c.action do |_, options, args|
|
151
|
-
require 'appmap/command/upload'
|
152
|
-
|
153
|
-
filenames = args
|
154
|
-
help_now!("'filename' argument is required") if filenames.empty?
|
155
|
-
|
156
|
-
url = options[:url]
|
157
|
-
user = options[:user]
|
158
|
-
org = options[:org]
|
159
|
-
|
160
|
-
batch_id = nil
|
161
|
-
uuids = filenames.map do |filename|
|
162
|
-
appmap = JSON.parse(File.read(filename))
|
163
|
-
|
164
|
-
warn "Uploading #{filename.inspect}"
|
165
|
-
upload = AppMap::Command::Upload.new(appmap, url, user, org)
|
166
|
-
upload.batch_id = batch_id if batch_id
|
167
|
-
upload.perform.tap do |response|
|
168
|
-
batch_id ||= response.batch_id
|
169
|
-
@output_file.puts "Scenario Id: #{response.scenario_uuid}"
|
170
|
-
end.scenario_uuid
|
171
|
-
end
|
172
|
-
@output_file.puts "Batch Id: #{batch_id}"
|
173
|
-
|
174
|
-
if options[:open] && STDIN.tty?
|
175
|
-
if uuids.length == 1
|
176
|
-
system "open #{url}/scenarios/#{uuids.first}"
|
177
|
-
else
|
178
|
-
system "open #{url}/scenario_batches/#{batch_id}"
|
179
|
-
end
|
180
|
-
end
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
128
|
pre do |global, _, options, _|
|
185
129
|
@config = interpret_config_option(global[:config])
|
186
130
|
@output_file = interpret_output_file_option(options[:output])
|
data/lib/appmap/version.rb
CHANGED
data/test/cli_test.rb
CHANGED
@@ -113,17 +113,4 @@ class CLITest < Minitest::Test
|
|
113
113
|
assert_includes output, %("location":"lib/cli_record_test/main.rb:3")
|
114
114
|
assert !File.file?(OUTPUT_FILENAME), "#{OUTPUT_FILENAME} should not exist"
|
115
115
|
end
|
116
|
-
|
117
|
-
def test_upload
|
118
|
-
Dir.chdir 'test/fixtures/cli_record_test' do
|
119
|
-
`#{File.expand_path '../exe/appmap', __dir__} record -o #{OUTPUT_FILENAME} ./lib/cli_record_test/main.rb`
|
120
|
-
end
|
121
|
-
|
122
|
-
upload_output = `./exe/appmap upload --org default --user admin --no-open #{OUTPUT_FILENAME}`
|
123
|
-
assert_equal 0, $CHILD_STATUS.exitstatus
|
124
|
-
# Example: 93e1e07d-4b39-49ac-82bf-27d63e296cae
|
125
|
-
assert_match(/Scenario Id/, upload_output)
|
126
|
-
assert_match(/Batch Id/, upload_output)
|
127
|
-
assert_match(/[0-9a-f]+\-[0-9a-f\-]+/, upload_output)
|
128
|
-
end
|
129
116
|
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.
|
4
|
+
version: 0.26.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Gilpin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -269,7 +269,6 @@ files:
|
|
269
269
|
- lib/appmap/class_map.rb
|
270
270
|
- lib/appmap/command/record.rb
|
271
271
|
- lib/appmap/command/stats.rb
|
272
|
-
- lib/appmap/command/upload.rb
|
273
272
|
- lib/appmap/event.rb
|
274
273
|
- lib/appmap/hook.rb
|
275
274
|
- lib/appmap/middleware/remote_recording.rb
|
@@ -1,101 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'json'
|
4
|
-
require 'faraday'
|
5
|
-
|
6
|
-
module AppMap
|
7
|
-
module Command
|
8
|
-
UploadResponse = Struct.new(:batch_id, :scenario_uuid)
|
9
|
-
|
10
|
-
UploadStruct = Struct.new(:data, :url, :user, :org)
|
11
|
-
class Upload < UploadStruct
|
12
|
-
MAX_DEPTH = 12
|
13
|
-
|
14
|
-
attr_accessor :batch_id
|
15
|
-
|
16
|
-
def initialize(data, url, user, org)
|
17
|
-
super
|
18
|
-
|
19
|
-
# TODO: Make this an option
|
20
|
-
@max_depth = MAX_DEPTH
|
21
|
-
end
|
22
|
-
|
23
|
-
def perform
|
24
|
-
appmap = data.clone
|
25
|
-
|
26
|
-
events = data.delete('events')
|
27
|
-
class_map = data.delete('classMap') || []
|
28
|
-
|
29
|
-
unless events.blank?
|
30
|
-
pruned_events = []
|
31
|
-
stack = []
|
32
|
-
events.each do |evt|
|
33
|
-
if evt['event'] == 'call'
|
34
|
-
stack << evt
|
35
|
-
stack_depth = stack.length
|
36
|
-
else
|
37
|
-
stack_depth = stack.length
|
38
|
-
stack.pop
|
39
|
-
end
|
40
|
-
|
41
|
-
prune = stack_depth > @max_depth
|
42
|
-
|
43
|
-
pruned_events << evt unless prune
|
44
|
-
end
|
45
|
-
|
46
|
-
warn "Pruned events to #{pruned_events.length}" if events.length > pruned_events.length
|
47
|
-
|
48
|
-
appmap[:events] = pruned_events
|
49
|
-
appmap[:classMap] = prune(class_map, events: pruned_events)
|
50
|
-
else
|
51
|
-
appmap[:events] = []
|
52
|
-
appmap[:classMap] = prune(class_map)
|
53
|
-
end
|
54
|
-
|
55
|
-
upload_file = { user: user, org: org, data: appmap }.compact
|
56
|
-
|
57
|
-
conn = Faraday.new(url: url)
|
58
|
-
response = conn.post do |req|
|
59
|
-
req.url '/api/scenarios'
|
60
|
-
req.headers['Content-Type'] = 'application/json'
|
61
|
-
req.headers[AppMap::BATCH_HEADER_NAME] = @batch_id if @batch_id
|
62
|
-
req.body = JSON.generate(upload_file)
|
63
|
-
end
|
64
|
-
|
65
|
-
unless response.body.blank?
|
66
|
-
message = begin
|
67
|
-
JSON.parse(response.body)
|
68
|
-
rescue JSON::ParserError => e
|
69
|
-
warn "Response is not valid JSON (#{e.message})"
|
70
|
-
nil
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
unless response.success?
|
75
|
-
error = [ 'Upload failed' ]
|
76
|
-
error << ": #{message}" if message
|
77
|
-
raise error.join
|
78
|
-
end
|
79
|
-
|
80
|
-
batch_id = @batch_id || response.headers[AppMap::BATCH_HEADER_NAME]
|
81
|
-
|
82
|
-
uuid = message['uuid']
|
83
|
-
UploadResponse.new(batch_id, uuid)
|
84
|
-
end
|
85
|
-
|
86
|
-
protected
|
87
|
-
|
88
|
-
def debug?
|
89
|
-
ENV['DEBUG'] == 'true' || ENV['GLI_DEBUG'] == 'true'
|
90
|
-
end
|
91
|
-
|
92
|
-
def prune(class_map, events: nil)
|
93
|
-
require 'appmap/algorithm/prune_class_map'
|
94
|
-
Algorithm::PruneClassMap.new(class_map).tap do |alg|
|
95
|
-
alg.events = events if events
|
96
|
-
alg.logger = ->(msg) { warn msg } if debug?
|
97
|
-
end.perform
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|