usher 0.7.3 → 0.7.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/usher/util/generate.rb +20 -36
- data/usher.gemspec +2 -2
- metadata +3 -2
data/lib/usher/util/generate.rb
CHANGED
@@ -3,7 +3,6 @@ class Usher
|
|
3
3
|
class Generators
|
4
4
|
|
5
5
|
class Generic
|
6
|
-
|
7
6
|
attr_accessor :usher
|
8
7
|
|
9
8
|
def generate(name, params)
|
@@ -14,20 +13,11 @@ class Usher
|
|
14
13
|
raise UnrecognizedException.new unless path
|
15
14
|
case params
|
16
15
|
when nil, Hash
|
17
|
-
|
16
|
+
path.generate_from_hash(params)
|
18
17
|
else
|
19
|
-
|
18
|
+
path.generate(*Array(params).slice!(0, path.dynamic_parts.size))
|
20
19
|
end
|
21
20
|
end
|
22
|
-
|
23
|
-
def generate_path_for_base_params_with_hash(path, params)
|
24
|
-
path.generate_from_hash(params)
|
25
|
-
end
|
26
|
-
|
27
|
-
def generate_path_for_base_params_with_array(path, params)
|
28
|
-
path.generate(*params.slice!(0, path.dynamic_parts.size))
|
29
|
-
end
|
30
|
-
|
31
21
|
end
|
32
22
|
|
33
23
|
class URL < Generic
|
@@ -114,14 +104,11 @@ class Usher
|
|
114
104
|
|
115
105
|
params = extra_params if extra_params
|
116
106
|
|
117
|
-
|
107
|
+
if generate_extra && params && !params.empty?
|
118
108
|
if usher.consider_destination_keys? && path.route.destination_keys
|
119
109
|
params.delete_if{|k, v| path.route.destination_keys.include?(k)}
|
120
110
|
end
|
121
|
-
unless params.empty?
|
122
|
-
result << '?' unless result[??]
|
123
|
-
result << generate_extra_params(params)
|
124
|
-
end
|
111
|
+
result << '?' << generate_querystring(params) unless params.empty?
|
125
112
|
end
|
126
113
|
result
|
127
114
|
end
|
@@ -184,25 +171,8 @@ class Usher
|
|
184
171
|
(url[-1] == ?/) ? url[0..-2] : url
|
185
172
|
end
|
186
173
|
|
187
|
-
def
|
188
|
-
path = case routing_lookup
|
189
|
-
when Route::Path
|
190
|
-
routing_lookup
|
191
|
-
when Symbol
|
192
|
-
route = @usher.named_routes[routing_lookup]
|
193
|
-
raise UnrecognizedException unless route
|
194
|
-
route.find_matching_path(params || {})
|
195
|
-
when Route
|
196
|
-
routing_lookup.find_matching_path(params)
|
197
|
-
when nil
|
198
|
-
params.is_a?(Hash) ? usher.path_for_options(params) : raise
|
199
|
-
end
|
200
|
-
end
|
201
|
-
|
202
|
-
|
203
|
-
def generate_extra_params(params)
|
174
|
+
def generate_querystring(params)
|
204
175
|
extra_params_result = ''
|
205
|
-
|
206
176
|
params.each do |k,v|
|
207
177
|
case v
|
208
178
|
when Array
|
@@ -218,8 +188,22 @@ class Usher
|
|
218
188
|
extra_params_result
|
219
189
|
end
|
220
190
|
|
221
|
-
end
|
222
191
|
|
192
|
+
def path_for_routing_lookup(routing_lookup, params = {})
|
193
|
+
path = case routing_lookup
|
194
|
+
when Route::Path
|
195
|
+
routing_lookup
|
196
|
+
when Symbol
|
197
|
+
route = @usher.named_routes[routing_lookup]
|
198
|
+
raise UnrecognizedException unless route
|
199
|
+
route.find_matching_path(params || {})
|
200
|
+
when Route
|
201
|
+
routing_lookup.find_matching_path(params)
|
202
|
+
when nil
|
203
|
+
params.is_a?(Hash) ? usher.path_for_options(params) : raise
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
223
207
|
end
|
224
208
|
end
|
225
209
|
end
|
data/usher.gemspec
CHANGED
@@ -5,8 +5,8 @@ require "base64"
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "usher"
|
8
|
-
s.version = "0.7.
|
9
|
-
s.authors = ["Daniel Neighman", "Daniel Vartanov", "Jakub Šťastný", "Joshua Hull"]
|
8
|
+
s.version = "0.7.4"
|
9
|
+
s.authors = ["Daniel Neighman", "Daniel Vartanov", "Jakub Šťastný", "Joshua Hull", "Davide D'Agostino"].sort
|
10
10
|
s.homepage = "http://github.com/joshbuddy/usher"
|
11
11
|
s.summary = "Pure ruby general purpose router with interfaces for rails, rack, email or choose your own adventure"
|
12
12
|
s.cert_chain = nil
|
metadata
CHANGED
@@ -5,12 +5,13 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 7
|
8
|
-
-
|
9
|
-
version: 0.7.
|
8
|
+
- 4
|
9
|
+
version: 0.7.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Daniel Neighman
|
13
13
|
- Daniel Vartanov
|
14
|
+
- Davide D'Agostino
|
14
15
|
- !binary |
|
15
16
|
SmFrdWIgxaDFpWFzdG7DvQ==
|
16
17
|
|