kjvarga/sitemap_generator — Issue #58: Pass information to block
Author: arufanov
Created: 2011-12-19 07:14:06+00:00
State: open

Dear gem owner!

Thank you for nice gem. I am using it at few projects and happy but had a problem with one project. I should pass custom information into block to generate sitemap. My application contains a few independent website and should create an independent sitemap for each website. Here is little code that illustrates how I do it:
Website.find(:all).each do |website|
@website_id = website.id
@website = website

puts 'test1 - @website_id ' + @website_id.inspect + " context: " + self.inspect
SitemapGenerator::Sitemap.default_host = @website.domain
SitemapGenerator::Sitemap.public_path = "tmp/"
SitemapGenerator::Sitemap.sitemaps_path = "sitemaps/#{@website.code}"
SitemapGenerator::Sitemap.adapter = SitemapGenerator::WaveAdapter.new
SitemapGenerator::Sitemap.create do
puts 'test2 - @website_id ' + @website_id.inspect + " context: " + self.inspect
add "/home"
add "/welcome"
end
end

and here is output:
test1 - @website_id 1 context: #22, :website_id=>3}, website_id=nil>
test2 - @website_id nil context: #, @sitemaps_path="sitemaps/wellness", @adapter=, @sitemaps_namer=sitemap1.xml.gz, @added_default_links=false, @interpreter=#, @sitemap=nil, @sitemap_index_namer=sitemap_index.xml.gz, @sitemap_index=nil>>
that illustrate that context and different. I used code like this:

SitemapGenerator::Sitemap.create :yield_sitemap => true do |interpreter|
interpreter.add “/home”
interpreter.add “/welcome”
end
but has result: undefined method `yield_sitemap=' for #
Can I pass some information to block? I think this would be useful for some tasks and would be great to have example at documentation that illustrates how to result this task.

This is questions or request for documentation rather than bug, but I wasn't able to find this category at github bug tracking system.

Sincerely yours,
Artem Rufanov.