Module: Maven::Tools::DSL::Options
- Included in:
- DependencyDSL, ExclusionDSL, ExclusionsDSL, JRubyDSL, Jarfile, RepositoryDSL
- Defined in:
- lib/maven/tools/dsl/options.rb
Instance Method Summary collapse
- #args_and_options(*args) ⇒ Object
- #fill_options(receiver, options, *allow_defaults) ⇒ Object
- #help(name, *args) ⇒ Object
- #help_block(*args) ⇒ Object
Instance Method Details
#args_and_options(*args) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/maven/tools/dsl/options.rb', line 26 def ( *args ) if args.last.is_a? Hash [ args[0..-2], args.last ] else [ args, {} ] end end |
#fill_options(receiver, options, *allow_defaults) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/maven/tools/dsl/options.rb', line 34 def ( receiver, , *allow_defaults ) .each do |k,v| if ! allow_defaults.member?( k ) && receiver.send( "#{k}".to_sym ) raise "#{receiver} has attribute #{k} already set" end receiver.send( "#{k}=".to_sym, v ) end end |
#help(name, *args) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/maven/tools/dsl/options.rb', line 43 def help( name, *args ) args, = ( *args ) args.each do |a| [ a ] = a.to_s if a && !.key?( a ) end opts = .select{ |k,v| v } t = "\n# " + name.to_s.upcase + " #\n\n" unless opts.empty? t += "hash options: #{name} #{opts.inspect.gsub( /\"[{]/, '(' ).gsub( /[}]\"/, ')' )}\n" end t += "nested: #{name} do\n" t = append_nested_block( , t ) t += " end\n" t end |
#help_block(*args) ⇒ Object
59 60 61 62 |
# File 'lib/maven/tools/dsl/options.rb', line 59 def help_block( *args ) args, = ( *args ) append_nested_block( ) end |