Class: LockJar::Domain::Dsl
- Inherits:
-
Object
- Object
- LockJar::Domain::Dsl
- Defined in:
- lib/lock_jar/domain/dsl.rb
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_GROUP =
['default']
Instance Attribute Summary collapse
-
#artifacts ⇒ Object
Returns the value of attribute artifacts.
-
#excludes ⇒ Object
Returns the value of attribute excludes.
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
-
#groups ⇒ Object
Returns the value of attribute groups.
-
#local_repository ⇒ Object
(also: #name)
Returns the value of attribute local_repository.
-
#maps ⇒ Object
Returns the value of attribute maps.
-
#merged ⇒ Object
Returns the value of attribute merged.
-
#remote_repositories ⇒ Object
Returns the value of attribute remote_repositories.
Class Method Summary collapse
Instance Method Summary collapse
- #exclude(*notations) ⇒ Object
- #group(*groups, &blk) ⇒ Object
-
#initialize ⇒ Dsl
constructor
A new instance of Dsl.
- #jar(notation, *args) ⇒ Object
- #local(*args) ⇒ Object
- #local_repo(path) ⇒ Object
-
#map(notation, *args) ⇒ Object
Map a dependency to another dependency or local directory.
- #pom(path, *args) ⇒ Object
- #remote_repo(url, opts = {}) ⇒ Object (also: #remote_repository, #repository)
-
#scope(*scopes, &blk) ⇒ Object
deprecated
Deprecated.
Please use #group instead
Constructor Details
#initialize ⇒ Dsl
Returns a new instance of Dsl.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/lock_jar/domain/dsl.rb', line 56 def initialize @remote_repositories = [] @artifacts = { 'default' => [] } @group_changed = false @present_group = 'default' @local_repository = nil @maps = {} @excludes = [] @merged = [] end |
Instance Attribute Details
#artifacts ⇒ Object
Returns the value of attribute artifacts.
26 27 28 |
# File 'lib/lock_jar/domain/dsl.rb', line 26 def artifacts @artifacts end |
#excludes ⇒ Object
Returns the value of attribute excludes.
26 27 28 |
# File 'lib/lock_jar/domain/dsl.rb', line 26 def excludes @excludes end |
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
29 30 31 |
# File 'lib/lock_jar/domain/dsl.rb', line 29 def file_path @file_path end |
#groups ⇒ Object
Returns the value of attribute groups.
26 27 28 |
# File 'lib/lock_jar/domain/dsl.rb', line 26 def groups @groups end |
#local_repository ⇒ Object Also known as: name
Returns the value of attribute local_repository.
26 27 28 |
# File 'lib/lock_jar/domain/dsl.rb', line 26 def local_repository @local_repository end |
#maps ⇒ Object
Returns the value of attribute maps.
26 27 28 |
# File 'lib/lock_jar/domain/dsl.rb', line 26 def maps @maps end |
#merged ⇒ Object
Returns the value of attribute merged.
26 27 28 |
# File 'lib/lock_jar/domain/dsl.rb', line 26 def merged @merged end |
#remote_repositories ⇒ Object
Returns the value of attribute remote_repositories.
26 27 28 |
# File 'lib/lock_jar/domain/dsl.rb', line 26 def remote_repositories @remote_repositories end |
Class Method Details
.create(jarfile = nil, &blk) ⇒ Object
33 34 35 36 |
# File 'lib/lock_jar/domain/dsl.rb', line 33 def create(jarfile = nil, &blk) builder = new evaluate(builder, jarfile, &blk) end |
.evaluate(builder, jarfile = nil, &blk) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/lock_jar/domain/dsl.rb', line 38 def evaluate(builder, jarfile = nil, &blk) if jarfile.nil? && blk.nil? raise "jarfile or block must be set" end if jarfile builder.instance_eval(DslHelper.read_file(jarfile.to_s), jarfile.to_s, 1) end if blk builder.instance_eval(&blk) end builder end |
Instance Method Details
#exclude(*notations) ⇒ Object
73 74 75 |
# File 'lib/lock_jar/domain/dsl.rb', line 73 def exclude(*notations) @excludes += notations end |
#group(*groups, &blk) ⇒ Object
142 143 144 145 146 147 148 149 150 |
# File 'lib/lock_jar/domain/dsl.rb', line 142 def group(*groups, &blk) @group_changed = true groups.each do |group| @present_group = group.to_s yield end @group_changed = false @present_group = 'default' end |
#jar(notation, *args) ⇒ Object
77 78 79 80 81 82 83 84 85 86 |
# File 'lib/lock_jar/domain/dsl.rb', line 77 def jar(notation, *args) opts = {} if args.last.is_a? Hash opts.merge!( args.last ) end artifact = Jar.new( notation ) assign_groups( artifact, opts[:group] ) end |
#local(*args) ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/lock_jar/domain/dsl.rb', line 88 def local( *args ) unless args.empty? if File.directory?( File.( args.first ) ) warn "[DEPRECATION] `local` to set local_repository is deprecated. Please use `local_repo` instead." local_repo(args.first) else path = args.shift opts = {} if args.last.is_a? Hash opts.merge!( args.last ) end artifact = Local.new( path ) assign_groups( artifact, opts[:group] ) end end end |
#local_repo(path) ⇒ Object
108 109 110 |
# File 'lib/lock_jar/domain/dsl.rb', line 108 def local_repo( path ) @local_repository = path end |
#map(notation, *args) ⇒ Object
Map a dependency to another dependency or local directory.
115 116 117 |
# File 'lib/lock_jar/domain/dsl.rb', line 115 def map( notation, *args ) @maps[notation] = args end |
#pom(path, *args) ⇒ Object
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/lock_jar/domain/dsl.rb', line 120 def pom(path, *args) unless path =~ /\.xml$/i raise "#{path} is an invalid pom path" end opts = { :scopes => ['runtime', 'compile'] } if args.last.is_a? Hash opts.merge! args.last end artifact = Pom.new( path, opts[:scopes] ) assign_groups( artifact, opts[:groups] ) end |
#remote_repo(url, opts = {}) ⇒ Object Also known as: remote_repository, repository
136 137 138 |
# File 'lib/lock_jar/domain/dsl.rb', line 136 def remote_repo( url, opts = {} ) @remote_repositories << url end |
#scope(*scopes, &blk) ⇒ Object
Please use #group instead
153 154 155 156 |
# File 'lib/lock_jar/domain/dsl.rb', line 153 def scope(*scopes, &blk) warn "[DEPRECATION] `scope` is deprecated. Please use `group` instead." group(*scopes,&blk) end |