fetch-api 0.5.1 → 0.6.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/README.md +12 -0
- data/lib/fetch/config.rb +5 -1
- data/lib/fetch/response.rb +2 -2
- data/lib/fetch/version.rb +1 -1
- data/lib/fetch.rb +1 -0
- data/sig/fetch/config.rbs +1 -0
- data/sig/fetch/response.rbs +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c44fa15b798e01607f5c81e771ad55d24c56abea4aaa1829de0046aa2a761a2
|
4
|
+
data.tar.gz: d8f8c324b7685c23d613ea1f00f5621bc23ef6e682aa66c0c181bb57c035d094
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89fc2a039bac8f9dea78f86a6af9d195dff47f1e47fdfbf86026364a916be5dba60961daccd4d24a56f321f95823e24148c9e32df58b50736b7aba03e9ae24cf
|
7
|
+
data.tar.gz: d60ae6beb1b1736cb4a5e71b5049742771a8905565475121f02e5d23b0691905575cb6f1ab55afcc8f7a97f2ed38fee6d169aa6f1f4220a9513ab01c3b97adc3
|
data/README.md
CHANGED
@@ -129,6 +129,18 @@ Fetch.configure do |config|
|
|
129
129
|
end
|
130
130
|
```
|
131
131
|
|
132
|
+
### Parsing JSON
|
133
|
+
|
134
|
+
By default, `Fetch::Response#json` calls `JSON.parse` without options. Additional options can be specified in `Fetch.config.json_parse_options`.
|
135
|
+
|
136
|
+
``` ruby
|
137
|
+
Fetch.configure do |config|
|
138
|
+
config.json_parse_options = {
|
139
|
+
symbolize_names: true
|
140
|
+
}
|
141
|
+
end
|
142
|
+
```
|
143
|
+
|
132
144
|
## Development
|
133
145
|
|
134
146
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/fetch/config.rb
CHANGED
data/lib/fetch/response.rb
CHANGED
@@ -21,10 +21,10 @@ module Fetch
|
|
21
21
|
Rack::Utils::HTTP_STATUS_CODES[status]
|
22
22
|
end
|
23
23
|
|
24
|
-
def json(
|
24
|
+
def json(**json_parse_options)
|
25
25
|
return nil unless body
|
26
26
|
|
27
|
-
JSON.parse(body,
|
27
|
+
JSON.parse(body, **Fetch.config.json_parse_options, **json_parse_options)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
data/lib/fetch/version.rb
CHANGED
data/lib/fetch.rb
CHANGED
data/sig/fetch/config.rbs
CHANGED
data/sig/fetch/response.rbs
CHANGED
@@ -9,6 +9,6 @@ module Fetch
|
|
9
9
|
def initialize: (url: String, status: Integer, headers: Headers, body: String?, redirected: bool) -> void
|
10
10
|
def ok: () -> bool
|
11
11
|
def status_text: () -> String
|
12
|
-
def json: (json_options) -> untyped
|
12
|
+
def json: (**json_options) -> untyped
|
13
13
|
end
|
14
14
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fetch-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keita Urashima
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -149,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
149
|
- !ruby/object:Gem::Version
|
150
150
|
version: '0'
|
151
151
|
requirements: []
|
152
|
-
rubygems_version: 3.5.
|
152
|
+
rubygems_version: 3.5.16
|
153
153
|
signing_key:
|
154
154
|
specification_version: 4
|
155
155
|
summary: Something like the Fetch API for Ruby
|