Sha256: fd61ed7f2eb1619878cc4b068617ebd1dbe083c0d5a5246362d59d93ba3df4c4

Contents?: true

Size: 1.04 KB

Versions: 10

Compression:

Stored size: 1.04 KB

Contents

module SitemapGenerator
  module Utilities
    extend self

    # Copy templates/sitemap.rb to config if not there yet.
    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

    # Remove config/sitemap.rb if exists.
    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

    # Clean sitemap files in output directory.
    def clean_files
      FileUtils.rm(Dir[File.join(RAILS_ROOT, 'public/sitemap*.xml.gz')])
    end

    # Returns a boolean indicating whether this environment is Rails 3
    #
    # @return [Boolean]
    def self.rails3?
      Rails.version.to_f >= 3
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
sitemap_generator-1.2.2 lib/sitemap_generator/utilities.rb
sitemap_generator-1.2.1 lib/sitemap_generator/utilities.rb
sitemap_generator-1.2.0 lib/sitemap_generator/utilities.rb
sitemap_generator-1.1.1 lib/sitemap_generator/utilities.rb
apsoto-sitemap_generator-1.1.0 lib/sitemap_generator/utilities.rb
apsoto-sitemap_generator-1.1.0.dev lib/sitemap_generator/utilities.rb
sitemap_generator-1.1.0 lib/sitemap_generator/utilities.rb
apsoto-sitemap_generator-1.0.1.dev lib/sitemap_generator/utilities.rb
sitemap_generator-1.0.1 lib/sitemap_generator/utilities.rb
sitemap_generator-1.0.0 lib/sitemap_generator/utilities.rb