sitemap_generator 5.2.0 → 5.3.0

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.
Files changed (58) hide show
  1. checksums.yaml +8 -8
  2. data/CHANGES.md +250 -0
  3. data/README.md +156 -125
  4. data/VERSION +1 -1
  5. data/lib/capistrano/tasks/sitemap_generator.cap +21 -23
  6. data/lib/sitemap_generator.rb +1 -2
  7. data/lib/sitemap_generator/adapters/s3_adapter.rb +5 -0
  8. data/lib/sitemap_generator/application.rb +1 -1
  9. data/lib/sitemap_generator/builder/sitemap_file.rb +7 -3
  10. data/lib/sitemap_generator/builder/sitemap_url.rb +1 -10
  11. data/lib/sitemap_generator/link_set.rb +16 -10
  12. data/lib/sitemap_generator/{sitemap_namer.rb → simple_namer.rb} +1 -1
  13. data/lib/sitemap_generator/sitemap_location.rb +13 -1
  14. data/lib/sitemap_generator/tasks.rb +2 -2
  15. metadata +51 -123
  16. data/Gemfile +0 -13
  17. data/Gemfile.lock +0 -38
  18. data/Rakefile +0 -43
  19. data/spec/blueprint.rb +0 -15
  20. data/spec/files/sitemap.create.rb +0 -12
  21. data/spec/files/sitemap.groups.rb +0 -49
  22. data/spec/sitemap_generator/adapters/s3_adapter_spec.rb +0 -23
  23. data/spec/sitemap_generator/alternate_sitemap_spec.rb +0 -100
  24. data/spec/sitemap_generator/application_spec.rb +0 -69
  25. data/spec/sitemap_generator/builder/sitemap_file_spec.rb +0 -110
  26. data/spec/sitemap_generator/builder/sitemap_index_file_spec.rb +0 -124
  27. data/spec/sitemap_generator/builder/sitemap_index_url_spec.rb +0 -28
  28. data/spec/sitemap_generator/builder/sitemap_url_spec.rb +0 -192
  29. data/spec/sitemap_generator/core_ext/bigdecimal_spec.rb +0 -20
  30. data/spec/sitemap_generator/core_ext/numeric_spec.rb +0 -43
  31. data/spec/sitemap_generator/file_adaptor_spec.rb +0 -20
  32. data/spec/sitemap_generator/geo_sitemap_spec.rb +0 -30
  33. data/spec/sitemap_generator/helpers/number_helper_spec.rb +0 -196
  34. data/spec/sitemap_generator/interpreter_spec.rb +0 -90
  35. data/spec/sitemap_generator/link_set_spec.rb +0 -864
  36. data/spec/sitemap_generator/mobile_sitemap_spec.rb +0 -27
  37. data/spec/sitemap_generator/news_sitemap_spec.rb +0 -42
  38. data/spec/sitemap_generator/pagemap_sitemap_spec.rb +0 -57
  39. data/spec/sitemap_generator/sitemap_generator_spec.rb +0 -591
  40. data/spec/sitemap_generator/sitemap_groups_spec.rb +0 -144
  41. data/spec/sitemap_generator/sitemap_location_spec.rb +0 -210
  42. data/spec/sitemap_generator/sitemap_namer_spec.rb +0 -96
  43. data/spec/sitemap_generator/templates_spec.rb +0 -24
  44. data/spec/sitemap_generator/utilities/existence_spec.rb +0 -26
  45. data/spec/sitemap_generator/utilities/hash_spec.rb +0 -57
  46. data/spec/sitemap_generator/utilities/rounding_spec.rb +0 -31
  47. data/spec/sitemap_generator/utilities_spec.rb +0 -101
  48. data/spec/sitemap_generator/video_sitemap_spec.rb +0 -117
  49. data/spec/spec_helper.rb +0 -24
  50. data/spec/support/file_macros.rb +0 -39
  51. data/spec/support/schemas/siteindex.xsd +0 -73
  52. data/spec/support/schemas/sitemap-geo.xsd +0 -41
  53. data/spec/support/schemas/sitemap-mobile.xsd +0 -32
  54. data/spec/support/schemas/sitemap-news.xsd +0 -159
  55. data/spec/support/schemas/sitemap-pagemap.xsd +0 -97
  56. data/spec/support/schemas/sitemap-video.xsd +0 -643
  57. data/spec/support/schemas/sitemap.xsd +0 -115
  58. data/spec/support/xml_macros.rb +0 -67
data/Gemfile DELETED
@@ -1,13 +0,0 @@
1
- source 'http://rubygems.org'
2
-
3
- gem 'builder'
4
- gem 'sitemap_generator', :path => './'
5
-
6
- group :development, :test do
7
- gem 'mocha'
8
- gem 'nokogiri', '=1.5.10' # last release to support Ruby 1.8.7
9
- gem 'rake'
10
- gem 'rspec'
11
- #gem 'ruby-debug19', :require => 'ruby-debug'
12
- #gem 'simplecov', :require => false
13
- end
@@ -1,38 +0,0 @@
1
- PATH
2
- remote: ./
3
- specs:
4
- sitemap_generator (5.2.0)
5
- builder (~> 3.0)
6
-
7
- GEM
8
- remote: http://rubygems.org/
9
- specs:
10
- builder (3.2.2)
11
- diff-lcs (1.1.3)
12
- metaclass (0.0.1)
13
- mocha (0.10.0)
14
- metaclass (~> 0.0.1)
15
- nokogiri (1.5.10)
16
- rake (10.0.4)
17
- rspec (2.8.0)
18
- rspec-core (~> 2.8.0)
19
- rspec-expectations (~> 2.8.0)
20
- rspec-mocks (~> 2.8.0)
21
- rspec-core (2.8.0)
22
- rspec-expectations (2.8.0)
23
- diff-lcs (~> 1.1.2)
24
- rspec-mocks (2.8.0)
25
-
26
- PLATFORMS
27
- ruby
28
-
29
- DEPENDENCIES
30
- builder
31
- mocha
32
- nokogiri (= 1.5.10)
33
- rake
34
- rspec
35
- sitemap_generator!
36
-
37
- BUNDLED WITH
38
- 1.12.5
data/Rakefile DELETED
@@ -1,43 +0,0 @@
1
- require 'bundler/setup'
2
- Bundler.require
3
-
4
- desc 'Default: run spec tests.'
5
- task :default => :spec
6
-
7
- require "rspec/core/rake_task"
8
- RSpec::Core::RakeTask.new(:spec) do |spec|
9
- spec.pattern = Dir.glob(['spec/sitemap_generator/**/*'])
10
- spec.rspec_opts = ['--backtrace']
11
- end
12
-
13
- #
14
- # Helpers
15
- #
16
-
17
- def name; @name ||= Dir['*.gemspec'].first.split('.').first end
18
- def version; File.read('VERSION').chomp end
19
- def gemspec_file; "#{name}.gemspec" end
20
- def gem_file; "#{name}-#{version}.gem" end
21
-
22
- #
23
- # Release Tasks
24
- # @see https://github.com/mojombo/rakegem
25
- #
26
-
27
- desc "Create tag v#{version}, build the gem and push to Git"
28
- task :release => :build do
29
- unless `git branch` =~ /^\* master$/
30
- puts "You must be on the master branch to release!"
31
- exit!
32
- end
33
- sh "git tag v#{version}"
34
- sh "git push origin master --tags"
35
- end
36
-
37
- desc "Build #{gem_file} into the pkg/ directory"
38
- task :build do
39
- sh "mkdir -p pkg"
40
- sh "gem build #{gemspec_file}"
41
- sh "mv #{gem_file} pkg"
42
- sh "bundle --local"
43
- end
@@ -1,15 +0,0 @@
1
- require 'machinist/active_record'
2
- require 'sham'
3
-
4
- Sham.title { Time.now.to_i }
5
- Content.blueprint do
6
- title
7
- end
8
-
9
- module Blueprint
10
- def self.seed
11
- 14.times do |i|
12
- content = Content.make(:title => "Link #{i}")
13
- end
14
- end
15
- end
@@ -1,12 +0,0 @@
1
- SitemapGenerator::Sitemap.default_host = "http://www.example.com"
2
-
3
- SitemapGenerator::Sitemap.create do
4
- add '/contents', :priority => 0.7, :changefreq => 'daily'
5
-
6
- # add all individual articles
7
- (1..10).each do |i|
8
- add "/content/#{i}"
9
- end
10
-
11
- add "/merchant_path", :host => "https://www.example.com"
12
- end
@@ -1,49 +0,0 @@
1
- SitemapGenerator::Sitemap.default_host = "http://www.example.com"
2
-
3
- SitemapGenerator::Sitemap.create(
4
- :include_root => true, :include_index => true,
5
- :filename => :new_sitemaps, :sitemaps_path => 'fr/') do
6
-
7
- add('/one', :priority => 0.7, :changefreq => 'daily')
8
-
9
- # Test a new location and filename and sitemaps host
10
- group(:sitemaps_path => 'en/', :filename => :xxx,
11
- :sitemaps_host => "http://newhost.com") do
12
-
13
- add '/two'
14
- add '/three'
15
- end
16
-
17
- # Test a simple namer.
18
- group(:namer => SitemapGenerator::SimpleNamer.new(:abc, :start => 4, :zero => 3)) do
19
- add '/four'
20
- add '/five'
21
- add '/six'
22
- end
23
-
24
- # Test a simple namer
25
- group(:namer => SitemapGenerator::SimpleNamer.new(:def)) do
26
- add '/four'
27
- add '/five'
28
- add '/six'
29
- end
30
-
31
- add '/seven'
32
-
33
- # This should be in a file of its own.
34
- # Not technically valid to have a link with a different host, but people like
35
- # to do strange things sometimes.
36
- group(:sitemaps_host => "http://exceptional.com") do
37
- add '/eight'
38
- add '/nine'
39
- end
40
-
41
- add '/ten'
42
-
43
- # This should have no effect. Already added default links.
44
- group(:include_root => true, :include_index => true) {}
45
-
46
- # Not technically valid to have a link with a different host, but people like
47
- # to do strange things sometimes
48
- add "/merchant_path", :host => "https://www.merchanthost.com"
49
- end
@@ -1,23 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- require 'spec_helper'
4
-
5
- # Don't run this test as part of the unit testing suite as we don't want
6
- # Fog to be a dependency of SitemapGenerator core. This is an integration
7
- # test. Unfortunately it doesn't really test much, so its usefullness is
8
- # questionable.
9
- describe 'SitemapGenerator::S3Adapter', :integration => true do
10
-
11
- let(:location) { SitemapGenerator::SitemapLocation.new(:namer => SitemapGenerator::SitemapNamer.new(:sitemap), :public_path => 'tmp/', :sitemaps_path => 'test/', :host => 'http://example.com/') }
12
- let(:directory) { stub(:files => stub(:create)) }
13
- let(:directories) { stub(:directories => stub(:new => directory)) }
14
-
15
- before do
16
- SitemapGenerator::S3Adapter # eager load
17
- Fog::Storage.stubs(:new => directories)
18
- end
19
-
20
- it 'should create the file in S3 with a single operation' do
21
- subject.write(location, 'payload')
22
- end
23
- end
@@ -1,100 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "SitemapGenerator" do
4
- it "should not include media element unless provided" do
5
- xml_fragment = SitemapGenerator::Builder::SitemapUrl.new('link_with_alternates.html',
6
- :host => 'http://www.example.com',
7
- :alternates => [
8
- {
9
- :lang => 'de',
10
- :href => 'http://www.example.de/link_with_alternate.html'
11
- }
12
- ]
13
- ).to_xml
14
-
15
- doc = Nokogiri::XML.parse("<root xmlns='http://www.sitemaps.org/schemas/sitemap/0.9' xmlns:xhtml='http://www.w3.org/1999/xhtml'>#{xml_fragment}</root>")
16
- url = doc.css('url')
17
- url.should_not be_nil
18
- url.css('loc').text.should == 'http://www.example.com/link_with_alternates.html'
19
-
20
- alternate = url.at_xpath('xhtml:link')
21
- alternate.should_not be_nil
22
- alternate.attribute('rel').value.should == 'alternate'
23
- alternate.attribute('hreflang').value.should == 'de'
24
- alternate.attribute('media').should be_nil
25
- end
26
-
27
- it "should not include hreflang element unless provided" do
28
- xml_fragment = SitemapGenerator::Builder::SitemapUrl.new('link_with_alternates.html',
29
- :host => 'http://www.example.com',
30
- :alternates => [
31
- {
32
- :href => 'http://www.example.de/link_with_alternate.html'
33
- }
34
- ]
35
- ).to_xml
36
-
37
- doc = Nokogiri::XML.parse("<root xmlns='http://www.sitemaps.org/schemas/sitemap/0.9' xmlns:xhtml='http://www.w3.org/1999/xhtml'>#{xml_fragment}</root>")
38
- url = doc.css('url')
39
- url.should_not be_nil
40
- url.css('loc').text.should == 'http://www.example.com/link_with_alternates.html'
41
-
42
- alternate = url.at_xpath('xhtml:link')
43
- alternate.should_not be_nil
44
- alternate.attribute('rel').value.should == 'alternate'
45
- alternate.attribute('hreflang').should be_nil
46
- end
47
-
48
- it "should add alternate links to sitemap" do
49
- xml_fragment = SitemapGenerator::Builder::SitemapUrl.new('link_with_alternates.html',
50
- :host => 'http://www.example.com',
51
- :alternates => [
52
- {
53
- :lang => 'de',
54
- :href => 'http://www.example.de/link_with_alternate.html',
55
- :media => 'only screen and (max-width: 640px)'
56
- }
57
- ]
58
- ).to_xml
59
-
60
- doc = Nokogiri::XML.parse("<root xmlns='http://www.sitemaps.org/schemas/sitemap/0.9' xmlns:xhtml='http://www.w3.org/1999/xhtml'>#{xml_fragment}</root>")
61
- url = doc.css('url')
62
- url.should_not be_nil
63
- url.css('loc').text.should == 'http://www.example.com/link_with_alternates.html'
64
-
65
- alternate = url.at_xpath('xhtml:link')
66
- alternate.should_not be_nil
67
- alternate.attribute('rel').value.should == 'alternate'
68
- alternate.attribute('hreflang').value.should == 'de'
69
- alternate.attribute('href').value.should == 'http://www.example.de/link_with_alternate.html'
70
- alternate.attribute('media').value.should == 'only screen and (max-width: 640px)'
71
- end
72
-
73
- it "should add alternate links to sitemap with rel nofollow" do
74
- xml_fragment = SitemapGenerator::Builder::SitemapUrl.new('link_with_alternates.html',
75
- :host => 'http://www.example.com',
76
- :alternates => [
77
- {
78
- :lang => 'de',
79
- :href => 'http://www.example.de/link_with_alternate.html',
80
- :nofollow => true,
81
- :media => 'only screen and (max-width: 640px)'
82
- }
83
- ]
84
- ).to_xml
85
-
86
- doc = Nokogiri::XML.parse("<root xmlns='http://www.sitemaps.org/schemas/sitemap/0.9' xmlns:xhtml='http://www.w3.org/1999/xhtml'>#{xml_fragment}</root>")
87
- url = doc.css('url')
88
- url.should_not be_nil
89
- url.css('loc').text.should == 'http://www.example.com/link_with_alternates.html'
90
-
91
- alternate = url.at_xpath('xhtml:link')
92
- alternate.should_not be_nil
93
- alternate.attribute('rel').value.should == 'alternate nofollow'
94
- alternate.attribute('hreflang').value.should == 'de'
95
- alternate.attribute('href').value.should == 'http://www.example.de/link_with_alternate.html'
96
- alternate.attribute('media').value.should == 'only screen and (max-width: 640px)'
97
- end
98
-
99
- end
100
-
@@ -1,69 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe SitemapGenerator::Application do
4
- before :all do
5
- SitemapGenerator::Utilities.with_warnings(nil) do
6
- Object.const_set(:Rails, Object.new)
7
- end
8
- end
9
-
10
- after :all do
11
- SitemapGenerator::Utilities.with_warnings(nil) do
12
- Object.const_set(:Rails, nil)
13
- end
14
- end
15
-
16
- before :each do
17
- @app = SitemapGenerator::Application.new
18
- end
19
-
20
- describe "rails3?" do
21
- tests = {
22
- :nil => false,
23
- '2.3.11' => false,
24
- '3.0.1' => true,
25
- '3.0.11' => true
26
- }
27
-
28
- it "should identify the rails version correctly" do
29
- tests.each do |version, result|
30
- Rails.expects(:version).returns(version)
31
- @app.rails3?.should == result
32
- end
33
- end
34
- end
35
-
36
- describe "with Rails" do
37
- before :each do
38
- @root = '/test'
39
- Rails.expects(:root).returns(@root).at_least_once
40
- end
41
-
42
- it "should use the Rails.root" do
43
- @app.root.should be_a(Pathname)
44
- @app.root.to_s.should == @root
45
- (@app.root + 'public/').to_s.should == File.join(@root, 'public/')
46
- end
47
- end
48
-
49
- describe "with no Rails" do
50
- before :each do
51
- @rails = Rails
52
- Object.send(:remove_const, :Rails)
53
- end
54
-
55
- after :each do
56
- Object::Rails = @rails
57
- end
58
-
59
- it "should not be Rails" do
60
- @app.rails?.should be_false
61
- end
62
-
63
- it "should use the current working directory" do
64
- @app.root.should be_a(Pathname)
65
- @app.root.to_s.should == Dir.getwd
66
- (@app.root + 'public/').to_s.should == File.join(Dir.getwd, 'public/')
67
- end
68
- end
69
- end
@@ -1,110 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'SitemapGenerator::Builder::SitemapFile' do
4
- let(:location) { SitemapGenerator::SitemapLocation.new(:namer => SitemapGenerator::SimpleNamer.new(:sitemap, :start => 2, :zero => 1), :public_path => 'tmp/', :sitemaps_path => 'test/', :host => 'http://example.com/') }
5
- let(:sitemap) { SitemapGenerator::Builder::SitemapFile.new(location) }
6
-
7
- it "should have a default namer" do
8
- sitemap = SitemapGenerator::Builder::SitemapFile.new
9
- sitemap.location.filename.should == 'sitemap1.xml.gz'
10
- end
11
-
12
- it "should return the name of the sitemap file" do
13
- sitemap.location.filename.should == 'sitemap1.xml.gz'
14
- end
15
-
16
- it "should return the URL" do
17
- sitemap.location.url.should == 'http://example.com/test/sitemap1.xml.gz'
18
- end
19
-
20
- it "should return the path" do
21
- sitemap.location.path.should == File.expand_path('tmp/test/sitemap1.xml.gz')
22
- end
23
-
24
- it "should be empty" do
25
- sitemap.empty?.should be_true
26
- sitemap.link_count.should == 0
27
- end
28
-
29
- it "should not be finalized" do
30
- sitemap.finalized?.should be_false
31
- end
32
-
33
- it "should raise if no default host is set" do
34
- lambda { SitemapGenerator::Builder::SitemapFile.new.location.url }.should raise_error(SitemapGenerator::SitemapError)
35
- end
36
-
37
- describe "lastmod" do
38
- it "should be the file last modified time" do
39
- lastmod = (Time.now - 1209600)
40
- sitemap.location.reserve_name
41
- File.expects(:mtime).with(sitemap.location.path).returns(lastmod)
42
- sitemap.lastmod.should == lastmod
43
- end
44
-
45
- it "should be nil if the location has not reserved a name" do
46
- File.expects(:mtime).never
47
- sitemap.lastmod.should be_nil
48
- end
49
-
50
- it "should be nil if location has reserved a name and the file DNE" do
51
- sitemap.location.reserve_name
52
- File.expects(:mtime).raises(Errno::ENOENT)
53
- sitemap.lastmod.should be_nil
54
- end
55
- end
56
-
57
- describe "new" do
58
- let(:original_sitemap) { sitemap }
59
- let(:new_sitemap) { sitemap.new }
60
-
61
- before :each do
62
- original_sitemap
63
- new_sitemap
64
- end
65
-
66
- it "should inherit the same options" do
67
- # The name is the same because the original sitemap was not finalized
68
- new_sitemap.location.url.should == 'http://example.com/test/sitemap1.xml.gz'
69
- new_sitemap.location.path.should == File.expand_path('tmp/test/sitemap1.xml.gz')
70
- end
71
-
72
- it "should not share the same location instance" do
73
- new_sitemap.location.should_not be(original_sitemap.location)
74
- end
75
-
76
- it "should inherit the same namer instance" do
77
- new_sitemap.location.namer.should == original_sitemap.location.namer
78
- end
79
- end
80
-
81
- describe "reserve_name" do
82
- it "should reserve the name from the location" do
83
- sitemap.reserved_name?.should be_false
84
- sitemap.location.expects(:reserve_name).returns('name')
85
- sitemap.reserve_name
86
- sitemap.reserved_name?.should be_true
87
- sitemap.instance_variable_get(:@reserved_name).should == 'name'
88
- end
89
-
90
- it "should be safe to call multiple times" do
91
- sitemap.location.expects(:reserve_name).returns('name').once
92
- sitemap.reserve_name
93
- sitemap.reserve_name
94
- end
95
- end
96
-
97
- describe "add" do
98
- it "should use the host provided" do
99
- url = SitemapGenerator::Builder::SitemapUrl.new('/one', :host => 'http://newhost.com/')
100
- SitemapGenerator::Builder::SitemapUrl.expects(:new).with('/one', :host => 'http://newhost.com').returns(url)
101
- sitemap.add '/one', :host => 'http://newhost.com'
102
- end
103
-
104
- it "should use the host from the location" do
105
- url = SitemapGenerator::Builder::SitemapUrl.new('/one', :host => 'http://example.com/')
106
- SitemapGenerator::Builder::SitemapUrl.expects(:new).with('/one', :host => 'http://example.com/').returns(url)
107
- sitemap.add '/one'
108
- end
109
- end
110
- end