Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
inherit_from: .rubocop_todo.yml

AllCops:
TargetRubyVersion: 2.5
DisabledByDefault: true
SuggestExtensions: false
Exclude:
- 'gemfiles/**/*'

Expand Down Expand Up @@ -112,7 +111,7 @@ Layout/SpaceInsideParens:
Enabled: true

Style/StringLiterals:
Enabled: false
Enabled: true
EnforcedStyle: double_quotes

Layout/IndentationStyle:
Expand Down
14 changes: 0 additions & 14 deletions .rubocop_todo.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ source "https://rubygems.org"

gemspec

gem 'rubocop', require: false
gem "rubocop", require: false
gem "matrix"
gem "codeclimate-test-reporter"
6 changes: 3 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env rake
# frozen_string_literal: true

require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
require "bundler/gem_tasks"
require "rspec/core/rake_task"

RSpec::Core::RakeTask.new('spec')
RSpec::Core::RakeTask.new("spec")

task default: :spec
48 changes: 24 additions & 24 deletions lib/split.rb
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
# frozen_string_literal: true

require 'redis'
require "redis"

require 'split/algorithms'
require 'split/algorithms/block_randomization'
require 'split/algorithms/weighted_sample'
require 'split/algorithms/whiplash'
require 'split/alternative'
require 'split/cache'
require 'split/configuration'
require 'split/encapsulated_helper'
require 'split/exceptions'
require 'split/experiment'
require 'split/experiment_catalog'
require 'split/extensions/string'
require 'split/goals_collection'
require 'split/helper'
require 'split/combined_experiments_helper'
require 'split/metric'
require 'split/persistence'
require 'split/redis_interface'
require 'split/trial'
require 'split/user'
require 'split/version'
require 'split/zscore'
require 'split/engine' if defined?(Rails)
require "split/algorithms"
require "split/algorithms/block_randomization"
require "split/algorithms/weighted_sample"
require "split/algorithms/whiplash"
require "split/alternative"
require "split/cache"
require "split/configuration"
require "split/encapsulated_helper"
require "split/exceptions"
require "split/experiment"
require "split/experiment_catalog"
require "split/extensions/string"
require "split/goals_collection"
require "split/helper"
require "split/combined_experiments_helper"
require "split/metric"
require "split/persistence"
require "split/redis_interface"
require "split/trial"
require "split/user"
require "split/version"
require "split/zscore"
require "split/engine" if defined?(Rails)

module Split
extend self
Expand Down
2 changes: 1 addition & 1 deletion lib/split/algorithms.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
end
end

require 'rubystats'
require "rubystats"

module Split
module Algorithms
Expand Down
26 changes: 13 additions & 13 deletions lib/split/alternative.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ def set_p_winner(prob, goal = nil)
end

def participant_count
Split.redis.hget(key, 'participant_count').to_i
Split.redis.hget(key, "participant_count").to_i
end

def participant_count=(count)
Split.redis.hset(key, 'participant_count', count.to_i)
Split.redis.hset(key, "participant_count", count.to_i)
end

def completed_count(goal = nil)
Expand Down Expand Up @@ -82,7 +82,7 @@ def set_completed_count(count, goal = nil)
end

def increment_participation
Split.redis.hincrby key, 'participant_count', 1
Split.redis.hincrby key, "participant_count", 1
end

def increment_completion(goal = nil)
Expand Down Expand Up @@ -112,7 +112,7 @@ def z_score(goal = nil)
control = experiment.control
alternative = self

return 'N/A' if control.name == alternative.name
return "N/A" if control.name == alternative.name

p_a = alternative.conversion_rate(goal)
p_c = control.conversion_rate(goal)
Expand All @@ -121,13 +121,13 @@ def z_score(goal = nil)
n_c = control.participant_count

# can't calculate zscore for P(x) > 1
return 'N/A' if p_a > 1 || p_c > 1
return "N/A" if p_a > 1 || p_c > 1

Split::Zscore.calculate(p_a, n_a, p_c, n_c)
end

def extra_info
data = Split.redis.hget(key, 'recorded_info')
data = Split.redis.hget(key, "recorded_info")
if data && data.length > 1
begin
JSON.parse(data)
Expand All @@ -149,24 +149,24 @@ def record_extra_info(k, value = 1)
@recorded_info[k] = value
end

Split.redis.hset key, 'recorded_info', (@recorded_info || {}).to_json
Split.redis.hset key, "recorded_info", (@recorded_info || {}).to_json
end

def save
Split.redis.hsetnx key, 'participant_count', 0
Split.redis.hsetnx key, 'completed_count', 0
Split.redis.hsetnx key, 'p_winner', p_winner
Split.redis.hsetnx key, 'recorded_info', (@recorded_info || {}).to_json
Split.redis.hsetnx key, "participant_count", 0
Split.redis.hsetnx key, "completed_count", 0
Split.redis.hsetnx key, "p_winner", p_winner
Split.redis.hsetnx key, "recorded_info", (@recorded_info || {}).to_json
end

def validate!
unless String === @name || hash_with_correct_values?(@name)
raise ArgumentError, 'Alternative must be a string'
raise ArgumentError, "Alternative must be a string"
end
end

def reset
Split.redis.hmset key, 'participant_count', 0, 'completed_count', 0, 'recorded_info', nil
Split.redis.hmset key, "participant_count", 0, "completed_count", 0, "recorded_info", nil
unless goals.empty?
goals.each do |g|
field = "completed_count:#{g}"
Expand Down
6 changes: 3 additions & 3 deletions lib/split/combined_experiments_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ def ab_combined_test(metric_descriptor, control = nil, *alternatives)
end

def find_combined_experiment(metric_descriptor)
raise(Split::InvalidExperimentsFormatError, 'Invalid descriptor class (String or Symbol required)') unless metric_descriptor.class == String || metric_descriptor.class == Symbol
raise(Split::InvalidExperimentsFormatError, 'Enable configuration') unless Split.configuration.enabled
raise(Split::InvalidExperimentsFormatError, 'Enable `allow_multiple_experiments`') unless Split.configuration.allow_multiple_experiments
raise(Split::InvalidExperimentsFormatError, "Invalid descriptor class (String or Symbol required)") unless metric_descriptor.class == String || metric_descriptor.class == Symbol
raise(Split::InvalidExperimentsFormatError, "Enable configuration") unless Split.configuration.enabled
raise(Split::InvalidExperimentsFormatError, "Enable `allow_multiple_experiments`") unless Split.configuration.allow_multiple_experiments
Split.configuration.experiments[metric_descriptor.to_sym]
end
end
Expand Down
132 changes: 66 additions & 66 deletions lib/split/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,83 +39,83 @@ class Configuration
def bots
@bots ||= {
# Indexers
'AdsBot-Google' => 'Google Adwords',
'Baidu' => 'Chinese search engine',
'Baiduspider' => 'Chinese search engine',
'bingbot' => 'Microsoft bing bot',
'Butterfly' => 'Topsy Labs',
'Gigabot' => 'Gigabot spider',
'Googlebot' => 'Google spider',
'MJ12bot' => 'Majestic-12 spider',
'msnbot' => 'Microsoft bot',
'rogerbot' => 'SeoMoz spider',
'PaperLiBot' => 'PaperLi is another content curation service',
'Slurp' => 'Yahoo spider',
'Sogou' => 'Chinese search engine',
'spider' => 'generic web spider',
'UnwindFetchor' => 'Gnip crawler',
'WordPress' => 'WordPress spider',
'YandexAccessibilityBot' => 'Yandex accessibility spider',
'YandexBot' => 'Yandex spider',
'YandexMobileBot' => 'Yandex mobile spider',
'ZIBB' => 'ZIBB spider',
"AdsBot-Google" => "Google Adwords",
"Baidu" => "Chinese search engine",
"Baiduspider" => "Chinese search engine",
"bingbot" => "Microsoft bing bot",
"Butterfly" => "Topsy Labs",
"Gigabot" => "Gigabot spider",
"Googlebot" => "Google spider",
"MJ12bot" => "Majestic-12 spider",
"msnbot" => "Microsoft bot",
"rogerbot" => "SeoMoz spider",
"PaperLiBot" => "PaperLi is another content curation service",
"Slurp" => "Yahoo spider",
"Sogou" => "Chinese search engine",
"spider" => "generic web spider",
"UnwindFetchor" => "Gnip crawler",
"WordPress" => "WordPress spider",
"YandexAccessibilityBot" => "Yandex accessibility spider",
"YandexBot" => "Yandex spider",
"YandexMobileBot" => "Yandex mobile spider",
"ZIBB" => "ZIBB spider",

# HTTP libraries
'Apache-HttpClient' => 'Java http library',
'AppEngine-Google' => 'Google App Engine',
'curl' => 'curl unix CLI http client',
'ColdFusion' => 'ColdFusion http library',
'EventMachine HttpClient' => 'Ruby http library',
'Go http package' => 'Go http library',
'Go-http-client' => 'Go http library',
'Java' => 'Generic Java http library',
'libwww-perl' => 'Perl client-server library loved by script kids',
'lwp-trivial' => 'Another Perl library loved by script kids',
'Python-urllib' => 'Python http library',
'PycURL' => 'Python http library',
'Test Certificate Info' => 'C http library?',
'Typhoeus' => 'Ruby http library',
'Wget' => 'wget unix CLI http client',
"Apache-HttpClient" => "Java http library",
"AppEngine-Google" => "Google App Engine",
"curl" => "curl unix CLI http client",
"ColdFusion" => "ColdFusion http library",
"EventMachine HttpClient" => "Ruby http library",
"Go http package" => "Go http library",
"Go-http-client" => "Go http library",
"Java" => "Generic Java http library",
"libwww-perl" => "Perl client-server library loved by script kids",
"lwp-trivial" => "Another Perl library loved by script kids",
"Python-urllib" => "Python http library",
"PycURL" => "Python http library",
"Test Certificate Info" => "C http library?",
"Typhoeus" => "Ruby http library",
"Wget" => "wget unix CLI http client",

# URL expanders / previewers
'awe.sm' => 'Awe.sm URL expander',
'bitlybot' => 'bit.ly bot',
'bot@linkfluence.net' => 'Linkfluence bot',
'facebookexternalhit' => 'facebook bot',
'Facebot' => 'Facebook crawler',
'Feedfetcher-Google' => 'Google Feedfetcher',
'https://developers.google.com/+/web/snippet' => 'Google+ Snippet Fetcher',
'LinkedInBot' => 'LinkedIn bot',
'LongURL' => 'URL expander service',
'NING' => 'NING - Yet Another Twitter Swarmer',
'Pinterestbot' => 'Pinterest Bot',
'redditbot' => 'Reddit Bot',
'ShortLinkTranslate' => 'Link shortener',
'Slackbot' => 'Slackbot link expander',
'TweetmemeBot' => 'TweetMeMe Crawler',
'Twitterbot' => 'Twitter URL expander',
'UnwindFetch' => 'Gnip URL expander',
'vkShare' => 'VKontake Sharer',
"awe.sm" => "Awe.sm URL expander",
"bitlybot" => "bit.ly bot",
"bot@linkfluence.net" => "Linkfluence bot",
"facebookexternalhit" => "facebook bot",
"Facebot" => "Facebook crawler",
"Feedfetcher-Google" => "Google Feedfetcher",
"https://developers.google.com/+/web/snippet" => "Google+ Snippet Fetcher",
"LinkedInBot" => "LinkedIn bot",
"LongURL" => "URL expander service",
"NING" => "NING - Yet Another Twitter Swarmer",
"Pinterestbot" => "Pinterest Bot",
"redditbot" => "Reddit Bot",
"ShortLinkTranslate" => "Link shortener",
"Slackbot" => "Slackbot link expander",
"TweetmemeBot" => "TweetMeMe Crawler",
"Twitterbot" => "Twitter URL expander",
"UnwindFetch" => "Gnip URL expander",
"vkShare" => "VKontake Sharer",

# Uptime monitoring
'check_http' => 'Nagios monitor',
'GoogleStackdriverMonitoring' => 'Google Cloud monitor',
'NewRelicPinger' => 'NewRelic monitor',
'Panopta' => 'Monitoring service',
'Pingdom' => 'Pingdom monitoring',
'SiteUptime' => 'Site monitoring services',
'UptimeRobot' => 'Monitoring service',
"check_http" => "Nagios monitor",
"GoogleStackdriverMonitoring" => "Google Cloud monitor",
"NewRelicPinger" => "NewRelic monitor",
"Panopta" => "Monitoring service",
"Pingdom" => "Pingdom monitoring",
"SiteUptime" => "Site monitoring services",
"UptimeRobot" => "Monitoring service",

# ???
'DigitalPersona Fingerprint Software' => 'HP Fingerprint scanner',
'ShowyouBot' => 'Showyou iOS app spider',
'ZyBorg' => 'Zyborg? Hmmm....',
'ELB-HealthChecker' => 'ELB Health Check'
"DigitalPersona Fingerprint Software" => "HP Fingerprint scanner",
"ShowyouBot" => "Showyou iOS app spider",
"ZyBorg" => "Zyborg? Hmmm....",
"ELB-HealthChecker" => "ELB Health Check"
}
end

def experiments=(experiments)
raise InvalidExperimentsFormatError.new('Experiments must be a Hash') unless experiments.respond_to?(:keys)
raise InvalidExperimentsFormatError.new("Experiments must be a Hash") unless experiments.respond_to?(:keys)
@experiments = experiments
end

Expand Down Expand Up @@ -232,7 +232,7 @@ def initialize
@include_rails_helper = true
@beta_probability_simulations = 10000
@winning_alternative_recalculation_interval = 60 * 60 * 24 # 1 day
@redis = ENV.fetch(ENV.fetch('REDIS_PROVIDER', 'REDIS_URL'), 'redis://localhost:6379')
@redis = ENV.fetch(ENV.fetch("REDIS_PROVIDER", "REDIS_URL"), "redis://localhost:6379")
@dashboard_pagination_default_per_page = 10
end

Expand Down
Loading