Class: Hookers::Pivotal::TrackerProject

Inherits:
Object
  • Object
show all
Defined in:
lib/hookers/pivotal/tracker_project.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token) ⇒ TrackerProject

Returns a new instance of TrackerProject.



8
9
10
11
12
13
# File 'lib/hookers/pivotal/tracker_project.rb', line 8

def initialize(token)
  raise "Pivotal api token not found" unless token
  self.token = token
  self.git = Git::Repository.new
  self.base_uri = 'http://www.pivotaltracker.com/'
end

Instance Attribute Details

#base_uriObject

Returns the value of attribute base_uri.



6
7
8
# File 'lib/hookers/pivotal/tracker_project.rb', line 6

def base_uri
  @base_uri
end

#gitObject

Returns the value of attribute git.



6
7
8
# File 'lib/hookers/pivotal/tracker_project.rb', line 6

def git
  @git
end

#tokenObject

Returns the value of attribute token.



6
7
8
# File 'lib/hookers/pivotal/tracker_project.rb', line 6

def token
  @token
end

Instance Method Details

#commit_uriObject



15
16
17
# File 'lib/hookers/pivotal/tracker_project.rb', line 15

def commit_uri
  "#{self.base_uri}services/v3/source_commits"
end

#notify_changesObject



19
20
21
22
23
24
25
26
27
# File 'lib/hookers/pivotal/tracker_project.rb', line 19

def notify_changes
  puts "Notifying pivotal tracker of changes..."

  commit = git.last_commit

  response = HttpClient.post(commit_uri, commit.to_xml, { "X-TrackerToken" => self.token, "Content-type" => "application/xml"  })

  puts "Pivotal notified succesfully" if response.code == "200"
end