This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
class BufferedString | |
class Buffer < String | |
def initialize | |
@eof = false | |
super | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# goes in start method for the server | |
if m = Waves.config.monitor | |
fork { m.call } | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Waves | |
module Servers | |
class Base | |
attr_accessor :application, :host, :port, :server | |
# returns the PID of the server process | |
def self.run( application, host, port ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Waves | |
module Foundations | |
module Compact | |
app.module_eval <<-_CODE | |
module Resources | |
class Map | |
include Waves::Resources::Mixin | |
handler( Exception ) do | |
Waves::Views::Errors.new( request ).server_error_500 | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Dog | |
attr_accessor :request | |
def initialize( request ) | |
@request = request | |
end | |
def get | |
“Fido” if request.path == ‘/name’ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'autocode' | |
class Object | |
include AutoCode | |
# fall back to creating a module that automatically loads | |
# from a directory of the snake-cased name, ex: Foo::Bar => 'foo/bar.rb' | |
auto_create_module true, Module.new do | |
auto_load true, :directory => lambda { self.class.name.snake_case } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module HelloWorld | |
include Waves::Foundations::Compact | |
module Resources | |
class Map | |
include Hoshi::View :html4 | |
on( :get, [ 'hello', :name ] ) { hello( captured.name ) } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module MyApp | |
module Configurations | |
class Production < Development | |
host '0.0.0.0' | |
port 80 | |
application do | |
use Rack::Static, :root => "public" | |
run Waves::Dispatchers::Fast.new | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module HelloWorld | |
include Waves::Foundations::Compact | |
module Resources | |
class Map | |
on( :get, [], :query => { :name => true } ) { "Hello #{query.name}" } | |
end | |
end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Pages | |
module Resources | |
class Default | |
include Waves::Resources::Mixin | |
include Pages::ResponseMixin | |
on( :get, [ :resource, { :name => 'home' }] ) { show } | |
# matching against / |