aws-codedeploy-agent 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.md +4 -0
- data/aws-codedeploy-agent.gemspec +7 -9
- metadata +41 -68
- data/vendor/gems/jmespath-1.0.1/lib/jmespath.rb +0 -41
- data/vendor/gems/jmespath-1.0.1/lib/jmespath/caching_parser.rb +0 -30
- data/vendor/gems/jmespath-1.0.1/lib/jmespath/errors.rb +0 -17
- data/vendor/gems/jmespath-1.0.1/lib/jmespath/expr_node.rb +0 -15
- data/vendor/gems/jmespath-1.0.1/lib/jmespath/lexer.rb +0 -116
- data/vendor/gems/jmespath-1.0.1/lib/jmespath/parser.rb +0 -347
- data/vendor/gems/jmespath-1.0.1/lib/jmespath/runtime.rb +0 -71
- data/vendor/gems/jmespath-1.0.1/lib/jmespath/token.rb +0 -41
- data/vendor/gems/jmespath-1.0.1/lib/jmespath/token_stream.rb +0 -60
- data/vendor/gems/jmespath-1.0.1/lib/jmespath/tree_interpreter.rb +0 -523
- data/vendor/gems/jmespath-1.0.1/lib/jmespath/version.rb +0 -3
@@ -1,347 +0,0 @@
|
|
1
|
-
require 'set'
|
2
|
-
|
3
|
-
module JMESPath
|
4
|
-
# @api private
|
5
|
-
class Parser
|
6
|
-
|
7
|
-
# @api private
|
8
|
-
AFTER_DOT = Set.new([
|
9
|
-
:identifier, # foo.bar
|
10
|
-
:quoted_identifier, # foo."bar"
|
11
|
-
:star, # foo.*
|
12
|
-
:lbrace, # foo[1]
|
13
|
-
:lbracket, # foo{a: 0}
|
14
|
-
:function, # foo.*.to_string(@)
|
15
|
-
:filter, # foo.[?bar==10]
|
16
|
-
])
|
17
|
-
|
18
|
-
CURRENT_NODE = { type: :current }
|
19
|
-
|
20
|
-
# @option options [Lexer] :lexer
|
21
|
-
def initialize(options = {})
|
22
|
-
@lexer = options[:lexer] || Lexer.new()
|
23
|
-
end
|
24
|
-
|
25
|
-
# @param [String<JMESPath>] expression
|
26
|
-
def parse(expression)
|
27
|
-
stream = TokenStream.new(expression, @lexer.tokenize(expression))
|
28
|
-
result = expr(stream)
|
29
|
-
if stream.token.type != :eof
|
30
|
-
raise Errors::SyntaxError, "expected :eof got #{stream.token.type}"
|
31
|
-
else
|
32
|
-
result
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
# @api private
|
37
|
-
def method_missing(method_name, *args)
|
38
|
-
if matches = method_name.match(/^(nud_|led_)(.*)/)
|
39
|
-
raise Errors::SyntaxError, "unexpected token #{matches[2]}"
|
40
|
-
else
|
41
|
-
super
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
private
|
46
|
-
|
47
|
-
# @param [TokenStream] stream
|
48
|
-
# @param [Integer] rbp Right binding power
|
49
|
-
def expr(stream, rbp = 0)
|
50
|
-
left = send("nud_#{stream.token.type}", stream)
|
51
|
-
while rbp < stream.token.binding_power
|
52
|
-
left = send("led_#{stream.token.type}", stream, left)
|
53
|
-
end
|
54
|
-
left
|
55
|
-
end
|
56
|
-
|
57
|
-
def nud_current(stream)
|
58
|
-
stream.next
|
59
|
-
CURRENT_NODE
|
60
|
-
end
|
61
|
-
|
62
|
-
def nud_expref(stream)
|
63
|
-
stream.next
|
64
|
-
{
|
65
|
-
type: :expression,
|
66
|
-
children: [expr(stream, 2)]
|
67
|
-
}
|
68
|
-
end
|
69
|
-
|
70
|
-
def nud_filter(stream)
|
71
|
-
led_filter(stream, CURRENT_NODE)
|
72
|
-
end
|
73
|
-
|
74
|
-
def nud_flatten(stream)
|
75
|
-
led_flatten(stream, CURRENT_NODE)
|
76
|
-
end
|
77
|
-
|
78
|
-
def nud_identifier(stream)
|
79
|
-
token = stream.token
|
80
|
-
stream.next
|
81
|
-
{ type: :field, key: token.value }
|
82
|
-
end
|
83
|
-
|
84
|
-
def nud_lbrace(stream)
|
85
|
-
valid_keys = Set.new([:quoted_identifier, :identifier])
|
86
|
-
stream.next(match:valid_keys)
|
87
|
-
pairs = []
|
88
|
-
begin
|
89
|
-
pairs << parse_key_value_pair(stream)
|
90
|
-
if stream.token.type == :comma
|
91
|
-
stream.next(match:valid_keys)
|
92
|
-
end
|
93
|
-
end while stream.token.type != :rbrace
|
94
|
-
stream.next
|
95
|
-
{
|
96
|
-
type: :multi_select_hash,
|
97
|
-
children: pairs
|
98
|
-
}
|
99
|
-
end
|
100
|
-
|
101
|
-
def nud_lbracket(stream)
|
102
|
-
stream.next
|
103
|
-
type = stream.token.type
|
104
|
-
if type == :number || type == :colon
|
105
|
-
parse_array_index_expression(stream)
|
106
|
-
elsif type == :star && stream.lookahead(1).type == :rbracket
|
107
|
-
parse_wildcard_array(stream)
|
108
|
-
else
|
109
|
-
parse_multi_select_list(stream)
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
def nud_literal(stream)
|
114
|
-
value = stream.token.value
|
115
|
-
stream.next
|
116
|
-
{
|
117
|
-
type: :literal,
|
118
|
-
value: value
|
119
|
-
}
|
120
|
-
end
|
121
|
-
|
122
|
-
def nud_quoted_identifier(stream)
|
123
|
-
token = stream.token
|
124
|
-
next_token = stream.next
|
125
|
-
if next_token.type == :lparen
|
126
|
-
msg = 'quoted identifiers are not allowed for function names'
|
127
|
-
raise Errors::SyntaxError, msg
|
128
|
-
else
|
129
|
-
{ type: :field, key: token[:value] }
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
def nud_star(stream)
|
134
|
-
parse_wildcard_object(stream, CURRENT_NODE)
|
135
|
-
end
|
136
|
-
|
137
|
-
def led_comparator(stream, left)
|
138
|
-
token = stream.token
|
139
|
-
stream.next
|
140
|
-
{
|
141
|
-
type: :comparator,
|
142
|
-
relation: token.value,
|
143
|
-
children: [
|
144
|
-
left,
|
145
|
-
expr(stream),
|
146
|
-
]
|
147
|
-
}
|
148
|
-
end
|
149
|
-
|
150
|
-
def led_dot(stream, left)
|
151
|
-
stream.next(match:AFTER_DOT)
|
152
|
-
if stream.token.type == :star
|
153
|
-
parse_wildcard_object(stream, left)
|
154
|
-
else
|
155
|
-
{
|
156
|
-
type: :subexpression,
|
157
|
-
children: [
|
158
|
-
left,
|
159
|
-
parse_dot(stream, Token::BINDING_POWER[:dot])
|
160
|
-
]
|
161
|
-
}
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
def led_filter(stream, left)
|
166
|
-
stream.next
|
167
|
-
expression = expr(stream)
|
168
|
-
if stream.token.type != :rbracket
|
169
|
-
raise Errors::SyntaxError, 'expected a closing rbracket for the filter'
|
170
|
-
end
|
171
|
-
stream.next
|
172
|
-
rhs = parse_projection(stream, Token::BINDING_POWER[:filter])
|
173
|
-
{
|
174
|
-
type: :projection,
|
175
|
-
from: :array,
|
176
|
-
children: [
|
177
|
-
left ? left : CURRENT_NODE,
|
178
|
-
{
|
179
|
-
type: :condition,
|
180
|
-
children: [expression, rhs],
|
181
|
-
}
|
182
|
-
]
|
183
|
-
}
|
184
|
-
end
|
185
|
-
|
186
|
-
def led_flatten(stream, left)
|
187
|
-
stream.next
|
188
|
-
{
|
189
|
-
type: :projection,
|
190
|
-
from: :array,
|
191
|
-
children: [
|
192
|
-
{ type: :flatten, children: [left] },
|
193
|
-
parse_projection(stream, Token::BINDING_POWER[:flatten])
|
194
|
-
]
|
195
|
-
}
|
196
|
-
end
|
197
|
-
|
198
|
-
def led_lbracket(stream, left)
|
199
|
-
stream.next(match: Set.new([:number, :colon, :star]))
|
200
|
-
type = stream.token.type
|
201
|
-
if type == :number || type == :colon
|
202
|
-
{
|
203
|
-
type: :subexpression,
|
204
|
-
children: [
|
205
|
-
left,
|
206
|
-
parse_array_index_expression(stream)
|
207
|
-
]
|
208
|
-
}
|
209
|
-
else
|
210
|
-
parse_wildcard_array(stream, left)
|
211
|
-
end
|
212
|
-
end
|
213
|
-
|
214
|
-
def led_lparen(stream, left)
|
215
|
-
args = []
|
216
|
-
name = left[:key]
|
217
|
-
stream.next
|
218
|
-
while stream.token.type != :rparen
|
219
|
-
args << expr(stream, 0)
|
220
|
-
if stream.token.type == :comma
|
221
|
-
stream.next
|
222
|
-
end
|
223
|
-
end
|
224
|
-
stream.next
|
225
|
-
{
|
226
|
-
type: :function,
|
227
|
-
fn: name,
|
228
|
-
children: args,
|
229
|
-
}
|
230
|
-
end
|
231
|
-
|
232
|
-
def led_or(stream, left)
|
233
|
-
stream.next
|
234
|
-
{
|
235
|
-
type: :or,
|
236
|
-
children: [left, expr(stream, Token::BINDING_POWER[:or])]
|
237
|
-
}
|
238
|
-
end
|
239
|
-
|
240
|
-
def led_pipe(stream, left)
|
241
|
-
stream.next
|
242
|
-
{
|
243
|
-
type: :pipe,
|
244
|
-
children: [left, expr(stream, Token::BINDING_POWER[:pipe])],
|
245
|
-
}
|
246
|
-
end
|
247
|
-
|
248
|
-
def parse_array_index_expression(stream)
|
249
|
-
pos = 0
|
250
|
-
parts = [nil, nil, nil]
|
251
|
-
begin
|
252
|
-
if stream.token.type == :colon
|
253
|
-
pos += 1
|
254
|
-
else
|
255
|
-
parts[pos] = stream.token.value
|
256
|
-
end
|
257
|
-
stream.next(match:Set.new([:number, :colon, :rbracket]))
|
258
|
-
end while stream.token.type != :rbracket
|
259
|
-
stream.next
|
260
|
-
if pos == 0
|
261
|
-
{ type: :index, index: parts[0] }
|
262
|
-
elsif pos > 2
|
263
|
-
raise Errors::SyntaxError, 'invalid array slice syntax: too many colons'
|
264
|
-
else
|
265
|
-
{ type: :slice, args: parts }
|
266
|
-
end
|
267
|
-
end
|
268
|
-
|
269
|
-
def parse_dot(stream, binding_power)
|
270
|
-
if stream.token.type == :lbracket
|
271
|
-
stream.next
|
272
|
-
parse_multi_select_list(stream)
|
273
|
-
else
|
274
|
-
expr(stream, binding_power)
|
275
|
-
end
|
276
|
-
end
|
277
|
-
|
278
|
-
def parse_key_value_pair(stream)
|
279
|
-
key = stream.token.value
|
280
|
-
stream.next(match:Set.new([:colon]))
|
281
|
-
stream.next
|
282
|
-
{
|
283
|
-
type: :key_value_pair,
|
284
|
-
key: key,
|
285
|
-
children: [expr(stream)]
|
286
|
-
}
|
287
|
-
end
|
288
|
-
|
289
|
-
def parse_multi_select_list(stream)
|
290
|
-
nodes = []
|
291
|
-
begin
|
292
|
-
nodes << expr(stream)
|
293
|
-
if stream.token.type == :comma
|
294
|
-
stream.next
|
295
|
-
if stream.token.type == :rbracket
|
296
|
-
raise Errors::SyntaxError, 'expression epxected, found rbracket'
|
297
|
-
end
|
298
|
-
end
|
299
|
-
end while stream.token.type != :rbracket
|
300
|
-
stream.next
|
301
|
-
{
|
302
|
-
type: :multi_select_list,
|
303
|
-
children: nodes
|
304
|
-
}
|
305
|
-
end
|
306
|
-
|
307
|
-
def parse_projection(stream, binding_power)
|
308
|
-
type = stream.token.type
|
309
|
-
if stream.token.binding_power < 10
|
310
|
-
CURRENT_NODE
|
311
|
-
elsif type == :dot
|
312
|
-
stream.next(match:AFTER_DOT)
|
313
|
-
parse_dot(stream, binding_power)
|
314
|
-
elsif type == :lbracket || type == :filter
|
315
|
-
expr(stream, binding_power)
|
316
|
-
else
|
317
|
-
raise Errors::SyntaxError, 'syntax error after projection'
|
318
|
-
end
|
319
|
-
end
|
320
|
-
|
321
|
-
def parse_wildcard_array(stream, left = nil)
|
322
|
-
stream.next(match:Set.new([:rbracket]))
|
323
|
-
stream.next
|
324
|
-
{
|
325
|
-
type: :projection,
|
326
|
-
from: :array,
|
327
|
-
children: [
|
328
|
-
left ? left : CURRENT_NODE,
|
329
|
-
parse_projection(stream, Token::BINDING_POWER[:star])
|
330
|
-
]
|
331
|
-
}
|
332
|
-
end
|
333
|
-
|
334
|
-
def parse_wildcard_object(stream, left = nil)
|
335
|
-
stream.next
|
336
|
-
{
|
337
|
-
type: :projection,
|
338
|
-
from: :object,
|
339
|
-
children: [
|
340
|
-
left ? left : CURRENT_NODE,
|
341
|
-
parse_projection(stream, Token::BINDING_POWER[:star])
|
342
|
-
]
|
343
|
-
}
|
344
|
-
end
|
345
|
-
|
346
|
-
end
|
347
|
-
end
|
@@ -1,71 +0,0 @@
|
|
1
|
-
module JMESPath
|
2
|
-
# @api private
|
3
|
-
class Runtime
|
4
|
-
|
5
|
-
# @api private
|
6
|
-
DEFAULT_PARSER = CachingParser.new
|
7
|
-
|
8
|
-
# Constructs a new runtime object for evaluating JMESPath expressions.
|
9
|
-
#
|
10
|
-
# runtime = JMESPath::Runtime.new
|
11
|
-
# runtime.search(expression, data)
|
12
|
-
# #=> ...
|
13
|
-
#
|
14
|
-
# ## Caching
|
15
|
-
#
|
16
|
-
# When constructing a {Runtime}, the default parser caches expressions.
|
17
|
-
# This significantly speeds up calls to {#search} multiple times
|
18
|
-
# with the same expression but different data. To disable caching, pass
|
19
|
-
# `:cache_expressions => false` to the constructor or pass a custom
|
20
|
-
# `:parser`.
|
21
|
-
#
|
22
|
-
# @example Re-use a Runtime, caching enabled by default
|
23
|
-
#
|
24
|
-
# runtime = JMESPath::Runtime.new
|
25
|
-
# runtime.parser
|
26
|
-
# #=> #<JMESPath::CachingParser ...>
|
27
|
-
#
|
28
|
-
# @example Disable caching
|
29
|
-
#
|
30
|
-
# runtime = JMESPath::Runtime.new(cache_expressions: false)
|
31
|
-
# runtime.parser
|
32
|
-
# #=> #<JMESPath::Parser ...>
|
33
|
-
#
|
34
|
-
# @option options [Boolean] :cache_expressions (true) When `false`, a non
|
35
|
-
# caching parser will be used. When `true`, a shared instance of
|
36
|
-
# {CachingParser} is used. Defaults to `true`.
|
37
|
-
#
|
38
|
-
# @option options [Parser,CachingParser] :parser
|
39
|
-
#
|
40
|
-
# @option options [Interpreter] :interpreter
|
41
|
-
#
|
42
|
-
def initialize(options = {})
|
43
|
-
@parser = options[:parser] || default_parser(options)
|
44
|
-
@interpreter = options[:interpreter] || TreeInterpreter.new
|
45
|
-
end
|
46
|
-
|
47
|
-
# @return [Parser, CachingParser]
|
48
|
-
attr_reader :parser
|
49
|
-
|
50
|
-
# @return [Interpreter]
|
51
|
-
attr_reader :interpreter
|
52
|
-
|
53
|
-
# @param [String<JMESPath>] expression
|
54
|
-
# @param [Hash] data
|
55
|
-
# @return [Mixed,nil]
|
56
|
-
def search(expression, data)
|
57
|
-
@interpreter.visit(@parser.parse(expression), data)
|
58
|
-
end
|
59
|
-
|
60
|
-
private
|
61
|
-
|
62
|
-
def default_parser(options)
|
63
|
-
if options[:cache_expressions] == false
|
64
|
-
Parser.new(options)
|
65
|
-
else
|
66
|
-
DEFAULT_PARSER
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
end
|
71
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
module JMESPath
|
2
|
-
# @api private
|
3
|
-
class Token < Struct.new(:type, :value, :position, :binding_power)
|
4
|
-
|
5
|
-
# @api private
|
6
|
-
NULL_TOKEN = Token.new(:eof, '', nil)
|
7
|
-
|
8
|
-
# binding power
|
9
|
-
# @api private
|
10
|
-
BINDING_POWER = {
|
11
|
-
:eof => 0,
|
12
|
-
:quoted_identifier => 0,
|
13
|
-
:identifier => 0,
|
14
|
-
:rbracket => 0,
|
15
|
-
:rparen => 0,
|
16
|
-
:comma => 0,
|
17
|
-
:rbrace => 0,
|
18
|
-
:number => 0,
|
19
|
-
:current => 0,
|
20
|
-
:expref => 0,
|
21
|
-
:pipe => 1,
|
22
|
-
:comparator => 2,
|
23
|
-
:or => 5,
|
24
|
-
:flatten => 6,
|
25
|
-
:star => 20,
|
26
|
-
:dot => 40,
|
27
|
-
:lbrace => 50,
|
28
|
-
:filter => 50,
|
29
|
-
:lbracket => 50,
|
30
|
-
:lparen => 60,
|
31
|
-
}
|
32
|
-
|
33
|
-
# @param [Symbol] type
|
34
|
-
# @param [Mixed] value
|
35
|
-
# @param [Integer] position
|
36
|
-
def initialize(type, value, position)
|
37
|
-
super(type, value, position, BINDING_POWER[type])
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
end
|