class AppMap::Depends::AppMapJSDepends

Command wraps the Node depends command.

Attributes

appmap_dir[RW]

Directory to scan for AppMaps.

base_dir[RW]

Directory name to prefix to the list of modified files which is provided to depends.

field[RW]

AppMap field to report.

Public Class Methods

new(appmap_dir) click to toggle source
# File lib/appmap/depends/appmap_js_depends.rb, line 17
def initialize(appmap_dir)
  @appmap_dir = appmap_dir
  @base_dir = false
  @field = 'source_location'
end

Public Instance Methods

depends(modified_files = nil) click to toggle source

Returns the source_location field of every AppMap that is “out of date” with respect to one of the modified_files.

# File lib/appmap/depends/appmap_js_depends.rb, line 31
def depends(modified_files = nil)
  validate

  index_appmaps(appmap_dir)

  cmd = %w[depends]
  cmd += [ '--field', field ] if field
  cmd += [ '--appmap-dir', appmap_dir ] if appmap_dir
  cmd += [ '--base-dir', base_dir ] if base_dir

  options = {}
  if modified_files
    cmd << '--stdin-files'
    options[:stdin_data] = modified_files.map(&:shellescape).join("\n")
    warn "Checking modified files: #{modified_files.join(' ')}" if Depends.verbose
  end

  stdout, = appmap_js_command cmd, options
  stdout.split("\n")
end
validate() click to toggle source

Ensures that all dependencies are available.

# File lib/appmap/depends/appmap_js_depends.rb, line 24
def validate
  detect_nodejs
  detect_appmap_js
end