Class: Grayskull::Formats::JSONHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/grayskull/formats/json_handler.rb

Overview

Handler for JSON file format.

Class Method Summary collapse

Class Method Details

.load(file) ⇒ Object

Loads the JSON file and parses it into a ruby type.

Raises an expection if file can not be parsed.



13
14
15
16
17
18
19
20
21
# File 'lib/grayskull/formats/json_handler.rb', line 13

def self.load(file)
   loaded = File.open(file)
   content = loaded.gets nil
  begin
    return JSON.parse(content)
  rescue Exception => e
    raise e.class, 'File could not be parsed as valid JSON'          
  end
end