class AgileNotifier::Github

Constants

ENTERPRISE_API
USERAGENT

Public Class Methods

get_value(key, url) click to toggle source
# File lib/agile_notifier/github.rb, line 50
def get_value(key, url)
  args = @@headers
  args.merge!(@@auth) if @@auth && @@auth.has_key?(:basic_auth)
  get_value_of_key(key, url, args)
end
new(url, args = {}) click to toggle source
Calls superclass method
# File lib/agile_notifier/github.rb, line 16
def initialize(url, args = {})
  super
  basic_auth = args.fetch(:basic_auth, nil)
  access_token = args.fetch(:Authorization, nil)
  if basic_auth
    @@auth = {:basic_auth => basic_auth}
  elsif access_token
    @@headers[@@headers.keys.first] = @@headers.values.first.merge({'Authorization' => access_token})
  end
  if url.include?(ENTERPRISE_API)
    status_url = url + '/zen'
    begin
      args = [status_url]
      args.push(@@auth && @@auth.has_key?(:basic_auth) ? @@headers.merge(@@auth) : @@headers)
      status = HTTParty.get(*args).code
      availability = ( status == 200 )
    rescue => e
      puts e.message
      availability = false
    end
  else
    @url.gsub!(/github\./, 'api.github.')
    status_url = url.gsub(/:\/\/api\./, '://status.') + '/api/status.json'
    status = self.class.get_value('status', status_url)
    availability = ( status == 'good' )
  end
  raise('Github is not available.') unless availability
end
new_enterprise_version(url, args = {}) click to toggle source
# File lib/agile_notifier/github.rb, line 46
def new_enterprise_version(url, args = {})
  new(url + ENTERPRISE_API, args)
end

Public Instance Methods

add_repository(args) click to toggle source
# File lib/agile_notifier/github.rb, line 57
def add_repository(args)
  user = args[:user]
  repo = args[:repo]
  repository = Repository.new(user: user, repo: repo, url: @url)
  @repositories.push(repository)
end