Sha256: 9fb1f91b022b307e912611ec5a18beb90d62be5e9730f3c112e0395d9479e30a

Contents?: true

Size: 702 Bytes

Versions: 2

Compression:

Stored size: 702 Bytes

Contents

require 'sinatra/base'

module FakeSQS
  class WebInterface < Sinatra::Base

    configure do
      set :sqs, FakeSQS.server(port: settings.port, host: settings.bind)
    end

    helpers do

      def action
        underscore(params.fetch("Action"))
      end

      def underscore(string)
        string.gsub(/([A-Z])/) { |m| "_#{m[0]}".downcase }.sub(/^_/, '')
      end

    end

    get "/" do
      200
    end

    delete "/" do
      settings.sqs.reset
      200
    end

    put "/" do
      settings.sqs.expire
      200
    end

    post "/" do
      settings.sqs.call(action, params)
    end

    post "/:queue" do |queue|
      settings.sqs.call(action, queue, params)
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fake_sqs-0.0.3 lib/fake_sqs/web_interface.rb
fake_sqs-0.0.2 lib/fake_sqs/web_interface.rb