Class: GitHooks::Notifier::TrackerClient
- Inherits:
-
Object
- Object
- GitHooks::Notifier::TrackerClient
- Defined in:
- lib/git_hooks/notifier/tracker_client.rb
Instance Attribute Summary collapse
-
#curl ⇒ Object
readonly
Returns the value of attribute curl.
Class Method Summary collapse
Instance Method Summary collapse
- #create_payloads(commits, &block) ⇒ Object
- #deliver(commits) ⇒ Object
-
#initialize(tracker_options) ⇒ TrackerClient
constructor
A new instance of TrackerClient.
Constructor Details
#initialize(tracker_options) ⇒ TrackerClient
Returns a new instance of TrackerClient.
16 17 18 19 20 21 |
# File 'lib/git_hooks/notifier/tracker_client.rb', line 16 def initialize() @curl = Curl::Easy.new("http://www.pivotaltracker.com/services/v3/source_commits") do |curl| curl.headers["X-TrackerToken"] = [:api_key] curl.headers["Content-type"] = "application/xml" end end |
Instance Attribute Details
#curl ⇒ Object (readonly)
Returns the value of attribute curl.
7 8 9 |
# File 'lib/git_hooks/notifier/tracker_client.rb', line 7 def curl @curl end |
Class Method Details
.deliver(options) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/git_hooks/notifier/tracker_client.rb', line 9 def self.deliver() commits = .delete(:commits) client_instance = new() client_instance.deliver(commits) end |
Instance Method Details
#create_payloads(commits, &block) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/git_hooks/notifier/tracker_client.rb', line 29 def create_payloads(commits, &block) payloads = commits.map do |commit| <<-XML <source_commit> <message>#{commit.}</message> <author>#{commit..name}</author> <commit_id>#{commit.id}</commit_id> </source_commit> XML end payloads.each(&block) end |
#deliver(commits) ⇒ Object
23 24 25 26 27 |
# File 'lib/git_hooks/notifier/tracker_client.rb', line 23 def deliver(commits) create_payloads(commits) do |payload| curl.http_post(payload) end end |