Class: LockJar::Domain::DslMerger
- Inherits:
-
Object
- Object
- LockJar::Domain::DslMerger
- Defined in:
- lib/lock_jar/domain/dsl_merger.rb
Overview
Merge DSLs
Instance Attribute Summary collapse
-
#from_dsl ⇒ Object
readonly
Returns the value of attribute from_dsl.
-
#into_dsl ⇒ Object
readonly
Returns the value of attribute into_dsl.
-
#into_groups ⇒ Object
readonly
Returns the value of attribute into_groups.
Instance Method Summary collapse
-
#initialize(into_dsl, from_dsl, into_groups = nil) ⇒ DslMerger
constructor
A new instance of DslMerger.
-
#merge ⇒ LockJar::Domain::Dsl
Merge LockJar::Domain::Dsl.
Constructor Details
#initialize(into_dsl, from_dsl, into_groups = nil) ⇒ DslMerger
Returns a new instance of DslMerger.
26 27 28 29 30 |
# File 'lib/lock_jar/domain/dsl_merger.rb', line 26 def initialize(into_dsl, from_dsl, into_groups = nil) @into_dsl = into_dsl @from_dsl = from_dsl @into_groups = into_groups end |
Instance Attribute Details
#from_dsl ⇒ Object (readonly)
Returns the value of attribute from_dsl.
20 21 22 |
# File 'lib/lock_jar/domain/dsl_merger.rb', line 20 def from_dsl @from_dsl end |
#into_dsl ⇒ Object (readonly)
Returns the value of attribute into_dsl.
20 21 22 |
# File 'lib/lock_jar/domain/dsl_merger.rb', line 20 def into_dsl @into_dsl end |
#into_groups ⇒ Object (readonly)
Returns the value of attribute into_groups.
20 21 22 |
# File 'lib/lock_jar/domain/dsl_merger.rb', line 20 def into_groups @into_groups end |
Instance Method Details
#merge ⇒ LockJar::Domain::Dsl
Merge LockJar::Domain::Dsl
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/lock_jar/domain/dsl_merger.rb', line 34 def merge merged_dsl = into_dsl.dup merged_dsl.remote_repositories = remote_repositories merged_dsl.artifacts = artifact_groups(into_groups) from_dsl.maps.each do |artifact, paths| maps = into_dsl.maps[artifact] || [] merged_dsl.maps[artifact] = (maps + paths).uniq end from_dsl.excludes.each do |exclude| merged_dsl.excludes << exclude unless into_dsl.excludes.include? exclude end merged_dsl.merged << from_dsl.file_path if from_dsl.file_path merged_dsl end |