Sha256: 9b5854aa6d7632e0f5800c4568a2db4e33e7993f81bed7d7bd62c05a141bea3d

Contents?: true

Size: 1.5 KB

Versions: 6

Compression:

Stored size: 1.5 KB

Contents

module HaveAPI::Fs::Components
  # The root of the filesystem. There is only one instance of this object.
  #
  # This directory contains some special hidden files:
  #  
  #  - `.remote_control` is used for IPC between the file system and executables
  #  - `.cache` contains some statistics about the cache
  #  - `.assets/` contains static files for HTML help files
  class Root < Directory
    component :root
    
    def initialize()
      super()
    end

    def setup
      super
      @api = context.fs.api
    end

    def contents
      super + %w(.client_version .fs_version .protocol_version) + \
        @api.resources.keys.map(&:to_s)
    end

    def resources
      @api.resources
    end

    def title
      context.url
    end

    protected
    def new_child(name)
      if child = super
        child
      
      elsif @api.resources.has_key?(name)
        [ResourceDir, @api.resources[name]]

      else
        case name
        when :'.remote_control'
          RemoteControlFile

        when :'.assets'
          [
              ProxyDir, 
              ::File.join(
                  ::File.realpath(::File.dirname(__FILE__)),
                  '..', '..', '..', '..',
                  'assets'
              ),
          ]

        when :'.client_version'
          ClientVersion

        when :'.fs_version'
          FsVersion

        when :'.protocol_version'
          ProtocolVersion

        when :'.cache'
          CacheStats

        else
          nil
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
haveapi-fs-0.11.0 lib/haveapi/fs/components/root.rb
haveapi-fs-0.10.0 lib/haveapi/fs/components/root.rb
haveapi-fs-0.9.0 lib/haveapi/fs/components/root.rb
haveapi-fs-0.8.0 lib/haveapi/fs/components/root.rb
haveapi-fs-0.7.1 lib/haveapi/fs/components/root.rb
haveapi-fs-0.7.0 lib/haveapi/fs/components/root.rb