abtest 0.0.4 → 0.0.5

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: 2feb33d2ff421a52ce02c0501b1595aa3f5c0640
4
- data.tar.gz: fc1e8b24c8ebfa81355961292ac0a7884ef4ab10
3
+ metadata.gz: cec62b482674e24404cf39a8d5f0e7603a28fc16
4
+ data.tar.gz: 48b6d4fbe6e12b4f871e476d8a08535718868a8d
5
5
  SHA512:
6
- metadata.gz: addace6fa5603b07dcbc930e8cd78d466662fcb1053236c931587d6c089c9edbceb20cecdd069207c58719e32ef9ad7f13130a8d5f2db63af96bfcc023f32e5c
7
- data.tar.gz: 9655689637f0c72e9c80e0353218bad317a4cdb72296c3ff02917f113a3d2ddd7d7449f1f96f0ecf25a09542fb258c47c01ae93d7f1545e470e0b13bf0420784
6
+ metadata.gz: 1788c07944936edf716f55f91a35d766a96f2bfd1113ea53d5ee1d04a92bde119d2db14254f9b3f46c4788d4a6877fb025497683e77ff6d08f2455cfd857b967
7
+ data.tar.gz: 5944e39d2d7ddb12d8a13b41e87bb7b34e10391855853742fd46b998d75d236d15bfb9af151e22305c73fbee3a62a23fb850627d352fff49a8ce94b27c45b97d
@@ -9,21 +9,29 @@ namespace :abtest do
9
9
 
10
10
  # Add directories for views and assets
11
11
  experiment_path = "#{Rails.root}/experiments/#{args[:name]}"
12
- application_css_path = "#{experiment_path}/assets/stylesheets"
12
+ application_css_path = "#{experiment_path}/assets/#{name}/stylesheets"
13
+ image_path = "#{experiment_path}/assets/#{name}/images"
13
14
  view_path = "#{experiment_path}/views"
14
15
  FileUtils.mkdir_p(view_path)
15
16
  FileUtils.mkdir_p(application_css_path)
17
+ FileUtils.mkdir_p(image_path)
16
18
 
17
19
  # Add template stylesheet
18
20
  css_template = File.read("#{File.dirname(__FILE__)}/templates/application.scss.erb")
19
21
  renderer = ERB.new(css_template)
20
22
  css_result = renderer.result(binding)
21
23
 
22
- File.open("#{application_css_path}/#{name}_application.scss", 'w') {|f| f.write(css_result) }
24
+ File.open("#{application_css_path}/application.scss", 'w') {|f| f.write(css_result) }
23
25
 
24
26
  # Create a new initializer file if it doesn't exist already
25
27
  initializer_path = "#{Rails.root}/config/initializers/abtest.rb"
26
- FileUtils.touch(initializer_path) unless File.exists?(initializer_path)
28
+ unless File.exists?(initializer_path)
29
+ initializer_template = File.read("#{File.dirname(__FILE__)}/templates/precompile_config.erb")
30
+ renderer = ERB.new(initializer_template)
31
+ result = renderer.result(binding)
32
+
33
+ File.open(initializer_path, 'a') { |f| f.write(result) }
34
+ end
27
35
 
28
36
  # Add template initializer
29
37
  template = File.read("#{File.dirname(__FILE__)}/templates/initializer.erb")
@@ -14,8 +14,8 @@
14
14
  }
15
15
 
16
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']
17
+ Rails.application.config.assets.paths << "<%= experiment_path %>/assets/"
18
+ Rails.application.config.assets.precompile += ['<%= experiment_path %>/assets/<%= name %>/stylesheets/application.scss']
19
19
 
20
20
  ################################################
21
21
  #
@@ -0,0 +1,13 @@
1
+ Rails.application.config.assets.precompile << Proc.new do |path|
2
+ unless path =~ /\.(css|js)\z/
3
+ full_path = Rails.application.assets.resolve(path).to_path
4
+ app_assets_path = "<%= experiment_path %>/assets/"
5
+ if full_path.starts_with? app_assets_path
6
+ true
7
+ else
8
+ false
9
+ end
10
+ else
11
+ false
12
+ end
13
+ end
@@ -1,3 +1,3 @@
1
1
  module Abtest
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
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.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Saarinen
@@ -74,6 +74,7 @@ files:
74
74
  - lib/abtest/tasks/experiments.rake
75
75
  - lib/abtest/tasks/templates/application.scss.erb
76
76
  - lib/abtest/tasks/templates/initializer.erb
77
+ - lib/abtest/tasks/templates/precompile_config.erb
77
78
  - lib/abtest/version.rb
78
79
  homepage: http://www.whitepages.com
79
80
  licenses: