This file contains hidden or 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 'rspec' | |
| require './search_scraper' | |
| require 'em-synchrony' | |
| def tmp_dir() File.join(File.dirname(__FILE__), 'tmp') ; end | |
| def ripd_dir() File.join(tmp_dir, 'social.network.twitter') ; end | |
| def cfg_hash | |
| { | |
| :namespace => "social.network.twitter", |
This file contains hidden or 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
| # Arbitrary class illustrating desired implementation of init options for a class | |
| # How do I spec this behavior? especially if there are many attrs and conditions? | |
| class Foo | |
| attr_accessor :bar | |
| def initialize(bar) | |
| # call an exiting method unless some condition is met by the variable passed in. Foo is an outward-facing class | |
| log_and_fail unless bar |
This file contains hidden or 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
| -- | |
| -- If your data looks like this: | |
| -- | |
| -- {"foo":1,"bar":1} | |
| -- {"foo":2,"bar":2} | |
| -- {"foo":3,"bar":3} | |
| -- | |
| -- Then write your store function this way; it will respect nested hashes and arrays if they are JSONed properly | |
| -- | |
| register wonderdog-1.0-SNAPSHOT.jar; |
This file contains hidden or 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
| # The way a wukong script is written regularly: | |
| require 'wukong' | |
| class WukongToFlume < Wukong::Streamer::LineStreamer | |
| def process(body, *args) | |
| # take input, do some processing | |
| processed = body.to_s.reverse | |
| yield [processed] |
This file contains hidden or 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
| #run me with `rspec -fd --color rspec_examples.rb` | |
| require 'rspec' | |
| # The class we want to test | |
| class YoMama | |
| attr_accessor :makeup | |
| def fat?() true ; end | |
This file contains hidden or 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 'gorillib/model' | |
| class Joke | |
| include Gorillib::Model | |
| field :is_so_fat, String, :default => "When she sits around the house, she sits *AROUND* the house" | |
| field :wears, String | |
| end |
This file contains hidden or 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
| Wukong.processor(:ogify) do | |
| def process(record) | |
| emit(record.gsub(/(a\w|e\w|i\w|o\w|u\w)/, 'og')) | |
| end | |
| end | |
| Wukong.processor(:poify) do |
This file contains hidden or 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 'gorillib/model' | |
| # In this first example, we have a User that will have a first and last name, and a synthetic secret_id. | |
| # The secret_id could be provided, but if it is not, we want to supply a default based on the names. | |
| # We need access to the other fields being received, so we used a delayed default: | |
| class User | |
| include Gorillib::Model | |
| field :first_name, String | |
| field :last_name, String |
This file contains hidden or 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
| class S3Spout { | |
| class S3Client { // Travis will write | |
| // Make using S3 easy like a boss | |
| } | |
| private S3Client _client; // Travis will write |
This file contains hidden or 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 'json' | |
| class DiffOMatic | |
| attr_reader :info | |
| def name(*_) ; end | |
| def description(*_) ; end |
OlderNewer