Skip to content

gingray/damn-legacy

Repository files navigation

Damn::Legacy

Quite a lot of time I have to work with huge legacy code bases. When I face a bug I create small ruby script to put everything I've found or related information. I create small DSL to describe "stacktraces" which I create by hand. Main goal of this gem is provide a nice DSL to create this kind of code mind maps.
I found it useful for few reasons first one all IDE support code navigation it means I can easely jump to real classes and keep context of the task tight in one file.
Second benefit this DSL can create diagrams currently it's support only Mermaid.js state diagram.
Good thing about it you can easily visualise it and embed in your document to share it with someone for your own knowledge base.

I'm trying this thing as POC means if you find it useful it's cool if not whatever :)

Damn::Legacy.turn_on
Damn::Legacy.store_clean

DeductMoney.meth(:prepare).step do
  Mail
end

Payment.meth([call: [validate: [check_balance: [:pay, :fail]]]]).step do
  DeductMoney.meth(:call).step do
    InformUser.meth(:notify).step do
      Mail
    end
  end
end

Example

stateDiagram-v2
DeductMoney --> DeductMoney#prepare
DeductMoney --> DeductMoney#call
DeductMoney#prepare --> Mail
Payment --> Payment#call
Payment#call --> Payment#call#validate
Payment#call#validate --> Payment#call#validate#check_balance
Payment#call#validate#check_balance --> Payment#call#validate#check_balance#pay
Payment#call#validate#check_balance --> Payment#call#validate#check_balance#fail
InformUser --> InformUser#notify
InformUser#notify --> Mail
DeductMoney#call --> InformUser
Payment#call#validate#check_balance#pay --> DeductMoney
Payment#call#validate#check_balance#fail --> DeductMoney
Loading

Installation

Add this line to your application's Gemfile:

gem 'damn-legacy'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install damn-legacy

Usage

TODO: Write usage instructions here

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/damn-legacy. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

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

Code of Conduct

Everyone interacting in the Damn::Legacy project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

About

Tool to help with legacy code and fix bugs

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors