Module: Tenter::Helpers
- Defined in:
- lib/tenter/helpers.rb
Instance Method Summary collapse
Instance Method Details
#authenticate ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/tenter/helpers.rb', line 7 def authenticate msg = "X-Hub-Signature header not set" halt 400, msg unless request.env['HTTP_X_HUB_SIGNATURE'] msg = "X-Hub-Signature header did not match" halt 403, msg unless Tenter::Utils.dir_exists? params[:site_dir] secret = Tenter::Utils.secret params[:site_dir] request_sig = request.env['HTTP_X_HUB_SIGNATURE'] request_body = request.body.read computed_sig = 'sha1=' + OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), secret, request_body) msg = "X-Hub-Signature header did not match" halt 403, msg unless Rack::Utils.secure_compare computed_sig, request_sig end |
#initiate ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/tenter/helpers.rb', line 27 def initiate command = Tenter::Utils.command params[:command_name], params[:site_dir] msg = "Command not found" halt 400, msg unless File.file? command["path"] ts = Tenter.settings[:timestamp] ? "[#{Time.now}] " : "" msg = ts + "Initiating: #{command["path"]}\n" Tenter::Utils.append_to_log command["log"], msg pid = if defined?(Bundler) && Bundler.respond_to?(:with_clean_env) Bundler.with_clean_env { command["proc"].call } else command["proc"].call end (ENV["APP_ENV"] != "test") ? Process.detach(pid) : Process.wait(pid) end |
#notify(message) ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/tenter/helpers.rb', line 45 def notify() case when :initiated return 200, "Command initiated" when :missing halt 404, "Page not found" end end |