kjvarga / sitemap_generator

SitemapGenerator is a framework-agnostic XML Sitemap generator written in Ruby with automatic Rails integration. It supports Video, News, Image, Mobile, PageMap and Alternate Links sitemap extensions and includes Rake tasks for managing your sitemaps, as well as many other great features.
MIT License
2.45k stars 277 forks source link

SitemapGenerator.verbose = false does not seem to work #332

Open jrochkind opened 5 years ago

jrochkind commented 5 years ago

I have an automated test of my sitemap generation.

This causes the sitemap_generator output to annoyingly show up in the middle of my test output, when I run tests over that. Eg.

..................In '/Users/jrochkind/code/scihist_digicoll/public/':
+ __sitemaps/sitemap.xml.gz                               14 links /  569 Bytes
Sitemap stats: 14 links / 1 sitemaps / 0m00s
............

It looks like I should be able to disable this with SitemapGenerator.verbose = false. But this does not work, the output is still there.

Debugging... the verbose flag is somehow being set to <Object:0x00007fc92aa54470>, what? Trying to debug this, there's a lot of abstract indirection making it hard....

Aha, right here:

https://github.com/kjvarga/sitemap_generator/blob/92c612cf53eebd9827a204867c0f2b5618264263/lib/sitemap_generator/tasks.rb#L51

It's getting that verbose value from Rake itself. Indeed I am testing by running Rake::Task["sitemap:create"].invoke

So it appears when running the rake task, the rake setting for "verbose" takes priority, and SitemapGenerator.verbose is ignored. OK, that could be intended?

jrochkind commented 5 years ago

Okay, finding the right place to set that rake verbose flag to false programmatically is a bit tricky, it appears to be:

Rake::FileUtilsExt.verbose(false)