impuri 0.10.0 → 0.12.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: 6611f3db5d9b8b599247bbe6141a10bf166dfc9470ae71e9b345d11ccbb7a6ec
4
- data.tar.gz: 9745a6127cd818bace3a0ed8d9fdff86242ae01385d5f7f90dbcf655c35ebb12
3
+ metadata.gz: c72a1dd69d974933264297f60ee3a7c049384798d1ea7a03f93dee06edbc1d2a
4
+ data.tar.gz: 1f2fb098d5be4b9fa995234f82efe16a68faa0b9d085f96626d6bafef4fa357b
5
5
  SHA512:
6
- metadata.gz: 27a5b988acd092e0e9ea0b6b676a52c95678249e8e085f8a74f677c7b72bc61b846bfad343492a852ae06a67afada6c16368be9961b7d65927a70b008c881ad5
7
- data.tar.gz: 9b3eacd4a16d8d794cdbb287862a169200ea43f64637f896f2765c6ef5a98637ee749b0d19148a6a05e7db9efb1989a05b2da03134a07da79520c6b1709e2d8b
6
+ metadata.gz: 1188cc96a712f06445506d575cdb70c5d318a5cd8fe46b378aa96b7fa1a2a35d8d5287781d0be7f24f94b8f02f5d8e5414834daecc10287b276b9e22b0b06f9e
7
+ data.tar.gz: fef2af493ff7a99a0a4dad6d8abaea054d79c30de505867275f1121a279e2ce676a2d3387b979d13fc20b913d8acdbd112ca2d83303554eb065fd35698065bc8
data/CHANGELOG CHANGED
@@ -1,16 +1,39 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 20260808
4
+
5
+ 0.12.0: + ImpURI#to_ssh, for going the other way.
6
+
7
+ 1. + ImpURI#to_ssh: the same resource as an ssh/scp descriptor, being [username@]hostname:path. Parsing both forms was the point of this from the start, and there was a renderer for neither of them beyond to_s giving back what it was handed.
8
+ 2. + The two paths are not the same kind of path, which is the whole of what makes this worth a method rather than a string interpolation. After a colon, a leading slash is the difference between a path from the root and one from the login directory, so a descriptor which arrived that way is returned exactly as it came. After a slash, that slash stood between the hostname and the path rather than anchoring it, so it is not carried into a form where it would say the other thing: github.com/thoran/lineage gives github.com:thoran/lineage and not github.com:/thoran/lineage.
9
+ 3. + has_colon_path_separator? is what tells the two apart, and it was already here.
10
+ 4. + ImpURI#username_with_separator, alongside the userinfo_with_separator and credentials_with_separator which were already here. to_ssh renders the username alone: ssh has no use for a password in this position, and a port number has nowhere to go in this form either, so both are dropped along with the scheme.
11
+ 5. + Nine tests over both directions, the password, the port number, and a descriptor with no path at all, which gives hostname and a colon, that being the login directory.
12
+ 6. Written for git-boot, which had been interpolating "#{username}@#{hostname}:#{path}" and getting git@github.com:/thoran/lineage for its trouble: a URI path spliced into a position where the leading slash means something else. That is a fault in the caller and not here, but a library which parses both forms may as well render both.
13
+
3
14
  ## 20260805
4
15
 
16
+ 0.11.0: Name the entry point and the gemspec for the gem.
17
+
18
+ 1. lib/: /ImpURI.rb/impuri.rb/, so the require becomes require 'impuri' rather than require 'ImpURI'. This is the breaking change: anything using the gem must be altered. It resolves either way here, the volume being case insensitive, but not on Linux. namo, webdav and statistics.rb all name the entry point for the gem and keep the namespace directory in CamelCase, so lib/ImpURI/ is left as it is.
19
+ 2. /ImpURI.gemspec/impuri.gemspec/, and the spec.files entry with it. Invisible to anyone installing the gem, since nothing requires a gemspec.
20
+ 3. ~ tests: require 'ImpURI' --> require 'impuri'.
21
+
22
+ 0.10.1: Use let rather than instance variables set in a before block.
23
+
24
+ 1. ~ tests: before do @impuri = ... end --> let(:impuri){...}, for 25 blocks and 847 references across the two files. Nothing in lib changes, so this is a patch.
25
+ 2. Only the three names actually used were substituted, since the string literals hold http://user@example.com/ and git@github.com:thoran/ImpURI.git, and a general @word replacement would have rewritten those too.
26
+
5
27
  0.10.0: Move the tests onto the expectation form Minitest supports
6
28
 
7
29
  1. ~ tests: x.must_equal y --> _(x).must_equal y, across all 801 assertions in the two test files. The global form was Minitest reopening Object so that every object answered must_equal, which it has since removed. Minitest's own documentation prefers the wrapped form, because it carries the test context rather than reaching for a thread-local to find it.
8
30
  2. - ImpURI.gemspec: the development dependency upon minitest-global_expectations, which was added in 0.9.0 only to keep the tests running while they were in the old form.
9
31
  3. ~ tests: require 'minitest/global_expectations/autorun' --> require 'minitest/autorun'.
10
32
 
33
+
11
34
  ## 20260805
12
35
 
13
- 0.9.0: Make the gem loadable on its own, rather than only where the helper files were already on the load path
36
+ 0.9.0: Make the gem loadable on its own, rather than only where the helper files were already on the load path.
14
37
 
15
38
  1. Moved the vendored helpers from lib/ImpURI/ up into lib/, so that they sit where they are required from. 0.8.0 shipped all seventeen of them, but one directory too deep: only lib/ goes onto the load path, so require '_meta/blankQ' looked for lib/_meta/blankQ.rb while the file sat at lib/ImpURI/_meta/blankQ.rb. The gem could therefore only be loaded on a machine which already had those helpers elsewhere on the load path, which is to say mine.
16
39
  2. + lib/Thoran/String/Urlencode/urlencode.rb and lib/Thoran/Hash/XWwwFormUrlencode/x_www_form_urlencode.rb, which had never been vendored at all. 0.8.0 required String/url_encode by way of Hash/x_www_form_urlencode.rb and shipped no such file, so that require was answered by whatever the machine happened to have: my own library, or any installed gem which vendored a file at that path. Both taken from http.rb 1.3.1, which carries the current implementation.
@@ -32,9 +55,10 @@
32
55
  18. ~ tests: require 'minitest/autorun' --> require 'minitest/global_expectations/autorun'. The tests are written in the global expectations style, as in `ImpURI.username(x).must_equal 'git'`, which Minitest has since removed, so every one of the 271 of them errored and not one of the 801 assertions ran. The shim restores that style without touching the tests; rewriting them to the `_(x).must_equal` form, and dropping the dependency again, is for 0.10.0.
33
56
  19. ~ ImpURI::VERSION: /0.8.0/0.9.0/
34
57
 
58
+
35
59
  ## 20200207
36
60
 
37
- 0.8.0: Preparation for release as a gem
61
+ 0.8.0: Preparation for release as a gem.
38
62
 
39
63
  1. Moved the contents of lib/ImpURI.rbd/ImpURI.rb into lib/ImpURI.rb and changed the directory name from lib/ImpURI.rbd to lib/ImpURI, so that it has a more conventional structure and while the .rbd stuff doesn't work!
40
64
  2. /must_equal nil/must_be_nil/ in tests, due to Mintest 6 deprecation messages.
@@ -46,7 +70,7 @@
46
70
 
47
71
  ## 20140707
48
72
 
49
- 0.7.0: Enable assignment of values to component parts
73
+ 0.7.0: Enable assignment of values to component parts.
50
74
 
51
75
  1. + #scheme=.
52
76
  2. + #username=.
data/README.md CHANGED
@@ -60,6 +60,28 @@ impuri.parameters
60
60
  # => {'q' => 'param'}
61
61
  ```
62
62
 
63
+ ### Rendering
64
+
65
+ ```ruby
66
+ impuri.to_s
67
+ # => the string it was given back again
68
+
69
+ ImpURI.new('github.com/thoran/lineage').to_ssh
70
+ # => 'github.com:thoran/lineage'
71
+
72
+ ImpURI.new('git@github.com:thoran/lineage.git').to_ssh
73
+ # => 'git@github.com:thoran/lineage.git'
74
+
75
+ ImpURI.new('user@host.com:/srv/git/thing.git').to_ssh
76
+ # => 'user@host.com:/srv/git/thing.git'
77
+ ```
78
+
79
+ `#to_ssh` renders the same resource as an ssh/scp descriptor, `[username@]hostname:path`.
80
+
81
+ Where the path arrived after a colon it is left as it stands, since a leading slash there is the difference between a path from the root and one from the login directory, and an ssh descriptor is returned unchanged. Where the path arrived after a slash, that slash separated it from the hostname rather than anchoring it, and so is not carried into a form where it would say the other thing.
82
+
83
+ A scheme, a port number and a password are all dropped, this form having no place for any of them.
84
+
63
85
  ## Contributing
64
86
 
65
87
  1. Fork it ( https://github.com/thoran/impuri/fork )
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.require_paths = ['lib']
23
23
 
24
24
  spec.files = [
25
- 'ImpURI.gemspec',
25
+ 'impuri.gemspec',
26
26
  'CHANGELOG',
27
27
  'Gemfile',
28
28
  'README.md',
@@ -2,5 +2,5 @@
2
2
  # ImpURI::VERSION
3
3
 
4
4
  class ImpURI
5
- VERSION = '0.10.0'
5
+ VERSION = '0.12.0'
6
6
  end
@@ -1,4 +1,4 @@
1
- # ImpURI.rb
1
+ # impuri.rb
2
2
  # ImpURI
3
3
 
4
4
  require_relative './_meta/blankQ'
@@ -432,6 +432,20 @@ class ImpURI
432
432
  end
433
433
  end
434
434
 
435
+ def username_with_separator
436
+ has_username? ? "#{username}@" : ''
437
+ end
438
+
439
+ # A path which arrived after a colon is left as it stands, a leading slash there being the difference between a path from the root and one from the login directory. A path which arrived after a slash was separated from the hostname by it rather than anchored by it, and so it is not carried into a form where it would mean the other thing.
440
+ def ssh_path
441
+ has_colon_path_separator? ? path : path.to_s.sub(%r{\A/}, '')
442
+ end
443
+
444
+ # The same resource as an ssh/scp descriptor, being [username@]hostname:path. A port number has no place in this form and is dropped, as is a password, ssh having no use for one here.
445
+ def to_ssh
446
+ "#{username_with_separator}#{hostname}:#{ssh_path}"
447
+ end
448
+
435
449
  def to_h
436
450
  {scheme: scheme, username: username, password: password, hostname: hostname, port_number: port_number, path: path, parameter_string: parameter_string}
437
451
  end