Run of fresh-releases for ruby-http-form-data

Merge these changes:

git pull https://janitor.debian.net/git/ruby-http-form-data fresh-releases/main
git pull https://janitor.debian.net/git/ruby-http-form-data fresh-releases/pristine-tar
git pull https://janitor.debian.net/git/ruby-http-form-data fresh-releases/upstream

Summary

Merged new upstream version: 2.3.0 (was: 2.2.0).

Diff

Branch: main

diff --git a/CHANGES.md b/CHANGES.md
index 22054d0..36459c7 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,3 +1,10 @@
+## 2.3.0 (2020-03-08)
+
+* [#29](https://github.com/httprb/form_data/pull/29)
+  Enhance HTTP::FormData::Urlencoded with per-instance encoder.
+  [@summera][]
+
+
 ## 2.2.0 (2020-01-09)
 
 * [#28](https://github.com/httprb/form_data/pull/28)
@@ -86,3 +93,4 @@
 [@mhickman]: https://github.com/mhickman
 [@HoneyryderChuck]: https://github.com/HoneyryderChuck
 [@FabienChaynes]: https://github.com/FabienChaynes
+[@summera]: https://github.com/summera
diff --git a/debian/changelog b/debian/changelog
index ab9a13f..8d1b44e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,12 +1,13 @@
-ruby-http-form-data (2.2.0-2) UNRELEASED; urgency=medium
+ruby-http-form-data (2.3.0-1) UNRELEASED; urgency=medium
 
   * Set field Upstream-Contact in debian/copyright.
   * Remove obsolete fields Contact, Name from debian/upstream/metadata
     (already present in machine-readable debian/copyright).
   * Apply multi-arch hints.
     + ruby-http-form-data: Add Multi-Arch: foreign.
+  * New upstream release.
 
- -- Debian Janitor <janitor@jelmer.uk>  Sun, 15 Mar 2020 04:47:14 +0000
+ -- Debian Janitor <janitor@jelmer.uk>  Wed, 16 Mar 2022 13:51:08 -0000
 
 ruby-http-form-data (2.2.0-1) unstable; urgency=medium
 
diff --git a/lib/http/form_data.rb b/lib/http/form_data.rb
index be542bc..e993161 100644
--- a/lib/http/form_data.rb
+++ b/lib/http/form_data.rb
@@ -41,11 +41,14 @@ module HTTP
       # @param [#to_h, Hash] data
       # @return [Multipart] if any of values is a {FormData::File}
       # @return [Urlencoded] otherwise
-      def create(data)
-        data  = ensure_hash data
-        klass = multipart?(data) ? Multipart : Urlencoded
+      def create(data, encoder: nil)
+        data = ensure_hash data
 
-        klass.new data
+        if multipart?(data)
+          Multipart.new(data)
+        else
+          Urlencoded.new(data, :encoder => encoder)
+        end
       end
 
       # Coerce `obj` to Hash.
diff --git a/lib/http/form_data/urlencoded.rb b/lib/http/form_data/urlencoded.rb
index dc47b94..9ebcaf0 100644
--- a/lib/http/form_data/urlencoded.rb
+++ b/lib/http/form_data/urlencoded.rb
@@ -63,8 +63,9 @@ module HTTP
       end
 
       # @param [#to_h, Hash] data form data key-value Hash
-      def initialize(data)
-        @io = StringIO.new(self.class.encoder.call(FormData.ensure_hash(data)))
+      def initialize(data, encoder: nil)
+        encoder ||= self.class.encoder
+        @io = StringIO.new(encoder.call(FormData.ensure_hash(data)))
       end
 
       # Returns MIME type to be used for HTTP request `Content-Type` header.
diff --git a/lib/http/form_data/version.rb b/lib/http/form_data/version.rb
index 7e997c0..0a3d78f 100644
--- a/lib/http/form_data/version.rb
+++ b/lib/http/form_data/version.rb
@@ -3,6 +3,6 @@
 module HTTP
   module FormData
     # Gem version.
-    VERSION = "2.2.0"
+    VERSION = "2.3.0"
   end
 end
diff --git a/spec/lib/http/form_data/urlencoded_spec.rb b/spec/lib/http/form_data/urlencoded_spec.rb
index a3de752..649e3b6 100644
--- a/spec/lib/http/form_data/urlencoded_spec.rb
+++ b/spec/lib/http/form_data/urlencoded_spec.rb
@@ -64,4 +64,15 @@ RSpec.describe HTTP::FormData::Urlencoded do
       expect(form_data.to_s).to eq('{"foo[bar]":"test"}')
     end
   end
+
+  context "with custom instance level encoder" do
+    let(:encoder) { proc { |data| ::JSON.dump(data) } }
+    subject(:form_data) do
+      HTTP::FormData::Urlencoded.new(data, :encoder => encoder)
+    end
+
+    it "uses encoder passed to initializer" do
+      expect(form_data.to_s).to eq('{"foo[bar]":"test"}')
+    end
+  end
 end

Branch: pristine-tar

diff --git a/ruby-http-form-data_2.3.0.orig.tar.gz.delta b/ruby-http-form-data_2.3.0.orig.tar.gz.delta
new file mode 100644
index 0000000..c609d18
Binary files /dev/null and b/ruby-http-form-data_2.3.0.orig.tar.gz.delta differ
diff --git a/ruby-http-form-data_2.3.0.orig.tar.gz.id b/ruby-http-form-data_2.3.0.orig.tar.gz.id
new file mode 100644
index 0000000..99c68be
--- /dev/null
+++ b/ruby-http-form-data_2.3.0.orig.tar.gz.id
@@ -0,0 +1 @@
+833d521d270adb26c1729a00e61733ad7a314773

Branch: upstream

Tag: upstream/2.3.0
diff --git a/CHANGES.md b/CHANGES.md
index 22054d0..36459c7 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,3 +1,10 @@
+## 2.3.0 (2020-03-08)
+
+* [#29](https://github.com/httprb/form_data/pull/29)
+  Enhance HTTP::FormData::Urlencoded with per-instance encoder.
+  [@summera][]
+
+
 ## 2.2.0 (2020-01-09)
 
 * [#28](https://github.com/httprb/form_data/pull/28)
@@ -86,3 +93,4 @@
 [@mhickman]: https://github.com/mhickman
 [@HoneyryderChuck]: https://github.com/HoneyryderChuck
 [@FabienChaynes]: https://github.com/FabienChaynes
+[@summera]: https://github.com/summera
diff --git a/lib/http/form_data.rb b/lib/http/form_data.rb
index be542bc..e993161 100644
--- a/lib/http/form_data.rb
+++ b/lib/http/form_data.rb
@@ -41,11 +41,14 @@ module HTTP
       # @param [#to_h, Hash] data
       # @return [Multipart] if any of values is a {FormData::File}
       # @return [Urlencoded] otherwise
-      def create(data)
-        data  = ensure_hash data
-        klass = multipart?(data) ? Multipart : Urlencoded
+      def create(data, encoder: nil)
+        data = ensure_hash data
 
-        klass.new data
+        if multipart?(data)
+          Multipart.new(data)
+        else
+          Urlencoded.new(data, :encoder => encoder)
+        end
       end
 
       # Coerce `obj` to Hash.
diff --git a/lib/http/form_data/urlencoded.rb b/lib/http/form_data/urlencoded.rb
index dc47b94..9ebcaf0 100644
--- a/lib/http/form_data/urlencoded.rb
+++ b/lib/http/form_data/urlencoded.rb
@@ -63,8 +63,9 @@ module HTTP
       end
 
       # @param [#to_h, Hash] data form data key-value Hash
-      def initialize(data)
-        @io = StringIO.new(self.class.encoder.call(FormData.ensure_hash(data)))
+      def initialize(data, encoder: nil)
+        encoder ||= self.class.encoder
+        @io = StringIO.new(encoder.call(FormData.ensure_hash(data)))
       end
 
       # Returns MIME type to be used for HTTP request `Content-Type` header.
diff --git a/lib/http/form_data/version.rb b/lib/http/form_data/version.rb
index 7e997c0..0a3d78f 100644
--- a/lib/http/form_data/version.rb
+++ b/lib/http/form_data/version.rb
@@ -3,6 +3,6 @@
 module HTTP
   module FormData
     # Gem version.
-    VERSION = "2.2.0"
+    VERSION = "2.3.0"
   end
 end
diff --git a/spec/lib/http/form_data/urlencoded_spec.rb b/spec/lib/http/form_data/urlencoded_spec.rb
index a3de752..649e3b6 100644
--- a/spec/lib/http/form_data/urlencoded_spec.rb
+++ b/spec/lib/http/form_data/urlencoded_spec.rb
@@ -64,4 +64,15 @@ RSpec.describe HTTP::FormData::Urlencoded do
       expect(form_data.to_s).to eq('{"foo[bar]":"test"}')
     end
   end
+
+  context "with custom instance level encoder" do
+    let(:encoder) { proc { |data| ::JSON.dump(data) } }
+    subject(:form_data) do
+      HTTP::FormData::Urlencoded.new(data, :encoder => encoder)
+    end
+
+    it "uses encoder passed to initializer" do
+      expect(form_data.to_s).to eq('{"foo[bar]":"test"}')
+    end
+  end
 end

Publish Blockers

Resulting package

The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:

apt install -t fresh-releases ruby-http-form-data

Lintian Result

Full worker log Full build log