class Releasenotes::Hockey

Attributes

app_versions[R]

Public Class Methods

new(app_public_id: nil, user_api_key: nil) click to toggle source
# File lib/releasenotes/hockey.rb, line 10
def initialize(app_public_id: nil, user_api_key: nil)
        @app_public_id = app_public_id
        @user_api_key = user_api_key

        fetch_app_versions()
end

Public Instance Methods

last_commit() click to toggle source
# File lib/releasenotes/hockey.rb, line 17
def last_commit
        if @app_versions.nil?
                return nil
        end
        
        @app_versions.each do |version|
                notes = version['notes']
                match = COMMIT_REGEX.match(notes)
                if match.nil?
                        next
                end
                return match[0]
        end
end

Protected Instance Methods

fetch_app_versions() click to toggle source
# File lib/releasenotes/hockey.rb, line 34
def fetch_app_versions
        uri = URI("https://rink.hockeyapp.net/api/2/apps/#{@app_public_id}/app_versions")
        https = Net::HTTP.new(uri.host, uri.port)
        https.use_ssl = true
        request = Net::HTTP::Get.new(uri.path)
        request['X-HockeyAppToken'] = @user_api_key
        result = https.request(request)

        json = JSON.parse(result.body)
        if not json['errors'].nil?
                puts "Hockey error: " + json['errors'].to_s
        else
                @app_versions = json['app_versions']
        end
end