Module: Middleman::Ontologist

Defined in:
lib/ontologist/version.rb,
lib/ontologist/ontology.rb,
lib/ontologist/extension.rb,
lib/ontologist/semantic_resource.rb

Defined Under Namespace

Modules: Helpers, SemanticResource, Utilities Classes: Ontology, Options

Constant Summary collapse

VERSION =
"0.0.1"

Class Method Summary collapse

Class Method Details

.registered(app, options_hash = {}) {|options| ... } ⇒ Object

Yields:

  • (options)


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/ontologist/extension.rb', line 34

def registered(app, options_hash = {}, &block)
  require 'ontologist/ontology'
  require 'ontologist/semantic_resource'
  require 'active_support/core_ext/time/zones'

  app.set :time_zone, 'UTC'
  app.send :include, Helpers

  options = Options.new(options_hash)
  yield options if block_given?

  options.uri_tag                 ||= "uri"
  options.date_tag                ||= "date"
  options.title_tag               ||= "title"
  options.ignore_list             ||= []
  options.aliases                 ||= {}
  options.namespaces              ||= {}
  options.default_namespace       ||= "http://example.org/ns/1.0/"
  options.resource_extension_list ||= ['.html']
  options.publish_future_dated    ||= false
  options.time_zone               ||= "UTC"
  options.strict                  ||= true

  app.after_configuration do
    
    # Make sure timezone is set
    zone_default = Time.find_zone!(options.time_zone)
    unless zone_default
      raise 'Value assigned to time_zone not recognized.'
    end
    Time.zone_default = zone_default

    # initialize the ontology object
    ontology(options)

    sitemap.register_resource_list_manipulator(:ontology, ontology, false)

  end

end