fustigit 0.1.1 → 0.1.3

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
  SHA1:
3
- metadata.gz: 551f4ad9ed874b976c1de00a5289a1352d946d64
4
- data.tar.gz: 1954e7f60f0c10a423f8a2cc0f16d0a09ba4d085
3
+ metadata.gz: c751ca9b2b4344d7ffdfe8135e75415cc6c56e17
4
+ data.tar.gz: 59c43e03ed9c4c51507bf4db11d54c3a47bb7979
5
5
  SHA512:
6
- metadata.gz: fe5bbee3df3198f8d9d93f7cc88a27c1609c2ee952e25a65884016f07b5e44b15a3d98cbe0c88e773b9f8806dc6788172708eb59be85d8bacee65b353ed88d61
7
- data.tar.gz: 50f90dbc0e42dca704a759d2ab68feb3a2ab326a380b4733ff848099b45a2e1fbd4e54850c587eb72befbabe34a633b37b908ff41cfdb7ac3d08675767896861
6
+ metadata.gz: 19fcae6c47cbc194ec192839a64f85bae11d26431d2a2215c56f5314f34f37d406389e49b543a7b72a6bef0dce40a282925860b1bfbd523c8edc0860c9e5630f
7
+ data.tar.gz: f52b1964f4dd1fe5ba16000d20eb75172afd0b8ba89951985fadfc8f65ef95a21c77f3cb3e3a83edd946ba710acfc6311ad659441a713dfef5205fbfe6eb9eb8
@@ -3,6 +3,16 @@ 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.1.3] - 07 July 2016
7
+ ### Added
8
+ - Triplets#split method returns the expected array of values for parsed triplets
9
+ ### Changed
10
+ - Improved Triplets#triplet? functionality
11
+
12
+ ## [0.1.2] - 07 July 2016
13
+ ### Added
14
+ - Triplets#triplet? method allows for fast testing on parsed triplets
15
+
6
16
  ## [0.1.1] - 09 May 2016
7
17
  ### Added
8
18
  - Fix Ruby 2.2.0 and 2.3.0 support
@@ -1,5 +1,5 @@
1
1
  module Fustigit
2
2
  module Version
3
- VERSION = "0.1.1".freeze
3
+ VERSION = "0.1.3".freeze
4
4
  end
5
5
  end
@@ -23,7 +23,7 @@ module Triplets
23
23
  str << "#{scheme}://" if scheme
24
24
  str << "#{user}@" if user
25
25
  if port && port != self.class::DEFAULT_PORT
26
- host_info [host, port].join(":")
26
+ host_info = [host, port].join(":")
27
27
  str << [host_info, path].join("/").squeeze("/")
28
28
  else
29
29
  str << [host, path].join("/").squeeze("/")
@@ -31,15 +31,19 @@ module Triplets
31
31
  end
32
32
  private :rfc_uri
33
33
 
34
- # if self.path is a relative path, assume that this was parsed
35
- # as a triplet and return a Triplet. Otherwise, assume that
36
- # this is a valid URI and print an RFC compliant URI. This
37
- # may not be the most robust method of determining if a
38
- # triplet should be used, but everything starts someplace.
39
34
  def to_s
40
- return triplet if relative?
35
+ return triplet if triplet?
41
36
  rfc_uri
42
37
  end
38
+
39
+ # Use the same regular expressions that the parser uses to determine
40
+ # if this is a valid triplet.
41
+ def triplet?
42
+ # False if self matches a normal URI scheme
43
+ !(rfc_uri =~ URI.parser.const_get(:SCHEME)) &&
44
+ # False unless self matches a Triplet scheme
45
+ !!(triplet =~ URI.parser.const_get(:TRIPLET))
46
+ end
43
47
  end
44
48
 
45
49
  # A SCP Triplet is *not* a canonical URI. It doesn't follow any RFCs that
@@ -60,6 +64,14 @@ module TripletInterruptus
60
64
  super(uri)
61
65
  end
62
66
 
67
+ def split(uri)
68
+ return super(uri) unless triplet?(uri)
69
+
70
+ parts = parse_triplet(uri)
71
+ [nil, parts[:userinfo], parts[:host], nil,
72
+ nil, parts[:path], nil, nil, nil]
73
+ end
74
+
63
75
  def triplet?(address)
64
76
  address.match(TRIPLET) && !address.match(SCHEME)
65
77
  end
@@ -96,6 +108,12 @@ module TripletHandling
96
108
  end
97
109
  @default_triplet_type = value
98
110
  end
111
+
112
+ def parser
113
+ return URI::RFC3986_Parser if
114
+ Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.2.0")
115
+ URI::Parser
116
+ end
99
117
  end
100
118
 
101
119
  # Reopen URI and include TripletHandling (which will then
@@ -26,6 +26,10 @@ describe URI do
26
26
  it "returns URI::#{URI.default_triplet_type}" do
27
27
  URI.parse(repo).is_a?(URI.const_get(URI.default_triplet_type)).must_equal true
28
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
29
33
  end
30
34
  end
31
35
  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.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan McKern
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-09 00:00:00.000000000 Z
11
+ date: 2016-07-12 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
@@ -49,7 +49,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
49
49
  version: '0'
50
50
  requirements: []
51
51
  rubyforge_project:
52
- rubygems_version: 2.6.4
52
+ rubygems_version: 2.6.6
53
53
  signing_key:
54
54
  specification_version: 3
55
55
  summary: Use URI to "parse" SCP-like triplets