Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Easy resolution of before/after relations for Ruby (not maintained anymore)
Ruby
branch: master
Failed to load latest commit information.
lib Release v0.1.0
test
.gitignore Remove Gemfile.lock from VC...
.rvmrc Use 1.9.2
Gemfile
LICENSE
README.md
Rakefile
depression.gemspec

README.md

Easy Resolution of Before/After Relations For Ruby

Depression resolves before/after relations by forming a graph of them and flattening it. It supports simple before/after as well as "greedy" relations.

Getting Started

$ gem install depression

After installation the first steps are really easy. You simply need a bunch of objects that respond to #name as well as #relations and return something more or less unique and a hash, resp.

require "depression"

Item = Struct.new(:name, :relations)
items = [
  Item.new(:foo, {}),
  Item.new(:bar, :before => [:foo]),
  Item.new(:baz, :after => [:foo])
]

sorted = Depression.process(items)
puts sorted.map {|i| i.name }.join(",")
# bar,foo,baz

Greedy Relations

TODO

Resolving Conflicts

TODO

Resolving Circular Relations

TODO

Dependencies

Runs fine on Ruby 1.9.2 and JRuby 1.5.6.

To do & Ideas

  • Gracefully drop greedy relations if they conflict with normal relations
  • Implement a "friendly" mode that simply drops "older" relations until a circular relation is resolved
  • Visualize various stages of relation resolution (probably via GraphViz)
  • Maybe switch to TSort

Contributing

  1. Fork at github.com/lgierth/depression
  2. Create a new branch
  3. Commit, commit, commit!
  4. Open a Pull Request

You can also open an issue for discussion first, if you want.

License

Depression is subject to an MIT-style license that can be found in the LICENSE file.

Something went wrong with that request. Please try again.