Class: Coradoc::Mirror::Output::MirrorJson

Inherits:
Object
  • Object
show all
Defined in:
lib/coradoc/mirror/output.rb

Overview

JSON output processor for the Coradoc::Output pipeline.

Class Method Summary collapse

Class Method Details

.processor_execute(input, options = {}) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/coradoc/mirror/output.rb', line 25

def processor_execute(input, options = {})
  pretty = options[:pretty] != false
  input.each_with_object({}) do |(filename, document), result|
    node = Coradoc::Mirror.transform(document)
    result[filename] = pretty ? JSON.pretty_generate(node.to_hash) : JSON.generate(node.to_hash)
  end
end

.processor_idObject



17
18
19
# File 'lib/coradoc/mirror/output.rb', line 17

def processor_id
  :mirror_json
end

.processor_match?(filename) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/coradoc/mirror/output.rb', line 21

def processor_match?(filename)
  filename.downcase.end_with?('.mirror.json')
end