/lib/puppet_helper/bitbucket_singleton.rb
Ruby | 37 lines | 28 code | 9 blank | 0 comment | 1 complexity | e6698ad06230b870735950d0a52422ff MD5 | raw file
- require 'puppet_helper/generic_login_singleton'
- require 'rest-client'
- if not Object.const_defined?('BitbucketSingleton')
- class BitbucketSingleton < GenericLoginSingleton
- def initialize
- super('Bitbucket', 'Username or email')
- end
- def authenticate
- begin
- RestClient::Request.execute(
- :method => :get,
- :url => 'https://bitbucket.org/api/1.0/user',
- :user => @username,
- :password => @password
- )
- return true
- rescue
- return false
- end
- end
- def information
- puts <<-'EOS'.gsub(/^\t*/, '')
- Agent Charlie requires your Bitbucket account details so we can install your private key and check out some
- useful tools to set up your development environment.
- EOS
- end
- end
- end