Sha256: db64115ae41451f27c9d89516f622bb5aac0628bde330500cb0925c0c3e2e74f
Contents?: true
Size: 1.68 KB
Versions: 2
Compression:
Stored size: 1.68 KB
Contents
require "active_support/inflector" require "pathname" require "massimo/resource/processing" require "massimo/resource/collection" module Massimo module Resource class Base include Processing extend Collection attr_reader :source_path, :body # The name of this Resource type. def self.name self.to_s.underscore.gsub(/.*\//, "") end # The plural name of this Resource type. def self.collection_name name.pluralize end # Gets the site instance def self.site Massimo::Site() end # Get the directory to this Resource type. def self.dir(*path) site.dir_for(self.collection_name, *path) end # Hook for adding Resource types. def self.inherited(subclass) Massimo.resources << subclass end # Creates a new page associated with the given file path. def initialize(source_path) @source_path = Pathname.new(source_path) read_source! end # Gets the resource's file name. def file_name @source_path.basename.to_s end # Gets the resource type, based on the file's extension def resource_type @source_path.extname.to_s[1..-1] end # Gets the site instance def site self.class.site end # Renders the page using the registered filters. def render(locals = {}) @body end protected # Get the options from the Site's config for the current resource type. def options_for_resource_type site.options[resource_type.to_sym] end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
massimo-0.4.5 | lib/massimo/resource/base.rb |
massimo-0.4.4 | lib/massimo/resource/base.rb |