class ArchSpec::Definition
The result of evaluating an Archspec.rb file: the project settings, declared components, and rules. ArchSpec::DSL::Context is mixed into an instance to provide the DSL, and the analyzer and evaluator read it to run the checks. Build one with ArchSpec.define.
Constants
- DEFAULT_IGNORE_PATTERNS
- DEFAULT_SOURCE_PATTERNS
Attributes
Public Class Methods
Source
# File lib/archspec/definition.rb, line 27 def initialize(name = nil) @name = name @root_path = '.' @todo_path = nil @base_dir = nil @source_patterns = [] @ignore_patterns = DEFAULT_IGNORE_PATTERNS.dup @component_specs = {} @rules = [] end
Public Instance Methods
# File lib/archspec/definition.rb, line 65 def absolute_root(base = base_dir || Dir.pwd) File.expand_path(root_path, base) end
Source
# File lib/archspec/definition.rb, line 46 def add_component(spec) if component_specs.key?(spec.name) component_specs.fetch(spec.name).merge!(spec) else component_specs[spec.name] = spec end end
# File lib/archspec/definition.rb, line 42 def add_ignore_patterns(patterns) @ignore_patterns |= Array(patterns).flatten.compact.map(&:to_s) end
Source
# File lib/archspec/definition.rb, line 58 def add_rule(rule) rules << rule end
# File lib/archspec/definition.rb, line 38 def add_source_patterns(patterns) @source_patterns |= Array(patterns).flatten.compact.map(&:to_s) end
Source
# File lib/archspec/definition.rb, line 69 def analysis_patterns patterns = source_patterns.empty? ? DEFAULT_SOURCE_PATTERNS.dup : source_patterns.dup patterns | component_specs.values.flat_map(&:file_patterns) end
Source
# File lib/archspec/definition.rb, line 54 def component?(name) component_specs.key?(name.to_sym) end