Class: AppMap::Depends::AppMapJSDepends

Inherits:
Object
  • Object
show all
Includes:
AppMapJS
Defined in:
lib/appmap/depends/appmap_js_depends.rb

Overview

Command wraps the Node depends command.

Constant Summary

Constants included from AppMapJS

AppMap::Depends::AppMapJS::APPMAP_JS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from AppMapJS

#appmap_js_command, #detect_appmap_js, #detect_nodejs, #do_fail, #index_appmaps

Constructor Details

#initialize(appmap_dir) ⇒ AppMapJSDepends

Returns a new instance of AppMapJSDepends.



17
18
19
20
21
# 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

Instance Attribute Details

#appmap_dirObject

Directory to scan for AppMaps.



11
12
13
# File 'lib/appmap/depends/appmap_js_depends.rb', line 11

def appmap_dir
  @appmap_dir
end

#base_dirObject

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



13
14
15
# File 'lib/appmap/depends/appmap_js_depends.rb', line 13

def base_dir
  @base_dir
end

#fieldObject

AppMap field to report.



15
16
17
# File 'lib/appmap/depends/appmap_js_depends.rb', line 15

def field
  @field
end

Instance Method Details

#depends(modified_files = nil) ⇒ Object

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



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# 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

#validateObject

Ensures that all dependencies are available.



24
25
26
27
# File 'lib/appmap/depends/appmap_js_depends.rb', line 24

def validate
  detect_nodejs
  detect_appmap_js
end