fustigit 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 964ec3d04e73940b8671a777029aaf1f1cd3b8ee
4
- data.tar.gz: 06e01972ce77d819da1a917d1a0bca7da6f3cca6
2
+ SHA256:
3
+ metadata.gz: 2521507f0a39cbeab8a60b250612e02c0bf5e42fc38afa9be6a16f348bfd3078
4
+ data.tar.gz: f892592872e5592f192720c5175542d804dce14daf7a1d56084073e2f6225c1b
5
5
  SHA512:
6
- metadata.gz: eedc38d0fc5685834c186c8c8917c0a934a11fa28be2e37ce6f3efe40cc3a9604ed71f9adb73e589c90e37b07ad2e97738a8562681d3b0c12631867f74918876
7
- data.tar.gz: e8e4cc9409423169bdba3671b25c39d11ba623a251057121d9ac0692258a20a61a1e696d5c904633e82b51716b1b9f81f8b44c2a48d3fa06c3afdaf59d4ef35f
6
+ metadata.gz: 7c4a55288990b7c8eb454d1a01ee6be7fffae687a9d4ab2470e6e69972e662806075c37f726f5eea7fda49219b61a22d5535fee5093bb40d0fee4e20e5810680
7
+ data.tar.gz: 1cf5ef69b396d5b7d1203d468f6a29ba6b26910480ab15a9db26f088264098a0ba868798fe6da0e1f546f2e2e5fb5abd10b21a6311b9dba72c1dd25aa0b98aa7
@@ -3,6 +3,13 @@ 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
+
6
13
  ## [0.1.4] - 06 March 2017
7
14
  ### Added
8
15
  - Fixed a missing '-' in the regex pattern that defined the parts of a triplet
data/README.md CHANGED
@@ -6,11 +6,11 @@
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
+ ![](https://github.com/mckern/fustigit/workflows/Ruby%20CI/badge.svg?branch=master)
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
 
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/setup"
2
4
  require "bundler/gem_tasks"
3
5
  require "rake/testtask"
@@ -25,6 +27,6 @@ RuboCop::RakeTask.new(:rubocop) do |task|
25
27
  end
26
28
 
27
29
  desc "Run all spec tests and linters"
28
- task check: %w(test:spec rubocop)
30
+ task check: %w[test:spec rubocop]
29
31
 
30
32
  task default: :check
@@ -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"
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Fustigit
2
4
  module Version
3
- VERSION = "0.1.4".freeze
5
+ VERSION = "0.2.0"
4
6
  end
5
7
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "uri/generic"
2
4
 
3
5
  module URI
@@ -7,10 +9,10 @@ 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
18
  @@schemes["GIT"] = Git
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "uri/generic"
2
4
 
3
5
  module URI
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "uri/generic"
2
4
 
3
5
  module URI
@@ -6,10 +8,10 @@ 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
17
  @@schemes["SCP"] = SCP
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "uri/generic"
2
4
 
3
5
  module URI
@@ -6,10 +8,10 @@ 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
17
  @@schemes["SSH"] = SSH
@@ -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
97
+
89
98
  Hash[parts.names.map(&:to_sym).zip(parts.captures)]
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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/setup"
2
4
  require "minitest/spec"
3
5
  require "minitest/autorun"
@@ -10,7 +12,7 @@ if ENV["COVERAGE"]
10
12
  require "simplecov"
11
13
  SimpleCov.start do
12
14
  # exclude common Bundler locations
13
- %w(.bundle vendor).each { |dir| add_filter dir }
15
+ %w[.bundle vendor].each { |dir| add_filter dir }
14
16
  # exclude test code
15
17
  add_filter "spec"
16
18
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "spec_helper"
2
4
  require "fustigit"
3
5
 
@@ -7,7 +9,7 @@ describe URI do # rubocop:disable Metrics/BlockLength
7
9
  repos.each do |repo|
8
10
  describe %(#parse takes given URI "#{repo}") do
9
11
  it "returns URI::#{protocol}" do
10
- URI.parse(repo).is_a?(URI.const_get(protocol)).must_equal true
12
+ _(URI.parse(repo).is_a?(URI.const_get(protocol))).must_equal true
11
13
  end
12
14
  end
13
15
  end
@@ -16,7 +18,7 @@ describe URI do # rubocop:disable Metrics/BlockLength
16
18
  @git_repos["paths"].each do |repo|
17
19
  describe %(#parse takes path "#{repo}") do
18
20
  it "returns URI::Generic" do
19
- URI.parse(repo).is_a?(URI::Generic).must_equal true
21
+ _(URI.parse(repo).is_a?(URI::Generic)).must_equal true
20
22
  end
21
23
  end
22
24
  end
@@ -24,11 +26,11 @@ describe URI do # rubocop:disable Metrics/BlockLength
24
26
  @git_repos["triplets"].each do |repo|
25
27
  describe %(#parse takes triplet "#{repo}") do
26
28
  it "returns URI::#{URI.default_triplet_type}" do
27
- URI.parse(repo).is_a?(URI.const_get(URI.default_triplet_type)).must_equal true
29
+ _(URI.parse(repo).is_a?(URI.const_get(URI.default_triplet_type))).must_equal true
28
30
  end
29
31
 
30
32
  it "recognizes URI::#{URI.default_triplet_type} as a triplet" do
31
- URI.parse(repo).triplet?.must_equal true
33
+ _(URI.parse(repo).triplet?).must_equal true
32
34
  end
33
35
  end
34
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fustigit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan McKern
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-06 00:00:00.000000000 Z
11
+ date: 2019-10-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: '"Parse" SCP-like address triplets with the Standard Ruby URI Library.'
14
14
  email: ryan@orangefort.com
@@ -41,15 +41,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
41
41
  requirements:
42
42
  - - ">="
43
43
  - !ruby/object:Gem::Version
44
- version: 2.1.0
44
+ version: 2.5.0
45
45
  required_rubygems_version: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
49
  version: '0'
50
50
  requirements: []
51
- rubyforge_project:
52
- rubygems_version: 2.6.10
51
+ rubygems_version: 3.0.6
53
52
  signing_key:
54
53
  specification_version: 3
55
54
  summary: Use URI to "parse" SCP-like triplets