Method: Ditz::Operator.build_args

Defined in:
lib/operator.rb

.build_args(project, method, args) ⇒ Object

Raises:



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/operator.rb', line 58

def build_args project, method, args
  command = "command '#{method_to_op method}'"
  built_args = @operations[method][:args_spec].map do |spec|
    val = args.shift
    case spec
    when :issue
      raise Error, "#{command} requires an issue name" unless val
      project.issue_for(val) or raise Error, "no issue with name #{val}"
    when :release
      raise Error, "#{command} requires a release name" unless val
      project.release_for(val) or raise Error, "no release with name #{val}"
    when :maybe_release
      parse_releases_arg project, val
    when :string
      raise Error, "#{command} requires a string" unless val
      val
    else
      val # no translation for other types
    end
  end
  raise Error, "too many arguments for #{command}" unless args.empty?
  built_args
end