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 'bundler/inline' | |
gemfile(true) do | |
source 'https://rubygems.org' | |
gem 'rom', github: 'rom-rb/rom' | |
gem 'rom-sql', github: 'rom-rb/rom-sql' | |
gem 'rom-repository', github: 'rom-rb/rom-repository' | |
gem 'sqlite3' | |
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
class GivesCreditToPreferredCustomers | |
LOOK_BACK_PERIOD = 3 | |
def self.for_large_orders(sales_amount, added_credit) | |
# the has_large_purchases scope now takes two arguments | |
preferred_customers = Customer.has_large_purchases(sales_amount, LOOK_BACK_PERIOD) | |
preferred_customers.each do |customer| | |
customer.add_credit added_credit | |
end | |
end | |
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
# Depends on working pdftk, gm (GraphicsMagick), and pdftotext (Poppler) commands. | |
# Splits a pdf into batches of N pages, creates their thumbnails and icons, | |
# as specified in the Job options, gets the text for every page, and merges | |
# it all back into a tar archive for convenient download. | |
# | |
# See <tt>examples/process_pdfs_example.rb</tt> for more information. | |
class ProcessPdfs < CloudCrowd::Action | |
# Split up a large pdf into single-page pdfs. Batch them into 'batch_size' | |
# chunks for processing. The double pdftk shuffle fixes the document xrefs. |
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
describe Tweet do | |
describe "basic fetching of tweets" do | |
describe "(search conditions)" do | |
attr_reader :new_search | |
before do | |
@new_search = mock(Twitter::Search, :null_object => true) | |
Twitter::Search.should_receive(:new).and_return(new_search) | |
end | |
after do | |
Tweet.fetch_new_tweets |