http_wrapper 3.0.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +19 -16
- data/Rakefile +4 -1
- data/lib/http_wrapper/request.rb +1 -1
- data/lib/http_wrapper/version.rb +1 -1
- data/spec/http_wrapper_spec.rb +1 -1
- metadata +28 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f43f24bf357f46eae6cd156c3286e1793c02bccb18cbe348fc9abd2c7ddfa8c8
|
4
|
+
data.tar.gz: 94394a79f926ef8612eb75be5eba1010bb4f84e433f2c9718d6f39796e6c347b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb72bc3f5b5f9646127f3b1c33e8315a2e0ffdab80cb708f645f82581ec13adbc298f128e0dedd4755a604f55483e372cdabf71b124bcacda7c9dd06f3a8954e
|
7
|
+
data.tar.gz: 12288e5e5cecd47aeb7159e624660988c3604d5f6e214ed5f2d20f0affb9d93ed1ce3fc2293aa9fd52d0148eaed2cd216bf22a04bc4a62cd5b05ac544925ad37
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## v4.0.0
|
4
|
+
|
5
|
+
* dropped support for Ruby 2.3 and 2.4
|
6
|
+
* added Ruby 2.7 to the TravisCI config
|
7
|
+
* rubocop-performance gem added
|
8
|
+
* rubocop rake task added to the default rake task
|
9
|
+
* all development dependencies updated
|
10
|
+
|
3
11
|
## v3.0.0
|
4
12
|
|
5
13
|
* dropped support for Ruby 1.9-2.2 and Rubinius
|
data/README.md
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
# http_wrapper
|
2
2
|
|
3
|
-
Simple wrapper around standard Net::HTTP library
|
4
|
-
|
5
3
|
[](https://badge.fury.io/rb/http_wrapper)
|
6
4
|
[](https://travis-ci.org/svyatov/http_wrapper)
|
5
|
+
[](https://depfu.com/github/svyatov/http_wrapper?project_id=6879)
|
7
6
|
[](https://codeclimate.com/github/svyatov/http_wrapper/maintainability)
|
8
7
|
[](https://codeclimate.com/github/svyatov/http_wrapper/test_coverage)
|
9
8
|
|
9
|
+
A simple wrapper around standard Ruby Net::HTTP library.
|
10
|
+
|
11
|
+
If you need something more fully-featured you should use absolutely awesome [HTTP](https://github.com/httprb/http) gem. ([Why?](https://twin.github.io/httprb-is-great/))
|
12
|
+
|
10
13
|
---
|
11
14
|
|
12
15
|
## Installation
|
@@ -14,7 +17,7 @@ Simple wrapper around standard Net::HTTP library
|
|
14
17
|
Add this line to your Gemfile:
|
15
18
|
|
16
19
|
```ruby
|
17
|
-
gem 'http_wrapper', '~>
|
20
|
+
gem 'http_wrapper', '~> 4.0'
|
18
21
|
```
|
19
22
|
|
20
23
|
And then execute:
|
@@ -94,9 +97,9 @@ Add special header or use special method:
|
|
94
97
|
```ruby
|
95
98
|
response = http.get_ajax some_url
|
96
99
|
# - or -
|
97
|
-
response = http.get some_url, headers: {x_requested_with: 'XMLHttpRequest'}
|
100
|
+
response = http.get some_url, headers: { x_requested_with: 'XMLHttpRequest' }
|
98
101
|
# - or -
|
99
|
-
response = http.get some_url, headers: {'X-Requested-With' => 'XMLHttpRequest'}
|
102
|
+
response = http.get some_url, headers: { 'X-Requested-With' => 'XMLHttpRequest' }
|
100
103
|
```
|
101
104
|
|
102
105
|
### Access JSON resource
|
@@ -108,9 +111,9 @@ response = http.get_json some_url
|
|
108
111
|
# - or -
|
109
112
|
response = http.get some_url, content_type: 'application/json; charset=UTF-8'
|
110
113
|
# - or -
|
111
|
-
response = http.get some_url, headers: {content_type: 'application/json; charset=UTF-8'}
|
114
|
+
response = http.get some_url, headers: { content_type: 'application/json; charset=UTF-8' }
|
112
115
|
# - or -
|
113
|
-
response = http.get some_url, headers: {'Content-Type' => 'application/json; charset=UTF-8'}
|
116
|
+
response = http.get some_url, headers: { 'Content-Type' => 'application/json; charset=UTF-8' }
|
114
117
|
```
|
115
118
|
|
116
119
|
### Access JSON resource mimicing AJAX
|
@@ -134,14 +137,14 @@ response = http.get_json_ajax some_url, some_params
|
|
134
137
|
Don't worry about escaping, `http_wrapper` got you covered here either.
|
135
138
|
|
136
139
|
```ruby
|
137
|
-
response = http.get 'http://www.google.com', query: {message: 'Hi! M&Ms!', user: 'iamjohn'}
|
140
|
+
response = http.get 'http://www.google.com', query: { message: 'Hi! M&Ms!', user: 'iamjohn' }
|
138
141
|
# => http://www.google.com/?message=Hi!%20M%26Ms!&user=iamjohn
|
139
142
|
```
|
140
143
|
|
141
144
|
Don't worry about parameters that already in URL, they'll be merged.
|
142
145
|
|
143
146
|
```ruby
|
144
|
-
response = http.get 'http://www.google.com/?q=test', query: {user: 'iamjohn'}
|
147
|
+
response = http.get 'http://www.google.com/?q=test', query: { user: 'iamjohn' }
|
145
148
|
# => http://www.google.com/?q=test&user=iamjohn
|
146
149
|
```
|
147
150
|
|
@@ -153,8 +156,8 @@ You can easily upload any number of files with `multipart/form-data` content typ
|
|
153
156
|
http = HTTPWrapper.new
|
154
157
|
params = {
|
155
158
|
multipart: [
|
156
|
-
# ['file input field name', 'File instance or string', {filename: 'itsfile.jpg', content_type: '...'}]
|
157
|
-
['user_photo', File.read('user_photo.jpg'), {filename: 'photo.jpg'}],
|
159
|
+
# ['file input field name', 'File instance or string', { filename: 'itsfile.jpg', content_type: '...' }]
|
160
|
+
['user_photo', File.read('user_photo.jpg'), { filename: 'photo.jpg' }],
|
158
161
|
# last element is optional
|
159
162
|
['user_pic', File.open('user_pic.jpg')],
|
160
163
|
# you can also specify other parameters
|
@@ -208,11 +211,11 @@ http = HTTPWrapper.new verify_cert: false
|
|
208
211
|
On each `get` method there are `post`, `put` and `delete` methods. Examples:
|
209
212
|
|
210
213
|
```ruby
|
211
|
-
http.post some_url, body: {user: 'iamjohn', password: 'secret'}
|
214
|
+
http.post some_url, body: { user: 'iamjohn', password: 'secret' }
|
212
215
|
# - or -
|
213
|
-
http.put some_url, body: {user: 'iamjohn', password: 'secret'}
|
216
|
+
http.put some_url, body: { user: 'iamjohn', password: 'secret' }
|
214
217
|
# - or -
|
215
|
-
http.delete some_url, query: {user: 'iamjohn'}
|
218
|
+
http.delete some_url, query: { user: 'iamjohn' }
|
216
219
|
```
|
217
220
|
|
218
221
|
Default content type header for these requests is `application/x-www-form-urlencoded; charset=UTF-8`.
|
@@ -298,9 +301,9 @@ http.execute request, uri
|
|
298
301
|
# you can use File object
|
299
302
|
['file_input_name', File.open('somefile.ext')],
|
300
303
|
# - or - string and specify filename
|
301
|
-
['file_input_name', File.read('somefile.ext'), {filename: 'readme.txt'}],
|
304
|
+
['file_input_name', File.read('somefile.ext'), { filename: 'readme.txt' }],
|
302
305
|
# - or - full format
|
303
|
-
['file_input_name', 'some file content', {filename: 'readme.txt', content_type: 'text/text'}],
|
306
|
+
['file_input_name', 'some file content', { filename: 'readme.txt', content_type: 'text/text' }],
|
304
307
|
# - or - add other simple parameters
|
305
308
|
['user_name', 'john smith']
|
306
309
|
]
|
data/Rakefile
CHANGED
data/lib/http_wrapper/request.rb
CHANGED
data/lib/http_wrapper/version.rb
CHANGED
data/spec/http_wrapper_spec.rb
CHANGED
@@ -65,7 +65,7 @@ RSpec.describe HTTPWrapper do
|
|
65
65
|
WebMock.allow_net_connect!
|
66
66
|
begin
|
67
67
|
http.get 'localhost'
|
68
|
-
rescue StandardError # rubocop:disable Lint/
|
68
|
+
rescue StandardError # rubocop:disable Lint/SuppressedException
|
69
69
|
# NOOP, rescue from "connection refused" and such
|
70
70
|
end
|
71
71
|
WebMock.disable_net_connect!
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: http_wrapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leonid Svyatov
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-03-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -45,70 +45,84 @@ dependencies:
|
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '3.
|
48
|
+
version: '3.9'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: '3.
|
55
|
+
version: '3.9'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: rubocop
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
60
|
- - "~>"
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: 0.
|
62
|
+
version: '0.80'
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: 0.
|
69
|
+
version: '0.80'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rubocop-performance
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '1.5'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '1.5'
|
70
84
|
- !ruby/object:Gem::Dependency
|
71
85
|
name: rubocop-rspec
|
72
86
|
requirement: !ruby/object:Gem::Requirement
|
73
87
|
requirements:
|
74
88
|
- - "~>"
|
75
89
|
- !ruby/object:Gem::Version
|
76
|
-
version: '1.
|
90
|
+
version: '1.38'
|
77
91
|
type: :development
|
78
92
|
prerelease: false
|
79
93
|
version_requirements: !ruby/object:Gem::Requirement
|
80
94
|
requirements:
|
81
95
|
- - "~>"
|
82
96
|
- !ruby/object:Gem::Version
|
83
|
-
version: '1.
|
97
|
+
version: '1.38'
|
84
98
|
- !ruby/object:Gem::Dependency
|
85
99
|
name: simplecov
|
86
100
|
requirement: !ruby/object:Gem::Requirement
|
87
101
|
requirements:
|
88
102
|
- - "~>"
|
89
103
|
- !ruby/object:Gem::Version
|
90
|
-
version: 0.
|
104
|
+
version: '0.18'
|
91
105
|
type: :development
|
92
106
|
prerelease: false
|
93
107
|
version_requirements: !ruby/object:Gem::Requirement
|
94
108
|
requirements:
|
95
109
|
- - "~>"
|
96
110
|
- !ruby/object:Gem::Version
|
97
|
-
version: 0.
|
111
|
+
version: '0.18'
|
98
112
|
- !ruby/object:Gem::Dependency
|
99
113
|
name: webmock
|
100
114
|
requirement: !ruby/object:Gem::Requirement
|
101
115
|
requirements:
|
102
116
|
- - "~>"
|
103
117
|
- !ruby/object:Gem::Version
|
104
|
-
version: '3.
|
118
|
+
version: '3.8'
|
105
119
|
type: :development
|
106
120
|
prerelease: false
|
107
121
|
version_requirements: !ruby/object:Gem::Requirement
|
108
122
|
requirements:
|
109
123
|
- - "~>"
|
110
124
|
- !ruby/object:Gem::Version
|
111
|
-
version: '3.
|
125
|
+
version: '3.8'
|
112
126
|
description: Simple wrapper around standard Net::HTTP library with multipart/form-data
|
113
127
|
file upload ability
|
114
128
|
email: leonid@svyatov.ru
|
@@ -142,14 +156,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
142
156
|
requirements:
|
143
157
|
- - ">="
|
144
158
|
- !ruby/object:Gem::Version
|
145
|
-
version: 2.
|
159
|
+
version: 2.5.0
|
146
160
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
161
|
requirements:
|
148
162
|
- - ">="
|
149
163
|
- !ruby/object:Gem::Version
|
150
164
|
version: '0'
|
151
165
|
requirements: []
|
152
|
-
rubygems_version: 3.
|
166
|
+
rubygems_version: 3.1.2
|
153
167
|
signing_key:
|
154
168
|
specification_version: 4
|
155
169
|
summary: Simple wrapper around standard Net::HTTP library
|