stduritemplate 0.0.39 → 0.0.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/stduritemplate.rb +60 -60
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4d545b136300c042c615e3e74151ebcad99d57e03f77f3e28181241fc0f5ad04
4
- data.tar.gz: 80b581405dbf57a57a6f5dbd870f0da57e16f1a9a5af192c37c69896391efd2c
3
+ metadata.gz: f8efa6481a69bb31c06154ce5f3193acf9c4a4ea1cb36b2c4247180a203d3872
4
+ data.tar.gz: 490c842eacdedc77dbc711e72c6eb36b8fa8487be15c31793057a5b6716665a0
5
5
  SHA512:
6
- metadata.gz: 38cbefb6a6c99f6dbfad3a520608b4401c23c9492ce84f66d212228a04b27d986bf975d91269abf5dcdfb7542144c887bda802b00d9b2a11527d5888ce704142
7
- data.tar.gz: 7f209da0078a0e73435004279c0e015473c31ddc3f55911525014f35e8c912e2116da2ba6d2da4e0577c6259ba7f54ac60d6b2e3567fc0307fc38a951561e55b
6
+ metadata.gz: 990ccb2e37e117856cca2bff247fea4fa01bbdeed93c19072fb6254345d6bf4b97f381f61c8d68c2f574058f9e490e4fbacc1cb360f530c16b1e25522a591799
7
+ data.tar.gz: c724e45e47e788d6060b213a7b9f600bdb5ed8ba86a21a14c06e75ea705eaee67d6eb6bc28c22944259119e378e65ef08db5c07d699af7045d0d3c44bf9a932e
@@ -10,8 +10,8 @@ module StdUriTemplate
10
10
  # Private implementation
11
11
  private
12
12
 
13
- module Modifier
14
- NO_MOD = :no_mod
13
+ module Operator
14
+ NO_OP = :no_op
15
15
  PLUS = :plus
16
16
  HASH = :hash
17
17
  DOT = :dot
@@ -44,33 +44,33 @@ module StdUriTemplate
44
44
  end
45
45
  end
46
46
 
47
- def self.get_modifier(c, token, col)
47
+ def self.get_operator(c, token, col)
48
48
  case c
49
49
  when '+'
50
- Modifier::PLUS
50
+ Operator::PLUS
51
51
  when '#'
52
- Modifier::HASH
52
+ Operator::HASH
53
53
  when '.'
54
- Modifier::DOT
54
+ Operator::DOT
55
55
  when '/'
56
- Modifier::SLASH
56
+ Operator::SLASH
57
57
  when ';'
58
- Modifier::SEMICOLON
58
+ Operator::SEMICOLON
59
59
  when '?'
60
- Modifier::QUESTION_MARK
60
+ Operator::QUESTION_MARK
61
61
  when '&'
62
- Modifier::AMP
62
+ Operator::AMP
63
63
  else
64
64
  validate_literal(c, col)
65
65
  token << c
66
- Modifier::NO_MOD
66
+ Operator::NO_OP
67
67
  end
68
68
  end
69
69
 
70
70
  def self.expand_impl(str, substitutions)
71
71
  result = ''
72
72
  token = nil
73
- modifier = nil
73
+ operator = nil
74
74
  composite = false
75
75
  max_char_buffer = nil
76
76
  first_token = true
@@ -82,10 +82,10 @@ module StdUriTemplate
82
82
  first_token = true
83
83
  when '}'
84
84
  if token
85
- expanded = expand_token(modifier, token, composite, get_max_char(max_char_buffer, i), first_token, substitutions, result, i)
85
+ expanded = expand_token(operator, token, composite, get_max_char(max_char_buffer, i), first_token, substitutions, result, i)
86
86
  first_token = false if expanded && first_token
87
87
  token = nil
88
- modifier = nil
88
+ operator = nil
89
89
  composite = false
90
90
  max_char_buffer = nil
91
91
  else
@@ -93,7 +93,7 @@ module StdUriTemplate
93
93
  end
94
94
  when ','
95
95
  if token
96
- expanded = expand_token(modifier, token, composite, get_max_char(max_char_buffer, i), first_token, substitutions, result, i)
96
+ expanded = expand_token(operator, token, composite, get_max_char(max_char_buffer, i), first_token, substitutions, result, i)
97
97
  first_token = false if expanded && first_token
98
98
  token = ''
99
99
  composite = false
@@ -101,8 +101,8 @@ module StdUriTemplate
101
101
  end
102
102
  else
103
103
  if token
104
- if modifier.nil?
105
- modifier = get_modifier(character, token, i)
104
+ if operator.nil?
105
+ operator = get_operator(character, token, i)
106
106
  elsif max_char_buffer
107
107
  if character =~ /\d/
108
108
  max_char_buffer << character
@@ -132,59 +132,59 @@ module StdUriTemplate
132
132
  end
133
133
  end
134
134
 
135
- def self.add_prefix(mod, result)
136
- case mod
137
- when Modifier::HASH
135
+ def self.add_prefix(op, result)
136
+ case op
137
+ when Operator::HASH
138
138
  result << '#'
139
- when Modifier::DOT
139
+ when Operator::DOT
140
140
  result << '.'
141
- when Modifier::SLASH
141
+ when Operator::SLASH
142
142
  result << '/'
143
- when Modifier::SEMICOLON
143
+ when Operator::SEMICOLON
144
144
  result << ';'
145
- when Modifier::QUESTION_MARK
145
+ when Operator::QUESTION_MARK
146
146
  result << '?'
147
- when Modifier::AMP
147
+ when Operator::AMP
148
148
  result << '&'
149
149
  end
150
150
  end
151
151
 
152
- def self.add_separator(mod, result)
153
- case mod
154
- when Modifier::DOT
152
+ def self.add_separator(op, result)
153
+ case op
154
+ when Operator::DOT
155
155
  result << '.'
156
- when Modifier::SLASH
156
+ when Operator::SLASH
157
157
  result << '/'
158
- when Modifier::SEMICOLON
158
+ when Operator::SEMICOLON
159
159
  result << ';'
160
- when Modifier::QUESTION_MARK, Modifier::AMP
160
+ when Operator::QUESTION_MARK, Operator::AMP
161
161
  result << '&'
162
162
  else
163
163
  result << ','
164
164
  end
165
165
  end
166
166
 
167
- def self.add_value(mod, token, value, result, max_char)
168
- case mod
169
- when Modifier::PLUS, Modifier::HASH
167
+ def self.add_value(op, token, value, result, max_char)
168
+ case op
169
+ when Operator::PLUS, Operator::HASH
170
170
  add_expanded_value(value, result, max_char, false)
171
- when Modifier::QUESTION_MARK, Modifier::AMP
171
+ when Operator::QUESTION_MARK, Operator::AMP
172
172
  result << token + '='
173
173
  add_expanded_value(value, result, max_char, true)
174
- when Modifier::SEMICOLON
174
+ when Operator::SEMICOLON
175
175
  result << token
176
176
  result << '=' unless value.empty?
177
177
  add_expanded_value(value, result, max_char, true)
178
- when Modifier::DOT, Modifier::SLASH, Modifier::NO_MOD
178
+ when Operator::DOT, Operator::SLASH, Operator::NO_OP
179
179
  add_expanded_value(value, result, max_char, true)
180
180
  end
181
181
  end
182
182
 
183
- def self.add_value_element(mod, token, value, result, max_char)
184
- case mod
185
- when Modifier::PLUS, Modifier::HASH
183
+ def self.add_value_element(op, token, value, result, max_char)
184
+ case op
185
+ when Operator::PLUS, Operator::HASH
186
186
  add_expanded_value(value, result, max_char, false)
187
- when Modifier::QUESTION_MARK, Modifier::AMP, Modifier::SEMICOLON, Modifier::DOT, Modifier::SLASH, Modifier::NO_MOD
187
+ when Operator::QUESTION_MARK, Operator::AMP, Operator::SEMICOLON, Operator::DOT, Operator::SLASH, Operator::NO_OP
188
188
  add_expanded_value(value, result, max_char, true)
189
189
  end
190
190
  end
@@ -284,7 +284,7 @@ module StdUriTemplate
284
284
  end
285
285
  end
286
286
 
287
- def self.expand_token(modifier, token, composite, max_char, first_token, substitutions, result, col)
287
+ def self.expand_token(operator, token, composite, max_char, first_token, substitutions, result, col)
288
288
  raise ArgumentError, "Found an empty token at col:#{col}" if token.empty?
289
289
 
290
290
  value = substitutions[token]
@@ -295,65 +295,65 @@ module StdUriTemplate
295
295
  return false if empty?(subst_type, value)
296
296
 
297
297
  if first_token
298
- add_prefix(modifier, result)
298
+ add_prefix(operator, result)
299
299
  else
300
- add_separator(modifier, result)
300
+ add_separator(operator, result)
301
301
  end
302
302
 
303
303
  case subst_type
304
304
  when SubstitutionType::STRING
305
- add_string_value(modifier, token, value.to_s, result, max_char)
305
+ add_string_value(operator, token, value.to_s, result, max_char)
306
306
  when SubstitutionType::LIST
307
- add_list_value(modifier, token, value, result, max_char, composite)
307
+ add_list_value(operator, token, value, result, max_char, composite)
308
308
  when SubstitutionType::MAP
309
- add_map_value(modifier, token, value, result, max_char, composite)
309
+ add_map_value(operator, token, value, result, max_char, composite)
310
310
  end
311
311
 
312
312
  true
313
313
  end
314
314
 
315
- def self.add_string_value(modifier, token, value, result, max_char)
316
- add_value(modifier, token, value, result, max_char)
315
+ def self.add_string_value(operator, token, value, result, max_char)
316
+ add_value(operator, token, value, result, max_char)
317
317
  end
318
318
 
319
- def self.add_list_value(modifier, token, value, result, max_char, composite)
319
+ def self.add_list_value(operator, token, value, result, max_char, composite)
320
320
  first = true
321
321
  value.each do |v|
322
322
  if first
323
- add_value(modifier, token, v.to_s, result, max_char)
323
+ add_value(operator, token, v.to_s, result, max_char)
324
324
  first = false
325
325
  else
326
326
  if composite
327
- add_separator(modifier, result)
328
- add_value(modifier, token, v.to_s, result, max_char)
327
+ add_separator(operator, result)
328
+ add_value(operator, token, v.to_s, result, max_char)
329
329
  else
330
330
  result << ','
331
- add_value_element(modifier, token, v.to_s, result, max_char)
331
+ add_value_element(operator, token, v.to_s, result, max_char)
332
332
  end
333
333
  end
334
334
  end
335
335
  !first
336
336
  end
337
337
 
338
- def self.add_map_value(modifier, token, value, result, max_char, composite)
338
+ def self.add_map_value(operator, token, value, result, max_char, composite)
339
339
  first = true
340
340
  raise ArgumentError, 'Value trimming is not allowed on Maps' if max_char != -1
341
341
 
342
342
  value.each do |key, val|
343
343
  if composite
344
- add_separator(modifier, result) unless first
345
- add_value_element(modifier, token, key.to_s, result, max_char)
344
+ add_separator(operator, result) unless first
345
+ add_value_element(operator, token, key.to_s, result, max_char)
346
346
  result << '='
347
347
  else
348
348
  if first
349
- add_value(modifier, token, key.to_s, result, max_char)
349
+ add_value(operator, token, key.to_s, result, max_char)
350
350
  else
351
351
  result << ','
352
- add_value_element(modifier, token, key.to_s, result, max_char)
352
+ add_value_element(operator, token, key.to_s, result, max_char)
353
353
  end
354
354
  result << ','
355
355
  end
356
- add_value_element(modifier, token, val.to_s, result, max_char)
356
+ add_value_element(operator, token, val.to_s, result, max_char)
357
357
  first = false
358
358
  end
359
359
  !first
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stduritemplate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.39
4
+ version: 0.0.40
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrea Peruffo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-06 00:00:00.000000000 Z
11
+ date: 2023-09-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: std-uritemplate implementation for Ruby
14
14
  email: andrea.peruffo1982@gmail.com