build-uri 1.0.0 → 1.0.1
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 +4 -4
- data/README.md +38 -7
- data/lib/build/uri/absolute.rb +3 -1
- data/lib/build/uri/triplet.rb +5 -1
- data/lib/build/uri/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f8a5d5877dee272338beeec3fda4f17abb9817e
|
4
|
+
data.tar.gz: 8c5a4a231d4d404d04bc1a72a91c0b18249838ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4265f956f7f4a54da0196a7a8a05daee21da01874f7e0f29991e6f5a0d333c9acb5b44484ed4f69e366ba55af3ee41146c53e867d45cb520d2666b4732cf5614
|
7
|
+
data.tar.gz: 90df195a715cdc880cb6ce9e91f2b73a5b7c99ca9a58174203ede9d307f0672b8fcb3303e52d912472993563984caa0d134233b2172024c207042ef272847d35
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Build::URI
|
2
2
|
|
3
|
-
`Build::URI` provides unform handling of
|
3
|
+
`Build::URI` provides unform handling of paths (e.g. `/var/lib`), URIs (e.g. `http://www.google.com/search`) and triples (e.g. `git@github.com:ioquatix/build-uri`). It supports logical concatenation of all combinations of these, and a nil token for convenience.
|
4
4
|
|
5
5
|
[](http://travis-ci.org/ioquatix/build-uri)
|
6
6
|
[](https://codeclimate.com/github/ioquatix/build-uri)
|
@@ -22,13 +22,36 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
|
25
|
+
Some examples of concatenation:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
Build::URI['http://www.github.com/ioquatix'] + 'build-uri'
|
29
|
+
# Absolute URI is concatenated with relative path, generating 'http://www.github.com/ioquatix/build-uri'.
|
30
|
+
|
31
|
+
Build::URI['var'] + 'lib'
|
32
|
+
# Concatenates relative paths, generating 'var/lib'.
|
33
|
+
|
34
|
+
Build::URI['/usr/bin'] + '/usr/local/bin'
|
35
|
+
# RHS is absolute path, so it is returned.
|
36
|
+
|
37
|
+
Build::URI['http://www.github.com/'] + Build::URI['git@github.com:ioquatix/build-uri']
|
38
|
+
# RHS is absolute URI, so it is returned.
|
39
|
+
|
40
|
+
Build::URI[nil] + 'etc'
|
41
|
+
# LHS is nil, so RHS is returned.
|
42
|
+
```
|
43
|
+
|
44
|
+
A `nil` token `Build::URI[nil]` or `Build::URI::EMPTY` is available which always yields the right-hand side when merging.
|
45
|
+
|
46
|
+
### Parsing Input
|
26
47
|
|
27
48
|
```ruby
|
28
49
|
uri = Build::URI[value]
|
29
50
|
```
|
30
51
|
|
31
|
-
|
52
|
+
### Local Path
|
53
|
+
|
54
|
+
Is it a local path or a (potentially) remote resource?
|
32
55
|
|
33
56
|
```ruby
|
34
57
|
if uri.local?
|
@@ -38,16 +61,24 @@ else
|
|
38
61
|
end
|
39
62
|
```
|
40
63
|
|
41
|
-
|
64
|
+
### Concatenation
|
42
65
|
|
43
66
|
```ruby
|
44
|
-
root = Build::URI["
|
45
|
-
path = Build::URI["
|
67
|
+
root = Build::URI["https://www.github.com/ioquatix"]
|
68
|
+
path = Build::URI["build-uri"]
|
46
69
|
|
47
70
|
(root + path).to_s
|
48
|
-
# => "
|
71
|
+
# => "https://www.github.com/ioquatix/build-uri"
|
49
72
|
```
|
50
73
|
|
74
|
+
## Caveats
|
75
|
+
|
76
|
+
This library does not implement URI encoding/decoding. It is expected that the inputs are valid encoded strings, and thus the outputs will be too.
|
77
|
+
|
78
|
+
This is not a general purposes URI handling library, but is focused on providing correct programmatic path concatenation for [teapot].
|
79
|
+
|
80
|
+
[teapot]: https://www.github.com/ioquatix/teapot
|
81
|
+
|
51
82
|
## Contributing
|
52
83
|
|
53
84
|
1. Fork it
|
data/lib/build/uri/absolute.rb
CHANGED
@@ -79,7 +79,9 @@ module Build
|
|
79
79
|
|
80
80
|
def self.parse(string)
|
81
81
|
if match = PARSER.match(string)
|
82
|
-
self.new(
|
82
|
+
self.new(
|
83
|
+
match[:scheme], match[:userinfo], match[:host], match[:path], match[:query], match[:fragment]
|
84
|
+
).freeze
|
83
85
|
end
|
84
86
|
end
|
85
87
|
end
|
data/lib/build/uri/triplet.rb
CHANGED
data/lib/build/uri/version.rb
CHANGED