uri_template 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -2
- data/lib/uri_template.rb +43 -28
- data/lib/uri_template/colon.rb +1 -1
- data/lib/uri_template/rfc6570.rb +27 -15
- data/lib/uri_template/rfc6570/expression.rb +1 -13
- data/lib/uri_template/rfc6570/expression/unnamed.rb +11 -1
- data/lib/uri_template/utils.rb +62 -68
- data/uri_template.gemspec +1 -1
- metadata +22 -22
data/README.md
CHANGED
@@ -3,7 +3,8 @@ URITemplate - a uri template library
|
|
3
3
|
|
4
4
|
[![Build Status](https://secure.travis-ci.org/hannesg/uri_template.png)](http://travis-ci.org/hannesg/uri_template)
|
5
5
|
[![Dependency Status](https://gemnasium.com/hannesg/uri_template.png)](https://gemnasium.com/hannesg/uri_template)
|
6
|
-
[![Code Climate](https://codeclimate.com/
|
6
|
+
[![Code Climate](https://codeclimate.com/github/hannesg/uri_template.png)](https://codeclimate.com/github/hannesg/uri_template)
|
7
|
+
[![Coverage](https://coveralls.io/repos/hannesg/uri_template/badge.png?branch=master)](https://coveralls.io/r/hannesg/uri_template)
|
7
8
|
|
8
9
|
With URITemplate you can generate URIs based on simple templates and extract variables from URIs using the same templates. There are currently two syntaxes defined. Namely the one defined in [RFC 6570]( http://tools.ietf.org/html/rfc6570 ) and a colon based syntax, similiar to the one used by sinatra.
|
9
10
|
|
@@ -53,4 +54,4 @@ The way variables are inserted can be modified using operators. The operator is
|
|
53
54
|
Benchmarks
|
54
55
|
-----------------------
|
55
56
|
|
56
|
-
I have assembled one benchmark based on the uritemplate-test examples. You can find them in the "benchmarks" folder. The short result: uri_template is 2-10x faster than addressable on ruby 1.9.3.
|
57
|
+
I have assembled one benchmark based on the uritemplate-test examples. You can find them in the "benchmarks" folder. The short result: uri_template is 2-10x faster than addressable on ruby 1.9.3.
|
data/lib/uri_template.rb
CHANGED
@@ -18,6 +18,42 @@
|
|
18
18
|
# A base module for all implementations of a uri template.
|
19
19
|
module URITemplate
|
20
20
|
|
21
|
+
# Helper module which defines class methods for all uri template
|
22
|
+
# classes.
|
23
|
+
module ClassMethods
|
24
|
+
# Tries to convert the given argument into an {URITemplate}.
|
25
|
+
# Returns nil if this fails.
|
26
|
+
#
|
27
|
+
# @return [nil|{URITemplate}]
|
28
|
+
def try_convert(x)
|
29
|
+
if x.kind_of? self
|
30
|
+
return x
|
31
|
+
elsif x.kind_of? String
|
32
|
+
return self.new(x)
|
33
|
+
else
|
34
|
+
return nil
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# Same as {.try_convert} but raises an ArgumentError when the given argument could not be converted.
|
39
|
+
#
|
40
|
+
# @raise ArgumentError if the argument is unconvertable
|
41
|
+
# @return {URITemplate}
|
42
|
+
def convert(x)
|
43
|
+
o = self.try_convert(x)
|
44
|
+
if o.nil?
|
45
|
+
raise ArgumentError, "Expected to receive something that can be converted into a URITemplate of type #{self.inspect}, but got #{x.inspect}"
|
46
|
+
end
|
47
|
+
return o
|
48
|
+
end
|
49
|
+
|
50
|
+
def included(base)
|
51
|
+
base.extend(ClassMethods)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
extend ClassMethods
|
56
|
+
|
21
57
|
# @api private
|
22
58
|
SCHEME_REGEX = /\A[a-z]+:/i.freeze
|
23
59
|
|
@@ -78,32 +114,6 @@ module URITemplate
|
|
78
114
|
return klass.new(*rest)
|
79
115
|
end
|
80
116
|
|
81
|
-
# Tries to convert the given argument into an {URITemplate}.
|
82
|
-
# Returns nil if this fails.
|
83
|
-
#
|
84
|
-
# @return [nil|{URITemplate}]
|
85
|
-
def self.try_convert(x)
|
86
|
-
if x.kind_of? URITemplate
|
87
|
-
return x
|
88
|
-
elsif x.kind_of? String
|
89
|
-
return URITemplate.new(x)
|
90
|
-
else
|
91
|
-
return nil
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
# Same as {.try_convert} but raises an ArgumentError when the given argument could not be converted.
|
96
|
-
#
|
97
|
-
# @raise ArgumentError if the argument is unconvertable
|
98
|
-
# @return {URITemplate}
|
99
|
-
def self.convert(x)
|
100
|
-
o = self.try_convert(x)
|
101
|
-
if o.nil?
|
102
|
-
raise ArgumentError, "Expected to receive something that can be converted to an URITemplate, but got #{x.inspect}"
|
103
|
-
end
|
104
|
-
return o
|
105
|
-
end
|
106
|
-
|
107
117
|
# Tries to coerce two URITemplates into a common representation.
|
108
118
|
# Returns an array with two {URITemplate}s and two booleans indicating which of the two were converted or raises an ArgumentError.
|
109
119
|
#
|
@@ -153,6 +163,7 @@ module URITemplate
|
|
153
163
|
a.send(method,b,*args)
|
154
164
|
end
|
155
165
|
|
166
|
+
# @api private
|
156
167
|
def self.coerce_first_arg(meth)
|
157
168
|
alias_method( (meth.to_s + '_without_coercion').to_sym , meth )
|
158
169
|
class_eval(<<-RUBY)
|
@@ -187,10 +198,14 @@ RUBY
|
|
187
198
|
# @param variables [#map]
|
188
199
|
# @return String
|
189
200
|
def expand(variables = {})
|
190
|
-
raise ArgumentError, "Expected something that
|
201
|
+
raise ArgumentError, "Expected something that responds to :map, but got: #{variables.inspect}" unless variables.respond_to? :map
|
191
202
|
|
192
203
|
# Stringify variables
|
193
|
-
|
204
|
+
arg = variables.map{ |k, v| [k.to_s, v] }
|
205
|
+
if arg.any?{|elem| !elem.kind_of?(Array) }
|
206
|
+
raise ArgumentError, "Expected the output of variables.map to return an array of arrays but got #{arg.inspect}"
|
207
|
+
end
|
208
|
+
variables = Hash[arg]
|
194
209
|
|
195
210
|
tokens.map{|part|
|
196
211
|
part.expand(variables)
|
data/lib/uri_template/colon.rb
CHANGED
data/lib/uri_template/rfc6570.rb
CHANGED
@@ -35,6 +35,7 @@ class URITemplate::RFC6570
|
|
35
35
|
# @private
|
36
36
|
Utils = URITemplate::Utils
|
37
37
|
|
38
|
+
# :nocov:
|
38
39
|
if Utils.use_unicode?
|
39
40
|
# @private
|
40
41
|
# \/ - unicode ctrl-chars
|
@@ -43,6 +44,7 @@ class URITemplate::RFC6570
|
|
43
44
|
# @private
|
44
45
|
LITERAL = Regexp.compile('([^"\'%<>\\\\^`{|}\x00-\x1F\x7F-\x9F\s]|%[0-9a-fA-F]{2})+',Utils::KCODE_UTF8)
|
45
46
|
end
|
47
|
+
# :nocov:
|
46
48
|
|
47
49
|
# @private
|
48
50
|
CHARACTER_CLASSES = {
|
@@ -84,13 +86,32 @@ class URITemplate::RFC6570
|
|
84
86
|
DEFAULT_PROCESSING = CONVERT_VALUES + CONVERT_RESULT
|
85
87
|
|
86
88
|
# @private
|
87
|
-
VAR = Regexp.compile(<<'__REGEXP__'
|
88
|
-
(
|
89
|
+
VAR = Regexp.compile(Utils.compact_regexp(<<'__REGEXP__'), Utils::KCODE_UTF8)
|
90
|
+
(
|
91
|
+
(?:[a-zA-Z0-9_]|%[0-9a-fA-F]{2})
|
92
|
+
(?:\.?
|
93
|
+
(?:[a-zA-Z0-9_]|%[0-9a-fA-F]{2})
|
94
|
+
)*
|
95
|
+
)
|
96
|
+
(?:(\*)|:([1-9]\d{0,3})|)
|
89
97
|
__REGEXP__
|
90
98
|
|
91
99
|
# @private
|
92
|
-
EXPRESSION = Regexp.compile(<<'__REGEXP__'
|
93
|
-
\{
|
100
|
+
EXPRESSION = Regexp.compile(Utils.compact_regexp(<<'__REGEXP__'), Utils::KCODE_UTF8)
|
101
|
+
\{
|
102
|
+
([+#\./;?&]?)
|
103
|
+
(
|
104
|
+
(?:[a-zA-Z0-9_]|%[0-9a-fA-F]{2})
|
105
|
+
(?:\.?(?:[a-zA-Z0-9_]|%[0-9a-fA-F]{2}))*
|
106
|
+
(?:\*|:[1-9]\d{0,3}|)
|
107
|
+
(?:
|
108
|
+
,
|
109
|
+
(?:[a-zA-Z0-9_]|%[0-9a-fA-F]{2})
|
110
|
+
(?:\.?(?:[a-zA-Z0-9_]|%[0-9a-fA-F]{2}))*
|
111
|
+
(?:\*|:[1-9]\d{0,3}|)
|
112
|
+
)*
|
113
|
+
)
|
114
|
+
\}
|
94
115
|
__REGEXP__
|
95
116
|
|
96
117
|
# @private
|
@@ -115,10 +136,6 @@ __REGEXP__
|
|
115
136
|
1
|
116
137
|
end
|
117
138
|
|
118
|
-
def arity
|
119
|
-
0
|
120
|
-
end
|
121
|
-
|
122
139
|
def to_r_source(*_)
|
123
140
|
Regexp.escape(@string)
|
124
141
|
end
|
@@ -366,7 +383,6 @@ __REGEXP__
|
|
366
383
|
if block_given?
|
367
384
|
return yield result
|
368
385
|
end
|
369
|
-
|
370
386
|
return result
|
371
387
|
end
|
372
388
|
end
|
@@ -435,10 +451,6 @@ protected
|
|
435
451
|
self.class::Tokenizer.new(pattern, self.class::OPERATORS).to_a
|
436
452
|
end
|
437
453
|
|
438
|
-
def arity
|
439
|
-
@arity ||= tokens.inject(0){|a,t| a + t.arity }
|
440
|
-
end
|
441
|
-
|
442
454
|
# @private
|
443
455
|
def extract_matchdata(matchdata, post_processing)
|
444
456
|
bc = 1
|
@@ -460,7 +472,7 @@ protected
|
|
460
472
|
return Hash[vars]
|
461
473
|
end
|
462
474
|
else
|
463
|
-
if post_processing.include? :
|
475
|
+
if post_processing.include? :convert_values
|
464
476
|
return vars.collect{|k,v| [k,Utils.pair_array_to_hash(v)] }
|
465
477
|
else
|
466
478
|
return vars
|
@@ -471,4 +483,4 @@ protected
|
|
471
483
|
end
|
472
484
|
|
473
485
|
require 'uri_template/rfc6570/regex_builder.rb'
|
474
|
-
require 'uri_template/rfc6570/expression.rb'
|
486
|
+
require 'uri_template/rfc6570/expression.rb'
|
@@ -41,7 +41,6 @@ class URITemplate::RFC6570
|
|
41
41
|
|
42
42
|
CHARACTER_CLASS = CHARACTER_CLASSES[:unreserved]
|
43
43
|
|
44
|
-
NAMED = false
|
45
44
|
OPERATOR = ''
|
46
45
|
|
47
46
|
def level
|
@@ -56,10 +55,6 @@ class URITemplate::RFC6570
|
|
56
55
|
end
|
57
56
|
end
|
58
57
|
|
59
|
-
def expands?
|
60
|
-
@variable_specs.any?{|_,expand,_| expand }
|
61
|
-
end
|
62
|
-
|
63
58
|
def arity
|
64
59
|
@variable_specs.size
|
65
60
|
end
|
@@ -241,8 +236,6 @@ class URITemplate::RFC6570
|
|
241
236
|
def transform_hash(name, hsh, expand , max_length)
|
242
237
|
if expand
|
243
238
|
hsh.map{|key,value| pair(escape(key),value) }
|
244
|
-
elsif hsh.none? && !self.class::NAMED
|
245
|
-
[]
|
246
239
|
else
|
247
240
|
[ self_pair(name,hsh){|key,value| escape(key)+self.class::LIST_CONNECTOR+escape(value)} ]
|
248
241
|
end
|
@@ -251,8 +244,6 @@ class URITemplate::RFC6570
|
|
251
244
|
def transform_array(name, ary, expand , max_length)
|
252
245
|
if expand
|
253
246
|
ary.map{|value| self_pair(name,value) }
|
254
|
-
elsif ary.none? && !self.class::NAMED
|
255
|
-
[]
|
256
247
|
else
|
257
248
|
[ self_pair(name, ary){|value| escape(value) } ]
|
258
249
|
end
|
@@ -332,7 +323,6 @@ class URITemplate::RFC6570
|
|
332
323
|
|
333
324
|
SEPARATOR = ';'.freeze
|
334
325
|
PREFIX = ';'.freeze
|
335
|
-
NAMED = true
|
336
326
|
PAIR_IF_EMPTY = false
|
337
327
|
OPERATOR = ';'.freeze
|
338
328
|
BASE_LEVEL = 3
|
@@ -343,7 +333,6 @@ class URITemplate::RFC6570
|
|
343
333
|
|
344
334
|
SEPARATOR = '&'.freeze
|
345
335
|
PREFIX = '?'.freeze
|
346
|
-
NAMED = true
|
347
336
|
OPERATOR = '?'.freeze
|
348
337
|
BASE_LEVEL = 3
|
349
338
|
|
@@ -353,7 +342,6 @@ class URITemplate::RFC6570
|
|
353
342
|
|
354
343
|
SEPARATOR = '&'.freeze
|
355
344
|
PREFIX = '&'.freeze
|
356
|
-
NAMED = true
|
357
345
|
OPERATOR = '&'.freeze
|
358
346
|
BASE_LEVEL = 3
|
359
347
|
|
@@ -371,4 +359,4 @@ class URITemplate::RFC6570
|
|
371
359
|
'&' => Expression::FormQueryContinuation
|
372
360
|
}
|
373
361
|
|
374
|
-
end
|
362
|
+
end
|
@@ -65,6 +65,16 @@ class URITemplate::RFC6570::Expression::Unnamed < URITemplate::RFC6570::Expressi
|
|
65
65
|
|
66
66
|
private
|
67
67
|
|
68
|
+
def transform_hash(name, hsh, expand , max_length)
|
69
|
+
return [] if hsh.none?
|
70
|
+
super
|
71
|
+
end
|
72
|
+
|
73
|
+
def transform_array(name, ary, expand , max_length)
|
74
|
+
return [] if ary.none?
|
75
|
+
super
|
76
|
+
end
|
77
|
+
|
68
78
|
def after_expand(name, splitted)
|
69
79
|
if splitted.none?{|_,b| b }
|
70
80
|
return [ [ name, splitted.map{|a,_| a } ] ]
|
@@ -73,4 +83,4 @@ private
|
|
73
83
|
end
|
74
84
|
end
|
75
85
|
|
76
|
-
end
|
86
|
+
end
|
data/lib/uri_template/utils.rb
CHANGED
@@ -14,7 +14,6 @@
|
|
14
14
|
#
|
15
15
|
# (c) 2011 - 2012 by Hannes Georg
|
16
16
|
#
|
17
|
-
|
18
17
|
module URITemplate
|
19
18
|
|
20
19
|
# An awesome little helper which helps iterating over a string.
|
@@ -31,14 +30,13 @@ module URITemplate
|
|
31
30
|
|
32
31
|
def each(str)
|
33
32
|
raise ArgumentError, "RegexpEnumerator#each expects a String, but got #{str.inspect}" unless str.kind_of? String
|
34
|
-
return
|
33
|
+
return self.to_enum(:each,str) unless block_given?
|
35
34
|
rest = str
|
36
35
|
loop do
|
37
36
|
m = @regexp.match(rest)
|
38
37
|
if m.nil?
|
39
38
|
if rest.size > 0
|
40
|
-
yield rest
|
41
|
-
raise "Unable to match #{rest.inspect} against #{@regexp.inspect}" if @rest == :raise
|
39
|
+
yield rest
|
42
40
|
end
|
43
41
|
break
|
44
42
|
end
|
@@ -83,69 +81,65 @@ module URITemplate
|
|
83
81
|
# Bundles some string encoding methods.
|
84
82
|
module StringEncoding
|
85
83
|
|
86
|
-
#
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
str
|
94
|
-
|
84
|
+
# Methods which do actual encoding.
|
85
|
+
module Encode
|
86
|
+
# converts a string to ascii
|
87
|
+
#
|
88
|
+
# @param str [String]
|
89
|
+
# @return String
|
90
|
+
# @visibility public
|
91
|
+
def to_ascii(str)
|
92
|
+
str.encode(Encoding::ASCII)
|
93
|
+
end
|
95
94
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
95
|
+
# converts a string to utf8
|
96
|
+
#
|
97
|
+
# @param str [String]
|
98
|
+
# @return String
|
99
|
+
# @visibility public
|
100
|
+
def to_utf8(str)
|
101
|
+
str.encode(Encoding::UTF_8)
|
102
|
+
end
|
103
|
+
|
104
|
+
# enforces UTF8 encoding
|
105
|
+
#
|
106
|
+
# @param str [String]
|
107
|
+
# @return String
|
108
|
+
# @visibility public
|
109
|
+
def force_utf8(str)
|
110
|
+
return str if str.encoding == Encoding::UTF_8
|
111
|
+
str = str.dup if str.frozen?
|
112
|
+
return str.force_encoding(Encoding::UTF_8)
|
113
|
+
end
|
105
114
|
|
106
|
-
# @method force_utf8(str)
|
107
|
-
# enforces UTF8 encoding
|
108
|
-
#
|
109
|
-
# @param str [String]
|
110
|
-
# @return String
|
111
|
-
# @visibility public
|
112
|
-
def force_utf8_encode(str)
|
113
|
-
return str if str.encoding == Encoding::UTF_8
|
114
|
-
str = str.dup if str.frozen?
|
115
|
-
return str.force_encoding(Encoding::UTF_8)
|
116
115
|
end
|
117
116
|
|
117
|
+
# Fallback methods to be used in pre 1.9 rubies.
|
118
|
+
module Fallback
|
118
119
|
|
119
|
-
|
120
|
-
|
121
|
-
|
120
|
+
def to_ascii(str)
|
121
|
+
str
|
122
|
+
end
|
122
123
|
|
123
|
-
|
124
|
-
|
125
|
-
|
124
|
+
def to_utf8(str)
|
125
|
+
str
|
126
|
+
end
|
127
|
+
|
128
|
+
def force_utf8(str)
|
129
|
+
str
|
130
|
+
end
|
126
131
|
|
127
|
-
def force_utf8_fallback(str)
|
128
|
-
str
|
129
132
|
end
|
130
133
|
|
134
|
+
# :nocov:
|
131
135
|
if "".respond_to?(:encode)
|
132
|
-
|
133
|
-
send(:alias_method, :to_ascii, :to_ascii_encode)
|
134
|
-
# @api private
|
135
|
-
send(:alias_method, :to_utf8, :to_utf8_encode)
|
136
|
-
# @api private
|
137
|
-
send(:alias_method, :force_utf8, :force_utf8_encode)
|
136
|
+
include Encode
|
138
137
|
else
|
139
|
-
|
140
|
-
send(:alias_method, :to_ascii, :to_ascii_fallback)
|
141
|
-
# @api private
|
142
|
-
send(:alias_method, :to_utf8, :to_utf8_fallback)
|
143
|
-
# @api private
|
144
|
-
send(:alias_method, :force_utf8, :force_utf8_fallback)
|
138
|
+
include Fallback
|
145
139
|
end
|
140
|
+
# :nocov:
|
146
141
|
|
147
|
-
|
148
|
-
public :to_utf8
|
142
|
+
private :force_utf8
|
149
143
|
|
150
144
|
end
|
151
145
|
|
@@ -155,8 +149,6 @@ module URITemplate
|
|
155
149
|
# The performance is acceptable, but could be better with escape_utils.
|
156
150
|
module Pure
|
157
151
|
|
158
|
-
include StringEncoding
|
159
|
-
|
160
152
|
# @private
|
161
153
|
URL_ESCAPED = /([^A-Za-z0-9\-\._])/.freeze
|
162
154
|
|
@@ -179,13 +171,13 @@ module URITemplate
|
|
179
171
|
end
|
180
172
|
|
181
173
|
def unescape_url(s)
|
182
|
-
force_utf8( to_ascii(s).gsub('+',' ').gsub(PCT){
|
174
|
+
force_utf8( to_ascii(s.to_s).gsub('+',' ').gsub(PCT){
|
183
175
|
$1.to_i(16).chr
|
184
176
|
} )
|
185
177
|
end
|
186
178
|
|
187
179
|
def unescape_uri(s)
|
188
|
-
force_utf8( to_ascii(s).gsub(PCT){
|
180
|
+
force_utf8( to_ascii(s.to_s).gsub(PCT){
|
189
181
|
$1.to_i(16).chr
|
190
182
|
})
|
191
183
|
end
|
@@ -202,8 +194,6 @@ module URITemplate
|
|
202
194
|
# The performance is good, espacially for strings with many escaped characters.
|
203
195
|
module EscapeUtils
|
204
196
|
|
205
|
-
include StringEncoding
|
206
|
-
|
207
197
|
include ::EscapeUtils
|
208
198
|
|
209
199
|
def using_escape_utils?
|
@@ -211,19 +201,19 @@ module URITemplate
|
|
211
201
|
end
|
212
202
|
|
213
203
|
def escape_url(s)
|
214
|
-
super(to_utf8(s)).gsub('+','%20')
|
204
|
+
super(to_utf8(s.to_s)).gsub('+','%20')
|
215
205
|
end
|
216
206
|
|
217
207
|
def escape_uri(s)
|
218
|
-
super(to_utf8(s))
|
208
|
+
super(to_utf8(s.to_s))
|
219
209
|
end
|
220
210
|
|
221
211
|
def unescape_url(s)
|
222
|
-
force_utf8(super(to_ascii(s)))
|
212
|
+
force_utf8(super(to_ascii(s.to_s)))
|
223
213
|
end
|
224
214
|
|
225
215
|
def unescape_uri(s)
|
226
|
-
force_utf8(super(to_ascii(s)))
|
216
|
+
force_utf8(super(to_ascii(s.to_s)))
|
227
217
|
end
|
228
218
|
|
229
219
|
end
|
@@ -233,7 +223,7 @@ module URITemplate
|
|
233
223
|
end
|
234
224
|
|
235
225
|
include StringEncoding
|
236
|
-
|
226
|
+
# :nocov:
|
237
227
|
if Escaping.const_defined? :EscapeUtils
|
238
228
|
include Escaping::EscapeUtils
|
239
229
|
puts "Using escape_utils." if $VERBOSE
|
@@ -241,6 +231,7 @@ module URITemplate
|
|
241
231
|
include Escaping::Pure
|
242
232
|
puts "Not using escape_utils." if $VERBOSE
|
243
233
|
end
|
234
|
+
# :nocov:
|
244
235
|
|
245
236
|
# Converts an object to a param value.
|
246
237
|
# Tries to call :to_param and then :to_s on that object.
|
@@ -267,9 +258,7 @@ module URITemplate
|
|
267
258
|
# @api private
|
268
259
|
# Should we use \u.... or \x.. in regexps?
|
269
260
|
def use_unicode?
|
270
|
-
|
271
|
-
rescue SyntaxError
|
272
|
-
false
|
261
|
+
eval('Regexp.compile("\u0020")') =~ " " rescue false
|
273
262
|
end
|
274
263
|
|
275
264
|
# Returns true when the given value is an array and it only consists of arrays with two items.
|
@@ -328,6 +317,11 @@ module URITemplate
|
|
328
317
|
return result
|
329
318
|
end
|
330
319
|
|
320
|
+
# @api private
|
321
|
+
def compact_regexp(rx)
|
322
|
+
rx.split("\n").map(&:strip).join
|
323
|
+
end
|
324
|
+
|
331
325
|
end
|
332
326
|
|
333
327
|
end
|
data/uri_template.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uri_template
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,14 +9,14 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-03-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_json
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0'
|
30
30
|
- !ruby/object:Gem::Dependency
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
none: false
|
34
34
|
requirements:
|
35
|
-
- -
|
35
|
+
- - '>='
|
36
36
|
- !ruby/object:Gem::Version
|
37
37
|
version: '0'
|
38
38
|
type: :development
|
@@ -40,7 +40,7 @@ dependencies:
|
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
|
-
- -
|
43
|
+
- - '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
46
|
- !ruby/object:Gem::Dependency
|
@@ -48,7 +48,7 @@ dependencies:
|
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
49
49
|
none: false
|
50
50
|
requirements:
|
51
|
-
- -
|
51
|
+
- - '>='
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: '0'
|
54
54
|
type: :development
|
@@ -56,7 +56,7 @@ dependencies:
|
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
none: false
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
- !ruby/object:Gem::Dependency
|
@@ -64,7 +64,7 @@ dependencies:
|
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
65
65
|
none: false
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - '>='
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
70
|
type: :development
|
@@ -72,7 +72,7 @@ dependencies:
|
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
|
-
- -
|
75
|
+
- - '>='
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0'
|
78
78
|
- !ruby/object:Gem::Dependency
|
@@ -80,7 +80,7 @@ dependencies:
|
|
80
80
|
requirement: !ruby/object:Gem::Requirement
|
81
81
|
none: false
|
82
82
|
requirements:
|
83
|
-
- -
|
83
|
+
- - '>='
|
84
84
|
- !ruby/object:Gem::Version
|
85
85
|
version: '0'
|
86
86
|
type: :development
|
@@ -88,7 +88,7 @@ dependencies:
|
|
88
88
|
version_requirements: !ruby/object:Gem::Requirement
|
89
89
|
none: false
|
90
90
|
requirements:
|
91
|
-
- -
|
91
|
+
- - '>='
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: '0'
|
94
94
|
description: A templating system for URIs, which implements RFC6570 and Colon based
|
@@ -98,16 +98,16 @@ executables: []
|
|
98
98
|
extensions: []
|
99
99
|
extra_rdoc_files: []
|
100
100
|
files:
|
101
|
-
- lib/uri_template/
|
102
|
-
- lib/uri_template/rfc6570/regex_builder.rb
|
103
|
-
- lib/uri_template/rfc6570/expression/named.rb
|
104
|
-
- lib/uri_template/rfc6570/expression/unnamed.rb
|
101
|
+
- lib/uri_template/utils.rb
|
105
102
|
- lib/uri_template/colon.rb
|
106
|
-
- lib/uri_template/literal.rb
|
107
103
|
- lib/uri_template/expression.rb
|
108
|
-
- lib/uri_template/utils.rb
|
109
|
-
- lib/uri_template/rfc6570.rb
|
110
104
|
- lib/uri_template/token.rb
|
105
|
+
- lib/uri_template/rfc6570.rb
|
106
|
+
- lib/uri_template/literal.rb
|
107
|
+
- lib/uri_template/rfc6570/regex_builder.rb
|
108
|
+
- lib/uri_template/rfc6570/expression/unnamed.rb
|
109
|
+
- lib/uri_template/rfc6570/expression/named.rb
|
110
|
+
- lib/uri_template/rfc6570/expression.rb
|
111
111
|
- lib/uri_template.rb
|
112
112
|
- uri_template.gemspec
|
113
113
|
- README.md
|
@@ -121,18 +121,18 @@ require_paths:
|
|
121
121
|
required_ruby_version: !ruby/object:Gem::Requirement
|
122
122
|
none: false
|
123
123
|
requirements:
|
124
|
-
- -
|
124
|
+
- - '>='
|
125
125
|
- !ruby/object:Gem::Version
|
126
126
|
version: '0'
|
127
127
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
128
|
none: false
|
129
129
|
requirements:
|
130
|
-
- -
|
130
|
+
- - '>='
|
131
131
|
- !ruby/object:Gem::Version
|
132
132
|
version: '0'
|
133
133
|
requirements: []
|
134
134
|
rubyforge_project:
|
135
|
-
rubygems_version: 1.8.
|
135
|
+
rubygems_version: 1.8.25
|
136
136
|
signing_key:
|
137
137
|
specification_version: 3
|
138
138
|
summary: A templating system for URIs.
|