request_via 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2d09f830e111ee1a4cc0a3a20d9f4a4c9336b41f
4
- data.tar.gz: e5e3ccad0cb0879d0e0477982fd7256a6fc7903b
3
+ metadata.gz: d4966442b32fe09b091c1ba940658f3ae1330210
4
+ data.tar.gz: d28c20e0ad6709eaa801f7751a3d2947d3e65c2c
5
5
  SHA512:
6
- metadata.gz: 9cb4e2a6bdb5bcd1a3e15ec93076e7cf93bf42b52dc85a3aff6c6465f5928fdaeefc3acc55ddd86c01f6ac89c0b23faa80f9b8021b80d577d7d0d889144d5ae2
7
- data.tar.gz: cf8d9947ea0982db0cb01560b21610ed01101cbf63872d90834393e0fb95f4a130488fd03b26a48c30513324b0c0f24730d11d81e9d95a6282aea6098a966d2b
6
+ metadata.gz: 470c31a0b38d42987f41eb9cbeff68f333ccdc875efa77098ec7a7fc3e544baa9476471ab7fc52d5b31070726d8d896438d7fedc865b33a667a3a8285afc058a
7
+ data.tar.gz: a78cf82f0077abcbd8d312072c5d0a26c32e90d5ee228aefe25dc216ebf2b4e81d3da3403828a83e6efe67bdb8763d154268fecc9eb5e96ece9eb55793d33b2d
data/README.md CHANGED
@@ -63,24 +63,29 @@ RequestVia::Get.('example.com', params: { foo: 'bar' })
63
63
  # Request with headers
64
64
  RequestVia::Get.('example.com/foo', headers: { 'X-Requested-With': 'RequestVia gem' })
65
65
 
66
- # Return the response and request objects as result
66
+ # Return the response and request objects
67
67
  response, request = RequestVia::Get.('example.com/foo', response_and_request: true)
68
+
69
+ # Request with the reversed arguments order
70
+ %w[
71
+ example.com/foo example.com/bar
72
+ ].map &RequestVia::GetR.(headers: { 'X-Requested-With': 'RequestVia gem' })
68
73
  ```
69
74
 
70
75
  Supported HTTP methods.
71
76
  (**NOTE:** you can use all arguments of previous examples)
72
77
  ```ruby
73
- RequestVia::Post.()
78
+ RequestVia::Post.() # RequestVia::PostR.()
74
79
 
75
- RequestVia::Put.()
80
+ RequestVia::Put.() # RequestVia::PutR.()
76
81
 
77
- RequestVia::Delete.()
82
+ RequestVia::Delete.() # RequestVia::DeteteR.()
78
83
 
79
- RequestVia::Options.()
84
+ RequestVia::Options.() # RequestVia::OptionsR.()
80
85
 
81
- RequestVia::Trace.()
86
+ RequestVia::Trace.() # RequestVia::TraceR.()
82
87
 
83
- RequestVia::Patch.()
88
+ RequestVia::Patch.() # RequestVia::PatchR.()
84
89
  ```
85
90
 
86
91
  Making a HTTPS request.
data/lib/request_via.rb CHANGED
@@ -8,19 +8,21 @@ require "request_via/http_client"
8
8
  require "request_via/func"
9
9
 
10
10
  module RequestVia
11
- Get = Func::FetchStrategyTo.(Net::HTTP::Get).freeze
12
-
13
- Head = Func::FetchStrategyTo.(Net::HTTP::Head).freeze
14
-
15
- Post = Func::FetchStrategyTo.(Net::HTTP::Post).freeze
16
-
17
- Put = Func::FetchStrategyTo.(Net::HTTP::Put).freeze
18
-
19
- Delete = Func::FetchStrategyTo.(Net::HTTP::Delete).freeze
20
-
11
+ Get = Func::FetchStrategyTo.(Net::HTTP::Get).freeze
12
+ Head = Func::FetchStrategyTo.(Net::HTTP::Head).freeze
13
+ Post = Func::FetchStrategyTo.(Net::HTTP::Post).freeze
14
+ Put = Func::FetchStrategyTo.(Net::HTTP::Put).freeze
15
+ Delete = Func::FetchStrategyTo.(Net::HTTP::Delete).freeze
21
16
  Options = Func::FetchStrategyTo.(Net::HTTP::Options).freeze
22
-
23
- Trace = Func::FetchStrategyTo.(Net::HTTP::Trace).freeze
24
-
25
- Patch = Func::FetchStrategyTo.(Net::HTTP::Patch).freeze
17
+ Trace = Func::FetchStrategyTo.(Net::HTTP::Trace).freeze
18
+ Patch = Func::FetchStrategyTo.(Net::HTTP::Patch).freeze
19
+
20
+ GetR = Func::ReverseRequestArgsTo.(Get).freeze
21
+ HeadR = Func::ReverseRequestArgsTo.(Head).freeze
22
+ PostR = Func::ReverseRequestArgsTo.(Post).freeze
23
+ PutR = Func::ReverseRequestArgsTo.(Put).freeze
24
+ DeleteR = Func::ReverseRequestArgsTo.(Delete).freeze
25
+ OptionsR = Func::ReverseRequestArgsTo.(Options).freeze
26
+ TraceR = Func::ReverseRequestArgsTo.(Trace).freeze
27
+ PatchR = Func::ReverseRequestArgsTo.(Patch).freeze
26
28
  end
@@ -2,6 +2,12 @@
2
2
 
3
3
  module RequestVia
4
4
  module Func
5
+ ReverseRequestArgsTo = -> request {
6
+ -> (options, url) {
7
+ request.(url, **options)
8
+ }.curry
9
+ }.freeze
10
+
5
11
  ParseURI = -> url {
6
12
  if url.start_with?('http://', 'https://')
7
13
  ::URI.parse(url)
@@ -3,7 +3,7 @@
3
3
  module RequestVia
4
4
  module SemVer
5
5
  MAJOR = 0
6
- MINOR = 2
6
+ MINOR = 3
7
7
  PATCH = 0
8
8
  end
9
9
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: request_via
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Serradura