Skip to content

Instantly share code, notes, and snippets.

require 'rubygems'
require 'socket'
include Socket::Constants
lock = Mutex.new ; buf = []
client = TCPServer.new( 2201 )
server = TCPSocket.new( '10.x.x.x', 2202 )
def read
require 'socket'
require 'rubygems'
require 'monitor'
include Socket::Constants
lock = Mutex.new ; buf = []
client = Connection.new( 2201, '10.45.10.219' ).listen
server = Connection.new( 2202, '10.45.10.219' ).connect
stop = false
module Pages
module Resources
class Default < Waves::Resources::Base
def add
controller.create and redirect( paths.show )
end
before do
on( :get => [ 'admin', true ], :resource => :admin ) { authenticated? }
end
after do
...
end
always do
...
before:
authenticated?: { get: /?resource/?name/edit }
blog.feed: { get: /blog/?name, accepts: rss }
default.edit: { get: /?resource/?name/edit }
media.get: { get: /?media/?path[*] }
# special rule to handle rss blog feed
blog.feed when get /blog/:name and accepts rss
with resource = site
authenticated when before get /admin/*
login when get /login
authenticate when post /login
main when get /admin
update when post /admin
Breakpoint 1 at autocode.rb:52
/opt/local/lib/ruby/gems/1.8/gems/autocode-1.0.0/lib/autocode.rb:52
Kernel.load( path ) unless path.nil?
(rdb:3) path
"helpers/default.rb"
(rdb:3) self
Pages::Helpers
(rdb:3) Kernel.load( path )
true
(rdb:3) const_defined?( :Default )
lambda {
string_or_symbol = lambda { |arg| arg.kind_of?(String) || arg.kind_of?(Symbol) }
Waves::ResponseMixin.module_eval do
[ :models, :controllers, :views, :helpers ].each do |k|
functor( k ) { app[ k ] }
functor( k, string_or_symbol ) { |name| app( name )[ k ] }
end
end
}.call
ypcmc02106:pages dyoder$ irb
>> load 'startup.rb'
=> true
>> with
ArgumentError: wrong number of arguments (0 for 1)
from (irb):2:in `with'
from (irb):2
class Default
def add ; action( :create ) and redirect( paths.show ) ; end
def update
action( :update, name ) and redirect( resource( :site ).paths.main )
end
def delete
action( :delete, name ) and redirect( resource( :site ).paths.main )
end
def edit ; action( :find, name ) and render( :editor ) } ; end
def show ; action( :find, name ) and render( :show ) ; end