class BitbucketPayload
A parser for Bitbucket payload data
Public Class Methods
new(data)
click to toggle source
# File lib/robot_sweatshop/payload/bitbucket.rb, line 7 def initialize(data) data = URI.decode_www_form(data)[0][1] @data = JSON.parse data || {} end
Public Instance Methods
branch()
click to toggle source
# File lib/robot_sweatshop/payload/bitbucket.rb, line 41 def branch latest_commit['branch'] end
clone_url()
click to toggle source
# File lib/robot_sweatshop/payload/bitbucket.rb, line 33 def clone_url "#{ @data['canon_url'] }#{ repository['absolute_url'] }" end
hash()
click to toggle source
# File lib/robot_sweatshop/payload/bitbucket.rb, line 37 def hash latest_commit['raw_node'] end
latest_commit()
click to toggle source
# File lib/robot_sweatshop/payload/bitbucket.rb, line 12 def latest_commit return {} if @data['commits'].nil? @data['commits'].last end
message()
click to toggle source
# File lib/robot_sweatshop/payload/bitbucket.rb, line 45 def message latest_commit['message'] end
repo_slug()
click to toggle source
# File lib/robot_sweatshop/payload/bitbucket.rb, line 49 def repo_slug slug = repository['absolute_url'] slug.nil? ? nil : slug[1...-1] end
repository()
click to toggle source
# File lib/robot_sweatshop/payload/bitbucket.rb, line 17 def repository return {} if @data['repository'].nil? @data['repository'] end
source_url()
click to toggle source
# File lib/robot_sweatshop/payload/bitbucket.rb, line 54 def source_url return '' if @data['canon_url'].nil? || repository.empty? || latest_commit.empty? base_url = @data['canon_url'] "#{base_url}/#{repo_slug}/commits/#{hash}/?at=#{branch}" end