Skip to content

Instantly share code, notes, and snippets.

Avatar

ab5tract ab5tract

  • Amsterdam, Netherlands
View GitHub Profile
View jr.rbuby compatible Rakefile
begin
$: << 'lib'; %w( rubygems rake/testtask rake/rdoctask rake/gempackagetask extensions/all
utilities/string utilities/symbol date).each { |dep| require dep }
rescue LoadError => e
if e.message == 'no such file to load -- extensions/all'
puts "Better do `rake setup` to get all the fancies you're missing"
puts
else
raise e
end
View database-uri.rb
# I was hoping something like this might work ....
# The hope was that config.database could as easily be a string as a hash....
+++configurations/development.rb
module Blog
module Configurations
class Development < Default
View gist:2016
<ab5tract> we are trying to figure out the best/preferred way to interface with sequel
<ab5tract> so if thats what you recommend, we'l write a converter function that takes the hash and turns it into a URI
<jeremyevans> ab5tract: That function is already there. Database#uri
<ab5tract> well, thats handy :)
* wishdev (n=jwh@67.170.158.202) has joined #sequel
<ab5tract> jeremyevans, does Database#uri take a hash?
<ab5tract> its sort of a stupid question, but im not getting the kind of uri i would expect by doing:
<ab5tract> irb(main):007:0> q = Sequel::Database.new :adapter => 'jdbc', :database_type => 'postgresql', :host => 'localhost', :database => 'jblog', :user => 'waves'
<ab5tract> => #<Sequel::Database: "://waves@localhost/jblog">
<ab5tract> irb(main):009:0> q.uri
View gist:3361
/home/user/waves> ./bin/waves ~/ruby/xs
Ruby/Extensions: Binding#eval is already defined; not overwriting
Ruby/Extensions: Enumerable#none? is already defined; not overwriting
Ruby/Extensions: Enumerable#one? is already defined; not overwriting
Ruby/Extensions: Integer#even? is already defined; not overwriting
Ruby/Extensions: Integer#odd? is already defined; not overwriting
Ruby/Extensions: Symbol#to_proc is already defined; not overwriting
** Creating new Waves application ...
/usr/lib/ruby/1.8/fileutils.rb:1262:in `initialize': No such file or directory - /home/user/ruby/xs/Rakefile (Errno::ENOENT)
from /usr/lib/ruby/1.8/fileutils.rb:1262:in `open'
View gist:7318
module <%= @name %>
module Configurations
class Default < Waves::Configurations::Default
attribute 'dependencies'
dependencies ['first', 'second']
end
end
end
View application.rb
require 'foundations/simple'
module Blog
include Waves::Foundations::Simple
end
@ab5tract
ab5tract / cache.rb
Created Sep 4, 2008
Waves Gets Cached
View cache.rb
module Waves
class Cache
attr_accessor :cache
def initialize
@cache = {}
end
def [](key)
View mod_memcached.rb
# All @memcached's are now Waves.cache ... will this be a problem when in reality
# Waves.cache = Waves::Layers::Cache::MemcachedCache.new("localhost:11211") ?
# It's the self referentiality that is confusing me....
module Waves
module Layers
module Cache
View memcached.rb
# mostly golden
module Waves
module Layers
module Cache
class Memcached < Waves::Cache
require 'memcached'
View dependencies.rb
def self.dependencies( *args )
self['dependencies'] ||= Set.new
args.length == 0 ? self['dependencies'] + gems.dependencies :
( self['dependencies'] += ( args - gems.dependencies ) )
end