Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ruby Ledger

A pure-Ruby port of Ledger, the plain-text accounting tool. Parses Ledger-format journal files and produces balance, register, and print reports — no C extensions, no external dependencies beyond bigdecimal.

CI Gem Version

Status: Active, early (v0.1). Core journal format, balance validation, and the three main reports work; budgets, periodic transactions, and valuation directives are not yet implemented. See Roadmap.

Why

Ledger already has ports in Haskell (hledger), Python (Beancount), Scala (Abandon), Go, PureScript, and more — but not Ruby. This fills that gap for teams and hobbyists who want plain-text accounting inside a Ruby or Rails codebase, without shelling out to another language's binary.

Installation

gem install ruby_ledger

Or add to your Gemfile:

gem "ruby_ledger"

Command-line usage

ruby_ledger balance -f myjournal.ledger
ruby_ledger register -f myjournal.ledger [ACCOUNT_FILTER]
ruby_ledger print -f myjournal.ledger

Given this journal:

2026-01-02 * Opening Balance
    Assets:Bank:Checking        $1000.00
    Equity:Opening Balances

2026-01-05 * Coffee Shop
    Expenses:Food:Coffee        $4.50
    Assets:Bank:Checking

ruby_ledger balance -f journal.ledger prints:

       $995.50  Assets:Bank:Checking
      $-1000    Equity:Opening Balances
         $4.50  Expenses:Food:Coffee
----------------------------------------
            $0

Note the second posting in each transaction above has no amount — Ruby Ledger auto-balances a single elided posting per transaction, same as Ledger itself.

Library usage

require "ruby_ledger"

journal = RubyLedger::Journal.load("myjournal.ledger")

RubyLedger::Reports::Balance.new(journal).totals
# => { "Assets:Bank:Checking" => { "$" => #<BigDecimal 995.50> }, ... }

RubyLedger::Reports::Register.new(journal, account_filter: "Checking").rows

Supported journal format

  • YYYY-MM-DD or YYYY/MM/DD dated transactions
  • * (cleared) / ! (pending) status markers, on transactions and postings
  • Multi-line postings, two-or-more-space account/amount separation
  • Elided (auto-balancing) posting amounts
  • $, £, , ¥ symbolic commodities and trailing commodities (50 AAPL)
  • ; comments (line and inline), plus #, %, |, * full-line comments
  • include directives

Not yet supported: budgets, periodic/forecast transactions, valuation and lot pricing, account/commodity declarations, virtual postings. PRs welcome — see CONTRIBUTING.md.

Rails integration

The core gem is framework-agnostic by design — the journal file, not a database, stays the source of truth. See ruby_ledger-rails/ for a mountable Rails engine that wraps this gem with:

  • Controllers/views rendering balance and register as HTML
  • Optional ActiveRecord read-models synced from the journal file, for fast querying and dashboards
  • A file-watcher to re-parse on journal changes in development

Roadmap

  • Budget and periodic transaction directives
  • Commodity price history / valuation
  • virtual and (parenthesized) postings
  • CSV import helper
  • Compatibility test suite run against Ledger's own upstream fixtures

Development

bundle install
bundle exec rspec
bundle exec rubocop

Contributing

Bug reports and PRs are welcome at https://github.com/aburoos/ruby_ledger. Please see CONTRIBUTING.md first.

License

MIT — see LICENSE.txt.

Related projects

Project Language
Ledger C++
hledger Haskell
Beancount Python
Abandon Scala
Ruby Ledger Ruby

See also the full comparison on plaintextaccounting.org and the Ledger wiki Ports page.

About

Ruby - Ledger Ported

Resources

Contributing

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages