Sha256: 9da8529e572b425d940d58f29a09608c0a4f95ccb92ba26f796d5a350e350678

Contents?: true

Size: 1.66 KB

Versions: 48

Compression:

Stored size: 1.66 KB

Contents

require 'find'
require 'apps/app_server/lib/app'
require 'apps/app_server/lib/git_app'

module Spider
    
    module AppServer
        
        def self.apps
            @apps ||= scan
        end
        
        def self.rescan
            @apps = scan
        end
    
        def self.scan
            apps = []
            self.paths.each do |path|
                apps += scan_path(path)
            end
            @apps_by_id = {}
            apps.each do |app|
                @apps_by_id[app.spec.id] = app
                app.app_server(Spider.conf.get('app_server.url'))
            end
            apps
        end
        
        def self.apps_by_id
            self.apps
            @apps_by_id
        end
        
        def self.scan_path(path)
            apps = []
            git_repos = search_git(path)
            git_repos.each do |p|
                app = GitApp.new(p)
                apps << app if app.spec
            end
            apps
        end
        
        def self.search_git(path)
            found = []
            Find.find(path) do |p|
                if File.directory?(p)
                    if File.directory?("#{p}/objects") && File.directory?("#{p}/info") && File.file?("#{p}/HEAD")
                        found << p
                        Find.prune
                    end
                end
            end
            found
        end
        
        def self.search_dirs(path)
            Dir.glob("#{path}/**/_init.rb").each do |f|
                found << File.dirname(f)
            end
        end
        
        def self.paths
            Spider.conf.get('app_server.search_paths') || []
        end
        
    end
    
end

Version data entries

48 entries across 48 versions & 1 rubygems

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