Skip to content

Commit 7a8a7f7

Browse files
Putting config class in client
1 parent 202e25f commit 7a8a7f7

File tree

6 files changed

+14
-18
lines changed

6 files changed

+14
-18
lines changed

CONTRIBUTING.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,6 @@ This allows for the following mapping from a URL to a method chain:
104104

105105
`/api_client/{api_key_id}/version` maps to `client.api_client._(api_key_id).version.<method>()` where <method> is a [HTTP verb](https://github.com/sendgrid/ruby-http-client/blob/master/lib/ruby_http_client.rb#L38).
106106

107-
**congfig.rb**
108-
109-
Loads the environment variables.
110-
111107
<a name="testing"></a>
112108
## Testing
113109

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Following is an abridged example, here is the [full working code](https://github
4848
```ruby
4949
require ruby_http_client
5050

51-
Config.new
51+
SendGrid::Config.new
5252
headers = JSON.parse('
5353
{
5454
"Authorization": "Bearer ' + ENV['SENDGRID_API_KEY'] + '",

examples/example.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
require_relative '../lib/config'
21
require_relative '../lib/ruby_http_client'
32

4-
Config.new
3+
SendGrid::Config.new
54
headers = JSON.parse('
65
{
76
"Authorization": "Bearer ' + ENV['SENDGRID_API_KEY'] + '",

lib/config.rb

Lines changed: 0 additions & 10 deletions
This file was deleted.

lib/ruby_http_client.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ module SendGrid
44
require 'net/http'
55
require 'net/https'
66

7+
# Loads environment variables from a .env file.
8+
class Config
9+
def initialize
10+
File.open('./.env').readlines.each do |line|
11+
key, value = line.split '='
12+
ENV[key] = value.chomp
13+
end
14+
ENV
15+
end
16+
end
17+
718
# Holds the response from an API call.
819
class Response
920
# * *Args* :

ruby_http_client.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
44

55
Gem::Specification.new do |spec|
66
spec.name = 'ruby_http_client'
7-
spec.version = '1.0.0'
7+
spec.version = '1.1.0'
88
spec.authors = ['Elmer Thomas']
99
spec.email = '[email protected]'
1010
spec.summary = 'A simple REST client'

0 commit comments

Comments
 (0)