Switch

Set and retrieve an arbitrary switch flag via GET and POST. Requires Rack.

Use

Switch.new("light", { :url_namespace => "/switch", :file_location => "/tmp" })

Functionality

This will expose: 

A route to get the current state of the switch:
/switch/light

A route for flicking the switch to ON:
/switch/light/on

A route for flicking the switch to OFF:
/switch/light/off

Switch state possibilities

The switch state is stored in a file:
/tmp/light_switch

File doesn't exist
    switch is on
File contains ON
    switch is on
File contains OFF
    server is off

An example config.ru file for mounting alongside Padrino:

require ::File.dirname(__FILE__) + '/config/boot.rb'
require 'switch'
run Rack::Cascade.new([
    Switch.new("aframe_webapp_status"), 
    Padrino.application,
])