Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

renaming List to DependencyGraph

  • Loading branch information...
commit 42ed345f9bdc5d683785f97f96e8ff11335bc150 1 parent ec3971c
@moonmaster9000 authored
Showing with 20 additions and 20 deletions.
  1. +8 −8 lib/frill/frill.rb
  2. +12 −12 spec/frill_spec.rb
View
16 lib/frill/frill.rb
@@ -2,17 +2,17 @@ module Frill
class CyclicDependency < RuntimeError; end
def self.included(base)
- self.list.add base
+ self.dependency_graph.add base
base.extend ClassMethods
end
def self.decorators
- @decorators ||= list.to_a
+ @decorators ||= dependency_graph.to_a
end
def self.reset!
@decorators = nil
- @list = nil
+ @dependency_graph = nil
end
def self.decorate object, context
@@ -23,21 +23,21 @@ def self.decorate object, context
object
end
- def self.list
- @list ||= List.new
+ def self.dependency_graph
+ @dependency_graph ||= DependencyGraph.new
end
module ClassMethods
def before decorator
- Frill.list.move_before self, decorator
+ Frill.dependency_graph.move_before self, decorator
end
def after decorator
- Frill.list.move_before decorator, self
+ Frill.dependency_graph.move_before decorator, self
end
end
- class List
+ class DependencyGraph
def initialize
@nodes = {}
end
View
24 spec/frill_spec.rb
@@ -70,7 +70,7 @@ module Module3; include Frill; end
end
describe ".before" do
- it "inserts the current module before the requested module in Frill's list of decorators" do
+ it "inserts the current module before the requested module in Frill's dependency_graph of decorators" do
Module4.before Module3
Module2.before Module1
Module5.after Module4
@@ -92,20 +92,20 @@ module Module3; include Frill; end
end
describe ".before" do
- it "inserts the current module before the requested module in Frill's list of decorators" do
- Frill.list.to_a.should == [Module1, Module2, Module3]
+ it "inserts the current module before the requested module in Frill's dependency_graph of decorators" do
+ Frill.dependency_graph.to_a.should == [Module1, Module2, Module3]
Module1.before Module2
- Frill.list.to_a.should == [Module1, Module2, Module3]
+ Frill.dependency_graph.to_a.should == [Module1, Module2, Module3]
Module3.before Module2
- Frill.list.to_a.should == [Module3, Module1, Module2]
+ Frill.dependency_graph.to_a.should == [Module3, Module1, Module2]
end
end
describe ".after" do
- it "inserts the current module after the requested module in Frill's list of decorators" do
- Frill.list.to_a.should == [Module1, Module2, Module3]
+ it "inserts the current module after the requested module in Frill's dependency_graph of decorators" do
+ Frill.dependency_graph.to_a.should == [Module1, Module2, Module3]
Module1.after Module2
Module3.after Module2
@@ -116,10 +116,10 @@ module Module3; include Frill; end
end
end
- describe Frill::List do
+ describe Frill::DependencyGraph do
describe "#add" do
- it "should add an element to the list" do
- g = Frill::List.new
+ it "should add an element to the dependency_graph" do
+ g = Frill::DependencyGraph.new
g.add "hi"
g["hi"].should_not be_nil
end
@@ -127,7 +127,7 @@ module Module3; include Frill; end
describe "#move_before(label1, label2)" do
it "should move label1 before label2" do
- g = Frill::List.new
+ g = Frill::DependencyGraph.new
g.move_before "a", "b"
g.move_before "c", "d"
g.move_before "c", "b"
@@ -135,7 +135,7 @@ module Module3; include Frill; end
end
it "should throw exceptions when cycles are detected" do
- g = Frill::List.new
+ g = Frill::DependencyGraph.new
g.move_before "c", "b"
g.move_before "b", "a"
Please sign in to comment.
Something went wrong with that request. Please try again.