Class: Crawlscope::StructuredData::Writer

Inherits:
Object
  • Object
show all
Defined in:
lib/crawlscope/structured_data/writer.rb

Instance Method Summary collapse

Constructor Details

#initialize(path:) ⇒ Writer

Returns a new instance of Writer.



10
11
12
# File 'lib/crawlscope/structured_data/writer.rb', line 10

def initialize(path:)
  @path = path
end

Instance Method Details

#write(result) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/crawlscope/structured_data/writer.rb', line 14

def write(result)
  FileUtils.mkdir_p(File.dirname(@path))
  File.write(
    @path,
    JSON.pretty_generate(
      generated_at: Time.now.iso8601,
      results: Report.new(result).results
    )
  )
end