WebRI  WebRI::Component

[Validate]
Generated with WebRI Redfish 1.2

Abstract Generator Component

Constants

PATH
(Not documented)

Attributes

generator[R]

Public Class Methods

new(generator) click to toggle source

New component instance. Components require the generator they are augmenting.

# File lib/webri/components/abstract.rb, line 16
    def initialize(generator)
      @generator = generator
      initialize_methods
    end

Public Instance Methods

debug_msg(msg) click to toggle source

Output progress information if rdoc debugging is enabled

# File lib/webri/components/abstract.rb, line 98
    def debug_msg(msg)
      return unless $DEBUG_RDOC
      case msg[-1,1]
        when '.' then tab = "= "
        when ':' then tab = "== "
        else          tab = "* "
      end
      $stderr.puts(tab + msg)
    end
generate() click to toggle source

This is the method that is called by the generator, allowing the component in turn to generate the files it needs. By default this copies the components static directory.

# File lib/webri/components/abstract.rb, line 37
    def generate
      generate_static
    end
generate_static() click to toggle source

Copy static files to output. All the common static content is stored in the assets/ directory. WebRI’s assets/ directory more or less follows an Abbreviated Monash convention:

  assets/
    css/      <- stylesheets
    json/     <- json data table (*maybe top level is better?)
    img/      <- images
    inc/      <- server-side includes
    js/       <- javascripts

Components can utilize this method by providing a path.

# File lib/webri/components/abstract.rb, line 54
    def generate_static
      from = Dir[(path_static + '**').to_s]
      dest = path_output.to_s
      show_from = path_static.to_s.sub(PATH.to_s+'/', '')
      debug_msg "Copying #{show_from}/** to #{path_output_relative}:"
      fileutils.cp_r from, dest, :preserve => true
    end
initialize_methods() click to toggle source

Subcomponents use this to setup template provisions.

  def initialize_methods
    provide :svninfo
  end

See the provide method.

# File lib/webri/components/abstract.rb, line 29
    def initialize_methods
    end
method_missing(s, *a, &b) click to toggle source
# File lib/webri/components/abstract.rb, line 64
    def method_missing(s, *a, &b)
      generator.__send__(s,*a,&b)
    end
name() click to toggle source
# File lib/webri/components/abstract.rb, line 76
    def name
      self.class.name.split('::').last.downcase
    end
path_static() click to toggle source
# File lib/webri/components/abstract.rb, line 70
    def path_static
      PATH + "#{name}/static"
    end
provision(method, &block) click to toggle source

Provide a method interface(s) to the generator. This extends the generator’s context with component methods. Since ERB templates are rendering in the generator scope, this is useful when a component needs to provide method access to templates.

# File lib/webri/components/abstract.rb, line 86
    def provision(method, &block)
      if block
        generator.provision(method, &block)
      else
        generator.provision(method) do |*a, &b|
          __send__(method, *a, &b)
        end
      end
    end

Disabled; run with --debug to generate this.