sitemap_generator 2.0.1.pre2 → 2.0.1

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.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ./
3
3
  specs:
4
- sitemap_generator (2.0.1.pre1)
4
+ sitemap_generator (2.0.0)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
data/README.md CHANGED
@@ -26,8 +26,6 @@ Does your website use SitemapGenerator to generate Sitemaps? Where would you be
26
26
  Changelog
27
27
  -------
28
28
 
29
- - v2.0.1.pre2: Fix uploading to the (bucket) root on a remote server
30
- - v2.0.1.pre1: Support read-only filesystems like Heroku by supporting uploading to remote server
31
29
  - v2.0.1: Minor improvements to verbose handling; prevent missing Timeout issue
32
30
  - **v2.0.0: Introducing a new simpler API, Sitemap Groups, Sitemap Namers and more!**
33
31
  - v1.5.0: New options `include_root`, `include_index`; Major testing & refactoring
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.1.pre2
1
+ 2.0.1
@@ -4,15 +4,12 @@ require 'sitemap_generator/link_set'
4
4
  require 'sitemap_generator/templates'
5
5
  require 'sitemap_generator/utilities'
6
6
  require 'sitemap_generator/application'
7
- require 'sitemap_generator/adapters'
8
7
  require 'sitemap_generator/sitemap_location'
9
8
  require 'active_support/core_ext/numeric'
10
9
 
11
10
  module SitemapGenerator
12
11
  autoload(:Interpreter, 'sitemap_generator/interpreter')
13
- autoload(:FileAdapter, 'sitemap_generator/adapters/file_adapter')
14
- autoload(:WaveAdapter, 'sitemap_generator/adapters/wave_adapter')
15
-
12
+
16
13
  SitemapError = Class.new(StandardError)
17
14
  SitemapFullError = Class.new(SitemapError)
18
15
  SitemapFinalizedError = Class.new(SitemapError)
@@ -93,7 +93,22 @@ module SitemapGenerator
93
93
  def finalize!
94
94
  raise SitemapGenerator::SitemapFinalizedError if finalized?
95
95
 
96
- @location.write(@xml_wrapper_start + @xml_content + @xml_wrapper_end)
96
+ # Ensure that the directory exists
97
+ dir = @location.directory
98
+ if !File.exists?(dir)
99
+ FileUtils.mkdir_p(dir)
100
+ elsif !File.directory?(dir)
101
+ raise SitemapError.new("#{dir} should be a directory!")
102
+ end
103
+
104
+ # Write out the file
105
+ open(@location.path, 'wb') do |file|
106
+ gz = Zlib::GzipWriter.new(file)
107
+ gz.write @xml_wrapper_start
108
+ gz.write @xml_content
109
+ gz.write @xml_wrapper_end
110
+ gz.close
111
+ end
97
112
 
98
113
  # Increment the namer (SitemapFile only)
99
114
  @location.namer.next if @location.namer
@@ -8,7 +8,7 @@ module SitemapGenerator
8
8
  @@new_location_opts = [:filename, :sitemaps_path, :sitemaps_namer]
9
9
 
10
10
  attr_reader :default_host, :sitemaps_path, :filename
11
- attr_accessor :verbose, :yahoo_app_id, :include_root, :include_index, :sitemaps_host, :adapter
11
+ attr_accessor :verbose, :yahoo_app_id, :include_root, :include_index, :sitemaps_host
12
12
 
13
13
  # Add links to the link set by evaluating the block. The block should
14
14
  # contains calls to sitemap methods like:
@@ -47,9 +47,6 @@ module SitemapGenerator
47
47
  # Constructor
48
48
  #
49
49
  # == Options:
50
- # * <tt>:adapter</tt> - subclass of SitemapGenerator::Adapter used for persisting the
51
- # sitemaps. Default adapter is a SitemapGenerator::FileAdapter
52
- #
53
50
  # * <tt>:default_host</tt> - host including protocol to use in all sitemap links
54
51
  # e.g. http://en.google.ca
55
52
  #
@@ -397,8 +394,7 @@ module SitemapGenerator
397
394
  :host => sitemaps_host,
398
395
  :namer => sitemaps_namer,
399
396
  :public_path => public_path,
400
- :sitemaps_path => @sitemaps_path,
401
- :adapter => @adapter
397
+ :sitemaps_path => @sitemaps_path
402
398
  )
403
399
  end
404
400
 
@@ -408,8 +404,7 @@ module SitemapGenerator
408
404
  :host => sitemaps_host,
409
405
  :namer => sitemap_index_namer,
410
406
  :public_path => public_path,
411
- :sitemaps_path => @sitemaps_path,
412
- :adapter => @adapter
407
+ :sitemaps_path => @sitemaps_path
413
408
  )
414
409
  end
415
410
 
@@ -1,7 +1,7 @@
1
1
  module SitemapGenerator
2
2
  class SitemapLocation < Hash
3
3
 
4
- [:host, :adapter].each do |method|
4
+ [:host].each do |method|
5
5
  define_method(method) do
6
6
  raise SitemapGenerator::SitemapError, "No value set for #{method}" unless self[method]
7
7
  self[method]
@@ -18,20 +18,18 @@ module SitemapGenerator
18
18
  # files this generates names like <tt>sitemap1.xml.gz</tt>, <tt>sitemap2.xml.gz</tt> and so on,
19
19
  #
20
20
  # === Options
21
- # * <tt>adapter</tt> - SitemapGenerator::Adapter subclass
22
- # * <tt>filename</tt> - full name of the file e.g. <tt>'sitemap1.xml.gz'<tt>
23
- # * <tt>host</tt> - host name for URLs. The full URL to the file is then constructed from
24
- # the <tt>host</tt>, <tt>sitemaps_path</tt> and <tt>filename</tt>
25
- # * <tt>namer</tt> - a SitemapGenerator::SitemapNamer instance. Can be passed instead of +filename+.
26
21
  # * <tt>public_path</tt> - path to the "public" directory, or the directory you want to
27
22
  # write sitemaps in. Default is a directory <tt>public/</tt>
28
23
  # in the current working directory, or relative to the Rails root
29
24
  # directory if running under Rails.
30
25
  # * <tt>sitemaps_path</tt> - gives the path relative to the <tt>public_path</tt> in which to
31
26
  # write sitemaps e.g. <tt>sitemaps/</tt>.
27
+ # * <tt>host</tt> - host name for URLs. The full URL to the file is then constructed from
28
+ # the <tt>host</tt>, <tt>sitemaps_path</tt> and <tt>filename</tt>
29
+ # * <tt>filename</tt> - full name of the file e.g. <tt>'sitemap1.xml.gz'<tt>
30
+ # * <tt>namer</tt> - a SitemapGenerator::SitemapNamer instance. Can be passed instead of +filename+.
32
31
  def initialize(opts={})
33
- SitemapGenerator::Utilities.assert_valid_keys(opts, [:adapter, :public_path, :sitemaps_path, :host, :filename, :namer])
34
- opts[:adapter] ||= SitemapGenerator::FileAdapter.new
32
+ SitemapGenerator::Utilities.assert_valid_keys(opts, [:public_path, :sitemaps_path, :host, :filename, :namer])
35
33
  opts[:public_path] ||= SitemapGenerator.app.root + 'public/'
36
34
  opts[:namer] = SitemapGenerator::SitemapNamer.new(:sitemap) if !opts[:filename] && !opts[:namer]
37
35
  self.merge!(opts)
@@ -94,10 +92,6 @@ module SitemapGenerator
94
92
  end
95
93
  super(key, value)
96
94
  end
97
-
98
- def write(data)
99
- adapter.write(self, data)
100
- end
101
95
  end
102
96
 
103
97
  class SitemapIndexLocation < SitemapLocation
metadata CHANGED
@@ -1,15 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sitemap_generator
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1923832037
5
- prerelease: 6
4
+ hash: 13
5
+ prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 0
9
9
  - 1
10
- - pre
11
- - 2
12
- version: 2.0.1.pre2
10
+ version: 2.0.1
13
11
  platform: ruby
14
12
  authors:
15
13
  - Karl Varga
@@ -18,7 +16,7 @@ autorequire:
18
16
  bindir: bin
19
17
  cert_chain: []
20
18
 
21
- date: 2011-08-03 00:00:00 -07:00
19
+ date: 2011-06-01 00:00:00 -07:00
22
20
  default_executable:
23
21
  dependencies:
24
22
  - !ruby/object:Gem::Dependency
@@ -121,9 +119,6 @@ files:
121
119
  - Rakefile
122
120
  - VERSION
123
121
  - lib/sitemap_generator.rb
124
- - lib/sitemap_generator/adapters.rb
125
- - lib/sitemap_generator/adapters/file_adapter.rb
126
- - lib/sitemap_generator/adapters/wave_adapter.rb
127
122
  - lib/sitemap_generator/application.rb
128
123
  - lib/sitemap_generator/builder.rb
129
124
  - lib/sitemap_generator/builder/sitemap_file.rb
@@ -163,14 +158,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
163
158
  required_rubygems_version: !ruby/object:Gem::Requirement
164
159
  none: false
165
160
  requirements:
166
- - - ">"
161
+ - - ">="
167
162
  - !ruby/object:Gem::Version
168
- hash: 25
163
+ hash: 3
169
164
  segments:
170
- - 1
171
- - 3
172
- - 1
173
- version: 1.3.1
165
+ - 0
166
+ version: "0"
174
167
  requirements: []
175
168
 
176
169
  rubyforge_project:
File without changes
@@ -1,21 +0,0 @@
1
- module SitemapGenerator
2
- class FileAdapter
3
- def write(location, raw_data)
4
- # Ensure that the directory exists
5
- dir = location.directory
6
- if !File.exists?(dir)
7
- FileUtils.mkdir_p(dir)
8
- elsif !File.directory?(dir)
9
- raise SitemapError.new("#{dir} should be a directory!")
10
- end
11
-
12
- gzip(open(location.path, 'wb'), raw_data)
13
- end
14
-
15
- def gzip(stream, data)
16
- gz = Zlib::GzipWriter.new(stream)
17
- gz.write data
18
- gz.close
19
- end
20
- end
21
- end
@@ -1,17 +0,0 @@
1
- require 'carrierwave'
2
-
3
- module SitemapGenerator
4
- class WaveAdapter < ::CarrierWave::Uploader::Base
5
- attr_accessor :store_dir
6
-
7
- # Call with a SitemapLocation and string data
8
- def write(location, raw_data)
9
- SitemapGenerator::FileAdapter.new.write(location, raw_data)
10
- directory = File.dirname(location.path_in_public)
11
- if directory != '.'
12
- self.store_dir = directory
13
- end
14
- store!(open(location.path, 'rb'))
15
- end
16
- end
17
- end