Class: Mascot::Sitemap
- Inherits:
-
Object
- Object
- Mascot::Sitemap
- Defined in:
- lib/mascot/sitemap.rb
Overview
A collection of pages from a directory.
Constant Summary collapse
- DEFAULT_GLOB =
Default file pattern to pick up in sitemap
"**/**".freeze
- DEFAULT_ROOT_PATH =
Default root path for sitemap.
Pathname.new(".").freeze
- DEFAULT_ROOT_REQUEST_PATH =
Default root request path
Pathname.new("/").freeze
Instance Attribute Summary collapse
-
#extensions ⇒ Object
readonly
Returns the value of attribute extensions.
-
#request_path ⇒ Object
Returns the value of attribute request_path.
-
#root ⇒ Object
Returns the value of attribute root.
Instance Method Summary collapse
-
#assets(glob = DEFAULT_GLOB) ⇒ Object
Lazy stream of files that will be rendered by resources.
-
#get(request_path) ⇒ Object
Find the page with a path.
-
#initialize(root: DEFAULT_ROOT_PATH, request_path: DEFAULT_ROOT_REQUEST_PATH) ⇒ Sitemap
constructor
A new instance of Sitemap.
-
#resources ⇒ Object
Returns a list of resources.
Constructor Details
#initialize(root: DEFAULT_ROOT_PATH, request_path: DEFAULT_ROOT_REQUEST_PATH) ⇒ Sitemap
Returns a new instance of Sitemap.
15 16 17 18 19 |
# File 'lib/mascot/sitemap.rb', line 15 def initialize(root: DEFAULT_ROOT_PATH, request_path: DEFAULT_ROOT_REQUEST_PATH) self.root = root self.request_path = request_path @extensions = [] end |
Instance Attribute Details
#extensions ⇒ Object (readonly)
Returns the value of attribute extensions.
13 14 15 |
# File 'lib/mascot/sitemap.rb', line 13 def extensions @extensions end |
#request_path ⇒ Object
Returns the value of attribute request_path.
13 14 15 |
# File 'lib/mascot/sitemap.rb', line 13 def request_path @request_path end |
#root ⇒ Object
Returns the value of attribute root.
13 14 15 |
# File 'lib/mascot/sitemap.rb', line 13 def root @root end |
Instance Method Details
#assets(glob = DEFAULT_GLOB) ⇒ Object
Lazy stream of files that will be rendered by resources.
22 23 24 25 26 |
# File 'lib/mascot/sitemap.rb', line 22 def assets(glob = DEFAULT_GLOB) safe_root.glob(root.join(glob)).select(&File.method(:file?)).lazy.map do |path| Asset.new(path: path) end end |
#get(request_path) ⇒ Object
Find the page with a path.
37 38 39 |
# File 'lib/mascot/sitemap.rb', line 37 def get(request_path) resources.get(request_path) end |