Skip to content

Commit d2ccaaa

Browse files
committed
Add ability to explicitly configure.
1 parent 2404df2 commit d2ccaaa

File tree

2 files changed

+42
-4
lines changed

2 files changed

+42
-4
lines changed

lib/github_api.rb

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def included(base)
2828
#
2929
# @api public
3030
def new(options = {}, &block)
31-
Github::Client.new(options, &block)
31+
Client.new(options, &block)
3232
end
3333

3434
# Delegate to Github::Client
@@ -52,7 +52,8 @@ def respond_to?(method_name, include_private = false)
5252
end
5353

5454
module ClassMethods
55-
# Requires internal github_api libraries
55+
56+
# Requires internal libraries
5657
#
5758
# @param [String] prefix
5859
# the relative path prefix
@@ -66,9 +67,31 @@ def require_all(prefix, *libs)
6667
end
6768
end
6869

69-
# Main client global configuration
70+
# The client configuration
71+
#
72+
# @return [Configuration]
73+
#
74+
# @api public
7075
def configuration
71-
@configuration ||= Github::Configuration.new
76+
@configuration ||= Configuration.new
77+
end
78+
79+
# Configure options
80+
#
81+
# @example
82+
# Github.configure do |c|
83+
# c.some_option = true
84+
# end
85+
#
86+
# @yield the configuration block
87+
# @yieldparam configuration [Github::Configuration]
88+
# the configuration instance
89+
#
90+
# @return [nil]
91+
#
92+
# @api public
93+
def configure
94+
yield configuration
7295
end
7396
end
7497

spec/github/configure_spec.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# encoding: utf-8
2+
3+
require 'spec_helper'
4+
5+
describe Github, '#configure' do
6+
subject { described_class }
7+
8+
it "allows to configure settings" do
9+
yielded = nil
10+
Github.configure do |config|
11+
yielded = config
12+
end
13+
expect(yielded).to be_a(Github::Configuration)
14+
end
15+
end

0 commit comments

Comments
 (0)