Class: Aardi::Sitemap
- Inherits:
-
Object
- Object
- Aardi::Sitemap
- Defined in:
- lib/aardi/sitemap.rb
Instance Method Summary collapse
-
#content ⇒ Object
:reek:NestedIterators.
- #render ⇒ Object
- #target_path ⇒ Object
- #update_mtime(path, path_mtime) ⇒ Object
-
#url_details(path, details, urlset) ⇒ Object
Methods called inside builder blocks must be public.
- #urls ⇒ Object
Instance Method Details
#content ⇒ Object
:reek:NestedIterators
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/aardi/sitemap.rb', line 6 def content sitemap = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do urlset(xmlns: 'http://www.sitemaps.org/schemas/sitemap/0.9') do |urlset| urls.each do |path, details| url_details(path, details, urlset) end end end sitemap.to_xml end |
#render ⇒ Object
18 19 20 21 |
# File 'lib/aardi/sitemap.rb', line 18 def render source = Content.new(content) FileTarget.new(source, target_path).write end |
#target_path ⇒ Object
23 |
# File 'lib/aardi/sitemap.rb', line 23 def target_path = './sitemap.xml' |
#update_mtime(path, path_mtime) ⇒ Object
25 26 27 |
# File 'lib/aardi/sitemap.rb', line 25 def update_mtime(path, path_mtime) urls[path][:lastmod] = path_mtime.iso8601 end |
#url_details(path, details, urlset) ⇒ Object
Methods called inside builder blocks must be public. :reek:FeatureEnvy
31 32 33 34 35 36 37 38 39 |
# File 'lib/aardi/sitemap.rb', line 31 def url_details(path, details, urlset) missing_path(path) unless File.exist?("./#{path}") urlset.url do details.slice(:loc, :lastmod, :changefreq).each do |node, value| urlset.public_send node, value end end end |