build-uri 1.0.0 → 1.0.1

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: 875ee954e27285ed02e09319a4522ff214f0a79c
4
- data.tar.gz: 7abb5ce2d4cac8a351a2b97825e09d7c8cb6bb8d
3
+ metadata.gz: 5f8a5d5877dee272338beeec3fda4f17abb9817e
4
+ data.tar.gz: 8c5a4a231d4d404d04bc1a72a91c0b18249838ba
5
5
  SHA512:
6
- metadata.gz: 6867609819a69023dc1ecd8eda6a3ff87b55feac5a7ce46eeeb201ade4ee4df67c7c7bb56a30a23f2d88ed0fa6adcdee822ec5fcf2bfc19bede0c236668c6201
7
- data.tar.gz: 91424aff5e447387a4e21742c568b72dcd55fa30492edf802fc1972b60040cc949b77b8cf8dc08464dda0d376d41d1cafd4f31d5c79dfd99d25b7bbec6bea5dc
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 file paths (`Build::URI::Relative`), URIs (`Build::URI::Absolute`) and triples (`Build::URI::Triple`).
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
  [![Build Status](https://secure.travis-ci.org/ioquatix/build-uri.svg)](http://travis-ci.org/ioquatix/build-uri)
6
6
  [![Code Climate](https://codeclimate.com/github/ioquatix/build-uri.svg)](https://codeclimate.com/github/ioquatix/build-uri)
@@ -22,13 +22,36 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- To parse an input:
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
- Is it a local file?
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
- Concatenate paths:
64
+ ### Concatenation
42
65
 
43
66
  ```ruby
44
- root = Build::URI["http://www.google.com/search?q=awesome"]
45
- path = Build::URI["/login"]
67
+ root = Build::URI["https://www.github.com/ioquatix"]
68
+ path = Build::URI["build-uri"]
46
69
 
47
70
  (root + path).to_s
48
- # => "http://www.google.com/login?q=awesome"
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
@@ -79,7 +79,9 @@ module Build
79
79
 
80
80
  def self.parse(string)
81
81
  if match = PARSER.match(string)
82
- self.new(*match.values_at(*self.members)).freeze
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
@@ -47,7 +47,11 @@ module Build
47
47
 
48
48
  def self.parse(string)
49
49
  if match = PARSER.match(string)
50
- self.new(*match.values_at(*self.members))
50
+ self.new(
51
+ match[:userinfo],
52
+ match[:host],
53
+ match[:path],
54
+ ).freeze
51
55
  end
52
56
  end
53
57
  end
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Build
22
22
  module URI
23
- VERSION = "1.0.0"
23
+ VERSION = "1.0.1"
24
24
  end
25
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: build-uri
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams