Module: SimpleSitemap

Defined in:
lib/simple_sitemap.rb,
lib/simple_sitemap/version.rb,
lib/simple_sitemap/generators/base.rb,
lib/simple_sitemap/generators/index.rb,
lib/simple_sitemap/generators/sitemap.rb,
lib/simple_sitemap/writers/gzip_writer.rb,
lib/simple_sitemap/writers/plain_writer.rb

Defined Under Namespace

Modules: Generators, Writers

Constant Summary collapse

50000
MAX_FILE_SIZE =

10 megabytes

10*1024*1024
VERSION =
'0.1.4'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configObject

Returns the value of attribute config.



18
19
20
# File 'lib/simple_sitemap.rb', line 18

def config
  @config
end

.hooksObject

Returns the value of attribute hooks.



18
19
20
# File 'lib/simple_sitemap.rb', line 18

def hooks
  @hooks
end

Class Method Details

.after_write(&block) ⇒ Object



36
37
38
39
# File 'lib/simple_sitemap.rb', line 36

def after_write(&block)
  @hooks ||= {}
  @hooks[:after_write] = block
end

.build(opts = {}, &block) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/simple_sitemap.rb', line 27

def build(opts={}, &block)
  config = OpenStruct.new(@config.marshal_dump.merge opts)
  start_time = Time.now
  generator = Generators::Sitemap.new config, @hooks
  generator.instance_eval &block
  generator.write!
  puts "Time taken: #{Time.now - start_time}" if config.verbose
end

.configure {|@config| ... } ⇒ Object

Yields:



20
21
22
23
24
25
# File 'lib/simple_sitemap.rb', line 20

def configure(&block)
  @config = OpenStruct.new
  @config.gzip = true
  @config.verbose = false
  yield @config
end