Module: Webby::Resources
- Defined in:
- lib/webby/resources.rb,
lib/webby/resources/db.rb,
lib/webby/resources/file.rb,
lib/webby/resources/page.rb,
lib/webby/resources/layout.rb,
lib/webby/resources/static.rb,
lib/webby/resources/partial.rb,
lib/webby/resources/resource.rb
Defined Under Namespace
Classes: DB, File, Layout, Page, Partial, Resource, Static
Class Method Summary collapse
-
.clear ⇒ Object
Clear the contents of the
layouts
,pages
andpartials
hash objects. -
.layouts ⇒ Object
Returns the layouts hash object.
-
.new(fn) ⇒ Object
call-seq: Resources.new( filename ).
-
.pages ⇒ Object
Returns the pages hash object.
-
.partials ⇒ Object
Returns the partials hash object.
-
.path(filename) ⇒ Object
Returns a normalized path for the given filename.
Class Method Details
.clear ⇒ Object
Clear the contents of the layouts
, pages
and partials
hash objects.
25 26 27 28 29 |
# File 'lib/webby/resources.rb', line 25 def clear self.pages.clear self.layouts.clear self.partials.clear end |
.layouts ⇒ Object
Returns the layouts hash object.
12 13 14 |
# File 'lib/webby/resources.rb', line 12 def layouts @layouts ||= ::Webby::Resources::DB.new end |
.new(fn) ⇒ Object
call-seq:
Resources.new( filename )
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/webby/resources.rb', line 35 def new( fn ) # normalize the path fn = self.path(fn) # see if we are dealing with a layout if %r/\A#{::Webby.site.layout_dir}\//o =~ fn r = ::Webby::Resources::Layout.new(fn) self.layouts << r return r end # see if we are dealing with a partial filename = ::Webby::Resources::File.basename(fn) if %r/\A_/o =~ filename r = ::Webby::Resources::Partial.new(fn) self.partials << r return r end # see if we are dealing with a static resource = ::Webby::Resources::File.(fn) if .nil? r = ::Webby::Resources::Static.new(fn) self.pages << r return r end # this is a renderable page r = ::Webby::Resources::Page.new(fn) self.pages << r return r end |
.pages ⇒ Object
Returns the pages hash object.
6 7 8 |
# File 'lib/webby/resources.rb', line 6 def pages @pages ||= ::Webby::Resources::DB.new end |
.partials ⇒ Object
Returns the partials hash object.
18 19 20 |
# File 'lib/webby/resources.rb', line 18 def partials @partials ||= ::Webby::Resources::DB.new end |
.path(filename) ⇒ Object
Returns a normalized path for the given filename.
70 71 72 |
# File 'lib/webby/resources.rb', line 70 def path( filename ) filename.sub(%r/\A(?:\.\/|\/)/o, '').freeze end |