http.rb 1.7.1 → 1.7.2

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: 275a68b16a13f177b907eb555faa75187ed2e03bb68e6d70902cfc5fc2f089d4
4
- data.tar.gz: 5f6b2930739ff00066c4968c0159e179b4f1cf4e419ce8ea4198fe1af2d2a23a
3
+ metadata.gz: f393fe0aa1125d6e4e74ee456067818c3c95c770fbefdf7b5e19487579e26bc1
4
+ data.tar.gz: 075d928ed5316c24f69134b768f80e8037fbbe6f58a6614be461ed0ed7c39328
5
5
  SHA512:
6
- metadata.gz: f1ae811bfb12e66bf13461d78b64681095c2f5167d154afd2d93a0dadcf703bb45208fb1cd9dcde634dd836e331cc8db60b314951ba2675672deae477f9f76bd
7
- data.tar.gz: 21b4a290fe9122f75d64a7d9e3878a3aed962262fdb6e6e434fa61a3b3cd664d2623b8ef36439a45177c120ddfce1693f1a5a7a9f1b76b8a906997e1e6ad85d1
6
+ metadata.gz: c2ed096075f4e6c25567e4bf89bee9ba39c6548bef5229b7771d5f992a60fbeb6fc9b6412d60c526c6aed7fd92485860a9c03c855bb27a93c45065b3a662c47f
7
+ data.tar.gz: 0c4c65e4ee9d5973e2a96ce941d6b99011da0108b477e52ed46a8206abdf91adebe0b3956131a594a7b4833d0cd9c8425b1a0252ecdb83978da61f57e31e4a47
data/CHANGELOG CHANGED
@@ -1,5 +1,16 @@
1
1
  # http/CHANGELOG
2
2
 
3
+ ## 20261129
4
+
5
+ 1.7.2: http.rb's own files are required relatively, so as files of the same names elsewhere on the load path aren't loaded in their place.
6
+
7
+ 1. ~ lib/http.rb: require_relative './HTTP/METHODS' and './HTTP/VERSION'.
8
+ 2. ~ lib/Hash/x_www_form_urlencode.rb: require_relative '../Thoran/Hash/XWwwFormUrlencode/x_www_form_urlencode'. An older copy earlier on the load path had been loaded in its place, so an array went as its inspect string.
9
+ 3. ~ lib/Thoran/Hash/XWwwFormUrlencode/x_www_form_urlencode.rb: require_relative '../../String/Urlencode/urlencode'.
10
+ 4. ~ test/loading_test.rb: With a decoy of each of those files first on the load path, requiring the gem loads none of them. ruby(): + load_path:.
11
+ 5. ~ HTTP::VERSION: /1.7.1/1.7.2/
12
+
13
+
3
14
  ## 20261019
4
15
 
5
16
  1.7.1: Args are joined to a query already in the URI with an ampersand, and an array among them repeats its key.
data/lib/HTTP/VERSION.rb CHANGED
@@ -2,5 +2,5 @@
2
2
  # HTTP::VERSION
3
3
 
4
4
  module HTTP
5
- VERSION = '1.7.1'
5
+ VERSION = '1.7.2'
6
6
  end
@@ -4,4 +4,4 @@
4
4
  # 20260713
5
5
  # 0.2.0
6
6
 
7
- require 'Thoran/Hash/XWwwFormUrlencode/x_www_form_urlencode'
7
+ require_relative '../Thoran/Hash/XWwwFormUrlencode/x_www_form_urlencode'
@@ -11,7 +11,7 @@
11
11
  # 0/1: An array value repeats its key for each element.
12
12
  # 3. ~ x_www_form_urlencode: an array value gives a pair for each of its elements, as URI.encode_www_form does, rather than one pair holding the array's inspect string, '[1, 2]'; a nil element is left out, as a nil value is.
13
13
 
14
- require 'Thoran/String/Urlencode/urlencode'
14
+ require_relative '../../String/Urlencode/urlencode'
15
15
 
16
16
  module Thoran
17
17
  module Hash
data/lib/http.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # http.rb
2
2
  # HTTP
3
3
 
4
- require 'HTTP/METHODS'
5
- require 'HTTP/VERSION'
4
+ require_relative './HTTP/METHODS'
5
+ require_relative './HTTP/VERSION'
data/test/loading_test.rb CHANGED
@@ -1,15 +1,34 @@
1
1
  # test/loading_test.rb
2
2
 
3
+ require 'fileutils'
3
4
  require 'minitest/autorun'
5
+ require 'tmpdir'
4
6
 
5
7
  require_relative '../lib/http'
6
8
 
7
9
  # In its own process, since this one has loaded the file directly and so could
8
10
  # not tell what requiring the gem by its own name would bring.
9
11
  describe 'loading' do
10
- def ruby(source)
12
+ def ruby(source, load_path: [])
11
13
  lib = File.expand_path('../lib', __dir__)
12
- IO.popen(['ruby', "-I#{lib}", '-e', source], err: [:child, :out]){|io| io.read}.strip
14
+ includes = (load_path + [lib]).map{|directory| "-I#{directory}"}
15
+ IO.popen(['ruby', *includes, '-e', source], err: [:child, :out]){|io| io.read}.strip
16
+ end
17
+
18
+ # Files of the same names as those lib/ carries, each failing if it's loaded.
19
+ def with_decoys
20
+ Dir.mktmpdir do |directory|
21
+ %w{
22
+ HTTP/METHODS.rb
23
+ HTTP/VERSION.rb
24
+ Thoran/Hash/XWwwFormUrlencode/x_www_form_urlencode.rb
25
+ Thoran/String/Urlencode/urlencode.rb
26
+ }.each do |path|
27
+ FileUtils.mkdir_p(File.join(directory, File.dirname(path)))
28
+ File.write(File.join(directory, path), "raise 'A decoy #{path} was loaded.'\n")
29
+ end
30
+ yield(directory)
31
+ end
13
32
  end
14
33
 
15
34
  # The gem is http.rb, so require 'http.rb' reads lib/http.rb. A capitalised
@@ -27,4 +46,10 @@ describe 'loading' do
27
46
  it "defines the version too" do
28
47
  _(ruby('require "http.rb"; print HTTP::VERSION')).must_equal HTTP::VERSION
29
48
  end
49
+
50
+ it "loads its own files, though others of the same names come first on the load path" do
51
+ with_decoys do |directory|
52
+ _(ruby('require "http.rb"; print HTTP::VERSION, " ", {a: [1, 2]}.x_www_form_urlencode', load_path: [directory])).must_equal "#{HTTP::VERSION} a=1&a=2"
53
+ end
54
+ end
30
55
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.1
4
+ version: 1.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - thoran