Module: AppMap
- Defined in:
- lib/appmap.rb,
lib/appmap/hook.rb,
lib/appmap/open.rb,
lib/appmap/util.rb,
lib/appmap/event.rb,
lib/appmap/rspec.rb,
lib/appmap/trace.rb,
lib/appmap/config.rb,
lib/appmap/railtie.rb,
lib/appmap/version.rb,
lib/appmap/cucumber.rb,
lib/appmap/metadata.rb,
lib/appmap/minitest.rb,
lib/appmap/class_map.rb,
lib/appmap/hook/method.rb,
lib/appmap/command/stats.rb,
lib/appmap/command/record.rb,
lib/appmap/algorithm/stats.rb,
lib/appmap/rails/sql_handler.rb,
lib/appmap/rails/request_handler.rb,
lib/appmap/algorithm/prune_class_map.rb,
lib/appmap/middleware/remote_recording.rb,
ext/appmap/appmap.c
Defined Under Namespace
Modules: Algorithm, Command, Cucumber, Event, Metadata, Middleware, Minitest, RSpec, Rails, Trace, Util Classes: ClassMap, Config, Hook, Open, OpenStruct, Railtie, Tracer
Constant Summary collapse
- URL =
'https://github.com/applandinc/appmap-ruby'- VERSION =
'0.40.0'- APPMAP_FORMAT_VERSION =
'1.4'
Class Method Summary collapse
-
.class_map(methods, options = {}) ⇒ Object
Builds a class map from a config and a list of Ruby methods.
-
.configuration ⇒ Object
Gets the configuration.
-
.configuration=(config) ⇒ Object
Sets the configuration.
-
.detect_metadata ⇒ Object
Returns default metadata detected from the Ruby system and from the filesystem.
-
.initialize(config_file_path = 'appmap.yml') ⇒ Object
Configures AppMap for recording.
-
.open(appmap = nil, &block) ⇒ Object
Uploads an AppMap to the AppLand website and displays it.
-
.record ⇒ Object
Records the events which occur while processing a block, and returns an AppMap as a Hash.
-
.tracing ⇒ Object
Used to start tracing, stop tracing, and record events.
Class Method Details
.class_map(methods, options = {}) ⇒ Object
Builds a class map from a config and a list of Ruby methods.
86 87 88 |
# File 'lib/appmap.rb', line 86 def class_map(methods, = {}) ClassMap.build_from_methods(methods, ) end |
.configuration ⇒ Object
Gets the configuration. If there is no configuration, the default configuration is initialized.
29 30 31 |
# File 'lib/appmap.rb', line 29 def configuration @configuration ||= initialize end |
.configuration=(config) ⇒ Object
Sets the configuration. This is only expected to happen once per Ruby process.
35 36 37 38 39 |
# File 'lib/appmap.rb', line 35 def configuration=(config) warn 'AppMap is already configured' if @configuration && config @configuration = config end |
.detect_metadata ⇒ Object
Returns default metadata detected from the Ruby system and from the filesystem.
92 93 94 95 |
# File 'lib/appmap.rb', line 92 def @metadata ||= Metadata.detect.freeze @metadata.deep_dup end |
.initialize(config_file_path = 'appmap.yml') ⇒ Object
Configures AppMap for recording. Default behavior is to configure from “appmap.yml”. This method also activates the code hooks which record function calls as trace events. Call this function before the program code is loaded by the Ruby VM, otherwise the load events won’t be seen and the hooks won’t activate.
45 46 47 48 49 50 51 |
# File 'lib/appmap.rb', line 45 def initialize(config_file_path = 'appmap.yml') warn "Configuring AppMap from path #{config_file_path}" Config.load_from_file(config_file_path).tap do |configuration| self.configuration = configuration Hook.new(configuration).enable end end |
.open(appmap = nil, &block) ⇒ Object
Uploads an AppMap to the AppLand website and displays it.
80 81 82 83 |
# File 'lib/appmap.rb', line 80 def open(appmap = nil, &block) appmap ||= AppMap.record(&block) AppMap::Open.new(appmap).perform end |
.record ⇒ Object
Records the events which occur while processing a block, and returns an AppMap as a Hash.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/appmap.rb', line 60 def record tracer = tracing.trace begin yield ensure tracing.delete(tracer) end events = [].tap do |event_list| event_list << tracer.next_event.to_h while tracer.event? end { 'version' => AppMap::APPMAP_FORMAT_VERSION, 'metadata' => , 'classMap' => class_map(tracer.event_methods), 'events' => events } end |