Skip to content

Commit

Permalink
Simplify DependencyTracker contract
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdefreyne committed Nov 24, 2016
1 parent 501b52c commit a9a1f8b
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions lib/nanoc/base/services/dependency_tracker.rb
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
module Nanoc::Int
# @api private
class DependencyTracker
include Nanoc::Int::ContractsSupport

C_OBJ = C::Or[Nanoc::Int::Item, Nanoc::Int::Layout]
C_ARGS = C::KeywordArgs[raw_content: C::Optional[C::Bool], attributes: C::Optional[C::Bool], compiled_content: C::Optional[C::Bool], path: C::Optional[C::Bool]]

class Null
include Nanoc::Int::ContractsSupport

contract C::Or[Nanoc::Int::Item, Nanoc::Int::Layout], C::KeywordArgs[raw_content: C::Optional[C::Bool], attributes: C::Optional[C::Bool], compiled_content: C::Optional[C::Bool], path: C::Optional[C::Bool]] => C::Any
contract C_OBJ, C_ARGS => C::Any
def enter(_obj, raw_content: false, attributes: false, compiled_content: false, path: false)
end

contract C::None => C::Any
contract C_OBJ => C::Any
def exit
end

contract C::Or[Nanoc::Int::Item, Nanoc::Int::Layout], C::KeywordArgs[raw_content: C::Optional[C::Bool], attributes: C::Optional[C::Bool], compiled_content: C::Optional[C::Bool], path: C::Optional[C::Bool]] => C::Any
contract C_OBJ, C_ARGS => C::Any
def bounce(_obj, raw_content: false, attributes: false, compiled_content: false, path: false)
end
end

include Nanoc::Int::ContractsSupport

def initialize(dependency_store)
@dependency_store = dependency_store
@stack = []
end

contract C::Or[Nanoc::Int::Item, Nanoc::Int::Layout], C::KeywordArgs[raw_content: C::Optional[C::Bool], attributes: C::Optional[C::Bool], compiled_content: C::Optional[C::Bool], path: C::Optional[C::Bool]] => C::Any
contract C_OBJ, C_ARGS => C::Any
def enter(obj, raw_content: false, attributes: false, compiled_content: false, path: false)
unless @stack.empty?
Nanoc::Int::NotificationCenter.post(:dependency_created, @stack.last, obj)
Expand All @@ -41,12 +44,12 @@ def enter(obj, raw_content: false, attributes: false, compiled_content: false, p
@stack.push(obj)
end

contract C::None => C::Any
contract C_OBJ => C::Any
def exit
@stack.pop
end

contract C::Or[Nanoc::Int::Item, Nanoc::Int::Layout], C::KeywordArgs[raw_content: C::Optional[C::Bool], attributes: C::Optional[C::Bool], compiled_content: C::Optional[C::Bool], path: C::Optional[C::Bool]] => C::Any
contract C_OBJ, C_ARGS => C::Any
def bounce(obj, raw_content: false, attributes: false, compiled_content: false, path: false)
enter(obj, raw_content: raw_content, attributes: attributes, compiled_content: compiled_content, path: path)
exit
Expand Down

0 comments on commit a9a1f8b

Please sign in to comment.