sitemap_generator 5.2.0 → 5.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGES.md +250 -0
- data/README.md +156 -125
- data/VERSION +1 -1
- data/lib/capistrano/tasks/sitemap_generator.cap +21 -23
- data/lib/sitemap_generator.rb +1 -2
- data/lib/sitemap_generator/adapters/s3_adapter.rb +5 -0
- data/lib/sitemap_generator/application.rb +1 -1
- data/lib/sitemap_generator/builder/sitemap_file.rb +7 -3
- data/lib/sitemap_generator/builder/sitemap_url.rb +1 -10
- data/lib/sitemap_generator/link_set.rb +16 -10
- data/lib/sitemap_generator/{sitemap_namer.rb → simple_namer.rb} +1 -1
- data/lib/sitemap_generator/sitemap_location.rb +13 -1
- data/lib/sitemap_generator/tasks.rb +2 -2
- metadata +51 -123
- data/Gemfile +0 -13
- data/Gemfile.lock +0 -38
- data/Rakefile +0 -43
- data/spec/blueprint.rb +0 -15
- data/spec/files/sitemap.create.rb +0 -12
- data/spec/files/sitemap.groups.rb +0 -49
- data/spec/sitemap_generator/adapters/s3_adapter_spec.rb +0 -23
- data/spec/sitemap_generator/alternate_sitemap_spec.rb +0 -100
- data/spec/sitemap_generator/application_spec.rb +0 -69
- data/spec/sitemap_generator/builder/sitemap_file_spec.rb +0 -110
- data/spec/sitemap_generator/builder/sitemap_index_file_spec.rb +0 -124
- data/spec/sitemap_generator/builder/sitemap_index_url_spec.rb +0 -28
- data/spec/sitemap_generator/builder/sitemap_url_spec.rb +0 -192
- data/spec/sitemap_generator/core_ext/bigdecimal_spec.rb +0 -20
- data/spec/sitemap_generator/core_ext/numeric_spec.rb +0 -43
- data/spec/sitemap_generator/file_adaptor_spec.rb +0 -20
- data/spec/sitemap_generator/geo_sitemap_spec.rb +0 -30
- data/spec/sitemap_generator/helpers/number_helper_spec.rb +0 -196
- data/spec/sitemap_generator/interpreter_spec.rb +0 -90
- data/spec/sitemap_generator/link_set_spec.rb +0 -864
- data/spec/sitemap_generator/mobile_sitemap_spec.rb +0 -27
- data/spec/sitemap_generator/news_sitemap_spec.rb +0 -42
- data/spec/sitemap_generator/pagemap_sitemap_spec.rb +0 -57
- data/spec/sitemap_generator/sitemap_generator_spec.rb +0 -591
- data/spec/sitemap_generator/sitemap_groups_spec.rb +0 -144
- data/spec/sitemap_generator/sitemap_location_spec.rb +0 -210
- data/spec/sitemap_generator/sitemap_namer_spec.rb +0 -96
- data/spec/sitemap_generator/templates_spec.rb +0 -24
- data/spec/sitemap_generator/utilities/existence_spec.rb +0 -26
- data/spec/sitemap_generator/utilities/hash_spec.rb +0 -57
- data/spec/sitemap_generator/utilities/rounding_spec.rb +0 -31
- data/spec/sitemap_generator/utilities_spec.rb +0 -101
- data/spec/sitemap_generator/video_sitemap_spec.rb +0 -117
- data/spec/spec_helper.rb +0 -24
- data/spec/support/file_macros.rb +0 -39
- data/spec/support/schemas/siteindex.xsd +0 -73
- data/spec/support/schemas/sitemap-geo.xsd +0 -41
- data/spec/support/schemas/sitemap-mobile.xsd +0 -32
- data/spec/support/schemas/sitemap-news.xsd +0 -159
- data/spec/support/schemas/sitemap-pagemap.xsd +0 -97
- data/spec/support/schemas/sitemap-video.xsd +0 -643
- data/spec/support/schemas/sitemap.xsd +0 -115
- data/spec/support/xml_macros.rb +0 -67
@@ -1,144 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
def with_max_links(num)
|
4
|
-
SitemapGenerator::Utilities.with_warnings(nil) do
|
5
|
-
original = SitemapGenerator::MAX_SITEMAP_LINKS
|
6
|
-
SitemapGenerator.const_set(:MAX_SITEMAP_LINKS, num)
|
7
|
-
yield
|
8
|
-
SitemapGenerator.const_set(:MAX_SITEMAP_LINKS, original)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
describe "Sitemap Groups" do
|
13
|
-
let(:linkset) { ::SitemapGenerator::LinkSet.new(:default_host => 'http://test.com') }
|
14
|
-
|
15
|
-
before :each do
|
16
|
-
FileUtils.rm_rf(SitemapGenerator.app.root + 'public/')
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should not finalize the default sitemap if using groups" do
|
20
|
-
linkset.create do
|
21
|
-
group(:filename => :sitemap_en) do
|
22
|
-
add '/en'
|
23
|
-
end
|
24
|
-
end
|
25
|
-
file_should_exist(SitemapGenerator.app.root + 'public/sitemap.xml.gz')
|
26
|
-
file_should_exist(SitemapGenerator.app.root + 'public/sitemap_en.xml.gz')
|
27
|
-
file_should_not_exist(SitemapGenerator.app.root + 'public/sitemap1.xml.gz')
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should not write out empty groups" do
|
31
|
-
linkset.create do
|
32
|
-
group(:filename => :sitemap_en) { }
|
33
|
-
end
|
34
|
-
file_should_not_exist(SitemapGenerator.app.root + 'public/sitemap_en.xml.gz')
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should add default links if no groups are created" do
|
38
|
-
linkset.create do
|
39
|
-
end
|
40
|
-
linkset.link_count.should == 1
|
41
|
-
file_should_exist(SitemapGenerator.app.root + 'public/sitemap.xml.gz')
|
42
|
-
file_should_not_exist(SitemapGenerator.app.root + 'public/sitemap1.xml.gz')
|
43
|
-
end
|
44
|
-
|
45
|
-
it "should add links to the default sitemap" do
|
46
|
-
linkset.create do
|
47
|
-
add '/before'
|
48
|
-
group(:filename => :sitemap_en) do
|
49
|
-
add '/link'
|
50
|
-
end
|
51
|
-
add '/after'
|
52
|
-
end
|
53
|
-
linkset.link_count.should == 4
|
54
|
-
file_should_exist(SitemapGenerator.app.root + 'public/sitemap.xml.gz')
|
55
|
-
file_should_exist(SitemapGenerator.app.root + 'public/sitemap1.xml.gz')
|
56
|
-
file_should_exist(SitemapGenerator.app.root + 'public/sitemap_en.xml.gz')
|
57
|
-
end
|
58
|
-
|
59
|
-
it "should rollover when sitemaps are full" do
|
60
|
-
with_max_links(1) {
|
61
|
-
linkset.include_index = false
|
62
|
-
linkset.include_root = false
|
63
|
-
linkset.create do
|
64
|
-
add '/before'
|
65
|
-
group(:filename => :sitemap_en, :sitemaps_path => 'en/') do
|
66
|
-
add '/one'
|
67
|
-
add '/two'
|
68
|
-
end
|
69
|
-
add '/after'
|
70
|
-
end
|
71
|
-
}
|
72
|
-
linkset.link_count.should == 4
|
73
|
-
file_should_exist(SitemapGenerator.app.root + 'public/sitemap.xml.gz')
|
74
|
-
file_should_exist(SitemapGenerator.app.root + 'public/sitemap1.xml.gz')
|
75
|
-
file_should_exist(SitemapGenerator.app.root + 'public/sitemap2.xml.gz')
|
76
|
-
file_should_not_exist(SitemapGenerator.app.root + 'public/sitemap3.xml.gz')
|
77
|
-
file_should_exist(SitemapGenerator.app.root + 'public/en/sitemap_en.xml.gz')
|
78
|
-
file_should_exist(SitemapGenerator.app.root + 'public/en/sitemap_en1.xml.gz')
|
79
|
-
file_should_not_exist(SitemapGenerator.app.root + 'public/en/sitemap_en2.xml.gz')
|
80
|
-
end
|
81
|
-
|
82
|
-
it "should support multiple groups" do
|
83
|
-
linkset.create do
|
84
|
-
group(:filename => :sitemap_en, :sitemaps_path => 'en/') do
|
85
|
-
add '/one'
|
86
|
-
end
|
87
|
-
group(:filename => :sitemap_fr, :sitemaps_path => 'fr/') do
|
88
|
-
add '/one'
|
89
|
-
end
|
90
|
-
end
|
91
|
-
linkset.link_count.should == 2
|
92
|
-
file_should_exist(SitemapGenerator.app.root + 'public/sitemap.xml.gz')
|
93
|
-
file_should_exist(SitemapGenerator.app.root + 'public/en/sitemap_en.xml.gz')
|
94
|
-
file_should_exist(SitemapGenerator.app.root + 'public/fr/sitemap_fr.xml.gz')
|
95
|
-
end
|
96
|
-
|
97
|
-
it "the sitemap shouldn't be finalized until the end if the groups don't conflict" do
|
98
|
-
linkset.create do
|
99
|
-
add 'one'
|
100
|
-
group(:filename => :first) { add '/two' }
|
101
|
-
add 'three'
|
102
|
-
group(:filename => :second) { add '/four' }
|
103
|
-
add 'five'
|
104
|
-
end
|
105
|
-
linkset.link_count.should == 6
|
106
|
-
file_should_exist(SitemapGenerator.app.root + 'public/sitemap.xml.gz')
|
107
|
-
file_should_exist(SitemapGenerator.app.root + 'public/sitemap1.xml.gz')
|
108
|
-
file_should_exist(SitemapGenerator.app.root + 'public/first.xml.gz')
|
109
|
-
file_should_exist(SitemapGenerator.app.root + 'public/second.xml.gz')
|
110
|
-
gzipped_xml_file_should_validate_against_schema(SitemapGenerator.app.root + 'public/sitemap.xml.gz', 'siteindex')
|
111
|
-
gzipped_xml_file_should_validate_against_schema(SitemapGenerator.app.root + 'public/sitemap1.xml.gz', 'sitemap')
|
112
|
-
end
|
113
|
-
|
114
|
-
it "groups should share the sitemap if the sitemap location is unchanged" do
|
115
|
-
linkset.create do
|
116
|
-
add 'one'
|
117
|
-
group(:default_host => 'http://newhost.com') { add '/two' }
|
118
|
-
add 'three'
|
119
|
-
group(:default_host => 'http://betterhost.com') { add '/four' }
|
120
|
-
add 'five'
|
121
|
-
end
|
122
|
-
linkset.link_count.should == 6
|
123
|
-
file_should_exist(SitemapGenerator.app.root + 'public/sitemap.xml.gz')
|
124
|
-
file_should_not_exist(SitemapGenerator.app.root + 'public/sitemap1.xml.gz')
|
125
|
-
gzipped_xml_file_should_validate_against_schema(SitemapGenerator.app.root + 'public/sitemap.xml.gz', 'sitemap')
|
126
|
-
end
|
127
|
-
|
128
|
-
it "sitemaps should be finalized if virtual location settings are changed" do
|
129
|
-
linkset.create do
|
130
|
-
add 'one'
|
131
|
-
group(:sitemaps_path => :en) { add '/two' }
|
132
|
-
add 'three'
|
133
|
-
group(:sitemaps_host => 'http://newhost.com') { add '/four' }
|
134
|
-
add 'five'
|
135
|
-
end
|
136
|
-
linkset.link_count.should == 6
|
137
|
-
file_should_exist(SitemapGenerator.app.root + 'public/sitemap.xml.gz')
|
138
|
-
file_should_exist(SitemapGenerator.app.root + 'public/sitemap1.xml.gz')
|
139
|
-
file_should_exist(SitemapGenerator.app.root + 'public/sitemap2.xml.gz')
|
140
|
-
file_should_exist(SitemapGenerator.app.root + 'public/sitemap3.xml.gz')
|
141
|
-
file_should_not_exist(SitemapGenerator.app.root + 'public/sitemap4.xml.gz')
|
142
|
-
file_should_exist(SitemapGenerator.app.root + 'public/en/sitemap.xml.gz')
|
143
|
-
end
|
144
|
-
end
|
@@ -1,210 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe SitemapGenerator::SitemapLocation do
|
4
|
-
let(:default_host) { 'http://example.com' }
|
5
|
-
let(:location) { SitemapGenerator::SitemapLocation.new }
|
6
|
-
|
7
|
-
it "public_path should default to the public directory in the application root" do
|
8
|
-
location.public_path.should == SitemapGenerator.app.root + 'public/'
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should have a default namer" do
|
12
|
-
location[:namer].should_not be_nil
|
13
|
-
location[:filename].should be_nil
|
14
|
-
location.filename.should == 'sitemap1.xml.gz'
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should require a filename" do
|
18
|
-
location[:filename] = nil
|
19
|
-
lambda {
|
20
|
-
location.filename.should be_nil
|
21
|
-
}.should raise_error
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should require a namer" do
|
25
|
-
location[:namer] = nil
|
26
|
-
lambda {
|
27
|
-
location.filename.should be_nil
|
28
|
-
}.should raise_error
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should require a host" do
|
32
|
-
location = SitemapGenerator::SitemapLocation.new(:filename => nil, :namer => nil)
|
33
|
-
lambda {
|
34
|
-
location.host.should be_nil
|
35
|
-
}.should raise_error
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should accept a Namer option" do
|
39
|
-
@namer = SitemapGenerator::SimpleNamer.new(:xxx)
|
40
|
-
location = SitemapGenerator::SitemapLocation.new(:namer => @namer)
|
41
|
-
location.filename.should == @namer.to_s
|
42
|
-
end
|
43
|
-
|
44
|
-
it "should protect the filename from further changes in the Namer" do
|
45
|
-
@namer = SitemapGenerator::SimpleNamer.new(:xxx)
|
46
|
-
location = SitemapGenerator::SitemapLocation.new(:namer => @namer)
|
47
|
-
location.filename.should == @namer.to_s
|
48
|
-
@namer.next
|
49
|
-
location.filename.should == @namer.previous.to_s
|
50
|
-
end
|
51
|
-
|
52
|
-
it "should allow changing the namer" do
|
53
|
-
@namer1 = SitemapGenerator::SimpleNamer.new(:xxx)
|
54
|
-
location = SitemapGenerator::SitemapLocation.new(:namer => @namer1)
|
55
|
-
location.filename.should == @namer1.to_s
|
56
|
-
@namer2 = SitemapGenerator::SimpleNamer.new(:yyy)
|
57
|
-
location[:namer] = @namer2
|
58
|
-
location.filename.should == @namer2.to_s
|
59
|
-
end
|
60
|
-
|
61
|
-
describe "testing options and #with" do
|
62
|
-
|
63
|
-
# Array of tuples with instance options and expected method return values
|
64
|
-
tests = [
|
65
|
-
[{
|
66
|
-
:sitemaps_path => nil,
|
67
|
-
:public_path => '/public',
|
68
|
-
:filename => 'sitemap.xml.gz',
|
69
|
-
:host => 'http://test.com' },
|
70
|
-
{ :url => 'http://test.com/sitemap.xml.gz',
|
71
|
-
:directory => '/public',
|
72
|
-
:path => '/public/sitemap.xml.gz',
|
73
|
-
:path_in_public => 'sitemap.xml.gz'
|
74
|
-
}],
|
75
|
-
[{
|
76
|
-
:sitemaps_path => 'sitemaps/en/',
|
77
|
-
:public_path => '/public/system/',
|
78
|
-
:filename => 'sitemap.xml.gz',
|
79
|
-
:host => 'http://test.com/plus/extra/' },
|
80
|
-
{ :url => 'http://test.com/plus/extra/sitemaps/en/sitemap.xml.gz',
|
81
|
-
:directory => '/public/system/sitemaps/en',
|
82
|
-
:path => '/public/system/sitemaps/en/sitemap.xml.gz',
|
83
|
-
:path_in_public => 'sitemaps/en/sitemap.xml.gz'
|
84
|
-
}]
|
85
|
-
]
|
86
|
-
tests.each do |opts, returns|
|
87
|
-
returns.each do |method, value|
|
88
|
-
it "#{method} should return #{value}" do
|
89
|
-
location.with(opts).send(method).should == value
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
describe "when duplicated" do
|
96
|
-
it "should not inherit some objects" do
|
97
|
-
location = SitemapGenerator::SitemapLocation.new(:filename => 'xxx', :host => default_host, :public_path => 'public/')
|
98
|
-
location.url.should == default_host+'/xxx'
|
99
|
-
location.public_path.to_s.should == 'public/'
|
100
|
-
dup = location.dup
|
101
|
-
dup.url.should == location.url
|
102
|
-
dup.url.should_not be(location.url)
|
103
|
-
dup.public_path.to_s.should == location.public_path.to_s
|
104
|
-
dup.public_path.should_not be(location.public_path)
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
describe "filesize" do
|
109
|
-
it "should read the size of the file at path" do
|
110
|
-
location.expects(:path).returns('/somepath')
|
111
|
-
File.expects(:size?).with('/somepath')
|
112
|
-
location.filesize
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
describe "public_path" do
|
117
|
-
it "should append a trailing slash" do
|
118
|
-
location = SitemapGenerator::SitemapLocation.new(:public_path => 'public/google')
|
119
|
-
location.public_path.to_s.should == 'public/google/'
|
120
|
-
location[:public_path] = 'new/path'
|
121
|
-
location.public_path.to_s.should == 'new/path/'
|
122
|
-
location[:public_path] = 'already/slashed/'
|
123
|
-
location.public_path.to_s.should == 'already/slashed/'
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
describe "sitemaps_path" do
|
128
|
-
it "should append a trailing slash" do
|
129
|
-
location = SitemapGenerator::SitemapLocation.new(:sitemaps_path => 'public/google')
|
130
|
-
location.sitemaps_path.to_s.should == 'public/google/'
|
131
|
-
location[:sitemaps_path] = 'new/path'
|
132
|
-
location.sitemaps_path.to_s.should == 'new/path/'
|
133
|
-
location[:sitemaps_path] = 'already/slashed/'
|
134
|
-
location.sitemaps_path.to_s.should == 'already/slashed/'
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
describe "url" do
|
139
|
-
it "should handle paths not ending in slash" do
|
140
|
-
location = SitemapGenerator::SitemapLocation.new(
|
141
|
-
:public_path => 'public/google', :filename => 'xxx',
|
142
|
-
:host => default_host, :sitemaps_path => 'sub/dir')
|
143
|
-
location.url.should == default_host + '/sub/dir/xxx'
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
describe "write" do
|
148
|
-
it "should output summary line when verbose" do
|
149
|
-
location = SitemapGenerator::SitemapLocation.new(:public_path => 'public/', :verbose => true)
|
150
|
-
location.adapter.stubs(:write)
|
151
|
-
location.expects(:summary)
|
152
|
-
location.write('data', 1)
|
153
|
-
end
|
154
|
-
|
155
|
-
it "should not output summary line when not verbose" do
|
156
|
-
location = SitemapGenerator::SitemapLocation.new(:public_path => 'public/', :verbose => false)
|
157
|
-
location.adapter.stubs(:write)
|
158
|
-
location.expects(:summary).never
|
159
|
-
location.write('data', 1)
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
describe "filename" do
|
164
|
-
it "should strip gz extension if not compressing" do
|
165
|
-
location = SitemapGenerator::SitemapLocation.new(:namer => SitemapGenerator::SimpleNamer.new(:sitemap), :compress => false)
|
166
|
-
location.filename.should == 'sitemap.xml'
|
167
|
-
end
|
168
|
-
|
169
|
-
it "should not strip gz extension if compressing" do
|
170
|
-
location = SitemapGenerator::SitemapLocation.new(:namer => SitemapGenerator::SimpleNamer.new(:sitemap), :compress => true)
|
171
|
-
location.filename.should == 'sitemap.xml.gz'
|
172
|
-
end
|
173
|
-
|
174
|
-
it "should strip gz extension if :all_but_first and first file" do
|
175
|
-
namer = SitemapGenerator::SimpleNamer.new(:sitemap)
|
176
|
-
namer.stubs(:start?).returns(true)
|
177
|
-
location = SitemapGenerator::SitemapLocation.new(:namer => namer, :compress => :all_but_first)
|
178
|
-
location.filename.should == 'sitemap.xml'
|
179
|
-
end
|
180
|
-
|
181
|
-
it "should strip gz extension if :all_but_first and first file" do
|
182
|
-
namer = SitemapGenerator::SimpleNamer.new(:sitemap)
|
183
|
-
namer.stubs(:start?).returns(false)
|
184
|
-
location = SitemapGenerator::SitemapLocation.new(:namer => namer, :compress => :all_but_first)
|
185
|
-
location.filename.should == 'sitemap.xml.gz'
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
describe "when not compressing" do
|
190
|
-
it "the URL should point to the uncompressed file" do
|
191
|
-
location = SitemapGenerator::SitemapLocation.new(
|
192
|
-
:namer => SitemapGenerator::SimpleNamer.new(:sitemap),
|
193
|
-
:host => 'http://example.com',
|
194
|
-
:compress => false
|
195
|
-
)
|
196
|
-
location.url.should == 'http://example.com/sitemap.xml'
|
197
|
-
end
|
198
|
-
end
|
199
|
-
end
|
200
|
-
|
201
|
-
describe SitemapGenerator::SitemapIndexLocation do
|
202
|
-
let(:location) { SitemapGenerator::SitemapIndexLocation.new }
|
203
|
-
|
204
|
-
it "should have a default namer" do
|
205
|
-
location = SitemapGenerator::SitemapIndexLocation.new
|
206
|
-
location[:namer].should_not be_nil
|
207
|
-
location[:filename].should be_nil
|
208
|
-
location.filename.should == 'sitemap.xml.gz'
|
209
|
-
end
|
210
|
-
end
|
@@ -1,96 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe SitemapGenerator::SimpleNamer do
|
4
|
-
it "should generate file names" do
|
5
|
-
namer = SitemapGenerator::SimpleNamer.new(:sitemap)
|
6
|
-
namer.to_s.should == "sitemap.xml.gz"
|
7
|
-
namer.next.to_s.should == "sitemap1.xml.gz"
|
8
|
-
namer.next.to_s.should == "sitemap2.xml.gz"
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should set the file extension" do
|
12
|
-
namer = SitemapGenerator::SimpleNamer.new(:sitemap, :extension => '.xyz')
|
13
|
-
namer.to_s.should == "sitemap.xyz"
|
14
|
-
namer.next.to_s.should == "sitemap1.xyz"
|
15
|
-
namer.next.to_s.should == "sitemap2.xyz"
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should set the starting index" do
|
19
|
-
namer = SitemapGenerator::SimpleNamer.new(:sitemap, :start => 10)
|
20
|
-
namer.to_s.should == "sitemap.xml.gz"
|
21
|
-
namer.next.to_s.should == "sitemap10.xml.gz"
|
22
|
-
namer.next.to_s.should == "sitemap11.xml.gz"
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should accept a string name" do
|
26
|
-
namer = SitemapGenerator::SimpleNamer.new('abc-def')
|
27
|
-
namer.to_s.should == "abc-def.xml.gz"
|
28
|
-
namer.next.to_s.should == "abc-def1.xml.gz"
|
29
|
-
namer.next.to_s.should == "abc-def2.xml.gz"
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should return previous name" do
|
33
|
-
namer = SitemapGenerator::SimpleNamer.new(:sitemap)
|
34
|
-
namer.to_s.should == "sitemap.xml.gz"
|
35
|
-
namer.next.to_s.should == "sitemap1.xml.gz"
|
36
|
-
namer.previous.to_s.should == "sitemap.xml.gz"
|
37
|
-
namer.next.next.to_s.should == "sitemap2.xml.gz"
|
38
|
-
namer.previous.to_s.should == "sitemap1.xml.gz"
|
39
|
-
namer.next.next.to_s.should == "sitemap3.xml.gz"
|
40
|
-
namer.previous.to_s.should == "sitemap2.xml.gz"
|
41
|
-
end
|
42
|
-
|
43
|
-
it "should raise if already at the start" do
|
44
|
-
namer = SitemapGenerator::SimpleNamer.new(:sitemap)
|
45
|
-
namer.to_s.should == "sitemap.xml.gz"
|
46
|
-
lambda { namer.previous }.should raise_error
|
47
|
-
end
|
48
|
-
|
49
|
-
it "should handle names with underscores" do
|
50
|
-
namer = SitemapGenerator::SimpleNamer.new("sitemap1_")
|
51
|
-
namer.to_s.should == "sitemap1_.xml.gz"
|
52
|
-
namer.next.to_s.should == "sitemap1_1.xml.gz"
|
53
|
-
end
|
54
|
-
|
55
|
-
it "should reset the namer" do
|
56
|
-
namer = SitemapGenerator::SimpleNamer.new(:sitemap)
|
57
|
-
namer.to_s.should == "sitemap.xml.gz"
|
58
|
-
namer.next.to_s.should == "sitemap1.xml.gz"
|
59
|
-
namer.reset
|
60
|
-
namer.to_s.should == "sitemap.xml.gz"
|
61
|
-
namer.next.to_s.should == "sitemap1.xml.gz"
|
62
|
-
end
|
63
|
-
|
64
|
-
describe "should handle the zero option" do
|
65
|
-
it "as a string" do
|
66
|
-
namer = SitemapGenerator::SimpleNamer.new(:sitemap, :zero => "string")
|
67
|
-
namer.to_s.should == "sitemapstring.xml.gz"
|
68
|
-
namer.next.to_s.should == "sitemap1.xml.gz"
|
69
|
-
end
|
70
|
-
|
71
|
-
it "as an integer" do
|
72
|
-
namer = SitemapGenerator::SimpleNamer.new(:sitemap, :zero => 0)
|
73
|
-
namer.to_s.should == "sitemap0.xml.gz"
|
74
|
-
namer.next.to_s.should == "sitemap1.xml.gz"
|
75
|
-
end
|
76
|
-
|
77
|
-
it "as a string" do
|
78
|
-
namer = SitemapGenerator::SimpleNamer.new(:sitemap, :zero => "_index")
|
79
|
-
namer.to_s.should == "sitemap_index.xml.gz"
|
80
|
-
namer.next.to_s.should == "sitemap1.xml.gz"
|
81
|
-
end
|
82
|
-
|
83
|
-
it "as a symbol" do
|
84
|
-
namer = SitemapGenerator::SimpleNamer.new(:sitemap, :zero => :index)
|
85
|
-
namer.to_s.should == "sitemapindex.xml.gz"
|
86
|
-
namer.next.to_s.should == "sitemap1.xml.gz"
|
87
|
-
end
|
88
|
-
|
89
|
-
it "with a starting index" do
|
90
|
-
namer = SitemapGenerator::SimpleNamer.new(:sitemap, :zero => 'abc', :start => 10)
|
91
|
-
namer.to_s.should == "sitemapabc.xml.gz"
|
92
|
-
namer.next.to_s.should == "sitemap10.xml.gz"
|
93
|
-
namer.next.to_s.should == "sitemap11.xml.gz"
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|