test_track_rails_client 4.0.0.alpha33 → 4.0.0.alpha34

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 04e1d08411f4d058bdafcfdb9b9fa9d9055e4e7c
4
- data.tar.gz: d6eb123a181c09a0f28d66c4d9e08d53d463f3d1
2
+ SHA256:
3
+ metadata.gz: 2ebec3b017f9413465d5366f3b94d95c12b38d7bf408693ce0a0d4086d39a107
4
+ data.tar.gz: '0728b2597327fb1e1583de3c9b4ed3eaf9a7f95bf62617d5cb2702c33d9723d8'
5
5
  SHA512:
6
- metadata.gz: 2a11aeb59407096e014890089d70b17249796b6cbddc17dcb9ed7bbb34a9c60fdb4b584e1671c04e0db1fae7615a640375c78888e79795dec85e3bcc084b1282
7
- data.tar.gz: 83095dea4ae36815b4497240d1b8eee1eaabecff2b24a5b82f9b5af0607c0a3b549c2d50765603cf82e38a3c05d188dea7917c15eb6f0bd9da35fc558a026315
6
+ metadata.gz: 86cbae6aa9be897b607781bb26bd53cc834bf47c140d1d2e7f911baadada95f280094ece25de2a4a2ce1415b20eeb4eb63e472fe60c6dc8a5a2256c6f63ecaab
7
+ data.tar.gz: 5cf5546c8d41542813f2aa682024ca3b476fc51afa7bd3144d93634982806fbfa7b2827f232de2da459a88118c1c43a26a5cdbab9713d42fd9d22ea739f1b970
data/Rakefile CHANGED
@@ -14,7 +14,7 @@ RDoc::Task.new(:rdoc) do |rdoc|
14
14
  rdoc.rdoc_files.include('lib/**/*.rb')
15
15
  end
16
16
 
17
- APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
17
+ APP_RAKEFILE = File.expand_path('spec/dummy/Rakefile', __dir__)
18
18
  load 'rails/tasks/engine.rake'
19
19
 
20
20
  Bundler::GemHelper.install_tasks
@@ -12,9 +12,7 @@ module TestTrack::Controller
12
12
  class_methods do
13
13
  def require_feature_flag(feature_flag, *args)
14
14
  before_action(*args) do
15
- unless test_track_visitor.ab(feature_flag, context: self.class.name.underscore)
16
- raise ActionController::RoutingError, 'Not Found'
17
- end
15
+ raise ActionController::RoutingError, 'Not Found' unless test_track_visitor.ab(feature_flag, context: self.class.name.underscore)
18
16
  end
19
17
  end
20
18
  end
@@ -6,6 +6,7 @@ module TestTrack::RequiredOptions
6
6
  def require_option!(opts, opt_name, my_opts = {})
7
7
  opt_provided = my_opts[:allow_nil] ? opts.key?(opt_name) : opts[opt_name]
8
8
  raise(ArgumentError, "Must provide #{opt_name}") unless opt_provided
9
+
9
10
  opts.delete(opt_name)
10
11
  end
11
12
  end
@@ -19,9 +19,7 @@ class TestTrack::ABConfiguration
19
19
  private
20
20
 
21
21
  def build_variant_hash
22
- if split_variants && split_variants.size > 2 # rubocop:disable Style/SafeNavigation
23
- notify_because_ab("configures split with more than 2 variants")
24
- end
22
+ notify_because_ab("configures split with more than 2 variants") if split_variants && split_variants.size > 2
25
23
  { true: true_variant, false: false_variant }
26
24
  end
27
25
 
@@ -30,7 +28,7 @@ class TestTrack::ABConfiguration
30
28
  end
31
29
 
32
30
  def false_variant
33
- @false_variant ||= non_true_variants.present? ? non_true_variants.sort.first : false
31
+ @false_variant ||= non_true_variants.present? ? non_true_variants.min : false
34
32
  end
35
33
 
36
34
  attr_reader :split_name, :split_registry
@@ -8,6 +8,7 @@ module TestTrack::Analytics
8
8
 
9
9
  def mixpanel
10
10
  raise "ENV['MIXPANEL_TOKEN'] must be set" unless ENV['MIXPANEL_TOKEN']
11
+
11
12
  @mixpanel ||= Mixpanel::Tracker.new(ENV['MIXPANEL_TOKEN'])
12
13
  end
13
14
  end
@@ -9,6 +9,7 @@ module TestTrack::Analytics
9
9
  def error_handler=(handler)
10
10
  raise ArgumentError, "error_handler must be a lambda" unless handler.lambda?
11
11
  raise ArgumentError, "error_handler must accept 1 argument" unless handler.arity == 1
12
+
12
13
  @error_handler = handler
13
14
  end
14
15
 
@@ -7,6 +7,7 @@ class TestTrack::ApplicationIdentity
7
7
 
8
8
  def app_name
9
9
  raise 'must configure TestTrack.app_name on application initialization' if TestTrack.app_name.blank?
10
+
10
11
  TestTrack.app_name
11
12
  end
12
13
 
@@ -27,7 +27,8 @@ class TestTrack::Assignment
27
27
 
28
28
  def _variant
29
29
  return if visitor.offline?
30
+
30
31
  variant = TestTrack::VariantCalculator.new(visitor: visitor, split_name: split_name).variant
31
- variant && variant.to_s
32
+ variant&.to_s
32
33
  end
33
34
  end
@@ -50,9 +50,7 @@ class TestTrack::Fake::SplitRegistry
50
50
  end
51
51
 
52
52
  def legacy_test_track_schema_yml
53
- unless instance_variable_defined?(:@legacy_test_track_schema_yml)
54
- @legacy_test_track_schema_yml = _legacy_test_track_schema_yml
55
- end
53
+ @legacy_test_track_schema_yml = _legacy_test_track_schema_yml unless instance_variable_defined?(:@legacy_test_track_schema_yml)
56
54
  @legacy_test_track_schema_yml
57
55
  end
58
56
 
@@ -69,7 +67,7 @@ class TestTrack::Fake::SplitRegistry
69
67
 
70
68
  def split_registry_with_deterministic_weights
71
69
  splits = split_hash.each_with_object({}) do |(split_name, weighting_registry), result|
72
- default_variant = weighting_registry.keys.sort.first
70
+ default_variant = weighting_registry.keys.min
73
71
 
74
72
  adjusted_weights = { default_variant => 100 }
75
73
  weighting_registry.except(default_variant).each_key do |variant|
@@ -24,9 +24,7 @@ class TestTrack::JobSession
24
24
 
25
25
  def notify_unsynced_assignments!
26
26
  identity_visitor_map.each_value do |visitor|
27
- if visitor.loaded? && visitor.unsynced_assignments.present?
28
- TestTrack::ThreadedVisitorNotifier.new(visitor).notify
29
- end
27
+ TestTrack::ThreadedVisitorNotifier.new(visitor).notify if visitor.loaded? && visitor.unsynced_assignments.present?
30
28
  end
31
29
  end
32
30
 
@@ -13,7 +13,7 @@ class TestTrack::LazyVisitorByIdentity
13
13
 
14
14
  private
15
15
 
16
- def method_missing(method, *args, &block) # rubocop:disable Style/MethodMissing
16
+ def method_missing(method, *args, &block)
17
17
  __visitor__.send(method, *args, &block)
18
18
  end
19
19
 
@@ -22,6 +22,7 @@ module TestTrack::MisconfigurationNotifier
22
22
  class Airbrake
23
23
  def notify(msg)
24
24
  raise "Aibrake was configured but not found" unless defined?(::Airbrake)
25
+
25
26
  if ::Airbrake.respond_to?(:notify_or_ignore)
26
27
  ::Airbrake.notify_or_ignore(StandardError.new, error_message: msg)
27
28
  else
@@ -28,6 +28,7 @@ class TestTrack::NotifyAssignmentJob
28
28
  def maybe_track
29
29
  return "failure" unless TestTrack.enabled?
30
30
  return "success" if skip_analytics_event?
31
+
31
32
  result = TestTrack.analytics.track(TestTrack::AnalyticsEvent.new(visitor_id, assignment))
32
33
  result ? "success" : "failure"
33
34
  end
@@ -3,6 +3,7 @@ class TestTrack::Remote::FakeServer
3
3
 
4
4
  def self.reset!(seed)
5
5
  raise('Cannot reset FakeServer if TestTrack is enabled.') if TestTrack.enabled?
6
+
6
7
  put('api/v1/reset', seed: seed)
7
8
  end
8
9
  end
@@ -21,6 +21,7 @@ class TestTrack::Remote::Identifier
21
21
 
22
22
  def visitor_opts!
23
23
  raise("Visitor data unavailable until you save this identifier.") unless attributes[:remote_visitor]
24
+
24
25
  { id: remote_visitor.id, assignments: remote_visitor.assignments }
25
26
  end
26
27
  end
@@ -15,6 +15,7 @@ class TestTrack::VariantCalculator
15
15
 
16
16
  def variant
17
17
  return nil unless split_registry.loaded?
18
+
18
19
  @variant ||= _variant || raise("Assignment bucket out of range. #{assignment_bucket} unmatched in #{split_name}: #{weighting}")
19
20
  end
20
21
 
@@ -18,6 +18,7 @@ class TestTrack::VaryDSL
18
18
 
19
19
  def when(*variants, &block)
20
20
  raise ArgumentError, "must provide at least one variant" if variants.blank?
21
+
21
22
  variants.each do |variant|
22
23
  assign_behavior_to_variant(variant, block)
23
24
  end
@@ -25,6 +26,7 @@ class TestTrack::VaryDSL
25
26
 
26
27
  def default(variant, &block)
27
28
  raise ArgumentError, "cannot provide more than one `default`" unless default_variant.nil?
29
+
28
30
  @default_variant = assign_behavior_to_variant(variant, block)
29
31
  end
30
32
 
@@ -57,6 +59,7 @@ class TestTrack::VaryDSL
57
59
  variant = variant.to_s
58
60
 
59
61
  raise ArgumentError, "must provide block for #{variant}" unless behavior_proc
62
+
60
63
  notify_because_vary(<<-MESSAGE) if variant_behaviors.include?(variant)
61
64
  configures variant "#{variant}" more than once.
62
65
  This will raise an error in the next version of test_track_rails_client.
@@ -93,6 +96,7 @@ class TestTrack::VaryDSL
93
96
  raise ArgumentError, "must provide exactly one `default`" unless default_variant
94
97
  raise ArgumentError, "must provide at least one `when`" unless variant_behaviors.size >= 2
95
98
  return true unless split_variants
99
+
96
100
  missing_variants = split_variants - variant_behaviors.keys
97
101
  notify_because_vary("does not configure variants #{missing_variants.to_sentence}") && false unless missing_variants.empty?
98
102
  end
@@ -23,6 +23,7 @@ class TestTrack::Visitor
23
23
  raise "unknown opts: #{opts.keys.to_sentence}" if opts.present?
24
24
 
25
25
  raise ArgumentError, "must provide block to `vary` for #{split_name}" unless block_given?
26
+
26
27
  v = TestTrack::VaryDSL.new(assignment: assignment_for(split_name), context: context, split_registry: split_registry)
27
28
  yield v
28
29
  v.send :run
@@ -59,6 +59,7 @@ class TestTrack::WebSession
59
59
 
60
60
  If your app doesn't support authentication, set it to `:none`.
61
61
  ERROR
62
+
62
63
  identity = controller.class.test_track_identity
63
64
  controller.send(identity) unless identity == :none
64
65
  end
@@ -34,9 +34,7 @@ class TestTrack::WebSessionVisitorRepository
34
34
 
35
35
  def notify_unsynced_assignments!
36
36
  all.each do |visitor|
37
- if visitor.loaded? && visitor.unsynced_assignments.present?
38
- TestTrack::ThreadedVisitorNotifier.new(visitor).notify
39
- end
37
+ TestTrack::ThreadedVisitorNotifier.new(visitor).notify if visitor.loaded? && visitor.unsynced_assignments.present?
40
38
  end
41
39
  end
42
40
 
data/lib/test_track.rb CHANGED
@@ -95,6 +95,7 @@ module TestTrack
95
95
 
96
96
  def url
97
97
  return nil unless private_url
98
+
98
99
  full_uri = URI.parse(private_url)
99
100
  full_uri.user = nil
100
101
  full_uri.password = nil
@@ -1,3 +1,3 @@
1
1
  module TestTrackRailsClient
2
- VERSION = "4.0.0.alpha33" # rubocop:disable Style/MutableConstant
2
+ VERSION = "4.0.0.alpha34" # rubocop:disable Style/MutableConstant
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test_track_rails_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0.alpha33
4
+ version: 4.0.0.alpha34
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan O'Neill
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2019-11-11 00:00:00.000000000 Z
16
+ date: 2020-01-08 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: delayed_job
@@ -134,7 +134,7 @@ dependencies:
134
134
  version: '4.1'
135
135
  - - "<"
136
136
  - !ruby/object:Gem::Version
137
- version: '6.0'
137
+ version: '7.0'
138
138
  type: :runtime
139
139
  prerelease: false
140
140
  version_requirements: !ruby/object:Gem::Requirement
@@ -144,7 +144,7 @@ dependencies:
144
144
  version: '4.1'
145
145
  - - "<"
146
146
  - !ruby/object:Gem::Version
147
- version: '6.0'
147
+ version: '7.0'
148
148
  - !ruby/object:Gem::Dependency
149
149
  name: request_store
150
150
  requirement: !ruby/object:Gem::Requirement
@@ -356,8 +356,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
356
356
  - !ruby/object:Gem::Version
357
357
  version: 1.3.1
358
358
  requirements: []
359
- rubyforge_project:
360
- rubygems_version: 2.5.1
359
+ rubygems_version: 3.0.6
361
360
  signing_key:
362
361
  specification_version: 4
363
362
  summary: Rails client for TestTrack