Parent

Included Modules

Files

POM::Resources

The Resource class models a table of project releated URIs. Each entry has a name and URI. The class is Enumerable so each entry can be iterated over, much like a hash.

The class also recognizes common entry names and aliases, which can be accessed via method calls.

How aliases work in this class is unique. When a recognized name is assigned an URI, all it’s aliases are assigned the URI as well. Therefore when iterating over the entries there will be duplicate URIs under the various names.

Resources.new(:home=>'http://foo.com').to_h
#=> {:home=>'http://foo.com', :homepage=>'http://foo.com'}

Attributes

api[RW]

Location of API reference documentation.

blog[RW]

Resource to project blog.

bugs[RW]

Location of issue tracker.

code[RW]

Browse source code.

dev[RW]

Location of development site.

development[RW]

Location of development site.

distributor[RW]

Package distribution service webpage.

doc[RW]

Location of documentation.

docs[RW]

Location of documentation.

documentation[RW]

Location of documentation.

download[RW]

Location to downloadable package(s).

email[RW]

Mailing list email or web address to online version.

forum[RW]

User discussion forum.

home[RW]

Offical project website.

homepage[RW]

Offical project website.

irc[RW]

IRC channel

issues[RW]

Location of issue tracker.

mail[RW]

Mailing list email or web address to online version.

mailinglist[RW]

Mailing list email or web address to online version.

reference[RW]

Location of API reference documentation.

repo[RW]

Resource for central public repository, e.g. `git://github.com/protuils/pom.git`.

repository[RW]

Resource for central public repository, e.g. `git://github.com/protuils/pom.git`.

source[RW]

Browse source code.

support[RW]

Location of support forum.

system_guide[RW]

Location of API reference documentation.

user_guide[RW]

Location of wiki.

weblog[RW]

Resource to project blog.

wiki[RW]

Location of wiki.

work[RW]

Location of development site.

Public Class Methods

attr_accessor(*names) click to toggle source

Special accessors disperse access over multiple hash entries.

# File lib/pom/resources.rb, line 26
def self.attr_accessor(*names)
  code = []
  names.each do |name|
    code << "def #{name}"
    code << "  @table['#{name}']"
    code << "end"
    code << "def #{name}=(val)"
    names.each do |n|
      code << "  @table['#{n}'] = val"
    end
    code << "end"
  end
  module_eval code.join("\n")
end
new(table={}) click to toggle source

New Resources object. The initializer can take a hash of name to URI settings.

# File lib/pom/resources.rb, line 43
def initialize(table={})
  @table = {}
  table.each{ |k,v| __send__("#{k}=", v) }
end

Public Instance Methods

each(&block) click to toggle source

Iterate over each enty, including aliases.

# File lib/pom/resources.rb, line 101
def each(&block)
  @table.each(&block)
end
method_missing(sym, *args) click to toggle source

If a method is missing and it is a setter method (ending in ‘=’) then a new entry by that name will be added to the table. If a plain method then the name will be looked for in the table.

# File lib/pom/resources.rb, line 114
def method_missing(sym, *args)
  meth = sym.to_s
  name = meth.chomp('=')
  case meth
  when /=$/
    @table[name] = args.first
  else
    super(sym, *args) if block_given? or args.size > 0
    nil
  end
end
size() click to toggle source

The size of the table, including aliases.

# File lib/pom/resources.rb, line 106
def size
  @table.size
end
to_h() click to toggle source

Convert to Hash by duplicating the underlying hash table.

# File lib/pom/resources.rb, line 96
def to_h
  @table.dup
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.