foauth 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -26,7 +26,9 @@ Or install it yourself as:
26
26
 
27
27
  ## Usage
28
28
 
29
- Create a new client passing in your [foauth][] email and password.
29
+ Create a new client passing in your [foauth][] email and password. If
30
+ you don't pass any credentials then it will look in the `FOAUTH_EMAIL`
31
+ and `FOAUTH_PASSWORD` environment variables.
30
32
 
31
33
  ```ruby
32
34
  client = Foauth.new('bob@example.org', 'secret')
@@ -82,6 +84,12 @@ See [faraday][] for more information.
82
84
 
83
85
  ## Version history
84
86
 
87
+ **0.4.0** (January 19, 2013)
88
+
89
+ * Credentials can now be read from the environment variables
90
+ `FOAUTH_EMAIL` and `FOAUTH_PASSWORD`. With these set you can create a
91
+ new client with no arguments (`Foauth.new`).
92
+
85
93
  **0.3.0** (January 12, 2013)
86
94
 
87
95
  * Ruby 1.8 support
data/lib/foauth.rb CHANGED
@@ -10,7 +10,7 @@ module Foauth
10
10
  # @param [String] password Your foauth.org password.
11
11
  # @yield [builder] Passes the `Faraday::Builder` instance to the block if given.
12
12
  # @return [Faraday::Connection] Configured to proxy requests to foauth.org.
13
- def self.new(email, password)
13
+ def self.new(email = ENV['FOAUTH_EMAIL'], password = ENV['FOAUTH_PASSWORD'])
14
14
  Faraday.new do |builder|
15
15
  builder.request :foauth_proxy
16
16
  builder.request :basic_auth, email, password
@@ -1,3 +1,3 @@
1
1
  module Foauth
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
data/spec/client_spec.rb CHANGED
@@ -28,4 +28,21 @@ describe Foauth do
28
28
  expect(response.env['foo']).to eq 'bar'
29
29
  end
30
30
  end
31
+
32
+ describe "with environment varaibles" do
33
+ let(:client) do
34
+ ENV['FOAUTH_EMAIL'] = 'foo@example.org'
35
+ ENV['FOAUTH_PASSWORD'] = 'secret'
36
+ Foauth.new
37
+ end
38
+
39
+ after do
40
+ ENV.delete('FOAUTH_EMAIL')
41
+ ENV.delete('FOAUTH_PASSWORD')
42
+ end
43
+
44
+ it "authenticates with environment credentials" do
45
+ expect(request_headers['Authorization']).to eq 'Basic Zm9vQGV4YW1wbGUub3JnOnNlY3JldA=='
46
+ end
47
+ end
31
48
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foauth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-12 00:00:00.000000000 Z
12
+ date: 2013-01-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday