class GithubPivotalFlow::Project

Attributes

config[RW]
host[RW]
name[RW]
owner[RW]

Public Class Methods

find(id) click to toggle source
# File lib/github_pivotal_flow/project.rb, line 5
def self.find(id)
  id = id.to_i if id.is_a?(String)
  return PivotalTracker::Project.find(id)
end
new(args = {}) click to toggle source
# File lib/github_pivotal_flow/project.rb, line 10
def initialize(args = {})
  args.each do |k,v|
    instance_variable_set("@#{k}", v) unless v.nil?
  end
  url = Git.get_config("remote.#{Git.get_remote}.url")
  if (matchdata = /^git@([a-z0-9\._-]+):([a-z0-9_-]+)\/([a-z0-9_-]+)(\.git)?$/i.match(url.strip))
    self.host ||= matchdata[1]
    self.owner ||= matchdata[2]
    self.name ||= matchdata[3]
  else
    url = URI(url) if !url.is_a?(URI)
    path_components = url.path.split('/', 4)
    self.owner ||= path_components[1]
    self.name ||= path_components[2]
    self.host ||= url.host
  end
  self.name = self.name.tr(' ', '-').sub(/\.git$/, '') if self.name
  self.name ||= File.basename(Dir.getwd)
  self.host ||= 'github.com'
  self.host = host.sub(/^ssh\./i, '') if 'ssh.github.com' == host.downcase
end

Public Instance Methods

==(other) click to toggle source
# File lib/github_pivotal_flow/project.rb, line 36
def ==(other)
  name_with_owner == other.name_with_owner
end
method_missing(m, *args, &block) click to toggle source
# File lib/github_pivotal_flow/project.rb, line 44
def method_missing(m, *args, &block)
  return pivotal_project.send(m, *args, &block)
end
name_with_owner() click to toggle source
# File lib/github_pivotal_flow/project.rb, line 32
def name_with_owner
  "#{owner}/#{name}"
end
pivotal_project() click to toggle source
# File lib/github_pivotal_flow/project.rb, line 40
def pivotal_project
  @pivotal_project ||= self.class.find(self.config.project_id)
end