simple_request 0.1.4 → 0.1.5
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/.rubocop.yml +34 -12
- data/Changelog.md +15 -1
- data/Gemfile +11 -1
- data/Gemfile.lock +56 -51
- data/README.md +9 -9
- data/lib/simple_helper/request.rb +24 -7
- data/lib/simple_helper/response_parser.rb +12 -4
- data/lib/simple_helper/version.rb +1 -1
- data/lib/simple_request.rb +35 -17
- data/simple_request.gemspec +14 -22
- metadata +10 -127
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2acd008e5817c9ccc1c75fbbd595c4b34a538a0ebf7541ffa54318b5a2e0bedf
|
|
4
|
+
data.tar.gz: dab64766f17b83c2533384667b572cbfa07eb3141e9faf9165bb9f60a97b8f7e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2d695885ec2b8ecfde881ca13bb32e5d614a4f77cbb36ff8bc1b6b94bd24c7382dfcc83790c912ea7bcfc6b6fb24d8dcdf4ff26173dde7cdfdb4ded450e87440
|
|
7
|
+
data.tar.gz: 31ad5b05e73a1ace906d7d6e4dae1d8182d7a920b329957415a5b40a6162c4a6680e0820c50ab688fba86b9452523c92050bdbf4889b0955100c9030ac18fb56
|
data/.rubocop.yml
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
inherit_from: .rubocop_todo.yml
|
|
1
|
+
# inherit_from: .rubocop_todo.yml
|
|
2
2
|
|
|
3
3
|
require: rubocop-performance
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
Documentation:
|
|
13
|
-
Enabled: false
|
|
5
|
+
AllCops:
|
|
6
|
+
TargetRubyVersion: 3.2.3
|
|
7
|
+
Exclude:
|
|
8
|
+
- bin/**
|
|
9
|
+
- db/**/*
|
|
10
|
+
- node_modules/**/*
|
|
14
11
|
|
|
15
12
|
Style/Documentation:
|
|
16
13
|
Enabled: false
|
|
@@ -24,14 +21,14 @@ Lint/Void:
|
|
|
24
21
|
Metrics/AbcSize:
|
|
25
22
|
Max: 30
|
|
26
23
|
|
|
27
|
-
|
|
24
|
+
Layout/LineLength:
|
|
28
25
|
Max: 120
|
|
29
26
|
|
|
30
27
|
Metrics/ClassLength:
|
|
31
28
|
Max: 1500
|
|
32
29
|
|
|
33
30
|
Metrics/MethodLength:
|
|
34
|
-
Max:
|
|
31
|
+
Max: 10
|
|
35
32
|
|
|
36
33
|
Metrics/BlockLength:
|
|
37
34
|
Max: 70
|
|
@@ -39,3 +36,28 @@ Metrics/BlockLength:
|
|
|
39
36
|
Layout/HashAlignment:
|
|
40
37
|
EnforcedHashRocketStyle: table
|
|
41
38
|
EnforcedColonStyle: table
|
|
39
|
+
|
|
40
|
+
Gemspec/DeprecatedAttributeAssignment:
|
|
41
|
+
Enabled: true
|
|
42
|
+
Gemspec/DevelopmentDependencies:
|
|
43
|
+
Enabled: true
|
|
44
|
+
Gemspec/RequireMFA:
|
|
45
|
+
Enabled: true
|
|
46
|
+
Layout/LineContinuationLeadingSpace:
|
|
47
|
+
Enabled: true
|
|
48
|
+
Layout/LineContinuationSpacing:
|
|
49
|
+
Enabled: true
|
|
50
|
+
Layout/LineEndStringConcatenationIndentation:
|
|
51
|
+
Enabled: true
|
|
52
|
+
Layout/SpaceBeforeBrackets:
|
|
53
|
+
Enabled: true
|
|
54
|
+
Lint/AmbiguousAssignment:
|
|
55
|
+
Enabled: true
|
|
56
|
+
Lint/AmbiguousOperatorPrecedence:
|
|
57
|
+
Enabled: true
|
|
58
|
+
Lint/AmbiguousRange:
|
|
59
|
+
Enabled: true
|
|
60
|
+
Lint/ConstantOverwrittenInRescue:
|
|
61
|
+
Enabled: true
|
|
62
|
+
Lint/DeprecatedConstants:
|
|
63
|
+
Enabled: true
|
data/Changelog.md
CHANGED
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
# Changeslog
|
|
2
2
|
|
|
3
3
|
## 2020-02-04
|
|
4
|
+
|
|
4
5
|
- Changed rspec examples from localhost project to JSONPlaceholder API
|
|
5
6
|
- Added `to_csv` in array class to convert array to csv
|
|
6
7
|
- Added `wrap` in array class to convert hash or nill to an array (Powered by rails core repo)
|
|
7
8
|
- Added `keys` in hash class to symbolize and stringify hash keys
|
|
8
9
|
- Added `string_colorize` in String class to colorize any string
|
|
9
|
-
- Supported csv format you can export the response to csv by `request.csv`
|
|
10
|
+
- Supported csv format you can export the response to csv by `request.csv`
|
|
11
|
+
|
|
12
|
+
## 2024-02-04
|
|
13
|
+
|
|
14
|
+
- Upgraded dependencies
|
|
15
|
+
|
|
16
|
+
1. bundler from `~> 2.0` to `~> 2.5", ">= 2.5.4`
|
|
17
|
+
2. rake from `~> 13.0` to `~> 13.1`
|
|
18
|
+
3. byebug from `11.1.3` to `11.1.3`
|
|
19
|
+
4. rspec from to `3.0` to `3.12`
|
|
20
|
+
5. rubocop from `0.93.1` to `1.60`
|
|
21
|
+
6. rubocop-performance from `1.8.1` to `1.20.2`
|
|
22
|
+
7. vcr from `5.0.0` to `6.2`
|
|
23
|
+
8. webmock from `3.6.2` to `3.19.1`
|
data/Gemfile
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
|
-
source
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
2
|
|
|
3
3
|
# Specify your gem's dependencies in simple_request.gemspec
|
|
4
4
|
gemspec
|
|
5
5
|
|
|
6
|
+
group :development do
|
|
7
|
+
gem 'bundler', '~> 2.5', '>= 2.5.4'
|
|
8
|
+
gem 'byebug', '~> 11.1.3'
|
|
9
|
+
gem 'rake', '~> 13.1'
|
|
10
|
+
gem 'rspec', '~> 3.12'
|
|
11
|
+
gem 'rubocop', '~> 1.60', '>= 1.60.1'
|
|
12
|
+
gem 'rubocop-performance', '~> 1.20', '>= 1.20.2'
|
|
13
|
+
gem 'vcr', '~> 6.2'
|
|
14
|
+
gem 'webmock', '~> 3.19', '>= 3.19.1'
|
|
15
|
+
end
|
data/Gemfile.lock
CHANGED
|
@@ -1,60 +1,65 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
simple_request (0.1.
|
|
4
|
+
simple_request (0.1.5)
|
|
5
5
|
|
|
6
6
|
GEM
|
|
7
7
|
remote: https://rubygems.org/
|
|
8
8
|
specs:
|
|
9
|
-
addressable (2.
|
|
10
|
-
public_suffix (>= 2.0.2, <
|
|
11
|
-
ast (2.4.
|
|
9
|
+
addressable (2.8.6)
|
|
10
|
+
public_suffix (>= 2.0.2, < 6.0)
|
|
11
|
+
ast (2.4.2)
|
|
12
12
|
byebug (11.1.3)
|
|
13
|
-
crack (0.4.
|
|
14
|
-
|
|
15
|
-
diff-lcs (1.
|
|
16
|
-
hashdiff (1.0
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
crack (0.4.5)
|
|
14
|
+
rexml
|
|
15
|
+
diff-lcs (1.5.0)
|
|
16
|
+
hashdiff (1.1.0)
|
|
17
|
+
json (2.7.1)
|
|
18
|
+
language_server-protocol (3.17.0.3)
|
|
19
|
+
parallel (1.24.0)
|
|
20
|
+
parser (3.3.0.4)
|
|
19
21
|
ast (~> 2.4.1)
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
rspec-
|
|
29
|
-
|
|
30
|
-
rspec-
|
|
31
|
-
rspec-
|
|
22
|
+
racc
|
|
23
|
+
public_suffix (5.0.4)
|
|
24
|
+
racc (1.7.3)
|
|
25
|
+
rainbow (3.1.1)
|
|
26
|
+
rake (13.1.0)
|
|
27
|
+
regexp_parser (2.9.0)
|
|
28
|
+
rexml (3.2.6)
|
|
29
|
+
rspec (3.12.0)
|
|
30
|
+
rspec-core (~> 3.12.0)
|
|
31
|
+
rspec-expectations (~> 3.12.0)
|
|
32
|
+
rspec-mocks (~> 3.12.0)
|
|
33
|
+
rspec-core (3.12.2)
|
|
34
|
+
rspec-support (~> 3.12.0)
|
|
35
|
+
rspec-expectations (3.12.3)
|
|
32
36
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
33
|
-
rspec-support (~> 3.
|
|
34
|
-
rspec-mocks (3.
|
|
37
|
+
rspec-support (~> 3.12.0)
|
|
38
|
+
rspec-mocks (3.12.6)
|
|
35
39
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
36
|
-
rspec-support (~> 3.
|
|
37
|
-
rspec-support (3.
|
|
38
|
-
rubocop (
|
|
40
|
+
rspec-support (~> 3.12.0)
|
|
41
|
+
rspec-support (3.12.1)
|
|
42
|
+
rubocop (1.60.1)
|
|
43
|
+
json (~> 2.3)
|
|
44
|
+
language_server-protocol (>= 3.17.0)
|
|
39
45
|
parallel (~> 1.10)
|
|
40
|
-
parser (>=
|
|
46
|
+
parser (>= 3.3.0.2)
|
|
41
47
|
rainbow (>= 2.2.2, < 4.0)
|
|
42
|
-
regexp_parser (>= 1.8)
|
|
43
|
-
rexml
|
|
44
|
-
rubocop-ast (>=
|
|
48
|
+
regexp_parser (>= 1.8, < 3.0)
|
|
49
|
+
rexml (>= 3.2.5, < 4.0)
|
|
50
|
+
rubocop-ast (>= 1.30.0, < 2.0)
|
|
45
51
|
ruby-progressbar (~> 1.7)
|
|
46
|
-
unicode-display_width (>=
|
|
47
|
-
rubocop-ast (
|
|
48
|
-
parser (>= 2.
|
|
49
|
-
rubocop-performance (1.
|
|
50
|
-
rubocop (>=
|
|
51
|
-
rubocop-ast (>=
|
|
52
|
-
ruby-progressbar (1.
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
addressable (>= 2.3.6)
|
|
52
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
|
53
|
+
rubocop-ast (1.30.0)
|
|
54
|
+
parser (>= 3.2.1.0)
|
|
55
|
+
rubocop-performance (1.20.2)
|
|
56
|
+
rubocop (>= 1.48.1, < 2.0)
|
|
57
|
+
rubocop-ast (>= 1.30.0, < 2.0)
|
|
58
|
+
ruby-progressbar (1.13.0)
|
|
59
|
+
unicode-display_width (2.5.0)
|
|
60
|
+
vcr (6.2.0)
|
|
61
|
+
webmock (3.19.1)
|
|
62
|
+
addressable (>= 2.8.0)
|
|
58
63
|
crack (>= 0.3.2)
|
|
59
64
|
hashdiff (>= 0.4.0, < 2.0.0)
|
|
60
65
|
|
|
@@ -62,15 +67,15 @@ PLATFORMS
|
|
|
62
67
|
ruby
|
|
63
68
|
|
|
64
69
|
DEPENDENCIES
|
|
65
|
-
bundler (~> 2.
|
|
70
|
+
bundler (~> 2.5, >= 2.5.4)
|
|
66
71
|
byebug (~> 11.1.3)
|
|
67
|
-
rake (~> 13.
|
|
68
|
-
rspec (~> 3.
|
|
69
|
-
rubocop (~>
|
|
70
|
-
rubocop-performance (~> 1.
|
|
72
|
+
rake (~> 13.1)
|
|
73
|
+
rspec (~> 3.12)
|
|
74
|
+
rubocop (~> 1.60, >= 1.60.1)
|
|
75
|
+
rubocop-performance (~> 1.20, >= 1.20.2)
|
|
71
76
|
simple_request!
|
|
72
|
-
vcr (~>
|
|
73
|
-
webmock (~> 3.
|
|
77
|
+
vcr (~> 6.2)
|
|
78
|
+
webmock (~> 3.19, >= 3.19.1)
|
|
74
79
|
|
|
75
80
|
BUNDLED WITH
|
|
76
|
-
2.
|
|
81
|
+
2.5.4
|
data/README.md
CHANGED
|
@@ -24,15 +24,17 @@
|
|
|
24
24
|
Add this line to your application's Gemfile:
|
|
25
25
|
|
|
26
26
|
```ruby
|
|
27
|
-
gem 'simple_request', '~> 0.1.
|
|
27
|
+
gem 'simple_request', '~> 0.1.4'
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
Then bundle it
|
|
31
|
+
|
|
31
32
|
```powershell
|
|
32
33
|
$ bundle
|
|
33
34
|
```
|
|
34
35
|
|
|
35
36
|
Install it independently:
|
|
37
|
+
|
|
36
38
|
```powershell
|
|
37
39
|
$ gem install simple_request
|
|
38
40
|
```
|
|
@@ -40,6 +42,7 @@ $ gem install simple_request
|
|
|
40
42
|
## Usage
|
|
41
43
|
|
|
42
44
|
#### GET Request
|
|
45
|
+
|
|
43
46
|
```ruby
|
|
44
47
|
request = SimpleRequest.get(url: 'https://api.xxxxx.xxxxxx.com/v1/cities', body: {}, headers: {'API-ACCESSOR' => 'xxxxxxx-xxxxx-xxxx-xxxx-x'})
|
|
45
48
|
request.json
|
|
@@ -118,18 +121,15 @@ request.plain
|
|
|
118
121
|
|
|
119
122
|
#### DELETE Request
|
|
120
123
|
```ruby
|
|
121
|
-
request =
|
|
124
|
+
request =
|
|
125
|
+
SimpleRequest.delete(
|
|
122
126
|
url: 'https://api.xxxxx.xxxxxx.com/v1/cities/10',
|
|
123
127
|
body: {},
|
|
124
|
-
headers: {
|
|
125
|
-
)
|
|
128
|
+
headers: { 'Authorization' => 'Bearer xxxxxxxxxxxx.xxxxxxxx.xxxxxxxx' }
|
|
129
|
+
)
|
|
126
130
|
|
|
127
131
|
request.json
|
|
128
|
-
# OUTPUT
|
|
129
|
-
# {"message"=>"City deleted successfully", "id"=>10}
|
|
130
|
-
request.plain
|
|
131
|
-
# OUTPUT
|
|
132
|
-
# "{\"message\":\"City deleted successfully\",\"id\":10}"
|
|
132
|
+
request.plain # "{\"message\":\"City deleted successfully\",\"id\":10}" # OUTPUT
|
|
133
133
|
```
|
|
134
134
|
|
|
135
135
|
## Development
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
2
3
|
require 'uri'
|
|
3
4
|
require 'net/http'
|
|
4
5
|
require 'net/https'
|
|
@@ -18,17 +19,25 @@ module SimpleHelper
|
|
|
18
19
|
req.body = params.to_json
|
|
19
20
|
https.request(req)
|
|
20
21
|
rescue Timeout::Error || Net::OpenTimeout
|
|
21
|
-
|
|
22
|
+
error_handler(message: 'Time out')
|
|
22
23
|
rescue Net::HTTPBadResponse || SocketError
|
|
23
|
-
|
|
24
|
+
error_handler(message: 'Request Failed!')
|
|
24
25
|
rescue StandardError
|
|
25
|
-
|
|
26
|
+
error_handler(message: 'An unknown error occurred!')
|
|
26
27
|
end
|
|
27
28
|
end
|
|
29
|
+
|
|
30
|
+
def error_handler(message: nil)
|
|
31
|
+
{
|
|
32
|
+
"status": 400,
|
|
33
|
+
"error": 'Bad Request',
|
|
34
|
+
"message": message
|
|
35
|
+
}
|
|
36
|
+
end
|
|
28
37
|
end
|
|
29
38
|
end
|
|
30
39
|
|
|
31
|
-
|
|
40
|
+
module Http
|
|
32
41
|
class << self
|
|
33
42
|
SimpleHelper::Config.supported_methods.each do |key, http_method|
|
|
34
43
|
define_method key.to_s do |uri, params, headers|
|
|
@@ -37,13 +46,21 @@ module SimpleHelper
|
|
|
37
46
|
req.body = params.to_json
|
|
38
47
|
http.request(req)
|
|
39
48
|
rescue Timeout::Error || Net::OpenTimeout
|
|
40
|
-
|
|
49
|
+
error_handler(message: 'Time out')
|
|
41
50
|
rescue Net::HTTPBadResponse || SocketError
|
|
42
|
-
|
|
51
|
+
error_handler(message: 'Request Failed!')
|
|
43
52
|
rescue StandardError
|
|
44
|
-
|
|
53
|
+
error_handler(message: 'An unknown error occurred!')
|
|
45
54
|
end
|
|
46
55
|
end
|
|
56
|
+
|
|
57
|
+
def error_handler(message: nil)
|
|
58
|
+
{
|
|
59
|
+
"status": 400,
|
|
60
|
+
"error": 'Bad Request',
|
|
61
|
+
"message": message
|
|
62
|
+
}
|
|
63
|
+
end
|
|
47
64
|
end
|
|
48
65
|
end
|
|
49
66
|
end
|
|
@@ -19,9 +19,9 @@ module SimpleHelper
|
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
def parse
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
if body.nil? || body == 'null' || (body.valid_encoding? && body.strip.empty?)
|
|
23
|
+
return log(message: 'Invalid response')
|
|
24
|
+
end
|
|
25
25
|
|
|
26
26
|
@body = body.gsub(/\A#{UTF8_BOM}/, '') if body.valid_encoding? && body.encoding == Encoding::UTF_8
|
|
27
27
|
send(format)
|
|
@@ -36,7 +36,7 @@ module SimpleHelper
|
|
|
36
36
|
def json
|
|
37
37
|
JSON.parse(body, quirks_mode: true, allow_nan: true)
|
|
38
38
|
rescue JSON::ParserError
|
|
39
|
-
|
|
39
|
+
log(message: "Response cannot be parsed because it's not a string nor valid JSON. please use .plain to get the the plain response")
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
def plain
|
|
@@ -50,6 +50,14 @@ module SimpleHelper
|
|
|
50
50
|
Array.wrap(data).to_csv('file_name.csv')
|
|
51
51
|
end
|
|
52
52
|
|
|
53
|
+
def log(message: nil)
|
|
54
|
+
{
|
|
55
|
+
"status": 400,
|
|
56
|
+
"error": 'Bad Request',
|
|
57
|
+
"message": message
|
|
58
|
+
}
|
|
59
|
+
end
|
|
60
|
+
|
|
53
61
|
# def xml
|
|
54
62
|
# MultiXml.parse(body)
|
|
55
63
|
# end
|
data/lib/simple_request.rb
CHANGED
|
@@ -8,35 +8,50 @@ end
|
|
|
8
8
|
class SimpleRequest
|
|
9
9
|
attr_reader :options, :response
|
|
10
10
|
|
|
11
|
-
def initialize(
|
|
11
|
+
def initialize(options = {})
|
|
12
12
|
@options = options.symbolize_keys!
|
|
13
13
|
validate
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
#
|
|
16
|
+
# def self.get; end
|
|
17
|
+
# def self.post; end
|
|
18
|
+
# def self.patch; end
|
|
19
|
+
# def self.put; end
|
|
20
|
+
# def self.delete; end
|
|
17
21
|
class << self
|
|
18
|
-
SimpleHelper::Config.supported_methods.
|
|
22
|
+
SimpleHelper::Config.supported_methods.each_key do |method_name|
|
|
19
23
|
define_method method_name do |*args|
|
|
20
24
|
new(*args).send(method_name)
|
|
21
25
|
end
|
|
22
26
|
end
|
|
23
27
|
end
|
|
24
28
|
|
|
25
|
-
#
|
|
26
|
-
|
|
29
|
+
# def get; end,
|
|
30
|
+
# def post; end
|
|
31
|
+
# def patch; end
|
|
32
|
+
# def put; end
|
|
33
|
+
# def delete; end
|
|
34
|
+
SimpleHelper::Config.supported_methods.each_key do |method_name|
|
|
27
35
|
define_method method_name do
|
|
28
36
|
@response = requested_class.send(method_name, uri, body, headers_processor)
|
|
29
37
|
self
|
|
30
38
|
end
|
|
31
39
|
end
|
|
32
40
|
|
|
33
|
-
#
|
|
41
|
+
# def scheme; end
|
|
42
|
+
# def host; end
|
|
43
|
+
# def port; end
|
|
44
|
+
# def request_uri; end
|
|
45
|
+
# def path; end
|
|
46
|
+
# def query; end
|
|
34
47
|
SimpleHelper::Config.reference.each do |key|
|
|
35
48
|
define_method key do
|
|
36
49
|
uri.instance_eval(key)
|
|
37
50
|
end
|
|
38
51
|
end
|
|
39
52
|
|
|
53
|
+
# def json; end
|
|
54
|
+
# def plain; end
|
|
40
55
|
SimpleHelper::Config.supported_format.each do |key|
|
|
41
56
|
define_method key do
|
|
42
57
|
SimpleHelper::ResponseParser.perform(body_response, key, nil)
|
|
@@ -82,7 +97,7 @@ class SimpleRequest
|
|
|
82
97
|
end
|
|
83
98
|
|
|
84
99
|
def validate
|
|
85
|
-
# raise SimpleHelper::RedirectionTooDeep
|
|
100
|
+
# raise SimpleHelper::RedirectionTooDeep, 'HTTP redirects too deep' if options[:limit].to_i <= 0
|
|
86
101
|
|
|
87
102
|
# unless SimpleHelper::Config.supported_methods.include?(http_method)
|
|
88
103
|
# raise ArgumentError, 'only get, post, patch, put, and delete methods are supported'
|
|
@@ -90,20 +105,23 @@ class SimpleRequest
|
|
|
90
105
|
|
|
91
106
|
raise ArgumentError, ':headers must be a hash' unless headers.respond_to?(:to_hash)
|
|
92
107
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
108
|
+
# return if SimpleHelper::Config.supported_schemes.include? scheme
|
|
109
|
+
|
|
110
|
+
return if SimpleHelper::Config.supported_schemes.include? scheme
|
|
111
|
+
|
|
112
|
+
raise SimpleHelper::UnsupportedURIScheme, 'URL Must start with http:// or https://'
|
|
113
|
+
# raise ArgumentError, ':body must be a hash' if !body.nil? && !body.respond_to?(:to_hash)
|
|
96
114
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
115
|
+
# if options[:basic_auth] && !options[:basic_auth].respond_to?(:to_hash)
|
|
116
|
+
# raise ArgumentError, ':basic_auth must be a hash'
|
|
117
|
+
# end
|
|
100
118
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
119
|
+
# if options[:digest_auth] && !options[:digest_auth].respond_to?(:to_hash)
|
|
120
|
+
# raise ArgumentError, ':digest_auth must be a hash'
|
|
121
|
+
# end
|
|
104
122
|
|
|
105
123
|
# if post? && !options[:query].nil? && !options[:query].respond_to?(:to_hash)
|
|
106
124
|
# raise ArgumentError, ':query must be hash if using HTTP Post'
|
|
107
|
-
#
|
|
125
|
+
# end
|
|
108
126
|
end
|
|
109
127
|
end
|
data/simple_request.gemspec
CHANGED
|
@@ -1,38 +1,30 @@
|
|
|
1
|
-
lib = File.expand_path(
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
|
2
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
|
-
require
|
|
3
|
+
require 'simple_helper/version'
|
|
4
4
|
|
|
5
5
|
Gem::Specification.new do |spec|
|
|
6
|
-
spec.name =
|
|
6
|
+
spec.name = 'simple_request'
|
|
7
7
|
spec.version = SimpleHelper::VERSION
|
|
8
|
-
spec.authors = [
|
|
9
|
-
spec.email = [
|
|
8
|
+
spec.authors = ['MaJeD BoJaN']
|
|
9
|
+
spec.email = ['bojanmajed@gmail.com']
|
|
10
10
|
|
|
11
11
|
spec.summary = 'Simple ruby gem that helps to make HTTP and HTTPS request from ruby projects.'
|
|
12
|
-
spec.homepage =
|
|
13
|
-
spec.license =
|
|
12
|
+
spec.homepage = 'https://github.com/MajedBojan/simple_request'
|
|
13
|
+
spec.license = 'MIT'
|
|
14
14
|
|
|
15
15
|
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
|
16
16
|
|
|
17
|
-
spec.metadata[
|
|
18
|
-
spec.metadata[
|
|
19
|
-
spec.metadata[
|
|
17
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
|
18
|
+
spec.metadata['source_code_uri'] = 'https://github.com/MajedBojan/simple_request'
|
|
19
|
+
spec.metadata['changelog_uri'] = 'https://github.com/MajedBojan/simple_request/blob/main/Changelog.md'
|
|
20
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
|
20
21
|
|
|
21
22
|
# Specify which files should be added to the gem when it is released.
|
|
22
23
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
23
|
-
spec.files
|
|
24
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
24
25
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
25
26
|
end
|
|
26
|
-
spec.bindir =
|
|
27
|
+
spec.bindir = 'exe'
|
|
27
28
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
28
|
-
spec.require_paths = [
|
|
29
|
-
|
|
30
|
-
spec.add_development_dependency "bundler", "~> 2.0"
|
|
31
|
-
spec.add_development_dependency 'byebug', '~> 11.1.3'
|
|
32
|
-
spec.add_development_dependency "rake", "~> 13.0"
|
|
33
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
|
34
|
-
spec.add_development_dependency 'rubocop', '~> 0.93.1'
|
|
35
|
-
spec.add_development_dependency 'rubocop-performance', '~> 1.8', '>= 1.8.1'
|
|
36
|
-
spec.add_development_dependency 'vcr', '~> 5.0.0'
|
|
37
|
-
spec.add_development_dependency 'webmock', '~> 3.6.2'
|
|
29
|
+
spec.require_paths = ['lib']
|
|
38
30
|
end
|
metadata
CHANGED
|
@@ -1,134 +1,16 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: simple_request
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- MaJeD BoJaN
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
12
|
-
dependencies:
|
|
13
|
-
|
|
14
|
-
name: bundler
|
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
|
16
|
-
requirements:
|
|
17
|
-
- - "~>"
|
|
18
|
-
- !ruby/object:Gem::Version
|
|
19
|
-
version: '2.0'
|
|
20
|
-
type: :development
|
|
21
|
-
prerelease: false
|
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
-
requirements:
|
|
24
|
-
- - "~>"
|
|
25
|
-
- !ruby/object:Gem::Version
|
|
26
|
-
version: '2.0'
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: byebug
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - "~>"
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: 11.1.3
|
|
34
|
-
type: :development
|
|
35
|
-
prerelease: false
|
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
-
requirements:
|
|
38
|
-
- - "~>"
|
|
39
|
-
- !ruby/object:Gem::Version
|
|
40
|
-
version: 11.1.3
|
|
41
|
-
- !ruby/object:Gem::Dependency
|
|
42
|
-
name: rake
|
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
|
44
|
-
requirements:
|
|
45
|
-
- - "~>"
|
|
46
|
-
- !ruby/object:Gem::Version
|
|
47
|
-
version: '13.0'
|
|
48
|
-
type: :development
|
|
49
|
-
prerelease: false
|
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
-
requirements:
|
|
52
|
-
- - "~>"
|
|
53
|
-
- !ruby/object:Gem::Version
|
|
54
|
-
version: '13.0'
|
|
55
|
-
- !ruby/object:Gem::Dependency
|
|
56
|
-
name: rspec
|
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
|
58
|
-
requirements:
|
|
59
|
-
- - "~>"
|
|
60
|
-
- !ruby/object:Gem::Version
|
|
61
|
-
version: '3.0'
|
|
62
|
-
type: :development
|
|
63
|
-
prerelease: false
|
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
-
requirements:
|
|
66
|
-
- - "~>"
|
|
67
|
-
- !ruby/object:Gem::Version
|
|
68
|
-
version: '3.0'
|
|
69
|
-
- !ruby/object:Gem::Dependency
|
|
70
|
-
name: rubocop
|
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
|
72
|
-
requirements:
|
|
73
|
-
- - "~>"
|
|
74
|
-
- !ruby/object:Gem::Version
|
|
75
|
-
version: 0.93.1
|
|
76
|
-
type: :development
|
|
77
|
-
prerelease: false
|
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
-
requirements:
|
|
80
|
-
- - "~>"
|
|
81
|
-
- !ruby/object:Gem::Version
|
|
82
|
-
version: 0.93.1
|
|
83
|
-
- !ruby/object:Gem::Dependency
|
|
84
|
-
name: rubocop-performance
|
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
|
86
|
-
requirements:
|
|
87
|
-
- - "~>"
|
|
88
|
-
- !ruby/object:Gem::Version
|
|
89
|
-
version: '1.8'
|
|
90
|
-
- - ">="
|
|
91
|
-
- !ruby/object:Gem::Version
|
|
92
|
-
version: 1.8.1
|
|
93
|
-
type: :development
|
|
94
|
-
prerelease: false
|
|
95
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
96
|
-
requirements:
|
|
97
|
-
- - "~>"
|
|
98
|
-
- !ruby/object:Gem::Version
|
|
99
|
-
version: '1.8'
|
|
100
|
-
- - ">="
|
|
101
|
-
- !ruby/object:Gem::Version
|
|
102
|
-
version: 1.8.1
|
|
103
|
-
- !ruby/object:Gem::Dependency
|
|
104
|
-
name: vcr
|
|
105
|
-
requirement: !ruby/object:Gem::Requirement
|
|
106
|
-
requirements:
|
|
107
|
-
- - "~>"
|
|
108
|
-
- !ruby/object:Gem::Version
|
|
109
|
-
version: 5.0.0
|
|
110
|
-
type: :development
|
|
111
|
-
prerelease: false
|
|
112
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
113
|
-
requirements:
|
|
114
|
-
- - "~>"
|
|
115
|
-
- !ruby/object:Gem::Version
|
|
116
|
-
version: 5.0.0
|
|
117
|
-
- !ruby/object:Gem::Dependency
|
|
118
|
-
name: webmock
|
|
119
|
-
requirement: !ruby/object:Gem::Requirement
|
|
120
|
-
requirements:
|
|
121
|
-
- - "~>"
|
|
122
|
-
- !ruby/object:Gem::Version
|
|
123
|
-
version: 3.6.2
|
|
124
|
-
type: :development
|
|
125
|
-
prerelease: false
|
|
126
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
127
|
-
requirements:
|
|
128
|
-
- - "~>"
|
|
129
|
-
- !ruby/object:Gem::Version
|
|
130
|
-
version: 3.6.2
|
|
131
|
-
description:
|
|
11
|
+
date: 2024-02-04 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description:
|
|
132
14
|
email:
|
|
133
15
|
- bojanmajed@gmail.com
|
|
134
16
|
executables: []
|
|
@@ -170,8 +52,9 @@ licenses:
|
|
|
170
52
|
metadata:
|
|
171
53
|
homepage_uri: https://github.com/MajedBojan/simple_request
|
|
172
54
|
source_code_uri: https://github.com/MajedBojan/simple_request
|
|
173
|
-
changelog_uri: https://github.com/MajedBojan/simple_request/blob/
|
|
174
|
-
|
|
55
|
+
changelog_uri: https://github.com/MajedBojan/simple_request/blob/main/Changelog.md
|
|
56
|
+
rubygems_mfa_required: 'true'
|
|
57
|
+
post_install_message:
|
|
175
58
|
rdoc_options: []
|
|
176
59
|
require_paths:
|
|
177
60
|
- lib
|
|
@@ -186,8 +69,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
186
69
|
- !ruby/object:Gem::Version
|
|
187
70
|
version: '0'
|
|
188
71
|
requirements: []
|
|
189
|
-
rubygems_version: 3.
|
|
190
|
-
signing_key:
|
|
72
|
+
rubygems_version: 3.4.10
|
|
73
|
+
signing_key:
|
|
191
74
|
specification_version: 4
|
|
192
75
|
summary: Simple ruby gem that helps to make HTTP and HTTPS request from ruby projects.
|
|
193
76
|
test_files: []
|