grape-route-helpers 1.2.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +11 -10
- data/README.md +6 -2
- data/grape-route-helpers.gemspec +1 -1
- data/lib/grape-route-helpers/all_routes.rb +1 -4
- data/lib/grape-route-helpers/decorated_route.rb +11 -10
- data/lib/grape-route-helpers/version.rb +1 -1
- data/spec/grape_route_helpers/all_routes_spec.rb +0 -1
- metadata +10 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83b55766476f52f66e8ca85e84cbb3982cc30ffc
|
4
|
+
data.tar.gz: 4e95656ec76aec7d9c61c09ed5f8d3ecf9d82992
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0e423a706e7c000da1c40203dfa482e38582189521917dfa271ba5f024c9e3c9efc67d66dbaeff1651e2b15ab7655534d99ae5bc4035f00cf294478844df0b5
|
7
|
+
data.tar.gz: 87182c670bca69856919540aba66c97d965d2c17c2da71cc94763561bc881e4ded309a9cf5d13e2846c875d62d512ebf0f657950351786a8c807acfb8b78a219
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
grape-route-helpers (
|
4
|
+
grape-route-helpers (2.0.0)
|
5
5
|
activesupport
|
6
6
|
grape
|
7
7
|
rake
|
@@ -9,7 +9,7 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
activesupport (4.2.
|
12
|
+
activesupport (4.2.6)
|
13
13
|
i18n (~> 0.7)
|
14
14
|
json (~> 1.7, >= 1.7.7)
|
15
15
|
minitest (~> 5.1)
|
@@ -29,25 +29,28 @@ GEM
|
|
29
29
|
descendants_tracker (0.0.4)
|
30
30
|
thread_safe (~> 0.3, >= 0.3.1)
|
31
31
|
diff-lcs (1.2.5)
|
32
|
+
enumerable-lazy (0.0.1)
|
32
33
|
equalizer (0.0.11)
|
33
|
-
grape (0.
|
34
|
+
grape (0.16.2)
|
34
35
|
activesupport
|
35
36
|
builder
|
36
37
|
hashie (>= 2.1.0)
|
37
38
|
multi_json (>= 1.3.2)
|
38
39
|
multi_xml (>= 0.5.2)
|
40
|
+
mustermann19 (~> 0.4.3)
|
39
41
|
rack (>= 1.3.0)
|
40
42
|
rack-accept
|
41
|
-
rack-mount
|
42
43
|
virtus (>= 1.0.0)
|
43
|
-
hashie (3.4.
|
44
|
+
hashie (3.4.3)
|
44
45
|
i18n (0.7.0)
|
45
|
-
ice_nine (0.11.
|
46
|
+
ice_nine (0.11.2)
|
46
47
|
json (1.8.3)
|
47
48
|
method_source (0.8.2)
|
48
|
-
minitest (5.8.
|
49
|
-
multi_json (1.11.
|
49
|
+
minitest (5.8.4)
|
50
|
+
multi_json (1.11.3)
|
50
51
|
multi_xml (0.5.5)
|
52
|
+
mustermann19 (0.4.3)
|
53
|
+
enumerable-lazy
|
51
54
|
parser (2.3.0.pre.2)
|
52
55
|
ast (>= 1.1, < 3.0)
|
53
56
|
powerpack (0.1.1)
|
@@ -58,8 +61,6 @@ GEM
|
|
58
61
|
rack (1.6.4)
|
59
62
|
rack-accept (0.4.5)
|
60
63
|
rack (>= 0.4)
|
61
|
-
rack-mount (0.8.3)
|
62
|
-
rack (>= 1.0.0)
|
63
64
|
rainbow (2.0.0)
|
64
65
|
rake (10.4.2)
|
65
66
|
rspec (3.3.0)
|
data/README.md
CHANGED
@@ -2,10 +2,14 @@
|
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/reprah/grape-route-helpers.svg)](https://travis-ci.org/reprah/grape-route-helpers)
|
4
4
|
|
5
|
-
|
5
|
+
Provides named route helpers for Grape APIs, similar to [Rails' route helpers](http://edgeguides.rubyonrails.org/routing.html#path-and-url-helpers).
|
6
6
|
|
7
7
|
### Installation
|
8
8
|
|
9
|
+
#### Compatibility with Grape
|
10
|
+
|
11
|
+
If you're using grape 0.16.0 or higher, you'll need version 2.0.0 or higher of grape-route-helpers.
|
12
|
+
|
9
13
|
#### Rails
|
10
14
|
|
11
15
|
1.) Add the gem to your Gemfile.
|
@@ -132,7 +136,7 @@ This results in creating a helper called `is_the_server_running_path`.
|
|
132
136
|
|
133
137
|
#### Testing
|
134
138
|
|
135
|
-
You can
|
139
|
+
You can use route helpers in your API tests by including the `GrapeRouteHelpers::NamedRouteMatcher` module inside your specs. Here's an example:
|
136
140
|
|
137
141
|
```ruby
|
138
142
|
require 'spec_helper'
|
data/grape-route-helpers.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |gem|
|
|
11
11
|
gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
12
12
|
gem.homepage = 'https://github.com/reprah/grape-route-helpers'
|
13
13
|
|
14
|
-
gem.add_runtime_dependency 'grape'
|
14
|
+
gem.add_runtime_dependency 'grape', '~> 0.16', '>= 0.16.0'
|
15
15
|
gem.add_runtime_dependency 'activesupport'
|
16
16
|
gem.add_runtime_dependency 'rake'
|
17
17
|
|
@@ -10,10 +10,7 @@ module GrapeRouteHelpers
|
|
10
10
|
|
11
11
|
def all_routes
|
12
12
|
routes = subclasses.flat_map { |s| s.send(:prepare_routes) }
|
13
|
-
|
14
|
-
routes.uniq do |route|
|
15
|
-
route.instance_variable_get( :@options )
|
16
|
-
end
|
13
|
+
routes.uniq(&:options)
|
17
14
|
end
|
18
15
|
end
|
19
16
|
end
|
@@ -10,7 +10,7 @@ module GrapeRouteHelpers
|
|
10
10
|
|
11
11
|
def initialize(route)
|
12
12
|
@route = route
|
13
|
-
@route_options = route.
|
13
|
+
@route_options = route.options
|
14
14
|
@helper_names = []
|
15
15
|
@helper_arguments = required_helper_segments
|
16
16
|
@extension = default_extension
|
@@ -64,16 +64,17 @@ module GrapeRouteHelpers
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def route_versions
|
67
|
+
version_pattern = /[^\[",\]\s]+/
|
67
68
|
if route_version
|
68
|
-
route_version.
|
69
|
+
route_version.scan(version_pattern)
|
69
70
|
else
|
70
71
|
[nil]
|
71
72
|
end
|
72
73
|
end
|
73
74
|
|
74
75
|
def path_helper_name(opts = {})
|
75
|
-
if
|
76
|
-
name =
|
76
|
+
if route_options[:as]
|
77
|
+
name = route_options[:as].to_s
|
77
78
|
else
|
78
79
|
segments = path_segments_with_values(opts)
|
79
80
|
|
@@ -90,7 +91,7 @@ module GrapeRouteHelpers
|
|
90
91
|
|
91
92
|
def segment_to_value(segment, opts = {})
|
92
93
|
options = HashWithIndifferentAccess.new(
|
93
|
-
|
94
|
+
route.options.merge(opts)
|
94
95
|
)
|
95
96
|
|
96
97
|
if dynamic_segment?(segment)
|
@@ -124,7 +125,7 @@ module GrapeRouteHelpers
|
|
124
125
|
|
125
126
|
def required_helper_segments
|
126
127
|
segments_in_options = dynamic_path_segments.select do |segment|
|
127
|
-
|
128
|
+
route.options[segment.to_sym]
|
128
129
|
end
|
129
130
|
dynamic_path_segments - segments_in_options
|
130
131
|
end
|
@@ -144,19 +145,19 @@ module GrapeRouteHelpers
|
|
144
145
|
end
|
145
146
|
|
146
147
|
def route_path
|
147
|
-
|
148
|
+
route.path
|
148
149
|
end
|
149
150
|
|
150
151
|
def route_version
|
151
|
-
|
152
|
+
route.version
|
152
153
|
end
|
153
154
|
|
154
155
|
def route_namespace
|
155
|
-
|
156
|
+
route.namespace
|
156
157
|
end
|
157
158
|
|
158
159
|
def route_method
|
159
|
-
|
160
|
+
route.request_method
|
160
161
|
end
|
161
162
|
end
|
162
163
|
end
|
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grape-route-helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Harper Henn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: grape
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.16'
|
17
20
|
- - ">="
|
18
21
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
22
|
+
version: 0.16.0
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0.16'
|
24
30
|
- - ">="
|
25
31
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
32
|
+
version: 0.16.0
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: activesupport
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|