Skip to content

Instantly share code, notes, and snippets.

@rmg
Created February 10, 2016 15:55
Show Gist options
  • Save rmg/32b886b2874a67d7db5f to your computer and use it in GitHub Desktop.
Save rmg/32b886b2874a67d7db5f to your computer and use it in GitHub Desktop.
mktmpio examples
# Inspiring DSL for temp directories
Dir.mktmpdir {|dir|
# use the directory...
open("#{dir}/foo", "w") { ... }
}
# Provide the same ergonomics for databases
mktmpio(:postgres) {|db|
pg.connect(db) {|conn|
# use the database...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment