Class: Nugget::Web

Inherits:
Object
  • Object
show all
Defined in:
lib/nugget/web.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.runObject



4
5
6
7
# File 'lib/nugget/web.rb', line 4

def self.run()
  app = Rack::URLMap.new('/'  => Nugget::Web.new)
  Thin::Server.start(Nugget::Config.ip, Nugget::Config.port, app)
end

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/nugget/web.rb', line 9

def call(env)
  time_diff = Time.now.to_i - File.mtime(Nugget::Config.resultsfile).to_i

  if time_diff < 3600
    body = [File.read(Nugget::Config.resultsfile)]
    [200, { 'Content-Type' => 'text/plain' }, body]
  else
    [500, { 'Content-Type' => 'text/plain' }, ["nugget results file is stale (#{time_diff} seconds), something is wrong"]]
  end
end