forked from assaf/vanity
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRakefile
119 lines (99 loc) · 3.27 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
require "rake/testtask"
spec = Gem::Specification.load(File.expand_path("vanity.gemspec", File.dirname(__FILE__)))
desc "Build the Gem"
task :build=>:test do
sh "gem build #{spec.name}.gemspec"
end
desc "Install #{spec.name} locally"
task :install=>:build do
sudo = "sudo" unless File.writable?( Gem::ConfigMap[:bindir])
sh "#{sudo} gem install #{spec.name}-#{spec.version}.gem"
end
desc "Push new release to gemcutter and git tag"
task :push=>:build do
sh "git push"
puts "Tagging version #{spec.version} .."
sh "git tag v#{spec.version}"
sh "git push --tag"
puts "Building and pushing gem .."
sh "gem push #{spec.name}-#{spec.version}.gem"
end
task :default=>:test
desc "Run all tests using Redis mock (also default task)"
Rake::TestTask.new do |task|
task.test_files = FileList['test/*_test.rb']
if Rake.application.options.trace
#task.warning = true
task.verbose = true
elsif Rake.application.options.silent
task.ruby_opts << "-W0"
else
task.verbose = true
end
end
desc "Run all tests using live redis server"
task "test:redis" do
ENV["REDIS"] = "true"
task(:test).invoke
end
task(:clobber) { rm_rf "tmp" }
begin
require "yard"
YARD::Rake::YardocTask.new(:yardoc) do |task|
task.files = FileList["lib/**/*.rb"].exclude("lib/vanity/backport.rb")
task.options = "--output", "html/api", "--title", "Vanity #{spec.version}", "--main", "README.rdoc", "--files", "CHANGELOG"
end
rescue LoadError
end
desc "Jekyll generates the main documentation (sans API)"
task(:jekyll) { sh "jekyll", "doc", "html" }
desc "Create documentation in docs directory (including API)"
task :docs=>[:jekyll, :yardoc]
desc "Remove temporary files and directories"
task(:clobber) { rm_rf "html" }
desc "Publish documentation to vanity.labnotes.org"
task :publish=>[:clobber, :docs] do
sh "rsync -cr --del --progress html/ labnotes.org:/var/www/vanity/"
end
task :report do
$LOAD_PATH.unshift "lib"
require "vanity"
require "timecop"
Vanity.playground.load_path = "test/experiments"
Vanity.playground.experiments.values.each(&:destroy)
Vanity.playground.metrics.values.each(&:destroy!)
Vanity.playground.reload!
# Control 182 35 19.23% N/A
# Treatment A 180 45 25.00% 1.33
# Treatment B 189 28 14.81% -1.13
# Treatment C 188 61 32.45% 2.94
Vanity.playground.experiment(:null_abc).instance_eval do
fake nil=>[182,35], :red=>[180,45], :green=>[189,28], :blue=>[188,61]
@created_at = (Date.today - 40).to_time
@completed_at = (Date.today - 35).to_time
end
Vanity.playground.experiment(:age_and_zipcode).instance_eval do
fake false=>[80,35], true=>[84,32]
@created_at = (Date.today - 30).to_time
@completed_at = (Date.today - 15).to_time
end
Vanity.context = Object.new
Vanity.context.instance_eval { def vanity_identity ; 0 ; end }
signups = 50
(Date.today - 90..Date.today).each do |date|
Timecop.travel date do
signups += rand(15) - 5
Vanity.playground.track! :signups, signups
end
end
cheers, yawns = 0, 0
(Date.today - 80..Date.today).each do |date|
Timecop.travel date do
cheers = cheers - 5 + rand(20)
Vanity.playground.track! :yawns, cheers
yawns = yawns - 5 + rand(30)
Vanity.playground.track! :cheers, yawns
end
end
Vanity::Commands.report ENV["OUTPUT"]
end