fog 0.1.10 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/fog.gemspec +1 -1
- data/lib/fog.rb +1 -1
- data/lib/fog/aws/models/s3/directories.rb +1 -6
- data/lib/fog/parser.rb +61 -0
- metadata +3 -3
data/fog.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
|
|
7
7
|
## If your rubyforge_project name is different, then edit it and comment out
|
8
8
|
## the sub! line in the Rakefile
|
9
9
|
s.name = 'fog'
|
10
|
-
s.version = '0.
|
10
|
+
s.version = '0.2.0'
|
11
11
|
s.date = '2010-06-18'
|
12
12
|
s.rubyforge_project = 'fog'
|
13
13
|
|
data/lib/fog.rb
CHANGED
@@ -36,12 +36,7 @@ module Fog
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
directory.files.merge_attributes(options)
|
39
|
-
files
|
40
|
-
while data['IsTruncated']
|
41
|
-
data = connection.get_bucket(key, options.merge!('marker' => files.last['Key'])).body
|
42
|
-
files.concat(data['Contents'])
|
43
|
-
end
|
44
|
-
directory.files.load(files)
|
39
|
+
directory.files.load(data['Contents'])
|
45
40
|
directory
|
46
41
|
rescue Excon::Errors::NotFound
|
47
42
|
nil
|
data/lib/fog/parser.rb
CHANGED
@@ -24,3 +24,64 @@ module Fog
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
27
|
+
|
28
|
+
module Fog
|
29
|
+
class ToHashDocument < Nokogiri::XML::SAX::Document
|
30
|
+
|
31
|
+
def initialize
|
32
|
+
@stack = []
|
33
|
+
end
|
34
|
+
|
35
|
+
def characters(string)
|
36
|
+
@value ||= ''
|
37
|
+
@value << string.strip
|
38
|
+
end
|
39
|
+
|
40
|
+
def end_element(name)
|
41
|
+
last = @stack.pop
|
42
|
+
if last.empty? && @value.empty?
|
43
|
+
@stack.last[name.to_sym] = ''
|
44
|
+
elsif !@value.empty?
|
45
|
+
@stack.last[name.to_sym] = @value
|
46
|
+
end
|
47
|
+
@value = ''
|
48
|
+
end
|
49
|
+
|
50
|
+
def body
|
51
|
+
@stack.first
|
52
|
+
end
|
53
|
+
|
54
|
+
def start_element(name, attributes = [])
|
55
|
+
@value = ''
|
56
|
+
parsed_attributes = {}
|
57
|
+
until attributes.empty?
|
58
|
+
if attributes.first.is_a?(Array)
|
59
|
+
key, value = attributes.shift
|
60
|
+
else
|
61
|
+
key, value = attributes.shift, attributes.shift
|
62
|
+
end
|
63
|
+
parsed_attributes[key.gsub(':','_').to_sym] = value
|
64
|
+
end
|
65
|
+
if @stack.last.is_a?(Array)
|
66
|
+
@stack.last << {name.to_sym => parsed_attributes}
|
67
|
+
else
|
68
|
+
data = if @stack.empty?
|
69
|
+
@stack.push(parsed_attributes)
|
70
|
+
parsed_attributes
|
71
|
+
elsif @stack.last[name.to_sym]
|
72
|
+
unless @stack.last[name.to_sym].is_a?(Array)
|
73
|
+
@stack.last[name.to_sym] = [@stack.last[name.to_sym]]
|
74
|
+
end
|
75
|
+
@stack.last[name.to_sym] << parsed_attributes
|
76
|
+
@stack.last[name.to_sym].last
|
77
|
+
else
|
78
|
+
@stack.last[name.to_sym] = {}
|
79
|
+
@stack.last[name.to_sym].merge!(parsed_attributes)
|
80
|
+
@stack.last[name.to_sym]
|
81
|
+
end
|
82
|
+
@stack.push(data)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
end
|