Class: Benoit::Server::Remote

Inherits:
Object
  • Object
show all
Defined in:
lib/benoit/server/remote.rb

Instance Method Summary collapse

Constructor Details

#initialize(project) ⇒ Remote

Returns a new instance of Remote.



5
6
7
# File 'lib/benoit/server/remote.rb', line 5

def initialize(project)
  @project = project
end

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/benoit/server/remote.rb', line 9

def call(env)
  code = 200

  case env['PATH_INFO']
  when '/clean'
    Benoit::Cleaner.run
    body = "cleaned"
  when '/build'
    @project.invoke
    body = "built"
  end

  code = 200 if body
  body || (body, code = ["not found", 404])

  [code, {"Content-Type" => "application/json"}, {response: body}.to_json]
end