Skip to content

Instantly share code, notes, and snippets.

task :test do
require "minitest/autorun"
Dir["spec/**/*_spec.rb"] { |f| require f }
end
@benolee
benolee / README.md
Last active December 16, 2015 16:40

r5 Notes

here's most of the core classes, modules, traits, and methods. i probably missed some, but it's a start.

the number after method names is the arity.

# Classes:

Object
@benolee
benolee / Gemfile
Last active December 16, 2015 16:19
source 'https://rubygems.org'
gem 'rails'
$ rails r 'File.write("./viz.html", Rails.application.routes.router.visualizer)'
$ ruby -r webrick -e "s = WEBrick::HTTPServer.new(:Port => 8080, :DocumentRoot => Dir.pwd); trap('INT') { s.shutdown }; s.start"
$ open "http://localhost:8080/viz.html"
*.c
*.rl
class Dot
class Node
attr_reader :children, :name, :started
attr_accessor :finished
def initialize name, fields = [], started = Time.now
@name = name
@fields = fields
@children = []
@started = started
diff --git a/lib/middleware/visitor.rb b/lib/middleware/visitor.rb
new file mode 100644
index 0000000..fdfb96d
--- /dev/null
+++ b/lib/middleware/visitor.rb
@@ -0,0 +1,100 @@
+module Middleware
+ class Visitor
+ class Node < Struct.new(:id, :name)
+ end
@benolee
benolee / ugh.rb
Created April 25, 2013 01:30 — forked from tenderlove/ugh.rb
####
# It must output this:
#
# hello one two
# world one two
#
class Filter
def initialize name
@name = name
end
def future # :block:
thread = Thread.new do
Thread.current.abort_on_exception = false
yield
end
lambda { thread.value }
end
def compose(proc) # :block:
@benolee
benolee / fbr.rb
Created April 23, 2013 02:34 — forked from tmm1/fbr.rb
# Poor Man's Fiber (API compatible Thread based Fiber implementation for Ruby 1.8)
# (c) 2008 Aman Gupta (tmm1)
unless defined? Fiber
require 'thread'
class FiberError < StandardError; end
class Fiber
def initialize