Class: Octopi::Base
- Inherits:
-
Object
- Object
- Octopi::Base
- Defined in:
- lib/octopi/base.rb
Direct Known Subclasses
Blob, Branch, Comment, Commit, FileObject, Gist, Issue, IssueComment, Key, Plan, Repository, Tag, Tree, User
Constant Summary collapse
- 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'." } }
Instance Attribute Summary collapse
-
#api ⇒ Object
Returns the value of attribute api.
Instance Method Summary collapse
- #error=(error) ⇒ Object
-
#initialize(attributes = {}) ⇒ Base
constructor
A new instance of Base.
- #property(p, v) ⇒ Object
- #save ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Base
Returns a new instance of Base.
24 25 26 27 28 29 30 31 32 |
# File 'lib/octopi/base.rb', line 24 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| method = "#{key}=" self.send(method, value) if respond_to? method end end |
Instance Attribute Details
#api ⇒ Object
Returns the value of attribute api.
22 23 24 |
# File 'lib/octopi/base.rb', line 22 def api @api end |
Instance Method Details
#error=(error) ⇒ Object
34 35 36 37 38 |
# File 'lib/octopi/base.rb', line 34 def error=(error) if /\w+ not found/.match(error) raise NotFound, self.class end end |