Sha256: 0d4e5ef4a8da18b6823c08320a7062d4037eee32d76c4ad2ce05c27baf7e99ce

Contents?: true

Size: 1.66 KB

Versions: 19

Compression:

Stored size: 1.66 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 pub_path
            controller.pub_path
        end

        def pub_url
            controller.pub_url
        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

19 entries across 19 versions & 1 rubygems

Version Path
spiderfw-1.0.1 lib/spiderfw/home.rb
spiderfw-1.0.0 lib/spiderfw/home.rb
spiderfw-0.6.39 lib/spiderfw/home.rb
spiderfw-0.6.38 lib/spiderfw/home.rb
spiderfw-0.6.37 lib/spiderfw/home.rb
spiderfw-0.6.35 lib/spiderfw/home.rb
spiderfw-0.6.34 lib/spiderfw/home.rb
spiderfw-0.6.33 lib/spiderfw/home.rb
spiderfw-0.6.32 lib/spiderfw/home.rb
spiderfw-0.6.31 lib/spiderfw/home.rb
spiderfw-0.6.30 lib/spiderfw/home.rb
spiderfw-0.6.29 lib/spiderfw/home.rb
spiderfw-0.6.28 lib/spiderfw/home.rb
spiderfw-0.6.27 lib/spiderfw/home.rb
spiderfw-0.6.26 lib/spiderfw/home.rb
spiderfw-0.6.26.pre1 lib/spiderfw/home.rb
spiderfw-0.6.25 lib/spiderfw/home.rb
spiderfw-0.6.24 lib/spiderfw/home.rb
spiderfw-0.6.23 lib/spiderfw/home.rb