Class: RVGP::Fakers::FakeReconciler

Inherits:
Faker::Base
  • Object
show all
Extended by:
FakerHelpers
Defined in:
lib/rvgp/fakers/fake_reconciler.rb

Overview

Contains faker implementations that produce reconciler yamls

Class Method Summary collapse

Class Method Details

.basic_checking(from: 'Personal:Assets:AcmeBank:Checking', label: nil, format_path: nil, input_path: nil, output_path: nil, income: nil, expense: nil) ⇒ String

Generates a basic reconciler, for use in reconciling a basic_checking feed

Parameters:

  • from (String) (defaults to: 'Personal:Assets:AcmeBank:Checking')

    The from parameter to write into our yaml

  • label (String) (defaults to: nil)

    The label parameter to write into our yaml

  • format_path (String) (defaults to: nil)

    A path to the format yaml, for use in the format parameter of our yaml

  • input_path (String) (defaults to: nil)

    A path to the input feed, for use in the input parameter of our yaml

  • output_path (String) (defaults to: nil)

    A path to the output journal, for use in the output parameter of our yaml

  • income (Array) (defaults to: nil)

    An array of hashes, containing the income rules, to write into our yaml

  • expense (Array) (defaults to: nil)

    An array of hashes, containing the expense rules, to write into our yaml

Returns:

  • (String)

    A YAML file, containing the generated reconciler

Raises:

  • (StandardError)


49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/rvgp/fakers/fake_reconciler.rb', line 49

def basic_checking(from: 'Personal:Assets:AcmeBank:Checking',
                   label: nil,
                   format_path: nil,
                   input_path: nil,
                   output_path: nil,
                   income: nil,
                   expense: nil)

  raise StandardError if [from, label, input_path, output_path].any?(&:nil?)

  format = "!!include #{format_path}" if format_path
  format ||= format("\n%s", DEFAULT_FORMAT.gsub(/^/, '  ').chomp)

  format BASIC_CHECKING_FEED,
         from: from,
         label: label,
         format: format,
         input_path: input_path,
         output_path: output_path,
         income: hashes_to_yaml_array(
           [income, { match: '/.*/', to: 'Personal:Income:Unknown' }].flatten.compact
         ),
         expense: hashes_to_yaml_array(
           [expense, { match: '/.*/', to: 'Personal:Expenses:Unknown' }].flatten.compact
         )
end