Class: GitCommander::Command::Loaders::FileLoader Abstract

Inherits:
Loader
  • Object
show all
Defined in:
lib/git_commander/command/loaders/file_loader.rb

Overview

This class is abstract.

Handles loading commands from file

Defined Under Namespace

Classes: FileLoadError, FileNotFoundError

Instance Attribute Summary collapse

Attributes inherited from Loader

#registry, #result

Instance Method Summary collapse

Methods inherited from Loader

#initialize, #system

Constructor Details

This class inherits a constructor from GitCommander::Loader

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.



13
14
15
# File 'lib/git_commander/command/loaders/file_loader.rb', line 13

def filename
  @filename
end

Instance Method Details

#load(filename) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/git_commander/command/loaders/file_loader.rb', line 15

def load(filename)
  raw_loader = Raw.new(registry)
  @result = raw_loader.load(File.read(filename))
rescue Errno::ENOENT => e
  handle_error FileNotFoundError, e
rescue StandardError => e
  handle_error FileLoadError, e
end