Module: SchwabRb::PathSupport

Defined in:
lib/schwab_rb/path_support.rb

Overview

Common path expansion and directory helpers for token and data files.

Class Method Summary collapse

Class Method Details

.ensure_parent_directory(path) ⇒ Object



16
17
18
19
# File 'lib/schwab_rb/path_support.rb', line 16

def ensure_parent_directory(path)
  directory = File.dirname(expand_path(path))
  FileUtils.mkdir_p(directory)
end

.expand_path(path) ⇒ Object

Raises:

  • (ArgumentError)


10
11
12
13
14
# File 'lib/schwab_rb/path_support.rb', line 10

def expand_path(path)
  raise ArgumentError, "token_path is nil or empty" if path.nil? || path.to_s.strip.empty?

  File.expand_path(path.to_s)
end