Module: SitemapGenerator::Utilities

Extended by:
Utilities
Included in:
Utilities
Defined in:
lib/sitemap_generator/utilities.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.rails3?Boolean

Returns a boolean indicating whether this environment is Rails 3

Returns:

  • (Boolean)


32
33
34
# File 'lib/sitemap_generator/utilities.rb', line 32

def self.rails3?
  Rails.version.to_f >= 3
end

Instance Method Details

#clean_filesObject

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_rbObject

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