Module: SitemapGenerator::Utilities
Class Method Summary collapse
-
.rails3? ⇒ Boolean
Returns whether this environment is using ActionPack version 3.0.0 or greater.
Instance Method Summary collapse
-
#clean_files ⇒ Object
Clean sitemap files in output directory.
-
#install_sitemap_rb(verbose = false) ⇒ Object
Copy templates/sitemap.rb to config if not there yet.
-
#uninstall_sitemap_rb ⇒ Object
Remove config/sitemap.rb if exists.
Class Method Details
.rails3? ⇒ Boolean
Returns whether this environment is using ActionPack version 3.0.0 or greater.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/sitemap_generator/utilities.rb', line 33 def self.rails3? # The ActionPack module is always loaded automatically in Rails >= 3 return false unless defined?(ActionPack) && defined?(ActionPack::VERSION) version = if defined?(ActionPack::VERSION::MAJOR) ActionPack::VERSION::MAJOR else # Rails 1.2 ActionPack::VERSION::Major end # 3.0.0.beta1 acts more like ActionPack 2 # for purposes of this method # (checking whether block helpers require = or -). # This extra check can be removed when beta2 is out. version >= 3 && !(defined?(ActionPack::VERSION::TINY) && ActionPack::VERSION::TINY == "0.beta") end |
Instance Method Details
#clean_files ⇒ Object
Clean sitemap files in output directory.
25 26 27 |
# File 'lib/sitemap_generator/utilities.rb', line 25 def clean_files FileUtils.rm(Dir[File.join(RAILS_ROOT, 'public/sitemap*.xml.gz')]) end |
#install_sitemap_rb(verbose = false) ⇒ Object
Copy templates/sitemap.rb to config if not there yet.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/sitemap_generator/utilities.rb', line 6 def install_sitemap_rb(verbose=false) if File.exist?(File.join(RAILS_ROOT, 'config/sitemap.rb')) puts "already exists: config/sitemap.rb, file not copied" if verbose else FileUtils.cp( SitemapGenerator.templates.template_path(:sitemap_sample), File.join(RAILS_ROOT, 'config/sitemap.rb')) puts "created: config/sitemap.rb" if verbose end end |
#uninstall_sitemap_rb ⇒ Object
Remove config/sitemap.rb if exists.
18 19 20 21 22 |
# File 'lib/sitemap_generator/utilities.rb', line 18 def uninstall_sitemap_rb if File.exist?(File.join(RAILS_ROOT, 'config/sitemap.rb')) File.rm(File.join(RAILS_ROOT, 'config/sitemap.rb')) end end |