PageRenderTime 45ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/puppet_helper/bitbucket_singleton.rb

https://bitbucket.org/atlassian/agent-charlie
Ruby | 37 lines | 28 code | 9 blank | 0 comment | 1 complexity | e6698ad06230b870735950d0a52422ff MD5 | raw file
  1. require 'puppet_helper/generic_login_singleton'
  2. require 'rest-client'
  3. if not Object.const_defined?('BitbucketSingleton')
  4. class BitbucketSingleton < GenericLoginSingleton
  5. def initialize
  6. super('Bitbucket', 'Username or email')
  7. end
  8. def authenticate
  9. begin
  10. RestClient::Request.execute(
  11. :method => :get,
  12. :url => 'https://bitbucket.org/api/1.0/user',
  13. :user => @username,
  14. :password => @password
  15. )
  16. return true
  17. rescue
  18. return false
  19. end
  20. end
  21. def information
  22. puts <<-'EOS'.gsub(/^\t*/, '')
  23. Agent Charlie requires your Bitbucket account details so we can install your private key and check out some
  24. useful tools to set up your development environment.
  25. EOS
  26. end
  27. end
  28. end