abtest 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/abtest.rb +43 -1
- data/lib/abtest/processor.rb +10 -0
- data/lib/abtest/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7003e71f137f358d4486677ee30d33f1b52ec8b7
|
4
|
+
data.tar.gz: e65200ded12e11fcc0b9edd18fd56c702e376dd4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9791117e91b7a670b98586c2c11dd86c573fac5566a514ae36422119ab71542fedd39b1cf1e2a067a02eb899c67315aea63bc0befe0ecb6656bf80e6e9d2b75
|
7
|
+
data.tar.gz: 6eff296817cf5694fd8d06518311b7198c2ecfb4c7b6f657d503cc6156e064250cd1de060f26980cdea5747a1ad0cf9762d27b42fc234c04a707ad74d135b87a
|
data/lib/abtest.rb
CHANGED
@@ -12,13 +12,55 @@ module Abtest
|
|
12
12
|
attr_accessor :manifests
|
13
13
|
|
14
14
|
def initialize
|
15
|
-
@manifests = {}
|
15
|
+
@manifests = {'default' => default_manifest }
|
16
16
|
end
|
17
17
|
|
18
18
|
def retrieve_manifest name
|
19
19
|
manifests[name] ||= create_manifest(name)
|
20
20
|
end
|
21
21
|
|
22
|
+
def default_manifest
|
23
|
+
app = Rails.application
|
24
|
+
|
25
|
+
# Create a custom sprockets environment
|
26
|
+
default_environment = Sprockets::Environment.new(Rails.root.to_s) do |env|
|
27
|
+
env.context_class.class_eval do
|
28
|
+
include ::Sprockets::Rails::Helper
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# Monkey patch class in-place with sass_config accessor
|
33
|
+
default_environment.context_class.extend(::Sass::Rails::Railtie::SassContext)
|
34
|
+
|
35
|
+
# Always calculate digests and compile files
|
36
|
+
app.config.assets.digest = true
|
37
|
+
app.config.assets.compile = true
|
38
|
+
default_environment.cache = :null_store # Disables the Asset cache
|
39
|
+
|
40
|
+
# Copy config.assets.paths to Sprockets
|
41
|
+
app.config.assets.paths.each do |path|
|
42
|
+
default_environment.append_path path
|
43
|
+
end
|
44
|
+
|
45
|
+
default_environment.js_compressor = app.config.assets.js_compressor
|
46
|
+
default_environment.css_compressor = app.config.assets.css_compressor
|
47
|
+
|
48
|
+
if app.config.logger
|
49
|
+
default_environment.logger = app.config.logger
|
50
|
+
else
|
51
|
+
default_environment.logger = Logger.new($stdout)
|
52
|
+
default_environment.logger.level = Logger::INFO
|
53
|
+
end
|
54
|
+
|
55
|
+
output_file = File.join(app.root, 'public', app.config.assets.prefix)
|
56
|
+
default_environment.context_class.assets_prefix = "#{app.config.assets.prefix}"
|
57
|
+
default_environment.context_class.digest_assets = app.config.assets.digest
|
58
|
+
default_environment.context_class.config = app.config.action_controller
|
59
|
+
default_environment.context_class.sass_config = app.config.sass
|
60
|
+
|
61
|
+
Sprockets::Manifest.new(default_environment, output_file)
|
62
|
+
end
|
63
|
+
|
22
64
|
def create_manifest name
|
23
65
|
app = Rails.application
|
24
66
|
experiment_path = File.join(app.root, 'abtest', 'experiments', name)
|
data/lib/abtest/processor.rb
CHANGED
@@ -37,6 +37,16 @@ module Abtest
|
|
37
37
|
I18n.reload! if I18n.load_path.reject! { |path| path.include?(experiment_name) }
|
38
38
|
end
|
39
39
|
end
|
40
|
+
|
41
|
+
unless experiment_activated
|
42
|
+
# Use default manifest
|
43
|
+
manifest = Abtest::ManifestManager.instance.retrieve_manifest('default')
|
44
|
+
|
45
|
+
# Set view context for asset path
|
46
|
+
controller.view_context_class.assets_prefix = File.join(Rails.application.config.assets.prefix)
|
47
|
+
controller.view_context_class.assets_environment = manifest.environment
|
48
|
+
controller.view_context_class.assets_manifest = manifest
|
49
|
+
end
|
40
50
|
end
|
41
51
|
end
|
42
52
|
end
|
data/lib/abtest/version.rb
CHANGED
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: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Saarinen
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-06-
|
12
|
+
date: 2014-06-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|