Project

libledger

0.0
No release in over 3 years
Low commit activity in last 3 years
Library for interacting with Ledger files
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.1.1
~> 2.4.1
~> 0.7.1
~> 12.3.0
~> 3.8.0
~> 0.74.0
 Project Readme

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.