Sha256: bc9c69010f44df3b357fa5f6dfbe104ac18e55c2e9c9317f5d0838a01a660e26

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

module Sifterology
  
  class Commit < Resource
    
    attr_accessor :project_url, :status, :assignee, :unassign, :issue, :changeset_url,
                  :committer, :committer_email, :commit_time, :commit_message
    
    def save
      post(entity_path, :body => payload)
    end
    
    def entity_path
      File.join(project_path, 'beanstalk')
    end
    
    def project_path
      URI.parse(project_url).path
    end
    
  private
  
    def payload
      sanitize_payload({
        "issue"    => issue,
        "assignee" => assignee,
        "status"   => status,
        "commit" => {
          "changeset_url" => changeset_url,
          "message"       => commit_message,
          "author"        => committer,
          "author_email"  => committer_email,
          "time"          => commit_time,
        }
      })
    end
    
    def sanitize_payload(hash)
      hash.tap do |h|
        h['assignee'] = ''   if unassign
        h.delete("status")   if hash["status"].nil?
        h.delete("assignee") if hash["assignee"].nil?
      end
    end
    
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sifterology-0.1.1 lib/sifterology/commit.rb