Project

hesabu

0.0
No release in over 3 years
Low commit activity in last 3 years
arithmetic equation solver.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

Gem Maintainability Test Coverage Build Status

Hesabu

Hesabu : equations solver relies on https://github.com/BLSQ/go-hesabu to solve equations

Hesabu is swahili word for arithmetic.

sample usage

    solver = Hesabu::Solver.new
    solver.add("c", "a + b")
    solver.add("a", "10")
    solver.add("b", "10 + a")

    solution = solver.solve!

    expect(solution).to eq("a" => 10, "b" => 20, "c" => 30)

The solver will deduce the correct order and find the values of a,b and c.

The expressions can be more complex (excel like), see the supported functions here

When parsing or solving, things can go wrong, here are various cases

Currently the solver :

  • is case sensitive.
  • and fast (32000 equations in 3 seconds)

Alternatives

Development

Running the tests

# only the fast
bundle exec rspec --tag ~slow
# all with integration test, expect around 30-40 seconds depending on your machine
bundle exec rspec

profiling

RUBY_PROF_MEASURE_MODE=wall PROF=true bundle exec rspec ./spec/lib/hesabu/integration_spec.rb
RUBY_PROF_MEASURE_MODE=allocations PROF=true bundle exec rspec ./spec/lib/hesabu/integration_spec.rb

then look at the numbers launch the complete test suite and verify timings before and after

deployment to rubygems.org

one time setup

gem install gem-release
curl -u rubygemaccount https://rubygems.org/api/v1/api_key.yaml > ~/.gem/credentials
chmod 0600 ~/.gem/credentials

gem bump --tag --release

License

The gem is available as open source under the terms of the MIT License.