vignette 0.0.2 → 0.0.3

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.
@@ -34,16 +34,17 @@ module ObjectExtensions
34
34
  store = case Vignette.store
35
35
  when :cookies
36
36
  raise VignetteError::ConfigError, "Missing cookies configuration in Vignette. Must access Vignette in controller within around_filter." if Vignette.cookies.nil?
37
+ Rails.logger.debug [ 'Vignette::vignette', 'Cookies Sampling', key, Vignette.cookies[key] ] if Vignette.logging
37
38
  Vignette.cookies
38
39
  when :session
39
40
  raise VignetteError::ConfigError, "Missing session configuration in Vignette. Must access Vignette in controller within around_filter." if Vignette.session.nil?
40
- # Rails.logger.debug [ 'Vignette::vignette', 'Session Sampling', key, Vignette.session[key], Vignette.session ]
41
+ Rails.logger.debug [ 'Vignette::vignette', 'Session Sampling', key, Vignette.session[key] ] if Vignette.logging
41
42
  Vignette.session
42
43
  else
43
- # Rails.logger.debug [ 'Vignette::vignette', 'Random Sampling' ]
44
+ Rails.logger.debug [ 'Vignette::vignette', 'Random Sampling' ] if Vignette.logging
44
45
  {} # This is an empty storage
45
46
  end
46
-
47
+
47
48
  choice = store[key] ||= rand(length) # Store key into storage if not available
48
49
 
49
50
  # We're going to track all tests in request
@@ -65,7 +66,7 @@ module ObjectExtensions
65
66
  private
66
67
 
67
68
  def init_vignette
68
- Vignette.request_config(request, cookies, session)
69
+ Vignette.request_config(request, session, cookies)
69
70
  yield
70
71
  ensure
71
72
  Vignette.clear_request # Clear request
@@ -1,3 +1,3 @@
1
1
  module Vignette
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/vignette.rb CHANGED
@@ -4,6 +4,7 @@ require "vignette/filter"
4
4
 
5
5
  module Vignette
6
6
  # Your code goes here...
7
+ mattr_accessor :logging
7
8
  mattr_accessor :store
8
9
  mattr_accessor :request, :session, :cookies
9
10
 
@@ -11,16 +12,18 @@ module Vignette
11
12
 
12
13
  # Defaults
13
14
  Vignette.store = :session
14
-
15
+ Vignette.logging = false
16
+
15
17
  # We're going to include ArrayExtensions
16
18
  ActionController::Base.send(:include, ObjectExtensions::ActionControllerExtensions)
17
19
  Array.send(:include, ObjectExtensions::ArrayExtensions)
18
20
 
19
21
  # Member Functions
20
-
22
+
21
23
  def self.init(opts={})
22
24
  opts = {
23
- store: :session
25
+ store: nil,
26
+ logging: nil
24
27
  }.with_indifferent_access.merge(opts)
25
28
 
26
29
  Vignette.store = opts[:store]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vignette
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: