fiverr-vanity 1.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. data/.autotest +22 -0
  2. data/.gitignore +7 -0
  3. data/.rvmrc +3 -0
  4. data/.travis.yml +13 -0
  5. data/CHANGELOG +374 -0
  6. data/Gemfile +28 -0
  7. data/MIT-LICENSE +21 -0
  8. data/README.rdoc +108 -0
  9. data/Rakefile +189 -0
  10. data/bin/vanity +16 -0
  11. data/doc/_config.yml +2 -0
  12. data/doc/_layouts/_header.html +34 -0
  13. data/doc/_layouts/page.html +47 -0
  14. data/doc/_metrics.textile +12 -0
  15. data/doc/ab_testing.textile +210 -0
  16. data/doc/configuring.textile +45 -0
  17. data/doc/contributing.textile +93 -0
  18. data/doc/credits.textile +23 -0
  19. data/doc/css/page.css +83 -0
  20. data/doc/css/print.css +43 -0
  21. data/doc/css/syntax.css +7 -0
  22. data/doc/email.textile +129 -0
  23. data/doc/experimental.textile +31 -0
  24. data/doc/faq.textile +8 -0
  25. data/doc/identity.textile +43 -0
  26. data/doc/images/ab_in_dashboard.png +0 -0
  27. data/doc/images/clear_winner.png +0 -0
  28. data/doc/images/price_options.png +0 -0
  29. data/doc/images/sidebar_test.png +0 -0
  30. data/doc/images/signup_metric.png +0 -0
  31. data/doc/images/vanity.png +0 -0
  32. data/doc/index.textile +91 -0
  33. data/doc/metrics.textile +231 -0
  34. data/doc/rails.textile +89 -0
  35. data/doc/site.js +27 -0
  36. data/generators/templates/vanity_migration.rb +53 -0
  37. data/generators/vanity_generator.rb +8 -0
  38. data/lib/generators/templates/vanity_migration.rb +53 -0
  39. data/lib/generators/vanity_generator.rb +15 -0
  40. data/lib/vanity.rb +36 -0
  41. data/lib/vanity/adapters/abstract_adapter.rb +140 -0
  42. data/lib/vanity/adapters/active_record_adapter.rb +247 -0
  43. data/lib/vanity/adapters/mock_adapter.rb +157 -0
  44. data/lib/vanity/adapters/mongodb_adapter.rb +178 -0
  45. data/lib/vanity/adapters/redis_adapter.rb +160 -0
  46. data/lib/vanity/backport.rb +26 -0
  47. data/lib/vanity/commands/list.rb +21 -0
  48. data/lib/vanity/commands/report.rb +64 -0
  49. data/lib/vanity/commands/upgrade.rb +34 -0
  50. data/lib/vanity/experiment/ab_test.rb +507 -0
  51. data/lib/vanity/experiment/base.rb +214 -0
  52. data/lib/vanity/frameworks.rb +16 -0
  53. data/lib/vanity/frameworks/rails.rb +318 -0
  54. data/lib/vanity/helpers.rb +66 -0
  55. data/lib/vanity/images/x.gif +0 -0
  56. data/lib/vanity/metric/active_record.rb +85 -0
  57. data/lib/vanity/metric/base.rb +244 -0
  58. data/lib/vanity/metric/google_analytics.rb +83 -0
  59. data/lib/vanity/metric/remote.rb +53 -0
  60. data/lib/vanity/playground.rb +396 -0
  61. data/lib/vanity/templates/_ab_test.erb +28 -0
  62. data/lib/vanity/templates/_experiment.erb +5 -0
  63. data/lib/vanity/templates/_experiments.erb +7 -0
  64. data/lib/vanity/templates/_metric.erb +14 -0
  65. data/lib/vanity/templates/_metrics.erb +13 -0
  66. data/lib/vanity/templates/_report.erb +27 -0
  67. data/lib/vanity/templates/_vanity.js.erb +20 -0
  68. data/lib/vanity/templates/flot.min.js +1 -0
  69. data/lib/vanity/templates/jquery.min.js +19 -0
  70. data/lib/vanity/templates/vanity.css +26 -0
  71. data/lib/vanity/templates/vanity.js +82 -0
  72. data/lib/vanity/version.rb +11 -0
  73. data/test/adapters/redis_adapter_test.rb +17 -0
  74. data/test/experiment/ab_test.rb +771 -0
  75. data/test/experiment/base_test.rb +150 -0
  76. data/test/experiments/age_and_zipcode.rb +19 -0
  77. data/test/experiments/metrics/cheers.rb +3 -0
  78. data/test/experiments/metrics/signups.rb +2 -0
  79. data/test/experiments/metrics/yawns.rb +3 -0
  80. data/test/experiments/null_abc.rb +5 -0
  81. data/test/metric/active_record_test.rb +277 -0
  82. data/test/metric/base_test.rb +293 -0
  83. data/test/metric/google_analytics_test.rb +104 -0
  84. data/test/metric/remote_test.rb +109 -0
  85. data/test/myapp/app/controllers/application_controller.rb +2 -0
  86. data/test/myapp/app/controllers/main_controller.rb +7 -0
  87. data/test/myapp/config/boot.rb +110 -0
  88. data/test/myapp/config/environment.rb +10 -0
  89. data/test/myapp/config/environments/production.rb +0 -0
  90. data/test/myapp/config/routes.rb +3 -0
  91. data/test/passenger_test.rb +43 -0
  92. data/test/playground_test.rb +26 -0
  93. data/test/rails_dashboard_test.rb +37 -0
  94. data/test/rails_helper_test.rb +36 -0
  95. data/test/rails_test.rb +389 -0
  96. data/test/test_helper.rb +145 -0
  97. data/vanity.gemspec +26 -0
  98. metadata +224 -0
@@ -0,0 +1,145 @@
1
+ GC.disable
2
+ $LOAD_PATH.delete_if { |path| path[/gems\/vanity-\d/] }
3
+ $LOAD_PATH.unshift File.expand_path("../lib", File.dirname(__FILE__))
4
+ ENV["RACK_ENV"] = "test"
5
+ ENV["DB"] ||= "redis"
6
+
7
+ RAILS_ROOT = File.expand_path("..")
8
+ require "test/unit"
9
+ require "mocha"
10
+ require "action_controller"
11
+ require "action_controller/test_case"
12
+ require "action_view/test_case"
13
+ require "active_record"
14
+ require "initializer"
15
+ Rails.configuration = Rails::Configuration.new
16
+ require "phusion_passenger/events"
17
+ require "lib/vanity"
18
+ require "timecop"
19
+ require "webmock/test_unit"
20
+ require "ruby-debug"
21
+
22
+
23
+ if $VERBOSE
24
+ $logger = Logger.new(STDOUT)
25
+ $logger.level = Logger::DEBUG
26
+ end
27
+
28
+
29
+ class Test::Unit::TestCase
30
+ include WebMock::API
31
+
32
+ # We go destructive on the database at the end of each run, so make sure we
33
+ # don't use databases you care about. For Redis, we pick database 15
34
+ # (default is 0).
35
+ DATABASE = {
36
+ "redis"=>"redis://localhost/15",
37
+ "mongodb"=>"mongodb://localhost/vanity",
38
+ "mysql"=> { "adapter"=>"active_record", "active_record_adapter"=>"mysql", "database"=>"vanity_test" },
39
+ "postgres"=> { "adapter"=>"active_record", "active_record_adapter"=>"postgresql", "database"=>"vanity_test", "username"=>"postgres" },
40
+ "mock"=>"mock:/"
41
+ }[ENV["DB"]] or raise "No support yet for #{ENV["DB"]}"
42
+
43
+
44
+ def setup
45
+ FileUtils.mkpath "tmp/experiments/metrics"
46
+ new_playground
47
+ end
48
+
49
+ # Call this on teardown. It wipes put the playground and any state held in it
50
+ # (mostly experiments), resets vanity ID, and clears database of all experiments.
51
+ def nuke_playground
52
+ Vanity.playground.connection.flushdb
53
+ new_playground
54
+ end
55
+
56
+ # Call this if you need a new playground, e.g. to re-define the same experiment,
57
+ # or reload an experiment (saved by the previous playground).
58
+ def new_playground
59
+ Vanity.playground = Vanity::Playground.new(:logger=>$logger, :load_path=>"tmp/experiments")
60
+ Vanity.playground.establish_connection DATABASE
61
+ end
62
+
63
+ # Defines the specified metrics (one or more names). Returns metric, or array
64
+ # of metric (if more than one argument).
65
+ def metric(*names)
66
+ metrics = names.map do |name|
67
+ id = name.to_s.downcase.gsub(/\W+/, '_').to_sym
68
+ Vanity.playground.metrics[id] ||= Vanity::Metric.new(Vanity.playground, name)
69
+ end
70
+ names.size == 1 ? metrics.first : metrics
71
+ end
72
+
73
+ # Defines an A/B experiment.
74
+ def new_ab_test(name, &block)
75
+ id = name.to_s.downcase.gsub(/\W/, "_").to_sym
76
+ experiment = Vanity::Experiment::AbTest.new(Vanity.playground, id, name)
77
+ experiment.instance_eval &block
78
+ experiment.save
79
+ Vanity.playground.experiments[id] = experiment
80
+ end
81
+
82
+ # Returns named experiment.
83
+ def experiment(name)
84
+ Vanity.playground.experiment(name)
85
+ end
86
+
87
+ def today
88
+ @today ||= Date.today
89
+ end
90
+
91
+ def not_collecting!
92
+ Vanity.playground.collecting = false
93
+ Vanity.playground.stubs(:connection).returns(stub(:flushdb=>nil))
94
+ end
95
+
96
+ def teardown
97
+ Vanity.context = nil
98
+ FileUtils.rm_rf "tmp"
99
+ Vanity.playground.connection.flushdb if Vanity.playground.connected?
100
+ WebMock.reset!
101
+ end
102
+
103
+ end
104
+
105
+ ActionController::Routing::Routes.draw do |map|
106
+ map.connect ':controller/:action/:id'
107
+ end
108
+
109
+
110
+ ActiveRecord::Base.logger = $logger
111
+ ActiveRecord::Base.establish_connection :adapter=>"mysql", :database=>"vanity_test"
112
+
113
+ if ENV["DB"] == "mysql" || ENV["DB"] == "postgres"
114
+ require "generators/templates/vanity_migration"
115
+ VanityMigration.down rescue nil
116
+ VanityMigration.up
117
+ end
118
+
119
+
120
+ class Array
121
+ # Not in Ruby 1.8.6.
122
+ unless method_defined?(:shuffle)
123
+ def shuffle
124
+ copy = clone
125
+ Array.new(size) { copy.delete_at(Kernel.rand(copy.size)) }
126
+ end
127
+ end
128
+ end
129
+
130
+
131
+ # Source: http://gist.github.com/25455
132
+ def context(*args, &block)
133
+ return super unless (name = args.first) && block
134
+ parent = Class === self ? self : (defined?(ActiveSupport::TestCase) ? ActiveSupport::TestCase : Test::Unit::TestCase)
135
+ klass = Class.new(parent) do
136
+ def self.test(name, &block)
137
+ define_method("test_#{name.gsub(/\W/,'_')}", &block) if block
138
+ end
139
+ def self.xtest(*args) end
140
+ def self.setup(&block) define_method(:setup) { super() ; instance_eval &block } end
141
+ def self.teardown(&block) define_method(:teardown) { super() ; instance_eval &block } end
142
+ end
143
+ parent.const_set name.split(/\W+/).map(&:capitalize).join, klass
144
+ klass.class_eval &block
145
+ end
@@ -0,0 +1,26 @@
1
+ $: << File.dirname(__FILE__) + "/lib"
2
+ require "vanity/version"
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = "fiverr-vanity"
6
+ spec.version = Vanity::VERSION
7
+ spec.author = "Assaf Arkin"
8
+ spec.email = "assaf@labnotes.org"
9
+ spec.homepage = "http://vanity.labnotes.org"
10
+ spec.summary = "Experience Driven Development framework for Ruby"
11
+ spec.description = "Mirror, mirror on the wall ..."
12
+ spec.post_install_message = "To get started run vanity --help"
13
+
14
+ spec.files = `git ls-files`.split("\n")
15
+ spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.extra_rdoc_files = "README.rdoc", "CHANGELOG"
20
+ spec.rdoc_options = "--title", "Vanity #{spec.version}", "--main", "README.rdoc",
21
+ "--webcvs", "http://github.com/assaf/#{spec.name}"
22
+
23
+ spec.required_ruby_version = '>= 1.8.7'
24
+ spec.add_dependency "redis", "~>2.0"
25
+ spec.add_dependency "redis-namespace", "~>1.0.0"
26
+ end
metadata ADDED
@@ -0,0 +1,224 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fiverr-vanity
3
+ version: !ruby/object:Gem::Version
4
+ hash: 15
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 7
9
+ - 2
10
+ version: 1.7.2
11
+ platform: ruby
12
+ authors:
13
+ - Assaf Arkin
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-12-01 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: redis
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 2
32
+ - 0
33
+ version: "2.0"
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: redis-namespace
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ hash: 23
45
+ segments:
46
+ - 1
47
+ - 0
48
+ - 0
49
+ version: 1.0.0
50
+ type: :runtime
51
+ version_requirements: *id002
52
+ description: Mirror, mirror on the wall ...
53
+ email: assaf@labnotes.org
54
+ executables:
55
+ - vanity
56
+ extensions: []
57
+
58
+ extra_rdoc_files:
59
+ - README.rdoc
60
+ - CHANGELOG
61
+ files:
62
+ - .autotest
63
+ - .gitignore
64
+ - .rvmrc
65
+ - .travis.yml
66
+ - CHANGELOG
67
+ - Gemfile
68
+ - MIT-LICENSE
69
+ - README.rdoc
70
+ - Rakefile
71
+ - bin/vanity
72
+ - doc/_config.yml
73
+ - doc/_layouts/_header.html
74
+ - doc/_layouts/page.html
75
+ - doc/_metrics.textile
76
+ - doc/ab_testing.textile
77
+ - doc/configuring.textile
78
+ - doc/contributing.textile
79
+ - doc/credits.textile
80
+ - doc/css/page.css
81
+ - doc/css/print.css
82
+ - doc/css/syntax.css
83
+ - doc/email.textile
84
+ - doc/experimental.textile
85
+ - doc/faq.textile
86
+ - doc/identity.textile
87
+ - doc/images/ab_in_dashboard.png
88
+ - doc/images/clear_winner.png
89
+ - doc/images/price_options.png
90
+ - doc/images/sidebar_test.png
91
+ - doc/images/signup_metric.png
92
+ - doc/images/vanity.png
93
+ - doc/index.textile
94
+ - doc/metrics.textile
95
+ - doc/rails.textile
96
+ - doc/site.js
97
+ - generators/templates/vanity_migration.rb
98
+ - generators/vanity_generator.rb
99
+ - lib/generators/templates/vanity_migration.rb
100
+ - lib/generators/vanity_generator.rb
101
+ - lib/vanity.rb
102
+ - lib/vanity/adapters/abstract_adapter.rb
103
+ - lib/vanity/adapters/active_record_adapter.rb
104
+ - lib/vanity/adapters/mock_adapter.rb
105
+ - lib/vanity/adapters/mongodb_adapter.rb
106
+ - lib/vanity/adapters/redis_adapter.rb
107
+ - lib/vanity/backport.rb
108
+ - lib/vanity/commands/list.rb
109
+ - lib/vanity/commands/report.rb
110
+ - lib/vanity/commands/upgrade.rb
111
+ - lib/vanity/experiment/ab_test.rb
112
+ - lib/vanity/experiment/base.rb
113
+ - lib/vanity/frameworks.rb
114
+ - lib/vanity/frameworks/rails.rb
115
+ - lib/vanity/helpers.rb
116
+ - lib/vanity/images/x.gif
117
+ - lib/vanity/metric/active_record.rb
118
+ - lib/vanity/metric/base.rb
119
+ - lib/vanity/metric/google_analytics.rb
120
+ - lib/vanity/metric/remote.rb
121
+ - lib/vanity/playground.rb
122
+ - lib/vanity/templates/_ab_test.erb
123
+ - lib/vanity/templates/_experiment.erb
124
+ - lib/vanity/templates/_experiments.erb
125
+ - lib/vanity/templates/_metric.erb
126
+ - lib/vanity/templates/_metrics.erb
127
+ - lib/vanity/templates/_report.erb
128
+ - lib/vanity/templates/_vanity.js.erb
129
+ - lib/vanity/templates/flot.min.js
130
+ - lib/vanity/templates/jquery.min.js
131
+ - lib/vanity/templates/vanity.css
132
+ - lib/vanity/templates/vanity.js
133
+ - lib/vanity/version.rb
134
+ - test/adapters/redis_adapter_test.rb
135
+ - test/experiment/ab_test.rb
136
+ - test/experiment/base_test.rb
137
+ - test/experiments/age_and_zipcode.rb
138
+ - test/experiments/metrics/cheers.rb
139
+ - test/experiments/metrics/signups.rb
140
+ - test/experiments/metrics/yawns.rb
141
+ - test/experiments/null_abc.rb
142
+ - test/metric/active_record_test.rb
143
+ - test/metric/base_test.rb
144
+ - test/metric/google_analytics_test.rb
145
+ - test/metric/remote_test.rb
146
+ - test/myapp/app/controllers/application_controller.rb
147
+ - test/myapp/app/controllers/main_controller.rb
148
+ - test/myapp/config/boot.rb
149
+ - test/myapp/config/environment.rb
150
+ - test/myapp/config/environments/production.rb
151
+ - test/myapp/config/routes.rb
152
+ - test/passenger_test.rb
153
+ - test/playground_test.rb
154
+ - test/rails_dashboard_test.rb
155
+ - test/rails_helper_test.rb
156
+ - test/rails_test.rb
157
+ - test/test_helper.rb
158
+ - vanity.gemspec
159
+ has_rdoc: true
160
+ homepage: http://vanity.labnotes.org
161
+ licenses: []
162
+
163
+ post_install_message: To get started run vanity --help
164
+ rdoc_options:
165
+ - --title
166
+ - Vanity 1.7.2
167
+ - --main
168
+ - README.rdoc
169
+ - --webcvs
170
+ - http://github.com/assaf/fiverr-vanity
171
+ require_paths:
172
+ - lib
173
+ required_ruby_version: !ruby/object:Gem::Requirement
174
+ none: false
175
+ requirements:
176
+ - - ">="
177
+ - !ruby/object:Gem::Version
178
+ hash: 57
179
+ segments:
180
+ - 1
181
+ - 8
182
+ - 7
183
+ version: 1.8.7
184
+ required_rubygems_version: !ruby/object:Gem::Requirement
185
+ none: false
186
+ requirements:
187
+ - - ">="
188
+ - !ruby/object:Gem::Version
189
+ hash: 3
190
+ segments:
191
+ - 0
192
+ version: "0"
193
+ requirements: []
194
+
195
+ rubyforge_project:
196
+ rubygems_version: 1.3.7
197
+ signing_key:
198
+ specification_version: 3
199
+ summary: Experience Driven Development framework for Ruby
200
+ test_files:
201
+ - test/adapters/redis_adapter_test.rb
202
+ - test/experiment/ab_test.rb
203
+ - test/experiment/base_test.rb
204
+ - test/experiments/age_and_zipcode.rb
205
+ - test/experiments/metrics/cheers.rb
206
+ - test/experiments/metrics/signups.rb
207
+ - test/experiments/metrics/yawns.rb
208
+ - test/experiments/null_abc.rb
209
+ - test/metric/active_record_test.rb
210
+ - test/metric/base_test.rb
211
+ - test/metric/google_analytics_test.rb
212
+ - test/metric/remote_test.rb
213
+ - test/myapp/app/controllers/application_controller.rb
214
+ - test/myapp/app/controllers/main_controller.rb
215
+ - test/myapp/config/boot.rb
216
+ - test/myapp/config/environment.rb
217
+ - test/myapp/config/environments/production.rb
218
+ - test/myapp/config/routes.rb
219
+ - test/passenger_test.rb
220
+ - test/playground_test.rb
221
+ - test/rails_dashboard_test.rb
222
+ - test/rails_helper_test.rb
223
+ - test/rails_test.rb
224
+ - test/test_helper.rb