appmap 0.21.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2f6f185625c62dee8266aaca7dc13d15994bf1ebe947569e134da574a0a557a0
4
- data.tar.gz: 46c6c133477606f5ba908b710fa69fd44063b91b4e966e8d1d36fb5eb8b4aa6b
3
+ metadata.gz: 7e4bb797e4a52228da17a1d2bea86cc7b39c0e77f868794282a4a506bc118c1b
4
+ data.tar.gz: 17c42a6dbab64ded9e0c0735df3e1a6b4ffb871f5368c134038fa4574f18a140
5
5
  SHA512:
6
- metadata.gz: 82ed069dbe728941c732d1b9c9e5681a6d31544df703a859e4e3a8c75fe0fde906036bfaaabebac5ad2f2cab5df1176e2233f16e975ab39f2eca1bac592fd3f0
7
- data.tar.gz: 77d93bb43e7efdc5cd81570422af35aac203e84438eea375eb18f07d5ed3e0a76ad7383ba808daa1cc8ac0e7f5a1a224c3857131aef7fbe5a64c323fefacdab7
6
+ metadata.gz: ce536f9473bc5c13127c7f9e327e011123a0b56291197c1c3f91db68c7ec2fa64438382cc08f002e2634cf7a1877b630f43849989197ca0285da72e79a93767d
7
+ data.tar.gz: 5a457dbc9afa127d6ca284bf47ee549b3e7a0cb579e1edf2313783ced314e87134ac9a2c4b06e1035402e5619876d7d990b0f65268e12a991480641b5574bc0e
@@ -1,3 +1,8 @@
1
+ # v0.22.0
2
+
3
+ * **RSpec** recorder generates an "inventory" (AppMap with classMap, without events) named `Inventory.appmap.json`.
4
+ * **appmap inspect** generates an inventory AppMap which includes `version`, `metadata`, and `classMap`. Previously, the file output by this command was the class map represented as an array.
5
+
1
6
  # v0.21.0
2
7
 
3
8
  * Scenario data includes `recorder` and `client` info, describing how the data was recorded.
data/exe/appmap CHANGED
@@ -48,8 +48,8 @@ module AppMap
48
48
 
49
49
  c.action do
50
50
  require 'appmap/command/inspect'
51
- features = AppMap::Command::Inspect.new(@config).perform
52
- @output_file.write JSON.pretty_generate(features)
51
+ appmap = AppMap::Command::Inspect.new(@config).perform
52
+ @output_file.write JSON.pretty_generate(appmap)
53
53
  end
54
54
  end
55
55
 
@@ -4,7 +4,10 @@ module AppMap
4
4
 
5
5
  class Inspect < InspectStruct
6
6
  def perform
7
- AppMap.inspect(config)
7
+ require 'appmap/command/record'
8
+
9
+ features = AppMap.inspect(config)
10
+ { version: AppMap::APPMAP_FORMAT_VERSION, metadata: AppMap::Command::Record.detect_metadata, classMap: features }
8
11
  end
9
12
  end
10
13
  end
@@ -21,11 +21,10 @@ module AppMap
21
21
  def perform
22
22
  appmap = data.clone
23
23
 
24
- # If it's a list, upload it as a classMap
25
- if data.is_a?(Hash)
26
- events = data.delete('events') || []
27
- class_map = data.delete('classMap') || []
24
+ events = data.delete('events')
25
+ class_map = data.delete('classMap') || []
28
26
 
27
+ unless events.blank?
29
28
  pruned_events = []
30
29
  stack = []
31
30
  events.each do |evt|
@@ -44,14 +43,11 @@ module AppMap
44
43
 
45
44
  warn "Pruned events to #{pruned_events.length}" if events.length > pruned_events.length
46
45
 
47
- events = pruned_events
48
-
49
- class_map = prune(class_map, events: events)
50
- appmap[:classMap] = class_map
51
- appmap[:events] = events
46
+ appmap[:events] = pruned_events
47
+ appmap[:classMap] = prune(class_map, events: pruned_events)
52
48
  else
53
- class_map = prune(data)
54
- appmap = { "version": AppMap::APPMAP_FORMAT_VERSION, "classMap": class_map, "events": [] }
49
+ appmap[:events] = []
50
+ appmap[:classMap] = prune(class_map)
55
51
  end
56
52
 
57
53
  upload_file = { user: user, org: org, data: appmap }.compact
@@ -29,7 +29,7 @@ module AppMap
29
29
  FileUtils.mkdir_p APPMAP_OUTPUT_DIR
30
30
  end
31
31
 
32
- def save(example_name, events, feature_name: nil, feature_group_name: nil, labels: nil)
32
+ def save(example_name, events: nil, feature_name: nil, feature_group_name: nil, labels: nil)
33
33
  require 'appmap/command/record'
34
34
  metadata = AppMap::Command::Record.detect_metadata.tap do |m|
35
35
  m[:name] = example_name
@@ -52,7 +52,7 @@ module AppMap
52
52
  classMap: features,
53
53
  metadata: metadata,
54
54
  events: events
55
- }
55
+ }.compact
56
56
  fname = sanitize_filename(example_name)
57
57
  File.write(File.join(APPMAP_OUTPUT_DIR, "#{fname}.appmap.json"), JSON.generate(appmap))
58
58
  end
@@ -198,6 +198,12 @@ module AppMap
198
198
  tp.defined_class.to_s == 'RSpec::Core::Example'
199
199
  end
200
200
 
201
+ def generate_inventory
202
+ Recorder.new.tap do |recorder|
203
+ recorder.setup
204
+ end.save 'Inventory', labels: %w[inventory]
205
+ end
206
+
201
207
  def generate_appmaps_from_specs
202
208
  recorder = Recorder.new
203
209
  recorder.setup
@@ -312,7 +318,7 @@ module AppMap
312
318
  feature_name = normalize.call(feature_name) if feature_name
313
319
 
314
320
  recorder.save full_description,
315
- events,
321
+ events: events,
316
322
  feature_name: feature_name,
317
323
  feature_group_name: feature_group,
318
324
  labels: labels.blank? ? nil : labels
@@ -320,8 +326,17 @@ module AppMap
320
326
  end
321
327
  end
322
328
  end
323
- end
324
329
 
325
- generate_appmaps_from_specs if ENV['APPMAP'] == 'true'
330
+ def enabled?
331
+ ENV['APPMAP'] == 'true'
332
+ end
333
+
334
+ def run
335
+ generate_inventory
336
+ generate_appmaps_from_specs
337
+ end
338
+ end
326
339
  end
327
340
  end
341
+
342
+ AppMap::RSpec.run if AppMap::RSpec.enabled?
@@ -3,7 +3,7 @@
3
3
  module AppMap
4
4
  URL = 'https://github.com/applandinc/appmap-ruby'
5
5
 
6
- VERSION = '0.21.0'
6
+ VERSION = '0.22.0'
7
7
 
8
8
  APPMAP_FORMAT_VERSION = '1.2'
9
9
  end
@@ -33,7 +33,16 @@ class CLITest < Minitest::Test
33
33
 
34
34
  assert_equal 0, $CHILD_STATUS.exitstatus
35
35
  assert !output.blank?, 'Output should exist in stdout'
36
- JSON.parse(output)
36
+ end
37
+
38
+ def test_inspect_fields
39
+ output = `./exe/appmap inspect -o -`
40
+
41
+ output = JSON.parse(output)
42
+ assert_includes output.keys, 'version'
43
+ assert_includes output.keys, 'classMap'
44
+ assert_includes output.keys, 'metadata'
45
+ assert !output.keys.include?('events')
37
46
  end
38
47
 
39
48
  def test_record
@@ -17,6 +17,21 @@ class RSpecTest < Minitest::Test
17
17
  end
18
18
  end
19
19
 
20
+ def test_inventory
21
+ perform_test 'plain_hello_spec' do
22
+ appmap_file = 'tmp/appmap/rspec/Inventory.appmap.json'
23
+
24
+ assert File.file?(appmap_file), 'appmap output file does not exist'
25
+ appmap = JSON.parse(File.read(appmap_file))
26
+ assert_equal AppMap::APPMAP_FORMAT_VERSION, appmap['version']
27
+ assert_includes appmap.keys, 'metadata'
28
+ metadata = appmap['metadata']
29
+ assert_equal 'Inventory', metadata['name']
30
+ assert_includes metadata.keys, 'labels'
31
+ assert_equal metadata['labels'], %w[inventory]
32
+ end
33
+ end
34
+
20
35
  def test_record_decorated_rspec
21
36
  perform_test 'decorated_hello_spec' do
22
37
  appmap_file = 'tmp/appmap/rspec/Hello_says_hello.appmap.json'
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.21.0
4
+ version: 0.22.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: 2019-12-12 00:00:00.000000000 Z
11
+ date: 2019-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport