Module: Svnx::Base::Tags::ClassMethods

Included in:
Svnx::Base::Tags
Defined in:
lib/svnx/base/tags.rb

Instance Method Summary collapse

Instance Method Details

#has(*fields) ⇒ Object

for common options/tags



32
33
34
35
36
37
# 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) ⇒ Object

tags with an argument



55
56
57
# File 'lib/svnx/base/tags.rb', line 55

def has_tag_argument(*names)
  has_tags(true, *names)
end

#has_tag_field(*names) ⇒ Object

tags with no argument



50
51
52
# File 'lib/svnx/base/tags.rb', line 50

def has_tag_field(*names)
  has_tags(false, *names)
end

#has_tags(argument, *names) ⇒ Object

tags with an argument



60
61
62
63
64
65
66
# 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) ⇒ Object

common options/tags



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# 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) ⇒ Object

gets the value for the tag/option by calling methname



40
41
42
# File 'lib/svnx/base/tags.rb', line 40

def to_args tagname, methname
  Proc.new { |obj| [ tagname, obj.send(methname) ] }
end

#to_tag(sym) ⇒ Object

converts the symbol to a tag



45
46
47
# File 'lib/svnx/base/tags.rb', line 45

def to_tag sym
  "--" + Svnx::StringUtil.with_dashes(sym)
end