Skip to content

Commit

Permalink
Abstract GITHUB constant into configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
joemsak committed Sep 30, 2012
1 parent f9f2bda commit 0ff01de
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
6 changes: 1 addition & 5 deletions lib/lexhub.rb
Expand Up @@ -29,9 +29,5 @@ def self.configure

Lexhub.configure do |config|
config.oauth_token = ENV['GITHUB_AUTH_TOKEN']
config.github = Github.new(:oauth_token => config.oauth_token)
end

# Internal: Github API Object
#
# Returns Github object
GITHUB = Github.new(:oauth_token => Lexhub.configuration.oauth_token)
7 changes: 7 additions & 0 deletions lib/lexhub/base.rb
Expand Up @@ -2,6 +2,13 @@ module Lexhub
# Base class for API interaction
class Base
private
# Internal: The Github object
#
# Returns Github object
def _github
Lexhub.configuration.github
end

# Internal: Collect items from API endpoints
#
# collection_item - Symbol name of item to collect
Expand Down
4 changes: 4 additions & 0 deletions lib/lexhub/configuration.rb
Expand Up @@ -4,8 +4,12 @@ class Configuration
# Public: Gets/Sets String oauth_token
attr_accessor :oauth_token

# Public: Gets/Sets Github github
attr_accessor :github

def initialize
self.oauth_token = nil
self.github = nil
end
end
end
2 changes: 1 addition & 1 deletion lib/lexhub/repo.rb
Expand Up @@ -81,7 +81,7 @@ def downcased_commit_message_words
#
# Returns the response from Github
def response(api_method)
@response ||= eval("GITHUB.#{api_method}(username, name)")
@response ||= eval("_github.#{api_method}(username, name)")
end
end
end

0 comments on commit 0ff01de

Please sign in to comment.