abtest 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cb40965c5504d6350cbf6bf7da5b76c9f0f47f6e
4
- data.tar.gz: 978cf2b5d26878668c44e239d084da7aa87c30eb
3
+ metadata.gz: 2feb33d2ff421a52ce02c0501b1595aa3f5c0640
4
+ data.tar.gz: fc1e8b24c8ebfa81355961292ac0a7884ef4ab10
5
5
  SHA512:
6
- metadata.gz: 1389a6c543d37030317a94a2f66a4158272403d92eed9ab7a44b658a10232ea2a4b9b7ff778541f5ca2dfd37e104e2dca76010f44ef657dc8064b926d7a3d435
7
- data.tar.gz: 83d24beda283ba5afc6f03bfc869772c51b13ce045f2e24a717a3e11948331f4e4bb0f19e77b1ac6f47748734bc02d1fda060993168324957734e07bdde2dbfb
6
+ metadata.gz: addace6fa5603b07dcbc930e8cd78d466662fcb1053236c931587d6c089c9edbceb20cecdd069207c58719e32ef9ad7f13130a8d5f2db63af96bfcc023f32e5c
7
+ data.tar.gz: 9655689637f0c72e9c80e0353218bad317a4cdb72296c3ff02917f113a3d2ddd7d7449f1f96f0ecf25a09542fb258c47c01ae93d7f1545e470e0b13bf0420784
@@ -4,12 +4,22 @@ namespace :abtest do
4
4
  name = args[:name]
5
5
  puts "Experiment name is required" and return if name.nil?
6
6
 
7
- # Check to see if we have a tests directory
8
- Dir.mkdir("#{Rails.root}/app/views/tests") unless Dir.exists?("#{Rails.root}/app/views/tests")
7
+ # Check to see if we have a experiments directory
8
+ FileUtils.mkdir_p("#{Rails.root}/experiments")
9
9
 
10
- # Create a folder for this experiment
11
- experiment_path = "#{Rails.root}/app/views/tests/#{args[:name]}"
12
- Dir.mkdir(experiment_path) unless Dir.exists?(experiment_path)
10
+ # Add directories for views and assets
11
+ experiment_path = "#{Rails.root}/experiments/#{args[:name]}"
12
+ application_css_path = "#{experiment_path}/assets/stylesheets"
13
+ view_path = "#{experiment_path}/views"
14
+ FileUtils.mkdir_p(view_path)
15
+ FileUtils.mkdir_p(application_css_path)
16
+
17
+ # Add template stylesheet
18
+ css_template = File.read("#{File.dirname(__FILE__)}/templates/application.scss.erb")
19
+ renderer = ERB.new(css_template)
20
+ css_result = renderer.result(binding)
21
+
22
+ File.open("#{application_css_path}/#{name}_application.scss", 'w') {|f| f.write(css_result) }
13
23
 
14
24
  # Create a new initializer file if it doesn't exist already
15
25
  initializer_path = "#{Rails.root}/config/initializers/abtest.rb"
@@ -28,11 +38,11 @@ namespace :abtest do
28
38
 
29
39
  desc "Delete all experiments"
30
40
  task :delete_experiments => :environment do
31
- # Remove tests directory
32
- FileUtils.rm_rf("#{Rails.root}/app/views/tests") if Dir.exists?("#{Rails.root}/app/views/tests")
41
+ # Remove experiments directory
42
+ FileUtils.rm_rf("#{Rails.root}/experiments")
33
43
 
34
44
  # Remove initializer
35
- FileUtils.rm("#{Rails.root}/config/initializers/abtest.rb") if Dir.exists?("#{Rails.root}/config/initializers/abtest.rb")
45
+ FileUtils.rm_f("#{Rails.root}/config/initializers/abtest.rb")
36
46
 
37
47
  puts "All tests removed"
38
48
  end
@@ -0,0 +1,3 @@
1
+ @import "<%= "#{Rails.root}/app/assets/stylesheets/application" %>";
2
+
3
+ /* IMPORT YOUR OVERRIDES HERE */
@@ -1,3 +1,10 @@
1
+
2
+ ################################################
3
+ #
4
+ # Begin configuration for <%= name %> experiment
5
+ #
6
+ ################################################
7
+
1
8
  <%= name %>_test = lambda { |request|
2
9
  false
3
10
  }
@@ -6,4 +13,12 @@
6
13
 
7
14
  }
8
15
 
9
- Abtest.register_test("<%= experiment_path %>", <%= name %>_test, <%= name %>_process)
16
+ Abtest.register_test("<%= experiment_path %>", <%= name %>_test, <%= name %>_process)
17
+ Rails.application.config.assets.paths << "<%= experiment_path %>/assets"
18
+ Rails.application.config.assets.precompile += ['<%= experiment_path %>/assets/stylesheets/<%= name %>_application.scss']
19
+
20
+ ################################################
21
+ #
22
+ # End configuration for <%= name %> experiment
23
+ #
24
+ ################################################
@@ -1,3 +1,3 @@
1
1
  module Abtest
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abtest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Saarinen
@@ -72,6 +72,7 @@ files:
72
72
  - lib/abtest/railtie.rb
73
73
  - lib/abtest/registry.rb
74
74
  - lib/abtest/tasks/experiments.rake
75
+ - lib/abtest/tasks/templates/application.scss.erb
75
76
  - lib/abtest/tasks/templates/initializer.erb
76
77
  - lib/abtest/version.rb
77
78
  homepage: http://www.whitepages.com