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.
21 22 23 24 25 26 27 28 29 |
# File 'lib/archspec/definition.rb', line 21 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.
18 19 20 |
# File 'lib/archspec/definition.rb', line 18 def baseline_path @baseline_path end |
#component_specs ⇒ Object (readonly)
Returns the value of attribute component_specs.
19 20 21 |
# File 'lib/archspec/definition.rb', line 19 def component_specs @component_specs end |
#ignore_patterns ⇒ Object (readonly)
Returns the value of attribute ignore_patterns.
19 20 21 |
# File 'lib/archspec/definition.rb', line 19 def ignore_patterns @ignore_patterns end |
#name ⇒ Object
Returns the value of attribute name.
18 19 20 |
# File 'lib/archspec/definition.rb', line 18 def name @name end |
#root_path ⇒ Object
Returns the value of attribute root_path.
18 19 20 |
# File 'lib/archspec/definition.rb', line 18 def root_path @root_path end |
#rules ⇒ Object (readonly)
Returns the value of attribute rules.
19 20 21 |
# File 'lib/archspec/definition.rb', line 19 def rules @rules end |
#source_patterns ⇒ Object (readonly)
Returns the value of attribute source_patterns.
19 20 21 |
# File 'lib/archspec/definition.rb', line 19 def source_patterns @source_patterns end |
Instance Method Details
#absolute_root(base_dir = Dir.pwd) ⇒ Object
55 56 57 |
# File 'lib/archspec/definition.rb', line 55 def absolute_root(base_dir = Dir.pwd) File.(root_path, base_dir) end |
#add_component(spec) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/archspec/definition.rb', line 39 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
35 36 37 |
# File 'lib/archspec/definition.rb', line 35 def add_ignore_patterns(patterns) @ignore_patterns |= Array(patterns).flatten.compact.map(&:to_s) end |
#add_rule(rule) ⇒ Object
51 52 53 |
# File 'lib/archspec/definition.rb', line 51 def add_rule(rule) rules << rule end |
#add_source_patterns(patterns) ⇒ Object
31 32 33 |
# File 'lib/archspec/definition.rb', line 31 def add_source_patterns(patterns) @source_patterns |= Array(patterns).flatten.compact.map(&:to_s) end |
#analysis_patterns ⇒ Object
59 60 61 62 |
# File 'lib/archspec/definition.rb', line 59 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
47 48 49 |
# File 'lib/archspec/definition.rb', line 47 def component?(name) component_specs.key?(name.to_sym) end |