http-form_data 2.1.1 → 2.2.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
- SHA1:
3
- metadata.gz: 91e7ff4611e0a772489c8106a841d5ca29fe86bb
4
- data.tar.gz: 2ccf8a6814414a191f016462568ccec8d230b956
2
+ SHA256:
3
+ metadata.gz: e09c6384f02137e31adab5115524beb33decdf03cff1e52b6e37f660a5956256
4
+ data.tar.gz: 5a2e181da1de4da73edb2be5d970b9ad4afbe2f2c9edcc8421ba3c885908f7a5
5
5
  SHA512:
6
- metadata.gz: 31bcdd5a50c1a3941723999b26037c2d6eceb19f6878ac11e1adecd0fb0ddc12dff07bb01b4267170ade30bbb20889e99fdba458cb443bf137cef329d00ff3c9
7
- data.tar.gz: 3a2f82eaab7a8a7cf40e5b0d9e4e33c3c7ba7e0d880787175396142fbb04dac7c9e554fbc7d1bb29b40d3592a8aca569a70d923a7a45cf32febc524f65e7117d
6
+ metadata.gz: ade103ecd25eb756f92421d673ab68af8629c40ed6b2633af6cdf0d5173c4a9332aa7bf33970c85e2b1926ee5c4b3d2dc0d33f4eaa506512b36da398e9a4b402
7
+ data.tar.gz: d89facbae50f67e1fb8f08b4395e37b6477a21c5d83bbe4efcebef488204020f100ef525e5141fbfa7186e905815662c8093a90b576ac8d19b3976c5e1d1da3a
@@ -0,0 +1,9 @@
1
+ root = true
2
+
3
+ [*]
4
+ indent_style = space
5
+ indent_size = 2
6
+ end_of_line = lf
7
+ charset = utf-8
8
+ trim_trailing_whitespace = true
9
+ insert_final_newline = true
data/.gitignore CHANGED
@@ -1,5 +1,6 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
+ /.ruby-version
3
4
  /Gemfile.lock
4
5
  /_yardoc/
5
6
  /coverage/
@@ -6,7 +6,7 @@ cache: bundler
6
6
  before_install:
7
7
  - gem update --system
8
8
  - gem --version
9
- - gem install bundler --no-rdoc --no-ri
9
+ - gem install bundler --no-document
10
10
  - bundle --version
11
11
 
12
12
  install: bundle install --without development doc
@@ -18,14 +18,15 @@ env: JRUBY_OPTS="$JRUBY_OPTS --debug"
18
18
  rvm:
19
19
  # Include JRuby first because it takes the longest
20
20
  - jruby-9.1.13.0
21
- - 2.2
22
- - 2.3.4
23
- - 2.4.1
21
+ - 2.4
22
+ - 2.5
23
+ - 2.6
24
+ - 2.7
24
25
 
25
26
  matrix:
26
27
  fast_finish: true
27
28
  include:
28
- - rvm: 2.4.1
29
+ - rvm: 2.7
29
30
  env: SUITE="rubocop"
30
31
 
31
32
  branches:
data/CHANGES.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 2.2.0 (2020-01-09)
2
+
3
+ * [#28](https://github.com/httprb/form_data/pull/28)
4
+ Ruby 2.7 compatibility.
5
+ [@janko][]
6
+
7
+
1
8
  ## 2.1.1 (2018-06-01)
2
9
 
3
10
  * [#23](https://github.com/httprb/form_data/pull/23)
data/README.md CHANGED
@@ -58,10 +58,10 @@ form = HTTP::FormData.create({
58
58
  This library aims to support and is [tested against][ci] the following Ruby
59
59
  versions:
60
60
 
61
- * Ruby 2.1.x
62
- * Ruby 2.2.x
63
- * Ruby 2.3.x
64
61
  * Ruby 2.4.x
62
+ * Ruby 2.5.x
63
+ * Ruby 2.6.x
64
+ * Ruby 2.7.x
65
65
  * JRuby 9.1.x.x
66
66
 
67
67
  If something doesn't work on one of these versions, it's a bug.
@@ -22,6 +22,4 @@ Gem::Specification.new do |spec|
22
22
  spec.executables = spec.files.grep(%r{^bin\/}).map { |f| File.basename(f) }
23
23
  spec.test_files = spec.files.grep(%r{^(test|spec|features)\/})
24
24
  spec.require_paths = ["lib"]
25
-
26
- spec.add_development_dependency "bundler", "~> 1.7"
27
25
  end
@@ -29,23 +29,12 @@ module HTTP
29
29
  #
30
30
  # @return [String, nil]
31
31
  def read(length = nil, outbuf = nil)
32
- outbuf = outbuf.to_s.clear
33
- # buffer in JRuby is sometimes US-ASCII, force to ASCII-8BIT
34
- outbuf.force_encoding(Encoding::BINARY)
32
+ data = outbuf.clear.force_encoding(Encoding::BINARY) if outbuf
33
+ data ||= "".b
35
34
 
36
- while current_io
37
- current_io.read(length, @buffer)
38
- outbuf << @buffer.force_encoding(Encoding::BINARY)
39
-
40
- if length
41
- length -= @buffer.bytesize
42
- break if length.zero?
43
- end
44
-
45
- advance_io
46
- end
35
+ read_chunks(length) { |chunk| data << chunk }
47
36
 
48
- outbuf unless length && outbuf.empty?
37
+ data unless length && data.empty?
49
38
  end
50
39
 
51
40
  # Returns sum of all IO sizes.
@@ -61,6 +50,30 @@ module HTTP
61
50
 
62
51
  private
63
52
 
53
+ # Yields chunks with total length up to `length`.
54
+ def read_chunks(length = nil)
55
+ while (chunk = readpartial(length))
56
+ yield chunk.force_encoding(Encoding::BINARY)
57
+
58
+ next if length.nil?
59
+
60
+ length -= chunk.bytesize
61
+
62
+ break if length.zero?
63
+ end
64
+ end
65
+
66
+ # Reads chunk from current IO with length up to `max_length`.
67
+ def readpartial(max_length = nil)
68
+ while current_io
69
+ chunk = current_io.read(max_length, @buffer)
70
+
71
+ return chunk if chunk && !chunk.empty?
72
+
73
+ advance_io
74
+ end
75
+ end
76
+
64
77
  # Returns IO object under the cursor.
65
78
  def current_io
66
79
  @ios[@index]
@@ -3,6 +3,6 @@
3
3
  module HTTP
4
4
  module FormData
5
5
  # Gem version.
6
- VERSION = "2.1.1"
6
+ VERSION = "2.2.0"
7
7
  end
8
8
  end
@@ -57,7 +57,7 @@ RSpec.describe HTTP::FormData::Multipart do
57
57
 
58
58
  context "with filename set to nil" do
59
59
  let(:part) { HTTP::FormData::Part.new("s", :content_type => "mime/type") }
60
- let(:form_data) { HTTP::FormData::Multipart.new(:foo => part) }
60
+ let(:form_data) { HTTP::FormData::Multipart.new({ :foo => part }) }
61
61
 
62
62
  it "doesn't include a filename" do
63
63
  boundary_value = form_data.content_type[/(#{boundary})$/, 1]
@@ -74,7 +74,7 @@ RSpec.describe HTTP::FormData::Multipart do
74
74
 
75
75
  context "with content type set to nil" do
76
76
  let(:part) { HTTP::FormData::Part.new("s") }
77
- let(:form_data) { HTTP::FormData::Multipart.new(:foo => part) }
77
+ let(:form_data) { HTTP::FormData::Multipart.new({ :foo => part }) }
78
78
 
79
79
  it "doesn't include a filename" do
80
80
  boundary_value = form_data.content_type[/(#{boundary})$/, 1]
@@ -3,7 +3,7 @@
3
3
  RSpec.describe HTTP::FormData::Part do
4
4
  let(:body) { "" }
5
5
  let(:opts) { {} }
6
- subject(:part) { HTTP::FormData::Part.new(body, opts) }
6
+ subject(:part) { HTTP::FormData::Part.new(body, **opts) }
7
7
 
8
8
  describe "#size" do
9
9
  subject { part.size }
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http-form_data
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aleksey V Zapparov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-01 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.7'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.7'
11
+ date: 2020-01-09 00:00:00.000000000 Z
12
+ dependencies: []
27
13
  description: Utility-belt to build form data request bodies. Provides support for
28
14
  `application/x-www-form-urlencoded` and `multipart/form-data` types.
29
15
  email:
@@ -32,6 +18,7 @@ executables: []
32
18
  extensions: []
33
19
  extra_rdoc_files: []
34
20
  files:
21
+ - ".editorconfig"
35
22
  - ".gitignore"
36
23
  - ".rspec"
37
24
  - ".rubocop.yml"
@@ -83,11 +70,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
70
  - !ruby/object:Gem::Version
84
71
  version: '0'
85
72
  requirements: []
86
- rubyforge_project:
87
- rubygems_version: 2.6.14.1
73
+ rubygems_version: 3.1.2
88
74
  signing_key:
89
75
  specification_version: 4
90
- summary: http-form_data-2.1.1
76
+ summary: http-form_data-2.2.0
91
77
  test_files:
92
78
  - spec/fixtures/expected-multipart-body.tpl
93
79
  - spec/fixtures/the-http-gem.info