Class: Ynap::CLI
- Inherits:
-
Thor
- Object
- Thor
- Ynap::CLI
- Defined in:
- lib/ynap/cli.rb
Constant Summary collapse
- DEFAULT_CONFIG_PATH =
'ynap.yml'
Instance Method Summary collapse
- #balances ⇒ Object
- #console ⇒ Object
- #diff(bank_id) ⇒ Object
- #import ⇒ Object
- #payees ⇒ Object
- #plaid ⇒ Object
- #plaid_ids(bank_id) ⇒ Object
- #transactions(bank_id) ⇒ Object
Instance Method Details
#balances ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/ynap/cli.rb', line 39 def balances load_config .config if .bank.nil? puts Bank.accounts_descriptions else puts Bank.find(.bank).accounts_descriptions end end |
#console ⇒ Object
15 16 17 |
# File 'lib/ynap/cli.rb', line 15 def console system("ruby #{File. File.dirname(__FILE__)}/../../bin/console") end |
#diff(bank_id) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/ynap/cli.rb', line 51 def diff(bank_id) load_config .config bank = Bank.find(bank_id) puts "**************\n* Last #{.limit} transactions for each account @ #{bank.name}\n**************" bank.accounts.each do |account| puts "\nAccount: #{account.description}\n" puts "\nPlaid\n-------" puts account.plaid_transactions.first(.limit).map(&:description).join("\n") puts "\nYNAB\n-------" puts account.ynab_transactions.first(.limit).map(&:description).join("\n") puts "\n*******" end end |
#import ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/ynap/cli.rb', line 69 def import load_config .config puts "* Fetching transactions and preparing import\n" if .bank.nil? Bank.all.each(&:import) else Bank.find(.bank).import end if .reconcile puts "\n* Fetching balances\n" balances end end |
#payees ⇒ Object
87 88 89 90 91 92 93 94 95 |
# File 'lib/ynap/cli.rb', line 87 def payees load_config .config if .bank.nil? puts Bank.payees(with_memos: .memos).join("\n") else puts Bank.find(.bank).send(.memos ? :payees_memos : :payees).join("\n") end end |
#plaid ⇒ Object
21 22 23 |
# File 'lib/ynap/cli.rb', line 21 def plaid system("ruby #{File. File.dirname(__FILE__)}/../../bin/plaid #{.config}") end |