This file contains 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
# | |
# Installs ree using rvm. | |
# | |
require_recipe "rvm" | |
bash "Install ree in rvm" do | |
user "root" | |
code "rvm install ree" | |
not_if "rvm list | grep ree" |
This file contains 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 | |
require 'rubygems' | |
require 'httparty' | |
class FakeRestJsonApi | |
include HTTParty | |
base_uri 'http://google.com/THIS_IS_A_FAKE_URL' | |
headers 'Accept' => 'application/json' | |
default_params :output => 'json' |
This file contains 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
#### | |
## Ruby port of "A Tale of 3 Nightclubs" | |
## | |
## Based on Scala version here: https://gist.github.com/970717 | |
## | |
## Demonstrates applicative validation in Ruby, inspired by the blog post: | |
## "An example of applicative validation in FSharpx" | |
## (http://bugsquash.blogspot.com/2012/03/example-of-applicative-validation-in.html) | |
#### |
This file contains 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 'pp' | |
require 'rumonade' | |
User = Struct.new(:user_id, :name) | |
Post = Struct.new(:post_id, :text, :comments) | |
Comment = Struct.new(:user, :post, :text) | |
Users = [User.new(101, "Dave")] | |
Posts = [Post.new(201, "Welcome to my blog", [])] |
This file contains 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
# A benchmarking script for Rubygems' linked list implementation. | |
# See https://github.com/rubygems/rubygems/pull/1200 | |
# | |
# To run, clone the rubygems repo and place this file in the | |
# root of the checkout. Then run: | |
# | |
# ruby ./benchmark_rubygems_list.rb | |
# | |
require 'benchmark' | |
require './lib/rubygems/util/list.rb' |
This file contains 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 'docile' | |
# Family tree node, mother and father are Person values as well | |
Person = Struct.new(:name, :mother, :father) | |
# Recursive dsl in a mutating builder using Docile | |
def person(&block) | |
Docile.dsl_eval(PersonBuilder.new, &block).build | |
end |
This file contains 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
## | |
# Examples of trying document classes created with Values gem, | |
# using YARD. | |
# https://github.com/tcrayford/Values | |
## | |
# Works 100%: Assigning a new Struct class to a constant | |
# And you can document the fields using `@attr`. | |
# | |
# @attr [Array<String>] a names of stuff |
This file contains 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
source 'https://rubygems.org' | |
gem 'docile' |
This file contains 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
# Workaround for https://github.com/ruby-concurrency/concurrent-ruby/issues/611 | |
# | |
# This approach works to *lazily* compose a chained future of | |
# sequential steps, where each step is a *zipped* future of a | |
# set of futures to execute in parallel at that step. | |
# | |
# Works with: | |
# | |
# gem install concurrent-ruby-edge -v 0.2.3.pre3 | |
# |
This file contains 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
# Simple immutable value objects for ruby. | |
# | |
# @example Make a new value class: | |
# Point = Value.new(:x, :y) | |
# | |
# @example And use it: | |
# p = Point.new(1, 0) | |
# p.x | |
# #=> 1 | |
# p.y |
OlderNewer