module Svnx::Base::Tags::ClassMethods

Public Instance Methods

has(*fields) click to toggle source

for common options/tags

# File lib/svnx/base/tags.rb, line 32
def has(*fields)
  fields.each do |field|
    arg = mapping field
    has_field field, arg
  end
end
has_tag_argument(*names) click to toggle source

tags with an argument

# File lib/svnx/base/tags.rb, line 55
def has_tag_argument(*names)
  has_tags(true, *names)
end
has_tag_field(*names) click to toggle source

tags with no argument

# File lib/svnx/base/tags.rb, line 50
def has_tag_field(*names)
  has_tags(false, *names)
end
has_tags(argument, *names) click to toggle source

tags with an argument

# File lib/svnx/base/tags.rb, line 60
def has_tags(argument, *names)
  names.each do |name|
    tag = to_tag name
    value = argument ? to_args(tag, name) : tag
    has_field name, value
  end
end
mapping(field) click to toggle source

common options/tags

# File lib/svnx/base/tags.rb, line 10
def mapping field
  case field
  when :revision
    to_args "-r", field
  when :ignore_whitespace
    %w{ -x -bw -x --ignore-eol-style }
  when :paths
    nil
  when :path
    nil
  when :urls
    nil
  when :url
    nil
  when :file
    to_args "--file", field
  else
    raise "invalid field '#{field}'"
  end
end
to_args(tagname, methname) click to toggle source

gets the value for the tag/option by calling methname

# File lib/svnx/base/tags.rb, line 40
def to_args tagname, methname
  Proc.new { |obj| [ tagname, obj.send(methname) ] }
end
to_tag(sym) click to toggle source

converts the symbol to a tag

# File lib/svnx/base/tags.rb, line 45
def to_tag sym
  "--" + Svnx::StringUtil.with_dashes(sym)
end