xml-sitemap 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ - ree
data/lib/xml-sitemap.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'time'
2
+ require 'date'
2
3
  require 'builder'
3
4
 
4
5
  require 'xml-sitemap/options'
@@ -4,9 +4,17 @@ module XmlSitemap
4
4
 
5
5
  def initialize(target, opts={})
6
6
  @target = target.to_s.strip
7
- @updated = opts[:updated] || Time.now.utc
7
+ @updated = opts[:updated] || Time.now
8
8
  @priority = opts[:priority] || 0.5
9
9
  @changefreq = opts[:period] || :weekly
10
+
11
+ # allow only date or time object
12
+ unless @updated.kind_of?(Time) || @updated.kind_of?(Date)
13
+ raise ArgumentError, "Time or Date required for :updated!"
14
+ end
15
+
16
+ # use full time and date only!
17
+ @updated = @updated.to_time if @updated.kind_of?(Date)
10
18
  end
11
19
  end
12
20
 
@@ -1,3 +1,3 @@
1
1
  module XmlSitemap
2
- VERSION = '1.1.1'
2
+ VERSION = '1.1.2'
3
3
  end
@@ -2,13 +2,13 @@
2
2
  <urlset xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
3
3
  <url>
4
4
  <loc>http://foobar.com/</loc>
5
- <lastmod>2011-06-01T05:00:01Z</lastmod>
5
+ <lastmod>2011-06-01T00:00:01Z</lastmod>
6
6
  <changefreq>weekly</changefreq>
7
7
  <priority>1.0</priority>
8
8
  </url>
9
9
  <url>
10
10
  <loc>http://foobar.com/path?a=b&amp;c=d&amp;e=sample string</loc>
11
- <lastmod>2011-06-01T05:00:01Z</lastmod>
11
+ <lastmod>2011-06-01T00:00:01Z</lastmod>
12
12
  <changefreq>weekly</changefreq>
13
13
  <priority>0.5</priority>
14
14
  </url>
@@ -2,10 +2,10 @@
2
2
  <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
3
3
  <sitemap>
4
4
  <loc>http://foobar.com/sitemap-0.xml</loc>
5
- <lastmod>2011-06-01T05:00:01Z</lastmod>
5
+ <lastmod>2011-06-01T00:00:01Z</lastmod>
6
6
  </sitemap>
7
7
  <sitemap>
8
8
  <loc>http://foobar.com/sitemap-1.xml</loc>
9
- <lastmod>2011-06-01T05:00:01Z</lastmod>
9
+ <lastmod>2011-06-01T00:00:01Z</lastmod>
10
10
  </sitemap>
11
11
  </urlset>
@@ -2,25 +2,25 @@
2
2
  <urlset xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
3
3
  <url>
4
4
  <loc>http://foobar.com/</loc>
5
- <lastmod>2011-06-01T05:00:01Z</lastmod>
5
+ <lastmod>2011-06-01T00:00:01Z</lastmod>
6
6
  <changefreq>weekly</changefreq>
7
7
  <priority>1.0</priority>
8
8
  </url>
9
9
  <url>
10
10
  <loc>http://foobar.com/about</loc>
11
- <lastmod>2011-06-01T05:00:01Z</lastmod>
11
+ <lastmod>2011-06-01T00:00:01Z</lastmod>
12
12
  <changefreq>weekly</changefreq>
13
13
  <priority>0.5</priority>
14
14
  </url>
15
15
  <url>
16
16
  <loc>http://foobar.com/terms</loc>
17
- <lastmod>2011-06-01T05:00:01Z</lastmod>
17
+ <lastmod>2011-06-01T00:00:01Z</lastmod>
18
18
  <changefreq>weekly</changefreq>
19
19
  <priority>0.5</priority>
20
20
  </url>
21
21
  <url>
22
22
  <loc>http://foobar.com/privacy</loc>
23
- <lastmod>2011-06-01T05:00:01Z</lastmod>
23
+ <lastmod>2011-06-01T00:00:01Z</lastmod>
24
24
  <changefreq>weekly</changefreq>
25
25
  <priority>0.5</priority>
26
26
  </url>
data/spec/index_spec.rb CHANGED
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe XmlSitemap::Index do
4
4
  before :all do
5
- @base_time = Time.mktime(2011, 6, 1, 0, 0, 1)
5
+ @base_time = Time.gm(2011, 6, 1, 0, 0, 1)
6
6
  end
7
7
 
8
8
  it 'should be valid if no sitemaps were supplied' do
data/spec/map_spec.rb CHANGED
@@ -2,8 +2,8 @@ require 'spec_helper'
2
2
 
3
3
  describe XmlSitemap::Map do
4
4
  before :all do
5
- @base_time = Time.mktime(2011, 6, 1, 0, 0, 1).utc
6
- @extra_time = Time.mktime(2011, 7, 1, 0, 0, 1).utc
5
+ @base_time = Time.gm(2011, 6, 1, 0, 0, 1)
6
+ @extra_time = Time.gm(2011, 7, 1, 0, 0, 1)
7
7
  end
8
8
 
9
9
  it 'should not allow empty domains' do
@@ -49,7 +49,13 @@ describe XmlSitemap::Map do
49
49
  it 'should properly set entry time' do
50
50
  map = XmlSitemap::Map.new('foobar.com', :time => @base_time)
51
51
  map.add('hello').updated.should == @base_time
52
- map.add('world', :updated => @extra_time).updated.should == Time.mktime(2011, 7, 1, 0, 0, 1)
52
+ map.add('world', :updated => @extra_time).updated.should == Time.gm(2011, 7, 1, 0, 0, 1)
53
+ end
54
+
55
+ it 'should raise Argument error if no time or date were provided' do
56
+ map = XmlSitemap::Map.new('foobar.com', :time => @base_time)
57
+ proc { map.add('hello', :updated => 'invalid data') }.
58
+ should raise_error ArgumentError, "Time or Date required for :updated!"
53
59
  end
54
60
 
55
61
  it 'should have properly encoded entities' do
data/xml-sitemap.gemspec CHANGED
@@ -9,17 +9,14 @@ Gem::Specification.new do |s|
9
9
  s.authors = ["Dan Sosedoff"]
10
10
  s.email = ["dan.sosedoff@gmail.com"]
11
11
 
12
- s.add_development_dependency 'rake', '~> 0.8'
13
- s.add_development_dependency 'rspec', '~> 2.6'
12
+ s.add_development_dependency 'rake', '~> 0.8'
13
+ s.add_development_dependency 'rspec', '~> 2.6'
14
14
  s.add_development_dependency 'simplecov', '~> 0.4'
15
15
 
16
- s.add_runtime_dependency 'builder', '~> 2.1'
16
+ s.add_runtime_dependency 'builder', '>= 2.0'
17
17
 
18
- s.files = `git ls-files`.split("\n")
19
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
- s.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f)}
18
+ s.files = `git ls-files`.split("\n")
19
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
+ s.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f)}
21
21
  s.require_paths = ["lib"]
22
-
23
- s.platform = Gem::Platform::RUBY
24
- s.required_rubygems_version = Gem::Requirement.new('>= 1.3.6') if s.respond_to? :required_rubygems_version=
25
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xml-sitemap
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-08-18 00:00:00.000000000Z
12
+ date: 2011-08-25 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &71108270 !ruby/object:Gem::Requirement
16
+ requirement: &2165753020 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0.8'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *71108270
24
+ version_requirements: *2165753020
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &71107960 !ruby/object:Gem::Requirement
27
+ requirement: &2165752460 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '2.6'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *71107960
35
+ version_requirements: *2165752460
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: simplecov
38
- requirement: &71107640 !ruby/object:Gem::Requirement
38
+ requirement: &2165751940 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,18 +43,18 @@ dependencies:
43
43
  version: '0.4'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *71107640
46
+ version_requirements: *2165751940
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: builder
49
- requirement: &71107400 !ruby/object:Gem::Requirement
49
+ requirement: &2165751460 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
- - - ~>
52
+ - - ! '>='
53
53
  - !ruby/object:Gem::Version
54
- version: '2.1'
54
+ version: '2.0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *71107400
57
+ version_requirements: *2165751460
58
58
  description: Provides a wrapper to generate XML sitemaps and sitemap indexes.
59
59
  email:
60
60
  - dan.sosedoff@gmail.com
@@ -64,6 +64,7 @@ extra_rdoc_files: []
64
64
  files:
65
65
  - .gitignore
66
66
  - .rspec
67
+ - .travis.yml
67
68
  - Gemfile
68
69
  - README.md
69
70
  - Rakefile
@@ -98,11 +99,19 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
99
  requirements:
99
100
  - - ! '>='
100
101
  - !ruby/object:Gem::Version
101
- version: 1.3.6
102
+ version: '0'
102
103
  requirements: []
103
104
  rubyforge_project:
104
- rubygems_version: 1.8.5
105
+ rubygems_version: 1.8.6
105
106
  signing_key:
106
107
  specification_version: 3
107
108
  summary: Simple XML sitemap generator for Ruby/Rails applications.
108
- test_files: []
109
+ test_files:
110
+ - spec/fixtures/empty_index.xml
111
+ - spec/fixtures/encoded_map.xml
112
+ - spec/fixtures/sample_index.xml
113
+ - spec/fixtures/saved_map.xml
114
+ - spec/fixtures/simple_map.xml
115
+ - spec/index_spec.rb
116
+ - spec/map_spec.rb
117
+ - spec/spec_helper.rb