abtest 1.0.0 → 1.0.1

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: 4ec13e778785f5298c33fe7d14820f1b876043b0
4
- data.tar.gz: e566a5b2924b3e1701903179088b24b6bbc1e649
3
+ metadata.gz: 7003e71f137f358d4486677ee30d33f1b52ec8b7
4
+ data.tar.gz: e65200ded12e11fcc0b9edd18fd56c702e376dd4
5
5
  SHA512:
6
- metadata.gz: 732ef569e5f011ce7c11e2843ba3e878c7c122de23e9065c5f6f56f8c81d9ef48133f563ebee31f5340d422b69a2e80eb22c457db8a49ba0420e90ffbd187322
7
- data.tar.gz: c42e9588674746ea798790c77bb0499d358ab190c214dda432e1dac3e0259078c9b039a9f2299d20e67893de7106787659ff0ccc26875e7a30c96e82fd5e9ac9
6
+ metadata.gz: c9791117e91b7a670b98586c2c11dd86c573fac5566a514ae36422119ab71542fedd39b1cf1e2a067a02eb899c67315aea63bc0befe0ecb6656bf80e6e9d2b75
7
+ data.tar.gz: 6eff296817cf5694fd8d06518311b7198c2ecfb4c7b6f657d503cc6156e064250cd1de060f26980cdea5747a1ad0cf9762d27b42fc234c04a707ad74d135b87a
@@ -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)
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Abtest
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
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: 1.0.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-06 00:00:00.000000000 Z
12
+ date: 2014-06-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails