Module: RoadForest::ContentHandling

Defined in:
lib/roadforest/content-handling/engine.rb,
lib/roadforest/content-handling/media-type.rb,
lib/roadforest/content-handling/handler-wrap.rb,
lib/roadforest/content-handling/common-engines.rb

Defined Under Namespace

Modules: Wrap Classes: Engine, MediaType, MediaTypeList, UnrecognizedType

Class Method Summary collapse

Class Method Details

.graphics_engineObject



52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/roadforest/content-handling/common-engines.rb', line 52

def graphics_engine
  @graphics_engine ||=
    begin
      require 'roadforest/type-handlers/handler'
      data = RoadForest::TypeHandlers::Handler.new

      RoadForest::ContentHandling::Engine.new.tap do |engine|
        engine.add data, "image/png"
        engine.add data, "image/gif;q=0.9"
        engine.add data, "image/jpeg;q=0.7"
      end
    end
end

.images_engineObject



37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/roadforest/content-handling/common-engines.rb', line 37

def images_engine
  @image_engine ||=
    begin
      require 'roadforest/type-handlers/handler'
      data = RoadForest::TypeHandlers::Handler.new

      RoadForest::ContentHandling::Engine.new.tap do |engine|
        engine.add data, "image/jpeg"
        engine.add data, "image/png;q=0.9"
        engine.add data, "image/gif;q=0.7"
      end
    end
end

.plaintext_engineObject



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/roadforest/content-handling/common-engines.rb', line 24

def plaintext_engine
  @plaintext_engine ||=
    begin
      require 'roadforest/type-handlers/handler'
      text = RoadForest::TypeHandlers::Handler.new

      ContentHandling::Engine.new.tap do |engine|
        engine.add text, "text/plain"
      end
    end
end

.rdf_engineObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/roadforest/content-handling/common-engines.rb', line 6

def rdf_engine
  @rdf_engine ||=
    begin
      require 'roadforest/type-handlers/jsonld'
      require 'roadforest/type-handlers/rdfa'
      rdfa = RoadForest::TypeHandlers::RDFa.new
      jsonld = RoadForest::TypeHandlers::JSONLD.new

      ContentHandling::Engine.new.tap do |engine|
        engine.add rdfa, "text/html;q=1;rdfa=1"
        engine.add rdfa, "application/xhtml+xml;q=1;rdfa=1"
        engine.add jsonld, "application/ld+json"
        engine.add rdfa, "text/html;q=0.5"
        engine.add rdfa, "application/xhtml+xml;q=0.5"
      end
    end
end