fustigit 0.1.3 → 0.3.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
- SHA1:
3
- metadata.gz: c751ca9b2b4344d7ffdfe8135e75415cc6c56e17
4
- data.tar.gz: 59c43e03ed9c4c51507bf4db11d54c3a47bb7979
2
+ SHA256:
3
+ metadata.gz: a001868c87f7c087d968121a2fda96b844ea25913e7dcdb72eb1693a758aeec7
4
+ data.tar.gz: 7b62afbd47f09af6912c714f99fc4eee50f0389318250c06b5ad9bdd8aa218bb
5
5
  SHA512:
6
- metadata.gz: 19fcae6c47cbc194ec192839a64f85bae11d26431d2a2215c56f5314f34f37d406389e49b543a7b72a6bef0dce40a282925860b1bfbd523c8edc0860c9e5630f
7
- data.tar.gz: f52b1964f4dd1fe5ba16000d20eb75172afd0b8ba89951985fadfc8f65ef95a21c77f3cb3e3a83edd946ba710acfc6311ad659441a713dfef5205fbfe6eb9eb8
6
+ metadata.gz: b8e293b6873be3478c0217713d6863be53589a1e06726bda8697be709ae8f4167198243824527342f75d739d8c5562f2739fcd4df1949b8582ad397e07da3b6f
7
+ data.tar.gz: 014c3dfcf9a79842a31df6cdd035ad4395dde4b6ab4496261ef76657635d1a66405bb1ecbd3d45f4479e0649cbe519068ec13cfaa2e96eba78e34b718926825b
data/CHANGELOG.md CHANGED
@@ -3,9 +3,22 @@ All notable changes to this project will be documented in this file.
3
3
  This project attempts to adhere to [Semantic Versioning](http://semver.org/).
4
4
  This changelog attempts to adhere to [Keep a CHANGELOG](http://keepachangelog.com/).
5
5
 
6
+ ## [0.2.0] - 24 October 2019
7
+ ### Changed
8
+ - Updated semantics to address use of frozen string literals
9
+ - Updated minitest semantics to address global `must_equal` deprecations
10
+ - Dropped support for Ruby versions older than 2.5.0
11
+ - Numerous Rubocop related fixups
12
+
13
+ ## [0.1.4] - 06 March 2017
14
+ ### Added
15
+ - Fixed a missing '-' in the regex pattern that defined the parts of a triplet
16
+ - Numerous Rubocop related fixups
17
+
6
18
  ## [0.1.3] - 07 July 2016
7
19
  ### Added
8
20
  - Triplets#split method returns the expected array of values for parsed triplets
21
+
9
22
  ### Changed
10
23
  - Improved Triplets#triplet? functionality
11
24
 
@@ -23,3 +36,9 @@ This changelog attempts to adhere to [Keep a CHANGELOG](http://keepachangelog.co
23
36
  ### Added
24
37
  - Initial release
25
38
  - README covers usage, licensing, and rationale
39
+
40
+ [0.1.4]: https://github.com/mckern/fustigit/compare/0.1.3...0.1.4
41
+ [0.1.3]: https://github.com/mckern/fustigit/compare/0.1.2...0.1.3
42
+ [0.1.2]: https://github.com/mckern/fustigit/compare/0.1.1...0.1.2
43
+ [0.1.1]: https://github.com/mckern/fustigit/compare/0.1.0...0.1.1
44
+ [0.1.0]: https://github.com/mckern/fustigit/tree/0.1.0
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2014-2016 Ryan McKern
1
+ Copyright 2014-2022 Ryan McKern
2
2
 
3
3
  Licensed under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License.
data/README.md CHANGED
@@ -6,17 +6,17 @@
6
6
  <dd>To criticize harshly.</dd>
7
7
  </dl>
8
8
 
9
- [![Build Status](https://travis-ci.org/mckern/fustigit.svg?branch=master)](https://travis-ci.org/mckern/fustigit)
9
+ [![Test & Lint](https://github.com/mckern/fustigit/actions/workflows/tests.yaml/badge.svg)](https://github.com/mckern/fustigit/actions/workflows/tests.yaml)
10
10
 
11
11
  ### TL;DR
12
12
 
13
- Fustigit will let you "parse" SCP-like address triplets using Ruby's baked-in [URI library](http://ruby-doc.org/stdlib-2.3.1/libdoc/uri/rdoc/index.html) (... and just a *moderate* amount of monkey-patching) and turn them into probably-valid URI objects.
13
+ Fustigit will let you "parse" SCP-like address triplets using Ruby's baked-in [URI library](https://ruby-doc.org/stdlib-2.5.7/libdoc/uri/rdoc/index.html) (... and just a *moderate* amount of monkey-patching) and turn them into probably-valid URI objects.
14
14
 
15
15
  ### What's a Triplet?
16
16
 
17
- <a href="https://www.debuggex.com/r/UF-0ESZoWXFewi8q"><img src="https://www.debuggex.com/i/UF-0ESZoWXFewi8q.png"></a>
17
+ <a href="https://www.debuggex.com/r/NtHqyDI9LUz-UMia"><img src="readme/railroad-diagram.jpg"></a>
18
18
 
19
- A triplet is a format for specifying a remote resource, much like a URI. It looks like this:
19
+ A triplet is a format for specifying a remote resource, much like a URI. It looks like this:
20
20
 
21
21
  # The username is optional but the hostname and pathname are not
22
22
  <username>@<hostname>:<pathname>
@@ -59,7 +59,7 @@ URI::InvalidURIError: bad URI(is not URI?): git@github.com:mckern/fustigit.git [
59
59
  => "mckern/fustigit.git"
60
60
  >> uri.to_s
61
61
  => "git@github.com:mckern/fustigit.git"
62
- >>
62
+ >>
63
63
  ```
64
64
 
65
65
  ### How (does it work)?
@@ -76,11 +76,11 @@ In the spirit of Jordan Sissel (a hero to admins and operations people everywher
76
76
 
77
77
  ### License
78
78
 
79
- Fustigate is licensed under the Apache License, Version 2.0.
79
+ Fustigate is licensed under the Apache License, Version 2.0.
80
80
 
81
- > "When in doubt, use brute force."
81
+ > "When in doubt, use brute force."
82
82
  > &#8213; <cite>Ken Thompson</cite>
83
83
 
84
84
  ### Maintainer
85
85
 
86
- Ryan McKern &lt;ryan@orangefort.com&gt;
86
+ Ryan McKern &lt;ryan@mckern.sh&gt;
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Fustigit
2
4
  module Version
3
- VERSION = "0.1.3".freeze
5
+ VERSION = "0.3.0"
4
6
  end
5
7
  end
data/lib/fustigit.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "uri/triplets"
2
4
  require "uri/git"
3
5
  require "uri/scp"
data/lib/uri/git.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "uri/generic"
2
4
 
3
5
  module URI
@@ -7,11 +9,15 @@ module URI
7
9
  DEFAULT_PORT = 9418
8
10
  USE_REGISTRY = false
9
11
 
10
- COMPONENT = [
11
- :scheme,
12
- :userinfo,
13
- :host, :port, :path
12
+ COMPONENT = %i[
13
+ scheme
14
+ userinfo
15
+ host port path
14
16
  ].freeze
15
17
  end
16
- @@schemes["GIT"] = Git
18
+ if respond_to? :register_scheme
19
+ register_scheme "GIT", Git
20
+ else
21
+ @@schemes["GIT"] = Git
22
+ end
17
23
  end
data/lib/uri/rsync.rb CHANGED
@@ -1,8 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "uri/generic"
2
4
 
3
5
  module URI
4
6
  class RSYNC < Generic
5
7
  DEFAULT_PORT = 873
6
8
  end
7
- @@schemes["RSYNC"] = RSYNC
9
+ if respond_to? :register_scheme
10
+ register_scheme "RSYNC", RSYNC
11
+ else
12
+ @@schemes["RSYNC"] = RSYNC
13
+ end
8
14
  end
data/lib/uri/scp.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "uri/generic"
2
4
 
3
5
  module URI
@@ -6,11 +8,15 @@ module URI
6
8
 
7
9
  DEFAULT_PORT = 22
8
10
 
9
- COMPONENT = [
10
- :scheme,
11
- :userinfo,
12
- :host, :port, :path
11
+ COMPONENT = %i[
12
+ scheme
13
+ userinfo
14
+ host port path
13
15
  ].freeze
14
16
  end
15
- @@schemes["SCP"] = SCP
17
+ if respond_to? :register_scheme
18
+ register_scheme "SCP", SCP
19
+ else
20
+ @@schemes["SCP"] = SCP
21
+ end
16
22
  end
data/lib/uri/ssh.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "uri/generic"
2
4
 
3
5
  module URI
@@ -6,11 +8,15 @@ module URI
6
8
 
7
9
  DEFAULT_PORT = 22
8
10
 
9
- COMPONENT = [
10
- :scheme,
11
- :userinfo,
12
- :host, :port, :path
11
+ COMPONENT = %i[
12
+ scheme
13
+ userinfo
14
+ host port path
13
15
  ].freeze
14
16
  end
15
- @@schemes["SSH"] = SSH
17
+ if respond_to? :register_scheme
18
+ register_scheme "SSH", SSH
19
+ else
20
+ @@schemes["SSH"] = SSH
21
+ end
16
22
  end
data/lib/uri/triplets.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "uri"
2
4
 
3
5
  # Triplets is a mix-in for subclasses of URI::Generic, which
@@ -9,9 +11,10 @@ module Triplets
9
11
  # @return [String] a string representation of the URI components
10
12
  # as an SCP-style Triplet
11
13
  def triplet
12
- str = ""
14
+ str = []
13
15
  str << "#{user}@" if user && !user.empty?
14
16
  str << "#{host}:#{path}".squeeze("/")
17
+ str.join
15
18
  end
16
19
  private :triplet
17
20
 
@@ -19,7 +22,7 @@ module Triplets
19
22
  # as a valid RFC compliant URI
20
23
  # rubocop:disable Metrics/AbcSize
21
24
  def rfc_uri
22
- str = ""
25
+ str = []
23
26
  str << "#{scheme}://" if scheme
24
27
  str << "#{user}@" if user
25
28
  if port && port != self.class::DEFAULT_PORT
@@ -28,11 +31,14 @@ module Triplets
28
31
  else
29
32
  str << [host, path].join("/").squeeze("/")
30
33
  end
34
+ str.join
31
35
  end
32
36
  private :rfc_uri
37
+ # rubocop:enable Metrics/AbcSize
33
38
 
34
39
  def to_s
35
40
  return triplet if triplet?
41
+
36
42
  rfc_uri
37
43
  end
38
44
 
@@ -40,7 +46,7 @@ module Triplets
40
46
  # if this is a valid triplet.
41
47
  def triplet?
42
48
  # False if self matches a normal URI scheme
43
- !(rfc_uri =~ URI.parser.const_get(:SCHEME)) &&
49
+ rfc_uri !~ URI.parser.const_get(:SCHEME) &&
44
50
  # False unless self matches a Triplet scheme
45
51
  !!(triplet =~ URI.parser.const_get(:TRIPLET))
46
52
  end
@@ -54,13 +60,14 @@ end
54
60
  # they're passed.
55
61
  module TripletInterruptus
56
62
  # Determine if a string can be teased apart into URI-like components
57
- TRIPLET = %r{\A(?:(?<userinfo>.+)[@]+)?(?<host>[\w.]+):(?<path>.*)\z}
63
+ TRIPLET = %r{\A(?:(?<userinfo>.+)@+)?(?<host>[\w.-]+):(?<path>.*)\z}.freeze
58
64
 
59
65
  # Determine if a string is prefixed with a URI scheme like http:// or ssh://
60
- SCHEME = %r{\A(?:(?<scheme>[a-z]+)://)}
66
+ SCHEME = %r{\A(?:(?<scheme>[a-z]+)://)}.freeze
61
67
 
62
68
  def parse(uri)
63
69
  return build_triplet(uri) if triplet?(uri)
70
+
64
71
  super(uri)
65
72
  end
66
73
 
@@ -79,6 +86,7 @@ module TripletInterruptus
79
86
  def build_triplet(address)
80
87
  values = parse_triplet(address)
81
88
  return nil unless values
89
+
82
90
  URI.scheme_list[URI.default_triplet_type].build(values)
83
91
  end
84
92
  private :build_triplet
@@ -86,13 +94,14 @@ module TripletInterruptus
86
94
  def parse_triplet(address)
87
95
  parts = address.match(TRIPLET)
88
96
  return nil unless parts
89
- Hash[parts.names.map(&:to_sym).zip(parts.captures)]
97
+
98
+ parts.names.map(&:to_sym).zip(parts.captures).to_h
90
99
  end
91
100
  private :parse_triplet
92
101
  end
93
102
 
94
103
  module TripletHandling
95
- TRIPLET_CLASSES = %w(Git SCP SSH).freeze
104
+ TRIPLET_CLASSES = %w[Git SCP SSH].freeze
96
105
 
97
106
  def self.included(base)
98
107
  base.extend(TripletHandling)
@@ -103,15 +112,15 @@ module TripletHandling
103
112
  end
104
113
 
105
114
  def default_triplet_type=(value)
106
- unless TRIPLET_CLASSES.include?(value)
107
- raise ArgumentError, "'#{value}' is not one of: #{TRIPLET_CLASSES.join(', ')}"
108
- end
115
+ raise ArgumentError, "'#{value}' is not one of: #{TRIPLET_CLASSES.join(', ')}" unless TRIPLET_CLASSES.include?(value)
116
+
109
117
  @default_triplet_type = value
110
118
  end
111
119
 
112
120
  def parser
113
121
  return URI::RFC3986_Parser if
114
122
  Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.2.0")
123
+
115
124
  URI::Parser
116
125
  end
117
126
  end
@@ -129,10 +138,11 @@ module URI
129
138
  # fall through to the original URI::Parser.parse method.
130
139
  #
131
140
  if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.2.0")
132
- # rubocop:disable Style/ClassAndModuleCamelCase
141
+ # rubocop:disable Naming/ClassAndModuleCamelCase
133
142
  class RFC3986_Parser
134
143
  prepend TripletInterruptus
135
144
  end
145
+ # rubocop:enable Naming/ClassAndModuleCamelCase
136
146
  else
137
147
  class Parser
138
148
  prepend TripletInterruptus
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fustigit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan McKern
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-12 00:00:00.000000000 Z
11
+ date: 2022-06-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: '"Parse" SCP-like address triplets with the Standard Ruby URI Library.'
14
- email: ryan@orangefort.com
14
+ email: ryan@mckern.sh
15
15
  executables: []
16
16
  extensions: []
17
17
  extra_rdoc_files: []
@@ -19,7 +19,6 @@ files:
19
19
  - CHANGELOG.md
20
20
  - LICENSE
21
21
  - README.md
22
- - Rakefile
23
22
  - lib/fustigit.rb
24
23
  - lib/fustigit/version.rb
25
24
  - lib/uri/git.rb
@@ -27,13 +26,12 @@ files:
27
26
  - lib/uri/scp.rb
28
27
  - lib/uri/ssh.rb
29
28
  - lib/uri/triplets.rb
30
- - spec/spec_helper.rb
31
- - spec/uri/fustigit_spec.rb
32
29
  homepage: http://github.com/mckern/fustigit
33
30
  licenses:
34
31
  - Apache-2.0
35
- metadata: {}
36
- post_install_message:
32
+ metadata:
33
+ rubygems_mfa_required: 'true'
34
+ post_install_message:
37
35
  rdoc_options: []
38
36
  require_paths:
39
37
  - lib
@@ -41,20 +39,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
41
39
  requirements:
42
40
  - - ">="
43
41
  - !ruby/object:Gem::Version
44
- version: 2.1.0
42
+ version: 2.7.0
45
43
  required_rubygems_version: !ruby/object:Gem::Requirement
46
44
  requirements:
47
45
  - - ">="
48
46
  - !ruby/object:Gem::Version
49
47
  version: '0'
50
48
  requirements: []
51
- rubyforge_project:
52
- rubygems_version: 2.6.6
53
- signing_key:
49
+ rubygems_version: 3.3.11
50
+ signing_key:
54
51
  specification_version: 3
55
52
  summary: Use URI to "parse" SCP-like triplets
56
- test_files:
57
- - Rakefile
58
- - spec/spec_helper.rb
59
- - spec/uri/fustigit_spec.rb
60
- has_rdoc:
53
+ test_files: []
data/Rakefile DELETED
@@ -1,30 +0,0 @@
1
- require "bundler/setup"
2
- require "bundler/gem_tasks"
3
- require "rake/testtask"
4
- require "rubocop/rake_task"
5
-
6
- desc "Test fustigit"
7
- namespace :test do
8
- Rake::TestTask.new(:spec) do |test|
9
- test.libs << "spec"
10
- test.pattern = "spec/**/*_spec.rb"
11
- test.verbose = false
12
- test.warning = false
13
- end
14
-
15
- desc "Test fustigit and calculate test coverage"
16
- task :coverage do
17
- ENV["COVERAGE"] = "true"
18
- Rake::Task["test:spec"].invoke
19
- end
20
- end
21
-
22
- desc "Run RuboCop"
23
- RuboCop::RakeTask.new(:rubocop) do |task|
24
- task.patterns = ["lib/**/*.rb"]
25
- end
26
-
27
- desc "Run all spec tests and linters"
28
- task check: %w(test:spec rubocop)
29
-
30
- task default: :check
data/spec/spec_helper.rb DELETED
@@ -1,22 +0,0 @@
1
- require "bundler/setup"
2
- require "minitest/spec"
3
- require "minitest/autorun"
4
- require "minitest/reporters"
5
- require "simplecov"
6
- require "json"
7
-
8
- Minitest::Reporters.use! Minitest::Reporters::DefaultReporter.new
9
-
10
- if ENV["COVERAGE"]
11
- SimpleCov.start do
12
- # exclude common Bundler locations
13
- %w(.bundle vendor).each { |dir| add_filter dir }
14
- # exclude test code
15
- add_filter "spec"
16
- end
17
- end
18
-
19
- def fixture(path)
20
- path = File.join(File.dirname(__FILE__), "fixtures", path)
21
- File.read(path)
22
- end
@@ -1,35 +0,0 @@
1
- require "spec_helper"
2
- require "fustigit"
3
-
4
- describe URI do
5
- @git_repos = JSON.load(fixture("formats.json"))
6
- @git_repos["URIs"].each do |protocol, repos|
7
- repos.each do |repo|
8
- describe %(#parse takes given URI "#{repo}") do
9
- it "returns URI::#{protocol}" do
10
- URI.parse(repo).is_a?(URI.const_get(protocol)).must_equal true
11
- end
12
- end
13
- end
14
- end
15
-
16
- @git_repos["paths"].each do |repo|
17
- describe %(#parse takes path "#{repo}") do
18
- it "returns URI::Generic" do
19
- URI.parse(repo).is_a?(URI::Generic).must_equal true
20
- end
21
- end
22
- end
23
-
24
- @git_repos["triplets"].each do |repo|
25
- describe %(#parse takes triplet "#{repo}") do
26
- it "returns URI::#{URI.default_triplet_type}" do
27
- URI.parse(repo).is_a?(URI.const_get(URI.default_triplet_type)).must_equal true
28
- end
29
-
30
- it "recognizes URI::#{URI.default_triplet_type} as a triplet" do
31
- URI.parse(repo).triplet?.must_equal true
32
- end
33
- end
34
- end
35
- end