Sha256: 92ba870eab68565cd8514e5e46c6685a285e61a70153ebfe6ee5775bdcf9a2f7

Contents?: true

Size: 747 Bytes

Versions: 2

Compression:

Stored size: 747 Bytes

Contents

# Start me with : rackup rack.ru
# Default port is 9292

require File::expand_path('../yamlade', File.dirname(__FILE__)) # When installed, just use : require 'yamlade'

# PUBLIC ROOT

map '/' do
  run Rack::File.new(File.expand_path('./public', File.dirname(__FILE__)))
end

# EDIT

map '/edit' do
  run lambda { |env|
    request = Rack::Request.new(env)

    @conf = Yamlade.new("options.yml")
    if request.post?
      @conf.update(request['yaml'])
    end

    [ 200, {'Content-Type' => 'text/html'}, @conf.to_form(request.path_info) + "<br /><br /><a href='/inspect'>&gt;&gt; INSPECT</a>" ]
  }
end

# INSPECT

map '/inspect' do
  run lambda { |env|
    [ 200, {'Content-Type' => 'text/html'}, YAML.load_file("options.yml").inspect ]
  }
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
yamlade-0.0.2 examples/rack.ru
yamlade-0.0.1 examples/rack.ru