Sha256: f77d44f3aa8dd44da5869593d4d6ef203450d273cac00a559f3d27b1aab244a4

Contents?: true

Size: 651 Bytes

Versions: 3

Compression:

Stored size: 651 Bytes

Contents

module Scales
  module Monitor
    
    PUBLIC_APP_DIR = File.expand_path("../app/public", __FILE__)
    
    module Monitor
      
      @@cache = nil
      
      class << self
        
        def serve(path)
          cache_files! if @@cache.nil?
          @@cache[path]
        end
        
        private
        
        def cache_files!
          @@cache = {}
          
          Dir.chdir(PUBLIC_APP_DIR)
          Dir["*.html", "assets/*"].each{ |file| @@cache["/#{file}"] = File.read(file) }
          Dir.chdir(Scales.pwd)
          
          @@cache["/"] = @@cache["/index.html"]
        end
        
      end
      
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
scales-monitor-0.0.4 lib/scales-monitor/monitor.rb
scales-monitor-0.0.1.beta.2 lib/scales-monitor/monitor.rb
scales-monitor-0.0.1.beta.1 lib/scales-monitor/monitor.rb