Class: Etcher::Loaders::JSON

Inherits:
Object
  • Object
show all
Defined in:
lib/etcher/loaders/json.rb

Overview

Loads a JSON configuration.

Instance Method Summary collapse

Constructor Details

#initialize(path, fallback: Core::EMPTY_HASH, logger: LOGGER) ⇒ JSON

Returns a new instance of JSON.



13
14
15
16
17
18
# File 'lib/etcher/loaders/json.rb', line 13

def initialize path, fallback: Core::EMPTY_HASH, logger: LOGGER
  @path = path
  @fallback = fallback
  @logger = logger
  freeze
end

Instance Method Details

#callObject



20
21
22
23
24
# File 'lib/etcher/loaders/json.rb', line 20

def call
  Success ::JSON.load_file(path)
rescue Errno::ENOENT, TypeError then debug_invalid_path
rescue ::JSON::ParserError => error then content_failure error
end