Class: StudFinder::JsFanIn
- Inherits:
-
Object
- Object
- StudFinder::JsFanIn
- Defined in:
- lib/stud_finder/js_fan_in.rb
Defined Under Namespace
Classes: Result
Constant Summary collapse
- TOOL_MISSING =
'js_tools_missing'- TIMEOUT =
'js_depcruise_timeout'- DEPCRUISE_NO_CONFIG =
'js_depcruise_no_config'- DEPCRUISE_FAILED =
'js_depcruise_failed'- FALLBACK_SUCCESS_MESSAGE =
'configured depcruise failed; retried with --no-config; fan_in may be undercounted'
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(repo_path:, files:, js_timeout: 60, stderr: $stderr) ⇒ JsFanIn
constructor
A new instance of JsFanIn.
Constructor Details
#initialize(repo_path:, files:, js_timeout: 60, stderr: $stderr) ⇒ JsFanIn
Returns a new instance of JsFanIn.
19 20 21 22 23 24 |
# File 'lib/stud_finder/js_fan_in.rb', line 19 def initialize(repo_path:, files:, js_timeout: 60, stderr: $stderr) @repo_path = File.(repo_path) @files = files @js_timeout = js_timeout @stderr = stderr end |
Instance Method Details
#call ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/stud_finder/js_fan_in.rb', line 26 def call return missing_tools unless node_available? depcruise = depcruise_binary return missing_tools unless depcruise stdout, stderr, status, warnings = run_depcruise(depcruise) return depcruise_failed(stderr) unless status.success? counts, fan_out_counts, edges = parse(stdout) warnings.each { |warning| warn(warning.fetch(:code), warning.fetch(:message)) } Result.new(counts: counts, fan_out_counts: fan_out_counts, edges: edges, warnings: warnings) rescue Timeout::Error warn(TIMEOUT) Result.new(counts: zero_counts, fan_out_counts: zero_counts, edges: empty_edges, warnings: [TIMEOUT]) rescue JSON::ParserError, KeyError, TypeError => e depcruise_failed("malformed dependency-cruiser JSON: #{e.}") end |