Class CorePlugins::ResourceManager::Resource
In: lib/webgen/plugins/coreplugins/resourcemanager.rb
Parent: Object
Webgen::Plugin ResourceManager Configuration lib/webgen/plugins/coreplugins/configuration.rb lib/webgen/plugins/coreplugins/resourcemanager.rb CorePlugins dot/m_21_0.png

The base class for all resources.

Methods

Attributes

name  [R]  The unique name of the resource.
output_path  [R]  The output path.
predefined  [RW]  Specifies if this resource is predefined. This is only used internally by webgen!
type  [RW]  The type of resource: file or memory.

Public Class methods

[Source]

    # File lib/webgen/plugins/coreplugins/resourcemanager.rb, line 47
47:       def initialize( name, type, output_path )
48:         @name = name
49:         @type = type
50:         @output_path = output_path.sub( /^\//, '' )
51:         @used = false
52:       end

Public Instance methods

Returns the complete destination path.

[Source]

    # File lib/webgen/plugins/coreplugins/resourcemanager.rb, line 60
60:       def dest_path( root_dir )
61:         File.join( root_dir, @output_path )
62:       end

Mark the resource as referenced. Only referenced resources are written to the output directory.

[Source]

    # File lib/webgen/plugins/coreplugins/resourcemanager.rb, line 65
65:       def referenced!
66:         @referenced = true
67:       end

Has the resource been used somewhere?

[Source]

    # File lib/webgen/plugins/coreplugins/resourcemanager.rb, line 70
70:       def referenced?
71:         @referenced
72:       end

Returns the relative path from the node to the resource.

[Source]

    # File lib/webgen/plugins/coreplugins/resourcemanager.rb, line 55
55:       def route_from( node )
56:         node.route_to( '/' + @output_path )
57:       end

Write the resource to the output directory.

[Source]

    # File lib/webgen/plugins/coreplugins/resourcemanager.rb, line 80
80:       def write_resource( root_dir, file_handler )
81:         raise NotImplementedError
82:       end

Can the resource be written to the output directory?

[Source]

    # File lib/webgen/plugins/coreplugins/resourcemanager.rb, line 75
75:       def write_resource?( root_dir, file_handler )
76:         @referenced
77:       end

[Validate]