Class: AppMap::Config::Package
- Inherits:
-
Struct
- Object
- Struct
- AppMap::Config::Package
- Defined in:
- lib/appmap/config.rb
Overview
Specifies a code path to be mapped.
Options:
gemmay indicate a gem name that "owns" the pathpackage_namecan be used to make sure that the code is required so that it can be loaded. This is generally used with builtins, or when the path to be required is not automatically required when bundler requires the gem.excludecan be used used to exclude sub-paths. Generally not used withgem.labelsis used to apply labels to matching code. This is really only useful when the package will be applied to specific functions, via TargetMethods.shallowindicates shallow mapping, in which only the entrypoint to a gem is recorded.
Instance Attribute Summary collapse
-
#exclude ⇒ Object
Returns the value of attribute exclude.
-
#gem ⇒ Object
Returns the value of attribute gem.
- #handler_class ⇒ Object
-
#labels ⇒ Object
Returns the value of attribute labels.
-
#package_name ⇒ Object
Returns the value of attribute package_name.
-
#path ⇒ Object
Returns the value of attribute path.
-
#shallow ⇒ Object
Returns the value of attribute shallow.
Class Method Summary collapse
-
.build_from_gem(gem, shallow: true, package_name: nil, exclude: [], labels: [], optional: false, force: false) ⇒ Object
Builds a package for gem.
-
.build_from_path(path, shallow: false, package_name: nil, exclude: [], labels: []) ⇒ Object
Builds a package for a path, such as
app/modelsin a Rails app.
Instance Method Summary collapse
- #name ⇒ Object
-
#shallow? ⇒ Boolean
Indicates that only the entry points to a package will be recorded.
- #to_h ⇒ Object
Instance Attribute Details
#exclude ⇒ Object
Returns the value of attribute exclude
24 25 26 |
# File 'lib/appmap/config.rb', line 24 def exclude @exclude end |
#gem ⇒ Object
Returns the value of attribute gem
24 25 26 |
# File 'lib/appmap/config.rb', line 24 def gem @gem end |
#handler_class ⇒ Object
31 32 33 34 |
# File 'lib/appmap/config.rb', line 31 def handler_class require 'appmap/handler/function' @handler_class || AppMap::Handler::Function end |
#labels ⇒ Object
Returns the value of attribute labels
24 25 26 |
# File 'lib/appmap/config.rb', line 24 def labels @labels end |
#package_name ⇒ Object
Returns the value of attribute package_name
24 25 26 |
# File 'lib/appmap/config.rb', line 24 def package_name @package_name end |
#path ⇒ Object
Returns the value of attribute path
24 25 26 |
# File 'lib/appmap/config.rb', line 24 def path @path end |
#shallow ⇒ Object
Returns the value of attribute shallow
24 25 26 |
# File 'lib/appmap/config.rb', line 24 def shallow @shallow end |
Class Method Details
.build_from_gem(gem, shallow: true, package_name: nil, exclude: [], labels: [], optional: false, force: false) ⇒ Object
Builds a package for gem. Generally corresponds to a gem: entry in appmap.yml. Also used when mapping
a builtin.
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/appmap/config.rb', line 52 def build_from_gem(gem, shallow: true, package_name: nil, exclude: [], labels: [], optional: false, force: false) if !force && %w[method_source activesupport].member?(gem) warn "WARNING: #{gem} cannot be AppMapped because it is a dependency of the appmap gem" return end path = gem_path(gem, optional) if path Package.new(path, gem, package_name, exclude, labels, shallow) else AppMap::Util. "#{gem} is not available in the bundle" end end |
.build_from_path(path, shallow: false, package_name: nil, exclude: [], labels: []) ⇒ Object
Builds a package for a path, such as app/models in a Rails app. Generally corresponds to a path: entry
in appmap.yml. Also used for mapping specific methods via TargetMethods.
46 47 48 |
# File 'lib/appmap/config.rb', line 46 def build_from_path(path, shallow: false, package_name: nil, exclude: [], labels: []) Package.new(path, nil, package_name, exclude, labels, shallow) end |
Instance Method Details
#name ⇒ Object
77 78 79 |
# File 'lib/appmap/config.rb', line 77 def name gem || path end |
#shallow? ⇒ Boolean
Indicates that only the entry points to a package will be recorded. Once the code has entered a package, subsequent calls within the package will not be recorded unless the code leaves the package and re-enters it.
39 40 41 |
# File 'lib/appmap/config.rb', line 39 def shallow? shallow end |
#to_h ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/appmap/config.rb', line 81 def to_h { path: path, package_name: package_name, gem: gem, handler_class: handler_class.name, exclude: Util.blank?(exclude) ? nil : exclude, labels: Util.blank?(labels) ? nil : labels, shallow: shallow }.compact end |