vanity 1.3.0 → 1.4.0.beta
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +61 -3
- data/Gemfile +22 -14
- data/README.rdoc +9 -4
- data/Rakefile +72 -12
- data/bin/vanity +16 -4
- data/lib/vanity.rb +7 -5
- data/lib/vanity/adapters/abstract_adapter.rb +135 -0
- data/lib/vanity/adapters/mock_adapter.rb +157 -0
- data/lib/vanity/adapters/mongo_adapter.rb +162 -0
- data/lib/vanity/adapters/redis_adapter.rb +154 -0
- data/lib/vanity/backport.rb +0 -17
- data/lib/vanity/commands/upgrade.rb +34 -0
- data/lib/vanity/experiment/ab_test.rb +46 -41
- data/lib/vanity/experiment/base.rb +13 -15
- data/lib/vanity/frameworks/rails.rb +5 -9
- data/lib/vanity/metric/active_record.rb +10 -4
- data/lib/vanity/metric/base.rb +46 -23
- data/lib/vanity/metric/google_analytics.rb +7 -0
- data/lib/vanity/metric/remote.rb +53 -0
- data/lib/vanity/playground.rb +133 -49
- data/test/{ab_test_test.rb → experiment/ab_test.rb} +47 -3
- data/test/{experiment_test.rb → experiment/base_test.rb} +8 -8
- data/test/metric/active_record_test.rb +253 -0
- data/test/metric/base_test.rb +293 -0
- data/test/metric/google_analytics_test.rb +104 -0
- data/test/metric/remote_test.rb +108 -0
- data/test/myapp/app/controllers/application_controller.rbc +66 -0
- data/test/myapp/app/controllers/main_controller.rb +3 -3
- data/test/myapp/app/controllers/main_controller.rbc +347 -0
- data/test/myapp/config/boot.rbc +2534 -0
- data/test/myapp/config/environment.rbc +403 -0
- data/test/myapp/config/routes.rbc +174 -0
- data/test/myapp/log/production.log +2601 -0
- data/test/passenger_test.rb +14 -5
- data/test/passenger_test.rbc +0 -0
- data/test/playground_test.rbc +256 -0
- data/test/rails_test.rb +75 -22
- data/test/rails_test.rbc +4086 -0
- data/test/test_helper.rb +30 -7
- data/test/test_helper.rbc +4297 -0
- data/vanity.gemspec +6 -2
- metadata +74 -73
- data/lib/vanity/commands.rb +0 -2
- data/lib/vanity/mock_redis.rb +0 -76
- data/test/metric_test.rb +0 -622
- data/vendor/cache/RedCloth-4.2.2.gem +0 -0
- data/vendor/cache/actionmailer-2.3.5.gem +0 -0
- data/vendor/cache/actionpack-2.3.5.gem +0 -0
- data/vendor/cache/activerecord-2.3.5.gem +0 -0
- data/vendor/cache/activeresource-2.3.5.gem +0 -0
- data/vendor/cache/activesupport-2.3.5.gem +0 -0
- data/vendor/cache/autotest-4.2.7.gem +0 -0
- data/vendor/cache/autotest-fsevent-0.2.1.gem +0 -0
- data/vendor/cache/autotest-growl-0.2.0.gem +0 -0
- data/vendor/cache/bundler-0.9.7.gem +0 -0
- data/vendor/cache/classifier-1.3.1.gem +0 -0
- data/vendor/cache/directory_watcher-1.3.1.gem +0 -0
- data/vendor/cache/fastthread-1.0.7.gem +0 -0
- data/vendor/cache/garb-0.7.0.gem +0 -0
- data/vendor/cache/happymapper-0.3.0.gem +0 -0
- data/vendor/cache/jekyll-0.5.7.gem +0 -0
- data/vendor/cache/libxml-ruby-1.1.3.gem +0 -0
- data/vendor/cache/liquid-2.0.0.gem +0 -0
- data/vendor/cache/maruku-0.6.0.gem +0 -0
- data/vendor/cache/mocha-0.9.8.gem +0 -0
- data/vendor/cache/open4-1.0.1.gem +0 -0
- data/vendor/cache/passenger-2.2.9.gem +0 -0
- data/vendor/cache/rack-1.0.1.gem +0 -0
- data/vendor/cache/rails-2.3.5.gem +0 -0
- data/vendor/cache/rake-0.8.7.gem +0 -0
- data/vendor/cache/rubygems-update-1.3.5.gem +0 -0
- data/vendor/cache/shoulda-2.10.3.gem +0 -0
- data/vendor/cache/sqlite3-ruby-1.2.5.gem +0 -0
- data/vendor/cache/stemmer-1.0.1.gem +0 -0
- data/vendor/cache/syntax-1.0.0.gem +0 -0
- data/vendor/cache/sys-uname-0.8.4.gem +0 -0
- data/vendor/cache/timecop-0.3.4.gem +0 -0
- data/vendor/redis-rb/LICENSE +0 -20
- data/vendor/redis-rb/README.markdown +0 -36
- data/vendor/redis-rb/Rakefile +0 -62
- data/vendor/redis-rb/bench.rb +0 -44
- data/vendor/redis-rb/benchmarking/suite.rb +0 -24
- data/vendor/redis-rb/benchmarking/worker.rb +0 -71
- data/vendor/redis-rb/bin/distredis +0 -33
- data/vendor/redis-rb/examples/basic.rb +0 -16
- data/vendor/redis-rb/examples/incr-decr.rb +0 -18
- data/vendor/redis-rb/examples/list.rb +0 -26
- data/vendor/redis-rb/examples/sets.rb +0 -36
- data/vendor/redis-rb/lib/dist_redis.rb +0 -124
- data/vendor/redis-rb/lib/hash_ring.rb +0 -128
- data/vendor/redis-rb/lib/pipeline.rb +0 -21
- data/vendor/redis-rb/lib/redis.rb +0 -370
- data/vendor/redis-rb/lib/redis/raketasks.rb +0 -1
- data/vendor/redis-rb/profile.rb +0 -22
- data/vendor/redis-rb/redis-rb.gemspec +0 -30
- data/vendor/redis-rb/spec/redis_spec.rb +0 -637
- data/vendor/redis-rb/spec/spec_helper.rb +0 -4
- data/vendor/redis-rb/speed.rb +0 -16
- data/vendor/redis-rb/tasks/redis.tasks.rb +0 -140
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/vendor/cache/garb-0.7.0.gem
DELETED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/vendor/cache/rack-1.0.1.gem
DELETED
Binary file
|
Binary file
|
data/vendor/cache/rake-0.8.7.gem
DELETED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/vendor/redis-rb/LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2009 Ezra Zygmuntowicz
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -1,36 +0,0 @@
|
|
1
|
-
# redis-rb
|
2
|
-
|
3
|
-
A ruby client library for the redis key value storage system.
|
4
|
-
|
5
|
-
## Information about redis
|
6
|
-
|
7
|
-
Redis is a key value store with some interesting features:
|
8
|
-
1. It's fast.
|
9
|
-
2. Keys are strings but values can have types of "NONE", "STRING", "LIST", or "SET". List's can be atomically push'd, pop'd, lpush'd, lpop'd and indexed. This allows you to store things like lists of comments under one key while retaining the ability to append comments without reading and putting back the whole list.
|
10
|
-
|
11
|
-
See [redis on code.google.com](http://code.google.com/p/redis/wiki/README) for more information.
|
12
|
-
|
13
|
-
See the build on [RunCodeRun](http://runcoderun.com/rsanheim/redis-rb)
|
14
|
-
|
15
|
-
## Dependencies
|
16
|
-
|
17
|
-
1. rspec -
|
18
|
-
sudo gem install rspec
|
19
|
-
|
20
|
-
2. redis -
|
21
|
-
|
22
|
-
rake redis:install
|
23
|
-
|
24
|
-
2. dtach -
|
25
|
-
|
26
|
-
rake dtach:install
|
27
|
-
|
28
|
-
3. git - git is the new black.
|
29
|
-
|
30
|
-
## Setup
|
31
|
-
|
32
|
-
Use the tasks mentioned above (in Dependencies) to get your machine setup.
|
33
|
-
|
34
|
-
## Examples
|
35
|
-
|
36
|
-
Check the examples/ directory. *Note* you need to have redis-server running first.
|
data/vendor/redis-rb/Rakefile
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'rake/gempackagetask'
|
3
|
-
require 'rubygems/specification'
|
4
|
-
require 'date'
|
5
|
-
require 'spec/rake/spectask'
|
6
|
-
require 'tasks/redis.tasks'
|
7
|
-
|
8
|
-
|
9
|
-
GEM = 'redis'
|
10
|
-
GEM_NAME = 'redis'
|
11
|
-
GEM_VERSION = '0.1'
|
12
|
-
AUTHORS = ['Ezra Zygmuntowicz', 'Taylor Weibley', 'Matthew Clark', 'Brian McKinney', 'Salvatore Sanfilippo', 'Luca Guidi']
|
13
|
-
EMAIL = "ez@engineyard.com"
|
14
|
-
HOMEPAGE = "http://github.com/ezmobius/redis-rb"
|
15
|
-
SUMMARY = "Ruby client library for redis key value storage server"
|
16
|
-
|
17
|
-
spec = Gem::Specification.new do |s|
|
18
|
-
s.name = GEM
|
19
|
-
s.version = GEM_VERSION
|
20
|
-
s.platform = Gem::Platform::RUBY
|
21
|
-
s.has_rdoc = true
|
22
|
-
s.extra_rdoc_files = ["LICENSE"]
|
23
|
-
s.summary = SUMMARY
|
24
|
-
s.description = s.summary
|
25
|
-
s.authors = AUTHORS
|
26
|
-
s.email = EMAIL
|
27
|
-
s.homepage = HOMEPAGE
|
28
|
-
s.add_dependency "rspec"
|
29
|
-
s.require_path = 'lib'
|
30
|
-
s.autorequire = GEM
|
31
|
-
s.files = %w(LICENSE README.markdown Rakefile) + Dir.glob("{lib,tasks,spec}/**/*")
|
32
|
-
end
|
33
|
-
|
34
|
-
task :default => :spec
|
35
|
-
|
36
|
-
desc "Run specs"
|
37
|
-
Spec::Rake::SpecTask.new do |t|
|
38
|
-
t.spec_files = FileList['spec/**/*_spec.rb']
|
39
|
-
t.spec_opts = %w(-fs --color)
|
40
|
-
end
|
41
|
-
|
42
|
-
Rake::GemPackageTask.new(spec) do |pkg|
|
43
|
-
pkg.gem_spec = spec
|
44
|
-
end
|
45
|
-
|
46
|
-
desc "install the gem locally"
|
47
|
-
task :install => [:package] do
|
48
|
-
sh %{sudo gem install pkg/#{GEM}-#{GEM_VERSION}}
|
49
|
-
end
|
50
|
-
|
51
|
-
desc "create a gemspec file"
|
52
|
-
task :make_spec do
|
53
|
-
File.open("#{GEM}.gemspec", "w") do |file|
|
54
|
-
file.puts spec.to_ruby
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
desc "Run all examples with RCov"
|
59
|
-
Spec::Rake::SpecTask.new(:rcov) do |t|
|
60
|
-
t.spec_files = FileList['spec/**/*_spec.rb']
|
61
|
-
t.rcov = true
|
62
|
-
end
|
data/vendor/redis-rb/bench.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'benchmark'
|
2
|
-
$:.push File.join(File.dirname(__FILE__), 'lib')
|
3
|
-
require 'redis'
|
4
|
-
|
5
|
-
times = 20000
|
6
|
-
|
7
|
-
@r = Redis.new#(:debug => true)
|
8
|
-
@r['foo'] = "The first line we sent to the server is some text"
|
9
|
-
|
10
|
-
Benchmark.bmbm do |x|
|
11
|
-
x.report("set") do
|
12
|
-
20000.times do |i|
|
13
|
-
@r["set#{i}"] = "The first line we sent to the server is some text"; @r["foo#{i}"]
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
x.report("set (pipelined)") do
|
18
|
-
@r.pipelined do |pipeline|
|
19
|
-
20000.times do |i|
|
20
|
-
pipeline["set_pipelined#{i}"] = "The first line we sent to the server is some text"; @r["foo#{i}"]
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
x.report("push+trim") do
|
26
|
-
20000.times do |i|
|
27
|
-
@r.push_head "push_trim#{i}", i
|
28
|
-
@r.list_trim "push_trim#{i}", 0, 30
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
x.report("push+trim (pipelined)") do
|
33
|
-
@r.pipelined do |pipeline|
|
34
|
-
20000.times do |i|
|
35
|
-
pipeline.push_head "push_trim_pipelined#{i}", i
|
36
|
-
pipeline.list_trim "push_trim_pipelined#{i}", 0, 30
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
@r.keys('*').each do |k|
|
43
|
-
@r.delete k
|
44
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
|
3
|
-
def run_in_background(command)
|
4
|
-
fork { system command }
|
5
|
-
end
|
6
|
-
|
7
|
-
def with_all_segments(&block)
|
8
|
-
0.upto(9) do |segment_number|
|
9
|
-
block_size = 100000
|
10
|
-
start_index = segment_number * block_size
|
11
|
-
end_index = start_index + block_size - 1
|
12
|
-
block.call(start_index, end_index)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
#with_all_segments do |start_index, end_index|
|
17
|
-
# puts "Initializing keys from #{start_index} to #{end_index}"
|
18
|
-
# system "ruby worker.rb initialize #{start_index} #{end_index} 0"
|
19
|
-
#end
|
20
|
-
|
21
|
-
with_all_segments do |start_index, end_index|
|
22
|
-
run_in_background "ruby worker.rb write #{start_index} #{end_index} 10"
|
23
|
-
run_in_background "ruby worker.rb read #{start_index} #{end_index} 1"
|
24
|
-
end
|
@@ -1,71 +0,0 @@
|
|
1
|
-
BENCHMARK_ROOT = File.dirname(__FILE__)
|
2
|
-
REDIS_ROOT = File.join(BENCHMARK_ROOT, "..", "lib")
|
3
|
-
|
4
|
-
$: << REDIS_ROOT
|
5
|
-
require 'redis'
|
6
|
-
require 'benchmark'
|
7
|
-
|
8
|
-
def show_usage
|
9
|
-
puts <<-EOL
|
10
|
-
Usage: worker.rb [read:write] <start_index> <end_index> <sleep_msec>
|
11
|
-
EOL
|
12
|
-
end
|
13
|
-
|
14
|
-
def shift_from_argv
|
15
|
-
value = ARGV.shift
|
16
|
-
unless value
|
17
|
-
show_usage
|
18
|
-
exit -1
|
19
|
-
end
|
20
|
-
value
|
21
|
-
end
|
22
|
-
|
23
|
-
operation = shift_from_argv.to_sym
|
24
|
-
start_index = shift_from_argv.to_i
|
25
|
-
end_index = shift_from_argv.to_i
|
26
|
-
sleep_msec = shift_from_argv.to_i
|
27
|
-
sleep_duration = sleep_msec/1000.0
|
28
|
-
|
29
|
-
redis = Redis.new
|
30
|
-
|
31
|
-
case operation
|
32
|
-
when :initialize
|
33
|
-
|
34
|
-
start_index.upto(end_index) do |i|
|
35
|
-
redis[i] = 0
|
36
|
-
end
|
37
|
-
|
38
|
-
when :clear
|
39
|
-
|
40
|
-
start_index.upto(end_index) do |i|
|
41
|
-
redis.delete(i)
|
42
|
-
end
|
43
|
-
|
44
|
-
when :read, :write
|
45
|
-
|
46
|
-
puts "Starting to #{operation} at segment #{end_index + 1}"
|
47
|
-
|
48
|
-
loop do
|
49
|
-
t1 = Time.now
|
50
|
-
start_index.upto(end_index) do |i|
|
51
|
-
case operation
|
52
|
-
when :read
|
53
|
-
redis.get(i)
|
54
|
-
when :write
|
55
|
-
redis.incr(i)
|
56
|
-
else
|
57
|
-
raise "Unknown operation: #{operation}"
|
58
|
-
end
|
59
|
-
sleep sleep_duration
|
60
|
-
end
|
61
|
-
t2 = Time.now
|
62
|
-
|
63
|
-
requests_processed = end_index - start_index
|
64
|
-
time = t2 - t1
|
65
|
-
puts "#{t2.strftime("%H:%M")} [segment #{end_index + 1}] : Processed #{requests_processed} requests in #{time} seconds - #{(requests_processed/time).round} requests/sec"
|
66
|
-
end
|
67
|
-
|
68
|
-
else
|
69
|
-
raise "Unknown operation: #{operation}"
|
70
|
-
end
|
71
|
-
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
|
3
|
-
class RedisCluster
|
4
|
-
|
5
|
-
def initialize(opts={})
|
6
|
-
opts = {:port => 6379, :host => 'localhost', :basedir => "#{Dir.pwd}/rdsrv" }.merge(opts)
|
7
|
-
FileUtils.mkdir_p opts[:basedir]
|
8
|
-
opts[:size].times do |i|
|
9
|
-
port = opts[:port] + i
|
10
|
-
FileUtils.mkdir_p "#{opts[:basedir]}/#{port}"
|
11
|
-
File.open("#{opts[:basedir]}/#{port}.conf", 'w'){|f| f.write(make_config(port, "#{opts[:basedir]}/#{port}", "#{opts[:basedir]}/#{port}.log"))}
|
12
|
-
system(%Q{#{File.join(File.expand_path(File.dirname(__FILE__)), "../redis/redis-server #{opts[:basedir]}/#{port}.conf &" )}})
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def make_config(port=6379, data=port, logfile='stdout', loglevel='debug')
|
17
|
-
config = %Q{
|
18
|
-
timeout 300
|
19
|
-
save 900 1
|
20
|
-
save 300 10
|
21
|
-
save 60 10000
|
22
|
-
dir #{data}
|
23
|
-
loglevel #{loglevel}
|
24
|
-
logfile #{logfile}
|
25
|
-
databases 16
|
26
|
-
port #{port}
|
27
|
-
}
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
|
33
|
-
RedisCluster.new :size => 4
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'redis'
|
3
|
-
|
4
|
-
r = Redis.new
|
5
|
-
|
6
|
-
puts
|
7
|
-
p 'incr'
|
8
|
-
r.delete 'counter'
|
9
|
-
|
10
|
-
p r.incr('counter')
|
11
|
-
p r.incr('counter')
|
12
|
-
p r.incr('counter')
|
13
|
-
|
14
|
-
puts
|
15
|
-
p 'decr'
|
16
|
-
p r.decr('counter')
|
17
|
-
p r.decr('counter')
|
18
|
-
p r.decr('counter')
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'redis'
|
3
|
-
|
4
|
-
r = Redis.new
|
5
|
-
|
6
|
-
r.delete 'logs'
|
7
|
-
|
8
|
-
puts
|
9
|
-
|
10
|
-
p "pushing log messages into a LIST"
|
11
|
-
r.push_tail 'logs', 'some log message'
|
12
|
-
r.push_tail 'logs', 'another log message'
|
13
|
-
r.push_tail 'logs', 'yet another log message'
|
14
|
-
r.push_tail 'logs', 'also another log message'
|
15
|
-
|
16
|
-
puts
|
17
|
-
p 'contents of logs LIST'
|
18
|
-
|
19
|
-
p r.list_range('logs', 0, -1)
|
20
|
-
|
21
|
-
puts
|
22
|
-
p 'Trim logs LIST to last 2 elements(easy circular buffer)'
|
23
|
-
|
24
|
-
r.list_trim('logs', -2, -1)
|
25
|
-
|
26
|
-
p r.list_range('logs', 0, -1)
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'redis'
|
3
|
-
|
4
|
-
r = Redis.new
|
5
|
-
|
6
|
-
r.delete 'foo-tags'
|
7
|
-
r.delete 'bar-tags'
|
8
|
-
|
9
|
-
puts
|
10
|
-
p "create a set of tags on foo-tags"
|
11
|
-
|
12
|
-
r.set_add 'foo-tags', 'one'
|
13
|
-
r.set_add 'foo-tags', 'two'
|
14
|
-
r.set_add 'foo-tags', 'three'
|
15
|
-
|
16
|
-
puts
|
17
|
-
p "create a set of tags on bar-tags"
|
18
|
-
|
19
|
-
r.set_add 'bar-tags', 'three'
|
20
|
-
r.set_add 'bar-tags', 'four'
|
21
|
-
r.set_add 'bar-tags', 'five'
|
22
|
-
|
23
|
-
puts
|
24
|
-
p 'foo-tags'
|
25
|
-
|
26
|
-
p r.set_members('foo-tags')
|
27
|
-
|
28
|
-
puts
|
29
|
-
p 'bar-tags'
|
30
|
-
|
31
|
-
p r.set_members('bar-tags')
|
32
|
-
|
33
|
-
puts
|
34
|
-
p 'intersection of foo-tags and bar-tags'
|
35
|
-
|
36
|
-
p r.set_intersect('foo-tags', 'bar-tags')
|