Class: ArchSpec::Definition
- Inherits:
-
Object
- Object
- ArchSpec::Definition
- Defined in:
- lib/archspec/definition.rb
Constant Summary collapse
- DEFAULT_SOURCE_PATTERNS =
[ 'app/**/*.rb', 'lib/**/*.rb', 'packs/*/app/**/*.rb', 'engines/*/app/**/*.rb' ].freeze
- DEFAULT_IGNORE_PATTERNS =
[ '.git/**/*', '.bundle/**/*', 'node_modules/**/*', 'tmp/**/*', 'vendor/**/*' ].freeze
Instance Attribute Summary collapse
-
#baseline_path ⇒ Object
Returns the value of attribute baseline_path.
-
#component_specs ⇒ Object
readonly
Returns the value of attribute component_specs.
-
#ignore_patterns ⇒ Object
readonly
Returns the value of attribute ignore_patterns.
-
#name ⇒ Object
Returns the value of attribute name.
-
#root_path ⇒ Object
Returns the value of attribute root_path.
-
#rules ⇒ Object
readonly
Returns the value of attribute rules.
-
#source_patterns ⇒ Object
readonly
Returns the value of attribute source_patterns.
Instance Method Summary collapse
- #absolute_root(base_dir = Dir.pwd) ⇒ Object
- #add_component(spec) ⇒ Object
- #add_ignore_patterns(patterns) ⇒ Object
- #add_rule(rule) ⇒ Object
- #add_source_patterns(patterns) ⇒ Object
- #analysis_patterns ⇒ Object
- #component?(name) ⇒ Boolean
-
#initialize(name) ⇒ Definition
constructor
A new instance of Definition.
Constructor Details
#initialize(name) ⇒ Definition
Returns a new instance of Definition.
23 24 25 26 27 28 29 30 31 |
# File 'lib/archspec/definition.rb', line 23 def initialize(name) @name = name @root_path = '.' @baseline_path = nil @source_patterns = [] @ignore_patterns = DEFAULT_IGNORE_PATTERNS.dup @component_specs = {} @rules = [] end |
Instance Attribute Details
#baseline_path ⇒ Object
Returns the value of attribute baseline_path.
20 21 22 |
# File 'lib/archspec/definition.rb', line 20 def baseline_path @baseline_path end |
#component_specs ⇒ Object (readonly)
Returns the value of attribute component_specs.
21 22 23 |
# File 'lib/archspec/definition.rb', line 21 def component_specs @component_specs end |
#ignore_patterns ⇒ Object (readonly)
Returns the value of attribute ignore_patterns.
21 22 23 |
# File 'lib/archspec/definition.rb', line 21 def ignore_patterns @ignore_patterns end |
#name ⇒ Object
Returns the value of attribute name.
20 21 22 |
# File 'lib/archspec/definition.rb', line 20 def name @name end |
#root_path ⇒ Object
Returns the value of attribute root_path.
20 21 22 |
# File 'lib/archspec/definition.rb', line 20 def root_path @root_path end |
#rules ⇒ Object (readonly)
Returns the value of attribute rules.
21 22 23 |
# File 'lib/archspec/definition.rb', line 21 def rules @rules end |
#source_patterns ⇒ Object (readonly)
Returns the value of attribute source_patterns.
21 22 23 |
# File 'lib/archspec/definition.rb', line 21 def source_patterns @source_patterns end |
Instance Method Details
#absolute_root(base_dir = Dir.pwd) ⇒ Object
57 58 59 |
# File 'lib/archspec/definition.rb', line 57 def absolute_root(base_dir = Dir.pwd) File.(root_path, base_dir) end |
#add_component(spec) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/archspec/definition.rb', line 41 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 |
#add_ignore_patterns(patterns) ⇒ Object
37 38 39 |
# File 'lib/archspec/definition.rb', line 37 def add_ignore_patterns(patterns) @ignore_patterns |= Array(patterns).flatten.compact.map(&:to_s) end |
#add_rule(rule) ⇒ Object
53 54 55 |
# File 'lib/archspec/definition.rb', line 53 def add_rule(rule) rules << rule end |
#add_source_patterns(patterns) ⇒ Object
33 34 35 |
# File 'lib/archspec/definition.rb', line 33 def add_source_patterns(patterns) @source_patterns |= Array(patterns).flatten.compact.map(&:to_s) end |
#analysis_patterns ⇒ Object
61 62 63 64 |
# File 'lib/archspec/definition.rb', line 61 def analysis_patterns patterns = source_patterns.empty? ? DEFAULT_SOURCE_PATTERNS.dup : source_patterns.dup patterns | component_specs.values.flat_map(&:file_patterns) end |
#component?(name) ⇒ Boolean
49 50 51 |
# File 'lib/archspec/definition.rb', line 49 def component?(name) component_specs.key?(name.to_sym) end |