protocol-url 0.6.0 → 0.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 10d18a95d6f20f5ca2457a52a2defa8d961ecf26eb372d45bea1f2d339f3a5c6
4
- data.tar.gz: f15a84b24bd971e6262306b84e271196b5c20cde76983eba4625af28b0895ddd
3
+ metadata.gz: 38bcf53ee312963527020be6c4a4c18697587ad4ecd75277552b1dbd744e0ec9
4
+ data.tar.gz: 85f2886788dfec25b6799f3c92d79f8bb31fbb5f48f3b017fca94993a21b507b
5
5
  SHA512:
6
- metadata.gz: e1493486247a9e36b696bf62225a33888905d7e4a5a83b31357dc67d227b3a6f481844e2423befc5cc21f4c0a14aebc4ea507faa68a06a50490619e455396950
7
- data.tar.gz: ee45f80e209b66b2a30d6b155188138a513e9a2c632bf1a4edc0322823e9bef209d2515babc955030c43c26c9da9ea687303a2aa91fa9704a2ac0594405d8cda
6
+ metadata.gz: c5870caa5923cc4918e909470522231f132946f3235a8b396dff155adcab311ab0a1743da9ae1de96c92d2427c6e61cb758760dc2a3133005c4b0929225a4af5
7
+ data.tar.gz: 820c6b061491cd83b553f38b5d53573cc641d76ad63be859e2835698e0b7242ae908763758b1730dd3b56a3f5a82dfe11d2f2de0cfafe12bd87ef66d4e405c17
checksums.yaml.gz.sig CHANGED
Binary file
@@ -34,17 +34,16 @@ module Protocol
34
34
  # When a block is given, each decoded value is passed through the block before assignment. The value returned by the block is assigned to the result.
35
35
  #
36
36
  # @parameter body [Object] A readable body which yields chunks from `#read`.
37
+ # @parameter result [Object] The result to populate. It must support `#add` and `#to_h`.
37
38
  # @yields {|name, value| ...} Each decoded form pair before assignment.
38
39
  # @returns [Hash] The nested form data.
39
- def parse(body)
40
- nested = Nested.new(maximum_depth: @maximum_depth)
41
-
40
+ def parse(body, result = make_result)
42
41
  each(body) do |name, value|
43
42
  value = yield(name, value) if block_given?
44
- nested.add(name, value)
43
+ result.add(name, value)
45
44
  end
46
45
 
47
- return nested.to_h
46
+ return result.to_h
48
47
  end
49
48
 
50
49
  # Incrementally enumerate URL-encoded form data as ordered name/value pairs.
@@ -88,6 +87,10 @@ module Protocol
88
87
 
89
88
  private
90
89
 
90
+ def make_result
91
+ return Nested.new(maximum_depth: @maximum_depth)
92
+ end
93
+
91
94
  def yield_pair(assignment)
92
95
  name, value = assignment.split("=", 2)
93
96
 
@@ -7,6 +7,6 @@
7
7
  module Protocol
8
8
  # @namespace
9
9
  module URL
10
- VERSION = "0.6.0"
10
+ VERSION = "0.7.0"
11
11
  end
12
12
  end
data/readme.md CHANGED
@@ -34,6 +34,10 @@ This project is best served by a collaborative and respectful environment. Treat
34
34
 
35
35
  Please see the [project releases](https://socketry.github.io/protocol-url/releases/index) for all releases.
36
36
 
37
+ ### v0.7.0
38
+
39
+ - Allow `Protocol::URL::FormData::Parser#parse` to populate a supplied result object.
40
+
37
41
  ### v0.6.0
38
42
 
39
43
  - Add `Protocol::URL::FormData::Parser` for incremental, limited parsing of `application/x-www-form-urlencoded` form data.
data/releases.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Releases
2
2
 
3
+ ## v0.7.0
4
+
5
+ - Allow `Protocol::URL::FormData::Parser#parse` to populate a supplied result object.
6
+
3
7
  ## v0.6.0
4
8
 
5
9
  - Add `Protocol::URL::FormData::Parser` for incremental, limited parsing of `application/x-www-form-urlencoded` form data.
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protocol-url
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
metadata.gz.sig CHANGED
Binary file