Record responses and play them from local cache.
Installation:
git clone https://gist.github.com/4368cae5de3f7384fd08.git recordplayer
mkdir ~/.recordplayer
Usage:
require 'torquebox/messaging' | |
require 'torquebox/messaging/connection_factory' | |
require 'torquebox/messaging/destination' | |
module TorqueBox | |
module Messaging | |
class Destination | |
def publish_each(messages, options = {}) | |
wait_for_destination(options[:startup_timeout]) do | |
with_session(options) do |session| |
.bundle | |
bundle |
# Idea from: http://www.developingandstuff.com/2014/06/disable-dangerous-rake-tasks-in.html | |
if Rails.env.production? | |
Rake::Task.tasks.each do |task| | |
next unless task.name.start_with?("db:") | |
Rake::Task[task].enhance do | |
abort "This task is disabled in production." | |
end | |
end |
jruby 1.7.20 (1.9.3p551) 2015-05-04 3086e6a on Java HotSpot(TM) 64-Bit Server VM 1.7.0_79-b15 +jit [darwin-x86_64] | |
>> $LOAD_PATH << File.expand_path('../vendor', __FILE__) | |
>> require "frak-0.1.7-SNAPSHOT-standalone.jar" | |
=> true | |
>> Java::clojure.lang.RT | |
=> Java::ClojureLang::RT | |
>> require "jrclj" | |
=> true |
# encoding: utf-8 | |
# https://gist.github.com/kml/ce164e1e0c1bde2ab96d | |
require "mongoid" | |
module Mongoid | |
module Extensions | |
module DefaultScopeOnlyId | |
def self.included(base) |
require "active_attr" | |
require "memoist" | |
class Model | |
include ActiveAttr::Model | |
extend Memoist | |
# by default ActiveAttr calls typecaster every time attribute reader is called | |
# this patch adds memoization | |
# https://github.com/cgriego/active_attr/blob/v0.8.5/lib/active_attr/attributes.rb#L199 |
class ClosedStruct < OpenStruct | |
# https://github.com/ruby/ruby/blob/trunk/lib/ostruct.rb#L176 | |
def method_missing(mid, *args) | |
return super if @table.has_key?(mid.to_sym) | |
raise NoMethodError, "undefined method `#{mid}' for #{self}" | |
end | |
end |
source :rubygems | |
gem 'rack' | |
gem 'json' | |
gem 'torquebox-rake-support' | |
gem 'rdiscount' | |
# ... | |
options = {properties: {}} | |
options[:properties]['_HQ_SCHED_DELIVERY'] = Time.now.to_i * 1000 + 30.seconds * 1000 # milis | |
download_queue.publish({message: {photo_id: photo.id}}, options) |
Record responses and play them from local cache.
Installation:
git clone https://gist.github.com/4368cae5de3f7384fd08.git recordplayer
mkdir ~/.recordplayer
Usage: