Permalink
Browse files

Use existing interface to read API key from file

  • Loading branch information...
sferik committed Jul 2, 2011
1 parent 7f6d95a commit 64ab5f32f93737474e9472da143a4233e7d92c65
Showing with 5 additions and 8 deletions.
  1. +5 −8 lib/gems/configuration.rb
View
@@ -1,4 +1,5 @@
require 'gems/version'
+require 'rubygems'
require 'yaml'
module Gems
@@ -12,19 +13,15 @@ module Configuration
:username,
]
- # The response format appended to the path if none is set
+ # Set the default response format appended to the path
#
# @note JSON is preferred over XML because it is more concise and faster to parse.
DEFAULT_FORMAT = :json
- # Attempt to automatically load credentials
- DEFAULT_KEY = begin
- YAML.load(File.read(File.expand_path("~/.gem/credentials")))[:rubygems_api_key]
- rescue Errno::ENOENT
- nil
- end
+ # Set the default credentials
+ DEFAULT_KEY = Gem.configuration.rubygems_api_key
- # The value sent in the 'User-Agent' header if none is set
+ # Set the default value sent in the 'User-Agent' header
DEFAULT_USER_AGENT = "Gems #{Gems::VERSION}".freeze
attr_accessor *VALID_OPTIONS_KEYS

0 comments on commit 64ab5f3

Please sign in to comment.