Class: Spider::Home

Inherits:
Object show all
Defined in:
lib/spiderfw/home.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Home

Returns a new instance of Home.



11
12
13
# File 'lib/spiderfw/home.rb', line 11

def initialize(path)
    @path = path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



9
10
11
# File 'lib/spiderfw/home.rb', line 9

def path
  @path
end

Instance Method Details

#appsObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/spiderfw/home.rb', line 44

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

#apps_pathObject



28
29
30
31
# File 'lib/spiderfw/home.rb', line 28

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

#controllerObject



15
16
17
18
# File 'lib/spiderfw/home.rb', line 15

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

#list_appsObject



33
34
35
36
37
38
39
40
41
42
# File 'lib/spiderfw/home.rb', line 33

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

#load_apps(*args) ⇒ Object



24
25
26
# File 'lib/spiderfw/home.rb', line 24

def load_apps(*args)
    Spider.load_apps(*args)
end

#route_appsObject



20
21
22
# File 'lib/spiderfw/home.rb', line 20

def route_apps
    Spider.route_apps
end