fmalamitsas-aws-s3 0.6.2.1254423625

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. data/CHANGELOG +107 -0
  2. data/COPYING +19 -0
  3. data/INSTALL +55 -0
  4. data/README.erb +58 -0
  5. data/Rakefile +334 -0
  6. data/TODO +26 -0
  7. data/aws-s3.gemspec +42 -0
  8. data/bin/s3sh +6 -0
  9. data/bin/setup.rb +10 -0
  10. data/lib/aws/s3.rb +60 -0
  11. data/lib/aws/s3/acl.rb +636 -0
  12. data/lib/aws/s3/authentication.rb +222 -0
  13. data/lib/aws/s3/base.rb +270 -0
  14. data/lib/aws/s3/bittorrent.rb +58 -0
  15. data/lib/aws/s3/bucket.rb +372 -0
  16. data/lib/aws/s3/connection.rb +288 -0
  17. data/lib/aws/s3/error.rb +69 -0
  18. data/lib/aws/s3/exceptions.rb +133 -0
  19. data/lib/aws/s3/extensions.rb +342 -0
  20. data/lib/aws/s3/logging.rb +317 -0
  21. data/lib/aws/s3/object.rb +626 -0
  22. data/lib/aws/s3/owner.rb +46 -0
  23. data/lib/aws/s3/parsing.rb +99 -0
  24. data/lib/aws/s3/response.rb +180 -0
  25. data/lib/aws/s3/service.rb +51 -0
  26. data/lib/aws/s3/version.rb +12 -0
  27. data/site/index.erb +41 -0
  28. data/site/public/images/box-and-gem.gif +0 -0
  29. data/site/public/images/favicon.ico +0 -0
  30. data/site/public/ruby.css +18 -0
  31. data/site/public/screen.css +99 -0
  32. data/support/faster-xml-simple/COPYING +18 -0
  33. data/support/faster-xml-simple/README +8 -0
  34. data/support/faster-xml-simple/Rakefile +54 -0
  35. data/support/faster-xml-simple/lib/faster_xml_simple.rb +190 -0
  36. data/support/faster-xml-simple/test/fixtures/test-1.rails.yml +4 -0
  37. data/support/faster-xml-simple/test/fixtures/test-1.xml +3 -0
  38. data/support/faster-xml-simple/test/fixtures/test-1.yml +4 -0
  39. data/support/faster-xml-simple/test/fixtures/test-2.rails.yml +6 -0
  40. data/support/faster-xml-simple/test/fixtures/test-2.xml +3 -0
  41. data/support/faster-xml-simple/test/fixtures/test-2.yml +6 -0
  42. data/support/faster-xml-simple/test/fixtures/test-3.rails.yml +6 -0
  43. data/support/faster-xml-simple/test/fixtures/test-3.xml +5 -0
  44. data/support/faster-xml-simple/test/fixtures/test-3.yml +6 -0
  45. data/support/faster-xml-simple/test/fixtures/test-4.rails.yml +5 -0
  46. data/support/faster-xml-simple/test/fixtures/test-4.xml +7 -0
  47. data/support/faster-xml-simple/test/fixtures/test-4.yml +5 -0
  48. data/support/faster-xml-simple/test/fixtures/test-5.rails.yml +8 -0
  49. data/support/faster-xml-simple/test/fixtures/test-5.xml +7 -0
  50. data/support/faster-xml-simple/test/fixtures/test-5.yml +8 -0
  51. data/support/faster-xml-simple/test/fixtures/test-6.rails.yml +43 -0
  52. data/support/faster-xml-simple/test/fixtures/test-6.xml +29 -0
  53. data/support/faster-xml-simple/test/fixtures/test-6.yml +41 -0
  54. data/support/faster-xml-simple/test/fixtures/test-7.rails.yml +23 -0
  55. data/support/faster-xml-simple/test/fixtures/test-7.xml +22 -0
  56. data/support/faster-xml-simple/test/fixtures/test-7.yml +22 -0
  57. data/support/faster-xml-simple/test/fixtures/test-8.rails.yml +14 -0
  58. data/support/faster-xml-simple/test/fixtures/test-8.xml +8 -0
  59. data/support/faster-xml-simple/test/fixtures/test-8.yml +11 -0
  60. data/support/faster-xml-simple/test/regression_test.rb +47 -0
  61. data/support/faster-xml-simple/test/test_helper.rb +17 -0
  62. data/support/faster-xml-simple/test/xml_simple_comparison_test.rb +46 -0
  63. data/support/rdoc/code_info.rb +211 -0
  64. data/test/acl_test.rb +254 -0
  65. data/test/authentication_test.rb +118 -0
  66. data/test/base_test.rb +136 -0
  67. data/test/bucket_test.rb +74 -0
  68. data/test/connection_test.rb +216 -0
  69. data/test/error_test.rb +70 -0
  70. data/test/extensions_test.rb +340 -0
  71. data/test/fixtures.rb +89 -0
  72. data/test/fixtures/buckets.yml +133 -0
  73. data/test/fixtures/errors.yml +34 -0
  74. data/test/fixtures/headers.yml +3 -0
  75. data/test/fixtures/logging.yml +15 -0
  76. data/test/fixtures/loglines.yml +5 -0
  77. data/test/fixtures/logs.yml +7 -0
  78. data/test/fixtures/policies.yml +16 -0
  79. data/test/logging_test.rb +89 -0
  80. data/test/mocks/fake_response.rb +26 -0
  81. data/test/object_test.rb +205 -0
  82. data/test/parsing_test.rb +66 -0
  83. data/test/remote/acl_test.rb +116 -0
  84. data/test/remote/bittorrent_test.rb +45 -0
  85. data/test/remote/bucket_test.rb +146 -0
  86. data/test/remote/logging_test.rb +82 -0
  87. data/test/remote/object_test.rb +379 -0
  88. data/test/remote/test_file.data +0 -0
  89. data/test/remote/test_helper.rb +33 -0
  90. data/test/response_test.rb +68 -0
  91. data/test/service_test.rb +23 -0
  92. data/test/test_helper.rb +118 -0
  93. metadata +241 -0
@@ -0,0 +1,99 @@
1
+ body {
2
+ background: #fff;
3
+ color: #333;
4
+ font-family: verdana, sans-serif;
5
+ font-size: 12px;
6
+ margin: 0;
7
+ }
8
+
9
+ div.left_column {
10
+ text-align: right;
11
+ float: left;
12
+ width: 185px;
13
+ font-size: 14px;
14
+ padding-right: 15px;
15
+ }
16
+
17
+ div.left_column img {
18
+ margin-right: -15px;
19
+ }
20
+
21
+
22
+ pre {
23
+ color: #555;
24
+ margin-left: 2em;
25
+ overflow: auto;
26
+ width: 600px;
27
+ }
28
+
29
+ div.page_area {
30
+ margin: 40px 0 120px 50px;
31
+ }
32
+
33
+ div.column {
34
+ margin-left: 220px;
35
+ padding-top: 3px;
36
+ width: 450px;
37
+ }
38
+
39
+ a:link,
40
+ a:visited {
41
+ color: #039;
42
+ }
43
+
44
+ h1 {
45
+ margin: 0 0 50px 0;
46
+ font-size: 14px;
47
+ }
48
+
49
+ h2 {
50
+ color: #bc0707;
51
+ font-size: 24px;
52
+ margin: 0;
53
+ }
54
+
55
+ h3 {
56
+ font-size: 16px;
57
+ line-height: 20px;
58
+ margin: 10px 0 0 0;
59
+ }
60
+
61
+
62
+ div.header {
63
+ font-size: 14px;
64
+ }
65
+
66
+ div.header p.links {
67
+ color: #ccc;
68
+ }
69
+
70
+ div.header h4 {
71
+ margin-bottom: 7px;
72
+ font-size: 16px;
73
+ }
74
+
75
+ div.header pre {
76
+ margin-top: 0;
77
+ }
78
+
79
+
80
+ div.readme {
81
+ font-size: 12px;
82
+ line-height: 140%;
83
+ }
84
+
85
+ div.readme h2 {
86
+ font-size: 20px;
87
+ margin: 2em 0 0 0;
88
+ }
89
+
90
+ div.readme h4 {
91
+ font-size: 12px;
92
+ color: #bc0707;
93
+ color: #000;
94
+ margin-top: 3em;
95
+ }
96
+
97
+ div.readme h4.first {
98
+ margin-top: 1.5em;
99
+ }
@@ -0,0 +1,18 @@
1
+ Copyright (c) 2006 Michael Koziarski
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in the
5
+ Software without restriction, including without limitation the rights to use,
6
+ copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
7
+ Software, and to permit persons to whom the Software is furnished to do so,
8
+ subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
17
+ AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,8 @@
1
+ FasterXmlSimple
2
+
3
+ FasterXS is intended to be a drop in replacement for the xml input functionality
4
+ from XmlSimple. Instead of using rexml, it uses libxml and the associated ruby
5
+ bindings. This reduces CPU utilisation and memory consumption considerably.
6
+
7
+ Preliminary benchmarks show it between 3 and 10 times as fast, and using a
8
+ fraction of the ram.
@@ -0,0 +1,54 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'rake/testtask'
4
+ require 'rake/rdoctask'
5
+ require 'rake/packagetask'
6
+ require 'rake/gempackagetask'
7
+ require 'lib/faster_xml_simple'
8
+
9
+ task :default => :test
10
+
11
+ Rake::TestTask.new do |test|
12
+ test.pattern = 'test/*_test.rb'
13
+ test.verbose = true
14
+ end
15
+
16
+
17
+ Rake::RDocTask.new do |rdoc|
18
+ rdoc.rdoc_dir = 'doc'
19
+ rdoc.title = "FasterXmlSimple, a libxml based replacement for XmlSimple"
20
+ rdoc.options << '--line-numbers' << '--inline-source'
21
+ rdoc.rdoc_files.include('README')
22
+ rdoc.rdoc_files.include('COPYING')
23
+ rdoc.rdoc_files.include('lib/**/*.rb')
24
+ end
25
+
26
+ namespace :dist do
27
+
28
+ spec = Gem::Specification.new do |s|
29
+ s.name = 'faster_xml_simple'
30
+ s.version = Gem::Version.new(FasterXmlSimple::Version)
31
+ s.summary = "A libxml based replacement for XmlSimple"
32
+ s.description = s.summary
33
+ s.email = 'michael@koziarski.com'
34
+ s.author = 'Michael Koziarski'
35
+ s.has_rdoc = true
36
+ s.extra_rdoc_files = %w(README COPYING)
37
+ s.homepage = 'http://fasterxs.rubyforge.org'
38
+ s.rubyforge_project = 'fasterxs'
39
+ s.files = FileList['Rakefile', 'lib/**/*.rb']
40
+ s.test_files = Dir['test/**/*']
41
+
42
+ s.add_dependency 'libxml-ruby', '>= 0.3.8.4'
43
+ s.rdoc_options = ['--title', "",
44
+ '--main', 'README',
45
+ '--line-numbers', '--inline-source']
46
+ end
47
+ Rake::GemPackageTask.new(spec) do |pkg|
48
+ pkg.need_tar_gz = true
49
+ pkg.package_files.include('{lib,test}/**/*')
50
+ pkg.package_files.include('README')
51
+ pkg.package_files.include('COPYING')
52
+ pkg.package_files.include('Rakefile')
53
+ end
54
+ end
@@ -0,0 +1,190 @@
1
+ #
2
+ # Copyright (c) 2006 Michael Koziarski
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
5
+ # this software and associated documentation files (the "Software"), to deal in the
6
+ # Software without restriction, including without limitation the rights to use,
7
+ # copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
8
+ # Software, and to permit persons to whom the Software is furnished to do so,
9
+ # subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be included in all
12
+ # copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18
+ # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
19
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
+
21
+ require 'rubygems'
22
+ require 'xml/libxml'
23
+
24
+ class FasterXmlSimple
25
+ Version = '0.5.0'
26
+ class << self
27
+ # Take an string containing XML, and returns a hash representing that
28
+ # XML document. For example:
29
+ #
30
+ # FasterXmlSimple.xml_in("<root><something>1</something></root>")
31
+ # {"root"=>{"something"=>{"__content__"=>"1"}}}
32
+ #
33
+ # Faster XML Simple is designed to be a drop in replacement for the xml_in
34
+ # functionality of http://xml-simple.rubyforge.org
35
+ #
36
+ # The following options are supported:
37
+ #
38
+ # * <tt>contentkey</tt>: The key to use for the content of text elements,
39
+ # defaults to '\_\_content__'
40
+ # * <tt>forcearray</tt>: The list of elements which should always be returned
41
+ # as arrays. Under normal circumstances single element arrays are inlined.
42
+ # * <tt>suppressempty</tt>: The value to return for empty elements, pass +true+
43
+ # to remove empty elements entirely.
44
+ # * <tt>keeproot</tt>: By default the hash returned has a single key with the
45
+ # name of the root element. If the name of the root element isn't
46
+ # interesting to you, pass +false+.
47
+ # * <tt>forcecontent</tt>: By default a text element with no attributes, will
48
+ # be collapsed to just a string instead of a hash with a single key.
49
+ # Pass +true+ to prevent this.
50
+ #
51
+ #
52
+ def xml_in(string, options={})
53
+ new(string, options).out
54
+ end
55
+ end
56
+
57
+ def initialize(string, options) #:nodoc:
58
+ @doc = parse(string)
59
+ @options = default_options.merge options
60
+ end
61
+
62
+ def out #:nodoc:
63
+ if @options['keeproot']
64
+ {@doc.root.name => collapse(@doc.root)}
65
+ else
66
+ collapse(@doc.root)
67
+ end
68
+ end
69
+
70
+ private
71
+ def default_options
72
+ {'contentkey' => '__content__', 'forcearray' => [], 'keeproot'=>true}
73
+ end
74
+
75
+ def collapse(element)
76
+ result = hash_of_attributes(element)
77
+ if text_node? element
78
+ text = collapse_text(element)
79
+ result[content_key] = text if text =~ /\S/
80
+ elsif element.children?
81
+ element.inject(result) do |hash, child|
82
+ unless child.text?
83
+ child_result = collapse(child)
84
+ (hash[child.name] ||= []) << child_result
85
+ end
86
+ hash
87
+ end
88
+ end
89
+ if result.empty?
90
+ return empty_element
91
+ end
92
+ # Compact them to ensure it complies with the user's requests
93
+ inline_single_element_arrays(result)
94
+ remove_empty_elements(result) if suppress_empty?
95
+ if content_only?(result) && !force_content?
96
+ result[content_key]
97
+ else
98
+ result
99
+ end
100
+ end
101
+
102
+ def content_only?(result)
103
+ result.keys == [content_key]
104
+ end
105
+
106
+ def content_key
107
+ @options['contentkey']
108
+ end
109
+
110
+ def force_array?(key_name)
111
+ Array(@options['forcearray']).include?(key_name)
112
+ end
113
+
114
+ def inline_single_element_arrays(result)
115
+ result.each do |key, value|
116
+ if value.size == 1 && value.is_a?(Array) && !force_array?(key)
117
+ result[key] = value.first
118
+ end
119
+ end
120
+ end
121
+
122
+ def remove_empty_elements(result)
123
+ result.each do |key, value|
124
+ if value == empty_element
125
+ result.delete key
126
+ end
127
+ end
128
+ end
129
+
130
+ def suppress_empty?
131
+ @options['suppressempty'] == true
132
+ end
133
+
134
+ def empty_element
135
+ if !@options.has_key? 'suppressempty'
136
+ {}
137
+ else
138
+ @options['suppressempty']
139
+ end
140
+ end
141
+
142
+ # removes the content if it's nothing but blanks, prevents
143
+ # the hash being polluted with lots of content like "\n\t\t\t"
144
+ def suppress_empty_content(result)
145
+ result.delete content_key if result[content_key] !~ /\S/
146
+ end
147
+
148
+ def force_content?
149
+ @options['forcecontent']
150
+ end
151
+
152
+ # a text node is one with 1 or more child nodes which are
153
+ # text nodes, and no non-text children, there's no sensible
154
+ # way to support nodes which are text and markup like:
155
+ # <p>Something <b>Bold</b> </p>
156
+ def text_node?(element)
157
+ !element.text? && element.all? {|c| c.text?}
158
+ end
159
+
160
+ # takes a text node, and collapses it into a string
161
+ def collapse_text(element)
162
+ element.map {|c| c.content } * ''
163
+ end
164
+
165
+ def hash_of_attributes(element)
166
+ result = {}
167
+ element.each_attr do |attribute|
168
+ name = attribute.name
169
+ name = [attribute.ns, attribute.name].join(':') if attribute.ns?
170
+ result[name] = attribute.value
171
+ end
172
+ result
173
+ end
174
+
175
+ def parse(string)
176
+ if string == ''
177
+ string = ' '
178
+ end
179
+ XML::Parser.string(string).parse
180
+ end
181
+ end
182
+
183
+ # Don't overwrite XmlSimple.xml_in since FasterXmlSimple's implementation isn't
184
+ # 100% compatible.
185
+ #
186
+ # class XmlSimple # :nodoc:
187
+ # def self.xml_in(*args)
188
+ # FasterXmlSimple.xml_in *args
189
+ # end
190
+ # end
@@ -0,0 +1,4 @@
1
+ ---
2
+ something:
3
+ something-else:
4
+ __content__: testing
@@ -0,0 +1,3 @@
1
+ <something>
2
+ <something-else>testing</something-else>
3
+ </something>
@@ -0,0 +1,4 @@
1
+ ---
2
+ something:
3
+ something-else:
4
+ - __content__: testing
@@ -0,0 +1,6 @@
1
+ ---
2
+ something:
3
+ something-else:
4
+ __content__: testing
5
+ child_attribute: "15"
6
+ root_attribute: "12"
@@ -0,0 +1,3 @@
1
+ <something root_attribute="12">
2
+ <something-else child_attribute="15">testing</something-else>
3
+ </something>
@@ -0,0 +1,6 @@
1
+ ---
2
+ something:
3
+ something-else:
4
+ - __content__: testing
5
+ child_attribute: "15"
6
+ root_attribute: "12"
@@ -0,0 +1,6 @@
1
+ ---
2
+ something:
3
+ something-else:
4
+ __content__: "\n\
5
+ \t\ttesting\n\
6
+ \t"
@@ -0,0 +1,5 @@
1
+ <something>
2
+ <something-else>
3
+ testing
4
+ </something-else>
5
+ </something>
@@ -0,0 +1,6 @@
1
+ ---
2
+ something:
3
+ something-else:
4
+ - __content__: "\n\
5
+ \t\ttesting\n\
6
+ \t"
@@ -0,0 +1,5 @@
1
+ ---
2
+ something:
3
+ something-else:
4
+ another_child:
5
+ attribute: "4"
@@ -0,0 +1,7 @@
1
+ <something>
2
+ <something-else>
3
+ testing
4
+ <another_child attribute='4' />
5
+ testing
6
+ </something-else>
7
+ </something>