restless_router 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -1
- data/lib/restless_router/route.rb +9 -1
- data/lib/restless_router/version.rb +1 -1
- data/spec/unit/route_spec.rb +9 -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: 5c69fdf41094206bf9aec0551d1cf5fc43e6efe0
|
4
|
+
data.tar.gz: 2b6a00897095a22bc9985f179823601af3961c06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03e5200821d86bbd039df53d3d46696e0ece67b4d000afe0a9ddfe8a25d25108c470adaf1f4cd794b8420920e9aa98b61e2651db2a94c1690a9c267fe24fed1c
|
7
|
+
data.tar.gz: 3dbf01e4c68c3fc2428fe58890eb2f036b02b79b1719d90d9319f7bceadaf5786c38d5bb8a031048167c6cec9c4b6823f0b739318a0754ebe110bff928d18381
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# RestlessRouter
|
2
2
|
|
3
|
-
[![Build Status](https://travis-ci.org/nateklaiber/restless_router.svg?branch=
|
3
|
+
[![Build Status](https://travis-ci.org/nateklaiber/restless_router.svg?branch=master)](https://travis-ci.org/nateklaiber/restless_router)
|
4
4
|
|
5
5
|
This helps fill the gap where web services only provide their routing
|
6
6
|
via external documentation. In order to prevent URL building scattered
|
@@ -93,6 +93,10 @@ directory_request = Faraday.get(directory_url)
|
|
93
93
|
Some APIs may provide hypermedia envelopes and you should use those where
|
94
94
|
available.
|
95
95
|
|
96
|
+
## Examples
|
97
|
+
|
98
|
+
I used this in the [`automatic-client`](https://rubygems.org/gems/automatic-client) Gem to handle the small set of available routes. These are defined in the [`Automatic::Client`](https://github.com/nateklaiber/automatic-client/blob/ef58709f93c8abcdaadb16be1eed8ec33989c05f/lib/automatic/client.rb) and available via the `routes` class method.
|
99
|
+
|
96
100
|
## Contributing
|
97
101
|
|
98
102
|
1. Fork it ( http://github.com/<my-github-username>/restless_router/fork )
|
@@ -19,7 +19,7 @@ module RestlessRouter
|
|
19
19
|
#
|
20
20
|
# # With a templated route
|
21
21
|
# route = RestlessRouter::Route.new('search', 'http://example.com/search{?q}', templated: true)
|
22
|
-
#
|
22
|
+
#
|
23
23
|
# route.name
|
24
24
|
# # => 'search'
|
25
25
|
#
|
@@ -47,6 +47,14 @@ module RestlessRouter
|
|
47
47
|
@name
|
48
48
|
end
|
49
49
|
|
50
|
+
# Return the specified path of the Route. This
|
51
|
+
# is either a fully qualified URL or a URI Template.
|
52
|
+
#
|
53
|
+
# @return [String] Path of the route
|
54
|
+
def path
|
55
|
+
@path
|
56
|
+
end
|
57
|
+
|
50
58
|
# Returns the URL for the route. If it's templated,
|
51
59
|
# then we utilize the provided options hash to expand
|
52
60
|
# the route. Otherwise we return the `path`
|
data/spec/unit/route_spec.rb
CHANGED
@@ -14,6 +14,10 @@ describe RestlessRouter::Route do
|
|
14
14
|
expect(subject.name).to eq('home')
|
15
15
|
end
|
16
16
|
|
17
|
+
it "returns the #path" do
|
18
|
+
expect(subject.path).to eq('http://www.example.com')
|
19
|
+
end
|
20
|
+
|
17
21
|
it "returns the #url_for" do
|
18
22
|
expect(subject.url_for).to eq('http://www.example.com')
|
19
23
|
end
|
@@ -27,7 +31,11 @@ describe RestlessRouter::Route do
|
|
27
31
|
it "returns the expanded #url_for" do
|
28
32
|
expect(subject.url_for(q: 'search-term')).to eq('http://www.example.com/search?q=search-term')
|
29
33
|
end
|
30
|
-
|
34
|
+
|
35
|
+
it "returns the raw #path" do
|
36
|
+
expect(subject.path).to eq('http://www.example.com/search{?q}')
|
37
|
+
end
|
38
|
+
|
31
39
|
it "returns the expanded #url_for with no expansions" do
|
32
40
|
expect(subject.url_for).to eq('http://www.example.com/search')
|
33
41
|
end
|