Class: LockJar::Domain::DslHelper
- Inherits:
-
Object
- Object
- LockJar::Domain::DslHelper
- Defined in:
- lib/lock_jar/domain/dsl_helper.rb
Class Method Summary collapse
-
.merge(into_dsl, from_dsl, into_group = nil) ⇒ LockJar::Domain::Dsl
Merge LockJar::Domain::Dsl.
- .read_file(file) ⇒ Object
Class Method Details
.merge(into_dsl, from_dsl, into_group = nil) ⇒ LockJar::Domain::Dsl
Merge LockJar::Domain::Dsl
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/lock_jar/domain/dsl_helper.rb', line 28 def merge( into_dsl, from_dsl, into_group = nil ) into_dsl.remote_repositories = (into_dsl.remote_repositories + from_dsl.remote_repositories).uniq # merge default and runtime group into specific group if into_group group_artifacts = into_dsl.artifacts[into_group] || [] defaults = from_dsl.artifacts['default'] || [] runtime = from_dsl.artifacts['runtime'] || [] ( defaults + runtime ).each do |art| unless group_artifacts.include? art group_artifacts << art end end into_dsl.artifacts[into_group] = group_artifacts # one to one merging of groups else from_dsl.artifacts.each do |group, artifacts| group_artifacts = into_dsl.artifacts[group] || [] artifacts.each do |art| unless group_artifacts.include? art group_artifacts << art end end into_dsl.artifacts[group] = group_artifacts end end from_dsl.maps.each do |artifact,paths| existing_map = into_dsl.maps[artifact] if existing_map into_dsl.maps[artifact] = (existing_map + paths).uniq else into_dsl.maps[artifact] = paths end end from_dsl.excludes.each do |exclude| unless into_dsl.include? exclude into_dsl.excludes << exclude end end if from_dsl.file_path into_dsl.merged << from_dsl.file_path end into_dsl end |
.read_file(file) ⇒ Object
78 79 80 |
# File 'lib/lock_jar/domain/dsl_helper.rb', line 78 def read_file(file) File.open(file, "rb") { |f| f.read } end |