Module: ArchSpec

Defined in:
lib/archspec.rb,
lib/archspec/cli.rb,
lib/archspec/dsl.rb,
lib/archspec/model.rb,
lib/archspec/presets.rb,
lib/archspec/version.rb,
lib/archspec/analyzer.rb,
lib/archspec/baseline.rb,
lib/archspec/evaluator.rb,
lib/archspec/definition.rb,
lib/archspec/diagnostic.rb,
lib/archspec/value_object.rb,
lib/archspec/architectures.rb,
lib/archspec/component_spec.rb,
lib/archspec/formatters/json.rb,
lib/archspec/formatters/text.rb,
lib/archspec/source_location.rb,
lib/archspec/rules/cycle_rule.rb,
lib/archspec/rules/zeitwerk_rule.rb,
lib/archspec/rules/protocol_rules.rb,
lib/archspec/rules/component_rules.rb,
lib/archspec/rules/dependency_rules.rb

Defined Under Namespace

Modules: Analyzer, Architectures, CLI, DSL, Evaluator, Formatters, Presets, Rules, ValueObject Classes: Baseline, Component, ComponentSpec, ConstantNode, Definition, Diagnostic, Error, Graph, SourceFile

Constant Summary collapse

ParseError =
ValueObject.define(:message, :location)
MethodDefinition =
ValueObject.define(:owner, :name, :scope, :location)
Suppression =
ValueObject.define(:rule, :start_line, :end_line, :reason) do
  def matches?(diagnostic)
    (rule.nil? || rule == diagnostic.rule) &&
      diagnostic.location.line >= start_line &&
      diagnostic.location.line <= end_line
  end
end
Edge =
ValueObject.define(:type, :from_path, :from_constant, :to, :location, :confidence)
VERSION =
'0.3.0'
SourceLocation =
ValueObject.define(:path, :line, :column) do
  def self.from_prism(path, location)
    new(path, location.start_line, location.start_column + 1)
  end

  def relative_path(root)
    Pathname(path).relative_path_from(Pathname(root)).to_s
  rescue ArgumentError
    path
  end
end

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.last_definitionObject

Returns the value of attribute last_definition.



29
30
31
# File 'lib/archspec.rb', line 29

def last_definition
  @last_definition
end

Class Method Details

.define(name = nil, &block) ⇒ Object



31
32
33
34
35
36
# File 'lib/archspec.rb', line 31

def define(name = nil, &block)
  definition = Definition.new(name)
  definition.extend(DSL::Context)
  definition.instance_eval(&block) if block
  self.last_definition = definition
end