xml-sitemap 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,18 @@
1
+ Copyright (c) 2010-2013 Dan Sosedoff <dan.sosedoff@gmail.com>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
+ the Software, and to permit persons to whom the Software is furnished to do so,
8
+ subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -126,6 +126,9 @@ map.add 'page'
126
126
 
127
127
  index = XmlSitemap::Index.new
128
128
 
129
+ # or if you want the URLs to use HTTPS
130
+ index = XmlSitemap::Index.new(:secure => true)
131
+
129
132
  # or via shortcut
130
133
  index = XmlSitemap.index
131
134
 
@@ -139,12 +142,39 @@ index.render
139
142
  index.render_to('/path/to/file.xml')
140
143
  ```
141
144
 
145
+ ## Testing
146
+
147
+ To execute test suite run:
148
+
149
+ ```
150
+ bundle exec rake test
151
+ ```
152
+
153
+ ## Contributing
154
+
155
+ 1. Fork it
156
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
157
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
158
+ 4. Push to the branch (`git push origin my-new-feature`)
159
+ 5. Create new Pull Request
160
+
142
161
  ## License
143
162
 
144
- Copyright &copy; 2010-2013 Dan Sosedoff.
163
+ Copyright (c) 2010-2013 Dan Sosedoff.
145
164
 
146
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
165
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
166
+ this software and associated documentation files (the "Software"), to deal in
167
+ the Software without restriction, including without limitation the rights to
168
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
169
+ the Software, and to permit persons to whom the Software is furnished to do so,
170
+ subject to the following conditions:
147
171
 
148
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
172
+ The above copyright notice and this permission notice shall be included in all
173
+ copies or substantial portions of the Software.
149
174
 
150
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
175
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
176
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
177
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
178
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
179
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
180
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -4,9 +4,14 @@ module XmlSitemap
4
4
 
5
5
  # Initialize a new Index instance
6
6
  #
7
+ # opts - Index options
8
+ #
9
+ # opts[:secure] - Force HTTPS for all items. (default: false)
10
+ #
7
11
  def initialize(opts={})
8
12
  @maps = []
9
13
  @offsets = Hash.new(0)
14
+ @secure = opts[:secure] || false
10
15
 
11
16
  yield self if block_given?
12
17
  end
@@ -20,7 +25,7 @@ module XmlSitemap
20
25
  raise ArgumentError, 'Map is empty!' if map.empty?
21
26
 
22
27
  @maps << {
23
- :loc => map.index_url(@offsets[map.group]),
28
+ :loc => map.index_url(@offsets[map.group], @secure),
24
29
  :lastmod => map.created_at.utc.iso8601
25
30
  }
26
31
  @offsets[map.group] += 1
@@ -83,8 +83,8 @@ module XmlSitemap
83
83
 
84
84
  # Get full url for index
85
85
  #
86
- def index_url(offset)
87
- "http://#{@domain}/#{@group}-#{offset}.xml"
86
+ def index_url(offset, secure)
87
+ "#{secure ? 'https' : 'http'}://#{@domain}/#{@group}-#{offset}.xml"
88
88
  end
89
89
 
90
90
  # Render XML
@@ -1,6 +1,6 @@
1
1
  module XmlSitemap
2
2
  unless defined?(::XmlSitemap::VERSION)
3
- VERSION = '1.3.0'
3
+ VERSION = '1.3.1'
4
4
  end
5
5
 
6
6
  def self.version
@@ -0,0 +1,11 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <sitemapindex xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
3
+ <sitemap>
4
+ <loc>https://foobar.com/sitemap-0.xml</loc>
5
+ <lastmod>2011-06-01T00:00:01Z</lastmod>
6
+ </sitemap>
7
+ <sitemap>
8
+ <loc>https://foobar.com/sitemap-1.xml</loc>
9
+ <lastmod>2011-06-01T00:00:01Z</lastmod>
10
+ </sitemap>
11
+ </sitemapindex>
@@ -33,6 +33,18 @@ describe XmlSitemap::Index do
33
33
 
34
34
  index.render.split("\n")[2..-1].join("\n").should == fixture('sample_index.xml').split("\n")[2..-1].join("\n")
35
35
  end
36
+
37
+ it 'renders a proper index with the secure option' do
38
+ m1 = XmlSitemap::Map.new('foobar.com', :time => base_time) { |m| m.add('about') }
39
+ m2 = XmlSitemap::Map.new('foobar.com', :time => base_time) { |m| m.add('about') }
40
+
41
+ index = XmlSitemap::Index.new(:secure => true) do |i|
42
+ i.add(m1)
43
+ i.add(m2)
44
+ end
45
+
46
+ index.render.split("\n")[2..-1].join("\n").should == fixture('sample_index_secure.xml').split("\n")[2..-1].join("\n")
47
+ end
36
48
  end
37
49
 
38
50
  describe '#render_to' do
@@ -9,12 +9,12 @@ 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'
14
- s.add_development_dependency 'simplecov', '~> 0.4'
12
+ s.add_development_dependency 'rake', '~> 10.0'
13
+ s.add_development_dependency 'rspec', '~> 2.13'
14
+ s.add_development_dependency 'simplecov', '~> 0.7'
15
15
  s.add_development_dependency 'nokogiri', '~> 1.5'
16
16
 
17
- s.add_runtime_dependency 'builder', '>= 2.0'
17
+ s.add_runtime_dependency 'builder', '>= 2.0'
18
18
 
19
19
  s.files = `git ls-files`.split("\n")
20
20
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
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.3.0
4
+ version: 1.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-21 00:00:00.000000000 Z
12
+ date: 2013-05-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: '0.8'
21
+ version: '10.0'
22
22
  type: :development
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- version: '0.8'
29
+ version: '10.0'
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: rspec
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -34,7 +34,7 @@ dependencies:
34
34
  requirements:
35
35
  - - ~>
36
36
  - !ruby/object:Gem::Version
37
- version: '2.6'
37
+ version: '2.13'
38
38
  type: :development
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirements:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
- version: '2.6'
45
+ version: '2.13'
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: simplecov
48
48
  requirement: !ruby/object:Gem::Requirement
@@ -50,7 +50,7 @@ dependencies:
50
50
  requirements:
51
51
  - - ~>
52
52
  - !ruby/object:Gem::Version
53
- version: '0.4'
53
+ version: '0.7'
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
@@ -58,7 +58,7 @@ dependencies:
58
58
  requirements:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: '0.4'
61
+ version: '0.7'
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: nokogiri
64
64
  requirement: !ruby/object:Gem::Requirement
@@ -102,6 +102,7 @@ files:
102
102
  - .rspec
103
103
  - .travis.yml
104
104
  - Gemfile
105
+ - LICENSE
105
106
  - README.md
106
107
  - Rakefile
107
108
  - lib/xml-sitemap.rb
@@ -116,6 +117,7 @@ files:
116
117
  - spec/fixtures/encoded_map.xml
117
118
  - spec/fixtures/group_index.xml
118
119
  - spec/fixtures/sample_index.xml
120
+ - spec/fixtures/sample_index_secure.xml
119
121
  - spec/fixtures/saved_map.xml
120
122
  - spec/fixtures/simple_map.xml
121
123
  - spec/index_spec.rb
@@ -136,21 +138,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
136
138
  - - ! '>='
137
139
  - !ruby/object:Gem::Version
138
140
  version: '0'
139
- segments:
140
- - 0
141
- hash: -987931989253574637
142
141
  required_rubygems_version: !ruby/object:Gem::Requirement
143
142
  none: false
144
143
  requirements:
145
144
  - - ! '>='
146
145
  - !ruby/object:Gem::Version
147
146
  version: '0'
148
- segments:
149
- - 0
150
- hash: -987931989253574637
151
147
  requirements: []
152
148
  rubyforge_project:
153
- rubygems_version: 1.8.25
149
+ rubygems_version: 1.8.24
154
150
  signing_key:
155
151
  specification_version: 3
156
152
  summary: Simple XML sitemap generator for Ruby/Rails applications.
@@ -160,6 +156,7 @@ test_files:
160
156
  - spec/fixtures/encoded_map.xml
161
157
  - spec/fixtures/group_index.xml
162
158
  - spec/fixtures/sample_index.xml
159
+ - spec/fixtures/sample_index_secure.xml
163
160
  - spec/fixtures/saved_map.xml
164
161
  - spec/fixtures/simple_map.xml
165
162
  - spec/index_spec.rb
@@ -167,3 +164,4 @@ test_files:
167
164
  - spec/map_spec.rb
168
165
  - spec/spec_helper.rb
169
166
  - spec/xmlsitemap_spec.rb
167
+ has_rdoc: