lib/webby/resources/db.rb in webby-0.9.0 vs lib/webby/resources/db.rb in webby-0.9.1
- old
+ new
@@ -21,11 +21,11 @@
#
# Add the given _resource_ to the database. It will not be added a second
# time if it already exists in the database.
#
def add( page )
- ary = @db[page.dir]
+ ary = @db[page.directory]
# make sure we don't duplicate pages
ary.delete page if ary.include? page
ary << page
@@ -181,11 +181,11 @@
# The attribute to sort by
# :reverse<Boolean>::
# Reverse the order of the results
#
def siblings( page, opts = {} )
- ary = @db[page.dir].dup
+ ary = @db[page.directory].dup
ary.delete page
return ary unless opts.has_key? :sort_by
m = opts[:sort_by]
ary.sort! {|a,b| a.__send__(m) <=> b.__send__(m)}
@@ -205,11 +205,11 @@
# The attribute to sort by
# :reverse<Boolean>::
# Reverse the order of the results
#
def children( page, opts = {} )
- rgxp = Regexp.new "\\A#{page.dir}/[^/]+"
+ rgxp = Regexp.new "\\A#{page.directory}/[^/]+"
keys = @db.keys.find_all {|k| rgxp =~ k}
ary = keys.map {|k| @db[k]}
ary.flatten!
@@ -227,10 +227,10 @@
# Returns the parent page of the given resource or nil if the resource is
# at the root of the directory structure. The parent is the "index" page
# of the current directory or the next directory up the chain.
#
def parent_of( page )
- dir = page.dir
+ dir = page.directory
loop do
if @db.has_key? dir
parent = @db[dir].find {|p| p.filename == 'index'}
return parent unless parent.nil? or parent == page