Class: MOSAIK::Commands::Extract
- Inherits:
-
MOSAIK::Command::Graph
- Object
- MOSAIK::Command
- MOSAIK::Command::Graph
- MOSAIK::Commands::Extract
- Defined in:
- lib/mosaik/commands/extract.rb
Overview
Extract information from the application
Instance Method Summary collapse
Instance Method Details
#call ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/mosaik/commands/extract.rb', line 35 def call info "Extracting information from the codebase (#{.map { |k, v| "#{k}: #{v}" }.join(', ')})" warn "No files found in the load paths, check if a valid mosaik.yml file exists in #{[:directory]}" if MOSAIK.configuration.files.empty? # Add a vertex for each constant in the load path MOSAIK.configuration.files.each do |file| # Resolve file path to class name class_name = resolver.resolve_file(file) # Add class to graph graph.find_or_add_vertex(class_name) end # Extract structural coupling information and add to graph if [:couplings].include?(:structural) Extractors::Structural .new(, graph) .tap(&:validate) .call end # Extract evolutionary (logical and contributor) coupling information and add to graph if [:couplings].include?(:logical) || [:couplings].include?(:contributor) Extractors::Evolution .new(, graph) .tap(&:validate) .call end # Write graph to file write_graph # Render graph visualization visualize_graph end |
#validate ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/mosaik/commands/extract.rb', line 23 def validate super couplings = [:couplings] - self.class.defaults[:couplings] raise OptionError, "unknown coupling: #{couplings.join(', ')}" unless couplings.empty? raise OptionError, "negative value: #{[:limit]}" if [:limit].negative? [:limit] = nil if [:limit].zero? end |