Class: Octopi::Base

Attributes

Instance Attributes

api [RW] public

Sets the attribute api.

Constants

VALID
{ :repo => { # FIXME: API currently chokes on repository names containing periods, # but presumably this will be fixed. :pat => /^[A-Za-z0-9_\.-]+$/, :msg => "%s is an invalid repository name"}, :user => { :pat => /^[A-Za-z0-9_\.-]+$/, :msg => "%s is an invalid username"}, :sha => { :pat => /^[a-f0-9]{40}$/, :msg => "%s is an invalid SHA hash"}, :state => { # FIXME: Any way to access Issue::STATES from here? :pat => /^(open|closed)$/, :msg => "%s is an invalid state; should be 'open' or 'closed'." } }

Constructor Summary

public initialize(attributes = {})
[View source]


29
30
31
32
33
34
35
36
37
# File 'lib/octopi/base.rb', line 29

def initialize(attributes={})
  # Useful for finding out what attr_accessor needs for classes
  # puts caller.first.inspect
  # puts "#{self.class.inspect} #{attributes.keys.map { |s| s.to_sym }.inspect}"
  attributes.each do |key, value|
    raise "no attr_accessor set for #{key} on #{self.class}" if !respond_to?("#{key}=")
    self.send("#{key}=", value)
  end
end

Public Visibility

Public Instance Method Summary

#error=(error)
#property(p, v)
#save

Public Instance Method Details

error=

public error=(error)
[View source]


39
40
41
42
43
# File 'lib/octopi/base.rb', line 39

def error=(error)
  if /\w+ not found/.match(error)
    raise NotFound, self.class
  end
end

property

public property(p, v)
[View source]


45
46
47
48
# File 'lib/octopi/base.rb', line 45

def property(p, v)
  path = "#{self.class.path_for(:resource)}/#{p}"
  @api.find(path, self.class.resource_name(:singular), v)
end

save

public save
[View source]


50
51
52
53
54
# File 'lib/octopi/base.rb', line 50

def save
  hash = {}
  @keys.each { |k| hash[k] = send(k) }
  @api.save(self.path_for(:resource), hash)
end
Generated on Friday, July 31 2009 at 05:01:55 PM by YARD 0.2.3.2 (ruby-1.8.6).