appmap 0.32.0 → 0.33.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 +4 -0
- data/appmap.gemspec +1 -0
- data/lib/appmap.rb +19 -10
- data/lib/appmap/open.rb +57 -0
- data/lib/appmap/version.rb +1 -1
- data/spec/open_spec.rb +19 -0
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae23c62b9a3f01cc3b7680706746d2f51c94c3a776978a8ee2d4e0e8501fca01
|
4
|
+
data.tar.gz: 4aa33af19ed0c31b826f8cffa75e147e2781fe93ed39353ace29cede8a7882b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04a3c1bee70c02c96c1b71d5153a6ed44d668d6fc69d6da77cd6201364ede609bee93604f4ace391ddb38f8259841d6b334fdbe9051f1667d41cf3383281fe58
|
7
|
+
data.tar.gz: c60d868b2c1fa9c1e8742856dd7f946f5bf1284cab01a4478708c1582add5ca8fd16002e150d8a2cd897819edb661a9082cb01ec3e9879686d85d49b341d4ba8
|
data/CHANGELOG.md
CHANGED
data/appmap.gemspec
CHANGED
@@ -26,6 +26,7 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_dependency 'faraday'
|
27
27
|
spec.add_dependency 'gli'
|
28
28
|
spec.add_dependency 'parser'
|
29
|
+
spec.add_dependency 'rack'
|
29
30
|
|
30
31
|
spec.add_development_dependency 'bundler', '~> 1.16'
|
31
32
|
spec.add_development_dependency 'minitest', '~> 5.0'
|
data/lib/appmap.rb
CHANGED
@@ -14,19 +14,20 @@ require 'appmap/trace'
|
|
14
14
|
require 'appmap/class_map'
|
15
15
|
require 'appmap/metadata'
|
16
16
|
require 'appmap/util'
|
17
|
+
require 'appmap/open'
|
17
18
|
|
18
19
|
module AppMap
|
19
20
|
class << self
|
20
21
|
@configuration = nil
|
21
22
|
@configuration_file_path = nil
|
22
23
|
|
23
|
-
#
|
24
|
+
# Gets the configuration. If there is no configuration, the default
|
24
25
|
# configuration is initialized.
|
25
26
|
def configuration
|
26
|
-
@configuration ||=
|
27
|
+
@configuration ||= initialize
|
27
28
|
end
|
28
29
|
|
29
|
-
#
|
30
|
+
# Sets the configuration. This is only expected to happen once per
|
30
31
|
# Ruby process.
|
31
32
|
def configuration=(config)
|
32
33
|
warn 'AppMap is already configured' if @configuration && config
|
@@ -34,22 +35,24 @@ module AppMap
|
|
34
35
|
@configuration = config
|
35
36
|
end
|
36
37
|
|
37
|
-
#
|
38
|
+
# Configures AppMap for recording. Default behavior is to configure from "appmap.yml".
|
38
39
|
# This method also activates the code hooks which record function calls as trace events.
|
39
40
|
# Call this function before the program code is loaded by the Ruby VM, otherwise
|
40
41
|
# the load events won't be seen and the hooks won't activate.
|
41
42
|
def initialize(config_file_path = 'appmap.yml')
|
42
43
|
warn "Configuring AppMap from path #{config_file_path}"
|
43
|
-
|
44
|
-
|
44
|
+
Config.load_from_file(config_file_path).tap do |configuration|
|
45
|
+
self.configuration = configuration
|
46
|
+
Hook.new(configuration).enable
|
47
|
+
end
|
45
48
|
end
|
46
49
|
|
47
|
-
#
|
50
|
+
# Used to start tracing, stop tracing, and record events.
|
48
51
|
def tracing
|
49
52
|
@tracing ||= Trace::Tracing.new
|
50
53
|
end
|
51
54
|
|
52
|
-
#
|
55
|
+
# Records the events which occur while processing a block,
|
53
56
|
# and returns an AppMap as a Hash.
|
54
57
|
def record
|
55
58
|
tracer = tracing.trace
|
@@ -70,12 +73,18 @@ module AppMap
|
|
70
73
|
}
|
71
74
|
end
|
72
75
|
|
73
|
-
#
|
76
|
+
# Uploads an AppMap to the AppLand website and displays it.
|
77
|
+
def open(appmap = nil, &block)
|
78
|
+
appmap ||= AppMap.record(&block)
|
79
|
+
AppMap::Open.new(appmap).perform
|
80
|
+
end
|
81
|
+
|
82
|
+
# Builds a class map from a config and a list of Ruby methods.
|
74
83
|
def class_map(methods)
|
75
84
|
ClassMap.build_from_methods(configuration, methods)
|
76
85
|
end
|
77
86
|
|
78
|
-
#
|
87
|
+
# Returns default metadata detected from the Ruby system and from the
|
79
88
|
# filesystem.
|
80
89
|
def detect_metadata
|
81
90
|
@metadata ||= Metadata.detect.freeze
|
data/lib/appmap/open.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AppMap
|
4
|
+
OpenStruct = Struct.new(:appmap)
|
5
|
+
|
6
|
+
class Open < OpenStruct
|
7
|
+
attr_reader :port
|
8
|
+
|
9
|
+
def perform
|
10
|
+
server = run_server
|
11
|
+
open_browser
|
12
|
+
server.kill
|
13
|
+
end
|
14
|
+
|
15
|
+
def page
|
16
|
+
require 'rack/utils'
|
17
|
+
<<~PAGE
|
18
|
+
<!DOCTYPE html>
|
19
|
+
<html>
|
20
|
+
<head>
|
21
|
+
<title>…</title>
|
22
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
23
|
+
<script type="text/javascript">
|
24
|
+
function dosubmit() { document.forms[0].submit(); }
|
25
|
+
</script>
|
26
|
+
</head>
|
27
|
+
<body onload="dosubmit();">
|
28
|
+
<form action="https://app.land/scenario_uploads" method="POST" accept-charset="utf-8">
|
29
|
+
<input type="hidden" name="data" value='#{Rack::Utils.escape_html appmap.to_json}'>
|
30
|
+
</form>
|
31
|
+
</body>
|
32
|
+
</html>
|
33
|
+
PAGE
|
34
|
+
end
|
35
|
+
|
36
|
+
def run_server
|
37
|
+
require 'rack'
|
38
|
+
Thread.new do
|
39
|
+
Rack::Handler::WEBrick.run(
|
40
|
+
lambda do |env|
|
41
|
+
return [200, { 'Content-Type' => 'text/html' }, [page]]
|
42
|
+
end,
|
43
|
+
:Port => 0
|
44
|
+
) do |server|
|
45
|
+
@port = server.config[:Port]
|
46
|
+
end
|
47
|
+
end.tap do
|
48
|
+
sleep 1.0
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def open_browser
|
53
|
+
system 'open', "http://localhost:#{@port}"
|
54
|
+
sleep 5.0
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/lib/appmap/version.rb
CHANGED
data/spec/open_spec.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe AppMap::Open do
|
6
|
+
context 'a block of Ruby code' do
|
7
|
+
it 'opens in the browser' do
|
8
|
+
appmap = AppMap.record do
|
9
|
+
File.read __FILE__
|
10
|
+
end
|
11
|
+
|
12
|
+
open = AppMap::Open.new(appmap)
|
13
|
+
server = open.run_server
|
14
|
+
page = Net::HTTP.get URI.parse("http://localhost:#{open.port}")
|
15
|
+
expect(page).to include(%(name="data" value='{"version))
|
16
|
+
server.kill
|
17
|
+
end
|
18
|
+
end
|
19
|
+
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.33.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-08-
|
11
|
+
date: 2020-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rack
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: bundler
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -277,6 +291,7 @@ files:
|
|
277
291
|
- lib/appmap/metadata.rb
|
278
292
|
- lib/appmap/middleware/remote_recording.rb
|
279
293
|
- lib/appmap/minitest.rb
|
294
|
+
- lib/appmap/open.rb
|
280
295
|
- lib/appmap/rails/action_handler.rb
|
281
296
|
- lib/appmap/rails/sql_handler.rb
|
282
297
|
- lib/appmap/railtie.rb
|
@@ -457,6 +472,7 @@ files:
|
|
457
472
|
- spec/fixtures/rails_users_app/spec/spec_helper.rb
|
458
473
|
- spec/fixtures/rails_users_app/users_app/.gitignore
|
459
474
|
- spec/hook_spec.rb
|
475
|
+
- spec/open_spec.rb
|
460
476
|
- spec/rails_spec_helper.rb
|
461
477
|
- spec/railtie_spec.rb
|
462
478
|
- spec/record_sql_rails4_pg_spec.rb
|