split_tester 0.3 → 0.4

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -34,7 +34,7 @@ PKG_FILES = FileList[
34
34
 
35
35
  spec = Gem::Specification.new do |s|
36
36
  s.name = "split_tester"
37
- s.version = "0.3"
37
+ s.version = "0.4"
38
38
  s.author = "Jeremy Hubert"
39
39
  s.email = "jhubert@gmail.com"
40
40
  s.homepage = "http://jeremyhubert.com/"
data/lib/split_tester.rb CHANGED
@@ -24,7 +24,7 @@ module SplitTester
24
24
  I18n.load_path += Dir[Rails.root.join('test', 'split', '*', 'locale.{rb,yml}')]
25
25
 
26
26
  @@preprocessed_pathsets = begin
27
- SPLIT_TESTS.keys.reject { |k| k == 'BASELINE' }.inject({}) do |pathsets, slug|
27
+ self.test_keys.inject({}) do |pathsets, slug|
28
28
  path = custom_view_path(slug)
29
29
  pathsets[path] = ActionView::Base.process_view_paths(path).first
30
30
  pathsets
@@ -46,6 +46,10 @@ module SplitTester
46
46
  @@split_test_map
47
47
  end
48
48
 
49
+ def self.test_keys
50
+ @test_keys ||= SPLIT_TESTS.keys.reject { |k| k == 'BASELINE' }
51
+ end
52
+
49
53
  def self.preprocessed_pathsets
50
54
  @@preprocessed_pathsets
51
55
  end
@@ -4,10 +4,34 @@ module SplitTester #:nodoc:
4
4
  module Caching
5
5
  def self.included(base)
6
6
  base.class_eval {
7
- def fragment_cache_key(key)
8
- namespace = is_split_test? ? "views-split-#{current_split_test_key}" : :views
7
+ def fragment_cache_key(key, namespace = nil)
8
+ namespace ||= is_split_test? ? "views-split-#{current_split_test_key}" : :views
9
9
  ActiveSupport::Cache.expand_cache_key(key.is_a?(Hash) ? url_for(key).split("://").last : key, namespace)
10
10
  end
11
+
12
+ def expire_fragment(key, options = nil)
13
+ return unless cache_configured?
14
+ key = fragment_cache_key(key, :views) unless key.is_a?(Regexp)
15
+ message = nil
16
+
17
+ instrument_fragment_cache :expire_fragment, key do
18
+ if key.is_a?(Regexp)
19
+ cache_store.delete_matched(key, options)
20
+ else
21
+ cache_store.delete(key, options)
22
+ end
23
+ end
24
+
25
+ unless key.is_a?(Regexp)
26
+ original_key = key.dup
27
+ SplitTester::Base.test_keys.each do |k,v|
28
+ key = original_key.sub('views/', "views-split-#{k}/")
29
+ instrument_fragment_cache :expire_fragment, key do
30
+ cache_store.delete(key, options)
31
+ end
32
+ end
33
+ end
34
+ end
11
35
  }
12
36
  end
13
37
  end
data/split_tester.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.platform = Gem::Platform::RUBY
3
3
  s.name = 'split_tester'
4
- s.version = '0.3'
4
+ s.version = '0.4'
5
5
  s.summary = 'Provides A/B split testing functionality for Rails'
6
6
  s.description = 'Split Tester provides support for A/B Split testing your pages with integration into Google Analytics.'
7
7
 
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: split_tester
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
5
- prerelease: false
4
+ hash: 3
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
- - 3
9
- version: "0.3"
8
+ - 4
9
+ version: "0.4"
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jeremy Hubert
@@ -78,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
78
  requirements: []
79
79
 
80
80
  rubyforge_project:
81
- rubygems_version: 1.3.7
81
+ rubygems_version: 1.4.2
82
82
  signing_key:
83
83
  specification_version: 3
84
84
  summary: Provides A/B split testing functionality for Rails