mechanize 2.12.2 → 2.14.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: a0f6963774d1167e4fd1a9a48252dc9aa30333b46bdaba1319b9bc8dac2e0796
4
- data.tar.gz: fbbb2f82727a36f58313dfca7ffe4d5f1a5b33024663cd501cebdb5515831e56
3
+ metadata.gz: 00134b35e4583ae30a00b320468fa362e7290bced2f030a3e02544848f58cde6
4
+ data.tar.gz: babed05130568f0a4c306ccaa77da706334bafbd3fe898c961af5e4faaa98c03
5
5
  SHA512:
6
- metadata.gz: 339bd5bb87e66aad70541bd0a1a9031f349f6fbe62d991c45b28ebae43d9d4db7d4ba31c15de8578ca86e5c0efa0593730075e3695fc3e412f87ba07e6529447
7
- data.tar.gz: 7e629b20b4760f9e7b701e9cbad275f21cd6bba5114f8538ea9607f1a2335e9f1e121d1c0f36cba1027889f8486afe0aa5e10edff9d0b371fb0c0adf24277059
6
+ metadata.gz: 26e8e71a37e1811cfd108c3947d6eaac79576128e2b684e9b1e1d32ee83270f93b4c912b5fa8a324fb643b28dc423ed88ad95bad6efc904fe3af592d9d179844
7
+ data.tar.gz: 20ae7f34891ff7dd2284831acad91789656c6817d70577de885744d419ac447d8fac5cb6d7f2e609624835f2b506a85cbd5ba20f6881ae6d402f6b17ae460b82
@@ -32,7 +32,7 @@ jobs:
32
32
  strategy:
33
33
  fail-fast: false
34
34
  matrix:
35
- ruby-version: ["2.6", "2.7", "3.0", "3.1", "3.2", "3.3", "jruby-9.4", "truffleruby"]
35
+ ruby-version: ["2.6", "2.7", "3.0", "3.1", "3.2", "3.3", "3.4", "head"]
36
36
  runs-on: ubuntu-latest
37
37
  steps:
38
38
  - uses: actions/checkout@v4
@@ -23,7 +23,7 @@ jobs:
23
23
  strategy:
24
24
  fail-fast: false
25
25
  matrix:
26
- ruby-version: ["head", "jruby-head", "truffleruby-head"]
26
+ ruby-version: ["head"]
27
27
  runs-on: ubuntu-latest
28
28
  steps:
29
29
  - uses: actions/checkout@v4
@@ -44,7 +44,7 @@ jobs:
44
44
  steps:
45
45
  - uses: actions/checkout@v4
46
46
  - uses: ruby/setup-ruby@v1
47
- with: { ruby-version: "3.3" }
47
+ with: { ruby-version: "3.4" }
48
48
  - run: |
49
49
  bundle add ${{matrix.name}} --git="${{matrix.git}}"
50
50
  bundle show
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Mechanize CHANGELOG
2
2
 
3
+ ## 2.14.0 / 2025-01-05
4
+
5
+ * `Mechanize` exposes a `write_timeout` attribute, which is set on the connection if it's supported (e.g., `Net::HTTP::Persistent.write_timeout`). (#586) @maurycy
6
+
7
+
8
+ ## 2.13.0 / 2025-01-02
9
+
10
+ * Quash frozen string warnings in Ruby 3.4. (#661) @simpl1g
11
+ * Quash URI::Parser warnings in Ruby 3.4. (#662) @flavorjones
12
+
13
+
3
14
  ## 2.12.2 / 2023-10-02
4
15
 
5
16
  * Quash warnings from `Mime::Type.new` in `mime-types` v3.6.0. (#655) @avk
@@ -256,7 +256,7 @@ class Mechanize::Form
256
256
 
257
257
  # Treat form fields like accessors.
258
258
  def method_missing(meth, *args)
259
- (method = meth.to_s).chomp!('=')
259
+ method = meth.to_s.chomp('=')
260
260
 
261
261
  if field(method)
262
262
  return field(method).value if args.empty?
@@ -106,6 +106,9 @@ class Mechanize::HTTP::Agent
106
106
  # Length of time to attempt to read data from the server
107
107
  attr_accessor :read_timeout
108
108
 
109
+ # Length of time to attempt to write data to the server
110
+ attr_accessor :write_timeout
111
+
109
112
  # :section:
110
113
 
111
114
  # The cookies for this agent
@@ -161,6 +164,7 @@ class Mechanize::HTTP::Agent
161
164
  @robots_mutex = Mutex.new
162
165
  @user_agent = nil
163
166
  @webrobots = nil
167
+ @write_timeout = nil
164
168
 
165
169
  # HTTP Authentication
166
170
  @auth_store = Mechanize::HTTP::AuthStore.new
@@ -274,6 +278,9 @@ class Mechanize::HTTP::Agent
274
278
  if @read_timeout && connection.respond_to?(:read_timeout=)
275
279
  connection.read_timeout = @read_timeout
276
280
  end
281
+ if @write_timeout && connection.respond_to?(:write_timeout=)
282
+ connection.write_timeout = @write_timeout
283
+ end
277
284
 
278
285
  request_log request
279
286
 
@@ -134,29 +134,27 @@ class Mechanize::Util
134
134
  end
135
135
 
136
136
  def self.uri_escape str, unsafe = nil
137
- @parser ||= begin
138
- URI::Parser.new
139
- rescue NameError
140
- URI
141
- end
142
-
143
- if URI == @parser then
137
+ if URI == parser then
144
138
  unsafe ||= URI::UNSAFE
145
139
  else
146
- unsafe ||= @parser.regexp[:UNSAFE]
140
+ unsafe ||= parser.regexp[:UNSAFE]
147
141
  end
148
142
 
149
- @parser.escape str, unsafe
143
+ parser.escape str, unsafe
150
144
  end
151
145
 
152
146
  def self.uri_unescape str
153
- @parser ||= begin
154
- URI::Parser.new
155
- rescue NameError
156
- URI
157
- end
158
-
159
- @parser.unescape str
147
+ parser.unescape str
160
148
  end
161
149
 
150
+ def self.parser
151
+ @parser ||=
152
+ if defined?(URI::RFC2396_PARSER)
153
+ URI::RFC2396_PARSER
154
+ elsif defined?(URI::Parser)
155
+ URI::Parser.new
156
+ else
157
+ URI
158
+ end
159
+ end
162
160
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  class Mechanize
3
- VERSION = "2.12.2"
3
+ VERSION = "2.14.0"
4
4
  end
data/lib/mechanize.rb CHANGED
@@ -951,6 +951,21 @@ Use of #auth and #basic_auth are deprecated due to a security vulnerability.
951
951
  @agent.read_timeout = read_timeout
952
952
  end
953
953
 
954
+ ##
955
+ # Length of time to wait for data to be sent to the server
956
+
957
+ def write_timeout
958
+ @agent.write_timeout
959
+ end
960
+
961
+ ##
962
+ # Sets the timeout for each chunk of data to be sent to the server to
963
+ # +write_timeout+. A single request may write many chunks of data.
964
+
965
+ def write_timeout= write_timeout
966
+ @agent.write_timeout = write_timeout
967
+ end
968
+
954
969
  ##
955
970
  # Controls how mechanize deals with redirects. The following values are
956
971
  # allowed:
@@ -1016,8 +1016,16 @@ but not <a href="/" rel="me nofollow">this</a>!
1016
1016
 
1017
1017
  def test_read_timeout_equals
1018
1018
  @mech.read_timeout = 5
1019
-
1020
1019
  assert_equal 5, @mech.read_timeout
1020
+ assert @mech.get('http://localhost/response_code?code=200')
1021
+ assert_equal 5, @mech.agent.http.read_timeout
1022
+ end
1023
+
1024
+ def test_write_timeout_equals
1025
+ @mech.write_timeout = 7
1026
+ assert_equal 7, @mech.write_timeout
1027
+ assert @mech.get('http://localhost/response_code?code=200')
1028
+ assert_equal 7, @mech.agent.http.write_timeout
1021
1029
  end
1022
1030
 
1023
1031
  def test_timeouts_for_file_connection
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mechanize
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.12.2
4
+ version: 2.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Hodel
@@ -9,10 +9,9 @@ authors:
9
9
  - Mike Dalessio
10
10
  - Akinori MUSHA
11
11
  - Lee Jarvis
12
- autorequire:
13
12
  bindir: bin
14
13
  cert_chain: []
15
- date: 2024-10-02 00:00:00.000000000 Z
14
+ date: 2025-01-05 00:00:00.000000000 Z
16
15
  dependencies:
17
16
  - !ruby/object:Gem::Dependency
18
17
  name: addressable
@@ -459,7 +458,6 @@ metadata:
459
458
  documentation_uri: https://www.rubydoc.info/gems/mechanize
460
459
  homepage_uri: https://github.com/sparklemotion/mechanize
461
460
  source_code_uri: https://github.com/sparklemotion/mechanize
462
- post_install_message:
463
461
  rdoc_options:
464
462
  - "--main"
465
463
  - README.md
@@ -476,8 +474,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
476
474
  - !ruby/object:Gem::Version
477
475
  version: '0'
478
476
  requirements: []
479
- rubygems_version: 3.5.11
480
- signing_key:
477
+ rubygems_version: 3.6.2
481
478
  specification_version: 4
482
479
  summary: The Mechanize library is used for automating interaction with websites
483
480
  test_files: