Sha256: 1f30ba495bdd6b655e79537d90634d4c376c44dd68227961afb680bd9cffc782

Contents?: true

Size: 1.53 KB

Versions: 17

Compression:

Stored size: 1.53 KB

Contents

require 'pathname'
require 'spiderfw/spider'
require 'spiderfw/app'


module Spider

    class Home
        attr_reader :path

        def initialize(path)
            @path = path
        end

        def controller
            require 'spiderfw/controller/home_controller'
            Spider::HomeController
        end

        def route_apps
            Spider.route_apps
        end

        def load_apps(*args)
            Spider.load_apps(*args)
        end
        
        def apps_path
            @apps_path = Spider.paths[:apps] if Spider.respond_to?(:paths)
            @apps_path ||= File.join(@path, 'apps')
        end

        def list_apps
            apps_dir = Pathname.new(self.apps_path)
            paths = Spider.find_all_apps(self.apps_path)
            apps = []
            paths.each do |path|
                dir = Pathname.new(path)
                apps << dir.relative_path_from(apps_dir).to_s
            end
            apps
        end
        
        def apps
            apps = {}
            list_apps.each do |path|
                spec_file = Dir.glob(File.join(self.apps_path, path, "*.appspec")).first
                spec = nil
                if spec_file
                    spec = Spider::App::AppSpec.load(spec_file)
                    app_name = spec.app_id
                else
                    app_name = path
                end
                apps[app_name] = {
                    :path => path,
                    :spec => spec
                }
            end
            apps
        end

    end


end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
spiderfw-0.6.22 lib/spiderfw/home.rb
spiderfw-0.6.21 lib/spiderfw/home.rb
spiderfw-0.6.20 lib/spiderfw/home.rb
spiderfw-0.6.19 lib/spiderfw/home.rb
spiderfw-0.6.18 lib/spiderfw/home.rb
spiderfw-0.6.17 lib/spiderfw/home.rb
spiderfw-0.6.16 lib/spiderfw/home.rb
spiderfw-0.6.15 lib/spiderfw/home.rb
spiderfw-0.6.14 lib/spiderfw/home.rb
spiderfw-0.6.13 lib/spiderfw/home.rb
spiderfw-0.6.12 lib/spiderfw/home.rb
spiderfw-0.6.11 lib/spiderfw/home.rb
spiderfw-0.6.10 lib/spiderfw/home.rb
spiderfw-0.6.9 lib/spiderfw/home.rb
spiderfw-0.6.8 lib/spiderfw/home.rb
spiderfw-0.6.7 lib/spiderfw/home.rb
spiderfw-0.6.6 lib/spiderfw/home.rb