fuzzyurl 0.8.0 → 0.9.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
2
  SHA1:
3
- metadata.gz: b8bc03d75fbe841afed852424c2123761aeff21b
4
- data.tar.gz: 0124a1e435856981f3088a25c9ca7348b172d4b8
3
+ metadata.gz: 7f97f4d61a613298ae6dc7d637c9db0e762a4ca2
4
+ data.tar.gz: 55abe6ac3a5f2d4f9b8d4df14499a59948a4242a
5
5
  SHA512:
6
- metadata.gz: 3acd8d87e7df1e4ae87c91e9edde769b84c1b1bd993d7f8275a19d06f2a611384c5af8ca8e7eba1542c06404aedd7161d313b6577ae5c16e84507ce39b41ca9e
7
- data.tar.gz: 18eef24b09a6f54690e6ebe53db791a07188050e8fae0fb652db938f076403941c4c2557b1eaf6f9f1eacee4d788fe6d7ee9333eef6ffa215ea2333cd2faaaf6
6
+ metadata.gz: 7297e9a3bf80f937ee928ae8f66f44b2f01c1e2e1ca885c53636ebed42da6fd54d60864de721a612998dffaa240a795cd7005ebf029cf78f0cdc8f35613d571a
7
+ data.tar.gz: 5fe01d27cfb6898cf85b7a5d9c0a3d8fa59fd20cc50ada7559638987f03c641ee05789a016e9ac880e60b303ce9aec6a57d5f6234fa21517d7667a73a22d9d54
@@ -4,6 +4,81 @@ require 'fuzzyurl/protocols'
4
4
  require 'fuzzyurl/match'
5
5
  require 'fuzzyurl/strings'
6
6
 
7
+
8
+ # Fuzzyurl provides two related functions: non-strict parsing of URLs or
9
+ # URL-like strings into their component pieces (protocol, username, password,
10
+ # hostname, port, path, query, and fragment), and fuzzy matching of URLs
11
+ # and URL patterns.
12
+ #
13
+ # Specifically, URLs that look like this:
14
+ #
15
+ # [protocol ://] [username [: password] @] [hostname] [: port] [/ path] [? query] [# fragment]
16
+ #
17
+ # Fuzzyurls can be constructed using some or all of the above
18
+ # fields, optionally replacing some or all of those fields with a `*`
19
+ # wildcard if you wish to use the Fuzzyurl as a URL mask.
20
+ #
21
+ #
22
+ # ## Parsing URLs
23
+ #
24
+ # irb> Fuzzyurl.from_string("https://api.example.com/users/123?full=true")
25
+ # #=> #<Fuzzyurl:0x007ff55b914f58 @protocol="https", @username=nil, @password=nil, @hostname="api.example.com", @port=nil, @path="/users/123", @query="full=true", @fragment=nil>
26
+ #
27
+ #
28
+ # ## Constructing URLs
29
+ #
30
+ # irb> f = Fuzzyurl.new(hostname: "example.com", protocol: "http", port: "8080")
31
+ # irb> f.to_s
32
+ # #=> "http://example.com:8080"
33
+ #
34
+ #
35
+ # ## Matching URLs
36
+ #
37
+ # Fuzzyurl supports wildcard matching:
38
+ #
39
+ # * `*` matches anything, including `null`.
40
+ # * `foo*` matches `foo`, `foobar`, `foo/bar`, etc.
41
+ # * `*bar` matches `bar`, `foobar`, `foo/bar`, etc.
42
+ #
43
+ # Path and hostname matching allows the use of a greedier wildcard `**` in
44
+ # addition to the naive wildcard `*`:
45
+ #
46
+ # * `*.example.com` matches `filsrv-01.corp.example.com` but not `example.com`.
47
+ # * `**.example.com` matches `filsrv-01.corp.example.com` and `example.com`.
48
+ # * `/some/path/*` matches `/some/path/foo/bar` and `/some/path/`
49
+ # but not `/some/path`
50
+ # * `/some/path/**` matches `/some/path/foo/bar` and `/some/path/`
51
+ # and `/some/path`
52
+ #
53
+ # The `Fuzzyurl.mask` function aids in the creation of URL masks.
54
+ #
55
+ # irb> Fuzzyurl.mask
56
+ # #=> #<Fuzzyurl:0x007ff55b039578 @protocol="*", @username="*", @password="*", @hostname="*", @port="*", @path="*", @query="*", @fragment="*">
57
+ #
58
+ # irb> Fuzzyurl.matches?(Fuzzyurl.mask, "http://example.com:8080/foo/bar")
59
+ # #=> true
60
+ #
61
+ # irb> mask = Fuzzyurl.mask(path: "/a/b/**")
62
+ # irb> Fuzzyurl.matches?(mask, "https://example.com/a/b/")
63
+ # #=> true
64
+ # irb> Fuzzyurl.matches?(mask, "git+ssh://jen@example.com/a/b/")
65
+ # #=> true
66
+ # irb> Fuzzyurl.matches?(mask, "https://example.com/a/bar")
67
+ # #=> false
68
+ #
69
+ # `Fuzzyurl.bestMatch`, given a list of URL masks and a URL, will return
70
+ # the given mask which most closely matches the URL:
71
+ #
72
+ # irb> masks = ["/foo/*", "/foo/bar", Fuzzyurl.mask]
73
+ # irb> Fuzzyurl.best_match(masks, "http://example.com/foo/bar")
74
+ # #=> "/foo/bar"
75
+ #
76
+ # If you'd prefer the array index instead of the matching mask itself, use
77
+ # `Fuzzyurl.best_match_index` instead:
78
+ #
79
+ # irb> Fuzzyurl.best_match_index(masks, "http://example.com/foo/bar")
80
+ # #=> 1
81
+ #
7
82
  class Fuzzyurl
8
83
  FIELDS.each {|f| attr_accessor f}
9
84
 
@@ -8,7 +8,7 @@ class Fuzzyurl::Strings
8
8
  (?: : (?<password> \* | [a-zA-Z0-9%_.!~*'();&=+$,-]*))?
9
9
  @
10
10
  )?
11
- (?<hostname> [a-zA-Z0-9\.\*\-]+?)?
11
+ (?<hostname> [a-zA-Z0-9\.\*\-_]+?)?
12
12
  (?: : (?<port> \* | \d+))?
13
13
  (?<path> / [^\?\#]*)? ## captures leading /
14
14
  (?: \? (?<query> [^\#]*) )?
@@ -1,5 +1,5 @@
1
1
  class Fuzzyurl
2
- VERSION = "0.8.0"
3
- VERSION_DATE = "2015-12-25"
2
+ VERSION = "0.9.0"
3
+ VERSION_DATE = "2016-06-28"
4
4
  end
5
5
 
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fuzzyurl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pete Gamache
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-25 00:00:00.000000000 Z
11
+ date: 2016-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 10.0.4
19
+ version: '10.0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 10.0.4
26
+ version: '10.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: minitest
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: 4.7.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 4.7.0
41
41
  - !ruby/object:Gem::Dependency
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 0.13.3
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 0.13.3
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: pry
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: coveralls
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  description:
70
84
  email: pete@gamache.org
71
85
  executables: []