sauberia-aws-s3 0.6.2.1254423624

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 +221 -0
@@ -0,0 +1,5 @@
1
+ ---
2
+ something:
3
+ something-else:
4
+ - another_child:
5
+ attribute: "4"
@@ -0,0 +1,8 @@
1
+ ---
2
+ something:
3
+ something-else:
4
+ - __content__: testing
5
+ - __content__: testing
6
+ - __content__: testing
7
+ - __content__: testing
8
+ - __content__: testing
@@ -0,0 +1,7 @@
1
+ <something>
2
+ <something-else>testing</something-else>
3
+ <something-else>testing</something-else>
4
+ <something-else>testing</something-else>
5
+ <something-else>testing</something-else>
6
+ <something-else>testing</something-else>
7
+ </something>
@@ -0,0 +1,8 @@
1
+ ---
2
+ something:
3
+ something-else:
4
+ - __content__: testing
5
+ - __content__: testing
6
+ - __content__: testing
7
+ - __content__: testing
8
+ - __content__: testing
@@ -0,0 +1,43 @@
1
+ ---
2
+ ListBucketResult:
3
+ Prefix: {}
4
+
5
+ Name:
6
+ __content__: projectionist
7
+ MaxKeys:
8
+ __content__: "1000"
9
+ Contents:
10
+ - StorageClass:
11
+ __content__: STANDARD
12
+ Owner:
13
+ DisplayName:
14
+ __content__: noradio
15
+ ID:
16
+ __content__: bb2041a25975c3d4ce9775fe9e93e5b77a6a9fad97dc7e00686191f3790b13f1
17
+ Size:
18
+ __content__: "186870"
19
+ ETag:
20
+ __content__: "\"2ac1aa042e20ab7e1a9879b0df9f17b7\""
21
+ LastModified:
22
+ __content__: "2006-11-15T05:49:39.000Z"
23
+ Key:
24
+ __content__: 1973-plymouth-satellite-sebring.jpg
25
+ - StorageClass:
26
+ __content__: STANDARD
27
+ Owner:
28
+ DisplayName:
29
+ __content__: noradio
30
+ ID:
31
+ __content__: bb2041a25975c3d4ce9775fe9e93e5b77a6a9fad97dc7e00686191f3790b13f1
32
+ Size:
33
+ __content__: "43562"
34
+ ETag:
35
+ __content__: "\"4ead118ba91491f9c9697153264a1943\""
36
+ LastModified:
37
+ __content__: "2006-11-15T05:51:20.000Z"
38
+ Key:
39
+ __content__: 37-cluster.jpg
40
+ Marker: {}
41
+
42
+ IsTruncated:
43
+ __content__: "false"
@@ -0,0 +1,29 @@
1
+ <ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
2
+ <Name>projectionist</Name>
3
+ <Prefix/>
4
+ <Marker/>
5
+ <MaxKeys>1000</MaxKeys>
6
+ <IsTruncated>false</IsTruncated>
7
+ <Contents>
8
+ <Key>1973-plymouth-satellite-sebring.jpg</Key>
9
+ <LastModified>2006-11-15T05:49:39.000Z</LastModified>
10
+ <ETag>"2ac1aa042e20ab7e1a9879b0df9f17b7"</ETag>
11
+ <Size>186870</Size>
12
+ <Owner>
13
+ <ID>bb2041a25975c3d4ce9775fe9e93e5b77a6a9fad97dc7e00686191f3790b13f1</ID>
14
+ <DisplayName>noradio</DisplayName>
15
+ </Owner>
16
+ <StorageClass>STANDARD</StorageClass>
17
+ </Contents>
18
+ <Contents>
19
+ <Key>37-cluster.jpg</Key>
20
+ <LastModified>2006-11-15T05:51:20.000Z</LastModified>
21
+ <ETag>"4ead118ba91491f9c9697153264a1943"</ETag>
22
+ <Size>43562</Size>
23
+ <Owner>
24
+ <ID>bb2041a25975c3d4ce9775fe9e93e5b77a6a9fad97dc7e00686191f3790b13f1</ID>
25
+ <DisplayName>noradio</DisplayName>
26
+ </Owner>
27
+ <StorageClass>STANDARD</StorageClass>
28
+ </Contents>
29
+ </ListBucketResult>
@@ -0,0 +1,41 @@
1
+ ---
2
+ ListBucketResult:
3
+ Prefix:
4
+ Name:
5
+ __content__: projectionist
6
+ MaxKeys:
7
+ __content__: "1000"
8
+ Contents:
9
+ - StorageClass:
10
+ __content__: STANDARD
11
+ Owner:
12
+ DisplayName:
13
+ __content__: noradio
14
+ ID:
15
+ __content__: bb2041a25975c3d4ce9775fe9e93e5b77a6a9fad97dc7e00686191f3790b13f1
16
+ Size:
17
+ __content__: "186870"
18
+ ETag:
19
+ __content__: "\"2ac1aa042e20ab7e1a9879b0df9f17b7\""
20
+ LastModified:
21
+ __content__: "2006-11-15T05:49:39.000Z"
22
+ Key:
23
+ __content__: 1973-plymouth-satellite-sebring.jpg
24
+ - StorageClass:
25
+ __content__: STANDARD
26
+ Owner:
27
+ DisplayName:
28
+ __content__: noradio
29
+ ID:
30
+ __content__: bb2041a25975c3d4ce9775fe9e93e5b77a6a9fad97dc7e00686191f3790b13f1
31
+ Size:
32
+ __content__: "43562"
33
+ ETag:
34
+ __content__: "\"4ead118ba91491f9c9697153264a1943\""
35
+ LastModified:
36
+ __content__: "2006-11-15T05:51:20.000Z"
37
+ Key:
38
+ __content__: 37-cluster.jpg
39
+ Marker:
40
+ IsTruncated:
41
+ __content__: "false"
@@ -0,0 +1,23 @@
1
+ ---
2
+ AccessControlPolicy:
3
+ AccessControlList:
4
+ Grant:
5
+ - Permission:
6
+ __content__: FULL_CONTROL
7
+ Grantee:
8
+ DisplayName:
9
+ __content__: noradio
10
+ ID:
11
+ __content__: bb2041a25975c3d4ce9775fe9e93e5b77a6a9fad97dc7e00686191f3790b13f1
12
+ xsi:type: CanonicalUser
13
+ - Permission:
14
+ __content__: READ
15
+ Grantee:
16
+ URI:
17
+ __content__: http://acs.amazonaws.com/groups/global/AllUsers
18
+ xsi:type: Group
19
+ Owner:
20
+ DisplayName:
21
+ __content__: noradio
22
+ ID:
23
+ __content__: bb2041a25975c3d4ce9775fe9e93e5b77a6a9fad97dc7e00686191f3790b13f1
@@ -0,0 +1,22 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <AccessControlPolicy xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
3
+ <Owner>
4
+ <ID>bb2041a25975c3d4ce9775fe9e93e5b77a6a9fad97dc7e00686191f3790b13f1</ID>
5
+ <DisplayName>noradio</DisplayName>
6
+ </Owner>
7
+ <AccessControlList>
8
+ <Grant>
9
+ <Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CanonicalUser">
10
+ <ID>bb2041a25975c3d4ce9775fe9e93e5b77a6a9fad97dc7e00686191f3790b13f1</ID>
11
+ <DisplayName>noradio</DisplayName>
12
+ </Grantee>
13
+ <Permission>FULL_CONTROL</Permission>
14
+ </Grant>
15
+ <Grant>
16
+ <Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Group">
17
+ <URI>http://acs.amazonaws.com/groups/global/AllUsers</URI>
18
+ </Grantee>
19
+ <Permission>READ</Permission>
20
+ </Grant>
21
+ </AccessControlList>
22
+ </AccessControlPolicy>
@@ -0,0 +1,22 @@
1
+ AccessControlPolicy:
2
+ Owner:
3
+ DisplayName:
4
+ __content__: noradio
5
+ ID:
6
+ __content__: bb2041a25975c3d4ce9775fe9e93e5b77a6a9fad97dc7e00686191f3790b13f1
7
+ AccessControlList:
8
+ Grant:
9
+ - Permission:
10
+ __content__: FULL_CONTROL
11
+ Grantee:
12
+ DisplayName:
13
+ __content__: noradio
14
+ ID:
15
+ __content__: bb2041a25975c3d4ce9775fe9e93e5b77a6a9fad97dc7e00686191f3790b13f1
16
+ xsi:type: CanonicalUser
17
+ - Permission:
18
+ __content__: READ
19
+ Grantee:
20
+ URI:
21
+ __content__: http://acs.amazonaws.com/groups/global/AllUsers
22
+ xsi:type: Group
@@ -0,0 +1,14 @@
1
+ ---
2
+ topic:
3
+ parent-id: {}
4
+
5
+ title: {}
6
+
7
+ approved:
8
+ type: boolean
9
+ id:
10
+ type: integer
11
+ viewed-at:
12
+ type: datetime
13
+ written-on:
14
+ type: date
@@ -0,0 +1,8 @@
1
+ <topic>
2
+ <title></title>
3
+ <id type="integer"></id>
4
+ <approved type="boolean"></approved>
5
+ <written-on type="date"></written-on>
6
+ <viewed-at type="datetime"></viewed-at>
7
+ <parent-id></parent-id>
8
+ </topic>
@@ -0,0 +1,11 @@
1
+ topic:
2
+ title:
3
+ id:
4
+ type: integer
5
+ approved:
6
+ type: boolean
7
+ parent-id:
8
+ viewed-at:
9
+ type: datetime
10
+ written-on:
11
+ type: date
@@ -0,0 +1,47 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ class RegressionTest < FasterXSTest
4
+ def test_content_nil_regressions
5
+ expected = {"asdf"=>{"jklsemicolon"=>{}}}
6
+ assert_equal expected, FasterXmlSimple.xml_in("<asdf><jklsemicolon /></asdf>")
7
+ assert_equal expected, FasterXmlSimple.xml_in("<asdf><jklsemicolon /></asdf>", 'forcearray'=>['asdf'])
8
+ end
9
+
10
+ def test_s3_regression
11
+ str = File.read("test/fixtures/test-7.xml")
12
+ assert_nil FasterXmlSimple.xml_in(str)["AccessControlPolicy"]["AccessControlList"]["__content__"]
13
+ end
14
+
15
+ def test_xml_simple_transparency
16
+ assert_equal XmlSimple.xml_in("<asdf />"), FasterXmlSimple.xml_in("<asdf />")
17
+ end
18
+
19
+ def test_suppress_empty_variations
20
+ str = "<asdf><fdsa /></asdf>"
21
+
22
+ assert_equal Hash.new, FasterXmlSimple.xml_in(str)["asdf"]["fdsa"]
23
+ assert_nil FasterXmlSimple.xml_in(str, 'suppressempty'=>nil)["asdf"]["fdsa"]
24
+ assert_equal '', FasterXmlSimple.xml_in(str, 'suppressempty'=>'')["asdf"]["fdsa"]
25
+ assert !FasterXmlSimple.xml_in(str, 'suppressempty'=>true)["asdf"].has_key?("fdsa")
26
+ end
27
+
28
+ def test_empty_string_doesnt_crash
29
+ assert_raise(XML::Parser::ParseError) do
30
+ silence_stderr do
31
+ FasterXmlSimple.xml_in('')
32
+ end
33
+ end
34
+ end
35
+
36
+ def test_keeproot_false
37
+ str = "<asdf><fdsa>1</fdsa></asdf>"
38
+ expected = {"fdsa"=>"1"}
39
+ assert_equal expected, FasterXmlSimple.xml_in(str, 'keeproot'=>false)
40
+ end
41
+
42
+ def test_keeproot_false_with_force_content
43
+ str = "<asdf><fdsa>1</fdsa></asdf>"
44
+ expected = {"fdsa"=>{"__content__"=>"1"}}
45
+ assert_equal expected, FasterXmlSimple.xml_in(str, 'keeproot'=>false, 'forcecontent'=>true)
46
+ end
47
+ end
@@ -0,0 +1,17 @@
1
+
2
+ require 'test/unit'
3
+ require 'faster_xml_simple'
4
+
5
+ class FasterXSTest < Test::Unit::TestCase
6
+ def default_test
7
+ end
8
+
9
+ def silence_stderr
10
+ str = STDERR.dup
11
+ STDERR.reopen("/dev/null")
12
+ STDERR.sync=true
13
+ yield
14
+ ensure
15
+ STDERR.reopen(str)
16
+ end
17
+ end
@@ -0,0 +1,46 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+ require 'yaml'
3
+
4
+ class XmlSimpleComparisonTest < FasterXSTest
5
+
6
+ # Define test methods
7
+
8
+ Dir["test/fixtures/test-*.xml"].each do |file_name|
9
+ xml_file_name = file_name
10
+ method_name = File.basename(file_name, ".xml").gsub('-', '_')
11
+ yml_file_name = file_name.gsub('xml', 'yml')
12
+ rails_yml_file_name = file_name.gsub('xml', 'rails.yml')
13
+ class_eval <<-EOV, __FILE__, __LINE__
14
+ def #{method_name}
15
+ assert_equal YAML.load(File.read('#{yml_file_name}')),
16
+ FasterXmlSimple.xml_in(File.read('#{xml_file_name}'), default_options )
17
+ end
18
+
19
+ def #{method_name}_rails
20
+ assert_equal YAML.load(File.read('#{rails_yml_file_name}')),
21
+ FasterXmlSimple.xml_in(File.read('#{xml_file_name}'), rails_options)
22
+ end
23
+ EOV
24
+ end
25
+
26
+ def default_options
27
+ {
28
+ 'keeproot' => true,
29
+ 'contentkey' => '__content__',
30
+ 'forcecontent' => true,
31
+ 'suppressempty' => nil,
32
+ 'forcearray' => ['something-else']
33
+ }
34
+ end
35
+
36
+ def rails_options
37
+ {
38
+ 'forcearray' => false,
39
+ 'forcecontent' => true,
40
+ 'keeproot' => true,
41
+ 'contentkey' => '__content__'
42
+ }
43
+ end
44
+
45
+
46
+ end
@@ -0,0 +1,211 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'rdoc/rdoc'
4
+
5
+ module RDoc
6
+ class CodeInfo
7
+ class << self
8
+ def parse(wildcard_pattern = nil)
9
+ @info_for_corpus = parse_files(wildcard_pattern)
10
+ end
11
+
12
+ def for(constant)
13
+ new(constant).info
14
+ end
15
+
16
+ def info_for_corpus
17
+ raise RuntimeError, "You must first generate a corpus to search by using RDoc::CodeInfo.parse" unless @info_for_corpus
18
+ @info_for_corpus
19
+ end
20
+
21
+ def parsed_files
22
+ info_for_corpus.map {|info| info.file_absolute_name}
23
+ end
24
+
25
+ def files_to_parse
26
+ @files_to_parse ||= Rake::FileList.new
27
+ end
28
+
29
+ private
30
+ def parse_files(pattern)
31
+ files = pattern ? Rake::FileList[pattern] : files_to_parse
32
+ options = Options.instance
33
+ options.parse(files << '-q', RDoc::GENERATORS)
34
+ rdoc.send(:parse_files, options)
35
+ end
36
+
37
+ def rdoc
38
+ TopLevel.reset
39
+ rdoc = RDoc.new
40
+ stats = Stats.new
41
+ # We don't want any output so we'll override the print method
42
+ stats.instance_eval { def print; nil end }
43
+ rdoc.instance_variable_set(:@stats, stats)
44
+ rdoc
45
+ end
46
+ end
47
+
48
+ attr_reader :info
49
+ def initialize(location)
50
+ @location = CodeLocation.new(location)
51
+ find_constant
52
+ find_method if @location.has_method?
53
+ end
54
+
55
+ private
56
+ attr_reader :location
57
+ attr_writer :info
58
+ def find_constant
59
+ parts = location.namespace_parts
60
+ self.class.info_for_corpus.each do |file_info|
61
+ @info = parts.inject(file_info) do |result, const_part|
62
+ (result.find_module_named(const_part) || result.find_class_named(const_part)) || break
63
+ end
64
+ return if info
65
+ end
66
+ end
67
+
68
+ def find_method
69
+ return unless info
70
+ self.info = info.method_list.detect do |method_info|
71
+ next unless method_info.name == location.method_name
72
+ if location.class_method?
73
+ method_info.singleton
74
+ elsif location.instance_method?
75
+ !method_info.singleton
76
+ else
77
+ true
78
+ end
79
+ end
80
+ end
81
+ end
82
+
83
+ class CodeLocation
84
+ attr_reader :location
85
+
86
+ def initialize(location)
87
+ @location = location
88
+ end
89
+
90
+ def parts
91
+ location.split(/::|\.|#/)
92
+ end
93
+
94
+ def namespace_parts
95
+ has_method? ? parts[0...-1] : parts
96
+ end
97
+
98
+ def has_method?
99
+ ('a'..'z').include?(parts.last[0, 1])
100
+ end
101
+
102
+ def instance_method?
103
+ !location['#'].nil?
104
+ end
105
+
106
+ def class_method?
107
+ has_method? && !location[/#|\./]
108
+ end
109
+
110
+ def method_name
111
+ parts.last if has_method?
112
+ end
113
+ end
114
+ end
115
+
116
+ if __FILE__ == $0
117
+ require 'test/unit'
118
+ class CodeInfoTest < Test::Unit::TestCase
119
+ def setup
120
+ RDoc::CodeInfo.parse(__FILE__)
121
+ end
122
+
123
+ def test_constant_lookup
124
+ assert RDoc::CodeInfo.for('RDoc')
125
+
126
+ info = RDoc::CodeInfo.for('RDoc::CodeInfo')
127
+ assert_equal 'CodeInfo', info.name
128
+ end
129
+
130
+ def test_method_lookup
131
+ {'RDoc::CodeInfo.parse' => true,
132
+ 'RDoc::CodeInfo::parse' => true,
133
+ 'RDoc::CodeInfo#parse' => false,
134
+ 'RDoc::CodeInfo.find_method' => true,
135
+ 'RDoc::CodeInfo::find_method' => false,
136
+ 'RDoc::CodeInfo#find_method' => true,
137
+ 'RDoc::CodeInfo#no_such_method' => false,
138
+ 'RDoc::NoSuchConst#foo' => false}.each do |location, result_of_lookup|
139
+ assert_equal result_of_lookup, !RDoc::CodeInfo.for(location).nil?
140
+ end
141
+ end
142
+ end
143
+
144
+ class CodeLocationTest < Test::Unit::TestCase
145
+ def test_parts
146
+ {'Foo' => %w(Foo),
147
+ 'Foo::Bar' => %w(Foo Bar),
148
+ 'Foo::Bar#baz' => %w(Foo Bar baz),
149
+ 'Foo::Bar.baz' => %w(Foo Bar baz),
150
+ 'Foo::Bar::baz' => %w(Foo Bar baz),
151
+ 'Foo::Bar::Baz' => %w(Foo Bar Baz)}.each do |location, parts|
152
+ assert_equal parts, RDoc::CodeLocation.new(location).parts
153
+ end
154
+ end
155
+
156
+ def test_namespace_parts
157
+ {'Foo' => %w(Foo),
158
+ 'Foo::Bar' => %w(Foo Bar),
159
+ 'Foo::Bar#baz' => %w(Foo Bar),
160
+ 'Foo::Bar.baz' => %w(Foo Bar),
161
+ 'Foo::Bar::baz' => %w(Foo Bar),
162
+ 'Foo::Bar::Baz' => %w(Foo Bar Baz)}.each do |location, namespace_parts|
163
+ assert_equal namespace_parts, RDoc::CodeLocation.new(location).namespace_parts
164
+ end
165
+ end
166
+
167
+ def test_has_method?
168
+ {'Foo' => false,
169
+ 'Foo::Bar' => false,
170
+ 'Foo::Bar#baz' => true,
171
+ 'Foo::Bar.baz' => true,
172
+ 'Foo::Bar::baz' => true,
173
+ 'Foo::Bar::Baz' => false}.each do |location, has_method_result|
174
+ assert_equal has_method_result, RDoc::CodeLocation.new(location).has_method?
175
+ end
176
+ end
177
+
178
+ def test_instance_method?
179
+ {'Foo' => false,
180
+ 'Foo::Bar' => false,
181
+ 'Foo::Bar#baz' => true,
182
+ 'Foo::Bar.baz' => false,
183
+ 'Foo::Bar::baz' => false,
184
+ 'Foo::Bar::Baz' => false}.each do |location, is_instance_method|
185
+ assert_equal is_instance_method, RDoc::CodeLocation.new(location).instance_method?
186
+ end
187
+ end
188
+
189
+ def test_class_method?
190
+ {'Foo' => false,
191
+ 'Foo::Bar' => false,
192
+ 'Foo::Bar#baz' => false,
193
+ 'Foo::Bar.baz' => false,
194
+ 'Foo::Bar::baz' => true,
195
+ 'Foo::Bar::Baz' => false}.each do |location, is_class_method|
196
+ assert_equal is_class_method, RDoc::CodeLocation.new(location).class_method?
197
+ end
198
+ end
199
+
200
+ def test_method_name
201
+ {'Foo' => nil,
202
+ 'Foo::Bar' => nil,
203
+ 'Foo::Bar#baz' => 'baz',
204
+ 'Foo::Bar.baz' => 'baz',
205
+ 'Foo::Bar::baz' => 'baz',
206
+ 'Foo::Bar::Baz' => nil}.each do |location, method_name|
207
+ assert_equal method_name, RDoc::CodeLocation.new(location).method_name
208
+ end
209
+ end
210
+ end
211
+ end