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

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_and_options( *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 fill_options( receiver, options, *allow_defaults )
  options.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, options = args_and_options( *args )
  args.each do |a|
    options[ a ] = a.to_s if a && !options.key?( a )
  end
  opts = options.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( options, 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, options = help_args_and_options( *args )
  append_nested_block( options )
end