aws-sdk-core 2.0.33 → 2.0.34

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,20 @@
1
+ require 'ox'
2
+ require 'stringio'
3
+
4
+ module Aws
5
+ module Xml
6
+ class Parser
7
+ class OxEngine
8
+
9
+ def initialize(stack)
10
+ @stack = stack
11
+ end
12
+
13
+ def parse(xml)
14
+ Ox.sax_parse(@stack, StringIO.new(xml))
15
+ end
16
+
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,45 @@
1
+ require 'rexml/document'
2
+ require 'rexml/streamlistener'
3
+
4
+ module Aws
5
+ module Xml
6
+ class Parser
7
+ class RexmlEngine
8
+
9
+ include REXML::StreamListener
10
+
11
+ def initialize(stack)
12
+ @stack = stack
13
+ @depth = 0
14
+ end
15
+
16
+ def parse(xml)
17
+ begin
18
+ source = REXML::Source.new(xml)
19
+ REXML::Parsers::StreamParser.new(source, self).parse
20
+ rescue REXML::ParseException => error
21
+ @stack.error(error.message)
22
+ end
23
+ end
24
+
25
+ def tag_start(name, attrs)
26
+ @depth += 1
27
+ @stack.start_element(name)
28
+ attrs.each do |attr|
29
+ @stack.attr(*attr)
30
+ end
31
+ end
32
+
33
+ def text(value)
34
+ @stack.text(value) if @depth > 0
35
+ end
36
+
37
+ def tag_end(name)
38
+ @stack.end_element
39
+ @depth -= 1
40
+ end
41
+
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,284 @@
1
+ require 'base64'
2
+ require 'time'
3
+
4
+ module Aws
5
+ module Xml
6
+ class Parser
7
+ class Frame
8
+
9
+ def initialize(parent, shape, result = nil)
10
+ @parent = parent
11
+ @shape = shape
12
+ @result = result
13
+ end
14
+
15
+ attr_reader :parent
16
+
17
+ attr_reader :shape
18
+
19
+ attr_reader :result
20
+
21
+ def set_text(value); end
22
+
23
+ def child_frame(xml_name)
24
+ NullFrame.new(self)
25
+ end
26
+
27
+ def consume_child_frame(child); end
28
+
29
+ private
30
+
31
+ class << self
32
+
33
+ def new(parent, shape, result = nil)
34
+ if self == Frame
35
+ frame = frame_class(shape).allocate
36
+ frame.send(:initialize, parent, shape, result)
37
+ frame
38
+ else
39
+ super
40
+ end
41
+ end
42
+
43
+ private
44
+
45
+ def frame_class(shape)
46
+ @classes ||= {
47
+ 'blob' => BlobFrame,
48
+ 'boolean' => BooleanFrame,
49
+ 'byte' => BlobFrame,
50
+ 'character' => StringFrame,
51
+ 'double' => FloatFrame,
52
+ 'float' => FloatFrame,
53
+ 'integer' => IntegerFrame,
54
+ 'list' => ListFrame,
55
+ 'list:flat' => FlatListFrame,
56
+ 'long' => IntegerFrame,
57
+ 'map' => MapFrame,
58
+ 'map:flat' => MapEntryFrame,
59
+ 'string' => StringFrame,
60
+ 'structure' => StructureFrame,
61
+ 'timestamp' => TimestampFrame,
62
+ }
63
+ if shape
64
+ type = shape.type
65
+ type += ':flat' if shape.definition['flattened']
66
+ @classes[type]
67
+ else
68
+ NullFrame
69
+ end
70
+ end
71
+
72
+ end
73
+ end
74
+
75
+ class StructureFrame < Frame
76
+
77
+ def initialize(parent, shape, result = nil)
78
+ super
79
+ @result ||= Structure.new(shape.member_names)
80
+ @members = {}
81
+ shape.members.each do |member_name, member_shape|
82
+ apply_default_value(member_name, member_shape)
83
+ @members[xml_name(member_shape)] = {
84
+ name: member_name,
85
+ shape: member_shape,
86
+ }
87
+ end
88
+ end
89
+
90
+ def child_frame(xml_name)
91
+ if @member = @members[xml_name]
92
+ Frame.new(self, @member[:shape])
93
+ else
94
+ NullFrame.new(self)
95
+ end
96
+ end
97
+
98
+ def consume_child_frame(child)
99
+ case child
100
+ when MapEntryFrame
101
+ @result[@member[:name]][child.key.result] = child.value.result
102
+ when FlatListFrame
103
+ @result[@member[:name]] << child.result
104
+ when NullFrame
105
+ else
106
+ @result[@member[:name]] = child.result
107
+ end
108
+ end
109
+
110
+ private
111
+
112
+ def apply_default_value(name, shape)
113
+ case shape
114
+ when Seahorse::Model::Shapes::List then @result[name] = DefaultList.new
115
+ when Seahorse::Model::Shapes::Map then @result[name] = {}
116
+ end
117
+ end
118
+
119
+ def xml_name(member_shape)
120
+ if member_shape.type == 'list' && member_shape.definition['flattened']
121
+ member_shape.member.location_name || member_shape.location_name
122
+ else
123
+ member_shape.location_name
124
+ end
125
+ end
126
+
127
+ end
128
+
129
+ class ListFrame < Frame
130
+
131
+ def initialize(*args)
132
+ super
133
+ @result = []
134
+ @member_xml_name = @shape.member.location_name || 'member'
135
+ end
136
+
137
+ def child_frame(xml_name)
138
+ if xml_name == @member_xml_name
139
+ Frame.new(self, @shape.member)
140
+ else
141
+ raise NotImplementedError
142
+ end
143
+ end
144
+
145
+ def consume_child_frame(child)
146
+ @result << child.result unless NullFrame === child
147
+ end
148
+
149
+ end
150
+
151
+ class FlatListFrame < Frame
152
+
153
+ def initialize(*args)
154
+ super
155
+ @member = Frame.new(self, @shape.member)
156
+ end
157
+
158
+ def result
159
+ @member.result
160
+ end
161
+
162
+ def set_text(value)
163
+ @member.set_text(value)
164
+ end
165
+
166
+ def child_frame(xml_name)
167
+ @member.child_frame(xml_name)
168
+ end
169
+
170
+ def consume_child_frame(child)
171
+ @result = @member.result
172
+ end
173
+
174
+ end
175
+
176
+ class MapFrame < Frame
177
+
178
+ def initialize(*args)
179
+ super
180
+ @result = {}
181
+ end
182
+
183
+ def child_frame(xml_name)
184
+ if xml_name == 'entry'
185
+ MapEntryFrame.new(self, @shape)
186
+ else
187
+ raise NotImplementedError
188
+ end
189
+ end
190
+
191
+ def consume_child_frame(child)
192
+ @result[child.key.result] = child.value.result
193
+ end
194
+
195
+ end
196
+
197
+ class MapEntryFrame < Frame
198
+
199
+ def initialize(*args)
200
+ super
201
+ @key_name = @shape.key.location_name || 'key'
202
+ @key = Frame.new(self, @shape.key)
203
+ @value_name = @shape.value.location_name || 'value'
204
+ @value = Frame.new(self, @shape.value)
205
+ end
206
+
207
+ # @return [StringFrame]
208
+ attr_reader :key
209
+
210
+ # @return [Frame]
211
+ attr_reader :value
212
+
213
+ def child_frame(xml_name)
214
+ if @key_name == xml_name
215
+ @key
216
+ elsif @value_name == xml_name
217
+ @value
218
+ else
219
+ NullFrame.new(self)
220
+ end
221
+ end
222
+
223
+ end
224
+
225
+ class NullFrame < Frame
226
+ def self.new(parent)
227
+ super(parent, nil)
228
+ end
229
+ end
230
+
231
+ class BlobFrame < Frame
232
+ def set_text(value)
233
+ @result = Base64.decode64(value)
234
+ end
235
+ end
236
+
237
+ class BooleanFrame < Frame
238
+ def set_text(value)
239
+ @result = (value == 'true')
240
+ end
241
+ end
242
+
243
+ class FloatFrame < Frame
244
+ def set_text(value)
245
+ @result = value.to_f
246
+ end
247
+ end
248
+
249
+ class IntegerFrame < Frame
250
+ def set_text(value)
251
+ @result = value.to_i
252
+ end
253
+ end
254
+
255
+ class StringFrame < Frame
256
+ def initialize(*args)
257
+ super
258
+ @result = ''
259
+ end
260
+ def set_text(value)
261
+ @result = value
262
+ end
263
+ end
264
+
265
+ class TimestampFrame < Frame
266
+ def set_text(value)
267
+ @result = parse(value)
268
+ end
269
+ def parse(value)
270
+ case value
271
+ when nil then nil
272
+ when /^\d+$/ then Time.at(value.to_i)
273
+ else
274
+ begin
275
+ Time.parse(value).utc
276
+ rescue ArgumentError
277
+ raise "unhandled timestamp format `#{value}'"
278
+ end
279
+ end
280
+ end
281
+ end
282
+ end
283
+ end
284
+ end
@@ -0,0 +1,19 @@
1
+ module Aws
2
+ module Xml
3
+ class Parser
4
+ class ParsingError < RuntimeError
5
+
6
+ def initialize(msg, line, column)
7
+ super(msg)
8
+ end
9
+
10
+ # @return [Integer,nil]
11
+ attr_reader :line
12
+
13
+ # @return [Integer,nil]
14
+ attr_reader :column
15
+
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,58 @@
1
+ module Aws
2
+ module Xml
3
+ class Parser
4
+ class Stack
5
+
6
+ def initialize(shape, result = nil)
7
+ @shape = shape
8
+ @frame = self
9
+ @result = result
10
+ end
11
+
12
+ attr_reader :frame
13
+
14
+ attr_reader :result
15
+
16
+ def start_element(name)
17
+ @frame = @frame.child_frame(name.to_s)
18
+ end
19
+
20
+ def attr(name, value)
21
+ if name.to_s == 'encoding' && value.to_s == 'base64'
22
+ @frame = BlobFrame.new(@frame.parent, @frame.shape)
23
+ else
24
+ start_element(name)
25
+ text(value)
26
+ end_element(name)
27
+ end
28
+ end
29
+
30
+ def text(value)
31
+ @frame.set_text(value)
32
+ end
33
+
34
+ def end_element(*args)
35
+ @frame.parent.consume_child_frame(@frame)
36
+ if @frame.parent.is_a?(FlatListFrame)
37
+ @frame = @frame.parent
38
+ @frame.parent.consume_child_frame(@frame)
39
+ end
40
+ @frame = @frame.parent
41
+ end
42
+
43
+ def error(msg, line = nil, column = nil)
44
+ raise ParsingError.new(msg, line, column)
45
+ end
46
+
47
+ def child_frame(name)
48
+ Frame.new(self, @shape, @result)
49
+ end
50
+
51
+ def consume_child_frame(frame)
52
+ @result = frame.result
53
+ end
54
+
55
+ end
56
+ end
57
+ end
58
+ end
@@ -58,7 +58,7 @@ module Seahorse
58
58
  name, shape = input.member_by_location_name(placeholder)
59
59
  param = context.params[name]
60
60
  if greedy
61
- param.split('/').map{ |value| escape(value) }.join('/')
61
+ param = param.gsub(/[^\/]+/) { |v| escape(v) }
62
62
  else
63
63
  escape(param)
64
64
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-sdk-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.33
4
+ version: 2.0.34
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amazon Web Services
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-26 00:00:00.000000000 Z
11
+ date: 2015-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.0'
27
- - !ruby/object:Gem::Dependency
28
- name: multi_xml
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '0.5'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '0.5'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: builder
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -315,6 +301,13 @@ files:
315
301
  - lib/aws-sdk-core/xml/default_list.rb
316
302
  - lib/aws-sdk-core/xml/error_handler.rb
317
303
  - lib/aws-sdk-core/xml/parser.rb
304
+ - lib/aws-sdk-core/xml/parser/engines/libxml.rb
305
+ - lib/aws-sdk-core/xml/parser/engines/nokogiri.rb
306
+ - lib/aws-sdk-core/xml/parser/engines/ox.rb
307
+ - lib/aws-sdk-core/xml/parser/engines/rexml.rb
308
+ - lib/aws-sdk-core/xml/parser/frame.rb
309
+ - lib/aws-sdk-core/xml/parser/parsing_error.rb
310
+ - lib/aws-sdk-core/xml/parser/stack.rb
318
311
  - lib/aws-sdk-core/xml/rest_handler.rb
319
312
  - lib/seahorse.rb
320
313
  - lib/seahorse/client/base.rb