ruby_http_client 3.0.1 → 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/CONTRIBUTING.md +5 -5
- data/lib/ruby_http_client.rb +10 -21
- data/ruby_http_client.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 915aca3c1ef2db0465b051e7a30aa8af13918469
|
4
|
+
data.tar.gz: 3a296aa133c66dd033b7be2b4483b0a3e085c242
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8e6f3b4c8c1c32d56fd0ed8dc7f845d5bb6ddd232305b532642a6340fe6fce102ddfa11687af5ac1cb8541ecb1ef0d6954e7583143b5dbaf39571dba68d0c74
|
7
|
+
data.tar.gz: 67b7f3b7d8db5bc929e566c0296e8f9297a9d8f921cdc916f0e755b5fe22eaaf9987d48b5618ccb6054d7f58c28e419328604db8fc5a65bd92575f3b163cd0e3
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,11 @@ All notable changes to this project will be documented in this file.
|
|
3
3
|
|
4
4
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
5
5
|
|
6
|
+
## [3.0.2] - 2016-04-10
|
7
|
+
### Update
|
8
|
+
- #8 Internal refactor
|
9
|
+
- Thanks to [ciamiz](https://github.com/ciamiz) for the pull request!
|
10
|
+
|
6
11
|
## [3.0.1] - 2016-01-25
|
7
12
|
### Fix
|
8
13
|
- [Pull Request #7](https://github.com/sendgrid/ruby-http-client/pull/7)
|
data/CONTRIBUTING.md
CHANGED
@@ -16,13 +16,13 @@ We use [Milestones](https://github.com/sendgrid/ruby-http-client/milestones) to
|
|
16
16
|
<a name="cla"></a>
|
17
17
|
## CLAs and CCLAs
|
18
18
|
|
19
|
-
Before you get started, SendGrid requires that a SendGrid Contributor License Agreement (CLA)
|
19
|
+
Before you get started, SendGrid requires that a SendGrid Contributor License Agreement (CLA) be filled out by every contributor to a SendGrid open source project.
|
20
20
|
|
21
|
-
Our goal with the CLA
|
21
|
+
Our goal with the CLA is to clarify the rights of our contributors and reduce other risks arising from inappropriate contributions. The CLA also clarifies the rights SendGrid holds in each contribution and helps to avoid misunderstandings over what rights each contributor is required to grant to SendGrid when making a contribution. In this way the CLA encourages broad participation by our open source community and helps us build strong open source projects, free from any individual contributor withholding or revoking rights to any contribution.
|
22
22
|
|
23
|
-
SendGrid does not merge a pull request made against a SendGrid open source project until that pull request is associated with a signed CLA
|
23
|
+
SendGrid does not merge a pull request made against a SendGrid open source project until that pull request is associated with a signed CLA. Copies of the CLA are available [here](https://gist.github.com/SendGridDX/98b42c0a5d500058357b80278fde3be8#file-sendgrid_cla).
|
24
24
|
|
25
|
-
|
25
|
+
When you create a Pull Request, after a few seconds, a comment will appear with a link to the CLA. Click the link and fill out the brief form and then click the "I agree" button and you are all set. You will not be asked to re-sign the CLA unless we make a change.
|
26
26
|
|
27
27
|
There are a few ways to contribute, which we'll enumerate below:
|
28
28
|
|
@@ -191,4 +191,4 @@ Please run your code through:
|
|
191
191
|
7. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/)
|
192
192
|
with a clear title and description against the `master` branch. All tests must be passing before we will review the PR.
|
193
193
|
|
194
|
-
If you have any additional questions, please feel free to [email](mailto:dx@sendgrid.com) us or create an issue in this repo.
|
194
|
+
If you have any additional questions, please feel free to [email](mailto:dx@sendgrid.com) us or create an issue in this repo.
|
data/lib/ruby_http_client.rb
CHANGED
@@ -32,9 +32,9 @@ module SendGrid
|
|
32
32
|
#
|
33
33
|
def initialize(host: nil, request_headers: nil, version: nil, url_path: nil)
|
34
34
|
@host = host
|
35
|
-
@request_headers = request_headers
|
35
|
+
@request_headers = request_headers || {}
|
36
36
|
@version = version
|
37
|
-
@url_path = url_path
|
37
|
+
@url_path = url_path || []
|
38
38
|
@methods = %w(delete get patch post put)
|
39
39
|
@query_params = nil
|
40
40
|
@request_body = nil
|
@@ -46,7 +46,7 @@ module SendGrid
|
|
46
46
|
# - +request_headers+ -> Hash of request header key/values
|
47
47
|
#
|
48
48
|
def update_headers(request_headers)
|
49
|
-
@request_headers
|
49
|
+
@request_headers.merge!(request_headers)
|
50
50
|
end
|
51
51
|
|
52
52
|
# Build the final request headers
|
@@ -70,9 +70,9 @@ module SendGrid
|
|
70
70
|
# * *Returns* :
|
71
71
|
# - The url string with the version pre-pended
|
72
72
|
#
|
73
|
-
def add_version(url)
|
74
|
-
|
75
|
-
url
|
73
|
+
def add_version(url = nil)
|
74
|
+
path = @version ? "/#{@version}" : ''
|
75
|
+
url.concat(path)
|
76
76
|
end
|
77
77
|
|
78
78
|
# Add query parameters to the url
|
@@ -84,14 +84,8 @@ module SendGrid
|
|
84
84
|
# - The url string with the query parameters appended
|
85
85
|
#
|
86
86
|
def build_query_params(url, query_params)
|
87
|
-
|
88
|
-
|
89
|
-
query_params.each do |key, value|
|
90
|
-
url.concat('&') if count > 0
|
91
|
-
url.concat("#{key}=#{value}")
|
92
|
-
count += 1
|
93
|
-
end
|
94
|
-
url
|
87
|
+
params = query_params.map { |key, value| "#{key}=#{value}" }.join('&')
|
88
|
+
url.concat("?#{params}")
|
95
89
|
end
|
96
90
|
|
97
91
|
# Set the query params, request headers and request body
|
@@ -122,11 +116,7 @@ module SendGrid
|
|
122
116
|
# - The final url string
|
123
117
|
#
|
124
118
|
def build_url(query_params: nil)
|
125
|
-
url = ''
|
126
|
-
url = add_version(url) if @version
|
127
|
-
@url_path.each do |x|
|
128
|
-
url.concat("/#{x}")
|
129
|
-
end
|
119
|
+
url = [add_version(''), *@url_path].join('/')
|
130
120
|
url = build_query_params(url, query_params) if query_params
|
131
121
|
URI.parse("#{@host}#{url}")
|
132
122
|
end
|
@@ -178,8 +168,7 @@ module SendGrid
|
|
178
168
|
# - HTTP::NET object
|
179
169
|
#
|
180
170
|
def add_ssl(http)
|
181
|
-
|
182
|
-
if protocol == 'https'
|
171
|
+
if host.start_with?('https')
|
183
172
|
http.use_ssl = true
|
184
173
|
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
185
174
|
end
|
data/ruby_http_client.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = 'ruby_http_client'
|
7
|
-
spec.version = '3.0.
|
7
|
+
spec.version = '3.0.2'
|
8
8
|
spec.authors = ['Elmer Thomas']
|
9
9
|
spec.email = 'dx@sendgrid.com'
|
10
10
|
spec.summary = 'A simple REST client'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_http_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elmer Thomas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -62,7 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
62
62
|
version: '0'
|
63
63
|
requirements: []
|
64
64
|
rubyforge_project:
|
65
|
-
rubygems_version: 2.
|
65
|
+
rubygems_version: 2.6.10
|
66
66
|
signing_key:
|
67
67
|
specification_version: 4
|
68
68
|
summary: A simple REST client
|