sitemap_generator 4.3.1 → 5.0.0.beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe SitemapGenerator::SitemapLocation do
4
4
  let(:default_host) { 'http://example.com' }
5
5
  let(:location) { SitemapGenerator::SitemapLocation.new }
6
-
6
+
7
7
  it "public_path should default to the public directory in the application root" do
8
8
  location.public_path.should == SitemapGenerator.app.root + 'public/'
9
9
  end
@@ -36,13 +36,13 @@ describe SitemapGenerator::SitemapLocation do
36
36
  end
37
37
 
38
38
  it "should accept a Namer option" do
39
- @namer = SitemapGenerator::SitemapNamer.new(:xxx)
39
+ @namer = SitemapGenerator::SimpleNamer.new(:xxx)
40
40
  location = SitemapGenerator::SitemapLocation.new(:namer => @namer)
41
41
  location.filename.should == @namer.to_s
42
42
  end
43
43
 
44
44
  it "should protect the filename from further changes in the Namer" do
45
- @namer = SitemapGenerator::SitemapNamer.new(:xxx)
45
+ @namer = SitemapGenerator::SimpleNamer.new(:xxx)
46
46
  location = SitemapGenerator::SitemapLocation.new(:namer => @namer)
47
47
  location.filename.should == @namer.to_s
48
48
  @namer.next
@@ -50,10 +50,10 @@ describe SitemapGenerator::SitemapLocation do
50
50
  end
51
51
 
52
52
  it "should allow changing the namer" do
53
- @namer1 = SitemapGenerator::SitemapNamer.new(:xxx)
53
+ @namer1 = SitemapGenerator::SimpleNamer.new(:xxx)
54
54
  location = SitemapGenerator::SitemapLocation.new(:namer => @namer1)
55
55
  location.filename.should == @namer1.to_s
56
- @namer2 = SitemapGenerator::SitemapNamer.new(:yyy)
56
+ @namer2 = SitemapGenerator::SimpleNamer.new(:yyy)
57
57
  location[:namer] = @namer2
58
58
  location.filename.should == @namer2.to_s
59
59
  end
@@ -65,22 +65,22 @@ describe SitemapGenerator::SitemapLocation do
65
65
  [{
66
66
  :sitemaps_path => nil,
67
67
  :public_path => '/public',
68
- :filename => 'sitemap1.xml.gz',
68
+ :filename => 'sitemap.xml.gz',
69
69
  :host => 'http://test.com' },
70
- { :url => 'http://test.com/sitemap1.xml.gz',
70
+ { :url => 'http://test.com/sitemap.xml.gz',
71
71
  :directory => '/public',
72
- :path => '/public/sitemap1.xml.gz',
73
- :path_in_public => 'sitemap1.xml.gz'
72
+ :path => '/public/sitemap.xml.gz',
73
+ :path_in_public => 'sitemap.xml.gz'
74
74
  }],
75
75
  [{
76
76
  :sitemaps_path => 'sitemaps/en/',
77
77
  :public_path => '/public/system/',
78
- :filename => 'sitemap1.xml.gz',
78
+ :filename => 'sitemap.xml.gz',
79
79
  :host => 'http://test.com/plus/extra/' },
80
- { :url => 'http://test.com/plus/extra/sitemaps/en/sitemap1.xml.gz',
80
+ { :url => 'http://test.com/plus/extra/sitemaps/en/sitemap.xml.gz',
81
81
  :directory => '/public/system/sitemaps/en',
82
- :path => '/public/system/sitemaps/en/sitemap1.xml.gz',
83
- :path_in_public => 'sitemaps/en/sitemap1.xml.gz'
82
+ :path => '/public/system/sitemaps/en/sitemap.xml.gz',
83
+ :path_in_public => 'sitemaps/en/sitemap.xml.gz'
84
84
  }]
85
85
  ]
86
86
  tests.each do |opts, returns|
@@ -112,7 +112,7 @@ describe SitemapGenerator::SitemapLocation do
112
112
  location.filesize
113
113
  end
114
114
  end
115
-
115
+
116
116
  describe "public_path" do
117
117
  it "should append a trailing slash" do
118
118
  location = SitemapGenerator::SitemapLocation.new(:public_path => 'public/google')
@@ -123,7 +123,7 @@ describe SitemapGenerator::SitemapLocation do
123
123
  location.public_path.to_s.should == 'already/slashed/'
124
124
  end
125
125
  end
126
-
126
+
127
127
  describe "sitemaps_path" do
128
128
  it "should append a trailing slash" do
129
129
  location = SitemapGenerator::SitemapLocation.new(:sitemaps_path => 'public/google')
@@ -134,15 +134,57 @@ describe SitemapGenerator::SitemapLocation do
134
134
  location.sitemaps_path.to_s.should == 'already/slashed/'
135
135
  end
136
136
  end
137
-
137
+
138
138
  describe "url" do
139
139
  it "should handle paths not ending in slash" do
140
140
  location = SitemapGenerator::SitemapLocation.new(
141
- :public_path => 'public/google', :filename => 'xxx',
141
+ :public_path => 'public/google', :filename => 'xxx',
142
142
  :host => default_host, :sitemaps_path => 'sub/dir')
143
143
  location.url.should == default_host + '/sub/dir/xxx'
144
144
  end
145
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')
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')
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
146
188
  end
147
189
 
148
190
  describe SitemapGenerator::SitemapIndexLocation do
@@ -1,75 +1,5 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'SitemapGenerator::SitemapNamer' do
4
-
5
- it "should generate file names" do
6
- namer = SitemapGenerator::SitemapNamer.new(:sitemap)
7
- namer.to_s.should == "sitemap1.xml.gz"
8
- namer.next.to_s.should == "sitemap2.xml.gz"
9
- namer.next.to_s.should == "sitemap3.xml.gz"
10
- end
11
-
12
- it "should set the file extension" do
13
- namer = SitemapGenerator::SitemapNamer.new(:sitemap, :extension => '.xyz')
14
- namer.to_s.should == "sitemap1.xyz"
15
- namer.next.to_s.should == "sitemap2.xyz"
16
- namer.next.to_s.should == "sitemap3.xyz"
17
- end
18
-
19
- it "should set the starting index" do
20
- namer = SitemapGenerator::SitemapNamer.new(:sitemap, :start => 10)
21
- namer.to_s.should == "sitemap10.xml.gz"
22
- namer.next.to_s.should == "sitemap11.xml.gz"
23
- namer.next.to_s.should == "sitemap12.xml.gz"
24
- end
25
-
26
- it "should accept a string name" do
27
- namer = SitemapGenerator::SitemapNamer.new('abc-def')
28
- namer.to_s.should == "abc-def1.xml.gz"
29
- namer.next.to_s.should == "abc-def2.xml.gz"
30
- namer.next.to_s.should == "abc-def3.xml.gz"
31
- end
32
-
33
- it "should return previous name" do
34
- namer = SitemapGenerator::SitemapNamer.new(:sitemap)
35
- namer.to_s.should == "sitemap1.xml.gz"
36
- namer.next.to_s.should == "sitemap2.xml.gz"
37
- namer.previous.to_s.should == "sitemap1.xml.gz"
38
- namer.next.to_s.should == "sitemap2.xml.gz"
39
- end
40
-
41
- it "should raise if already at the start" do
42
- namer = SitemapGenerator::SitemapNamer.new(:sitemap)
43
- namer.to_s.should == "sitemap1.xml.gz"
44
- lambda { namer.previous }.should raise_error
45
- end
46
-
47
- it "should handle names with underscores" do
48
- namer = SitemapGenerator::SitemapNamer.new("sitemap1_")
49
- namer.to_s.should == "sitemap1_1.xml.gz"
50
- end
51
-
52
- it "should reset the namer" do
53
- namer = SitemapGenerator::SitemapNamer.new(:sitemap)
54
- namer.to_s.should == "sitemap1.xml.gz"
55
- namer.next.to_s.should == "sitemap2.xml.gz"
56
- namer.reset
57
- namer.to_s.should == "sitemap1.xml.gz"
58
- namer.next.to_s.should == "sitemap2.xml.gz"
59
- end
60
- end
61
-
62
- describe SitemapGenerator::SitemapIndexNamer do
63
- it "should always return the same name" do
64
- default = "sitemap_index.xml.gz"
65
- namer = SitemapGenerator::SitemapIndexNamer.new(:sitemap_index)
66
- namer.to_s.should == default
67
- namer.next.to_s.should == default
68
- namer.previous.to_s.should == default
69
- SitemapGenerator::SitemapIndexNamer.new(:sitemap).to_s.should == 'sitemap.xml.gz'
70
- end
71
- end
72
-
73
3
  describe SitemapGenerator::SimpleNamer do
74
4
  it "should generate file names" do
75
5
  namer = SitemapGenerator::SimpleNamer.new(:sitemap)
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sitemap_generator
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ prerelease: true
5
5
  segments:
6
- - 4
7
- - 3
8
- - 1
9
- version: 4.3.1
6
+ - 5
7
+ - 0
8
+ - 0
9
+ - beta
10
+ version: 5.0.0.beta
10
11
  platform: ruby
11
12
  authors:
12
13
  - Karl Varga
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2013-12-10 00:00:00 -08:00
18
+ date: 2014-01-06 00:00:00 -08:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
@@ -114,7 +115,6 @@ files:
114
115
  - templates/sitemap.rb
115
116
  - spec/blueprint.rb
116
117
  - spec/files/sitemap.create.rb
117
- - spec/files/sitemap.deprecated.rb
118
118
  - spec/files/sitemap.groups.rb
119
119
  - spec/sitemap_generator/adapters/s3_adapter_spec.rb
120
120
  - spec/sitemap_generator/alternate_sitemap_spec.rb
@@ -125,6 +125,7 @@ files:
125
125
  - spec/sitemap_generator/builder/sitemap_url_spec.rb
126
126
  - spec/sitemap_generator/core_ext/bigdecimal_spec.rb
127
127
  - spec/sitemap_generator/core_ext/numeric_spec.rb
128
+ - spec/sitemap_generator/file_adaptor_spec.rb
128
129
  - spec/sitemap_generator/geo_sitemap_spec.rb
129
130
  - spec/sitemap_generator/helpers/number_helper_spec.rb
130
131
  - spec/sitemap_generator/interpreter_spec.rb
@@ -174,19 +175,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
174
175
  requirements:
175
176
  - - ">="
176
177
  - !ruby/object:Gem::Version
177
- hash: 556482523995297639
178
+ hash: -334787337373282166
178
179
  segments:
179
180
  - 0
180
181
  version: "0"
181
182
  required_rubygems_version: !ruby/object:Gem::Requirement
182
183
  none: false
183
184
  requirements:
184
- - - ">="
185
+ - - ">"
185
186
  - !ruby/object:Gem::Version
186
- hash: 556482523995297639
187
187
  segments:
188
- - 0
189
- version: "0"
188
+ - 1
189
+ - 3
190
+ - 1
191
+ version: 1.3.1
190
192
  requirements: []
191
193
 
192
194
  rubyforge_project:
@@ -197,7 +199,6 @@ summary: Easily generate XML Sitemaps
197
199
  test_files:
198
200
  - spec/blueprint.rb
199
201
  - spec/files/sitemap.create.rb
200
- - spec/files/sitemap.deprecated.rb
201
202
  - spec/files/sitemap.groups.rb
202
203
  - spec/sitemap_generator/adapters/s3_adapter_spec.rb
203
204
  - spec/sitemap_generator/alternate_sitemap_spec.rb
@@ -208,6 +209,7 @@ test_files:
208
209
  - spec/sitemap_generator/builder/sitemap_url_spec.rb
209
210
  - spec/sitemap_generator/core_ext/bigdecimal_spec.rb
210
211
  - spec/sitemap_generator/core_ext/numeric_spec.rb
212
+ - spec/sitemap_generator/file_adaptor_spec.rb
211
213
  - spec/sitemap_generator/geo_sitemap_spec.rb
212
214
  - spec/sitemap_generator/helpers/number_helper_spec.rb
213
215
  - spec/sitemap_generator/interpreter_spec.rb
@@ -1,15 +0,0 @@
1
- SitemapGenerator::Sitemap.default_host = "http://www.example.com"
2
- SitemapGenerator::Sitemap.yahoo_app_id = false
3
- SitemapGenerator::Sitemap.create_index = true
4
- SitemapGenerator::Sitemap.namer = SitemapGenerator::SimpleNamer.new(:sitemap, :zero => '_index')
5
-
6
- SitemapGenerator::Sitemap.add_links do |sitemap|
7
- sitemap.add '/contents', :priority => 0.7, :changefreq => 'daily'
8
-
9
- # add all individual articles
10
- (1..10).each do |i|
11
- sitemap.add "/content/#{i}"
12
- end
13
-
14
- sitemap.add "/merchant_path", :host => "https://www.example.com"
15
- end