Class: CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/mfynab/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ CLI

Returns a new instance of CLI.



13
14
15
# File 'lib/mfynab/cli.rb', line 13

def initialize(argv)
  @argv = argv
end

Class Method Details

.start(argv) ⇒ Object



9
10
11
# File 'lib/mfynab/cli.rb', line 9

def self.start(argv)
  new(argv).start
end

Instance Method Details

#startObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/mfynab/cli.rb', line 17

def start
  logger.info("Running...")

  Dir.mktmpdir("mfynab") do |save_path|
    money_forward.download_csv(
      session_id: session_id,
      path: save_path,
      months: months_to_sync,
    )

    data = MFYNAB::MoneyForwardData.new(logger: logger)
    data.read_all_csv(save_path)
    ynab_transaction_importer.run(data.to_h)
  end

  logger.info("Done!")
end