impuri 0.8.0 → 0.9.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: 40ca40d65673baa8fd1e3e0ce1106e66ab63ca2d9aed70cbab13ace1b8c116db
4
- data.tar.gz: 4604c7ea0f54a85b99a17fb9c93d864c911ccc950d3d4f622cf4a8a0edca9b26
3
+ metadata.gz: 44fb3692e45dc1de42d26f18c4a134fe6337e58333f7c69587e511e26530ecd4
4
+ data.tar.gz: 83726d475b88fc52c4ab0860639da6a80f363de6c162e71c32993d5dab7eebad
5
5
  SHA512:
6
- metadata.gz: 6be56f6d68e9d44f190798b7f508e4d86fc4b5f67a15305e20a114c692a4070ef6e79259407e13d468d888dedfa5ccebf63d5ed8a6a4943442fb79e4b924a150
7
- data.tar.gz: 0b173b0184b505df469f7183eb1d73cd79b020af261691601b2346e3bc09696d970ee00a6096577fe5d0d78d0c7f1e971ff953e2ea26818f46a344b1bffd948d
6
+ metadata.gz: 3d4d7434d832be7a361cd53699904cef3c892b9c09a6a76ba853422cf4b18218718afe20167d4c0545c6b66f339fec7007e815e2574a48daa3323e8ef841c6df
7
+ data.tar.gz: 7a03f5beb223d87fc130aed2fa04f346eabe0236173bc4a6285b8d7206357ce44655644d1810f631cab6a36c3721e786199b83b7500e719983d31f360c7390c8
data/CHANGELOG ADDED
@@ -0,0 +1,74 @@
1
+ # CHANGELOG
2
+
3
+ ## 20260805
4
+
5
+ 0.9.0: Make the gem loadable on its own, rather than only where the helper files were already on the load path
6
+
7
+ 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.
8
+ 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.
9
+ 3. ~ lib/Hash/x_www_form_urlencode.rb: the 2013 implementation replaced by the shim which requires the namespaced one. The old one called url_encode and then gsub'd spaces to plus signs, which url_encode had already done; the replacement drops that, and encodes identically.
10
+ 4. ~ lib/ImpURI.rb: require --> require_relative for the helpers and for VERSION, so that loading no longer depends upon the load path at all. lib/ImpURI.rb keeps its name, so `require 'ImpURI'` is unchanged and nothing which already uses the gem need be touched.
11
+ 5. - lib/ImpURI.rb: $LOAD_PATH.unshift, which was there to make the plain requires work and never could, since it added lib/ while the files were under lib/ImpURI/.
12
+ 6. - lib/ImpURI.rb: the date, version and description comments, the version now being kept only in lib/ImpURI/VERSION.rb.
13
+ 7. ~ ImpURI.gemspec: spec.version now reads ImpURI::VERSION, so that the version is declared in one place.
14
+ 8. - ImpURI.gemspec: spec.has_rdoc, which RubyGems has removed, and which aborted `gem build` outright.
15
+ 9. - ImpURI.gemspec: spec.date, which was stamped 2020-02-07 and is better left for the build to set.
16
+ 10. ~ ImpURI.gemspec: spec.required_ruby_version, 1.8.6 --> 2.7.
17
+ 11. ~ ImpURI.gemspec: spec.description shortened, and spec.homepage http --> https.
18
+ 12. ~ ImpURI.gemspec: spec.files now lists the gemspec, CHANGELOG, README.md and TODO.txt alongside lib and test, rather than lib alone, and + spec.require_paths, so as this matches the other gems. The tests now ship, and so can be run from the unpacked gem.
19
+ 13. + Gemfile, so as the development dependencies declared above are acted upon rather than merely stated. Without one nothing reads them, and a plain ruby lets any of the installed gems answer a require: RubyGems indexes every installed gem by the paths it provides, and activates whichever one answers. Under bundle exec only the resolved bundle is visible, which is how a require this does not declare fails here rather than for whoever installs it. Had this been developed so, the missing String/url_encode would have raised in 2020 instead of being answered by an unrelated gem.
20
+ 14. /CHANGES.txt/CHANGELOG/, and the entries reordered so as the most recent comes first.
21
+ 15. ~ .gitignore, filled out for Ruby.
22
+ 16. ~ README.md: trailing whitespace removed.
23
+ 17. + ImpURI.gemspec: development dependencies upon minitest and minitest-global_expectations, and the Gem::Specification#development_dependencies= helper to declare them.
24
+ 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.
25
+ 19. ~ ImpURI::VERSION: /0.8.0/0.9.0/
26
+
27
+ ## 20200207
28
+
29
+ 0.8.0: Preparation for release as a gem
30
+
31
+ 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!
32
+ 2. /must_equal nil/must_be_nil/ in tests, due to Mintest 6 deprecation messages.
33
+ 3. Changes comments moved from lib/ImpURI.rb --> CHANGES.txt. (ie. This file!)
34
+ 4. /README/README.md/
35
+ 5. + lib/ImpURI/VERSION.rb
36
+ 6. + ImpURI.gemspec, so this is now a gem. Finally!
37
+
38
+
39
+ ## 20140707
40
+
41
+ 0.7.0: Enable assignment of values to component parts
42
+
43
+ 1. + #scheme=.
44
+ 2. + #username=.
45
+ 3. + #password=.
46
+ 4. + #hostname=.
47
+ 5. + #port_number=.
48
+ 6. + #path=.
49
+ 7. + #parameter_string=.
50
+ 8. + #parameters=.
51
+ 9. + #request_uri=.
52
+ 10. + require 'Hash/x_www_form_urlencode'.
53
+ 11. ~ self.has_username?, so that it works more correctly.
54
+ 12. ~ #scheme_with_separator, so that it is defined in terms of it's component parts, rather than making use of the class methods.
55
+ 13. ~ #userinfo, so that it is defined in terms of it's component parts, rather than making use of the class methods.
56
+ 14. ~ #userinfo_with_separator, so that it is defined in terms of it's component parts, rather than making use of the class methods.
57
+ 15. ~ #hostname_optionally_with_port_number, so that it is defined in terms of it's component parts, rather than making use of the class methods.
58
+ 16. ~ #hostname_and_path, so that it is defined in terms of it's component parts, rather than making use of the class methods.
59
+ 17. ~ #hostname_and_port_number, so that it is defined in terms of it's component parts, rather than making use of the class methods.
60
+ 18. ~ #all_but_scheme, so that it is defined in terms of it's component parts, rather than making use of the class methods.
61
+ 19. ~ #to_s, so that it is defined in terms of it's component parts, rather than making use of the class methods.
62
+ 20. ~ #to_h, so that it includes parameter_string.
63
+ 21. ~ #to_s, so that it makes use of #all_but_scheme, and includes parameter_string.
64
+ 22. + alias_methods for #has_semicolon_parameter_separator?.
65
+ 23. + alias #ssh? for #is_ssh?.
66
+ 24. ~ #has_scheme?, so that it tests the local component value, rather than using the corresponding class method.
67
+ 25. ~ #has_port_number?, so that it tests the local component value, rather than using the corresponding class method.
68
+ 26. ~ #has_parameters?, so that it tests the local component value, rather than using the corresponding class method.
69
+ 27. + #has_username?.
70
+ 28. + #has_password?.
71
+ 29. + #has_hostname?.
72
+ 30. + #has_path?.
73
+ 31. + #has_parameter_string?.
74
+ 32. + #hostname_optionally_with_port_number, for use in #all_but_scheme.
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/ImpURI.gemspec ADDED
@@ -0,0 +1,38 @@
1
+ require_relative './lib/ImpURI/VERSION'
2
+
3
+ class Gem::Specification
4
+ def development_dependencies=(gems)
5
+ gems.each{|gem| add_development_dependency(*gem)}
6
+ end
7
+ end
8
+
9
+ Gem::Specification.new do |spec|
10
+ spec.name = 'impuri'
11
+ spec.version = ImpURI::VERSION
12
+
13
+ spec.summary = "This is a hand-written non-validating parser for URI's and ssh/scp almost URI resource descriptors."
14
+ spec.description = "This is a hand-written non-validating parser for URI's and ssh/scp almost URI resource descriptors, which is intended to be cleaner and simpler than Ruby's standard URI."
15
+
16
+ spec.author = 'thoran'
17
+ spec.email = 'code@thoran.com'
18
+ spec.homepage = 'https://github.com/thoran/ImpURI'
19
+ spec.license = 'MIT'
20
+
21
+ spec.required_ruby_version = '>= 2.7'
22
+ spec.require_paths = ['lib']
23
+
24
+ spec.files = [
25
+ 'ImpURI.gemspec',
26
+ 'CHANGELOG',
27
+ 'Gemfile',
28
+ 'README.md',
29
+ 'TODO.txt',
30
+ Dir['lib/**/*.rb'],
31
+ Dir['test/**/*.rb']
32
+ ].flatten
33
+
34
+ spec.development_dependencies = [
35
+ ['minitest', '~> 6.0'],
36
+ ['minitest-global_expectations', '~> 1.0']
37
+ ]
38
+ end
data/README.md ADDED
@@ -0,0 +1,69 @@
1
+ # ImpURI
2
+
3
+ ## Description
4
+
5
+ This is a hand-written non-validating parser for URI's and ssh/scp almost URI resource descriptors which is intended to be cleaner and simpler than Ruby's standard URI.
6
+
7
+ ## Raison d'etre
8
+
9
+ I wrote it for two reasons...
10
+
11
+ 1. Ruby's standard URI library doesn't handle ssh/scp resource descriptors, which are the near-to, not quite URI, but commonly used, ssh/scp way of describing a network addressable resource: username:password@host:path. URI's have a scheme at the start, and the path begins with only a forward slash, whereas an ssh/scp resource has no scheme, and the path begins with a colon and a slash. I wanted to be able to handle both.
12
+
13
+ 2. Ruby's standard URI class does too much. It is overblown and untidy. I just want it to break the strings down and that's it. I don't want any scheme interpolation from the port number, nor from the host name, or any other 'smarts'.
14
+
15
+ ## Installation
16
+
17
+ Add this line to your application's Gemfile:
18
+
19
+ gem 'impuri'
20
+
21
+ And then execute:
22
+
23
+ $ bundle
24
+
25
+ Or install it yourself as:
26
+
27
+ $ gem install impuri
28
+
29
+ ## Usage
30
+
31
+ ```ruby
32
+ impuri = ImpURI.parse('scheme://user:pass@hostname.domain.name:20/path/to/resource?q=param')
33
+ # => an object of class ImpURI
34
+
35
+ impuri.scheme OR impuri.protocol
36
+ # => 'scheme'
37
+
38
+ impuri.userinfo OR impuri.credentials OR impuri.user_info OR impuri.username_and_password
39
+ # => 'user:pass'
40
+
41
+ impuri.user OR impuri.username
42
+ # => 'user'
43
+
44
+ impuri.pass OR impuri.passwd OR impuri.password
45
+ # => 'pass'
46
+
47
+ impuri.host OR impuri.hostname
48
+ # => 'hostname.domain.name'
49
+
50
+ impuri.port OR impuri.portnumber OR impuri.port_number
51
+ # => '20'
52
+
53
+ impuri.path
54
+ # => '/path/to/resource'
55
+
56
+ impuri.parameter_string
57
+ # => 'q=param'
58
+
59
+ impuri.parameters
60
+ # => {'q' => 'param'}
61
+ ```
62
+
63
+ ## Contributing
64
+
65
+ 1. Fork it ( https://github.com/thoran/impuri/fork )
66
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
67
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
68
+ 4. Push to the branch (`git push origin my-new-feature`)
69
+ 5. Create a new pull request
data/TODO.txt ADDED
@@ -0,0 +1,6 @@
1
+ 1. Handle port numbers. Done as of 0.1.0.
2
+ 2. Create strict and non-strict parsing modes, which will either accept or reject non-URI ssh/scp formatted strings if they are supplied. Done as of 0.2.0.
3
+ 3. Doesn't handle some of the funkier URI's like: ssh:// with keys in the userinfo section, mailto: (no ://, but merely :), and ldap://.
4
+ 4. Consider encoding everything in the URI before breaking down the strings, so as to avoid the kind of complexity introduced in ImpURI.has_userinfo?().
5
+ 5. Be able to change the semicolon parameter separator for an ImpURI instance.
6
+ 6. Be able to change the colon path separator for an ImpURI instance, say if converting from ssh-form to the URI-form of an ssh resource for instance. Any other uses?
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,7 @@
1
+ # Hash/x_www_form_urlencode.rb
2
+ # Hash#x_www_form_urlencode
3
+
4
+ # 20260713
5
+ # 0.2.0
6
+
7
+ require 'Thoran/Hash/XWwwFormUrlencode/x_www_form_urlencode'
@@ -2,5 +2,5 @@
2
2
  # ImpURI::VERSION
3
3
 
4
4
  class ImpURI
5
- VERSION = '0.8.0'
5
+ VERSION = '0.9.0'
6
6
  end
data/lib/ImpURI.rb CHANGED
@@ -1,21 +1,14 @@
1
1
  # ImpURI.rb
2
2
  # ImpURI
3
3
 
4
- # 20200207
5
- # 0.8.0
6
-
7
- # Description: A cleaner and simpler URI and ssh/scp resource parser for Ruby. Though I'm not sure about the simpler bit anymore. It's now over 500 lines you know!
8
-
9
- $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')))
10
-
11
- require '_meta/blankQ'
12
- require 'Array/all_but_first'
13
- require 'Array/all_but_last'
14
- require 'Array/extract_optionsX'
15
- require 'Hash/x_www_form_urlencode'
16
- require 'Module/alias_methods'
17
-
18
- require 'ImpURI/VERSION'
4
+ require_relative './_meta/blankQ'
5
+ require_relative './Array/all_but_first'
6
+ require_relative './Array/all_but_last'
7
+ require_relative './Array/extract_optionsX'
8
+ require_relative './Hash/x_www_form_urlencode'
9
+ require_relative './Module/alias_methods'
10
+
11
+ require_relative './ImpURI/VERSION'
19
12
 
20
13
  class ImpURI
21
14
 
File without changes
@@ -0,0 +1,27 @@
1
+ # Thoran/Hash/XWwwFormUrlencode/x_www_form_urlencode.rb
2
+ # Thoran::Hash::XWwwFormUrlencode#x_www_form_urlencode
3
+
4
+ # 20260713
5
+ # 0.3.0
6
+
7
+ # Changes since 0.2:
8
+ # -/0: (The class name and the snake case name really are consistent now.)
9
+ # 1. /XWwwFormUrlEncode/XWwwFormUrlencode/
10
+ # 2. /url_encode/urlencode/
11
+
12
+ require 'Thoran/String/Urlencode/urlencode'
13
+
14
+ module Thoran
15
+ module Hash
16
+ module XWwwFormUrlencode
17
+
18
+ def x_www_form_urlencode(joiner = '&')
19
+ inject([]){|a,e| a << "#{e.first.to_s.urlencode}=#{e.last.to_s.urlencode}" unless e.last.nil?; a}.join(joiner)
20
+ end
21
+ alias_method :x_www_form_url_encode, :x_www_form_urlencode
22
+
23
+ end
24
+ end
25
+ end
26
+
27
+ Hash.send(:include, Thoran::Hash::XWwwFormUrlencode)
@@ -0,0 +1,29 @@
1
+ # Thoran/String/Urlencode/urlencode.rb
2
+ # Thoran::String::Urlencode#urlencode
3
+
4
+ # 20260713
5
+ # 0.4.0
6
+
7
+ # Acknowledgements: I've simply ripped off and refashioned the code from the CGI module!...
8
+
9
+ # Changes since 0.3:
10
+ # -/0: More consistent naming.
11
+ # 1. /UrlEncode/Urlencode/
12
+ # 2. /url_encode/urlencode/
13
+
14
+ module Thoran
15
+ module String
16
+ module Urlencode
17
+
18
+ def urlencode
19
+ self.gsub(/([^ a-zA-Z0-9_.-]+)/n) do
20
+ '%' + $1.unpack('H2' * $1.size).join('%').upcase
21
+ end.tr(' ', '+')
22
+ end
23
+ alias_method :url_encode, :urlencode
24
+
25
+ end
26
+ end
27
+ end
28
+
29
+ String.send(:include, Thoran::String::Urlencode)