Skip to content

akerl/libledger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

libledger

Gem Version GitHub Workflow Status MIT Licensed

Library for interacting with Ledger files.

Usage

libledger provides Ledger::Entry, which is a transaction, and Ledger::Journal, a list of transactions.

To create a new entry:

require 'libledger'
require 'date'

entry = Ledger::Entry.new(
  name: 'Delicious Chipotle Burrito',
  state: :cleared,
  date: Date.today,
  actions: [
    { name: 'Expenses:Burritos', amount: '$6.89' },
    { name: 'Assets:visa' }
  ]
)

# This will print the entry in ledger format
puts entry

To read an entry, call Ledger::Entry.from_lines(lines). lines should be an array of strings, which are the lines of a ledger journal for that transaction.

To read a full journal, use Ledger::Journal.from_file(file), where file should be a path to the journal file. If you have multiple files, Ledger::Journal.from_files(files) accepts an array of paths.

To create a journal, use Ledger::Journal.new(entries: array_of_entries).

The output of .to_s on a Journal (which is called if you do puts my_journal is the ledger text file format for its transactions.

Installation

gem install libledger

License

libledger is released under the MIT License. See the bundled LICENSE file for details.

About

Library for reading and writing Ledger transactions

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages