Search is not available for this dataset
id
stringlengths 1
8
| text
stringlengths 72
9.81M
| addition_count
int64 0
10k
| commit_subject
stringlengths 0
3.7k
| deletion_count
int64 0
8.43k
| file_extension
stringlengths 0
32
| lang
stringlengths 1
94
| license
stringclasses 10
values | repo_name
stringlengths 9
59
|
---|---|---|---|---|---|---|---|---|
10071550 | <NME> configuration.rb
<BEF> # frozen_string_literal: true
module Split
class Configuration
attr_accessor :ignore_ip_addresses
attr_accessor :ignore_filter
attr_accessor :db_failover
attr_accessor :db_failover_on_db_error
attr_accessor :db_failover_allow_parameter_override
attr_accessor :allow_multiple_experiments
attr_accessor :enabled
attr_accessor :persistence
attr_accessor :persistence_cookie_length
attr_accessor :persistence_cookie_domain
attr_accessor :algorithm
attr_accessor :store_override
attr_accessor :start_manually
attr_accessor :reset_manually
attr_accessor :on_trial
attr_accessor :on_trial_choose
attr_accessor :on_trial_complete
attr_accessor :on_experiment_reset
attr_accessor :on_experiment_delete
attr_accessor :on_before_experiment_reset
attr_accessor :on_experiment_winner_choose
attr_accessor :on_before_experiment_delete
attr_accessor :include_rails_helper
attr_accessor :beta_probability_simulations
attr_accessor :winning_alternative_recalculation_interval
attr_accessor :redis
attr_accessor :dashboard_pagination_default_per_page
attr_accessor :cache
attr_reader :experiments
attr_writer :bots
attr_writer :robot_regex
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",
# 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",
# URL expanders / previewers
"awe.sm" => "Awe.sm URL expander",
"bitlybot" => "bit.ly bot",
"[email protected]" => "Linkfluence bot",
"facebookexternalhit" => "facebook bot",
"Facebot" => "Facebook crawler",
'DigitalPersona Fingerprint Software' => 'HP Fingerprint scanner',
'ShowyouBot' => 'Showyou iOS app spider',
'ZyBorg' => 'Zyborg? Hmmm....',
}
end
"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",
# ???
"DigitalPersona Fingerprint Software" => "HP Fingerprint scanner",
@metrics = {}
if self.experiments
self.experiments.each do |key, value|
metric_name = value_for(value, :metric).to_sym rescue nil
if metric_name
@metrics[metric_name] ||= []
@metrics[metric_name] << Split::Experiment.new(key)
end
end
end
!enabled
end
def experiment_for(name)
if normalized_experiments
# TODO symbols
normalized_experiments[name.to_sym]
end
end
def metrics
return @metrics if defined?(@metrics)
@metrics = {}
if self.experiments
self.experiments.each do |key, value|
metrics = value_for(value, :metric) rescue nil
Array(metrics).each do |metric_name|
if metric_name
@metrics[metric_name.to_sym] ||= []
@metrics[metric_name.to_sym] << Split::Experiment.new(key)
end
end
end
end
@metrics
end
def normalized_experiments
return nil if @experiments.nil?
experiment_config = {}
@experiments.keys.each do |name|
experiment_config[name.to_sym] = {}
end
@experiments.each do |experiment_name, settings|
alternatives = if (alts = value_for(settings, :alternatives))
normalize_alternatives(alts)
end
experiment_data = {
alternatives: alternatives,
goals: value_for(settings, :goals),
metadata: value_for(settings, :metadata),
algorithm: value_for(settings, :algorithm),
resettable: value_for(settings, :resettable)
}
experiment_data.each do |name, value|
experiment_config[experiment_name.to_sym][name] = value if value != nil
end
end
experiment_config
end
def normalize_alternatives(alternatives)
given_probability, num_with_probability = alternatives.inject([0, 0]) do |a, v|
p, n = a
if percent = value_for(v, :percent)
[p + percent, n + 1]
else
a
end
end
num_without_probability = alternatives.length - num_with_probability
unassigned_probability = ((100.0 - given_probability) / num_without_probability / 100.0)
if num_with_probability.nonzero?
alternatives = alternatives.map do |v|
if (name = value_for(v, :name)) && (percent = value_for(v, :percent))
{ name => percent / 100.0 }
elsif name = value_for(v, :name)
{ name => unassigned_probability }
else
{ v => unassigned_probability }
end
end
[alternatives.shift, alternatives]
else
alternatives = alternatives.dup
[alternatives.shift, alternatives]
end
end
def robot_regex
@robot_regex ||= /\b(?:#{escaped_bots.join('|')})\b|\A\W*\z/i
end
def initialize
@ignore_ip_addresses = []
@ignore_filter = proc { |request| is_robot? || is_ignored_ip_address? }
@db_failover = false
@db_failover_on_db_error = proc { |error| } # e.g. use Rails logger here
@on_experiment_reset = proc { |experiment| }
@on_experiment_delete = proc { |experiment| }
@on_before_experiment_reset = proc { |experiment| }
@on_before_experiment_delete = proc { |experiment| }
@on_experiment_winner_choose = proc { |experiment| }
@db_failover_allow_parameter_override = false
@allow_multiple_experiments = false
@enabled = true
@experiments = {}
@persistence = Split::Persistence::SessionAdapter
@persistence_cookie_length = 31536000 # One year from now
@persistence_cookie_domain = nil
@algorithm = Split::Algorithms::WeightedSample
@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")
@dashboard_pagination_default_per_page = 10
end
private
def value_for(hash, key)
if hash.kind_of?(Hash)
hash.has_key?(key.to_s) ? hash[key.to_s] : hash[key.to_sym]
end
end
def escaped_bots
bots.map { |key, _| Regexp.escape(key) }
end
end
end
<MSG> Merge pull request #260 from WhitehawkVentures/master
support multiple metrics per experiment
<DFF> @@ -86,6 +86,7 @@ module Split
'DigitalPersona Fingerprint Software' => 'HP Fingerprint scanner',
'ShowyouBot' => 'Showyou iOS app spider',
'ZyBorg' => 'Zyborg? Hmmm....',
+ 'ELB-HealthChecker' => 'ELB Health Check'
}
end
@@ -110,10 +111,12 @@ module Split
@metrics = {}
if self.experiments
self.experiments.each do |key, value|
- metric_name = value_for(value, :metric).to_sym rescue nil
- if metric_name
- @metrics[metric_name] ||= []
- @metrics[metric_name] << Split::Experiment.new(key)
+ metrics = value_for(value, :metric) rescue nil
+ Array(metrics).each do |metric_name|
+ if metric_name
+ @metrics[metric_name.to_sym] ||= []
+ @metrics[metric_name.to_sym] << Split::Experiment.new(key)
+ end
end
end
end
| 7 | Merge pull request #260 from WhitehawkVentures/master | 4 | .rb | rb | mit | splitrb/split |
10071551 | <NME> MANIFEST.in
<BEF> include AUTHORS
include README
include TODO
include MANIFEST.in
recursive-include djangopypi *
recursive-include chishop *
<MSG> Added LICENSE and Changelog to MANIFEST.
<DFF> @@ -2,5 +2,7 @@ include AUTHORS
include README
include TODO
include MANIFEST.in
+include LICENSE
+include Changelog
recursive-include djangopypi *
recursive-include chishop *
| 2 | Added LICENSE and Changelog to MANIFEST. | 0 | .in | in | bsd-3-clause | ask/chishop |
10071552 | <NME> README.md
<BEF> # [Split](https://libraries.io/rubygems/split)
[](http://badge.fury.io/rb/split)

[](https://codeclimate.com/github/splitrb/split)
[](https://codeclimate.com/github/splitrb/split/coverage)
[](https://github.com/RichardLitt/standard-readme)
[](https://www.codetriage.com/splitrb/split)
> ๐ The Rack Based A/B testing framework https://libraries.io/rubygems/split
Split is a rack based A/B testing framework designed to work with Rails, Sinatra or any other rack based app.
Split is heavily inspired by the [Abingo](https://github.com/ryanb/abingo) and [Vanity](https://github.com/assaf/vanity) Rails A/B testing plugins and [Resque](https://github.com/resque/resque) in its use of Redis.
Split is designed to be hacker friendly, allowing for maximum customisation and extensibility.
## Install
### Requirements
Split v4.0+ is currently tested with Ruby >= 2.5 and Rails >= 5.2.
If your project requires compatibility with Ruby 2.4.x or older Rails versions. You can try v3.0 or v0.8.0(for Ruby 1.9.3)
Split uses Redis as a datastore.
Split only supports Redis 4.0 or greater.
If you're on OS X, Homebrew is the simplest way to install Redis:
```bash
brew install redis
redis-server /usr/local/etc/redis.conf
```
You now have a Redis daemon running on port `6379`.
### Setup
```bash
gem install split
```
#### Rails
Adding `gem 'split'` to your Gemfile will autoload it when rails starts up, as long as you've configured Redis it will 'just work'.
#### Sinatra
To configure Sinatra with Split you need to enable sessions and mix in the helper methods. Add the following lines at the top of your Sinatra app:
```ruby
require 'split'
class MySinatraApp < Sinatra::Base
enable :sessions
helpers Split::Helper
get '/' do
...
end
```
## Usage
To begin your A/B test use the `ab_test` method, naming your experiment with the first argument and then the different alternatives which you wish to test on as the other arguments.
`ab_test` returns one of the alternatives, if a user has already seen that test they will get the same alternative as before, which you can use to split your code on.
It can be used to render different templates, show different text or any other case based logic.
`ab_finished` is used to make a completion of an experiment, or conversion.
Example: View
```erb
<% ab_test(:login_button, "/images/button1.jpg", "/images/button2.jpg") do |button_file| %>
<%= image_tag(button_file, alt: "Login!") %>
<% end %>
```
Example: Controller
```ruby
def register_new_user
# See what level of free points maximizes users' decision to buy replacement points.
@starter_points = ab_test(:new_user_free_points, '100', '200', '300')
end
```
Example: Conversion tracking (in a controller!)
```ruby
def buy_new_points
# some business logic
ab_finished(:new_user_free_points)
end
```
Example: Conversion tracking (in a view)
```erb
Thanks for signing up, dude! <% ab_finished(:signup_page_redesign) %>
```
You can find more examples, tutorials and guides on the [wiki](https://github.com/splitrb/split/wiki).
## Statistical Validity
Split has two options for you to use to determine which alternative is the best.
The first option (default on the dashboard) uses a z test (n>30) for the difference between your control and alternative conversion rates to calculate statistical significance. This test will tell you whether an alternative is better or worse than your control, but it will not distinguish between which alternative is the best in an experiment with multiple alternatives. Split will only tell you if your experiment is 90%, 95%, or 99% significant, and this test only works if you have more than 30 participants and 5 conversions for each branch.
As per this [blog post](https://www.evanmiller.org/how-not-to-run-an-ab-test.html) on the pitfalls of A/B testing, it is highly recommended that you determine your requisite sample size for each branch before running the experiment. Otherwise, you'll have an increased rate of false positives (experiments which show a significant effect where really there is none).
[Here](https://www.evanmiller.org/ab-testing/sample-size.html) is a sample size calculator for your convenience.
The second option uses simulations from a beta distribution to determine the probability that the given alternative is the winner compared to all other alternatives. You can view these probabilities by clicking on the drop-down menu labeled "Confidence." This option should be used when the experiment has more than just 1 control and 1 alternative. It can also be used for a simple, 2-alternative A/B test.
Calculating the beta-distribution simulations for a large number of experiments can be slow, so the results are cached. You can specify how often they should be recalculated (the default is once per day).
```ruby
Split.configure do |config|
config.winning_alternative_recalculation_interval = 3600 # 1 hour
end
```
## Extras
### Weighted alternatives
Perhaps you only want to show an alternative to 10% of your visitors because it is very experimental or not yet fully load tested.
To do this you can pass a weight with each alternative in the following ways:
```ruby
ab_test(:homepage_design, {'Old' => 18}, {'New' => 2})
ab_test(:homepage_design, 'Old', {'New' => 1.0/9})
ab_test(:homepage_design, {'Old' => 9}, 'New')
```
This will only show the new alternative to visitors 1 in 10 times, the default weight for an alternative is 1.
### Overriding alternatives
For development and testing, you may wish to force your app to always return an alternative.
You can do this by passing it as a parameter in the url.
If you have an experiment called `button_color` with alternatives called `red` and `blue` used on your homepage, a url such as:
http://myawesomesite.com?ab_test[button_color]=red
will always have red buttons. This won't be stored in your session or count towards to results, unless you set the `store_override` configuration option.
In the event you want to disable all tests without having to know the individual experiment names, add a `SPLIT_DISABLE` query parameter.
http://myawesomesite.com?SPLIT_DISABLE=true
It is not required to send `SPLIT_DISABLE=false` to activate Split.
### Rspec Helper
To aid testing with RSpec, write `spec/support/split_helper.rb` and call `use_ab_test(alternatives_by_experiment)` in your specs as instructed below:
```ruby
# Create a file with these contents at 'spec/support/split_helper.rb'
# and ensure it is `require`d in your rails_helper.rb or spec_helper.rb
module SplitHelper
# Force a specific experiment alternative to always be returned:
# use_ab_test(signup_form: "single_page")
#
# Force alternatives for multiple experiments:
# use_ab_test(signup_form: "single_page", pricing: "show_enterprise_prices")
#
def use_ab_test(alternatives_by_experiment)
allow_any_instance_of(Split::Helper).to receive(:ab_test) do |_receiver, experiment, &block|
variant = alternatives_by_experiment.fetch(experiment) { |key| raise "Unknown experiment '#{key}'" }
block.call(variant) unless block.nil?
variant
end
end
end
# Make the `use_ab_test` method available to all specs:
RSpec.configure do |config|
config.include SplitHelper
end
```
Now you can call `use_ab_test(alternatives_by_experiment)` in your specs, for example:
```ruby
it "registers using experimental signup" do
use_ab_test experiment_name: "alternative_name"
post "/signups"
...
end
```
### Starting experiments manually
By default new A/B tests will be active right after deployment. In case you would like to start new test a while after
the deploy, you can do it by setting the `start_manually` configuration option to `true`.
After choosing this option tests won't be started right after deploy, but after pressing the `Start` button in Split admin dashboard. If a test is deleted from the Split dashboard, then it can only be started after pressing the `Start` button whenever being re-initialized.
### Reset after completion
When a user completes a test their session is reset so that they may start the test again in the future.
To stop this behaviour you can pass the following option to the `ab_finished` method:
```ruby
ab_finished(:experiment_name, reset: false)
```
The user will then always see the alternative they started with.
Any old unfinished experiment key will be deleted from the user's data storage if the experiment had been removed or is over and a winner had been chosen. This allows a user to enroll into any new experiment in cases when the `allow_multiple_experiments` config option is set to `false`.
### Reset experiments manually
By default Split automatically resets the experiment whenever it detects the configuration for an experiment has changed (e.g. you call `ab_test` with different alternatives). You can prevent this by setting the option `reset_manually` to `true`.
You may want to do this when you want to change something, like the variants' names, the metadata about an experiment, etc. without resetting everything.
### Multiple experiments at once
By default Split will avoid users participating in multiple experiments at once. This means you are less likely to skew results by adding in more variation to your tests.
To stop this behaviour and allow users to participate in multiple experiments at once set the `allow_multiple_experiments` config option to true like so:
```ruby
Split.configure do |config|
config.allow_multiple_experiments = true
end
```
This will allow the user to participate in any number of experiments and belong to any alternative in each experiment. This has the possible downside of a variation in one experiment influencing the outcome of another.
To address this, setting the `allow_multiple_experiments` config option to 'control' like so:
```ruby
Split.configure do |config|
config.allow_multiple_experiments = 'control'
end
```
For this to work, each and every experiment you define must have an alternative named 'control'. This will allow the user to participate in multiple experiments as long as the user belongs to the alternative 'control' in each experiment. As soon as the user belongs to an alternative named something other than 'control' the user may not participate in any more experiments. Calling ab_test(<other experiments>) will always return the first alternative without adding the user to that experiment.
### Experiment Persistence
Split comes with three built-in persistence adapters for storing users and the alternatives they've been given for each experiment.
By default Split will store the tests for each user in the session.
You can optionally configure Split to use a cookie, Redis, or any custom adapter of your choosing.
#### Cookies
```ruby
Split.configure do |config|
config.persistence = :cookie
end
```
When using the cookie persistence, Split stores data into an anonymous tracking cookie named 'split', which expires in 1 year. To change that, set the `persistence_cookie_length` in the configuration (unit of time in seconds).
```ruby
Split.configure do |config|
config.persistence = :cookie
config.persistence_cookie_length = 2592000 # 30 days
end
```
The data stored consists of the experiment name and the variants the user is in. Example: { "experiment_name" => "variant_a" }
__Note:__ Using cookies depends on `ActionDispatch::Cookies` or any identical API
#### Redis
Using Redis will allow ab_users to persist across sessions or machines.
```ruby
Split.configure do |config|
config.persistence = Split::Persistence::RedisAdapter.with_config(lookup_by: -> (context) { context.current_user_id })
# Equivalent
# config.persistence = Split::Persistence::RedisAdapter.with_config(lookup_by: :current_user_id)
end
```
Options:
* `lookup_by`: method to invoke per request for uniquely identifying ab_users (mandatory configuration)
* `namespace`: separate namespace to store these persisted values (default "persistence")
* `expire_seconds`: sets TTL for user key. (if a user is in multiple experiments most recent update will reset TTL for all their assignments)
#### Dual Adapter
The Dual Adapter allows the use of different persistence adapters for logged-in and logged-out users. A common use case is to use Redis for logged-in users and Cookies for logged-out users.
```ruby
cookie_adapter = Split::Persistence::CookieAdapter
redis_adapter = Split::Persistence::RedisAdapter.with_config(
lookup_by: -> (context) { context.send(:current_user).try(:id) },
expire_seconds: 2592000)
Split.configure do |config|
config.persistence = Split::Persistence::DualAdapter.with_config(
logged_in: -> (context) { !context.send(:current_user).try(:id).nil? },
logged_in_adapter: redis_adapter,
logged_out_adapter: cookie_adapter)
config.persistence_cookie_length = 2592000 # 30 days
end
```
#### Custom Adapter
Your custom adapter needs to implement the same API as existing adapters.
See `Split::Persistence::CookieAdapter` or `Split::Persistence::SessionAdapter` for a starting point.
```ruby
Split.configure do |config|
config.persistence = YourCustomAdapterClass
end
```
### Trial Event Hooks
You can define methods that will be called at the same time as experiment
alternative participation and goal completion.
For example:
``` ruby
Split.configure do |config|
config.on_trial = :log_trial # run on every trial
config.on_trial_choose = :log_trial_choose # run on trials with new users only
config.on_trial_complete = :log_trial_complete
end
```
Set these attributes to a method name available in the same context as the
`ab_test` method. These methods should accept one argument, a `Trial` instance.
``` ruby
def log_trial(trial)
logger.info "experiment=%s alternative=%s user=%s" %
[ trial.experiment.name, trial.alternative, current_user.id ]
end
def log_trial_choose(trial)
logger.info "[new user] experiment=%s alternative=%s user=%s" %
[ trial.experiment.name, trial.alternative, current_user.id ]
end
def log_trial_complete(trial)
logger.info "experiment=%s alternative=%s user=%s complete=true" %
[ trial.experiment.name, trial.alternative, current_user.id ]
end
```
#### Views
If you are running `ab_test` from a view, you must define your event
hook callback as a
[helper_method](https://apidock.com/rails/AbstractController/Helpers/ClassMethods/helper_method)
in the controller:
``` ruby
helper_method :log_trial_choose
def log_trial_choose(trial)
logger.info "experiment=%s alternative=%s user=%s" %
[ trial.experiment.name, trial.alternative, current_user.id ]
end
```
### Experiment Hooks
You can assign a proc that will be called when an experiment is reset or deleted. You can use these hooks to call methods within your application to keep data related to experiments in sync with Split.
For example:
``` ruby
Split.configure do |config|
# after experiment reset or deleted
config.on_experiment_reset = -> (example) { # Do something on reset }
config.on_experiment_delete = -> (experiment) { # Do something else on delete }
# before experiment reset or deleted
config.on_before_experiment_reset = -> (example) { # Do something on reset }
config.on_before_experiment_delete = -> (experiment) { # Do something else on delete }
# after experiment winner had been set
config.on_experiment_winner_choose = -> (experiment) { # Do something on winner choose }
end
```
## Web Interface
Split comes with a Sinatra-based front end to get an overview of how your experiments are doing.
If you are running Rails 2: You can mount this inside your app using Rack::URLMap in your `config.ru`
```ruby
require 'split/dashboard'
run Rack::URLMap.new \
"/" => Your::App.new,
"/split" => Split::Dashboard.new
```
However, if you are using Rails 3 or higher: You can mount this inside your app routes by first adding this to the Gemfile:
```ruby
gem 'split', require: 'split/dashboard'
```
Then adding this to config/routes.rb
```ruby
mount Split::Dashboard, at: 'split'
```
You may want to password protect that page, you can do so with `Rack::Auth::Basic` (in your split initializer file)
```ruby
# Rails apps or apps that already depend on activesupport
You can also add meta data for each experiment, very useful when you need more than an alternative name to change behaviour:
```yaml
my_first_experiment:
alternatives:
match "/split" => Split::Dashboard, anchor: false, via: [:get, :post, :delete], constraints: -> (request) do
request.env['warden'].authenticated? # are we authenticated?
request.env['warden'].authenticate! # authenticate if not already
# or even check any other condition such as request.env['warden'].user.is_admin?
end
```
More information on this [here](https://steve.dynedge.co.uk/2011/12/09/controlling-access-to-routes-and-rack-apps-in-rails-3-with-devise-and-warden/)
### Screenshot

## Configuration
You can override the default configuration options of Split like so:
```ruby
Split.configure do |config|
config.db_failover = true # handle Redis errors gracefully
config.db_failover_on_db_error = -> (error) { Rails.logger.error(error.message) }
config.allow_multiple_experiments = true
config.enabled = true
config.persistence = Split::Persistence::SessionAdapter
#config.start_manually = false ## new test will have to be started manually from the admin panel. default false
#config.reset_manually = false ## if true, it never resets the experiment data, even if the configuration changes
config.include_rails_helper = true
config.redis = "redis://custom.redis.url:6380"
end
```
Split looks for the Redis host in the environment variable `REDIS_URL` then
defaults to `redis://localhost:6379` if not specified by configure block.
On platforms like Heroku, Split will use the value of `REDIS_PROVIDER` to
determine which env variable key to use when retrieving the host config. This
defaults to `REDIS_URL`.
### Filtering
In most scenarios you don't want to have AB-Testing enabled for web spiders, robots or special groups of users.
Split provides functionality to filter this based on a predefined, extensible list of bots, IP-lists or custom exclude logic.
```ruby
Split.configure do |config|
# bot config
config.robot_regex = /my_custom_robot_regex/ # or
config.bots['newbot'] = "Description for bot with 'newbot' user agent, which will be added to config.robot_regex for exclusion"
# IP config
config.ignore_ip_addresses << '81.19.48.130' # or regex: /81\.19\.48\.[0-9]+/
# or provide your own filter functionality, the default is proc{ |request| is_robot? || is_ignored_ip_address? || is_preview? }
config.ignore_filter = -> (request) { CustomExcludeLogic.excludes?(request) }
end
```
### Experiment configuration
Instead of providing the experiment options inline, you can store them
in a hash. This hash can control your experiment's alternatives, weights,
algorithm and if the experiment resets once finished:
```ruby
Split.configure do |config|
config.experiments = {
my_first_experiment: {
alternatives: ["a", "b"],
resettable: false
},
:my_second_experiment => {
algorithm: 'Split::Algorithms::Whiplash',
alternatives: [
{ name: "a", percent: 67 },
{ name: "b", percent: 33 }
]
}
}
end
```
You can also store your experiments in a YAML file:
```ruby
Split.configure do |config|
config.experiments = YAML.load_file "config/experiments.yml"
end
```
You can then define the YAML file like:
```yaml
my_first_experiment:
alternatives:
- a
- b
my_second_experiment:
alternatives:
- name: a
percent: 67
- name: b
percent: 33
resettable: false
```
This simplifies the calls from your code:
```ruby
ab_test(:my_first_experiment)
```
and:
```ruby
ab_finished(:my_first_experiment)
```
You can also add meta data for each experiment, which is very useful when you need more than an alternative name to change behaviour:
```ruby
Split.configure do |config|
config.experiments = {
my_first_experiment: {
alternatives: ["a", "b"],
metadata: {
"a" => {"text" => "Have a fantastic day"},
"b" => {"text" => "Don't get hit by a bus"}
}
}
}
end
```
```yaml
my_first_experiment:
alternatives:
- a
- b
metadata:
a:
text: "Have a fantastic day"
b:
text: "Don't get hit by a bus"
```
This allows for some advanced experiment configuration using methods like:
```ruby
trial.alternative.name # => "a"
trial.metadata['text'] # => "Have a fantastic day"
```
or in views:
```erb
<% ab_test("my_first_experiment") do |alternative, meta| %>
<%= alternative %>
<small><%= meta['text'] %></small>
<% end %>
```
The keys used in meta data should be Strings
#### Metrics
You might wish to track generic metrics, such as conversions, and use
those to complete multiple different experiments without adding more to
your code. You can use the configuration hash to do this, thanks to
the `:metric` option.
```ruby
Split.configure do |config|
config.experiments = {
my_first_experiment: {
alternatives: ["a", "b"],
metric: :my_metric
}
}
end
```
Your code may then track a completion using the metric instead of
the experiment name:
```ruby
ab_finished(:my_metric)
```
You can also create a new metric by instantiating and saving a new Metric object.
```ruby
Split::Metric.new(:my_metric)
Split::Metric.save
```
#### Goals
You might wish to allow an experiment to have multiple, distinguishable goals.
The API to define goals for an experiment is this:
```ruby
ab_test({link_color: ["purchase", "refund"]}, "red", "blue")
```
or you can define them in a configuration file:
```ruby
Split.configure do |config|
config.experiments = {
link_color: {
alternatives: ["red", "blue"],
goals: ["purchase", "refund"]
}
}
end
```
To complete a goal conversion, you do it like:
```ruby
ab_finished(link_color: "purchase")
```
Note that if you pass additional options, that should be a separate hash:
```ruby
ab_finished({ link_color: "purchase" }, reset: false)
```
**NOTE:** This does not mean that a single experiment can complete more than one goal.
Once you finish one of the goals, the test is considered to be completed, and finishing the other goal will no longer register. (Assuming the test runs with `reset: false`.)
**Good Example**: Test if listing Plan A first result in more conversions to Plan A (goal: "plana_conversion") or Plan B (goal: "planb_conversion").
**Bad Example**: Test if button color increases conversion rate through multiple steps of a funnel. THIS WILL NOT WORK.
**Bad Example**: Test both how button color affects signup *and* how it affects login, at the same time. THIS WILL NOT WORK.
#### Combined Experiments
If you want to test how button color affects signup *and* how it affects login at the same time, use combined experiments.
Configure like so:
```ruby
Split.configuration.experiments = {
:button_color_experiment => {
:alternatives => ["blue", "green"],
:combined_experiments => ["button_color_on_signup", "button_color_on_login"]
}
}
```
Starting the combined test starts all combined experiments
```ruby
ab_combined_test(:button_color_experiment)
```
Finish each combined test as normal
```ruby
ab_finished(:button_color_on_login)
ab_finished(:button_color_on_signup)
```
**Additional Configuration**:
* Be sure to enable `allow_multiple_experiments`
* In Sinatra include the CombinedExperimentsHelper
```
helpers Split::CombinedExperimentsHelper
```
### DB failover solution
Due to the fact that Redis has no automatic failover mechanism, it's
possible to switch on the `db_failover` config option, so that `ab_test`
and `ab_finished` will not crash in case of a db failure. `ab_test` always
delivers alternative A (the first one) in that case.
It's also possible to set a `db_failover_on_db_error` callback (proc)
for example to log these errors via Rails.logger.
### Redis
You may want to change the Redis host and port Split connects to, or
set various other options at startup.
Split has a `redis` setter which can be given a string or a Redis
object. This means if you're already using Redis in your app, Split
can re-use the existing connection.
String: `Split.redis = 'redis://localhost:6379'`
Redis: `Split.redis = $redis`
For our rails app we have a `config/initializers/split.rb` file where
we load `config/split.yml` by hand and set the Redis information
appropriately.
Here's our `config/split.yml`:
```yml
development: redis://localhost:6379
test: redis://localhost:6379
staging: redis://redis1.example.com:6379
fi: redis://localhost:6379
production: redis://redis1.example.com:6379
```
And our initializer:
```ruby
split_config = YAML.load_file(Rails.root.join('config', 'split.yml'))
Split.redis = split_config[Rails.env]
```
### Redis Caching (v4.0+)
In some high-volume usage scenarios, Redis load can be incurred by repeated
fetches for fairly static data. Enabling caching will reduce this load.
```ruby
Split.configuration.cache = true
````
This currently caches:
- `Split::ExperimentCatalog.find`
- `Split::Experiment.start_time`
- `Split::Experiment.winner`
## Namespaces
If you're running multiple, separate instances of Split you may want
to namespace the keyspaces so they do not overlap. This is not unlike
the approach taken by many memcached clients.
This feature can be provided by the [redis-namespace](https://github.com/defunkt/redis-namespace)
library. To configure Split to use `Redis::Namespace`, do the following:
1. Add `redis-namespace` to your Gemfile:
```ruby
gem 'redis-namespace'
```
2. Configure `Split.redis` to use a `Redis::Namespace` instance (possible in an
initializer):
```ruby
redis = Redis.new(url: ENV['REDIS_URL']) # or whatever config you want
Split.redis = Redis::Namespace.new(:your_namespace, redis: redis)
```
## Outside of a Web Session
Split provides the Helper module to facilitate running experiments inside web sessions.
Alternatively, you can access the underlying Metric, Trial, Experiment and Alternative objects to
conduct experiments that are not tied to a web session.
```ruby
# create a new experiment
experiment = Split::ExperimentCatalog.find_or_create('color', 'red', 'blue')
# create a new trial
trial = Split::Trial.new(:experiment => experiment)
# run trial
trial.choose!
# get the result, returns either red or blue
trial.alternative.name
# if the goal has been achieved, increment the successful completions for this alternative.
if goal_achieved?
trial.complete!
end
```
## Algorithms
By default, Split ships with `Split::Algorithms::WeightedSample` that randomly selects from possible alternatives for a traditional a/b test.
It is possible to specify static weights to favor certain alternatives.
`Split::Algorithms::Whiplash` is an implementation of a [multi-armed bandit algorithm](http://stevehanov.ca/blog/index.php?id=132).
This algorithm will automatically weight the alternatives based on their relative performance,
choosing the better-performing ones more often as trials are completed.
`Split::Algorithms::BlockRandomization` is an algorithm that ensures equal
participation across all alternatives. This algorithm will choose the alternative
with the fewest participants. In the event of multiple minimum participant alternatives
(i.e. starting a new "Block") the algorithm will choose a random alternative from
those minimum participant alternatives.
Users may also write their own algorithms. The default algorithm may be specified globally in the configuration file, or on a per experiment basis using the experiments hash of the configuration file.
To change the algorithm globally for all experiments, use the following in your initializer:
```ruby
Split.configure do |config|
config.algorithm = Split::Algorithms::Whiplash
end
```
## Extensions
- [Split::Export](https://github.com/splitrb/split-export) - Easily export A/B test data out of Split.
- [Split::Analytics](https://github.com/splitrb/split-analytics) - Push test data to Google Analytics.
- [Split::Mongoid](https://github.com/MongoHQ/split-mongoid) - Store experiment data in mongoid (still uses redis).
- [Split::Cacheable](https://github.com/harrystech/split_cacheable) - Automatically create cache buckets per test.
- [Split::Counters](https://github.com/bernardkroes/split-counters) - Add counters per experiment and alternative.
- [Split::Cli](https://github.com/craigmcnamara/split-cli) - A CLI to trigger Split A/B tests.
## Screencast
Ryan bates has produced an excellent 10 minute screencast about split on the Railscasts site: [A/B Testing with Split](http://railscasts.com/episodes/331-a-b-testing-with-split)
## Blogposts
* [Recipe: A/B testing with KISSMetrics and the split gem](https://robots.thoughtbot.com/post/9595887299/recipe-a-b-testing-with-kissmetrics-and-the-split-gem)
* [Rails A/B testing with Split on Heroku](http://blog.nathanhumbert.com/2012/02/rails-ab-testing-with-split-on-heroku.html)
## Backers
Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/split#backer)]
<a href="https://opencollective.com/split/backer/0/website" target="_blank"><img src="https://opencollective.com/split/backer/0/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/1/website" target="_blank"><img src="https://opencollective.com/split/backer/1/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/2/website" target="_blank"><img src="https://opencollective.com/split/backer/2/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/3/website" target="_blank"><img src="https://opencollective.com/split/backer/3/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/4/website" target="_blank"><img src="https://opencollective.com/split/backer/4/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/5/website" target="_blank"><img src="https://opencollective.com/split/backer/5/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/6/website" target="_blank"><img src="https://opencollective.com/split/backer/6/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/7/website" target="_blank"><img src="https://opencollective.com/split/backer/7/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/8/website" target="_blank"><img src="https://opencollective.com/split/backer/8/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/9/website" target="_blank"><img src="https://opencollective.com/split/backer/9/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/10/website" target="_blank"><img src="https://opencollective.com/split/backer/10/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/11/website" target="_blank"><img src="https://opencollective.com/split/backer/11/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/12/website" target="_blank"><img src="https://opencollective.com/split/backer/12/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/13/website" target="_blank"><img src="https://opencollective.com/split/backer/13/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/14/website" target="_blank"><img src="https://opencollective.com/split/backer/14/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/15/website" target="_blank"><img src="https://opencollective.com/split/backer/15/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/16/website" target="_blank"><img src="https://opencollective.com/split/backer/16/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/17/website" target="_blank"><img src="https://opencollective.com/split/backer/17/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/18/website" target="_blank"><img src="https://opencollective.com/split/backer/18/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/19/website" target="_blank"><img src="https://opencollective.com/split/backer/19/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/20/website" target="_blank"><img src="https://opencollective.com/split/backer/20/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/21/website" target="_blank"><img src="https://opencollective.com/split/backer/21/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/22/website" target="_blank"><img src="https://opencollective.com/split/backer/22/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/23/website" target="_blank"><img src="https://opencollective.com/split/backer/23/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/24/website" target="_blank"><img src="https://opencollective.com/split/backer/24/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/25/website" target="_blank"><img src="https://opencollective.com/split/backer/25/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/26/website" target="_blank"><img src="https://opencollective.com/split/backer/26/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/27/website" target="_blank"><img src="https://opencollective.com/split/backer/27/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/28/website" target="_blank"><img src="https://opencollective.com/split/backer/28/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/29/website" target="_blank"><img src="https://opencollective.com/split/backer/29/avatar.svg"></a>
## Sponsors
Become a sponsor and get your logo on our README on Github with a link to your site. [[Become a sponsor](https://opencollective.com/split#sponsor)]
<a href="https://opencollective.com/split/sponsor/0/website" target="_blank"><img src="https://opencollective.com/split/sponsor/0/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/1/website" target="_blank"><img src="https://opencollective.com/split/sponsor/1/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/2/website" target="_blank"><img src="https://opencollective.com/split/sponsor/2/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/3/website" target="_blank"><img src="https://opencollective.com/split/sponsor/3/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/4/website" target="_blank"><img src="https://opencollective.com/split/sponsor/4/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/5/website" target="_blank"><img src="https://opencollective.com/split/sponsor/5/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/6/website" target="_blank"><img src="https://opencollective.com/split/sponsor/6/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/7/website" target="_blank"><img src="https://opencollective.com/split/sponsor/7/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/8/website" target="_blank"><img src="https://opencollective.com/split/sponsor/8/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/9/website" target="_blank"><img src="https://opencollective.com/split/sponsor/9/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/10/website" target="_blank"><img src="https://opencollective.com/split/sponsor/10/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/11/website" target="_blank"><img src="https://opencollective.com/split/sponsor/11/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/12/website" target="_blank"><img src="https://opencollective.com/split/sponsor/12/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/13/website" target="_blank"><img src="https://opencollective.com/split/sponsor/13/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/14/website" target="_blank"><img src="https://opencollective.com/split/sponsor/14/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/15/website" target="_blank"><img src="https://opencollective.com/split/sponsor/15/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/16/website" target="_blank"><img src="https://opencollective.com/split/sponsor/16/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/17/website" target="_blank"><img src="https://opencollective.com/split/sponsor/17/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/18/website" target="_blank"><img src="https://opencollective.com/split/sponsor/18/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/19/website" target="_blank"><img src="https://opencollective.com/split/sponsor/19/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/20/website" target="_blank"><img src="https://opencollective.com/split/sponsor/20/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/21/website" target="_blank"><img src="https://opencollective.com/split/sponsor/21/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/22/website" target="_blank"><img src="https://opencollective.com/split/sponsor/22/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/23/website" target="_blank"><img src="https://opencollective.com/split/sponsor/23/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/24/website" target="_blank"><img src="https://opencollective.com/split/sponsor/24/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/25/website" target="_blank"><img src="https://opencollective.com/split/sponsor/25/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/26/website" target="_blank"><img src="https://opencollective.com/split/sponsor/26/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/27/website" target="_blank"><img src="https://opencollective.com/split/sponsor/27/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/28/website" target="_blank"><img src="https://opencollective.com/split/sponsor/28/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/29/website" target="_blank"><img src="https://opencollective.com/split/sponsor/29/avatar.svg"></a>
## Contribute
Please do! Over 70 different people have contributed to the project, you can see them all here: https://github.com/splitrb/split/graphs/contributors.
### Development
The source code is hosted at [GitHub](https://github.com/splitrb/split).
Report issues and feature requests on [GitHub Issues](https://github.com/splitrb/split/issues).
You can find a discussion form on [Google Groups](https://groups.google.com/d/forum/split-ruby).
### Tests
Run the tests like this:
# Start a Redis server in another tab.
redis-server
bundle
rake spec
### A Note on Patches and Pull Requests
* Fork the project.
* Make your feature addition or bug fix.
* Add tests for it. This is important so I don't break it in a
future version unintentionally.
* Add documentation if necessary.
* Commit. Do not mess with the rakefile, version, or history.
(If you want to have your own version, that is fine. But bump the version in a commit by itself, which I can ignore when I pull.)
* Send a pull request. Bonus points for topic branches.
### Code of Conduct
Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.
## Copyright
[MIT License](LICENSE) ยฉ 2019 [Andrew Nesbitt](https://github.com/andrew).
<MSG> README: Metadata example in ruby
Metadata keys must be in JSON values (no symbols) otherwise #185 bug occurs.
<DFF> @@ -430,6 +430,20 @@ finished(:my_first_experiment)
You can also add meta data for each experiment, very useful when you need more than an alternative name to change behaviour:
+```ruby
+Split.configure do |config|
+ config.experiments = {
+ my_first_experiment: {
+ alternatives: ["a", "b"],
+ metadata: {
+ "checkbox" => {"text" => "Have a fantastic day"},
+ "radio" => {"text" => "Don't get hit by a bus"},
+ }
+ },
+ }
+end
+```
+
```yaml
my_first_experiment:
alternatives:
| 14 | README: Metadata example in ruby | 0 | .md | md | mit | splitrb/split |
10071553 | <NME> README.md
<BEF> # [Split](https://libraries.io/rubygems/split)
[](http://badge.fury.io/rb/split)

[](https://codeclimate.com/github/splitrb/split)
[](https://codeclimate.com/github/splitrb/split/coverage)
[](https://github.com/RichardLitt/standard-readme)
[](https://www.codetriage.com/splitrb/split)
> ๐ The Rack Based A/B testing framework https://libraries.io/rubygems/split
Split is a rack based A/B testing framework designed to work with Rails, Sinatra or any other rack based app.
Split is heavily inspired by the [Abingo](https://github.com/ryanb/abingo) and [Vanity](https://github.com/assaf/vanity) Rails A/B testing plugins and [Resque](https://github.com/resque/resque) in its use of Redis.
Split is designed to be hacker friendly, allowing for maximum customisation and extensibility.
## Install
### Requirements
Split v4.0+ is currently tested with Ruby >= 2.5 and Rails >= 5.2.
If your project requires compatibility with Ruby 2.4.x or older Rails versions. You can try v3.0 or v0.8.0(for Ruby 1.9.3)
Split uses Redis as a datastore.
Split only supports Redis 4.0 or greater.
If you're on OS X, Homebrew is the simplest way to install Redis:
```bash
brew install redis
redis-server /usr/local/etc/redis.conf
```
You now have a Redis daemon running on port `6379`.
### Setup
```bash
gem install split
```
#### Rails
Adding `gem 'split'` to your Gemfile will autoload it when rails starts up, as long as you've configured Redis it will 'just work'.
#### Sinatra
To configure Sinatra with Split you need to enable sessions and mix in the helper methods. Add the following lines at the top of your Sinatra app:
```ruby
require 'split'
class MySinatraApp < Sinatra::Base
enable :sessions
helpers Split::Helper
get '/' do
...
end
```
## Usage
To begin your A/B test use the `ab_test` method, naming your experiment with the first argument and then the different alternatives which you wish to test on as the other arguments.
`ab_test` returns one of the alternatives, if a user has already seen that test they will get the same alternative as before, which you can use to split your code on.
It can be used to render different templates, show different text or any other case based logic.
`ab_finished` is used to make a completion of an experiment, or conversion.
Example: View
```erb
<% ab_test(:login_button, "/images/button1.jpg", "/images/button2.jpg") do |button_file| %>
<%= image_tag(button_file, alt: "Login!") %>
<% end %>
```
Example: Controller
```ruby
def register_new_user
# See what level of free points maximizes users' decision to buy replacement points.
@starter_points = ab_test(:new_user_free_points, '100', '200', '300')
end
```
Example: Conversion tracking (in a controller!)
```ruby
def buy_new_points
# some business logic
ab_finished(:new_user_free_points)
end
```
Example: Conversion tracking (in a view)
```erb
Thanks for signing up, dude! <% ab_finished(:signup_page_redesign) %>
```
You can find more examples, tutorials and guides on the [wiki](https://github.com/splitrb/split/wiki).
## Statistical Validity
Split has two options for you to use to determine which alternative is the best.
The first option (default on the dashboard) uses a z test (n>30) for the difference between your control and alternative conversion rates to calculate statistical significance. This test will tell you whether an alternative is better or worse than your control, but it will not distinguish between which alternative is the best in an experiment with multiple alternatives. Split will only tell you if your experiment is 90%, 95%, or 99% significant, and this test only works if you have more than 30 participants and 5 conversions for each branch.
As per this [blog post](https://www.evanmiller.org/how-not-to-run-an-ab-test.html) on the pitfalls of A/B testing, it is highly recommended that you determine your requisite sample size for each branch before running the experiment. Otherwise, you'll have an increased rate of false positives (experiments which show a significant effect where really there is none).
[Here](https://www.evanmiller.org/ab-testing/sample-size.html) is a sample size calculator for your convenience.
The second option uses simulations from a beta distribution to determine the probability that the given alternative is the winner compared to all other alternatives. You can view these probabilities by clicking on the drop-down menu labeled "Confidence." This option should be used when the experiment has more than just 1 control and 1 alternative. It can also be used for a simple, 2-alternative A/B test.
Calculating the beta-distribution simulations for a large number of experiments can be slow, so the results are cached. You can specify how often they should be recalculated (the default is once per day).
```ruby
Split.configure do |config|
config.winning_alternative_recalculation_interval = 3600 # 1 hour
end
```
## Extras
### Weighted alternatives
Perhaps you only want to show an alternative to 10% of your visitors because it is very experimental or not yet fully load tested.
To do this you can pass a weight with each alternative in the following ways:
```ruby
ab_test(:homepage_design, {'Old' => 18}, {'New' => 2})
ab_test(:homepage_design, 'Old', {'New' => 1.0/9})
ab_test(:homepage_design, {'Old' => 9}, 'New')
```
This will only show the new alternative to visitors 1 in 10 times, the default weight for an alternative is 1.
### Overriding alternatives
For development and testing, you may wish to force your app to always return an alternative.
You can do this by passing it as a parameter in the url.
If you have an experiment called `button_color` with alternatives called `red` and `blue` used on your homepage, a url such as:
http://myawesomesite.com?ab_test[button_color]=red
will always have red buttons. This won't be stored in your session or count towards to results, unless you set the `store_override` configuration option.
In the event you want to disable all tests without having to know the individual experiment names, add a `SPLIT_DISABLE` query parameter.
http://myawesomesite.com?SPLIT_DISABLE=true
It is not required to send `SPLIT_DISABLE=false` to activate Split.
### Rspec Helper
To aid testing with RSpec, write `spec/support/split_helper.rb` and call `use_ab_test(alternatives_by_experiment)` in your specs as instructed below:
```ruby
# Create a file with these contents at 'spec/support/split_helper.rb'
# and ensure it is `require`d in your rails_helper.rb or spec_helper.rb
module SplitHelper
# Force a specific experiment alternative to always be returned:
# use_ab_test(signup_form: "single_page")
#
# Force alternatives for multiple experiments:
# use_ab_test(signup_form: "single_page", pricing: "show_enterprise_prices")
#
def use_ab_test(alternatives_by_experiment)
allow_any_instance_of(Split::Helper).to receive(:ab_test) do |_receiver, experiment, &block|
variant = alternatives_by_experiment.fetch(experiment) { |key| raise "Unknown experiment '#{key}'" }
block.call(variant) unless block.nil?
variant
end
end
end
# Make the `use_ab_test` method available to all specs:
RSpec.configure do |config|
config.include SplitHelper
end
```
Now you can call `use_ab_test(alternatives_by_experiment)` in your specs, for example:
```ruby
it "registers using experimental signup" do
use_ab_test experiment_name: "alternative_name"
post "/signups"
...
end
```
### Starting experiments manually
By default new A/B tests will be active right after deployment. In case you would like to start new test a while after
the deploy, you can do it by setting the `start_manually` configuration option to `true`.
After choosing this option tests won't be started right after deploy, but after pressing the `Start` button in Split admin dashboard. If a test is deleted from the Split dashboard, then it can only be started after pressing the `Start` button whenever being re-initialized.
### Reset after completion
When a user completes a test their session is reset so that they may start the test again in the future.
To stop this behaviour you can pass the following option to the `ab_finished` method:
```ruby
ab_finished(:experiment_name, reset: false)
```
The user will then always see the alternative they started with.
Any old unfinished experiment key will be deleted from the user's data storage if the experiment had been removed or is over and a winner had been chosen. This allows a user to enroll into any new experiment in cases when the `allow_multiple_experiments` config option is set to `false`.
### Reset experiments manually
By default Split automatically resets the experiment whenever it detects the configuration for an experiment has changed (e.g. you call `ab_test` with different alternatives). You can prevent this by setting the option `reset_manually` to `true`.
You may want to do this when you want to change something, like the variants' names, the metadata about an experiment, etc. without resetting everything.
### Multiple experiments at once
By default Split will avoid users participating in multiple experiments at once. This means you are less likely to skew results by adding in more variation to your tests.
To stop this behaviour and allow users to participate in multiple experiments at once set the `allow_multiple_experiments` config option to true like so:
```ruby
Split.configure do |config|
config.allow_multiple_experiments = true
end
```
This will allow the user to participate in any number of experiments and belong to any alternative in each experiment. This has the possible downside of a variation in one experiment influencing the outcome of another.
To address this, setting the `allow_multiple_experiments` config option to 'control' like so:
```ruby
Split.configure do |config|
config.allow_multiple_experiments = 'control'
end
```
For this to work, each and every experiment you define must have an alternative named 'control'. This will allow the user to participate in multiple experiments as long as the user belongs to the alternative 'control' in each experiment. As soon as the user belongs to an alternative named something other than 'control' the user may not participate in any more experiments. Calling ab_test(<other experiments>) will always return the first alternative without adding the user to that experiment.
### Experiment Persistence
Split comes with three built-in persistence adapters for storing users and the alternatives they've been given for each experiment.
By default Split will store the tests for each user in the session.
You can optionally configure Split to use a cookie, Redis, or any custom adapter of your choosing.
#### Cookies
```ruby
Split.configure do |config|
config.persistence = :cookie
end
```
When using the cookie persistence, Split stores data into an anonymous tracking cookie named 'split', which expires in 1 year. To change that, set the `persistence_cookie_length` in the configuration (unit of time in seconds).
```ruby
Split.configure do |config|
config.persistence = :cookie
config.persistence_cookie_length = 2592000 # 30 days
end
```
The data stored consists of the experiment name and the variants the user is in. Example: { "experiment_name" => "variant_a" }
__Note:__ Using cookies depends on `ActionDispatch::Cookies` or any identical API
#### Redis
Using Redis will allow ab_users to persist across sessions or machines.
```ruby
Split.configure do |config|
config.persistence = Split::Persistence::RedisAdapter.with_config(lookup_by: -> (context) { context.current_user_id })
# Equivalent
# config.persistence = Split::Persistence::RedisAdapter.with_config(lookup_by: :current_user_id)
end
```
Options:
* `lookup_by`: method to invoke per request for uniquely identifying ab_users (mandatory configuration)
* `namespace`: separate namespace to store these persisted values (default "persistence")
* `expire_seconds`: sets TTL for user key. (if a user is in multiple experiments most recent update will reset TTL for all their assignments)
#### Dual Adapter
The Dual Adapter allows the use of different persistence adapters for logged-in and logged-out users. A common use case is to use Redis for logged-in users and Cookies for logged-out users.
```ruby
cookie_adapter = Split::Persistence::CookieAdapter
redis_adapter = Split::Persistence::RedisAdapter.with_config(
lookup_by: -> (context) { context.send(:current_user).try(:id) },
expire_seconds: 2592000)
Split.configure do |config|
config.persistence = Split::Persistence::DualAdapter.with_config(
logged_in: -> (context) { !context.send(:current_user).try(:id).nil? },
logged_in_adapter: redis_adapter,
logged_out_adapter: cookie_adapter)
config.persistence_cookie_length = 2592000 # 30 days
end
```
#### Custom Adapter
Your custom adapter needs to implement the same API as existing adapters.
See `Split::Persistence::CookieAdapter` or `Split::Persistence::SessionAdapter` for a starting point.
```ruby
Split.configure do |config|
config.persistence = YourCustomAdapterClass
end
```
### Trial Event Hooks
You can define methods that will be called at the same time as experiment
alternative participation and goal completion.
For example:
``` ruby
Split.configure do |config|
config.on_trial = :log_trial # run on every trial
config.on_trial_choose = :log_trial_choose # run on trials with new users only
config.on_trial_complete = :log_trial_complete
end
```
Set these attributes to a method name available in the same context as the
`ab_test` method. These methods should accept one argument, a `Trial` instance.
``` ruby
def log_trial(trial)
logger.info "experiment=%s alternative=%s user=%s" %
[ trial.experiment.name, trial.alternative, current_user.id ]
end
def log_trial_choose(trial)
logger.info "[new user] experiment=%s alternative=%s user=%s" %
[ trial.experiment.name, trial.alternative, current_user.id ]
end
def log_trial_complete(trial)
logger.info "experiment=%s alternative=%s user=%s complete=true" %
[ trial.experiment.name, trial.alternative, current_user.id ]
end
```
#### Views
If you are running `ab_test` from a view, you must define your event
hook callback as a
[helper_method](https://apidock.com/rails/AbstractController/Helpers/ClassMethods/helper_method)
in the controller:
``` ruby
helper_method :log_trial_choose
def log_trial_choose(trial)
logger.info "experiment=%s alternative=%s user=%s" %
[ trial.experiment.name, trial.alternative, current_user.id ]
end
```
### Experiment Hooks
You can assign a proc that will be called when an experiment is reset or deleted. You can use these hooks to call methods within your application to keep data related to experiments in sync with Split.
For example:
``` ruby
Split.configure do |config|
# after experiment reset or deleted
config.on_experiment_reset = -> (example) { # Do something on reset }
config.on_experiment_delete = -> (experiment) { # Do something else on delete }
# before experiment reset or deleted
config.on_before_experiment_reset = -> (example) { # Do something on reset }
config.on_before_experiment_delete = -> (experiment) { # Do something else on delete }
# after experiment winner had been set
config.on_experiment_winner_choose = -> (experiment) { # Do something on winner choose }
end
```
## Web Interface
Split comes with a Sinatra-based front end to get an overview of how your experiments are doing.
If you are running Rails 2: You can mount this inside your app using Rack::URLMap in your `config.ru`
```ruby
require 'split/dashboard'
run Rack::URLMap.new \
"/" => Your::App.new,
"/split" => Split::Dashboard.new
```
However, if you are using Rails 3 or higher: You can mount this inside your app routes by first adding this to the Gemfile:
```ruby
gem 'split', require: 'split/dashboard'
```
Then adding this to config/routes.rb
```ruby
mount Split::Dashboard, at: 'split'
```
You may want to password protect that page, you can do so with `Rack::Auth::Basic` (in your split initializer file)
```ruby
# Rails apps or apps that already depend on activesupport
You can also add meta data for each experiment, very useful when you need more than an alternative name to change behaviour:
```yaml
my_first_experiment:
alternatives:
match "/split" => Split::Dashboard, anchor: false, via: [:get, :post, :delete], constraints: -> (request) do
request.env['warden'].authenticated? # are we authenticated?
request.env['warden'].authenticate! # authenticate if not already
# or even check any other condition such as request.env['warden'].user.is_admin?
end
```
More information on this [here](https://steve.dynedge.co.uk/2011/12/09/controlling-access-to-routes-and-rack-apps-in-rails-3-with-devise-and-warden/)
### Screenshot

## Configuration
You can override the default configuration options of Split like so:
```ruby
Split.configure do |config|
config.db_failover = true # handle Redis errors gracefully
config.db_failover_on_db_error = -> (error) { Rails.logger.error(error.message) }
config.allow_multiple_experiments = true
config.enabled = true
config.persistence = Split::Persistence::SessionAdapter
#config.start_manually = false ## new test will have to be started manually from the admin panel. default false
#config.reset_manually = false ## if true, it never resets the experiment data, even if the configuration changes
config.include_rails_helper = true
config.redis = "redis://custom.redis.url:6380"
end
```
Split looks for the Redis host in the environment variable `REDIS_URL` then
defaults to `redis://localhost:6379` if not specified by configure block.
On platforms like Heroku, Split will use the value of `REDIS_PROVIDER` to
determine which env variable key to use when retrieving the host config. This
defaults to `REDIS_URL`.
### Filtering
In most scenarios you don't want to have AB-Testing enabled for web spiders, robots or special groups of users.
Split provides functionality to filter this based on a predefined, extensible list of bots, IP-lists or custom exclude logic.
```ruby
Split.configure do |config|
# bot config
config.robot_regex = /my_custom_robot_regex/ # or
config.bots['newbot'] = "Description for bot with 'newbot' user agent, which will be added to config.robot_regex for exclusion"
# IP config
config.ignore_ip_addresses << '81.19.48.130' # or regex: /81\.19\.48\.[0-9]+/
# or provide your own filter functionality, the default is proc{ |request| is_robot? || is_ignored_ip_address? || is_preview? }
config.ignore_filter = -> (request) { CustomExcludeLogic.excludes?(request) }
end
```
### Experiment configuration
Instead of providing the experiment options inline, you can store them
in a hash. This hash can control your experiment's alternatives, weights,
algorithm and if the experiment resets once finished:
```ruby
Split.configure do |config|
config.experiments = {
my_first_experiment: {
alternatives: ["a", "b"],
resettable: false
},
:my_second_experiment => {
algorithm: 'Split::Algorithms::Whiplash',
alternatives: [
{ name: "a", percent: 67 },
{ name: "b", percent: 33 }
]
}
}
end
```
You can also store your experiments in a YAML file:
```ruby
Split.configure do |config|
config.experiments = YAML.load_file "config/experiments.yml"
end
```
You can then define the YAML file like:
```yaml
my_first_experiment:
alternatives:
- a
- b
my_second_experiment:
alternatives:
- name: a
percent: 67
- name: b
percent: 33
resettable: false
```
This simplifies the calls from your code:
```ruby
ab_test(:my_first_experiment)
```
and:
```ruby
ab_finished(:my_first_experiment)
```
You can also add meta data for each experiment, which is very useful when you need more than an alternative name to change behaviour:
```ruby
Split.configure do |config|
config.experiments = {
my_first_experiment: {
alternatives: ["a", "b"],
metadata: {
"a" => {"text" => "Have a fantastic day"},
"b" => {"text" => "Don't get hit by a bus"}
}
}
}
end
```
```yaml
my_first_experiment:
alternatives:
- a
- b
metadata:
a:
text: "Have a fantastic day"
b:
text: "Don't get hit by a bus"
```
This allows for some advanced experiment configuration using methods like:
```ruby
trial.alternative.name # => "a"
trial.metadata['text'] # => "Have a fantastic day"
```
or in views:
```erb
<% ab_test("my_first_experiment") do |alternative, meta| %>
<%= alternative %>
<small><%= meta['text'] %></small>
<% end %>
```
The keys used in meta data should be Strings
#### Metrics
You might wish to track generic metrics, such as conversions, and use
those to complete multiple different experiments without adding more to
your code. You can use the configuration hash to do this, thanks to
the `:metric` option.
```ruby
Split.configure do |config|
config.experiments = {
my_first_experiment: {
alternatives: ["a", "b"],
metric: :my_metric
}
}
end
```
Your code may then track a completion using the metric instead of
the experiment name:
```ruby
ab_finished(:my_metric)
```
You can also create a new metric by instantiating and saving a new Metric object.
```ruby
Split::Metric.new(:my_metric)
Split::Metric.save
```
#### Goals
You might wish to allow an experiment to have multiple, distinguishable goals.
The API to define goals for an experiment is this:
```ruby
ab_test({link_color: ["purchase", "refund"]}, "red", "blue")
```
or you can define them in a configuration file:
```ruby
Split.configure do |config|
config.experiments = {
link_color: {
alternatives: ["red", "blue"],
goals: ["purchase", "refund"]
}
}
end
```
To complete a goal conversion, you do it like:
```ruby
ab_finished(link_color: "purchase")
```
Note that if you pass additional options, that should be a separate hash:
```ruby
ab_finished({ link_color: "purchase" }, reset: false)
```
**NOTE:** This does not mean that a single experiment can complete more than one goal.
Once you finish one of the goals, the test is considered to be completed, and finishing the other goal will no longer register. (Assuming the test runs with `reset: false`.)
**Good Example**: Test if listing Plan A first result in more conversions to Plan A (goal: "plana_conversion") or Plan B (goal: "planb_conversion").
**Bad Example**: Test if button color increases conversion rate through multiple steps of a funnel. THIS WILL NOT WORK.
**Bad Example**: Test both how button color affects signup *and* how it affects login, at the same time. THIS WILL NOT WORK.
#### Combined Experiments
If you want to test how button color affects signup *and* how it affects login at the same time, use combined experiments.
Configure like so:
```ruby
Split.configuration.experiments = {
:button_color_experiment => {
:alternatives => ["blue", "green"],
:combined_experiments => ["button_color_on_signup", "button_color_on_login"]
}
}
```
Starting the combined test starts all combined experiments
```ruby
ab_combined_test(:button_color_experiment)
```
Finish each combined test as normal
```ruby
ab_finished(:button_color_on_login)
ab_finished(:button_color_on_signup)
```
**Additional Configuration**:
* Be sure to enable `allow_multiple_experiments`
* In Sinatra include the CombinedExperimentsHelper
```
helpers Split::CombinedExperimentsHelper
```
### DB failover solution
Due to the fact that Redis has no automatic failover mechanism, it's
possible to switch on the `db_failover` config option, so that `ab_test`
and `ab_finished` will not crash in case of a db failure. `ab_test` always
delivers alternative A (the first one) in that case.
It's also possible to set a `db_failover_on_db_error` callback (proc)
for example to log these errors via Rails.logger.
### Redis
You may want to change the Redis host and port Split connects to, or
set various other options at startup.
Split has a `redis` setter which can be given a string or a Redis
object. This means if you're already using Redis in your app, Split
can re-use the existing connection.
String: `Split.redis = 'redis://localhost:6379'`
Redis: `Split.redis = $redis`
For our rails app we have a `config/initializers/split.rb` file where
we load `config/split.yml` by hand and set the Redis information
appropriately.
Here's our `config/split.yml`:
```yml
development: redis://localhost:6379
test: redis://localhost:6379
staging: redis://redis1.example.com:6379
fi: redis://localhost:6379
production: redis://redis1.example.com:6379
```
And our initializer:
```ruby
split_config = YAML.load_file(Rails.root.join('config', 'split.yml'))
Split.redis = split_config[Rails.env]
```
### Redis Caching (v4.0+)
In some high-volume usage scenarios, Redis load can be incurred by repeated
fetches for fairly static data. Enabling caching will reduce this load.
```ruby
Split.configuration.cache = true
````
This currently caches:
- `Split::ExperimentCatalog.find`
- `Split::Experiment.start_time`
- `Split::Experiment.winner`
## Namespaces
If you're running multiple, separate instances of Split you may want
to namespace the keyspaces so they do not overlap. This is not unlike
the approach taken by many memcached clients.
This feature can be provided by the [redis-namespace](https://github.com/defunkt/redis-namespace)
library. To configure Split to use `Redis::Namespace`, do the following:
1. Add `redis-namespace` to your Gemfile:
```ruby
gem 'redis-namespace'
```
2. Configure `Split.redis` to use a `Redis::Namespace` instance (possible in an
initializer):
```ruby
redis = Redis.new(url: ENV['REDIS_URL']) # or whatever config you want
Split.redis = Redis::Namespace.new(:your_namespace, redis: redis)
```
## Outside of a Web Session
Split provides the Helper module to facilitate running experiments inside web sessions.
Alternatively, you can access the underlying Metric, Trial, Experiment and Alternative objects to
conduct experiments that are not tied to a web session.
```ruby
# create a new experiment
experiment = Split::ExperimentCatalog.find_or_create('color', 'red', 'blue')
# create a new trial
trial = Split::Trial.new(:experiment => experiment)
# run trial
trial.choose!
# get the result, returns either red or blue
trial.alternative.name
# if the goal has been achieved, increment the successful completions for this alternative.
if goal_achieved?
trial.complete!
end
```
## Algorithms
By default, Split ships with `Split::Algorithms::WeightedSample` that randomly selects from possible alternatives for a traditional a/b test.
It is possible to specify static weights to favor certain alternatives.
`Split::Algorithms::Whiplash` is an implementation of a [multi-armed bandit algorithm](http://stevehanov.ca/blog/index.php?id=132).
This algorithm will automatically weight the alternatives based on their relative performance,
choosing the better-performing ones more often as trials are completed.
`Split::Algorithms::BlockRandomization` is an algorithm that ensures equal
participation across all alternatives. This algorithm will choose the alternative
with the fewest participants. In the event of multiple minimum participant alternatives
(i.e. starting a new "Block") the algorithm will choose a random alternative from
those minimum participant alternatives.
Users may also write their own algorithms. The default algorithm may be specified globally in the configuration file, or on a per experiment basis using the experiments hash of the configuration file.
To change the algorithm globally for all experiments, use the following in your initializer:
```ruby
Split.configure do |config|
config.algorithm = Split::Algorithms::Whiplash
end
```
## Extensions
- [Split::Export](https://github.com/splitrb/split-export) - Easily export A/B test data out of Split.
- [Split::Analytics](https://github.com/splitrb/split-analytics) - Push test data to Google Analytics.
- [Split::Mongoid](https://github.com/MongoHQ/split-mongoid) - Store experiment data in mongoid (still uses redis).
- [Split::Cacheable](https://github.com/harrystech/split_cacheable) - Automatically create cache buckets per test.
- [Split::Counters](https://github.com/bernardkroes/split-counters) - Add counters per experiment and alternative.
- [Split::Cli](https://github.com/craigmcnamara/split-cli) - A CLI to trigger Split A/B tests.
## Screencast
Ryan bates has produced an excellent 10 minute screencast about split on the Railscasts site: [A/B Testing with Split](http://railscasts.com/episodes/331-a-b-testing-with-split)
## Blogposts
* [Recipe: A/B testing with KISSMetrics and the split gem](https://robots.thoughtbot.com/post/9595887299/recipe-a-b-testing-with-kissmetrics-and-the-split-gem)
* [Rails A/B testing with Split on Heroku](http://blog.nathanhumbert.com/2012/02/rails-ab-testing-with-split-on-heroku.html)
## Backers
Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/split#backer)]
<a href="https://opencollective.com/split/backer/0/website" target="_blank"><img src="https://opencollective.com/split/backer/0/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/1/website" target="_blank"><img src="https://opencollective.com/split/backer/1/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/2/website" target="_blank"><img src="https://opencollective.com/split/backer/2/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/3/website" target="_blank"><img src="https://opencollective.com/split/backer/3/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/4/website" target="_blank"><img src="https://opencollective.com/split/backer/4/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/5/website" target="_blank"><img src="https://opencollective.com/split/backer/5/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/6/website" target="_blank"><img src="https://opencollective.com/split/backer/6/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/7/website" target="_blank"><img src="https://opencollective.com/split/backer/7/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/8/website" target="_blank"><img src="https://opencollective.com/split/backer/8/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/9/website" target="_blank"><img src="https://opencollective.com/split/backer/9/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/10/website" target="_blank"><img src="https://opencollective.com/split/backer/10/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/11/website" target="_blank"><img src="https://opencollective.com/split/backer/11/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/12/website" target="_blank"><img src="https://opencollective.com/split/backer/12/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/13/website" target="_blank"><img src="https://opencollective.com/split/backer/13/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/14/website" target="_blank"><img src="https://opencollective.com/split/backer/14/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/15/website" target="_blank"><img src="https://opencollective.com/split/backer/15/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/16/website" target="_blank"><img src="https://opencollective.com/split/backer/16/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/17/website" target="_blank"><img src="https://opencollective.com/split/backer/17/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/18/website" target="_blank"><img src="https://opencollective.com/split/backer/18/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/19/website" target="_blank"><img src="https://opencollective.com/split/backer/19/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/20/website" target="_blank"><img src="https://opencollective.com/split/backer/20/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/21/website" target="_blank"><img src="https://opencollective.com/split/backer/21/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/22/website" target="_blank"><img src="https://opencollective.com/split/backer/22/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/23/website" target="_blank"><img src="https://opencollective.com/split/backer/23/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/24/website" target="_blank"><img src="https://opencollective.com/split/backer/24/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/25/website" target="_blank"><img src="https://opencollective.com/split/backer/25/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/26/website" target="_blank"><img src="https://opencollective.com/split/backer/26/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/27/website" target="_blank"><img src="https://opencollective.com/split/backer/27/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/28/website" target="_blank"><img src="https://opencollective.com/split/backer/28/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/29/website" target="_blank"><img src="https://opencollective.com/split/backer/29/avatar.svg"></a>
## Sponsors
Become a sponsor and get your logo on our README on Github with a link to your site. [[Become a sponsor](https://opencollective.com/split#sponsor)]
<a href="https://opencollective.com/split/sponsor/0/website" target="_blank"><img src="https://opencollective.com/split/sponsor/0/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/1/website" target="_blank"><img src="https://opencollective.com/split/sponsor/1/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/2/website" target="_blank"><img src="https://opencollective.com/split/sponsor/2/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/3/website" target="_blank"><img src="https://opencollective.com/split/sponsor/3/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/4/website" target="_blank"><img src="https://opencollective.com/split/sponsor/4/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/5/website" target="_blank"><img src="https://opencollective.com/split/sponsor/5/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/6/website" target="_blank"><img src="https://opencollective.com/split/sponsor/6/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/7/website" target="_blank"><img src="https://opencollective.com/split/sponsor/7/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/8/website" target="_blank"><img src="https://opencollective.com/split/sponsor/8/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/9/website" target="_blank"><img src="https://opencollective.com/split/sponsor/9/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/10/website" target="_blank"><img src="https://opencollective.com/split/sponsor/10/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/11/website" target="_blank"><img src="https://opencollective.com/split/sponsor/11/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/12/website" target="_blank"><img src="https://opencollective.com/split/sponsor/12/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/13/website" target="_blank"><img src="https://opencollective.com/split/sponsor/13/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/14/website" target="_blank"><img src="https://opencollective.com/split/sponsor/14/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/15/website" target="_blank"><img src="https://opencollective.com/split/sponsor/15/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/16/website" target="_blank"><img src="https://opencollective.com/split/sponsor/16/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/17/website" target="_blank"><img src="https://opencollective.com/split/sponsor/17/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/18/website" target="_blank"><img src="https://opencollective.com/split/sponsor/18/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/19/website" target="_blank"><img src="https://opencollective.com/split/sponsor/19/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/20/website" target="_blank"><img src="https://opencollective.com/split/sponsor/20/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/21/website" target="_blank"><img src="https://opencollective.com/split/sponsor/21/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/22/website" target="_blank"><img src="https://opencollective.com/split/sponsor/22/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/23/website" target="_blank"><img src="https://opencollective.com/split/sponsor/23/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/24/website" target="_blank"><img src="https://opencollective.com/split/sponsor/24/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/25/website" target="_blank"><img src="https://opencollective.com/split/sponsor/25/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/26/website" target="_blank"><img src="https://opencollective.com/split/sponsor/26/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/27/website" target="_blank"><img src="https://opencollective.com/split/sponsor/27/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/28/website" target="_blank"><img src="https://opencollective.com/split/sponsor/28/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/29/website" target="_blank"><img src="https://opencollective.com/split/sponsor/29/avatar.svg"></a>
## Contribute
Please do! Over 70 different people have contributed to the project, you can see them all here: https://github.com/splitrb/split/graphs/contributors.
### Development
The source code is hosted at [GitHub](https://github.com/splitrb/split).
Report issues and feature requests on [GitHub Issues](https://github.com/splitrb/split/issues).
You can find a discussion form on [Google Groups](https://groups.google.com/d/forum/split-ruby).
### Tests
Run the tests like this:
# Start a Redis server in another tab.
redis-server
bundle
rake spec
### A Note on Patches and Pull Requests
* Fork the project.
* Make your feature addition or bug fix.
* Add tests for it. This is important so I don't break it in a
future version unintentionally.
* Add documentation if necessary.
* Commit. Do not mess with the rakefile, version, or history.
(If you want to have your own version, that is fine. But bump the version in a commit by itself, which I can ignore when I pull.)
* Send a pull request. Bonus points for topic branches.
### Code of Conduct
Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.
## Copyright
[MIT License](LICENSE) ยฉ 2019 [Andrew Nesbitt](https://github.com/andrew).
<MSG> README: Metadata example in ruby
Metadata keys must be in JSON values (no symbols) otherwise #185 bug occurs.
<DFF> @@ -430,6 +430,20 @@ finished(:my_first_experiment)
You can also add meta data for each experiment, very useful when you need more than an alternative name to change behaviour:
+```ruby
+Split.configure do |config|
+ config.experiments = {
+ my_first_experiment: {
+ alternatives: ["a", "b"],
+ metadata: {
+ "checkbox" => {"text" => "Have a fantastic day"},
+ "radio" => {"text" => "Don't get hit by a bus"},
+ }
+ },
+ }
+end
+```
+
```yaml
my_first_experiment:
alternatives:
| 14 | README: Metadata example in ruby | 0 | .md | md | mit | splitrb/split |
10071554 | <NME> README.md
<BEF> # [Split](https://libraries.io/rubygems/split)
[](http://badge.fury.io/rb/split)

[](https://codeclimate.com/github/splitrb/split)
[](https://codeclimate.com/github/splitrb/split/coverage)
[](https://github.com/RichardLitt/standard-readme)
[](https://www.codetriage.com/splitrb/split)
> ๐ The Rack Based A/B testing framework https://libraries.io/rubygems/split
Split is a rack based A/B testing framework designed to work with Rails, Sinatra or any other rack based app.
Split is heavily inspired by the [Abingo](https://github.com/ryanb/abingo) and [Vanity](https://github.com/assaf/vanity) Rails A/B testing plugins and [Resque](https://github.com/resque/resque) in its use of Redis.
Split is designed to be hacker friendly, allowing for maximum customisation and extensibility.
## Install
### Requirements
Split v4.0+ is currently tested with Ruby >= 2.5 and Rails >= 5.2.
If your project requires compatibility with Ruby 2.4.x or older Rails versions. You can try v3.0 or v0.8.0(for Ruby 1.9.3)
Split uses Redis as a datastore.
Split only supports Redis 4.0 or greater.
If you're on OS X, Homebrew is the simplest way to install Redis:
```bash
brew install redis
redis-server /usr/local/etc/redis.conf
```
You now have a Redis daemon running on port `6379`.
### Setup
```bash
gem install split
```
#### Rails
Adding `gem 'split'` to your Gemfile will autoload it when rails starts up, as long as you've configured Redis it will 'just work'.
#### Sinatra
To configure Sinatra with Split you need to enable sessions and mix in the helper methods. Add the following lines at the top of your Sinatra app:
```ruby
require 'split'
class MySinatraApp < Sinatra::Base
enable :sessions
helpers Split::Helper
get '/' do
...
end
```
## Usage
To begin your A/B test use the `ab_test` method, naming your experiment with the first argument and then the different alternatives which you wish to test on as the other arguments.
`ab_test` returns one of the alternatives, if a user has already seen that test they will get the same alternative as before, which you can use to split your code on.
It can be used to render different templates, show different text or any other case based logic.
`ab_finished` is used to make a completion of an experiment, or conversion.
Example: View
```erb
<% ab_test(:login_button, "/images/button1.jpg", "/images/button2.jpg") do |button_file| %>
<%= image_tag(button_file, alt: "Login!") %>
<% end %>
```
Example: Controller
```ruby
def register_new_user
# See what level of free points maximizes users' decision to buy replacement points.
@starter_points = ab_test(:new_user_free_points, '100', '200', '300')
end
```
Example: Conversion tracking (in a controller!)
```ruby
def buy_new_points
# some business logic
ab_finished(:new_user_free_points)
end
```
Example: Conversion tracking (in a view)
```erb
Thanks for signing up, dude! <% ab_finished(:signup_page_redesign) %>
```
You can find more examples, tutorials and guides on the [wiki](https://github.com/splitrb/split/wiki).
## Statistical Validity
Split has two options for you to use to determine which alternative is the best.
The first option (default on the dashboard) uses a z test (n>30) for the difference between your control and alternative conversion rates to calculate statistical significance. This test will tell you whether an alternative is better or worse than your control, but it will not distinguish between which alternative is the best in an experiment with multiple alternatives. Split will only tell you if your experiment is 90%, 95%, or 99% significant, and this test only works if you have more than 30 participants and 5 conversions for each branch.
As per this [blog post](https://www.evanmiller.org/how-not-to-run-an-ab-test.html) on the pitfalls of A/B testing, it is highly recommended that you determine your requisite sample size for each branch before running the experiment. Otherwise, you'll have an increased rate of false positives (experiments which show a significant effect where really there is none).
[Here](https://www.evanmiller.org/ab-testing/sample-size.html) is a sample size calculator for your convenience.
The second option uses simulations from a beta distribution to determine the probability that the given alternative is the winner compared to all other alternatives. You can view these probabilities by clicking on the drop-down menu labeled "Confidence." This option should be used when the experiment has more than just 1 control and 1 alternative. It can also be used for a simple, 2-alternative A/B test.
Calculating the beta-distribution simulations for a large number of experiments can be slow, so the results are cached. You can specify how often they should be recalculated (the default is once per day).
```ruby
Split.configure do |config|
config.winning_alternative_recalculation_interval = 3600 # 1 hour
end
```
## Extras
### Weighted alternatives
Perhaps you only want to show an alternative to 10% of your visitors because it is very experimental or not yet fully load tested.
To do this you can pass a weight with each alternative in the following ways:
```ruby
ab_test(:homepage_design, {'Old' => 18}, {'New' => 2})
ab_test(:homepage_design, 'Old', {'New' => 1.0/9})
ab_test(:homepage_design, {'Old' => 9}, 'New')
```
This will only show the new alternative to visitors 1 in 10 times, the default weight for an alternative is 1.
### Overriding alternatives
For development and testing, you may wish to force your app to always return an alternative.
You can do this by passing it as a parameter in the url.
If you have an experiment called `button_color` with alternatives called `red` and `blue` used on your homepage, a url such as:
http://myawesomesite.com?ab_test[button_color]=red
will always have red buttons. This won't be stored in your session or count towards to results, unless you set the `store_override` configuration option.
In the event you want to disable all tests without having to know the individual experiment names, add a `SPLIT_DISABLE` query parameter.
http://myawesomesite.com?SPLIT_DISABLE=true
It is not required to send `SPLIT_DISABLE=false` to activate Split.
### Rspec Helper
To aid testing with RSpec, write `spec/support/split_helper.rb` and call `use_ab_test(alternatives_by_experiment)` in your specs as instructed below:
```ruby
# Create a file with these contents at 'spec/support/split_helper.rb'
# and ensure it is `require`d in your rails_helper.rb or spec_helper.rb
module SplitHelper
# Force a specific experiment alternative to always be returned:
# use_ab_test(signup_form: "single_page")
#
# Force alternatives for multiple experiments:
# use_ab_test(signup_form: "single_page", pricing: "show_enterprise_prices")
#
def use_ab_test(alternatives_by_experiment)
allow_any_instance_of(Split::Helper).to receive(:ab_test) do |_receiver, experiment, &block|
variant = alternatives_by_experiment.fetch(experiment) { |key| raise "Unknown experiment '#{key}'" }
block.call(variant) unless block.nil?
variant
end
end
end
# Make the `use_ab_test` method available to all specs:
RSpec.configure do |config|
config.include SplitHelper
end
```
Now you can call `use_ab_test(alternatives_by_experiment)` in your specs, for example:
```ruby
it "registers using experimental signup" do
use_ab_test experiment_name: "alternative_name"
post "/signups"
...
end
```
### Starting experiments manually
By default new A/B tests will be active right after deployment. In case you would like to start new test a while after
the deploy, you can do it by setting the `start_manually` configuration option to `true`.
After choosing this option tests won't be started right after deploy, but after pressing the `Start` button in Split admin dashboard. If a test is deleted from the Split dashboard, then it can only be started after pressing the `Start` button whenever being re-initialized.
### Reset after completion
When a user completes a test their session is reset so that they may start the test again in the future.
To stop this behaviour you can pass the following option to the `ab_finished` method:
```ruby
ab_finished(:experiment_name, reset: false)
```
The user will then always see the alternative they started with.
Any old unfinished experiment key will be deleted from the user's data storage if the experiment had been removed or is over and a winner had been chosen. This allows a user to enroll into any new experiment in cases when the `allow_multiple_experiments` config option is set to `false`.
### Reset experiments manually
By default Split automatically resets the experiment whenever it detects the configuration for an experiment has changed (e.g. you call `ab_test` with different alternatives). You can prevent this by setting the option `reset_manually` to `true`.
You may want to do this when you want to change something, like the variants' names, the metadata about an experiment, etc. without resetting everything.
### Multiple experiments at once
By default Split will avoid users participating in multiple experiments at once. This means you are less likely to skew results by adding in more variation to your tests.
To stop this behaviour and allow users to participate in multiple experiments at once set the `allow_multiple_experiments` config option to true like so:
```ruby
Split.configure do |config|
config.allow_multiple_experiments = true
end
```
This will allow the user to participate in any number of experiments and belong to any alternative in each experiment. This has the possible downside of a variation in one experiment influencing the outcome of another.
To address this, setting the `allow_multiple_experiments` config option to 'control' like so:
```ruby
Split.configure do |config|
config.allow_multiple_experiments = 'control'
end
```
For this to work, each and every experiment you define must have an alternative named 'control'. This will allow the user to participate in multiple experiments as long as the user belongs to the alternative 'control' in each experiment. As soon as the user belongs to an alternative named something other than 'control' the user may not participate in any more experiments. Calling ab_test(<other experiments>) will always return the first alternative without adding the user to that experiment.
### Experiment Persistence
Split comes with three built-in persistence adapters for storing users and the alternatives they've been given for each experiment.
By default Split will store the tests for each user in the session.
You can optionally configure Split to use a cookie, Redis, or any custom adapter of your choosing.
#### Cookies
```ruby
Split.configure do |config|
config.persistence = :cookie
end
```
When using the cookie persistence, Split stores data into an anonymous tracking cookie named 'split', which expires in 1 year. To change that, set the `persistence_cookie_length` in the configuration (unit of time in seconds).
```ruby
Split.configure do |config|
config.persistence = :cookie
config.persistence_cookie_length = 2592000 # 30 days
end
```
The data stored consists of the experiment name and the variants the user is in. Example: { "experiment_name" => "variant_a" }
__Note:__ Using cookies depends on `ActionDispatch::Cookies` or any identical API
#### Redis
Using Redis will allow ab_users to persist across sessions or machines.
```ruby
Split.configure do |config|
config.persistence = Split::Persistence::RedisAdapter.with_config(lookup_by: -> (context) { context.current_user_id })
# Equivalent
# config.persistence = Split::Persistence::RedisAdapter.with_config(lookup_by: :current_user_id)
end
```
Options:
* `lookup_by`: method to invoke per request for uniquely identifying ab_users (mandatory configuration)
* `namespace`: separate namespace to store these persisted values (default "persistence")
* `expire_seconds`: sets TTL for user key. (if a user is in multiple experiments most recent update will reset TTL for all their assignments)
#### Dual Adapter
The Dual Adapter allows the use of different persistence adapters for logged-in and logged-out users. A common use case is to use Redis for logged-in users and Cookies for logged-out users.
```ruby
cookie_adapter = Split::Persistence::CookieAdapter
redis_adapter = Split::Persistence::RedisAdapter.with_config(
lookup_by: -> (context) { context.send(:current_user).try(:id) },
expire_seconds: 2592000)
Split.configure do |config|
config.persistence = Split::Persistence::DualAdapter.with_config(
logged_in: -> (context) { !context.send(:current_user).try(:id).nil? },
logged_in_adapter: redis_adapter,
logged_out_adapter: cookie_adapter)
config.persistence_cookie_length = 2592000 # 30 days
end
```
#### Custom Adapter
Your custom adapter needs to implement the same API as existing adapters.
See `Split::Persistence::CookieAdapter` or `Split::Persistence::SessionAdapter` for a starting point.
```ruby
Split.configure do |config|
config.persistence = YourCustomAdapterClass
end
```
### Trial Event Hooks
You can define methods that will be called at the same time as experiment
alternative participation and goal completion.
For example:
``` ruby
Split.configure do |config|
config.on_trial = :log_trial # run on every trial
config.on_trial_choose = :log_trial_choose # run on trials with new users only
config.on_trial_complete = :log_trial_complete
end
```
Set these attributes to a method name available in the same context as the
`ab_test` method. These methods should accept one argument, a `Trial` instance.
``` ruby
def log_trial(trial)
logger.info "experiment=%s alternative=%s user=%s" %
[ trial.experiment.name, trial.alternative, current_user.id ]
end
def log_trial_choose(trial)
logger.info "[new user] experiment=%s alternative=%s user=%s" %
[ trial.experiment.name, trial.alternative, current_user.id ]
end
def log_trial_complete(trial)
logger.info "experiment=%s alternative=%s user=%s complete=true" %
[ trial.experiment.name, trial.alternative, current_user.id ]
end
```
#### Views
If you are running `ab_test` from a view, you must define your event
hook callback as a
[helper_method](https://apidock.com/rails/AbstractController/Helpers/ClassMethods/helper_method)
in the controller:
``` ruby
helper_method :log_trial_choose
def log_trial_choose(trial)
logger.info "experiment=%s alternative=%s user=%s" %
[ trial.experiment.name, trial.alternative, current_user.id ]
end
```
### Experiment Hooks
You can assign a proc that will be called when an experiment is reset or deleted. You can use these hooks to call methods within your application to keep data related to experiments in sync with Split.
For example:
``` ruby
Split.configure do |config|
# after experiment reset or deleted
config.on_experiment_reset = -> (example) { # Do something on reset }
config.on_experiment_delete = -> (experiment) { # Do something else on delete }
# before experiment reset or deleted
config.on_before_experiment_reset = -> (example) { # Do something on reset }
config.on_before_experiment_delete = -> (experiment) { # Do something else on delete }
# after experiment winner had been set
config.on_experiment_winner_choose = -> (experiment) { # Do something on winner choose }
end
```
## Web Interface
Split comes with a Sinatra-based front end to get an overview of how your experiments are doing.
If you are running Rails 2: You can mount this inside your app using Rack::URLMap in your `config.ru`
```ruby
require 'split/dashboard'
run Rack::URLMap.new \
"/" => Your::App.new,
"/split" => Split::Dashboard.new
```
However, if you are using Rails 3 or higher: You can mount this inside your app routes by first adding this to the Gemfile:
```ruby
gem 'split', require: 'split/dashboard'
```
Then adding this to config/routes.rb
```ruby
mount Split::Dashboard, at: 'split'
```
You may want to password protect that page, you can do so with `Rack::Auth::Basic` (in your split initializer file)
```ruby
# Rails apps or apps that already depend on activesupport
You can also add meta data for each experiment, very useful when you need more than an alternative name to change behaviour:
```yaml
my_first_experiment:
alternatives:
match "/split" => Split::Dashboard, anchor: false, via: [:get, :post, :delete], constraints: -> (request) do
request.env['warden'].authenticated? # are we authenticated?
request.env['warden'].authenticate! # authenticate if not already
# or even check any other condition such as request.env['warden'].user.is_admin?
end
```
More information on this [here](https://steve.dynedge.co.uk/2011/12/09/controlling-access-to-routes-and-rack-apps-in-rails-3-with-devise-and-warden/)
### Screenshot

## Configuration
You can override the default configuration options of Split like so:
```ruby
Split.configure do |config|
config.db_failover = true # handle Redis errors gracefully
config.db_failover_on_db_error = -> (error) { Rails.logger.error(error.message) }
config.allow_multiple_experiments = true
config.enabled = true
config.persistence = Split::Persistence::SessionAdapter
#config.start_manually = false ## new test will have to be started manually from the admin panel. default false
#config.reset_manually = false ## if true, it never resets the experiment data, even if the configuration changes
config.include_rails_helper = true
config.redis = "redis://custom.redis.url:6380"
end
```
Split looks for the Redis host in the environment variable `REDIS_URL` then
defaults to `redis://localhost:6379` if not specified by configure block.
On platforms like Heroku, Split will use the value of `REDIS_PROVIDER` to
determine which env variable key to use when retrieving the host config. This
defaults to `REDIS_URL`.
### Filtering
In most scenarios you don't want to have AB-Testing enabled for web spiders, robots or special groups of users.
Split provides functionality to filter this based on a predefined, extensible list of bots, IP-lists or custom exclude logic.
```ruby
Split.configure do |config|
# bot config
config.robot_regex = /my_custom_robot_regex/ # or
config.bots['newbot'] = "Description for bot with 'newbot' user agent, which will be added to config.robot_regex for exclusion"
# IP config
config.ignore_ip_addresses << '81.19.48.130' # or regex: /81\.19\.48\.[0-9]+/
# or provide your own filter functionality, the default is proc{ |request| is_robot? || is_ignored_ip_address? || is_preview? }
config.ignore_filter = -> (request) { CustomExcludeLogic.excludes?(request) }
end
```
### Experiment configuration
Instead of providing the experiment options inline, you can store them
in a hash. This hash can control your experiment's alternatives, weights,
algorithm and if the experiment resets once finished:
```ruby
Split.configure do |config|
config.experiments = {
my_first_experiment: {
alternatives: ["a", "b"],
resettable: false
},
:my_second_experiment => {
algorithm: 'Split::Algorithms::Whiplash',
alternatives: [
{ name: "a", percent: 67 },
{ name: "b", percent: 33 }
]
}
}
end
```
You can also store your experiments in a YAML file:
```ruby
Split.configure do |config|
config.experiments = YAML.load_file "config/experiments.yml"
end
```
You can then define the YAML file like:
```yaml
my_first_experiment:
alternatives:
- a
- b
my_second_experiment:
alternatives:
- name: a
percent: 67
- name: b
percent: 33
resettable: false
```
This simplifies the calls from your code:
```ruby
ab_test(:my_first_experiment)
```
and:
```ruby
ab_finished(:my_first_experiment)
```
You can also add meta data for each experiment, which is very useful when you need more than an alternative name to change behaviour:
```ruby
Split.configure do |config|
config.experiments = {
my_first_experiment: {
alternatives: ["a", "b"],
metadata: {
"a" => {"text" => "Have a fantastic day"},
"b" => {"text" => "Don't get hit by a bus"}
}
}
}
end
```
```yaml
my_first_experiment:
alternatives:
- a
- b
metadata:
a:
text: "Have a fantastic day"
b:
text: "Don't get hit by a bus"
```
This allows for some advanced experiment configuration using methods like:
```ruby
trial.alternative.name # => "a"
trial.metadata['text'] # => "Have a fantastic day"
```
or in views:
```erb
<% ab_test("my_first_experiment") do |alternative, meta| %>
<%= alternative %>
<small><%= meta['text'] %></small>
<% end %>
```
The keys used in meta data should be Strings
#### Metrics
You might wish to track generic metrics, such as conversions, and use
those to complete multiple different experiments without adding more to
your code. You can use the configuration hash to do this, thanks to
the `:metric` option.
```ruby
Split.configure do |config|
config.experiments = {
my_first_experiment: {
alternatives: ["a", "b"],
metric: :my_metric
}
}
end
```
Your code may then track a completion using the metric instead of
the experiment name:
```ruby
ab_finished(:my_metric)
```
You can also create a new metric by instantiating and saving a new Metric object.
```ruby
Split::Metric.new(:my_metric)
Split::Metric.save
```
#### Goals
You might wish to allow an experiment to have multiple, distinguishable goals.
The API to define goals for an experiment is this:
```ruby
ab_test({link_color: ["purchase", "refund"]}, "red", "blue")
```
or you can define them in a configuration file:
```ruby
Split.configure do |config|
config.experiments = {
link_color: {
alternatives: ["red", "blue"],
goals: ["purchase", "refund"]
}
}
end
```
To complete a goal conversion, you do it like:
```ruby
ab_finished(link_color: "purchase")
```
Note that if you pass additional options, that should be a separate hash:
```ruby
ab_finished({ link_color: "purchase" }, reset: false)
```
**NOTE:** This does not mean that a single experiment can complete more than one goal.
Once you finish one of the goals, the test is considered to be completed, and finishing the other goal will no longer register. (Assuming the test runs with `reset: false`.)
**Good Example**: Test if listing Plan A first result in more conversions to Plan A (goal: "plana_conversion") or Plan B (goal: "planb_conversion").
**Bad Example**: Test if button color increases conversion rate through multiple steps of a funnel. THIS WILL NOT WORK.
**Bad Example**: Test both how button color affects signup *and* how it affects login, at the same time. THIS WILL NOT WORK.
#### Combined Experiments
If you want to test how button color affects signup *and* how it affects login at the same time, use combined experiments.
Configure like so:
```ruby
Split.configuration.experiments = {
:button_color_experiment => {
:alternatives => ["blue", "green"],
:combined_experiments => ["button_color_on_signup", "button_color_on_login"]
}
}
```
Starting the combined test starts all combined experiments
```ruby
ab_combined_test(:button_color_experiment)
```
Finish each combined test as normal
```ruby
ab_finished(:button_color_on_login)
ab_finished(:button_color_on_signup)
```
**Additional Configuration**:
* Be sure to enable `allow_multiple_experiments`
* In Sinatra include the CombinedExperimentsHelper
```
helpers Split::CombinedExperimentsHelper
```
### DB failover solution
Due to the fact that Redis has no automatic failover mechanism, it's
possible to switch on the `db_failover` config option, so that `ab_test`
and `ab_finished` will not crash in case of a db failure. `ab_test` always
delivers alternative A (the first one) in that case.
It's also possible to set a `db_failover_on_db_error` callback (proc)
for example to log these errors via Rails.logger.
### Redis
You may want to change the Redis host and port Split connects to, or
set various other options at startup.
Split has a `redis` setter which can be given a string or a Redis
object. This means if you're already using Redis in your app, Split
can re-use the existing connection.
String: `Split.redis = 'redis://localhost:6379'`
Redis: `Split.redis = $redis`
For our rails app we have a `config/initializers/split.rb` file where
we load `config/split.yml` by hand and set the Redis information
appropriately.
Here's our `config/split.yml`:
```yml
development: redis://localhost:6379
test: redis://localhost:6379
staging: redis://redis1.example.com:6379
fi: redis://localhost:6379
production: redis://redis1.example.com:6379
```
And our initializer:
```ruby
split_config = YAML.load_file(Rails.root.join('config', 'split.yml'))
Split.redis = split_config[Rails.env]
```
### Redis Caching (v4.0+)
In some high-volume usage scenarios, Redis load can be incurred by repeated
fetches for fairly static data. Enabling caching will reduce this load.
```ruby
Split.configuration.cache = true
````
This currently caches:
- `Split::ExperimentCatalog.find`
- `Split::Experiment.start_time`
- `Split::Experiment.winner`
## Namespaces
If you're running multiple, separate instances of Split you may want
to namespace the keyspaces so they do not overlap. This is not unlike
the approach taken by many memcached clients.
This feature can be provided by the [redis-namespace](https://github.com/defunkt/redis-namespace)
library. To configure Split to use `Redis::Namespace`, do the following:
1. Add `redis-namespace` to your Gemfile:
```ruby
gem 'redis-namespace'
```
2. Configure `Split.redis` to use a `Redis::Namespace` instance (possible in an
initializer):
```ruby
redis = Redis.new(url: ENV['REDIS_URL']) # or whatever config you want
Split.redis = Redis::Namespace.new(:your_namespace, redis: redis)
```
## Outside of a Web Session
Split provides the Helper module to facilitate running experiments inside web sessions.
Alternatively, you can access the underlying Metric, Trial, Experiment and Alternative objects to
conduct experiments that are not tied to a web session.
```ruby
# create a new experiment
experiment = Split::ExperimentCatalog.find_or_create('color', 'red', 'blue')
# create a new trial
trial = Split::Trial.new(:experiment => experiment)
# run trial
trial.choose!
# get the result, returns either red or blue
trial.alternative.name
# if the goal has been achieved, increment the successful completions for this alternative.
if goal_achieved?
trial.complete!
end
```
## Algorithms
By default, Split ships with `Split::Algorithms::WeightedSample` that randomly selects from possible alternatives for a traditional a/b test.
It is possible to specify static weights to favor certain alternatives.
`Split::Algorithms::Whiplash` is an implementation of a [multi-armed bandit algorithm](http://stevehanov.ca/blog/index.php?id=132).
This algorithm will automatically weight the alternatives based on their relative performance,
choosing the better-performing ones more often as trials are completed.
`Split::Algorithms::BlockRandomization` is an algorithm that ensures equal
participation across all alternatives. This algorithm will choose the alternative
with the fewest participants. In the event of multiple minimum participant alternatives
(i.e. starting a new "Block") the algorithm will choose a random alternative from
those minimum participant alternatives.
Users may also write their own algorithms. The default algorithm may be specified globally in the configuration file, or on a per experiment basis using the experiments hash of the configuration file.
To change the algorithm globally for all experiments, use the following in your initializer:
```ruby
Split.configure do |config|
config.algorithm = Split::Algorithms::Whiplash
end
```
## Extensions
- [Split::Export](https://github.com/splitrb/split-export) - Easily export A/B test data out of Split.
- [Split::Analytics](https://github.com/splitrb/split-analytics) - Push test data to Google Analytics.
- [Split::Mongoid](https://github.com/MongoHQ/split-mongoid) - Store experiment data in mongoid (still uses redis).
- [Split::Cacheable](https://github.com/harrystech/split_cacheable) - Automatically create cache buckets per test.
- [Split::Counters](https://github.com/bernardkroes/split-counters) - Add counters per experiment and alternative.
- [Split::Cli](https://github.com/craigmcnamara/split-cli) - A CLI to trigger Split A/B tests.
## Screencast
Ryan bates has produced an excellent 10 minute screencast about split on the Railscasts site: [A/B Testing with Split](http://railscasts.com/episodes/331-a-b-testing-with-split)
## Blogposts
* [Recipe: A/B testing with KISSMetrics and the split gem](https://robots.thoughtbot.com/post/9595887299/recipe-a-b-testing-with-kissmetrics-and-the-split-gem)
* [Rails A/B testing with Split on Heroku](http://blog.nathanhumbert.com/2012/02/rails-ab-testing-with-split-on-heroku.html)
## Backers
Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/split#backer)]
<a href="https://opencollective.com/split/backer/0/website" target="_blank"><img src="https://opencollective.com/split/backer/0/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/1/website" target="_blank"><img src="https://opencollective.com/split/backer/1/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/2/website" target="_blank"><img src="https://opencollective.com/split/backer/2/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/3/website" target="_blank"><img src="https://opencollective.com/split/backer/3/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/4/website" target="_blank"><img src="https://opencollective.com/split/backer/4/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/5/website" target="_blank"><img src="https://opencollective.com/split/backer/5/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/6/website" target="_blank"><img src="https://opencollective.com/split/backer/6/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/7/website" target="_blank"><img src="https://opencollective.com/split/backer/7/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/8/website" target="_blank"><img src="https://opencollective.com/split/backer/8/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/9/website" target="_blank"><img src="https://opencollective.com/split/backer/9/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/10/website" target="_blank"><img src="https://opencollective.com/split/backer/10/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/11/website" target="_blank"><img src="https://opencollective.com/split/backer/11/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/12/website" target="_blank"><img src="https://opencollective.com/split/backer/12/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/13/website" target="_blank"><img src="https://opencollective.com/split/backer/13/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/14/website" target="_blank"><img src="https://opencollective.com/split/backer/14/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/15/website" target="_blank"><img src="https://opencollective.com/split/backer/15/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/16/website" target="_blank"><img src="https://opencollective.com/split/backer/16/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/17/website" target="_blank"><img src="https://opencollective.com/split/backer/17/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/18/website" target="_blank"><img src="https://opencollective.com/split/backer/18/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/19/website" target="_blank"><img src="https://opencollective.com/split/backer/19/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/20/website" target="_blank"><img src="https://opencollective.com/split/backer/20/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/21/website" target="_blank"><img src="https://opencollective.com/split/backer/21/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/22/website" target="_blank"><img src="https://opencollective.com/split/backer/22/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/23/website" target="_blank"><img src="https://opencollective.com/split/backer/23/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/24/website" target="_blank"><img src="https://opencollective.com/split/backer/24/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/25/website" target="_blank"><img src="https://opencollective.com/split/backer/25/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/26/website" target="_blank"><img src="https://opencollective.com/split/backer/26/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/27/website" target="_blank"><img src="https://opencollective.com/split/backer/27/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/28/website" target="_blank"><img src="https://opencollective.com/split/backer/28/avatar.svg"></a>
<a href="https://opencollective.com/split/backer/29/website" target="_blank"><img src="https://opencollective.com/split/backer/29/avatar.svg"></a>
## Sponsors
Become a sponsor and get your logo on our README on Github with a link to your site. [[Become a sponsor](https://opencollective.com/split#sponsor)]
<a href="https://opencollective.com/split/sponsor/0/website" target="_blank"><img src="https://opencollective.com/split/sponsor/0/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/1/website" target="_blank"><img src="https://opencollective.com/split/sponsor/1/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/2/website" target="_blank"><img src="https://opencollective.com/split/sponsor/2/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/3/website" target="_blank"><img src="https://opencollective.com/split/sponsor/3/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/4/website" target="_blank"><img src="https://opencollective.com/split/sponsor/4/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/5/website" target="_blank"><img src="https://opencollective.com/split/sponsor/5/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/6/website" target="_blank"><img src="https://opencollective.com/split/sponsor/6/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/7/website" target="_blank"><img src="https://opencollective.com/split/sponsor/7/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/8/website" target="_blank"><img src="https://opencollective.com/split/sponsor/8/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/9/website" target="_blank"><img src="https://opencollective.com/split/sponsor/9/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/10/website" target="_blank"><img src="https://opencollective.com/split/sponsor/10/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/11/website" target="_blank"><img src="https://opencollective.com/split/sponsor/11/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/12/website" target="_blank"><img src="https://opencollective.com/split/sponsor/12/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/13/website" target="_blank"><img src="https://opencollective.com/split/sponsor/13/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/14/website" target="_blank"><img src="https://opencollective.com/split/sponsor/14/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/15/website" target="_blank"><img src="https://opencollective.com/split/sponsor/15/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/16/website" target="_blank"><img src="https://opencollective.com/split/sponsor/16/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/17/website" target="_blank"><img src="https://opencollective.com/split/sponsor/17/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/18/website" target="_blank"><img src="https://opencollective.com/split/sponsor/18/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/19/website" target="_blank"><img src="https://opencollective.com/split/sponsor/19/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/20/website" target="_blank"><img src="https://opencollective.com/split/sponsor/20/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/21/website" target="_blank"><img src="https://opencollective.com/split/sponsor/21/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/22/website" target="_blank"><img src="https://opencollective.com/split/sponsor/22/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/23/website" target="_blank"><img src="https://opencollective.com/split/sponsor/23/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/24/website" target="_blank"><img src="https://opencollective.com/split/sponsor/24/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/25/website" target="_blank"><img src="https://opencollective.com/split/sponsor/25/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/26/website" target="_blank"><img src="https://opencollective.com/split/sponsor/26/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/27/website" target="_blank"><img src="https://opencollective.com/split/sponsor/27/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/28/website" target="_blank"><img src="https://opencollective.com/split/sponsor/28/avatar.svg"></a>
<a href="https://opencollective.com/split/sponsor/29/website" target="_blank"><img src="https://opencollective.com/split/sponsor/29/avatar.svg"></a>
## Contribute
Please do! Over 70 different people have contributed to the project, you can see them all here: https://github.com/splitrb/split/graphs/contributors.
### Development
The source code is hosted at [GitHub](https://github.com/splitrb/split).
Report issues and feature requests on [GitHub Issues](https://github.com/splitrb/split/issues).
You can find a discussion form on [Google Groups](https://groups.google.com/d/forum/split-ruby).
### Tests
Run the tests like this:
# Start a Redis server in another tab.
redis-server
bundle
rake spec
### A Note on Patches and Pull Requests
* Fork the project.
* Make your feature addition or bug fix.
* Add tests for it. This is important so I don't break it in a
future version unintentionally.
* Add documentation if necessary.
* Commit. Do not mess with the rakefile, version, or history.
(If you want to have your own version, that is fine. But bump the version in a commit by itself, which I can ignore when I pull.)
* Send a pull request. Bonus points for topic branches.
### Code of Conduct
Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.
## Copyright
[MIT License](LICENSE) ยฉ 2019 [Andrew Nesbitt](https://github.com/andrew).
<MSG> README: Metadata example in ruby
Metadata keys must be in JSON values (no symbols) otherwise #185 bug occurs.
<DFF> @@ -430,6 +430,20 @@ finished(:my_first_experiment)
You can also add meta data for each experiment, very useful when you need more than an alternative name to change behaviour:
+```ruby
+Split.configure do |config|
+ config.experiments = {
+ my_first_experiment: {
+ alternatives: ["a", "b"],
+ metadata: {
+ "checkbox" => {"text" => "Have a fantastic day"},
+ "radio" => {"text" => "Don't get hit by a bus"},
+ }
+ },
+ }
+end
+```
+
```yaml
my_first_experiment:
alternatives:
| 14 | README: Metadata example in ruby | 0 | .md | md | mit | splitrb/split |
10071555 | <NME> 6.0.gemfile
<BEF> source "https://rubygems.org"
gem "rubocop", require: false
gem "appraisal"
gem "codeclimate-test-reporter"
gem "rails", "~> 6.0.0.beta3"
gemspec path: "../"
<MSG> Update Rails 6.0 version from beta
<DFF> @@ -4,6 +4,6 @@ source "https://rubygems.org"
gem "appraisal"
gem "codeclimate-test-reporter"
-gem "rails", "~> 6.0.0.beta3"
+gem "rails", "~> 6.0"
gemspec path: "../"
| 1 | Update Rails 6.0 version from beta | 1 | .gemfile | 0 | mit | splitrb/split |
10071556 | <NME> 6.0.gemfile
<BEF> source "https://rubygems.org"
gem "rubocop", require: false
gem "appraisal"
gem "codeclimate-test-reporter"
gem "rails", "~> 6.0.0.beta3"
gemspec path: "../"
<MSG> Update Rails 6.0 version from beta
<DFF> @@ -4,6 +4,6 @@ source "https://rubygems.org"
gem "appraisal"
gem "codeclimate-test-reporter"
-gem "rails", "~> 6.0.0.beta3"
+gem "rails", "~> 6.0"
gemspec path: "../"
| 1 | Update Rails 6.0 version from beta | 1 | .gemfile | 0 | mit | splitrb/split |
10071557 | <NME> 6.0.gemfile
<BEF> source "https://rubygems.org"
gem "rubocop", require: false
gem "appraisal"
gem "codeclimate-test-reporter"
gem "rails", "~> 6.0.0.beta3"
gemspec path: "../"
<MSG> Update Rails 6.0 version from beta
<DFF> @@ -4,6 +4,6 @@ source "https://rubygems.org"
gem "appraisal"
gem "codeclimate-test-reporter"
-gem "rails", "~> 6.0.0.beta3"
+gem "rails", "~> 6.0"
gemspec path: "../"
| 1 | Update Rails 6.0 version from beta | 1 | .gemfile | 0 | mit | splitrb/split |
10071558 | <NME> jquery.meow.js
<BEF> (function ($, window) {
'use strict';
// Meow queue
var meow_area,
meows = {
queue: {},
add: function (meow) {
this.queue[meow.timestamp] = meow;
},
get: function (timestamp) {
return this.queue[timestamp];
},
remove: function (timestamp) {
delete this.queue[timestamp];
},
size: function () {
var timestamp,
size = 0;
for (timestamp in this.queue) {
if (this.queue.hasOwnProperty(timestamp)) { size += 1; }
}
return size;
}
},
// Meow constructor
Meow = function (options) {
var that = this;
this.timestamp = new Date().getTime(); // used to identify this meow and timeout
this.hovered = false; // whether mouse is over or not
if (typeof options.group === 'string') {
this.group = options.group;
} else {
this.group = 'body';
}
if (meows.size() <= 0) {
meow_area = 'meows-' + new Date().getTime();
$(this.group).prepend($(window.document.createElement('div')).attr({'id': meow_area, 'class': 'meows'}));
if (typeof options.beforeCreateFirst === 'function') {
options.beforeCreateFirst.call(that);
}
}
if (typeof options.title === 'string') {
this.title = options.title;
}
if (typeof options.message === 'string') {
this.message = options.message;
} else if (options.message instanceof $) {
if (options.message.is('input,textarea,select')) {
this.message = options.message.val();
} else {
this.message = options.message.text();
}
if (typeof this.title === 'undefined' && typeof options.message.attr('title') === 'string') {
this.title = options.message.attr('title');
}
}
if (typeof options.icon === 'string') {
this.icon = options.icon;
}
if (options.sticky) {
this.duration = Infinity;
} else {
this.duration = options.duration || 5000;
}
// Call callback if it's defined (this = meow object)
if (typeof options.beforeCreate === 'function') {
options.beforeCreate.call(that);
}
// Add the meow to the meow area
$('#' + meow_area).append($(window.document.createElement('div'))
.attr('id', 'meow-' + this.timestamp.toString())
.addClass('meow')
.html($(window.document.createElement('div')).addClass('inner').html(this.message))
.hide()
.fadeIn(400));
this.manifest = $('#meow-' + this.timestamp.toString());
// Add title if it's defined
if (typeof this.title === 'string') {
this.manifest.find('.inner').prepend(
$(window.document.createElement('h1')).text(this.title)
);
}
// Add icon if it's defined
if (typeof that.icon === 'string') {
this.manifest.find('.inner').prepend(
$(window.document.createElement('div')).addClass('icon').html(
$(window.document.createElement('img')).attr('src', this.icon)
)
);
}
// Add close button if the meow isn't uncloseable
// TODO: this close button needs to be much prettier
if (options.closeable !== false) {
this.manifest.find('.inner').prepend(
$(window.document.createElement('a'))
.addClass('close')
.html('×')
.attr('href', '#close-meow-' + that.timestamp)
.click(function (e) {
e.preventDefault();
that.destroy();
})
);
}
this.manifest.bind('mouseenter mouseleave', function (event) {
if (event.type === 'mouseleave') {
that.hovered = false;
that.manifest.removeClass('hover');
// Destroy the mow on mouseleave if it's timed out
if (that.timestamp + that.duration <= new Date().getTime()) {
that.destroy();
}
} else {
that.hovered = true;
that.manifest.addClass('hover');
}
});
// Add a timeout if the duration isn't Infinity
if (this.duration !== Infinity) {
this.timeout = window.setTimeout(function () {
// Make sure this meow hasn't already been destroyed
if (typeof meows.get(that.timestamp) !== 'undefined') {
// Call callback if it's defined (this = meow DOM element)
if (typeof options.onTimeout === 'function') {
options.onTimeout.call(that.manifest);
}
// Don't destroy if user is hovering over meow
if (that.hovered !== true && typeof that === 'object') {
that.destroy();
}
}
}, that.duration);
}
this.destroy = function () {
if (that.destroyed !== true) {
// Call callback if it's defined (this = meow DOM element)
if (typeof options.beforeDestroy === 'function') {
options.beforeDestroy.call(that.manifest);
}
that.manifest.find('.inner').fadeTo(400, 0, function () {
that.manifest.slideUp(function () {
that.manifest.remove();
that.destroyed = true;
meows.remove(that.timestamp);
if (typeof options.afterDestroy === 'function') {
options.afterDestroy.call(null);
}
if (meows.size() <= 0) {
$('#' + meow_area).remove();
if (typeof options.afterDestroyLast === 'function') {
options.afterDestroyLast.call(null);
}
}
});
});
}
};
};
$.fn.meow = function (args) {
var meow = new Meow(args);
meows.add(meow);
return meow;
};
$.meow = $.fn.meow;
}(jQuery, window));
<MSG> Resolve conflicts with default meow area
<DFF> @@ -1,7 +1,7 @@
(function ($, window) {
'use strict';
// Meow queue
- var meow_area,
+ var default_meow_area,
meows = {
queue: {},
add: function (meow) {
@@ -29,20 +29,26 @@
this.timestamp = new Date().getTime(); // used to identify this meow and timeout
this.hovered = false; // whether mouse is over or not
- if (typeof options.group === 'string') {
- this.group = options.group;
- } else {
- this.group = 'body';
+ if (typeof default_meow_area === 'undefined'
+ && typeof options.container === 'undefined') {
+ default_meow_area = $(window.document.createElement('div'))
+ .attr({'id': ((new Date()).getTime()), 'class': 'meows'});
+ $('body').prepend(default_meow_area);
}
if (meows.size() <= 0) {
- meow_area = 'meows-' + new Date().getTime();
- $(this.group).prepend($(window.document.createElement('div')).attr({'id': meow_area, 'class': 'meows'}));
if (typeof options.beforeCreateFirst === 'function') {
options.beforeCreateFirst.call(that);
}
}
+ if (typeof options.container === 'string') {
+ this.container = $(options.container);
+ } else {
+ this.container = default_meow_area;
+ }
+
+
if (typeof options.title === 'string') {
this.title = options.title;
}
@@ -76,7 +82,7 @@
}
// Add the meow to the meow area
- $('#' + meow_area).append($(window.document.createElement('div'))
+ this.container.append($(window.document.createElement('div'))
.attr('id', 'meow-' + this.timestamp.toString())
.addClass('meow')
.html($(window.document.createElement('div')).addClass('inner').html(this.message))
@@ -162,7 +168,10 @@
options.afterDestroy.call(null);
}
if (meows.size() <= 0) {
- $('#' + meow_area).remove();
+ if (default_meow_area instanceof $) {
+ default_meow_area.remove();
+ default_meow_area = undefined;
+ }
if (typeof options.afterDestroyLast === 'function') {
options.afterDestroyLast.call(null);
}
| 18 | Resolve conflicts with default meow area | 9 | .js | meow | mit | zacstewart/Meow |
10071559 | <NME> jquery.meow.js
<BEF> (function ($, window) {
'use strict';
// Meow queue
var meow_area,
meows = {
queue: {},
add: function (meow) {
this.queue[meow.timestamp] = meow;
},
get: function (timestamp) {
return this.queue[timestamp];
},
remove: function (timestamp) {
delete this.queue[timestamp];
},
size: function () {
var timestamp,
size = 0;
for (timestamp in this.queue) {
if (this.queue.hasOwnProperty(timestamp)) { size += 1; }
}
return size;
}
},
// Meow constructor
Meow = function (options) {
var that = this;
this.timestamp = new Date().getTime(); // used to identify this meow and timeout
this.hovered = false; // whether mouse is over or not
if (typeof options.group === 'string') {
this.group = options.group;
} else {
this.group = 'body';
}
if (meows.size() <= 0) {
meow_area = 'meows-' + new Date().getTime();
$(this.group).prepend($(window.document.createElement('div')).attr({'id': meow_area, 'class': 'meows'}));
if (typeof options.beforeCreateFirst === 'function') {
options.beforeCreateFirst.call(that);
}
}
if (typeof options.title === 'string') {
this.title = options.title;
}
if (typeof options.message === 'string') {
this.message = options.message;
} else if (options.message instanceof $) {
if (options.message.is('input,textarea,select')) {
this.message = options.message.val();
} else {
this.message = options.message.text();
}
if (typeof this.title === 'undefined' && typeof options.message.attr('title') === 'string') {
this.title = options.message.attr('title');
}
}
if (typeof options.icon === 'string') {
this.icon = options.icon;
}
if (options.sticky) {
this.duration = Infinity;
} else {
this.duration = options.duration || 5000;
}
// Call callback if it's defined (this = meow object)
if (typeof options.beforeCreate === 'function') {
options.beforeCreate.call(that);
}
// Add the meow to the meow area
$('#' + meow_area).append($(window.document.createElement('div'))
.attr('id', 'meow-' + this.timestamp.toString())
.addClass('meow')
.html($(window.document.createElement('div')).addClass('inner').html(this.message))
.hide()
.fadeIn(400));
this.manifest = $('#meow-' + this.timestamp.toString());
// Add title if it's defined
if (typeof this.title === 'string') {
this.manifest.find('.inner').prepend(
$(window.document.createElement('h1')).text(this.title)
);
}
// Add icon if it's defined
if (typeof that.icon === 'string') {
this.manifest.find('.inner').prepend(
$(window.document.createElement('div')).addClass('icon').html(
$(window.document.createElement('img')).attr('src', this.icon)
)
);
}
// Add close button if the meow isn't uncloseable
// TODO: this close button needs to be much prettier
if (options.closeable !== false) {
this.manifest.find('.inner').prepend(
$(window.document.createElement('a'))
.addClass('close')
.html('×')
.attr('href', '#close-meow-' + that.timestamp)
.click(function (e) {
e.preventDefault();
that.destroy();
})
);
}
this.manifest.bind('mouseenter mouseleave', function (event) {
if (event.type === 'mouseleave') {
that.hovered = false;
that.manifest.removeClass('hover');
// Destroy the mow on mouseleave if it's timed out
if (that.timestamp + that.duration <= new Date().getTime()) {
that.destroy();
}
} else {
that.hovered = true;
that.manifest.addClass('hover');
}
});
// Add a timeout if the duration isn't Infinity
if (this.duration !== Infinity) {
this.timeout = window.setTimeout(function () {
// Make sure this meow hasn't already been destroyed
if (typeof meows.get(that.timestamp) !== 'undefined') {
// Call callback if it's defined (this = meow DOM element)
if (typeof options.onTimeout === 'function') {
options.onTimeout.call(that.manifest);
}
// Don't destroy if user is hovering over meow
if (that.hovered !== true && typeof that === 'object') {
that.destroy();
}
}
}, that.duration);
}
this.destroy = function () {
if (that.destroyed !== true) {
// Call callback if it's defined (this = meow DOM element)
if (typeof options.beforeDestroy === 'function') {
options.beforeDestroy.call(that.manifest);
}
that.manifest.find('.inner').fadeTo(400, 0, function () {
that.manifest.slideUp(function () {
that.manifest.remove();
that.destroyed = true;
meows.remove(that.timestamp);
if (typeof options.afterDestroy === 'function') {
options.afterDestroy.call(null);
}
if (meows.size() <= 0) {
$('#' + meow_area).remove();
if (typeof options.afterDestroyLast === 'function') {
options.afterDestroyLast.call(null);
}
}
});
});
}
};
};
$.fn.meow = function (args) {
var meow = new Meow(args);
meows.add(meow);
return meow;
};
$.meow = $.fn.meow;
}(jQuery, window));
<MSG> Resolve conflicts with default meow area
<DFF> @@ -1,7 +1,7 @@
(function ($, window) {
'use strict';
// Meow queue
- var meow_area,
+ var default_meow_area,
meows = {
queue: {},
add: function (meow) {
@@ -29,20 +29,26 @@
this.timestamp = new Date().getTime(); // used to identify this meow and timeout
this.hovered = false; // whether mouse is over or not
- if (typeof options.group === 'string') {
- this.group = options.group;
- } else {
- this.group = 'body';
+ if (typeof default_meow_area === 'undefined'
+ && typeof options.container === 'undefined') {
+ default_meow_area = $(window.document.createElement('div'))
+ .attr({'id': ((new Date()).getTime()), 'class': 'meows'});
+ $('body').prepend(default_meow_area);
}
if (meows.size() <= 0) {
- meow_area = 'meows-' + new Date().getTime();
- $(this.group).prepend($(window.document.createElement('div')).attr({'id': meow_area, 'class': 'meows'}));
if (typeof options.beforeCreateFirst === 'function') {
options.beforeCreateFirst.call(that);
}
}
+ if (typeof options.container === 'string') {
+ this.container = $(options.container);
+ } else {
+ this.container = default_meow_area;
+ }
+
+
if (typeof options.title === 'string') {
this.title = options.title;
}
@@ -76,7 +82,7 @@
}
// Add the meow to the meow area
- $('#' + meow_area).append($(window.document.createElement('div'))
+ this.container.append($(window.document.createElement('div'))
.attr('id', 'meow-' + this.timestamp.toString())
.addClass('meow')
.html($(window.document.createElement('div')).addClass('inner').html(this.message))
@@ -162,7 +168,10 @@
options.afterDestroy.call(null);
}
if (meows.size() <= 0) {
- $('#' + meow_area).remove();
+ if (default_meow_area instanceof $) {
+ default_meow_area.remove();
+ default_meow_area = undefined;
+ }
if (typeof options.afterDestroyLast === 'function') {
options.afterDestroyLast.call(null);
}
| 18 | Resolve conflicts with default meow area | 9 | .js | meow | mit | zacstewart/Meow |
10071560 | <NME> experiment.rb
<BEF> module Split
class Experiment
attr_accessor :name
attr_accessor :alternative_names
attr_accessor :winner
def initialize(name, *alternative_names)
@name = name.to_s
@alternative_names = alternative_names.map do |alternative|
Split::Alternative.new(alternative, name)
end.map(&:name)
end
def winner
resettable: true
}
def self.find(name)
Split.cache(:experiments, name) do
return unless Split.redis.exists?(name)
Experiment.new(name).tap { |exp| exp.load_from_redis }
end
end
def initialize(name, options = {})
options = DEFAULT_OPTIONS.merge(options)
@name = name.to_s
extract_alternatives_from_options(options)
end
end
def alternatives
@alternative_names.map {|a| Split::Alternative.new(a, name)}
end
def next_alternative
self.resettable = options_with_defaults[:resettable]
self.algorithm = options_with_defaults[:algorithm]
self.metadata = options_with_defaults[:metadata]
end
def extract_alternatives_from_options(options)
alts = options[:alternatives] || []
if alts.length == 1
if alts[0].is_a? Hash
alts = alts[0].map { |k, v| { k => v } }
end
end
if alts.empty?
exp_config = Split.configuration.experiment_for(name)
if exp_config
alts = load_alternatives_from_configuration
options[:goals] = Split::GoalsCollection.new(@name).load_from_configuration
options[:metadata] = load_metadata_from_configuration
options[:resettable] = exp_config[:resettable]
options[:algorithm] = exp_config[:algorithm]
end
end
options[:alternatives] = alts
set_alternatives_and_options(options)
# calculate probability that each alternative is the winner
@alternative_probabilities = {}
alts
end
def save
validate!
if new_record?
start unless Split.configuration.start_manually
persist_experiment_configuration
elsif experiment_configuration_has_changed?
reset unless Split.configuration.reset_manually
persist_experiment_configuration
end
redis.hmset(experiment_config_key, :resettable, resettable.to_s,
:algorithm, algorithm.to_s)
self
end
def save
if new_record?
Split.redis.sadd(:experiments, name)
@alternative_names.reverse.each {|a| Split.redis.lpush(name, a) }
end
end
end
def new_record?
ExperimentCatalog.find(name).nil?
end
def ==(obj)
self.name == obj.name
end
def [](name)
alternatives.find { |a| a.name == name }
end
def algorithm
@algorithm ||= Split.configuration.algorithm
end
def algorithm=(algorithm)
@algorithm = algorithm.is_a?(String) ? algorithm.constantize : algorithm
end
def resettable=(resettable)
@resettable = resettable.is_a?(String) ? resettable == "true" : resettable
end
def alternatives=(alts)
@alternatives = alts.map do |alternative|
if alternative.kind_of?(Split::Alternative)
alternative
else
Split::Alternative.new(alternative, @name)
end
end
end
def winner
Split.cache(:experiment_winner, name) do
experiment_winner = redis.hget(:experiment_winner, name)
if experiment_winner
Split::Alternative.new(experiment_winner, name)
else
nil
end
end
end
def has_winner?
return @has_winner if defined? @has_winner
@has_winner = !winner.nil?
end
def winner=(winner_name)
redis.hset(:experiment_winner, name, winner_name.to_s)
@has_winner = true
Split.configuration.on_experiment_winner_choose.call(self)
end
def participant_count
alternatives.inject(0) { |sum, a| sum + a.participant_count }
end
def control
alternatives.first
end
def reset_winner
redis.hdel(:experiment_winner, name)
@has_winner = false
Split::Cache.clear_key(@name)
end
def start
redis.hset(:experiment_start_times, @name, Time.now.to_i)
end
def start_time
Split.cache(:experiment_start_times, @name) do
t = redis.hget(:experiment_start_times, @name)
if t
# Check if stored time is an integer
if t =~ /^[-+]?[0-9]+$/
Time.at(t.to_i)
else
Time.parse(t)
end
end
end
end
def next_alternative
winner || random_alternative
end
def random_alternative
if alternatives.length > 1
algorithm.choose_alternative(self)
else
alternatives.first
end
end
def version
@version ||= (redis.get("#{name}:version").to_i || 0)
end
def increment_version
@version = redis.incr("#{name}:version")
end
def key
if version.to_i > 0
"#{name}:#{version}"
else
name
end
end
def goals_key
"#{name}:goals"
end
def finished_key
self.class.finished_key(key)
end
def metadata_key
"#{name}:metadata"
end
def resettable?
resettable
end
def reset
Split.configuration.on_before_experiment_reset.call(self)
Split::Cache.clear_key(@name)
alternatives.each(&:reset)
reset_winner
Split.configuration.on_experiment_reset.call(self)
increment_version
end
def delete
Split.configuration.on_before_experiment_delete.call(self)
if Split.configuration.start_manually
redis.hdel(:experiment_start_times, @name)
end
reset_winner
redis.srem(:experiments, name)
remove_experiment_cohorting
remove_experiment_configuration
Split.configuration.on_experiment_delete.call(self)
increment_version
end
def delete_metadata
redis.del(metadata_key)
end
def load_from_redis
exp_config = redis.hgetall(experiment_config_key)
options = {
resettable: exp_config["resettable"],
algorithm: exp_config["algorithm"],
alternatives: load_alternatives_from_redis,
goals: Split::GoalsCollection.new(@name).load_from_redis,
metadata: load_metadata_from_redis
}
set_alternatives_and_options(options)
end
def calc_winning_alternatives
# Cache the winning alternatives so we recalculate them once per the specified interval.
intervals_since_epoch =
Time.now.utc.to_i / Split.configuration.winning_alternative_recalculation_interval
if self.calc_time != intervals_since_epoch
if goals.empty?
self.estimate_winning_alternative
else
goals.each do |goal|
self.estimate_winning_alternative(goal)
end
end
self.calc_time = intervals_since_epoch
self.save
end
end
def estimate_winning_alternative(goal = nil)
# initialize a hash of beta distributions based on the alternatives' conversion rates
beta_params = calc_beta_params(goal)
winning_alternatives = []
Split.configuration.beta_probability_simulations.times do
# calculate simulated conversion rates from the beta distributions
simulated_cr_hash = calc_simulated_conversion_rates(beta_params)
winning_alternative = find_simulated_winner(simulated_cr_hash)
# push the winning pair to the winning_alternatives array
winning_alternatives.push(winning_alternative)
end
winning_counts = count_simulated_wins(winning_alternatives)
@alternative_probabilities = calc_alternative_probabilities(winning_counts, Split.configuration.beta_probability_simulations)
write_to_alternatives(goal)
self.save
end
def write_to_alternatives(goal = nil)
alternatives.each do |alternative|
alternative.set_p_winner(@alternative_probabilities[alternative], goal)
end
end
def calc_alternative_probabilities(winning_counts, number_of_simulations)
alternative_probabilities = {}
winning_counts.each do |alternative, wins|
alternative_probabilities[alternative] = wins / number_of_simulations.to_f
end
alternative_probabilities
end
def count_simulated_wins(winning_alternatives)
# initialize a hash to keep track of winning alternative in simulations
winning_counts = {}
alternatives.each do |alternative|
winning_counts[alternative] = 0
end
# count number of times each alternative won, calculate probabilities, place in hash
winning_alternatives.each do |alternative|
winning_counts[alternative] += 1
end
winning_counts
end
def find_simulated_winner(simulated_cr_hash)
# figure out which alternative had the highest simulated conversion rate
winning_pair = ["", 0.0]
simulated_cr_hash.each do |alternative, rate|
if rate > winning_pair[1]
winning_pair = [alternative, rate]
end
end
winner = winning_pair[0]
winner
end
def calc_simulated_conversion_rates(beta_params)
simulated_cr_hash = {}
# create a hash which has the conversion rate pulled from each alternative's beta distribution
beta_params.each do |alternative, params|
alpha = params[0]
beta = params[1]
simulated_conversion_rate = Split::Algorithms.beta_distribution_rng(alpha, beta)
simulated_cr_hash[alternative] = simulated_conversion_rate
end
simulated_cr_hash
end
def calc_beta_params(goal = nil)
beta_params = {}
alternatives.each do |alternative|
conversions = goal.nil? ? alternative.completed_count : alternative.completed_count(goal)
alpha = 1 + conversions
beta = 1 + alternative.participant_count - conversions
params = [alpha, beta]
beta_params[alternative] = params
end
beta_params
end
def calc_time=(time)
redis.hset(experiment_config_key, :calc_time, time)
end
def calc_time
redis.hget(experiment_config_key, :calc_time).to_i
end
def jstring(goal = nil)
js_id = if goal.nil?
name
else
name + "-" + goal
end
js_id.gsub("/", "--")
end
def cohorting_disabled?
@cohorting_disabled ||= begin
value = redis.hget(experiment_config_key, :cohorting)
value.nil? ? false : value.downcase == "true"
end
end
def disable_cohorting
@cohorting_disabled = true
redis.hset(experiment_config_key, :cohorting, true.to_s)
end
def enable_cohorting
@cohorting_disabled = false
redis.hset(experiment_config_key, :cohorting, false.to_s)
end
protected
def experiment_config_key
"experiment_configurations/#{@name}"
end
def load_metadata_from_configuration
Split.configuration.experiment_for(@name)[:metadata]
end
def load_metadata_from_redis
meta = redis.get(metadata_key)
JSON.parse(meta) unless meta.nil?
end
def load_alternatives_from_configuration
alts = Split.configuration.experiment_for(@name)[:alternatives]
raise ArgumentError, "Experiment configuration is missing :alternatives array" unless alts
if alts.is_a?(Hash)
alts.keys
else
alts.flatten
end
end
def load_alternatives_from_redis
alternatives = redis.lrange(@name, 0, -1)
alternatives.map do |alt|
alt = begin
JSON.parse(alt)
rescue
alt
end
Split::Alternative.new(alt, @name)
end
end
private
def redis
Split.redis
end
def redis_interface
RedisInterface.new
end
def persist_experiment_configuration
redis_interface.add_to_set(:experiments, name)
redis_interface.persist_list(name, @alternatives.map { |alt| { alt.name => alt.weight }.to_json })
goals_collection.save
if @metadata
redis.set(metadata_key, @metadata.to_json)
else
delete_metadata
end
end
def remove_experiment_configuration
@alternatives.each(&:delete)
goals_collection.delete
delete_metadata
redis.del(@name)
end
def experiment_configuration_has_changed?
existing_experiment = Experiment.find(@name)
existing_experiment.alternatives.map(&:to_s) != @alternatives.map(&:to_s) ||
existing_experiment.goals != @goals ||
existing_experiment.metadata != @metadata
end
def goals_collection
Split::GoalsCollection.new(@name, @goals)
end
def remove_experiment_cohorting
@cohorting_disabled = false
redis.hdel(experiment_config_key, :cohorting)
end
end
end
<MSG> Store alternatives as array of objects
<DFF> @@ -1,14 +1,13 @@
module Split
class Experiment
attr_accessor :name
- attr_accessor :alternative_names
attr_accessor :winner
def initialize(name, *alternative_names)
@name = name.to_s
- @alternative_names = alternative_names.map do |alternative|
- Split::Alternative.new(alternative, name)
- end.map(&:name)
+ @alternatives = alternative_names.map do |alternative|
+ Split::Alternative.new(alternative, name)
+ end
end
def winner
@@ -33,7 +32,11 @@ module Split
end
def alternatives
- @alternative_names.map {|a| Split::Alternative.new(a, name)}
+ @alternatives.dup
+ end
+
+ def alternative_names
+ @alternatives.map(&:name)
end
def next_alternative
@@ -89,7 +92,7 @@ module Split
def save
if new_record?
Split.redis.sadd(:experiments, name)
- @alternative_names.reverse.each {|a| Split.redis.lpush(name, a) }
+ @alternatives.reverse.each {|a| Split.redis.lpush(name, a.name) }
end
end
| 9 | Store alternatives as array of objects | 6 | .rb | rb | mit | splitrb/split |
10071561 | <NME> experiment.rb
<BEF> module Split
class Experiment
attr_accessor :name
attr_accessor :alternative_names
attr_accessor :winner
def initialize(name, *alternative_names)
@name = name.to_s
@alternative_names = alternative_names.map do |alternative|
Split::Alternative.new(alternative, name)
end.map(&:name)
end
def winner
resettable: true
}
def self.find(name)
Split.cache(:experiments, name) do
return unless Split.redis.exists?(name)
Experiment.new(name).tap { |exp| exp.load_from_redis }
end
end
def initialize(name, options = {})
options = DEFAULT_OPTIONS.merge(options)
@name = name.to_s
extract_alternatives_from_options(options)
end
end
def alternatives
@alternative_names.map {|a| Split::Alternative.new(a, name)}
end
def next_alternative
self.resettable = options_with_defaults[:resettable]
self.algorithm = options_with_defaults[:algorithm]
self.metadata = options_with_defaults[:metadata]
end
def extract_alternatives_from_options(options)
alts = options[:alternatives] || []
if alts.length == 1
if alts[0].is_a? Hash
alts = alts[0].map { |k, v| { k => v } }
end
end
if alts.empty?
exp_config = Split.configuration.experiment_for(name)
if exp_config
alts = load_alternatives_from_configuration
options[:goals] = Split::GoalsCollection.new(@name).load_from_configuration
options[:metadata] = load_metadata_from_configuration
options[:resettable] = exp_config[:resettable]
options[:algorithm] = exp_config[:algorithm]
end
end
options[:alternatives] = alts
set_alternatives_and_options(options)
# calculate probability that each alternative is the winner
@alternative_probabilities = {}
alts
end
def save
validate!
if new_record?
start unless Split.configuration.start_manually
persist_experiment_configuration
elsif experiment_configuration_has_changed?
reset unless Split.configuration.reset_manually
persist_experiment_configuration
end
redis.hmset(experiment_config_key, :resettable, resettable.to_s,
:algorithm, algorithm.to_s)
self
end
def save
if new_record?
Split.redis.sadd(:experiments, name)
@alternative_names.reverse.each {|a| Split.redis.lpush(name, a) }
end
end
end
def new_record?
ExperimentCatalog.find(name).nil?
end
def ==(obj)
self.name == obj.name
end
def [](name)
alternatives.find { |a| a.name == name }
end
def algorithm
@algorithm ||= Split.configuration.algorithm
end
def algorithm=(algorithm)
@algorithm = algorithm.is_a?(String) ? algorithm.constantize : algorithm
end
def resettable=(resettable)
@resettable = resettable.is_a?(String) ? resettable == "true" : resettable
end
def alternatives=(alts)
@alternatives = alts.map do |alternative|
if alternative.kind_of?(Split::Alternative)
alternative
else
Split::Alternative.new(alternative, @name)
end
end
end
def winner
Split.cache(:experiment_winner, name) do
experiment_winner = redis.hget(:experiment_winner, name)
if experiment_winner
Split::Alternative.new(experiment_winner, name)
else
nil
end
end
end
def has_winner?
return @has_winner if defined? @has_winner
@has_winner = !winner.nil?
end
def winner=(winner_name)
redis.hset(:experiment_winner, name, winner_name.to_s)
@has_winner = true
Split.configuration.on_experiment_winner_choose.call(self)
end
def participant_count
alternatives.inject(0) { |sum, a| sum + a.participant_count }
end
def control
alternatives.first
end
def reset_winner
redis.hdel(:experiment_winner, name)
@has_winner = false
Split::Cache.clear_key(@name)
end
def start
redis.hset(:experiment_start_times, @name, Time.now.to_i)
end
def start_time
Split.cache(:experiment_start_times, @name) do
t = redis.hget(:experiment_start_times, @name)
if t
# Check if stored time is an integer
if t =~ /^[-+]?[0-9]+$/
Time.at(t.to_i)
else
Time.parse(t)
end
end
end
end
def next_alternative
winner || random_alternative
end
def random_alternative
if alternatives.length > 1
algorithm.choose_alternative(self)
else
alternatives.first
end
end
def version
@version ||= (redis.get("#{name}:version").to_i || 0)
end
def increment_version
@version = redis.incr("#{name}:version")
end
def key
if version.to_i > 0
"#{name}:#{version}"
else
name
end
end
def goals_key
"#{name}:goals"
end
def finished_key
self.class.finished_key(key)
end
def metadata_key
"#{name}:metadata"
end
def resettable?
resettable
end
def reset
Split.configuration.on_before_experiment_reset.call(self)
Split::Cache.clear_key(@name)
alternatives.each(&:reset)
reset_winner
Split.configuration.on_experiment_reset.call(self)
increment_version
end
def delete
Split.configuration.on_before_experiment_delete.call(self)
if Split.configuration.start_manually
redis.hdel(:experiment_start_times, @name)
end
reset_winner
redis.srem(:experiments, name)
remove_experiment_cohorting
remove_experiment_configuration
Split.configuration.on_experiment_delete.call(self)
increment_version
end
def delete_metadata
redis.del(metadata_key)
end
def load_from_redis
exp_config = redis.hgetall(experiment_config_key)
options = {
resettable: exp_config["resettable"],
algorithm: exp_config["algorithm"],
alternatives: load_alternatives_from_redis,
goals: Split::GoalsCollection.new(@name).load_from_redis,
metadata: load_metadata_from_redis
}
set_alternatives_and_options(options)
end
def calc_winning_alternatives
# Cache the winning alternatives so we recalculate them once per the specified interval.
intervals_since_epoch =
Time.now.utc.to_i / Split.configuration.winning_alternative_recalculation_interval
if self.calc_time != intervals_since_epoch
if goals.empty?
self.estimate_winning_alternative
else
goals.each do |goal|
self.estimate_winning_alternative(goal)
end
end
self.calc_time = intervals_since_epoch
self.save
end
end
def estimate_winning_alternative(goal = nil)
# initialize a hash of beta distributions based on the alternatives' conversion rates
beta_params = calc_beta_params(goal)
winning_alternatives = []
Split.configuration.beta_probability_simulations.times do
# calculate simulated conversion rates from the beta distributions
simulated_cr_hash = calc_simulated_conversion_rates(beta_params)
winning_alternative = find_simulated_winner(simulated_cr_hash)
# push the winning pair to the winning_alternatives array
winning_alternatives.push(winning_alternative)
end
winning_counts = count_simulated_wins(winning_alternatives)
@alternative_probabilities = calc_alternative_probabilities(winning_counts, Split.configuration.beta_probability_simulations)
write_to_alternatives(goal)
self.save
end
def write_to_alternatives(goal = nil)
alternatives.each do |alternative|
alternative.set_p_winner(@alternative_probabilities[alternative], goal)
end
end
def calc_alternative_probabilities(winning_counts, number_of_simulations)
alternative_probabilities = {}
winning_counts.each do |alternative, wins|
alternative_probabilities[alternative] = wins / number_of_simulations.to_f
end
alternative_probabilities
end
def count_simulated_wins(winning_alternatives)
# initialize a hash to keep track of winning alternative in simulations
winning_counts = {}
alternatives.each do |alternative|
winning_counts[alternative] = 0
end
# count number of times each alternative won, calculate probabilities, place in hash
winning_alternatives.each do |alternative|
winning_counts[alternative] += 1
end
winning_counts
end
def find_simulated_winner(simulated_cr_hash)
# figure out which alternative had the highest simulated conversion rate
winning_pair = ["", 0.0]
simulated_cr_hash.each do |alternative, rate|
if rate > winning_pair[1]
winning_pair = [alternative, rate]
end
end
winner = winning_pair[0]
winner
end
def calc_simulated_conversion_rates(beta_params)
simulated_cr_hash = {}
# create a hash which has the conversion rate pulled from each alternative's beta distribution
beta_params.each do |alternative, params|
alpha = params[0]
beta = params[1]
simulated_conversion_rate = Split::Algorithms.beta_distribution_rng(alpha, beta)
simulated_cr_hash[alternative] = simulated_conversion_rate
end
simulated_cr_hash
end
def calc_beta_params(goal = nil)
beta_params = {}
alternatives.each do |alternative|
conversions = goal.nil? ? alternative.completed_count : alternative.completed_count(goal)
alpha = 1 + conversions
beta = 1 + alternative.participant_count - conversions
params = [alpha, beta]
beta_params[alternative] = params
end
beta_params
end
def calc_time=(time)
redis.hset(experiment_config_key, :calc_time, time)
end
def calc_time
redis.hget(experiment_config_key, :calc_time).to_i
end
def jstring(goal = nil)
js_id = if goal.nil?
name
else
name + "-" + goal
end
js_id.gsub("/", "--")
end
def cohorting_disabled?
@cohorting_disabled ||= begin
value = redis.hget(experiment_config_key, :cohorting)
value.nil? ? false : value.downcase == "true"
end
end
def disable_cohorting
@cohorting_disabled = true
redis.hset(experiment_config_key, :cohorting, true.to_s)
end
def enable_cohorting
@cohorting_disabled = false
redis.hset(experiment_config_key, :cohorting, false.to_s)
end
protected
def experiment_config_key
"experiment_configurations/#{@name}"
end
def load_metadata_from_configuration
Split.configuration.experiment_for(@name)[:metadata]
end
def load_metadata_from_redis
meta = redis.get(metadata_key)
JSON.parse(meta) unless meta.nil?
end
def load_alternatives_from_configuration
alts = Split.configuration.experiment_for(@name)[:alternatives]
raise ArgumentError, "Experiment configuration is missing :alternatives array" unless alts
if alts.is_a?(Hash)
alts.keys
else
alts.flatten
end
end
def load_alternatives_from_redis
alternatives = redis.lrange(@name, 0, -1)
alternatives.map do |alt|
alt = begin
JSON.parse(alt)
rescue
alt
end
Split::Alternative.new(alt, @name)
end
end
private
def redis
Split.redis
end
def redis_interface
RedisInterface.new
end
def persist_experiment_configuration
redis_interface.add_to_set(:experiments, name)
redis_interface.persist_list(name, @alternatives.map { |alt| { alt.name => alt.weight }.to_json })
goals_collection.save
if @metadata
redis.set(metadata_key, @metadata.to_json)
else
delete_metadata
end
end
def remove_experiment_configuration
@alternatives.each(&:delete)
goals_collection.delete
delete_metadata
redis.del(@name)
end
def experiment_configuration_has_changed?
existing_experiment = Experiment.find(@name)
existing_experiment.alternatives.map(&:to_s) != @alternatives.map(&:to_s) ||
existing_experiment.goals != @goals ||
existing_experiment.metadata != @metadata
end
def goals_collection
Split::GoalsCollection.new(@name, @goals)
end
def remove_experiment_cohorting
@cohorting_disabled = false
redis.hdel(experiment_config_key, :cohorting)
end
end
end
<MSG> Store alternatives as array of objects
<DFF> @@ -1,14 +1,13 @@
module Split
class Experiment
attr_accessor :name
- attr_accessor :alternative_names
attr_accessor :winner
def initialize(name, *alternative_names)
@name = name.to_s
- @alternative_names = alternative_names.map do |alternative|
- Split::Alternative.new(alternative, name)
- end.map(&:name)
+ @alternatives = alternative_names.map do |alternative|
+ Split::Alternative.new(alternative, name)
+ end
end
def winner
@@ -33,7 +32,11 @@ module Split
end
def alternatives
- @alternative_names.map {|a| Split::Alternative.new(a, name)}
+ @alternatives.dup
+ end
+
+ def alternative_names
+ @alternatives.map(&:name)
end
def next_alternative
@@ -89,7 +92,7 @@ module Split
def save
if new_record?
Split.redis.sadd(:experiments, name)
- @alternative_names.reverse.each {|a| Split.redis.lpush(name, a) }
+ @alternatives.reverse.each {|a| Split.redis.lpush(name, a.name) }
end
end
| 9 | Store alternatives as array of objects | 6 | .rb | rb | mit | splitrb/split |
10071562 | <NME> experiment.rb
<BEF> module Split
class Experiment
attr_accessor :name
attr_accessor :alternative_names
attr_accessor :winner
def initialize(name, *alternative_names)
@name = name.to_s
@alternative_names = alternative_names.map do |alternative|
Split::Alternative.new(alternative, name)
end.map(&:name)
end
def winner
resettable: true
}
def self.find(name)
Split.cache(:experiments, name) do
return unless Split.redis.exists?(name)
Experiment.new(name).tap { |exp| exp.load_from_redis }
end
end
def initialize(name, options = {})
options = DEFAULT_OPTIONS.merge(options)
@name = name.to_s
extract_alternatives_from_options(options)
end
end
def alternatives
@alternative_names.map {|a| Split::Alternative.new(a, name)}
end
def next_alternative
self.resettable = options_with_defaults[:resettable]
self.algorithm = options_with_defaults[:algorithm]
self.metadata = options_with_defaults[:metadata]
end
def extract_alternatives_from_options(options)
alts = options[:alternatives] || []
if alts.length == 1
if alts[0].is_a? Hash
alts = alts[0].map { |k, v| { k => v } }
end
end
if alts.empty?
exp_config = Split.configuration.experiment_for(name)
if exp_config
alts = load_alternatives_from_configuration
options[:goals] = Split::GoalsCollection.new(@name).load_from_configuration
options[:metadata] = load_metadata_from_configuration
options[:resettable] = exp_config[:resettable]
options[:algorithm] = exp_config[:algorithm]
end
end
options[:alternatives] = alts
set_alternatives_and_options(options)
# calculate probability that each alternative is the winner
@alternative_probabilities = {}
alts
end
def save
validate!
if new_record?
start unless Split.configuration.start_manually
persist_experiment_configuration
elsif experiment_configuration_has_changed?
reset unless Split.configuration.reset_manually
persist_experiment_configuration
end
redis.hmset(experiment_config_key, :resettable, resettable.to_s,
:algorithm, algorithm.to_s)
self
end
def save
if new_record?
Split.redis.sadd(:experiments, name)
@alternative_names.reverse.each {|a| Split.redis.lpush(name, a) }
end
end
end
def new_record?
ExperimentCatalog.find(name).nil?
end
def ==(obj)
self.name == obj.name
end
def [](name)
alternatives.find { |a| a.name == name }
end
def algorithm
@algorithm ||= Split.configuration.algorithm
end
def algorithm=(algorithm)
@algorithm = algorithm.is_a?(String) ? algorithm.constantize : algorithm
end
def resettable=(resettable)
@resettable = resettable.is_a?(String) ? resettable == "true" : resettable
end
def alternatives=(alts)
@alternatives = alts.map do |alternative|
if alternative.kind_of?(Split::Alternative)
alternative
else
Split::Alternative.new(alternative, @name)
end
end
end
def winner
Split.cache(:experiment_winner, name) do
experiment_winner = redis.hget(:experiment_winner, name)
if experiment_winner
Split::Alternative.new(experiment_winner, name)
else
nil
end
end
end
def has_winner?
return @has_winner if defined? @has_winner
@has_winner = !winner.nil?
end
def winner=(winner_name)
redis.hset(:experiment_winner, name, winner_name.to_s)
@has_winner = true
Split.configuration.on_experiment_winner_choose.call(self)
end
def participant_count
alternatives.inject(0) { |sum, a| sum + a.participant_count }
end
def control
alternatives.first
end
def reset_winner
redis.hdel(:experiment_winner, name)
@has_winner = false
Split::Cache.clear_key(@name)
end
def start
redis.hset(:experiment_start_times, @name, Time.now.to_i)
end
def start_time
Split.cache(:experiment_start_times, @name) do
t = redis.hget(:experiment_start_times, @name)
if t
# Check if stored time is an integer
if t =~ /^[-+]?[0-9]+$/
Time.at(t.to_i)
else
Time.parse(t)
end
end
end
end
def next_alternative
winner || random_alternative
end
def random_alternative
if alternatives.length > 1
algorithm.choose_alternative(self)
else
alternatives.first
end
end
def version
@version ||= (redis.get("#{name}:version").to_i || 0)
end
def increment_version
@version = redis.incr("#{name}:version")
end
def key
if version.to_i > 0
"#{name}:#{version}"
else
name
end
end
def goals_key
"#{name}:goals"
end
def finished_key
self.class.finished_key(key)
end
def metadata_key
"#{name}:metadata"
end
def resettable?
resettable
end
def reset
Split.configuration.on_before_experiment_reset.call(self)
Split::Cache.clear_key(@name)
alternatives.each(&:reset)
reset_winner
Split.configuration.on_experiment_reset.call(self)
increment_version
end
def delete
Split.configuration.on_before_experiment_delete.call(self)
if Split.configuration.start_manually
redis.hdel(:experiment_start_times, @name)
end
reset_winner
redis.srem(:experiments, name)
remove_experiment_cohorting
remove_experiment_configuration
Split.configuration.on_experiment_delete.call(self)
increment_version
end
def delete_metadata
redis.del(metadata_key)
end
def load_from_redis
exp_config = redis.hgetall(experiment_config_key)
options = {
resettable: exp_config["resettable"],
algorithm: exp_config["algorithm"],
alternatives: load_alternatives_from_redis,
goals: Split::GoalsCollection.new(@name).load_from_redis,
metadata: load_metadata_from_redis
}
set_alternatives_and_options(options)
end
def calc_winning_alternatives
# Cache the winning alternatives so we recalculate them once per the specified interval.
intervals_since_epoch =
Time.now.utc.to_i / Split.configuration.winning_alternative_recalculation_interval
if self.calc_time != intervals_since_epoch
if goals.empty?
self.estimate_winning_alternative
else
goals.each do |goal|
self.estimate_winning_alternative(goal)
end
end
self.calc_time = intervals_since_epoch
self.save
end
end
def estimate_winning_alternative(goal = nil)
# initialize a hash of beta distributions based on the alternatives' conversion rates
beta_params = calc_beta_params(goal)
winning_alternatives = []
Split.configuration.beta_probability_simulations.times do
# calculate simulated conversion rates from the beta distributions
simulated_cr_hash = calc_simulated_conversion_rates(beta_params)
winning_alternative = find_simulated_winner(simulated_cr_hash)
# push the winning pair to the winning_alternatives array
winning_alternatives.push(winning_alternative)
end
winning_counts = count_simulated_wins(winning_alternatives)
@alternative_probabilities = calc_alternative_probabilities(winning_counts, Split.configuration.beta_probability_simulations)
write_to_alternatives(goal)
self.save
end
def write_to_alternatives(goal = nil)
alternatives.each do |alternative|
alternative.set_p_winner(@alternative_probabilities[alternative], goal)
end
end
def calc_alternative_probabilities(winning_counts, number_of_simulations)
alternative_probabilities = {}
winning_counts.each do |alternative, wins|
alternative_probabilities[alternative] = wins / number_of_simulations.to_f
end
alternative_probabilities
end
def count_simulated_wins(winning_alternatives)
# initialize a hash to keep track of winning alternative in simulations
winning_counts = {}
alternatives.each do |alternative|
winning_counts[alternative] = 0
end
# count number of times each alternative won, calculate probabilities, place in hash
winning_alternatives.each do |alternative|
winning_counts[alternative] += 1
end
winning_counts
end
def find_simulated_winner(simulated_cr_hash)
# figure out which alternative had the highest simulated conversion rate
winning_pair = ["", 0.0]
simulated_cr_hash.each do |alternative, rate|
if rate > winning_pair[1]
winning_pair = [alternative, rate]
end
end
winner = winning_pair[0]
winner
end
def calc_simulated_conversion_rates(beta_params)
simulated_cr_hash = {}
# create a hash which has the conversion rate pulled from each alternative's beta distribution
beta_params.each do |alternative, params|
alpha = params[0]
beta = params[1]
simulated_conversion_rate = Split::Algorithms.beta_distribution_rng(alpha, beta)
simulated_cr_hash[alternative] = simulated_conversion_rate
end
simulated_cr_hash
end
def calc_beta_params(goal = nil)
beta_params = {}
alternatives.each do |alternative|
conversions = goal.nil? ? alternative.completed_count : alternative.completed_count(goal)
alpha = 1 + conversions
beta = 1 + alternative.participant_count - conversions
params = [alpha, beta]
beta_params[alternative] = params
end
beta_params
end
def calc_time=(time)
redis.hset(experiment_config_key, :calc_time, time)
end
def calc_time
redis.hget(experiment_config_key, :calc_time).to_i
end
def jstring(goal = nil)
js_id = if goal.nil?
name
else
name + "-" + goal
end
js_id.gsub("/", "--")
end
def cohorting_disabled?
@cohorting_disabled ||= begin
value = redis.hget(experiment_config_key, :cohorting)
value.nil? ? false : value.downcase == "true"
end
end
def disable_cohorting
@cohorting_disabled = true
redis.hset(experiment_config_key, :cohorting, true.to_s)
end
def enable_cohorting
@cohorting_disabled = false
redis.hset(experiment_config_key, :cohorting, false.to_s)
end
protected
def experiment_config_key
"experiment_configurations/#{@name}"
end
def load_metadata_from_configuration
Split.configuration.experiment_for(@name)[:metadata]
end
def load_metadata_from_redis
meta = redis.get(metadata_key)
JSON.parse(meta) unless meta.nil?
end
def load_alternatives_from_configuration
alts = Split.configuration.experiment_for(@name)[:alternatives]
raise ArgumentError, "Experiment configuration is missing :alternatives array" unless alts
if alts.is_a?(Hash)
alts.keys
else
alts.flatten
end
end
def load_alternatives_from_redis
alternatives = redis.lrange(@name, 0, -1)
alternatives.map do |alt|
alt = begin
JSON.parse(alt)
rescue
alt
end
Split::Alternative.new(alt, @name)
end
end
private
def redis
Split.redis
end
def redis_interface
RedisInterface.new
end
def persist_experiment_configuration
redis_interface.add_to_set(:experiments, name)
redis_interface.persist_list(name, @alternatives.map { |alt| { alt.name => alt.weight }.to_json })
goals_collection.save
if @metadata
redis.set(metadata_key, @metadata.to_json)
else
delete_metadata
end
end
def remove_experiment_configuration
@alternatives.each(&:delete)
goals_collection.delete
delete_metadata
redis.del(@name)
end
def experiment_configuration_has_changed?
existing_experiment = Experiment.find(@name)
existing_experiment.alternatives.map(&:to_s) != @alternatives.map(&:to_s) ||
existing_experiment.goals != @goals ||
existing_experiment.metadata != @metadata
end
def goals_collection
Split::GoalsCollection.new(@name, @goals)
end
def remove_experiment_cohorting
@cohorting_disabled = false
redis.hdel(experiment_config_key, :cohorting)
end
end
end
<MSG> Store alternatives as array of objects
<DFF> @@ -1,14 +1,13 @@
module Split
class Experiment
attr_accessor :name
- attr_accessor :alternative_names
attr_accessor :winner
def initialize(name, *alternative_names)
@name = name.to_s
- @alternative_names = alternative_names.map do |alternative|
- Split::Alternative.new(alternative, name)
- end.map(&:name)
+ @alternatives = alternative_names.map do |alternative|
+ Split::Alternative.new(alternative, name)
+ end
end
def winner
@@ -33,7 +32,11 @@ module Split
end
def alternatives
- @alternative_names.map {|a| Split::Alternative.new(a, name)}
+ @alternatives.dup
+ end
+
+ def alternative_names
+ @alternatives.map(&:name)
end
def next_alternative
@@ -89,7 +92,7 @@ module Split
def save
if new_record?
Split.redis.sadd(:experiments, name)
- @alternative_names.reverse.each {|a| Split.redis.lpush(name, a) }
+ @alternatives.reverse.each {|a| Split.redis.lpush(name, a.name) }
end
end
| 9 | Store alternatives as array of objects | 6 | .rb | rb | mit | splitrb/split |
10071563 | <NME> index.erb
<BEF> <% if @experiments.any? %>
<p class="intro">The list below contains all the registered experiments along with the number of test participants, completed and conversion rate currently in the system.</p>
<input type="text" placeholder="Begin typing to filter" id="filter" />
<input type="button" id="clear-filter" value="Clear filter" />
<% @experiments.each do |experiment| %>
<% if experiment.goals.empty? %>
<% paginated(@experiments).each do |experiment| %>
<% if experiment.goals.empty? %>
<%= erb :_experiment, :locals => {:goal => nil, :experiment => experiment} %>
<% else %>
<%= erb :_experiment_with_goal_header, :locals => {:experiment => experiment} %>
<% experiment.goals.each do |g| %>
<%= erb :_experiment, :locals => {:goal => g, :experiment => experiment} %>
<% end %>
<% end %>
<% end %>
<div class="pagination">
<%= pagination(@experiments) %>
</div>
<% else %>
<p class="intro">No experiments have started yet, you need to define them in your code and introduce them to your users.</p>
<p class="intro">Check out the <a href='https://github.com/splitrb/split#readme'>Readme</a> for more help getting started.</p>
<% end %>
<div class="dashboard-controls dashboard-controls-bottom">
<form action="<%= url "/initialize_experiment" %>" method='post'>
<label>Add unregistered experiment: </label>
<select name="experiment" id="experiment-select">
<option selected disabled>experiment</option>
<% @unintialized_experiments.sort.each do |experiment_name| %>
<option value="<%= experiment_name %>"><%= experiment_name %></option>
<% end %>
</select>
<input type="submit" id="register-experiment-btn" value="register experiment"/>
</form>
<div>
<MSG> Merge pull request #364 from ccallebs/master
Implement filtering dashboard by active/complete experiments
<DFF> @@ -2,7 +2,9 @@
<p class="intro">The list below contains all the registered experiments along with the number of test participants, completed and conversion rate currently in the system.</p>
<input type="text" placeholder="Begin typing to filter" id="filter" />
- <input type="button" id="clear-filter" value="Clear filter" />
+ <input type="button" id="toggle-completed" value="Hide completed" />
+ <input type="button" id="toggle-active" value="Hide active" />
+ <input type="button" id="clear-filter" value="Clear filters" />
<% @experiments.each do |experiment| %>
<% if experiment.goals.empty? %>
| 3 | Merge pull request #364 from ccallebs/master | 1 | .erb | erb | mit | splitrb/split |
10071564 | <NME> index.erb
<BEF> <% if @experiments.any? %>
<p class="intro">The list below contains all the registered experiments along with the number of test participants, completed and conversion rate currently in the system.</p>
<input type="text" placeholder="Begin typing to filter" id="filter" />
<input type="button" id="clear-filter" value="Clear filter" />
<% @experiments.each do |experiment| %>
<% if experiment.goals.empty? %>
<% paginated(@experiments).each do |experiment| %>
<% if experiment.goals.empty? %>
<%= erb :_experiment, :locals => {:goal => nil, :experiment => experiment} %>
<% else %>
<%= erb :_experiment_with_goal_header, :locals => {:experiment => experiment} %>
<% experiment.goals.each do |g| %>
<%= erb :_experiment, :locals => {:goal => g, :experiment => experiment} %>
<% end %>
<% end %>
<% end %>
<div class="pagination">
<%= pagination(@experiments) %>
</div>
<% else %>
<p class="intro">No experiments have started yet, you need to define them in your code and introduce them to your users.</p>
<p class="intro">Check out the <a href='https://github.com/splitrb/split#readme'>Readme</a> for more help getting started.</p>
<% end %>
<div class="dashboard-controls dashboard-controls-bottom">
<form action="<%= url "/initialize_experiment" %>" method='post'>
<label>Add unregistered experiment: </label>
<select name="experiment" id="experiment-select">
<option selected disabled>experiment</option>
<% @unintialized_experiments.sort.each do |experiment_name| %>
<option value="<%= experiment_name %>"><%= experiment_name %></option>
<% end %>
</select>
<input type="submit" id="register-experiment-btn" value="register experiment"/>
</form>
<div>
<MSG> Merge pull request #364 from ccallebs/master
Implement filtering dashboard by active/complete experiments
<DFF> @@ -2,7 +2,9 @@
<p class="intro">The list below contains all the registered experiments along with the number of test participants, completed and conversion rate currently in the system.</p>
<input type="text" placeholder="Begin typing to filter" id="filter" />
- <input type="button" id="clear-filter" value="Clear filter" />
+ <input type="button" id="toggle-completed" value="Hide completed" />
+ <input type="button" id="toggle-active" value="Hide active" />
+ <input type="button" id="clear-filter" value="Clear filters" />
<% @experiments.each do |experiment| %>
<% if experiment.goals.empty? %>
| 3 | Merge pull request #364 from ccallebs/master | 1 | .erb | erb | mit | splitrb/split |
10071565 | <NME> index.erb
<BEF> <% if @experiments.any? %>
<p class="intro">The list below contains all the registered experiments along with the number of test participants, completed and conversion rate currently in the system.</p>
<input type="text" placeholder="Begin typing to filter" id="filter" />
<input type="button" id="clear-filter" value="Clear filter" />
<% @experiments.each do |experiment| %>
<% if experiment.goals.empty? %>
<% paginated(@experiments).each do |experiment| %>
<% if experiment.goals.empty? %>
<%= erb :_experiment, :locals => {:goal => nil, :experiment => experiment} %>
<% else %>
<%= erb :_experiment_with_goal_header, :locals => {:experiment => experiment} %>
<% experiment.goals.each do |g| %>
<%= erb :_experiment, :locals => {:goal => g, :experiment => experiment} %>
<% end %>
<% end %>
<% end %>
<div class="pagination">
<%= pagination(@experiments) %>
</div>
<% else %>
<p class="intro">No experiments have started yet, you need to define them in your code and introduce them to your users.</p>
<p class="intro">Check out the <a href='https://github.com/splitrb/split#readme'>Readme</a> for more help getting started.</p>
<% end %>
<div class="dashboard-controls dashboard-controls-bottom">
<form action="<%= url "/initialize_experiment" %>" method='post'>
<label>Add unregistered experiment: </label>
<select name="experiment" id="experiment-select">
<option selected disabled>experiment</option>
<% @unintialized_experiments.sort.each do |experiment_name| %>
<option value="<%= experiment_name %>"><%= experiment_name %></option>
<% end %>
</select>
<input type="submit" id="register-experiment-btn" value="register experiment"/>
</form>
<div>
<MSG> Merge pull request #364 from ccallebs/master
Implement filtering dashboard by active/complete experiments
<DFF> @@ -2,7 +2,9 @@
<p class="intro">The list below contains all the registered experiments along with the number of test participants, completed and conversion rate currently in the system.</p>
<input type="text" placeholder="Begin typing to filter" id="filter" />
- <input type="button" id="clear-filter" value="Clear filter" />
+ <input type="button" id="toggle-completed" value="Hide completed" />
+ <input type="button" id="toggle-active" value="Hide active" />
+ <input type="button" id="clear-filter" value="Clear filters" />
<% @experiments.each do |experiment| %>
<% if experiment.goals.empty? %>
| 3 | Merge pull request #364 from ccallebs/master | 1 | .erb | erb | mit | splitrb/split |
10071566 | <NME> README.md
<BEF> Semantic-UI-Angular
===================
[](https://gitter.im/Semantic-Org/Semantic-UI-Angular?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[](https://travis-ci.org/Semantic-Org/Semantic-UI-Angular)
[](https://david-dm.org/Semantic-Org/Semantic-UI-Angular)
[](https://david-dm.org/Semantic-Org/Semantic-UI-Angular#info=devDependencies)
Status
------
**Work in Progress**
Current progress:
-----------------
**Work in progress**
We are working on setting up proper environment, contribution guidelines and everything else for comfortable community contributions.
Once we release first `alpha.0` we are happy to get community help.
- sm-radio-group and sm-radio-button;
- sm-rating.
TODOs:
-----
- Create generic directives to cover common use cases.
- Create a documentation generation.
- Update project up to Angular 1.4 (ES6/TS - under discussion)
Building Semantic-UI-Angular
----------------------------
You have to have `nodejs` installed before running following commands.
```
npm install
npm run build
```
The distribution packages will be stored in `dist` folder.
Running tests
-------------
Single run:
```
npm test
```
Dev mode:
```
npm run test-dev
```
<MSG> Update README.md
<DFF> @@ -8,8 +8,7 @@ Semantic-UI-Angular
Status
------
-
-**Work in Progress**
+Working to open the first release.
Current progress:
-----------------
@@ -21,9 +20,6 @@ At this moment we have following directives:
- sm-radio-group and sm-radio-button;
- sm-rating.
-TODOs:
------
+## To do:
+All tasks for the release of the first release are the issues. https://github.com/Semantic-Org/Semantic-UI-Angular/issues
- - Create generic directives to cover common use cases.
- - Create a documentation generation.
- - Update project up to Angular 1.4 (ES6/TS - under discussion)
| 3 | Update README.md | 7 | .md | md | mit | Semantic-Org/Semantic-UI-Angular |
10071567 | <NME> README.md
<BEF> Semantic-UI-Angular
===================
[](https://gitter.im/Semantic-Org/Semantic-UI-Angular?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[](https://travis-ci.org/Semantic-Org/Semantic-UI-Angular)
[](https://david-dm.org/Semantic-Org/Semantic-UI-Angular)
[](https://david-dm.org/Semantic-Org/Semantic-UI-Angular#info=devDependencies)
Status
------
**Work in Progress**
Current progress:
-----------------
**Work in progress**
We are working on setting up proper environment, contribution guidelines and everything else for comfortable community contributions.
Once we release first `alpha.0` we are happy to get community help.
- sm-radio-group and sm-radio-button;
- sm-rating.
TODOs:
-----
- Create generic directives to cover common use cases.
- Create a documentation generation.
- Update project up to Angular 1.4 (ES6/TS - under discussion)
Building Semantic-UI-Angular
----------------------------
You have to have `nodejs` installed before running following commands.
```
npm install
npm run build
```
The distribution packages will be stored in `dist` folder.
Running tests
-------------
Single run:
```
npm test
```
Dev mode:
```
npm run test-dev
```
<MSG> Update README.md
<DFF> @@ -8,8 +8,7 @@ Semantic-UI-Angular
Status
------
-
-**Work in Progress**
+Working to open the first release.
Current progress:
-----------------
@@ -21,9 +20,6 @@ At this moment we have following directives:
- sm-radio-group and sm-radio-button;
- sm-rating.
-TODOs:
------
+## To do:
+All tasks for the release of the first release are the issues. https://github.com/Semantic-Org/Semantic-UI-Angular/issues
- - Create generic directives to cover common use cases.
- - Create a documentation generation.
- - Update project up to Angular 1.4 (ES6/TS - under discussion)
| 3 | Update README.md | 7 | .md | md | mit | Semantic-Org/Semantic-UI-Angular |
10071568 | <NME> README.md
<BEF> Semantic-UI-Angular
===================
[](https://gitter.im/Semantic-Org/Semantic-UI-Angular?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[](https://travis-ci.org/Semantic-Org/Semantic-UI-Angular)
[](https://david-dm.org/Semantic-Org/Semantic-UI-Angular)
[](https://david-dm.org/Semantic-Org/Semantic-UI-Angular#info=devDependencies)
Status
------
**Work in Progress**
Current progress:
-----------------
**Work in progress**
We are working on setting up proper environment, contribution guidelines and everything else for comfortable community contributions.
Once we release first `alpha.0` we are happy to get community help.
- sm-radio-group and sm-radio-button;
- sm-rating.
TODOs:
-----
- Create generic directives to cover common use cases.
- Create a documentation generation.
- Update project up to Angular 1.4 (ES6/TS - under discussion)
Building Semantic-UI-Angular
----------------------------
You have to have `nodejs` installed before running following commands.
```
npm install
npm run build
```
The distribution packages will be stored in `dist` folder.
Running tests
-------------
Single run:
```
npm test
```
Dev mode:
```
npm run test-dev
```
<MSG> Update README.md
<DFF> @@ -8,8 +8,7 @@ Semantic-UI-Angular
Status
------
-
-**Work in Progress**
+Working to open the first release.
Current progress:
-----------------
@@ -21,9 +20,6 @@ At this moment we have following directives:
- sm-radio-group and sm-radio-button;
- sm-rating.
-TODOs:
------
+## To do:
+All tasks for the release of the first release are the issues. https://github.com/Semantic-Org/Semantic-UI-Angular/issues
- - Create generic directives to cover common use cases.
- - Create a documentation generation.
- - Update project up to Angular 1.4 (ES6/TS - under discussion)
| 3 | Update README.md | 7 | .md | md | mit | Semantic-Org/Semantic-UI-Angular |
10071569 | <NME> urls.py
<BEF> # -*- coding: utf-8 -*-
from django.conf.urls.defaults import patterns, url, include, handler404, handler500
from django.conf import settings
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('')
# Serve static pages.
if settings.LOCAL_DEVELOPMENT:
urlpatterns += patterns("django.views",
url(r"^%s(?P<path>.*)$" % settings.MEDIA_URL[1:], "static.serve", {
"document_root": settings.MEDIA_ROOT}))
urlpatterns += patterns("",
# Admin interface
url(r'^admin/doc/', include("django.contrib.admindocs.urls")),
url(r'^admin/(.*)', admin.site.root),
url(r'', include("djangopypi.urls"))
)
<MSG> Added registration through django-registration
<DFF> @@ -18,6 +18,9 @@ urlpatterns += patterns("",
url(r'^admin/doc/', include("django.contrib.admindocs.urls")),
url(r'^admin/(.*)', admin.site.root),
+ # Registration
+ url(r'^accounts/', include('registration.backends.default.urls')),
+
+ # The Chishop
url(r'', include("djangopypi.urls"))
)
-
| 4 | Added registration through django-registration | 1 | .py | py | bsd-3-clause | ask/chishop |
10071570 | <NME> ppadd.py
<BEF> """
Management command for adding a package to the repository. Supposed to be the
equivelant of calling easy_install, but the install target is the chishop.
"""
from __future__ import with_statement
import os
import tempfile
import shutil
import urllib
import pkginfo
from django.core.files.base import File
from django.core.management.base import LabelCommand
from optparse import make_option
from contextlib import contextmanager
from urlparse import urlsplit
from setuptools.package_index import PackageIndex
from django.contrib.auth.models import User
from djangopypi.models import Project, Release, Classifier
@contextmanager
def tempdir():
"""Simple context that provides a temporary directory that is deleted
when the context is exited."""
d = tempfile.mkdtemp(".tmp", "djangopypi.")
yield d
shutil.rmtree(d)
class Command(LabelCommand):
option_list = LabelCommand.option_list + (
make_option("-o", "--owner", help="add packages as OWNER",
metavar="OWNER", default=None),
)
help = """Add one or more packages to the repository. Each argument can
be a package name or a URL to an archive or egg. Package names honour
the same rules as easy_install with regard to indicating versions etc.
If a version of the package exists, but is older than what we want to install,
the owner remains the same.
For new packages there needs to be an owner. If the --owner option is present
we use that value. If not, we try to match the maintainer of the package, form
the metadata, with a user in out database, based on the If it's a new package
and the maintainer emailmatches someone in our user list, we use that. If not,
the package can not be
added"""
def __init__(self, *args, **kwargs):
self.pypi = PackageIndex()
LabelCommand.__init__(self, *args, **kwargs)
def handle_label(self, label, **options):
with tempdir() as tmp:
path = self.pypi.download(label, tmp)
if path:
self._save_package(path, options["owner"])
else:
print "Could not add %s. Not found." % label
def _save_package(self, path, ownerid):
meta = self._get_meta(path)
try:
# can't use get_or_create as that demands there be an owner
project = Project.objects.get(name=meta.name)
isnewproject = False
except Project.DoesNotExist:
project = Project(name=meta.name)
isnewproject = True
release = project.get_release(meta.version)
if not isnewproject and release and release.version == meta.version:
print "%s-%s already added" % (meta.name, meta.version)
return
# algorithm as follows: If owner is given, try to grab user with that
# username from db. If doesn't exist, bail. If no owner set look at
# mail address from metadata and try to get that user. If it exists
# use it. If not, bail.
owner = None
if ownerid:
try:
if "@" in ownerid:
owner = User.objects.get(email=ownerid)
else:
owner = User.objects.get(username=ownerid)
except User.DoesNotExist:
pass
else:
try:
owner = User.objects.get(email=meta.author_email)
except User.DoesNotExist:
pass
if not owner:
print "No owner defined. Use --owner to force one"
return
# at this point we have metadata and an owner, can safely add it.
project.owner = owner
# Some packages don't have proper licence, seems to be a problem
# with setup.py upload. Use "UNKNOWN"
project.license = meta.license or "Unknown"
project.metadata_version = meta.metadata_version
project.author = meta.author
project.home_page = meta.home_page
project.download_url = meta.download_url
project.summary = meta.summary
project.description = meta.description
project.author_email = meta.author_email
project.save()
for classifier in meta.classifiers:
project.classifiers.add(
Classifier.objects.get_or_create(name=classifier)[0])
release = Release()
release.version = meta.version
release.project = project
filename = os.path.basename(path)
file = File(open(path, "rb"))
release.distribution.save(filename, file)
release.save()
print "%s-%s added" % (meta.name, meta.version)
def _get_meta(self, path):
if path.endswith((".zip", ".tar.gz")):
return pkginfo.SDist(path)
elif path.endswith(".egg"):
return pkginfo.BDist(path)
else:
print "Couldn't get metadata from %s. Not added to chishop" % os.path.basename(path)
return None
<MSG> Fixed ppadd command. Was broken due to change in pkginfo module
<DFF> @@ -134,10 +134,9 @@ added"""
print "%s-%s added" % (meta.name, meta.version)
def _get_meta(self, path):
- if path.endswith((".zip", ".tar.gz")):
- return pkginfo.SDist(path)
- elif path.endswith(".egg"):
- return pkginfo.BDist(path)
+ data = pkginfo.get_metadata(path)
+ if data:
+ return data
else:
print "Couldn't get metadata from %s. Not added to chishop" % os.path.basename(path)
return None
| 3 | Fixed ppadd command. Was broken due to change in pkginfo module | 4 | .py | py | bsd-3-clause | ask/chishop |
10071571 | <NME> version.rb
<BEF> module Split
VERSION = "0.2.2"
end
VERSION = "4.0.1"
end
<MSG> Version 0.2.3
<DFF> @@ -1,3 +1,3 @@
module Split
- VERSION = "0.2.2"
+ VERSION = "0.2.3"
end
| 1 | Version 0.2.3 | 1 | .rb | rb | mit | splitrb/split |
10071572 | <NME> version.rb
<BEF> module Split
VERSION = "0.2.2"
end
VERSION = "4.0.1"
end
<MSG> Version 0.2.3
<DFF> @@ -1,3 +1,3 @@
module Split
- VERSION = "0.2.2"
+ VERSION = "0.2.3"
end
| 1 | Version 0.2.3 | 1 | .rb | rb | mit | splitrb/split |
10071573 | <NME> version.rb
<BEF> module Split
VERSION = "0.2.2"
end
VERSION = "4.0.1"
end
<MSG> Version 0.2.3
<DFF> @@ -1,3 +1,3 @@
module Split
- VERSION = "0.2.2"
+ VERSION = "0.2.3"
end
| 1 | Version 0.2.3 | 1 | .rb | rb | mit | splitrb/split |
10071574 | <NME> split.rb
<BEF> # frozen_string_literal: true
require "split/#{f}"
end
require 'split/engine' if defined?(Rails)
require 'redis/namespace'
module Split
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
attr_accessor :configuration
# Accepts:
# 1. A redis URL (valid for `Redis.new(url: url)`)
# 2. an options hash compatible with `Redis.new`
# 3. or a valid Redis instance (one that responds to `#smembers`). Likely,
# this will be an instance of either `Redis`, `Redis::Client`,
# `Redis::DistRedis`, or `Redis::Namespace`.
def redis=(server)
@redis = if server.is_a?(String)
Redis.new(url: server)
elsif server.is_a?(Hash)
Redis.new(server)
elsif server.respond_to?(:smembers)
server
else
raise ArgumentError,
"You must supply a url, options hash or valid Redis connection instance"
end
end
# Returns the current Redis connection. If none has been created, will
# create a new one.
def redis
return @redis if @redis
self.redis = self.configuration.redis
self.redis
end
# Call this method to modify defaults in your initializers.
#
# @example
# Split.configure do |config|
# config.ignore_ip_addresses = '192.168.2.1'
# end
def configure
self.configuration ||= Configuration.new
yield(configuration)
end
def cache(namespace, key, &block)
Split::Cache.fetch(namespace, key, &block)
end
end
# Check to see if being run in a Rails application. If so, wait until before_initialize to run configuration so Gems that create ENV variables have the chance to initialize first.
if defined?(::Rails)
class Split::Railtie < Rails::Railtie
config.before_initialize { Split.configure { } }
end
else
Split.configure { }
end
<MSG> Merge pull request #167 from Scoutmob/rails2.3-compatibility
Rails 2.3 compatibility
<DFF> @@ -2,7 +2,7 @@
require "split/#{f}"
end
-require 'split/engine' if defined?(Rails)
+require 'split/engine' if defined?(Rails) && Rails::VERSION::MAJOR >= 3
require 'redis/namespace'
module Split
| 1 | Merge pull request #167 from Scoutmob/rails2.3-compatibility | 1 | .rb | rb | mit | splitrb/split |
10071575 | <NME> split.rb
<BEF> # frozen_string_literal: true
require "split/#{f}"
end
require 'split/engine' if defined?(Rails)
require 'redis/namespace'
module Split
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
attr_accessor :configuration
# Accepts:
# 1. A redis URL (valid for `Redis.new(url: url)`)
# 2. an options hash compatible with `Redis.new`
# 3. or a valid Redis instance (one that responds to `#smembers`). Likely,
# this will be an instance of either `Redis`, `Redis::Client`,
# `Redis::DistRedis`, or `Redis::Namespace`.
def redis=(server)
@redis = if server.is_a?(String)
Redis.new(url: server)
elsif server.is_a?(Hash)
Redis.new(server)
elsif server.respond_to?(:smembers)
server
else
raise ArgumentError,
"You must supply a url, options hash or valid Redis connection instance"
end
end
# Returns the current Redis connection. If none has been created, will
# create a new one.
def redis
return @redis if @redis
self.redis = self.configuration.redis
self.redis
end
# Call this method to modify defaults in your initializers.
#
# @example
# Split.configure do |config|
# config.ignore_ip_addresses = '192.168.2.1'
# end
def configure
self.configuration ||= Configuration.new
yield(configuration)
end
def cache(namespace, key, &block)
Split::Cache.fetch(namespace, key, &block)
end
end
# Check to see if being run in a Rails application. If so, wait until before_initialize to run configuration so Gems that create ENV variables have the chance to initialize first.
if defined?(::Rails)
class Split::Railtie < Rails::Railtie
config.before_initialize { Split.configure { } }
end
else
Split.configure { }
end
<MSG> Merge pull request #167 from Scoutmob/rails2.3-compatibility
Rails 2.3 compatibility
<DFF> @@ -2,7 +2,7 @@
require "split/#{f}"
end
-require 'split/engine' if defined?(Rails)
+require 'split/engine' if defined?(Rails) && Rails::VERSION::MAJOR >= 3
require 'redis/namespace'
module Split
| 1 | Merge pull request #167 from Scoutmob/rails2.3-compatibility | 1 | .rb | rb | mit | splitrb/split |
10071576 | <NME> split.rb
<BEF> # frozen_string_literal: true
require "split/#{f}"
end
require 'split/engine' if defined?(Rails)
require 'redis/namespace'
module Split
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
attr_accessor :configuration
# Accepts:
# 1. A redis URL (valid for `Redis.new(url: url)`)
# 2. an options hash compatible with `Redis.new`
# 3. or a valid Redis instance (one that responds to `#smembers`). Likely,
# this will be an instance of either `Redis`, `Redis::Client`,
# `Redis::DistRedis`, or `Redis::Namespace`.
def redis=(server)
@redis = if server.is_a?(String)
Redis.new(url: server)
elsif server.is_a?(Hash)
Redis.new(server)
elsif server.respond_to?(:smembers)
server
else
raise ArgumentError,
"You must supply a url, options hash or valid Redis connection instance"
end
end
# Returns the current Redis connection. If none has been created, will
# create a new one.
def redis
return @redis if @redis
self.redis = self.configuration.redis
self.redis
end
# Call this method to modify defaults in your initializers.
#
# @example
# Split.configure do |config|
# config.ignore_ip_addresses = '192.168.2.1'
# end
def configure
self.configuration ||= Configuration.new
yield(configuration)
end
def cache(namespace, key, &block)
Split::Cache.fetch(namespace, key, &block)
end
end
# Check to see if being run in a Rails application. If so, wait until before_initialize to run configuration so Gems that create ENV variables have the chance to initialize first.
if defined?(::Rails)
class Split::Railtie < Rails::Railtie
config.before_initialize { Split.configure { } }
end
else
Split.configure { }
end
<MSG> Merge pull request #167 from Scoutmob/rails2.3-compatibility
Rails 2.3 compatibility
<DFF> @@ -2,7 +2,7 @@
require "split/#{f}"
end
-require 'split/engine' if defined?(Rails)
+require 'split/engine' if defined?(Rails) && Rails::VERSION::MAJOR >= 3
require 'redis/namespace'
module Split
| 1 | Merge pull request #167 from Scoutmob/rails2.3-compatibility | 1 | .rb | rb | mit | splitrb/split |
10071577 | <NME> spec_helper.rb
<BEF> # frozen_string_literal: true
ENV["RACK_ENV"] = "test"
require "rubygems"
require "bundler/setup"
require "simplecov"
SimpleCov.start
require "split"
require "ostruct"
require "yaml"
Dir["./spec/support/*.rb"].each { |f| require f }
module GlobalSharedContext
extend RSpec::SharedContext
let(:mock_user) { Split::User.new(double(session: {})) }
before(:each) do
Split.redis = Redis.new
Split.redis.select(10)
Split.redis.flushdb
@ab_user = mock_user
params = nil
end
end
end
RSpec.configure do |config|
config.order = "random"
config.include GlobalSharedContext
config.raise_errors_for_deprecations!
end
def session
@session ||= {}
end
def params
@params ||= {}
end
def request(ua = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; de-de) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27")
@request ||= begin
r = OpenStruct.new
r.user_agent = ua
r.ip = "192.168.1.1"
r
end
end
<MSG> Added in-memory cache for `ExperimentCatalog#find`
<DFF> @@ -22,6 +22,7 @@ module GlobalSharedContext
Split.redis = Redis.new
Split.redis.select(10)
Split.redis.flushdb
+ Split::ExperimentCatalog.clear_cache
@ab_user = mock_user
params = nil
end
| 1 | Added in-memory cache for `ExperimentCatalog#find` | 0 | .rb | rb | mit | splitrb/split |
10071578 | <NME> spec_helper.rb
<BEF> # frozen_string_literal: true
ENV["RACK_ENV"] = "test"
require "rubygems"
require "bundler/setup"
require "simplecov"
SimpleCov.start
require "split"
require "ostruct"
require "yaml"
Dir["./spec/support/*.rb"].each { |f| require f }
module GlobalSharedContext
extend RSpec::SharedContext
let(:mock_user) { Split::User.new(double(session: {})) }
before(:each) do
Split.redis = Redis.new
Split.redis.select(10)
Split.redis.flushdb
@ab_user = mock_user
params = nil
end
end
end
RSpec.configure do |config|
config.order = "random"
config.include GlobalSharedContext
config.raise_errors_for_deprecations!
end
def session
@session ||= {}
end
def params
@params ||= {}
end
def request(ua = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; de-de) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27")
@request ||= begin
r = OpenStruct.new
r.user_agent = ua
r.ip = "192.168.1.1"
r
end
end
<MSG> Added in-memory cache for `ExperimentCatalog#find`
<DFF> @@ -22,6 +22,7 @@ module GlobalSharedContext
Split.redis = Redis.new
Split.redis.select(10)
Split.redis.flushdb
+ Split::ExperimentCatalog.clear_cache
@ab_user = mock_user
params = nil
end
| 1 | Added in-memory cache for `ExperimentCatalog#find` | 0 | .rb | rb | mit | splitrb/split |
10071579 | <NME> spec_helper.rb
<BEF> # frozen_string_literal: true
ENV["RACK_ENV"] = "test"
require "rubygems"
require "bundler/setup"
require "simplecov"
SimpleCov.start
require "split"
require "ostruct"
require "yaml"
Dir["./spec/support/*.rb"].each { |f| require f }
module GlobalSharedContext
extend RSpec::SharedContext
let(:mock_user) { Split::User.new(double(session: {})) }
before(:each) do
Split.redis = Redis.new
Split.redis.select(10)
Split.redis.flushdb
@ab_user = mock_user
params = nil
end
end
end
RSpec.configure do |config|
config.order = "random"
config.include GlobalSharedContext
config.raise_errors_for_deprecations!
end
def session
@session ||= {}
end
def params
@params ||= {}
end
def request(ua = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; de-de) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27")
@request ||= begin
r = OpenStruct.new
r.user_agent = ua
r.ip = "192.168.1.1"
r
end
end
<MSG> Added in-memory cache for `ExperimentCatalog#find`
<DFF> @@ -22,6 +22,7 @@ module GlobalSharedContext
Split.redis = Redis.new
Split.redis.select(10)
Split.redis.flushdb
+ Split::ExperimentCatalog.clear_cache
@ab_user = mock_user
params = nil
end
| 1 | Added in-memory cache for `ExperimentCatalog#find` | 0 | .rb | rb | mit | splitrb/split |
10071580 | <NME> split.rb
<BEF> # frozen_string_literal: true
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/#{f}"
end
require 'redis/namespace'
module Split
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
attr_accessor :configuration
# Accepts:
# 1. A redis URL (valid for `Redis.new(url: url)`)
# 2. an options hash compatible with `Redis.new`
# 3. or a valid Redis instance (one that responds to `#smembers`). Likely,
# this will be an instance of either `Redis`, `Redis::Client`,
# `Redis::DistRedis`, or `Redis::Namespace`.
def redis=(server)
@redis = if server.is_a?(String)
Redis.new(url: server)
elsif server.is_a?(Hash)
Redis.new(server)
elsif server.respond_to?(:smembers)
server
else
raise ArgumentError,
"You must supply a url, options hash or valid Redis connection instance"
end
end
# Returns the current Redis connection. If none has been created, will
# create a new one.
def redis
return @redis if @redis
self.redis = self.configuration.redis
self.redis
end
# Call this method to modify defaults in your initializers.
#
# @example
# Split.configure do |config|
# config.ignore_ip_addresses = '192.168.2.1'
# end
def configure
self.configuration ||= Configuration.new
yield(configuration)
end
def cache(namespace, key, &block)
Split::Cache.fetch(namespace, key, &block)
end
end
# Check to see if being run in a Rails application. If so, wait until before_initialize to run configuration so Gems that create ENV variables have the chance to initialize first.
if defined?(::Rails)
class Split::Railtie < Rails::Railtie
config.before_initialize { Split.configure { } }
end
else
Split.configure { }
end
<MSG> Require engine if Rails is defined
<DFF> @@ -15,6 +15,7 @@
require "split/#{f}"
end
+require 'split/engine' if defined?(Rails)
require 'redis/namespace'
module Split
| 1 | Require engine if Rails is defined | 0 | .rb | rb | mit | splitrb/split |
10071581 | <NME> split.rb
<BEF> # frozen_string_literal: true
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/#{f}"
end
require 'redis/namespace'
module Split
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
attr_accessor :configuration
# Accepts:
# 1. A redis URL (valid for `Redis.new(url: url)`)
# 2. an options hash compatible with `Redis.new`
# 3. or a valid Redis instance (one that responds to `#smembers`). Likely,
# this will be an instance of either `Redis`, `Redis::Client`,
# `Redis::DistRedis`, or `Redis::Namespace`.
def redis=(server)
@redis = if server.is_a?(String)
Redis.new(url: server)
elsif server.is_a?(Hash)
Redis.new(server)
elsif server.respond_to?(:smembers)
server
else
raise ArgumentError,
"You must supply a url, options hash or valid Redis connection instance"
end
end
# Returns the current Redis connection. If none has been created, will
# create a new one.
def redis
return @redis if @redis
self.redis = self.configuration.redis
self.redis
end
# Call this method to modify defaults in your initializers.
#
# @example
# Split.configure do |config|
# config.ignore_ip_addresses = '192.168.2.1'
# end
def configure
self.configuration ||= Configuration.new
yield(configuration)
end
def cache(namespace, key, &block)
Split::Cache.fetch(namespace, key, &block)
end
end
# Check to see if being run in a Rails application. If so, wait until before_initialize to run configuration so Gems that create ENV variables have the chance to initialize first.
if defined?(::Rails)
class Split::Railtie < Rails::Railtie
config.before_initialize { Split.configure { } }
end
else
Split.configure { }
end
<MSG> Require engine if Rails is defined
<DFF> @@ -15,6 +15,7 @@
require "split/#{f}"
end
+require 'split/engine' if defined?(Rails)
require 'redis/namespace'
module Split
| 1 | Require engine if Rails is defined | 0 | .rb | rb | mit | splitrb/split |
10071582 | <NME> split.rb
<BEF> # frozen_string_literal: true
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/#{f}"
end
require 'redis/namespace'
module Split
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
attr_accessor :configuration
# Accepts:
# 1. A redis URL (valid for `Redis.new(url: url)`)
# 2. an options hash compatible with `Redis.new`
# 3. or a valid Redis instance (one that responds to `#smembers`). Likely,
# this will be an instance of either `Redis`, `Redis::Client`,
# `Redis::DistRedis`, or `Redis::Namespace`.
def redis=(server)
@redis = if server.is_a?(String)
Redis.new(url: server)
elsif server.is_a?(Hash)
Redis.new(server)
elsif server.respond_to?(:smembers)
server
else
raise ArgumentError,
"You must supply a url, options hash or valid Redis connection instance"
end
end
# Returns the current Redis connection. If none has been created, will
# create a new one.
def redis
return @redis if @redis
self.redis = self.configuration.redis
self.redis
end
# Call this method to modify defaults in your initializers.
#
# @example
# Split.configure do |config|
# config.ignore_ip_addresses = '192.168.2.1'
# end
def configure
self.configuration ||= Configuration.new
yield(configuration)
end
def cache(namespace, key, &block)
Split::Cache.fetch(namespace, key, &block)
end
end
# Check to see if being run in a Rails application. If so, wait until before_initialize to run configuration so Gems that create ENV variables have the chance to initialize first.
if defined?(::Rails)
class Split::Railtie < Rails::Railtie
config.before_initialize { Split.configure { } }
end
else
Split.configure { }
end
<MSG> Require engine if Rails is defined
<DFF> @@ -15,6 +15,7 @@
require "split/#{f}"
end
+require 'split/engine' if defined?(Rails)
require 'redis/namespace'
module Split
| 1 | Require engine if Rails is defined | 0 | .rb | rb | mit | splitrb/split |
10071583 | <NME> extract-abbreviation.ts
<BEF> import { deepStrictEqual, strictEqual, ok } from 'assert';
import extractAbbreviation, { ExtractOptions, ExtractedAbbreviation } from '../src/extract-abbreviation';
import isAtHTMLTag from '../src/extract-abbreviation/is-html';
import scanner from '../src/extract-abbreviation/reader';
import { consumeQuoted } from '../src/extract-abbreviation/quotes';
function extract(abbr: string, options?: Partial<ExtractOptions>) {
let caretPos: number | undefined = abbr.indexOf('|');
if (caretPos !== -1) {
abbr = abbr.slice(0, caretPos) + abbr.slice(caretPos + 1);
} else {
caretPos = void 0;
}
return extractAbbreviation(abbr, caretPos, options);
}
function result(abbreviation: string, location: number, start = location): ExtractedAbbreviation {
return {
abbreviation,
location,
start: start != null ? start : location,
end: location + abbreviation.length
};
}
describe('Extract abbreviation', () => {
it('basic', () => {
deepStrictEqual(extract('.bar'), result('.bar', 0));
deepStrictEqual(extract('.foo .bar'), result('.bar', 5));
deepStrictEqual(extract('.foo @bar'), result('@bar', 5));
deepStrictEqual(extract('.foo img/'), result('img/', 5));
deepStrictEqual(extract('ัะตะบััdiv'), result('div', 5));
deepStrictEqual(extract('foo div[foo="ัะตะบัั" bar=ัะตะบัั2]'), result('div[foo="ัะตะบัั" bar=ัะตะบัั2]', 4));
// https://github.com/emmetio/emmet/issues/577
deepStrictEqual(
extract('table>(tr.prefix-intro>td*1)+(tr.prefix-pro-con>th*1+td*3)+(tr.prefix-key-specs>th[colspan=2]*1+td[colspan=2]*3)+(tr.prefix-key-find-online>th[colspan=2]*1+td*2)'),
result('table>(tr.prefix-intro>td*1)+(tr.prefix-pro-con>th*1+td*3)+(tr.prefix-key-specs>th[colspan=2]*1+td[colspan=2]*3)+(tr.prefix-key-find-online>th[colspan=2]*1+td*2)', 0));
});
it('abbreviation with operators', () => {
deepStrictEqual(extract('a foo+bar.baz'), result('foo+bar.baz', 2));
deepStrictEqual(extract('a foo>bar+baz*3'), result('foo>bar+baz*3', 2));
});
it('abbreviation with attributes', () => {
deepStrictEqual(extract('a foo[bar|]'), result('foo[bar]', 2));
deepStrictEqual(extract('a foo[bar="baz" a b]'), result('foo[bar="baz" a b]', 2));
deepStrictEqual(extract('foo bar[a|] baz'), result('bar[a]', 4));
});
it('tag test', () => {
deepStrictEqual(extract('<foo>bar[a b="c"]>baz'), result('bar[a b="c"]>baz', 5));
deepStrictEqual(extract('foo>bar'), result('foo>bar', 0));
deepStrictEqual(extract('<foo>bar'), result('bar', 5));
deepStrictEqual(extract('<foo>bar[a="d" b="c"]>baz'), result('bar[a="d" b="c"]>baz', 5));
});
it('stylesheet abbreviation', () => {
deepStrictEqual(extract('foo{bar|}'), result('foo{bar}', 0));
deepStrictEqual(extract('foo{bar|}', { type: 'stylesheet' }), result('bar', 4));
});
it('prefixed extract', () => {
deepStrictEqual(extract('<foo>bar[a b="c"]>baz'), result('bar[a b="c"]>baz', 5));
deepStrictEqual(extract('<foo>bar[a b="c"]>baz', { prefix: '<' }), result('foo>bar[a b="c"]>baz', 1, 0));
deepStrictEqual(extract('<foo>bar[a b="<"]>baz', { prefix: '<' }), result('foo>bar[a b="<"]>baz', 1, 0));
deepStrictEqual(extract('<foo>bar{<}>baz', { prefix: '<' }), result('foo>bar{<}>baz', 1, 0));
strictEqual(extract('<foo>bar[a b="c"]>baz', { prefix: '&&' }), void 0);
});
it('HTML test', () => {
const html = (str: string) => isAtHTMLTag(scanner(str));
});
it('HTML test', () => {
const html = (str: string) => isAtHTMLTag(scanner(str));
// simple tag
ok(html('<div>'));
ok(html('<div/>'));
ok(html('<div />'));
ok(html('</div>'));
// tag with attributes
ok(html('<div foo="bar">'));
ok(html('<div foo=bar>'));
ok(html('<div foo>'));
ok(html('<div a="b" c=d>'));
ok(html('<div a=b c=d>'));
ok(html('<div a=^b$ c=d>'));
ok(html('<div a=b c=^%d]$>'));
ok(html('<div title=ะฟัะธะฒะตั>'));
ok(html('<div title=ะฟัะธะฒะตั123>'));
ok(html('<foo-bar>'));
// invalid tags
ok(!html('div>'));
ok(!html('<div'));
ok(!html('<div ะฟัะธะฒะตั>'));
ok(!html('<div =bar>'));
ok(!html('<div foo=>'));
ok(!html('[a=b c=d]>'));
ok(!html('div[a=b c=d]>'));
});
it('consume quotes', () => {
let s = scanner(' "foo"');
ok(consumeQuoted(s));
strictEqual(s.pos, 1);
s = scanner('"foo"');
ok(consumeQuoted(s));
strictEqual(s.pos, 0);
s = scanner('""');
ok(consumeQuoted(s));
strictEqual(s.pos, 0);
s = scanner('"a\\\"b"');
ok(consumeQuoted(s));
strictEqual(s.pos, 0);
// donโt eat anything
s = scanner('foo');
ok(!consumeQuoted(s));
strictEqual(s.pos, 3);
});
});
<MSG> Fix issue #570 (#571)
* Fix issue #570
* Fix formatting
<DFF> @@ -70,6 +70,12 @@ describe('Extract abbreviation', () => {
strictEqual(extract('<foo>bar[a b="c"]>baz', { prefix: '&&' }), void 0);
});
+ it('brackets inside curly braces', () => {
+ deepStrictEqual(extract('foo div{[}+a{}'), result('div{[}+a{}', 4));
+ deepStrictEqual(extract('div{}}'), undefined);
+ deepStrictEqual(extract('div{{}'), result('{}', 4));
+ })
+
it('HTML test', () => {
const html = (str: string) => isAtHTMLTag(scanner(str));
| 6 | Fix issue #570 (#571) | 0 | .ts | ts | mit | emmetio/emmet |
10071584 | <NME> extract-abbreviation.ts
<BEF> import { deepStrictEqual, strictEqual, ok } from 'assert';
import extractAbbreviation, { ExtractOptions, ExtractedAbbreviation } from '../src/extract-abbreviation';
import isAtHTMLTag from '../src/extract-abbreviation/is-html';
import scanner from '../src/extract-abbreviation/reader';
import { consumeQuoted } from '../src/extract-abbreviation/quotes';
function extract(abbr: string, options?: Partial<ExtractOptions>) {
let caretPos: number | undefined = abbr.indexOf('|');
if (caretPos !== -1) {
abbr = abbr.slice(0, caretPos) + abbr.slice(caretPos + 1);
} else {
caretPos = void 0;
}
return extractAbbreviation(abbr, caretPos, options);
}
function result(abbreviation: string, location: number, start = location): ExtractedAbbreviation {
return {
abbreviation,
location,
start: start != null ? start : location,
end: location + abbreviation.length
};
}
describe('Extract abbreviation', () => {
it('basic', () => {
deepStrictEqual(extract('.bar'), result('.bar', 0));
deepStrictEqual(extract('.foo .bar'), result('.bar', 5));
deepStrictEqual(extract('.foo @bar'), result('@bar', 5));
deepStrictEqual(extract('.foo img/'), result('img/', 5));
deepStrictEqual(extract('ัะตะบััdiv'), result('div', 5));
deepStrictEqual(extract('foo div[foo="ัะตะบัั" bar=ัะตะบัั2]'), result('div[foo="ัะตะบัั" bar=ัะตะบัั2]', 4));
// https://github.com/emmetio/emmet/issues/577
deepStrictEqual(
extract('table>(tr.prefix-intro>td*1)+(tr.prefix-pro-con>th*1+td*3)+(tr.prefix-key-specs>th[colspan=2]*1+td[colspan=2]*3)+(tr.prefix-key-find-online>th[colspan=2]*1+td*2)'),
result('table>(tr.prefix-intro>td*1)+(tr.prefix-pro-con>th*1+td*3)+(tr.prefix-key-specs>th[colspan=2]*1+td[colspan=2]*3)+(tr.prefix-key-find-online>th[colspan=2]*1+td*2)', 0));
});
it('abbreviation with operators', () => {
deepStrictEqual(extract('a foo+bar.baz'), result('foo+bar.baz', 2));
deepStrictEqual(extract('a foo>bar+baz*3'), result('foo>bar+baz*3', 2));
});
it('abbreviation with attributes', () => {
deepStrictEqual(extract('a foo[bar|]'), result('foo[bar]', 2));
deepStrictEqual(extract('a foo[bar="baz" a b]'), result('foo[bar="baz" a b]', 2));
deepStrictEqual(extract('foo bar[a|] baz'), result('bar[a]', 4));
});
it('tag test', () => {
deepStrictEqual(extract('<foo>bar[a b="c"]>baz'), result('bar[a b="c"]>baz', 5));
deepStrictEqual(extract('foo>bar'), result('foo>bar', 0));
deepStrictEqual(extract('<foo>bar'), result('bar', 5));
deepStrictEqual(extract('<foo>bar[a="d" b="c"]>baz'), result('bar[a="d" b="c"]>baz', 5));
});
it('stylesheet abbreviation', () => {
deepStrictEqual(extract('foo{bar|}'), result('foo{bar}', 0));
deepStrictEqual(extract('foo{bar|}', { type: 'stylesheet' }), result('bar', 4));
});
it('prefixed extract', () => {
deepStrictEqual(extract('<foo>bar[a b="c"]>baz'), result('bar[a b="c"]>baz', 5));
deepStrictEqual(extract('<foo>bar[a b="c"]>baz', { prefix: '<' }), result('foo>bar[a b="c"]>baz', 1, 0));
deepStrictEqual(extract('<foo>bar[a b="<"]>baz', { prefix: '<' }), result('foo>bar[a b="<"]>baz', 1, 0));
deepStrictEqual(extract('<foo>bar{<}>baz', { prefix: '<' }), result('foo>bar{<}>baz', 1, 0));
strictEqual(extract('<foo>bar[a b="c"]>baz', { prefix: '&&' }), void 0);
});
it('HTML test', () => {
const html = (str: string) => isAtHTMLTag(scanner(str));
});
it('HTML test', () => {
const html = (str: string) => isAtHTMLTag(scanner(str));
// simple tag
ok(html('<div>'));
ok(html('<div/>'));
ok(html('<div />'));
ok(html('</div>'));
// tag with attributes
ok(html('<div foo="bar">'));
ok(html('<div foo=bar>'));
ok(html('<div foo>'));
ok(html('<div a="b" c=d>'));
ok(html('<div a=b c=d>'));
ok(html('<div a=^b$ c=d>'));
ok(html('<div a=b c=^%d]$>'));
ok(html('<div title=ะฟัะธะฒะตั>'));
ok(html('<div title=ะฟัะธะฒะตั123>'));
ok(html('<foo-bar>'));
// invalid tags
ok(!html('div>'));
ok(!html('<div'));
ok(!html('<div ะฟัะธะฒะตั>'));
ok(!html('<div =bar>'));
ok(!html('<div foo=>'));
ok(!html('[a=b c=d]>'));
ok(!html('div[a=b c=d]>'));
});
it('consume quotes', () => {
let s = scanner(' "foo"');
ok(consumeQuoted(s));
strictEqual(s.pos, 1);
s = scanner('"foo"');
ok(consumeQuoted(s));
strictEqual(s.pos, 0);
s = scanner('""');
ok(consumeQuoted(s));
strictEqual(s.pos, 0);
s = scanner('"a\\\"b"');
ok(consumeQuoted(s));
strictEqual(s.pos, 0);
// donโt eat anything
s = scanner('foo');
ok(!consumeQuoted(s));
strictEqual(s.pos, 3);
});
});
<MSG> Fix issue #570 (#571)
* Fix issue #570
* Fix formatting
<DFF> @@ -70,6 +70,12 @@ describe('Extract abbreviation', () => {
strictEqual(extract('<foo>bar[a b="c"]>baz', { prefix: '&&' }), void 0);
});
+ it('brackets inside curly braces', () => {
+ deepStrictEqual(extract('foo div{[}+a{}'), result('div{[}+a{}', 4));
+ deepStrictEqual(extract('div{}}'), undefined);
+ deepStrictEqual(extract('div{{}'), result('{}', 4));
+ })
+
it('HTML test', () => {
const html = (str: string) => isAtHTMLTag(scanner(str));
| 6 | Fix issue #570 (#571) | 0 | .ts | ts | mit | emmetio/emmet |
10071585 | <NME> split.rb
<BEF> # frozen_string_literal: true
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/#{f}"
end
require 'split/engine' if defined?(Rails) && Rails::VERSION::MAJOR >= 3
require 'redis/namespace'
module Split
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
attr_accessor :configuration
# Accepts:
# 1. A redis URL (valid for `Redis.new(url: url)`)
# 2. an options hash compatible with `Redis.new`
# 3. or a valid Redis instance (one that responds to `#smembers`). Likely,
# this will be an instance of either `Redis`, `Redis::Client`,
# `Redis::DistRedis`, or `Redis::Namespace`.
def redis=(server)
@redis = if server.is_a?(String)
Redis.new(url: server)
elsif server.is_a?(Hash)
Redis.new(server)
elsif server.respond_to?(:smembers)
server
else
raise ArgumentError,
"You must supply a url, options hash or valid Redis connection instance"
end
end
# Returns the current Redis connection. If none has been created, will
# create a new one.
def redis
return @redis if @redis
self.redis = self.configuration.redis
self.redis
end
# Call this method to modify defaults in your initializers.
#
# @example
# Split.configure do |config|
# config.ignore_ip_addresses = '192.168.2.1'
# end
def configure
self.configuration ||= Configuration.new
yield(configuration)
end
def cache(namespace, key, &block)
Split::Cache.fetch(namespace, key, &block)
end
end
# Check to see if being run in a Rails application. If so, wait until before_initialize to run configuration so Gems that create ENV variables have the chance to initialize first.
if defined?(::Rails)
class Split::Railtie < Rails::Railtie
config.before_initialize { Split.configure { } }
end
else
Split.configure { }
end
<MSG> Remove check for Rails > 3
<DFF> @@ -15,7 +15,6 @@
require "split/#{f}"
end
-require 'split/engine' if defined?(Rails) && Rails::VERSION::MAJOR >= 3
require 'redis/namespace'
module Split
| 0 | Remove check for Rails > 3 | 1 | .rb | rb | mit | splitrb/split |
10071586 | <NME> split.rb
<BEF> # frozen_string_literal: true
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/#{f}"
end
require 'split/engine' if defined?(Rails) && Rails::VERSION::MAJOR >= 3
require 'redis/namespace'
module Split
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
attr_accessor :configuration
# Accepts:
# 1. A redis URL (valid for `Redis.new(url: url)`)
# 2. an options hash compatible with `Redis.new`
# 3. or a valid Redis instance (one that responds to `#smembers`). Likely,
# this will be an instance of either `Redis`, `Redis::Client`,
# `Redis::DistRedis`, or `Redis::Namespace`.
def redis=(server)
@redis = if server.is_a?(String)
Redis.new(url: server)
elsif server.is_a?(Hash)
Redis.new(server)
elsif server.respond_to?(:smembers)
server
else
raise ArgumentError,
"You must supply a url, options hash or valid Redis connection instance"
end
end
# Returns the current Redis connection. If none has been created, will
# create a new one.
def redis
return @redis if @redis
self.redis = self.configuration.redis
self.redis
end
# Call this method to modify defaults in your initializers.
#
# @example
# Split.configure do |config|
# config.ignore_ip_addresses = '192.168.2.1'
# end
def configure
self.configuration ||= Configuration.new
yield(configuration)
end
def cache(namespace, key, &block)
Split::Cache.fetch(namespace, key, &block)
end
end
# Check to see if being run in a Rails application. If so, wait until before_initialize to run configuration so Gems that create ENV variables have the chance to initialize first.
if defined?(::Rails)
class Split::Railtie < Rails::Railtie
config.before_initialize { Split.configure { } }
end
else
Split.configure { }
end
<MSG> Remove check for Rails > 3
<DFF> @@ -15,7 +15,6 @@
require "split/#{f}"
end
-require 'split/engine' if defined?(Rails) && Rails::VERSION::MAJOR >= 3
require 'redis/namespace'
module Split
| 0 | Remove check for Rails > 3 | 1 | .rb | rb | mit | splitrb/split |
10071587 | <NME> split.rb
<BEF> # frozen_string_literal: true
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/#{f}"
end
require 'split/engine' if defined?(Rails) && Rails::VERSION::MAJOR >= 3
require 'redis/namespace'
module Split
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
attr_accessor :configuration
# Accepts:
# 1. A redis URL (valid for `Redis.new(url: url)`)
# 2. an options hash compatible with `Redis.new`
# 3. or a valid Redis instance (one that responds to `#smembers`). Likely,
# this will be an instance of either `Redis`, `Redis::Client`,
# `Redis::DistRedis`, or `Redis::Namespace`.
def redis=(server)
@redis = if server.is_a?(String)
Redis.new(url: server)
elsif server.is_a?(Hash)
Redis.new(server)
elsif server.respond_to?(:smembers)
server
else
raise ArgumentError,
"You must supply a url, options hash or valid Redis connection instance"
end
end
# Returns the current Redis connection. If none has been created, will
# create a new one.
def redis
return @redis if @redis
self.redis = self.configuration.redis
self.redis
end
# Call this method to modify defaults in your initializers.
#
# @example
# Split.configure do |config|
# config.ignore_ip_addresses = '192.168.2.1'
# end
def configure
self.configuration ||= Configuration.new
yield(configuration)
end
def cache(namespace, key, &block)
Split::Cache.fetch(namespace, key, &block)
end
end
# Check to see if being run in a Rails application. If so, wait until before_initialize to run configuration so Gems that create ENV variables have the chance to initialize first.
if defined?(::Rails)
class Split::Railtie < Rails::Railtie
config.before_initialize { Split.configure { } }
end
else
Split.configure { }
end
<MSG> Remove check for Rails > 3
<DFF> @@ -15,7 +15,6 @@
require "split/#{f}"
end
-require 'split/engine' if defined?(Rails) && Rails::VERSION::MAJOR >= 3
require 'redis/namespace'
module Split
| 0 | Remove check for Rails > 3 | 1 | .rb | rb | mit | splitrb/split |
10071588 | <NME> style.css
<BEF> html {
background: #efefef;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 13px;
}
body {
padding: 0;
margin: 0;
}
.header {
background: #ededed;
background: -webkit-gradient(linear, left top, left bottom,
color-stop(0%,#6a7176),
color-stop(100%,#4d5256));
background: -moz-linear-gradient (top, #6a7176 0%, #4d5256 100%);
background: -webkit-linear-gradient(top, #6a7176 0%, #4d5256 100%);
background: -o-linear-gradient (top, #6a7176 0%, #4d5256 100%);
background: -ms-linear-gradient (top, #6a7176 0%, #4d5256 100%);
background: linear-gradient (top, #6a7176 0%, #4d5256 100%);
border-bottom: 1px solid #fff;
overflow:hidden;
padding: 10px 5%;
-moz-border-radius-topright: 5px;
-webkit-border-top-right-radius:5px;
border-top-right-radius: 5px;
overflow:hidden;
padding: 10px 5%;
text-shadow:0 1px 0 #000;
}
.header h1 {
color: #eee;
float:left;
font-size:1.2em;
font-weight:normal;
margin:2px 30px 0 0;
}
.header ul li {
display: inline;
}
.header ul li a {
color: #eee;
text-decoration: none;
margin-right: 10px;
display: inline-block;
padding: 4px 8px;
-moz-border-radius: 10px;
-webkit-border-radius:10px;
border-radius: 10px;
}
.header ul li a:hover {
background: rgba(255,255,255,0.1);
}
.header ul li a:active {
-moz-box-shadow: inset 0 1px 0 rgba(0,0,0,0.2);
-webkit-box-shadow:inset 0 1px 0 rgba(0,0,0,0.2);
box-shadow: inset 0 1px 0 rgba(0,0,0,0.2);
}
.header ul li.current a {
background: rgba(255,255,255,0.1);
#main {
padding: 10px 5%;
background: #f9f9f9;
overflow: hidden;
}
float: right;
}
#main {
padding: 10px 5%;
background: #f9f9f9;
border:1px solid #ccc;
border-top:none;
-moz-box-shadow: 0 3px 10px rgba(0,0,0,0.2);
-webkit-box-shadow:0 3px 10px rgba(0,0,0,0.2);
box-shadow: 0 3px 10px rgba(0,0,0,0.2);
overflow: hidden;
}
#main .logo {
float: right;
margin: 10px;
}
#main span.hl {
background: #efefef;
padding: 2px;
}
#main h1 {
margin: 10px 0;
font-size: 190%;
font-weight: bold;
color: #0080FF;
}
#main table {
width: 100%;
margin:0 0 10px;
}
#main table tr td, #main table tr th {
border-bottom: 1px solid #ccc;
padding: 6px;
}
#main table tr th {
background: #efefef;
color: #888;
font-size: 80%;
text-transform:uppercase;
}
#main table tr td.no-data {
text-align: center;
padding: 40px 0;
color: #999;
font-style: italic;
font-size: 130%;
}
#main a {
color: #111;
}
#main p {
margin: 5px 0;
}
#main p.intro {
}
.experiment {
width: 60%;
background:#fff;
border: 1px solid #eee;
border-bottom:none;
#main h1.wi {
margin-bottom: 5px;
}
#main p.sub {
font-size: 95%;
color: #999;
}
.experiment {
background:#fff;
border: 1px solid #eee;
border-bottom:none;
margin:30px 0;
}
.experiment_with_goal {
margin: -32px 0 30px 0;
}
.experiment .experiment-header {
background: #f4f4f4;
background: -webkit-gradient(linear, left top, left bottom,
color-stop(0%,#f4f4f4),
color-stop(100%,#e0e0e0));
background: -moz-linear-gradient (top, #f4f4f4 0%, #e0e0e0 100%);
background: -webkit-linear-gradient(top, #f4f4f4 0%, #e0e0e0 100%);
background: -o-linear-gradient (top, #f4f4f4 0%, #e0e0e0 100%);
background: -ms-linear-gradient (top, #f4f4f4 0%, #e0e0e0 100%);
background: linear-gradient (top, #f4f4f4 0%, #e0e0e0 100%);
border-top:1px solid #fff;
overflow:hidden;
padding:0 10px;
}
.experiment h2 {
color:#888;
margin: 12px 0 12px 0;
font-size: 1em;
font-weight:bold;
float:left;
text-shadow:0 1px 0 rgba(255,255,255,0.8);
}
#footer {
padding: 10px 5%;
background: #efefef;
color: #999;
font-size: 85%;
line-height: 1.5;
border-top: 5px solid #ccc;
padding-top: 10px;
}
font-weight:normal;
}
.experiment table em{
font-style:italic;
font-size:0.9em;
color:#bbb;
}
.experiment table .totals td {
background: #eee;
font-weight: bold;
}
#footer {
padding: 10px 5%;
color: #999;
font-size: 85%;
line-height: 1.5;
padding-top: 10px;
}
#footer p a {
color: #999;
}
.inline-controls {
float:right;
}
.inline-controls small {
color: #888;
font-size: 11px;
}
.inline-controls form {
display: inline-block;
font-size: 10px;
line-height: 38px;
}
.inline-controls input {
margin-left: 10px;
}
.worse, .better {
color: #773F3F;
font-size: 10px;
font-weight:bold;
}
.better {
color: #408C48;
}
.experiment a.button, .experiment button, .experiment input[type="submit"] {
padding: 4px 10px;
overflow: hidden;
background: #d8dae0;
-moz-box-shadow: 0 1px 0 rgba(0,0,0,0.5);
-webkit-box-shadow:0 1px 0 rgba(0,0,0,0.5);
box-shadow: 0 1px 0 rgba(0,0,0,0.5);
border:none;
-moz-border-radius: 30px;
-webkit-border-radius:30px;
border-radius: 30px;
color:#2e3035;
cursor: pointer;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
text-decoration: none;
text-shadow:0 1px 0 rgba(255,255,255,0.8);
-moz-user-select: none;
-webkit-user-select:none;
user-select: none;
white-space: nowrap;
}
a.button:hover, button:hover, input[type="submit"]:hover,
a.button:focus, button:focus, input[type="submit"]:focus{
background:#bbbfc7;
}
a.button:active, button:active, input[type="submit"]:active{
-moz-box-shadow: inset 0 0 4px #484d57;
-webkit-box-shadow:inset 0 0 4px #484d57;
box-shadow: inset 0 0 4px #484d57;
position:relative;
top:1px;
}
a.button.red, button.red, input[type="submit"].red,
a.button.green, button.green, input[type="submit"].green {
color:#fff;
text-shadow:0 1px 0 rgba(0,0,0,0.4);
}
a.button.red, button.red, input[type="submit"].red {
background:#a56d6d;
}
a.button.red:hover, button.red:hover, input[type="submit"].red:hover,
a.button.red:focus, button.red:focus, input[type="submit"].red:focus {
background:#895C5C;
}
a.button.green, button.green, input[type="submit"].green {
background:#8daa92;
}
a.button.green:hover, button.green:hover, input[type="submit"].green:hover,
a.button.green:focus, button.green:focus, input[type="submit"].green:focus {
background:#768E7A;
}
.dashboard-controls input, .dashboard-controls select {
padding: 10px;
}
.dashboard-controls-bottom {
margin-top: 10px;
}
.pagination {
text-align: center;
font-size: 15px;
}
.pagination a, .paginaton span {
display: inline-block;
padding: 5px;
}
.divider {
display: inline-block;
margin-left: 10px;
}
<MSG> Alignment, header colour.
<DFF> @@ -5,20 +5,21 @@ html {
}
body {
- padding: 0;
- margin: 0;
+ padding: 0 10px;
+ margin: 10px auto 0;
+ max-width:800px;
}
.header {
background: #ededed;
background: -webkit-gradient(linear, left top, left bottom,
- color-stop(0%,#6a7176),
+ color-stop(0%,#576a76),
color-stop(100%,#4d5256));
- background: -moz-linear-gradient (top, #6a7176 0%, #4d5256 100%);
- background: -webkit-linear-gradient(top, #6a7176 0%, #4d5256 100%);
- background: -o-linear-gradient (top, #6a7176 0%, #4d5256 100%);
- background: -ms-linear-gradient (top, #6a7176 0%, #4d5256 100%);
- background: linear-gradient (top, #6a7176 0%, #4d5256 100%);
+ background: -moz-linear-gradient (top, #576a76 0%, #414e58 100%);
+ background: -webkit-linear-gradient(top, #576a76 0%, #414e58 100%);
+ background: -o-linear-gradient (top, #576a76 0%, #414e58 100%);
+ background: -ms-linear-gradient (top, #576a76 0%, #414e58 100%);
+ background: linear-gradient (top, #576a76 0%, #414e58 100%);
border-bottom: 1px solid #fff;
overflow:hidden;
padding: 10px 5%;
@@ -70,6 +71,11 @@ body {
#main {
padding: 10px 5%;
background: #f9f9f9;
+ border:1px solid #ccc;
+ border-top:none;
+ -moz-box-shadow: 0 3px 10px rgba(0,0,0,0.2);
+ -webkit-box-shadow:0 3px 10px rgba(0,0,0,0.2);
+ box-shadow: 0 3px 10px rgba(0,0,0,0.2);
overflow: hidden;
}
@@ -141,7 +147,6 @@ body {
}
.experiment {
- width: 60%;
background:#fff;
border: 1px solid #eee;
border-bottom:none;
@@ -192,11 +197,9 @@ body {
#footer {
padding: 10px 5%;
- background: #efefef;
color: #999;
font-size: 85%;
line-height: 1.5;
- border-top: 5px solid #ccc;
padding-top: 10px;
}
| 14 | Alignment, header colour. | 11 | .css | css | mit | splitrb/split |
10071589 | <NME> style.css
<BEF> html {
background: #efefef;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 13px;
}
body {
padding: 0;
margin: 0;
}
.header {
background: #ededed;
background: -webkit-gradient(linear, left top, left bottom,
color-stop(0%,#6a7176),
color-stop(100%,#4d5256));
background: -moz-linear-gradient (top, #6a7176 0%, #4d5256 100%);
background: -webkit-linear-gradient(top, #6a7176 0%, #4d5256 100%);
background: -o-linear-gradient (top, #6a7176 0%, #4d5256 100%);
background: -ms-linear-gradient (top, #6a7176 0%, #4d5256 100%);
background: linear-gradient (top, #6a7176 0%, #4d5256 100%);
border-bottom: 1px solid #fff;
overflow:hidden;
padding: 10px 5%;
-moz-border-radius-topright: 5px;
-webkit-border-top-right-radius:5px;
border-top-right-radius: 5px;
overflow:hidden;
padding: 10px 5%;
text-shadow:0 1px 0 #000;
}
.header h1 {
color: #eee;
float:left;
font-size:1.2em;
font-weight:normal;
margin:2px 30px 0 0;
}
.header ul li {
display: inline;
}
.header ul li a {
color: #eee;
text-decoration: none;
margin-right: 10px;
display: inline-block;
padding: 4px 8px;
-moz-border-radius: 10px;
-webkit-border-radius:10px;
border-radius: 10px;
}
.header ul li a:hover {
background: rgba(255,255,255,0.1);
}
.header ul li a:active {
-moz-box-shadow: inset 0 1px 0 rgba(0,0,0,0.2);
-webkit-box-shadow:inset 0 1px 0 rgba(0,0,0,0.2);
box-shadow: inset 0 1px 0 rgba(0,0,0,0.2);
}
.header ul li.current a {
background: rgba(255,255,255,0.1);
#main {
padding: 10px 5%;
background: #f9f9f9;
overflow: hidden;
}
float: right;
}
#main {
padding: 10px 5%;
background: #f9f9f9;
border:1px solid #ccc;
border-top:none;
-moz-box-shadow: 0 3px 10px rgba(0,0,0,0.2);
-webkit-box-shadow:0 3px 10px rgba(0,0,0,0.2);
box-shadow: 0 3px 10px rgba(0,0,0,0.2);
overflow: hidden;
}
#main .logo {
float: right;
margin: 10px;
}
#main span.hl {
background: #efefef;
padding: 2px;
}
#main h1 {
margin: 10px 0;
font-size: 190%;
font-weight: bold;
color: #0080FF;
}
#main table {
width: 100%;
margin:0 0 10px;
}
#main table tr td, #main table tr th {
border-bottom: 1px solid #ccc;
padding: 6px;
}
#main table tr th {
background: #efefef;
color: #888;
font-size: 80%;
text-transform:uppercase;
}
#main table tr td.no-data {
text-align: center;
padding: 40px 0;
color: #999;
font-style: italic;
font-size: 130%;
}
#main a {
color: #111;
}
#main p {
margin: 5px 0;
}
#main p.intro {
}
.experiment {
width: 60%;
background:#fff;
border: 1px solid #eee;
border-bottom:none;
#main h1.wi {
margin-bottom: 5px;
}
#main p.sub {
font-size: 95%;
color: #999;
}
.experiment {
background:#fff;
border: 1px solid #eee;
border-bottom:none;
margin:30px 0;
}
.experiment_with_goal {
margin: -32px 0 30px 0;
}
.experiment .experiment-header {
background: #f4f4f4;
background: -webkit-gradient(linear, left top, left bottom,
color-stop(0%,#f4f4f4),
color-stop(100%,#e0e0e0));
background: -moz-linear-gradient (top, #f4f4f4 0%, #e0e0e0 100%);
background: -webkit-linear-gradient(top, #f4f4f4 0%, #e0e0e0 100%);
background: -o-linear-gradient (top, #f4f4f4 0%, #e0e0e0 100%);
background: -ms-linear-gradient (top, #f4f4f4 0%, #e0e0e0 100%);
background: linear-gradient (top, #f4f4f4 0%, #e0e0e0 100%);
border-top:1px solid #fff;
overflow:hidden;
padding:0 10px;
}
.experiment h2 {
color:#888;
margin: 12px 0 12px 0;
font-size: 1em;
font-weight:bold;
float:left;
text-shadow:0 1px 0 rgba(255,255,255,0.8);
}
#footer {
padding: 10px 5%;
background: #efefef;
color: #999;
font-size: 85%;
line-height: 1.5;
border-top: 5px solid #ccc;
padding-top: 10px;
}
font-weight:normal;
}
.experiment table em{
font-style:italic;
font-size:0.9em;
color:#bbb;
}
.experiment table .totals td {
background: #eee;
font-weight: bold;
}
#footer {
padding: 10px 5%;
color: #999;
font-size: 85%;
line-height: 1.5;
padding-top: 10px;
}
#footer p a {
color: #999;
}
.inline-controls {
float:right;
}
.inline-controls small {
color: #888;
font-size: 11px;
}
.inline-controls form {
display: inline-block;
font-size: 10px;
line-height: 38px;
}
.inline-controls input {
margin-left: 10px;
}
.worse, .better {
color: #773F3F;
font-size: 10px;
font-weight:bold;
}
.better {
color: #408C48;
}
.experiment a.button, .experiment button, .experiment input[type="submit"] {
padding: 4px 10px;
overflow: hidden;
background: #d8dae0;
-moz-box-shadow: 0 1px 0 rgba(0,0,0,0.5);
-webkit-box-shadow:0 1px 0 rgba(0,0,0,0.5);
box-shadow: 0 1px 0 rgba(0,0,0,0.5);
border:none;
-moz-border-radius: 30px;
-webkit-border-radius:30px;
border-radius: 30px;
color:#2e3035;
cursor: pointer;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
text-decoration: none;
text-shadow:0 1px 0 rgba(255,255,255,0.8);
-moz-user-select: none;
-webkit-user-select:none;
user-select: none;
white-space: nowrap;
}
a.button:hover, button:hover, input[type="submit"]:hover,
a.button:focus, button:focus, input[type="submit"]:focus{
background:#bbbfc7;
}
a.button:active, button:active, input[type="submit"]:active{
-moz-box-shadow: inset 0 0 4px #484d57;
-webkit-box-shadow:inset 0 0 4px #484d57;
box-shadow: inset 0 0 4px #484d57;
position:relative;
top:1px;
}
a.button.red, button.red, input[type="submit"].red,
a.button.green, button.green, input[type="submit"].green {
color:#fff;
text-shadow:0 1px 0 rgba(0,0,0,0.4);
}
a.button.red, button.red, input[type="submit"].red {
background:#a56d6d;
}
a.button.red:hover, button.red:hover, input[type="submit"].red:hover,
a.button.red:focus, button.red:focus, input[type="submit"].red:focus {
background:#895C5C;
}
a.button.green, button.green, input[type="submit"].green {
background:#8daa92;
}
a.button.green:hover, button.green:hover, input[type="submit"].green:hover,
a.button.green:focus, button.green:focus, input[type="submit"].green:focus {
background:#768E7A;
}
.dashboard-controls input, .dashboard-controls select {
padding: 10px;
}
.dashboard-controls-bottom {
margin-top: 10px;
}
.pagination {
text-align: center;
font-size: 15px;
}
.pagination a, .paginaton span {
display: inline-block;
padding: 5px;
}
.divider {
display: inline-block;
margin-left: 10px;
}
<MSG> Alignment, header colour.
<DFF> @@ -5,20 +5,21 @@ html {
}
body {
- padding: 0;
- margin: 0;
+ padding: 0 10px;
+ margin: 10px auto 0;
+ max-width:800px;
}
.header {
background: #ededed;
background: -webkit-gradient(linear, left top, left bottom,
- color-stop(0%,#6a7176),
+ color-stop(0%,#576a76),
color-stop(100%,#4d5256));
- background: -moz-linear-gradient (top, #6a7176 0%, #4d5256 100%);
- background: -webkit-linear-gradient(top, #6a7176 0%, #4d5256 100%);
- background: -o-linear-gradient (top, #6a7176 0%, #4d5256 100%);
- background: -ms-linear-gradient (top, #6a7176 0%, #4d5256 100%);
- background: linear-gradient (top, #6a7176 0%, #4d5256 100%);
+ background: -moz-linear-gradient (top, #576a76 0%, #414e58 100%);
+ background: -webkit-linear-gradient(top, #576a76 0%, #414e58 100%);
+ background: -o-linear-gradient (top, #576a76 0%, #414e58 100%);
+ background: -ms-linear-gradient (top, #576a76 0%, #414e58 100%);
+ background: linear-gradient (top, #576a76 0%, #414e58 100%);
border-bottom: 1px solid #fff;
overflow:hidden;
padding: 10px 5%;
@@ -70,6 +71,11 @@ body {
#main {
padding: 10px 5%;
background: #f9f9f9;
+ border:1px solid #ccc;
+ border-top:none;
+ -moz-box-shadow: 0 3px 10px rgba(0,0,0,0.2);
+ -webkit-box-shadow:0 3px 10px rgba(0,0,0,0.2);
+ box-shadow: 0 3px 10px rgba(0,0,0,0.2);
overflow: hidden;
}
@@ -141,7 +147,6 @@ body {
}
.experiment {
- width: 60%;
background:#fff;
border: 1px solid #eee;
border-bottom:none;
@@ -192,11 +197,9 @@ body {
#footer {
padding: 10px 5%;
- background: #efefef;
color: #999;
font-size: 85%;
line-height: 1.5;
- border-top: 5px solid #ccc;
padding-top: 10px;
}
| 14 | Alignment, header colour. | 11 | .css | css | mit | splitrb/split |
10071590 | <NME> style.css
<BEF> html {
background: #efefef;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 13px;
}
body {
padding: 0;
margin: 0;
}
.header {
background: #ededed;
background: -webkit-gradient(linear, left top, left bottom,
color-stop(0%,#6a7176),
color-stop(100%,#4d5256));
background: -moz-linear-gradient (top, #6a7176 0%, #4d5256 100%);
background: -webkit-linear-gradient(top, #6a7176 0%, #4d5256 100%);
background: -o-linear-gradient (top, #6a7176 0%, #4d5256 100%);
background: -ms-linear-gradient (top, #6a7176 0%, #4d5256 100%);
background: linear-gradient (top, #6a7176 0%, #4d5256 100%);
border-bottom: 1px solid #fff;
overflow:hidden;
padding: 10px 5%;
-moz-border-radius-topright: 5px;
-webkit-border-top-right-radius:5px;
border-top-right-radius: 5px;
overflow:hidden;
padding: 10px 5%;
text-shadow:0 1px 0 #000;
}
.header h1 {
color: #eee;
float:left;
font-size:1.2em;
font-weight:normal;
margin:2px 30px 0 0;
}
.header ul li {
display: inline;
}
.header ul li a {
color: #eee;
text-decoration: none;
margin-right: 10px;
display: inline-block;
padding: 4px 8px;
-moz-border-radius: 10px;
-webkit-border-radius:10px;
border-radius: 10px;
}
.header ul li a:hover {
background: rgba(255,255,255,0.1);
}
.header ul li a:active {
-moz-box-shadow: inset 0 1px 0 rgba(0,0,0,0.2);
-webkit-box-shadow:inset 0 1px 0 rgba(0,0,0,0.2);
box-shadow: inset 0 1px 0 rgba(0,0,0,0.2);
}
.header ul li.current a {
background: rgba(255,255,255,0.1);
#main {
padding: 10px 5%;
background: #f9f9f9;
overflow: hidden;
}
float: right;
}
#main {
padding: 10px 5%;
background: #f9f9f9;
border:1px solid #ccc;
border-top:none;
-moz-box-shadow: 0 3px 10px rgba(0,0,0,0.2);
-webkit-box-shadow:0 3px 10px rgba(0,0,0,0.2);
box-shadow: 0 3px 10px rgba(0,0,0,0.2);
overflow: hidden;
}
#main .logo {
float: right;
margin: 10px;
}
#main span.hl {
background: #efefef;
padding: 2px;
}
#main h1 {
margin: 10px 0;
font-size: 190%;
font-weight: bold;
color: #0080FF;
}
#main table {
width: 100%;
margin:0 0 10px;
}
#main table tr td, #main table tr th {
border-bottom: 1px solid #ccc;
padding: 6px;
}
#main table tr th {
background: #efefef;
color: #888;
font-size: 80%;
text-transform:uppercase;
}
#main table tr td.no-data {
text-align: center;
padding: 40px 0;
color: #999;
font-style: italic;
font-size: 130%;
}
#main a {
color: #111;
}
#main p {
margin: 5px 0;
}
#main p.intro {
}
.experiment {
width: 60%;
background:#fff;
border: 1px solid #eee;
border-bottom:none;
#main h1.wi {
margin-bottom: 5px;
}
#main p.sub {
font-size: 95%;
color: #999;
}
.experiment {
background:#fff;
border: 1px solid #eee;
border-bottom:none;
margin:30px 0;
}
.experiment_with_goal {
margin: -32px 0 30px 0;
}
.experiment .experiment-header {
background: #f4f4f4;
background: -webkit-gradient(linear, left top, left bottom,
color-stop(0%,#f4f4f4),
color-stop(100%,#e0e0e0));
background: -moz-linear-gradient (top, #f4f4f4 0%, #e0e0e0 100%);
background: -webkit-linear-gradient(top, #f4f4f4 0%, #e0e0e0 100%);
background: -o-linear-gradient (top, #f4f4f4 0%, #e0e0e0 100%);
background: -ms-linear-gradient (top, #f4f4f4 0%, #e0e0e0 100%);
background: linear-gradient (top, #f4f4f4 0%, #e0e0e0 100%);
border-top:1px solid #fff;
overflow:hidden;
padding:0 10px;
}
.experiment h2 {
color:#888;
margin: 12px 0 12px 0;
font-size: 1em;
font-weight:bold;
float:left;
text-shadow:0 1px 0 rgba(255,255,255,0.8);
}
#footer {
padding: 10px 5%;
background: #efefef;
color: #999;
font-size: 85%;
line-height: 1.5;
border-top: 5px solid #ccc;
padding-top: 10px;
}
font-weight:normal;
}
.experiment table em{
font-style:italic;
font-size:0.9em;
color:#bbb;
}
.experiment table .totals td {
background: #eee;
font-weight: bold;
}
#footer {
padding: 10px 5%;
color: #999;
font-size: 85%;
line-height: 1.5;
padding-top: 10px;
}
#footer p a {
color: #999;
}
.inline-controls {
float:right;
}
.inline-controls small {
color: #888;
font-size: 11px;
}
.inline-controls form {
display: inline-block;
font-size: 10px;
line-height: 38px;
}
.inline-controls input {
margin-left: 10px;
}
.worse, .better {
color: #773F3F;
font-size: 10px;
font-weight:bold;
}
.better {
color: #408C48;
}
.experiment a.button, .experiment button, .experiment input[type="submit"] {
padding: 4px 10px;
overflow: hidden;
background: #d8dae0;
-moz-box-shadow: 0 1px 0 rgba(0,0,0,0.5);
-webkit-box-shadow:0 1px 0 rgba(0,0,0,0.5);
box-shadow: 0 1px 0 rgba(0,0,0,0.5);
border:none;
-moz-border-radius: 30px;
-webkit-border-radius:30px;
border-radius: 30px;
color:#2e3035;
cursor: pointer;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
text-decoration: none;
text-shadow:0 1px 0 rgba(255,255,255,0.8);
-moz-user-select: none;
-webkit-user-select:none;
user-select: none;
white-space: nowrap;
}
a.button:hover, button:hover, input[type="submit"]:hover,
a.button:focus, button:focus, input[type="submit"]:focus{
background:#bbbfc7;
}
a.button:active, button:active, input[type="submit"]:active{
-moz-box-shadow: inset 0 0 4px #484d57;
-webkit-box-shadow:inset 0 0 4px #484d57;
box-shadow: inset 0 0 4px #484d57;
position:relative;
top:1px;
}
a.button.red, button.red, input[type="submit"].red,
a.button.green, button.green, input[type="submit"].green {
color:#fff;
text-shadow:0 1px 0 rgba(0,0,0,0.4);
}
a.button.red, button.red, input[type="submit"].red {
background:#a56d6d;
}
a.button.red:hover, button.red:hover, input[type="submit"].red:hover,
a.button.red:focus, button.red:focus, input[type="submit"].red:focus {
background:#895C5C;
}
a.button.green, button.green, input[type="submit"].green {
background:#8daa92;
}
a.button.green:hover, button.green:hover, input[type="submit"].green:hover,
a.button.green:focus, button.green:focus, input[type="submit"].green:focus {
background:#768E7A;
}
.dashboard-controls input, .dashboard-controls select {
padding: 10px;
}
.dashboard-controls-bottom {
margin-top: 10px;
}
.pagination {
text-align: center;
font-size: 15px;
}
.pagination a, .paginaton span {
display: inline-block;
padding: 5px;
}
.divider {
display: inline-block;
margin-left: 10px;
}
<MSG> Alignment, header colour.
<DFF> @@ -5,20 +5,21 @@ html {
}
body {
- padding: 0;
- margin: 0;
+ padding: 0 10px;
+ margin: 10px auto 0;
+ max-width:800px;
}
.header {
background: #ededed;
background: -webkit-gradient(linear, left top, left bottom,
- color-stop(0%,#6a7176),
+ color-stop(0%,#576a76),
color-stop(100%,#4d5256));
- background: -moz-linear-gradient (top, #6a7176 0%, #4d5256 100%);
- background: -webkit-linear-gradient(top, #6a7176 0%, #4d5256 100%);
- background: -o-linear-gradient (top, #6a7176 0%, #4d5256 100%);
- background: -ms-linear-gradient (top, #6a7176 0%, #4d5256 100%);
- background: linear-gradient (top, #6a7176 0%, #4d5256 100%);
+ background: -moz-linear-gradient (top, #576a76 0%, #414e58 100%);
+ background: -webkit-linear-gradient(top, #576a76 0%, #414e58 100%);
+ background: -o-linear-gradient (top, #576a76 0%, #414e58 100%);
+ background: -ms-linear-gradient (top, #576a76 0%, #414e58 100%);
+ background: linear-gradient (top, #576a76 0%, #414e58 100%);
border-bottom: 1px solid #fff;
overflow:hidden;
padding: 10px 5%;
@@ -70,6 +71,11 @@ body {
#main {
padding: 10px 5%;
background: #f9f9f9;
+ border:1px solid #ccc;
+ border-top:none;
+ -moz-box-shadow: 0 3px 10px rgba(0,0,0,0.2);
+ -webkit-box-shadow:0 3px 10px rgba(0,0,0,0.2);
+ box-shadow: 0 3px 10px rgba(0,0,0,0.2);
overflow: hidden;
}
@@ -141,7 +147,6 @@ body {
}
.experiment {
- width: 60%;
background:#fff;
border: 1px solid #eee;
border-bottom:none;
@@ -192,11 +197,9 @@ body {
#footer {
padding: 10px 5%;
- background: #efefef;
color: #999;
font-size: 85%;
line-height: 1.5;
- border-top: 5px solid #ccc;
padding-top: 10px;
}
| 14 | Alignment, header colour. | 11 | .css | css | mit | splitrb/split |
10071591 | <NME> configuration_spec.rb
<BEF> # frozen_string_literal: true
require "spec_helper"
describe Split::Configuration do
before(:each) { @config = Split::Configuration.new }
it "should provide a default value for ignore_ip_addresses" do
expect(@config.ignore_ip_addresses).to eq([])
end
it "should provide default values for db failover" do
expect(@config.db_failover).to be_falsey
expect(@config.db_failover_on_db_error).to be_a Proc
end
it "should not allow multiple experiments by default" do
expect(@config.allow_multiple_experiments).to be_falsey
end
it "should be enabled by default" do
expect(@config.enabled).to be_truthy
end
it "disabled is the opposite of enabled" do
@config.enabled = false
expect(@config.disabled?).to be_truthy
end
it "should not store the overridden test group per default" do
expect(@config.store_override).to be_falsey
end
it "should provide a default pattern for robots" do
%w[Baidu Gigabot Googlebot libwww-perl lwp-trivial msnbot SiteUptime Slurp WordPress ZIBB ZyBorg YandexBot AdsBot-Google Wget curl bitlybot facebookexternalhit spider].each do |robot|
expect(@config.robot_regex).to match(robot)
end
expect(@config.robot_regex).to match("EventMachine HttpClient")
expect(@config.robot_regex).to match("libwww-perl/5.836")
expect(@config.robot_regex).to match("Pingdom.com_bot_version_1.4_(http://www.pingdom.com)")
expect(@config.robot_regex).to match(" - ")
end
it "should accept real UAs with the robot regexp" do
expect(@config.robot_regex).not_to match("Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.4) Gecko/20091017 SeaMonkey/2.0")
expect(@config.robot_regex).not_to match("Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; F-6.0SP2-20041109; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 1.1.4322; InfoPath.3)")
end
it "should allow adding a bot to the bot list" do
@config.bots["newbot"] = "An amazing test bot"
expect(@config.robot_regex).to match("newbot")
end
it "should use the session adapter for persistence by default" do
expect(@config.persistence).to eq(Split::Persistence::SessionAdapter)
end
it "should load a metric" do
@config.experiments = { my_experiment: { alternatives: ["control_opt", "other_opt"], metric: :my_metric } }
expect(@config.metrics).not_to be_nil
expect(@config.metrics.keys).to eq([:my_metric])
end
it "should allow loading of experiment using experment_for" do
@config.experiments = { my_experiment: { alternatives: ["control_opt", "other_opt"], metric: :my_metric } }
expect(@config.experiment_for(:my_experiment)).to eq({ alternatives: ["control_opt", ["other_opt"]] })
end
context "when experiments are defined via YAML" do
context "as strings" do
context "in a basic configuration" do
before do
experiments_yaml = <<-eos
my_experiment:
alternatives:
- Control Opt
- Alt One
- Alt Two
resettable: false
eos
@config.experiments = YAML.load(experiments_yaml)
end
it "should normalize experiments" do
expect(@config.normalized_experiments).to eq({ my_experiment: { resettable: false, alternatives: ["Control Opt", ["Alt One", "Alt Two"]] } })
end
end
end
context "in a complex configuration" do
before do
experiments_yaml = <<-eos
alternatives:
- name: Control Opt
percent: 67
- name: Alt One
percent: 10
- name: Alt Two
percent: 23
resettable: false
metric: my_metric
another_experiment:
alternatives:
- a
- b
eos
@config.experiments = YAML.load(experiments_yaml)
end
it "should normalize experiments" do
expect(@config.normalized_experiments).to eq({ my_experiment: { resettable: false, alternatives: [{ "Control Opt"=>0.67 },
[{ "Alt One"=>0.1 }, { "Alt Two"=>0.23 }]] }, another_experiment: { alternatives: ["a", ["b"]] } })
end
it "should recognize metrics" do
expect(@config.metrics).not_to be_nil
expect(@config.metrics).not_to be_nil
expect(@config.metrics.keys).to eq([:my_metric])
end
end
end
before do
experiments_yaml = <<-eos
:my_experiment:
:alternatives:
- Control Opt
- Alt One
- Alt Two
:resettable: false
eos
@config.experiments = YAML.load(experiments_yaml)
end
it "should normalize experiments" do
expect(@config.normalized_experiments).to eq({ my_experiment: { resettable: false, alternatives: ["Control Opt", ["Alt One", "Alt Two"]] } })
end
end
context "with invalid YAML" do
let(:yaml) { YAML.load(input) }
context "with an empty string" do
let(:input) { "" }
it "should raise an error" do
expect { @config.experiments = yaml }.to raise_error(Split::InvalidExperimentsFormatError)
end
end
context "with just the YAML header" do
let(:input) { "---" }
it "should raise an error" do
expect { @config.experiments = yaml }.to raise_error(Split::InvalidExperimentsFormatError)
end
end
end
end
end
it "should normalize experiments" do
@config.experiments = {
my_experiment: {
alternatives: [
{ name: "control_opt", percent: 67 },
{ name: "second_opt", percent: 10 },
{ name: "third_opt", percent: 23 },
],
}
}
expect(@config.normalized_experiments).to eq({ my_experiment: { alternatives: [{ "control_opt"=>0.67 }, [{ "second_opt"=>0.1 }, { "third_opt"=>0.23 }]] } })
end
context "redis configuration" do
it "should default to local redis server" do
old_redis_url = ENV["REDIS_URL"]
ENV.delete("REDIS_URL")
expect(Split::Configuration.new.redis).to eq("redis://localhost:6379")
ENV["REDIS_URL"] = old_redis_url
end
it "should allow for redis url to be configured" do
@config.redis = "custom_redis_url"
expect(@config.redis).to eq("custom_redis_url")
end
context "provided REDIS_URL environment variable" do
it "should use the ENV variable" do
old_redis_url = ENV["REDIS_URL"]
ENV["REDIS_URL"] = "env_redis_url"
expect(Split::Configuration.new.redis).to eq("env_redis_url")
ENV["REDIS_URL"] = old_redis_url
end
end
end
context "persistence cookie length" do
it "should default to 1 year" do
expect(@config.persistence_cookie_length).to eq(31536000)
end
it "should allow the persistence cookie length to be configured" do
@config.persistence_cookie_length = 2592000
expect(@config.persistence_cookie_length).to eq(2592000)
end
end
context "persistence cookie domain" do
it "should default to nil" do
expect(@config.persistence_cookie_domain).to eq(nil)
end
it "should allow the persistence cookie domain to be configured" do
@config.persistence_cookie_domain = ".acme.com"
expect(@config.persistence_cookie_domain).to eq(".acme.com")
end
end
end
<MSG> Explicitly load the configuration metadata into normalized experiments
<DFF> @@ -90,6 +90,36 @@ describe Split::Configuration do
end
end
+ context "in a configuration with metadata" do
+ before do
+ experiments_yaml = <<-eos
+ my_experiment:
+ alternatives:
+ - name: Control Opt
+ percent: 67
+ - name: Alt One
+ percent: 10
+ - name: Alt Two
+ percent: 23
+ metadata:
+ Control Opt:
+ text: 'Control Option'
+ Alt One:
+ text: 'Alternative One'
+ Alt Two:
+ text: 'Alternative Two'
+ resettable: false
+ eos
+ @config.experiments = YAML.load(experiments_yaml)
+ end
+
+ it 'should have metadata on the experiment' do
+ meta = @config.normalized_experiments[:my_experiment][:metadata]
+ expect(meta).to_not be nil
+ expect(meta['Control Opt']['text']).to eq('Control Option')
+ end
+ end
+
context "in a complex configuration" do
before do
experiments_yaml = <<-eos
@@ -120,6 +150,7 @@ describe Split::Configuration do
expect(@config.metrics).not_to be_nil
expect(@config.metrics.keys).to eq([:my_metric])
end
+
end
end
| 31 | Explicitly load the configuration metadata into normalized experiments | 0 | .rb | rb | mit | splitrb/split |
10071592 | <NME> configuration_spec.rb
<BEF> # frozen_string_literal: true
require "spec_helper"
describe Split::Configuration do
before(:each) { @config = Split::Configuration.new }
it "should provide a default value for ignore_ip_addresses" do
expect(@config.ignore_ip_addresses).to eq([])
end
it "should provide default values for db failover" do
expect(@config.db_failover).to be_falsey
expect(@config.db_failover_on_db_error).to be_a Proc
end
it "should not allow multiple experiments by default" do
expect(@config.allow_multiple_experiments).to be_falsey
end
it "should be enabled by default" do
expect(@config.enabled).to be_truthy
end
it "disabled is the opposite of enabled" do
@config.enabled = false
expect(@config.disabled?).to be_truthy
end
it "should not store the overridden test group per default" do
expect(@config.store_override).to be_falsey
end
it "should provide a default pattern for robots" do
%w[Baidu Gigabot Googlebot libwww-perl lwp-trivial msnbot SiteUptime Slurp WordPress ZIBB ZyBorg YandexBot AdsBot-Google Wget curl bitlybot facebookexternalhit spider].each do |robot|
expect(@config.robot_regex).to match(robot)
end
expect(@config.robot_regex).to match("EventMachine HttpClient")
expect(@config.robot_regex).to match("libwww-perl/5.836")
expect(@config.robot_regex).to match("Pingdom.com_bot_version_1.4_(http://www.pingdom.com)")
expect(@config.robot_regex).to match(" - ")
end
it "should accept real UAs with the robot regexp" do
expect(@config.robot_regex).not_to match("Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.4) Gecko/20091017 SeaMonkey/2.0")
expect(@config.robot_regex).not_to match("Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; F-6.0SP2-20041109; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 1.1.4322; InfoPath.3)")
end
it "should allow adding a bot to the bot list" do
@config.bots["newbot"] = "An amazing test bot"
expect(@config.robot_regex).to match("newbot")
end
it "should use the session adapter for persistence by default" do
expect(@config.persistence).to eq(Split::Persistence::SessionAdapter)
end
it "should load a metric" do
@config.experiments = { my_experiment: { alternatives: ["control_opt", "other_opt"], metric: :my_metric } }
expect(@config.metrics).not_to be_nil
expect(@config.metrics.keys).to eq([:my_metric])
end
it "should allow loading of experiment using experment_for" do
@config.experiments = { my_experiment: { alternatives: ["control_opt", "other_opt"], metric: :my_metric } }
expect(@config.experiment_for(:my_experiment)).to eq({ alternatives: ["control_opt", ["other_opt"]] })
end
context "when experiments are defined via YAML" do
context "as strings" do
context "in a basic configuration" do
before do
experiments_yaml = <<-eos
my_experiment:
alternatives:
- Control Opt
- Alt One
- Alt Two
resettable: false
eos
@config.experiments = YAML.load(experiments_yaml)
end
it "should normalize experiments" do
expect(@config.normalized_experiments).to eq({ my_experiment: { resettable: false, alternatives: ["Control Opt", ["Alt One", "Alt Two"]] } })
end
end
end
context "in a complex configuration" do
before do
experiments_yaml = <<-eos
alternatives:
- name: Control Opt
percent: 67
- name: Alt One
percent: 10
- name: Alt Two
percent: 23
resettable: false
metric: my_metric
another_experiment:
alternatives:
- a
- b
eos
@config.experiments = YAML.load(experiments_yaml)
end
it "should normalize experiments" do
expect(@config.normalized_experiments).to eq({ my_experiment: { resettable: false, alternatives: [{ "Control Opt"=>0.67 },
[{ "Alt One"=>0.1 }, { "Alt Two"=>0.23 }]] }, another_experiment: { alternatives: ["a", ["b"]] } })
end
it "should recognize metrics" do
expect(@config.metrics).not_to be_nil
expect(@config.metrics).not_to be_nil
expect(@config.metrics.keys).to eq([:my_metric])
end
end
end
before do
experiments_yaml = <<-eos
:my_experiment:
:alternatives:
- Control Opt
- Alt One
- Alt Two
:resettable: false
eos
@config.experiments = YAML.load(experiments_yaml)
end
it "should normalize experiments" do
expect(@config.normalized_experiments).to eq({ my_experiment: { resettable: false, alternatives: ["Control Opt", ["Alt One", "Alt Two"]] } })
end
end
context "with invalid YAML" do
let(:yaml) { YAML.load(input) }
context "with an empty string" do
let(:input) { "" }
it "should raise an error" do
expect { @config.experiments = yaml }.to raise_error(Split::InvalidExperimentsFormatError)
end
end
context "with just the YAML header" do
let(:input) { "---" }
it "should raise an error" do
expect { @config.experiments = yaml }.to raise_error(Split::InvalidExperimentsFormatError)
end
end
end
end
end
it "should normalize experiments" do
@config.experiments = {
my_experiment: {
alternatives: [
{ name: "control_opt", percent: 67 },
{ name: "second_opt", percent: 10 },
{ name: "third_opt", percent: 23 },
],
}
}
expect(@config.normalized_experiments).to eq({ my_experiment: { alternatives: [{ "control_opt"=>0.67 }, [{ "second_opt"=>0.1 }, { "third_opt"=>0.23 }]] } })
end
context "redis configuration" do
it "should default to local redis server" do
old_redis_url = ENV["REDIS_URL"]
ENV.delete("REDIS_URL")
expect(Split::Configuration.new.redis).to eq("redis://localhost:6379")
ENV["REDIS_URL"] = old_redis_url
end
it "should allow for redis url to be configured" do
@config.redis = "custom_redis_url"
expect(@config.redis).to eq("custom_redis_url")
end
context "provided REDIS_URL environment variable" do
it "should use the ENV variable" do
old_redis_url = ENV["REDIS_URL"]
ENV["REDIS_URL"] = "env_redis_url"
expect(Split::Configuration.new.redis).to eq("env_redis_url")
ENV["REDIS_URL"] = old_redis_url
end
end
end
context "persistence cookie length" do
it "should default to 1 year" do
expect(@config.persistence_cookie_length).to eq(31536000)
end
it "should allow the persistence cookie length to be configured" do
@config.persistence_cookie_length = 2592000
expect(@config.persistence_cookie_length).to eq(2592000)
end
end
context "persistence cookie domain" do
it "should default to nil" do
expect(@config.persistence_cookie_domain).to eq(nil)
end
it "should allow the persistence cookie domain to be configured" do
@config.persistence_cookie_domain = ".acme.com"
expect(@config.persistence_cookie_domain).to eq(".acme.com")
end
end
end
<MSG> Explicitly load the configuration metadata into normalized experiments
<DFF> @@ -90,6 +90,36 @@ describe Split::Configuration do
end
end
+ context "in a configuration with metadata" do
+ before do
+ experiments_yaml = <<-eos
+ my_experiment:
+ alternatives:
+ - name: Control Opt
+ percent: 67
+ - name: Alt One
+ percent: 10
+ - name: Alt Two
+ percent: 23
+ metadata:
+ Control Opt:
+ text: 'Control Option'
+ Alt One:
+ text: 'Alternative One'
+ Alt Two:
+ text: 'Alternative Two'
+ resettable: false
+ eos
+ @config.experiments = YAML.load(experiments_yaml)
+ end
+
+ it 'should have metadata on the experiment' do
+ meta = @config.normalized_experiments[:my_experiment][:metadata]
+ expect(meta).to_not be nil
+ expect(meta['Control Opt']['text']).to eq('Control Option')
+ end
+ end
+
context "in a complex configuration" do
before do
experiments_yaml = <<-eos
@@ -120,6 +150,7 @@ describe Split::Configuration do
expect(@config.metrics).not_to be_nil
expect(@config.metrics.keys).to eq([:my_metric])
end
+
end
end
| 31 | Explicitly load the configuration metadata into normalized experiments | 0 | .rb | rb | mit | splitrb/split |
10071593 | <NME> configuration_spec.rb
<BEF> # frozen_string_literal: true
require "spec_helper"
describe Split::Configuration do
before(:each) { @config = Split::Configuration.new }
it "should provide a default value for ignore_ip_addresses" do
expect(@config.ignore_ip_addresses).to eq([])
end
it "should provide default values for db failover" do
expect(@config.db_failover).to be_falsey
expect(@config.db_failover_on_db_error).to be_a Proc
end
it "should not allow multiple experiments by default" do
expect(@config.allow_multiple_experiments).to be_falsey
end
it "should be enabled by default" do
expect(@config.enabled).to be_truthy
end
it "disabled is the opposite of enabled" do
@config.enabled = false
expect(@config.disabled?).to be_truthy
end
it "should not store the overridden test group per default" do
expect(@config.store_override).to be_falsey
end
it "should provide a default pattern for robots" do
%w[Baidu Gigabot Googlebot libwww-perl lwp-trivial msnbot SiteUptime Slurp WordPress ZIBB ZyBorg YandexBot AdsBot-Google Wget curl bitlybot facebookexternalhit spider].each do |robot|
expect(@config.robot_regex).to match(robot)
end
expect(@config.robot_regex).to match("EventMachine HttpClient")
expect(@config.robot_regex).to match("libwww-perl/5.836")
expect(@config.robot_regex).to match("Pingdom.com_bot_version_1.4_(http://www.pingdom.com)")
expect(@config.robot_regex).to match(" - ")
end
it "should accept real UAs with the robot regexp" do
expect(@config.robot_regex).not_to match("Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.4) Gecko/20091017 SeaMonkey/2.0")
expect(@config.robot_regex).not_to match("Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; F-6.0SP2-20041109; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 1.1.4322; InfoPath.3)")
end
it "should allow adding a bot to the bot list" do
@config.bots["newbot"] = "An amazing test bot"
expect(@config.robot_regex).to match("newbot")
end
it "should use the session adapter for persistence by default" do
expect(@config.persistence).to eq(Split::Persistence::SessionAdapter)
end
it "should load a metric" do
@config.experiments = { my_experiment: { alternatives: ["control_opt", "other_opt"], metric: :my_metric } }
expect(@config.metrics).not_to be_nil
expect(@config.metrics.keys).to eq([:my_metric])
end
it "should allow loading of experiment using experment_for" do
@config.experiments = { my_experiment: { alternatives: ["control_opt", "other_opt"], metric: :my_metric } }
expect(@config.experiment_for(:my_experiment)).to eq({ alternatives: ["control_opt", ["other_opt"]] })
end
context "when experiments are defined via YAML" do
context "as strings" do
context "in a basic configuration" do
before do
experiments_yaml = <<-eos
my_experiment:
alternatives:
- Control Opt
- Alt One
- Alt Two
resettable: false
eos
@config.experiments = YAML.load(experiments_yaml)
end
it "should normalize experiments" do
expect(@config.normalized_experiments).to eq({ my_experiment: { resettable: false, alternatives: ["Control Opt", ["Alt One", "Alt Two"]] } })
end
end
end
context "in a complex configuration" do
before do
experiments_yaml = <<-eos
alternatives:
- name: Control Opt
percent: 67
- name: Alt One
percent: 10
- name: Alt Two
percent: 23
resettable: false
metric: my_metric
another_experiment:
alternatives:
- a
- b
eos
@config.experiments = YAML.load(experiments_yaml)
end
it "should normalize experiments" do
expect(@config.normalized_experiments).to eq({ my_experiment: { resettable: false, alternatives: [{ "Control Opt"=>0.67 },
[{ "Alt One"=>0.1 }, { "Alt Two"=>0.23 }]] }, another_experiment: { alternatives: ["a", ["b"]] } })
end
it "should recognize metrics" do
expect(@config.metrics).not_to be_nil
expect(@config.metrics).not_to be_nil
expect(@config.metrics.keys).to eq([:my_metric])
end
end
end
before do
experiments_yaml = <<-eos
:my_experiment:
:alternatives:
- Control Opt
- Alt One
- Alt Two
:resettable: false
eos
@config.experiments = YAML.load(experiments_yaml)
end
it "should normalize experiments" do
expect(@config.normalized_experiments).to eq({ my_experiment: { resettable: false, alternatives: ["Control Opt", ["Alt One", "Alt Two"]] } })
end
end
context "with invalid YAML" do
let(:yaml) { YAML.load(input) }
context "with an empty string" do
let(:input) { "" }
it "should raise an error" do
expect { @config.experiments = yaml }.to raise_error(Split::InvalidExperimentsFormatError)
end
end
context "with just the YAML header" do
let(:input) { "---" }
it "should raise an error" do
expect { @config.experiments = yaml }.to raise_error(Split::InvalidExperimentsFormatError)
end
end
end
end
end
it "should normalize experiments" do
@config.experiments = {
my_experiment: {
alternatives: [
{ name: "control_opt", percent: 67 },
{ name: "second_opt", percent: 10 },
{ name: "third_opt", percent: 23 },
],
}
}
expect(@config.normalized_experiments).to eq({ my_experiment: { alternatives: [{ "control_opt"=>0.67 }, [{ "second_opt"=>0.1 }, { "third_opt"=>0.23 }]] } })
end
context "redis configuration" do
it "should default to local redis server" do
old_redis_url = ENV["REDIS_URL"]
ENV.delete("REDIS_URL")
expect(Split::Configuration.new.redis).to eq("redis://localhost:6379")
ENV["REDIS_URL"] = old_redis_url
end
it "should allow for redis url to be configured" do
@config.redis = "custom_redis_url"
expect(@config.redis).to eq("custom_redis_url")
end
context "provided REDIS_URL environment variable" do
it "should use the ENV variable" do
old_redis_url = ENV["REDIS_URL"]
ENV["REDIS_URL"] = "env_redis_url"
expect(Split::Configuration.new.redis).to eq("env_redis_url")
ENV["REDIS_URL"] = old_redis_url
end
end
end
context "persistence cookie length" do
it "should default to 1 year" do
expect(@config.persistence_cookie_length).to eq(31536000)
end
it "should allow the persistence cookie length to be configured" do
@config.persistence_cookie_length = 2592000
expect(@config.persistence_cookie_length).to eq(2592000)
end
end
context "persistence cookie domain" do
it "should default to nil" do
expect(@config.persistence_cookie_domain).to eq(nil)
end
it "should allow the persistence cookie domain to be configured" do
@config.persistence_cookie_domain = ".acme.com"
expect(@config.persistence_cookie_domain).to eq(".acme.com")
end
end
end
<MSG> Explicitly load the configuration metadata into normalized experiments
<DFF> @@ -90,6 +90,36 @@ describe Split::Configuration do
end
end
+ context "in a configuration with metadata" do
+ before do
+ experiments_yaml = <<-eos
+ my_experiment:
+ alternatives:
+ - name: Control Opt
+ percent: 67
+ - name: Alt One
+ percent: 10
+ - name: Alt Two
+ percent: 23
+ metadata:
+ Control Opt:
+ text: 'Control Option'
+ Alt One:
+ text: 'Alternative One'
+ Alt Two:
+ text: 'Alternative Two'
+ resettable: false
+ eos
+ @config.experiments = YAML.load(experiments_yaml)
+ end
+
+ it 'should have metadata on the experiment' do
+ meta = @config.normalized_experiments[:my_experiment][:metadata]
+ expect(meta).to_not be nil
+ expect(meta['Control Opt']['text']).to eq('Control Option')
+ end
+ end
+
context "in a complex configuration" do
before do
experiments_yaml = <<-eos
@@ -120,6 +150,7 @@ describe Split::Configuration do
expect(@config.metrics).not_to be_nil
expect(@config.metrics.keys).to eq([:my_metric])
end
+
end
end
| 31 | Explicitly load the configuration metadata into normalized experiments | 0 | .rb | rb | mit | splitrb/split |
10071594 | <NME> extract-abbreviation.ts
<BEF> import { deepStrictEqual, strictEqual, ok } from 'assert';
import extractAbbreviation, { ExtractOptions, ExtractedAbbreviation } from '../src/extract-abbreviation';
import isAtHTMLTag from '../src/extract-abbreviation/is-html';
import scanner from '../src/extract-abbreviation/reader';
import { consumeQuoted } from '../src/extract-abbreviation/quotes';
function extract(abbr: string, options?: Partial<ExtractOptions>) {
let caretPos: number | undefined = abbr.indexOf('|');
if (caretPos !== -1) {
abbr = abbr.slice(0, caretPos) + abbr.slice(caretPos + 1);
} else {
caretPos = void 0;
}
return extractAbbreviation(abbr, caretPos, options);
}
function result(abbreviation: string, location: number, start = location): ExtractedAbbreviation {
return {
abbreviation,
location,
start: start != null ? start : location,
end: location + abbreviation.length
};
}
describe('Extract abbreviation', () => {
it('basic', () => {
deepStrictEqual(extract('.bar'), result('.bar', 0));
deepStrictEqual(extract('.foo .bar'), result('.bar', 5));
deepStrictEqual(extract('.foo @bar'), result('@bar', 5));
deepStrictEqual(extract('.foo img/'), result('img/', 5));
deepStrictEqual(extract('ัะตะบััdiv'), result('div', 5));
deepStrictEqual(extract('foo div[foo="ัะตะบัั" bar=ัะตะบัั2]'), result('div[foo="ัะตะบัั" bar=ัะตะบัั2]', 4));
});
it('abbreviation with operators', () => {
deepStrictEqual(extract('a foo+bar.baz'), result('foo+bar.baz', 2));
deepStrictEqual(extract('a foo>bar+baz*3'), result('foo>bar+baz*3', 2));
});
it('abbreviation with attributes', () => {
deepStrictEqual(extract('a foo[bar|]'), result('foo[bar]', 2));
deepStrictEqual(extract('a foo[bar="baz" a b]'), result('foo[bar="baz" a b]', 2));
deepStrictEqual(extract('foo bar[a|] baz'), result('bar[a]', 4));
});
it('tag test', () => {
deepStrictEqual(extract('<foo>bar[a b="c"]>baz'), result('bar[a b="c"]>baz', 5));
deepStrictEqual(extract('foo>bar'), result('foo>bar', 0));
deepStrictEqual(extract('<foo>bar'), result('bar', 5));
deepStrictEqual(extract('<foo>bar[a="d" b="c"]>baz'), result('bar[a="d" b="c"]>baz', 5));
});
it('stylesheet abbreviation', () => {
deepStrictEqual(extract('foo{bar|}'), result('foo{bar}', 0));
deepStrictEqual(extract('foo{bar|}', { type: 'stylesheet' }), result('bar', 4));
});
it('prefixed extract', () => {
deepStrictEqual(extract('<foo>bar[a b="c"]>baz'), result('bar[a b="c"]>baz', 5));
deepStrictEqual(extract('<foo>bar[a b="c"]>baz', { prefix: '<' }), result('foo>bar[a b="c"]>baz', 1, 0));
deepStrictEqual(extract('<foo>bar[a b="<"]>baz', { prefix: '<' }), result('foo>bar[a b="<"]>baz', 1, 0));
deepStrictEqual(extract('<foo>bar{<}>baz', { prefix: '<' }), result('foo>bar{<}>baz', 1, 0));
// Multiple prefix characters
deepStrictEqual(extract('foo>>>bar[a b="c"]>baz', { prefix: '>>>' }), result('bar[a b="c"]>baz', 6, 3));
// Absent prefix
strictEqual(extract('<foo>bar[a b="c"]>baz', { prefix: '&&' }), void 0);
});
it('brackets inside curly braces', () => {
deepStrictEqual(extract('foo div{[}+a{}'), result('div{[}+a{}', 4));
deepStrictEqual(extract('div{}}'), undefined);
deepStrictEqual(extract('div{{}'), result('{}', 4));
});
it('HTML test', () => {
const html = (str: string) => isAtHTMLTag(scanner(str));
// simple tag
ok(html('<div>'));
ok(html('<div/>'));
ok(html('<div />'));
ok(html('</div>'));
// tag with attributes
ok(html('<div foo="bar">'));
ok(html('<div foo=bar>'));
ok(html('<div foo>'));
ok(html('<div a="b" c=d>'));
ok(html('<div a=b c=d>'));
ok(html('<div a=^b$ c=d>'));
ok(html('<div a=b c=^%d]$>'));
ok(html('<div title=ะฟัะธะฒะตั>'));
ok(html('<div title=ะฟัะธะฒะตั123>'));
ok(html('<foo-bar>'));
// invalid tags
ok(!html('div>'));
ok(!html('<div'));
ok(!html('<div ะฟัะธะฒะตั>'));
ok(!html('<div =bar>'));
ok(!html('<div foo=>'));
ok(!html('[a=b c=d]>'));
ok(!html('div[a=b c=d]>'));
});
it('consume quotes', () => {
let s = scanner(' "foo"');
ok(consumeQuoted(s));
strictEqual(s.pos, 1);
s = scanner('"foo"');
ok(consumeQuoted(s));
strictEqual(s.pos, 0);
s = scanner('""');
ok(consumeQuoted(s));
strictEqual(s.pos, 0);
s = scanner('"a\\\"b"');
ok(consumeQuoted(s));
strictEqual(s.pos, 0);
// donโt eat anything
s = scanner('foo');
ok(!consumeQuoted(s));
strictEqual(s.pos, 3);
});
});
<MSG> Fixed issue with invalid HTML tag hit test when extracting abbreviation
<DFF> @@ -32,6 +32,11 @@ describe('Extract abbreviation', () => {
deepStrictEqual(extract('.foo img/'), result('img/', 5));
deepStrictEqual(extract('ัะตะบััdiv'), result('div', 5));
deepStrictEqual(extract('foo div[foo="ัะตะบัั" bar=ัะตะบัั2]'), result('div[foo="ัะตะบัั" bar=ัะตะบัั2]', 4));
+
+ // https://github.com/emmetio/emmet/issues/577
+ deepStrictEqual(
+ extract('table>(tr.prefix-intro>td*1)+(tr.prefix-pro-con>th*1+td*3)+(tr.prefix-key-specs>th[colspan=2]*1+td[colspan=2]*3)+(tr.prefix-key-find-online>th[colspan=2]*1+td*2)'),
+ result('table>(tr.prefix-intro>td*1)+(tr.prefix-pro-con>th*1+td*3)+(tr.prefix-key-specs>th[colspan=2]*1+td[colspan=2]*3)+(tr.prefix-key-find-online>th[colspan=2]*1+td*2)', 0));
});
it('abbreviation with operators', () => {
| 5 | Fixed issue with invalid HTML tag hit test when extracting abbreviation | 0 | .ts | ts | mit | emmetio/emmet |
10071595 | <NME> extract-abbreviation.ts
<BEF> import { deepStrictEqual, strictEqual, ok } from 'assert';
import extractAbbreviation, { ExtractOptions, ExtractedAbbreviation } from '../src/extract-abbreviation';
import isAtHTMLTag from '../src/extract-abbreviation/is-html';
import scanner from '../src/extract-abbreviation/reader';
import { consumeQuoted } from '../src/extract-abbreviation/quotes';
function extract(abbr: string, options?: Partial<ExtractOptions>) {
let caretPos: number | undefined = abbr.indexOf('|');
if (caretPos !== -1) {
abbr = abbr.slice(0, caretPos) + abbr.slice(caretPos + 1);
} else {
caretPos = void 0;
}
return extractAbbreviation(abbr, caretPos, options);
}
function result(abbreviation: string, location: number, start = location): ExtractedAbbreviation {
return {
abbreviation,
location,
start: start != null ? start : location,
end: location + abbreviation.length
};
}
describe('Extract abbreviation', () => {
it('basic', () => {
deepStrictEqual(extract('.bar'), result('.bar', 0));
deepStrictEqual(extract('.foo .bar'), result('.bar', 5));
deepStrictEqual(extract('.foo @bar'), result('@bar', 5));
deepStrictEqual(extract('.foo img/'), result('img/', 5));
deepStrictEqual(extract('ัะตะบััdiv'), result('div', 5));
deepStrictEqual(extract('foo div[foo="ัะตะบัั" bar=ัะตะบัั2]'), result('div[foo="ัะตะบัั" bar=ัะตะบัั2]', 4));
});
it('abbreviation with operators', () => {
deepStrictEqual(extract('a foo+bar.baz'), result('foo+bar.baz', 2));
deepStrictEqual(extract('a foo>bar+baz*3'), result('foo>bar+baz*3', 2));
});
it('abbreviation with attributes', () => {
deepStrictEqual(extract('a foo[bar|]'), result('foo[bar]', 2));
deepStrictEqual(extract('a foo[bar="baz" a b]'), result('foo[bar="baz" a b]', 2));
deepStrictEqual(extract('foo bar[a|] baz'), result('bar[a]', 4));
});
it('tag test', () => {
deepStrictEqual(extract('<foo>bar[a b="c"]>baz'), result('bar[a b="c"]>baz', 5));
deepStrictEqual(extract('foo>bar'), result('foo>bar', 0));
deepStrictEqual(extract('<foo>bar'), result('bar', 5));
deepStrictEqual(extract('<foo>bar[a="d" b="c"]>baz'), result('bar[a="d" b="c"]>baz', 5));
});
it('stylesheet abbreviation', () => {
deepStrictEqual(extract('foo{bar|}'), result('foo{bar}', 0));
deepStrictEqual(extract('foo{bar|}', { type: 'stylesheet' }), result('bar', 4));
});
it('prefixed extract', () => {
deepStrictEqual(extract('<foo>bar[a b="c"]>baz'), result('bar[a b="c"]>baz', 5));
deepStrictEqual(extract('<foo>bar[a b="c"]>baz', { prefix: '<' }), result('foo>bar[a b="c"]>baz', 1, 0));
deepStrictEqual(extract('<foo>bar[a b="<"]>baz', { prefix: '<' }), result('foo>bar[a b="<"]>baz', 1, 0));
deepStrictEqual(extract('<foo>bar{<}>baz', { prefix: '<' }), result('foo>bar{<}>baz', 1, 0));
// Multiple prefix characters
deepStrictEqual(extract('foo>>>bar[a b="c"]>baz', { prefix: '>>>' }), result('bar[a b="c"]>baz', 6, 3));
// Absent prefix
strictEqual(extract('<foo>bar[a b="c"]>baz', { prefix: '&&' }), void 0);
});
it('brackets inside curly braces', () => {
deepStrictEqual(extract('foo div{[}+a{}'), result('div{[}+a{}', 4));
deepStrictEqual(extract('div{}}'), undefined);
deepStrictEqual(extract('div{{}'), result('{}', 4));
});
it('HTML test', () => {
const html = (str: string) => isAtHTMLTag(scanner(str));
// simple tag
ok(html('<div>'));
ok(html('<div/>'));
ok(html('<div />'));
ok(html('</div>'));
// tag with attributes
ok(html('<div foo="bar">'));
ok(html('<div foo=bar>'));
ok(html('<div foo>'));
ok(html('<div a="b" c=d>'));
ok(html('<div a=b c=d>'));
ok(html('<div a=^b$ c=d>'));
ok(html('<div a=b c=^%d]$>'));
ok(html('<div title=ะฟัะธะฒะตั>'));
ok(html('<div title=ะฟัะธะฒะตั123>'));
ok(html('<foo-bar>'));
// invalid tags
ok(!html('div>'));
ok(!html('<div'));
ok(!html('<div ะฟัะธะฒะตั>'));
ok(!html('<div =bar>'));
ok(!html('<div foo=>'));
ok(!html('[a=b c=d]>'));
ok(!html('div[a=b c=d]>'));
});
it('consume quotes', () => {
let s = scanner(' "foo"');
ok(consumeQuoted(s));
strictEqual(s.pos, 1);
s = scanner('"foo"');
ok(consumeQuoted(s));
strictEqual(s.pos, 0);
s = scanner('""');
ok(consumeQuoted(s));
strictEqual(s.pos, 0);
s = scanner('"a\\\"b"');
ok(consumeQuoted(s));
strictEqual(s.pos, 0);
// donโt eat anything
s = scanner('foo');
ok(!consumeQuoted(s));
strictEqual(s.pos, 3);
});
});
<MSG> Fixed issue with invalid HTML tag hit test when extracting abbreviation
<DFF> @@ -32,6 +32,11 @@ describe('Extract abbreviation', () => {
deepStrictEqual(extract('.foo img/'), result('img/', 5));
deepStrictEqual(extract('ัะตะบััdiv'), result('div', 5));
deepStrictEqual(extract('foo div[foo="ัะตะบัั" bar=ัะตะบัั2]'), result('div[foo="ัะตะบัั" bar=ัะตะบัั2]', 4));
+
+ // https://github.com/emmetio/emmet/issues/577
+ deepStrictEqual(
+ extract('table>(tr.prefix-intro>td*1)+(tr.prefix-pro-con>th*1+td*3)+(tr.prefix-key-specs>th[colspan=2]*1+td[colspan=2]*3)+(tr.prefix-key-find-online>th[colspan=2]*1+td*2)'),
+ result('table>(tr.prefix-intro>td*1)+(tr.prefix-pro-con>th*1+td*3)+(tr.prefix-key-specs>th[colspan=2]*1+td[colspan=2]*3)+(tr.prefix-key-find-online>th[colspan=2]*1+td*2)', 0));
});
it('abbreviation with operators', () => {
| 5 | Fixed issue with invalid HTML tag hit test when extracting abbreviation | 0 | .ts | ts | mit | emmetio/emmet |
10071596 | <NME> button.spec.js
<BEF> ADDFILE
<MSG> Merge pull request #4 from Semantic-Org/semantic-ui-elements-button
Semantic-UI-Angular: sm-button directive
<DFF> @@ -0,0 +1,66 @@
+describe('Semantic-UI: Elements - smButton', function() {
+'use strict';
+
+ var $scope, $compile;
+
+ beforeEach(module('semantic.ui.elements.button'));
+
+ beforeEach(inject(function($rootScope, _$compile_) {
+ $scope = $rootScope.$new();
+ $compile = _$compile_;
+ }));
+
+ function getTagName(nodes) {
+ return nodes[0].tagName.toLocaleLowerCase();
+ }
+
+ it('has to be anchor tag if there is a href attribute', function() {
+ var smButton = $compile('<sm-button href=""></sm-button>')($scope);
+ $scope.$digest();
+
+ expect(getTagName(smButton)).toBe('a');
+ });
+
+ it('has to be anchor tag if there is a ng-href attribute', function() {
+ var smButton = $compile('<sm-button ng-href=""></sm-button>')($scope);
+ $scope.$digest();
+
+ expect(getTagName(smButton)).toBe('a');
+ });
+
+ it('has to be anchor tag if there is a xlink:href attribute', function() {
+ var smButton = $compile('<sm-button xlink:href=""></sm-button>')($scope);
+ $scope.$digest();
+
+ expect(getTagName(smButton)).toBe('a');
+ });
+
+ it('has to be button tag otherwise', function() {
+ var smButton = $compile('<sm-button></sm-button>')($scope);
+ $scope.$digest();
+
+ expect(getTagName(smButton)).toBe('button');
+ });
+
+ it('has to add aria-label attribute with textContent if one was not provided', function() {
+ var smButton = $compile('<sm-button>Button</sm-button>')($scope);
+ $scope.$digest();
+
+ expect(smButton[0].hasAttribute('aria-label')).toBe(true);
+ expect(smButton.attr('aria-label')).toBe('Button');
+ });
+
+ it('has to support custom aria-label arribute', function() {
+ var smButton = $compile('<sm-button aria-label="my cool button">Button</sm-button>')($scope);
+ $scope.$digest();
+
+ expect(smButton.attr('aria-label')).toBe('my cool button');
+ });
+
+ it('has to transclude textContent', function() {
+ var smButton = $compile('<sm-button>Button</sm-button>')($scope);
+ $scope.$digest();
+
+ expect(smButton.text()).toBe('Button');
+ });
+});
| 66 | Merge pull request #4 from Semantic-Org/semantic-ui-elements-button | 0 | .js | spec | mit | Semantic-Org/Semantic-UI-Angular |
10071597 | <NME> button.spec.js
<BEF> ADDFILE
<MSG> Merge pull request #4 from Semantic-Org/semantic-ui-elements-button
Semantic-UI-Angular: sm-button directive
<DFF> @@ -0,0 +1,66 @@
+describe('Semantic-UI: Elements - smButton', function() {
+'use strict';
+
+ var $scope, $compile;
+
+ beforeEach(module('semantic.ui.elements.button'));
+
+ beforeEach(inject(function($rootScope, _$compile_) {
+ $scope = $rootScope.$new();
+ $compile = _$compile_;
+ }));
+
+ function getTagName(nodes) {
+ return nodes[0].tagName.toLocaleLowerCase();
+ }
+
+ it('has to be anchor tag if there is a href attribute', function() {
+ var smButton = $compile('<sm-button href=""></sm-button>')($scope);
+ $scope.$digest();
+
+ expect(getTagName(smButton)).toBe('a');
+ });
+
+ it('has to be anchor tag if there is a ng-href attribute', function() {
+ var smButton = $compile('<sm-button ng-href=""></sm-button>')($scope);
+ $scope.$digest();
+
+ expect(getTagName(smButton)).toBe('a');
+ });
+
+ it('has to be anchor tag if there is a xlink:href attribute', function() {
+ var smButton = $compile('<sm-button xlink:href=""></sm-button>')($scope);
+ $scope.$digest();
+
+ expect(getTagName(smButton)).toBe('a');
+ });
+
+ it('has to be button tag otherwise', function() {
+ var smButton = $compile('<sm-button></sm-button>')($scope);
+ $scope.$digest();
+
+ expect(getTagName(smButton)).toBe('button');
+ });
+
+ it('has to add aria-label attribute with textContent if one was not provided', function() {
+ var smButton = $compile('<sm-button>Button</sm-button>')($scope);
+ $scope.$digest();
+
+ expect(smButton[0].hasAttribute('aria-label')).toBe(true);
+ expect(smButton.attr('aria-label')).toBe('Button');
+ });
+
+ it('has to support custom aria-label arribute', function() {
+ var smButton = $compile('<sm-button aria-label="my cool button">Button</sm-button>')($scope);
+ $scope.$digest();
+
+ expect(smButton.attr('aria-label')).toBe('my cool button');
+ });
+
+ it('has to transclude textContent', function() {
+ var smButton = $compile('<sm-button>Button</sm-button>')($scope);
+ $scope.$digest();
+
+ expect(smButton.text()).toBe('Button');
+ });
+});
| 66 | Merge pull request #4 from Semantic-Org/semantic-ui-elements-button | 0 | .js | spec | mit | Semantic-Org/Semantic-UI-Angular |
10071598 | <NME> button.spec.js
<BEF> ADDFILE
<MSG> Merge pull request #4 from Semantic-Org/semantic-ui-elements-button
Semantic-UI-Angular: sm-button directive
<DFF> @@ -0,0 +1,66 @@
+describe('Semantic-UI: Elements - smButton', function() {
+'use strict';
+
+ var $scope, $compile;
+
+ beforeEach(module('semantic.ui.elements.button'));
+
+ beforeEach(inject(function($rootScope, _$compile_) {
+ $scope = $rootScope.$new();
+ $compile = _$compile_;
+ }));
+
+ function getTagName(nodes) {
+ return nodes[0].tagName.toLocaleLowerCase();
+ }
+
+ it('has to be anchor tag if there is a href attribute', function() {
+ var smButton = $compile('<sm-button href=""></sm-button>')($scope);
+ $scope.$digest();
+
+ expect(getTagName(smButton)).toBe('a');
+ });
+
+ it('has to be anchor tag if there is a ng-href attribute', function() {
+ var smButton = $compile('<sm-button ng-href=""></sm-button>')($scope);
+ $scope.$digest();
+
+ expect(getTagName(smButton)).toBe('a');
+ });
+
+ it('has to be anchor tag if there is a xlink:href attribute', function() {
+ var smButton = $compile('<sm-button xlink:href=""></sm-button>')($scope);
+ $scope.$digest();
+
+ expect(getTagName(smButton)).toBe('a');
+ });
+
+ it('has to be button tag otherwise', function() {
+ var smButton = $compile('<sm-button></sm-button>')($scope);
+ $scope.$digest();
+
+ expect(getTagName(smButton)).toBe('button');
+ });
+
+ it('has to add aria-label attribute with textContent if one was not provided', function() {
+ var smButton = $compile('<sm-button>Button</sm-button>')($scope);
+ $scope.$digest();
+
+ expect(smButton[0].hasAttribute('aria-label')).toBe(true);
+ expect(smButton.attr('aria-label')).toBe('Button');
+ });
+
+ it('has to support custom aria-label arribute', function() {
+ var smButton = $compile('<sm-button aria-label="my cool button">Button</sm-button>')($scope);
+ $scope.$digest();
+
+ expect(smButton.attr('aria-label')).toBe('my cool button');
+ });
+
+ it('has to transclude textContent', function() {
+ var smButton = $compile('<sm-button>Button</sm-button>')($scope);
+ $scope.$digest();
+
+ expect(smButton.text()).toBe('Button');
+ });
+});
| 66 | Merge pull request #4 from Semantic-Org/semantic-ui-elements-button | 0 | .js | spec | mit | Semantic-Org/Semantic-UI-Angular |
10071599 | <NME> split.gemspec
<BEF> # -*- encoding: utf-8 -*-
# frozen_string_literal: true
$:.push File.expand_path("../lib", __FILE__)
require "split/version"
Gem::Specification.new do |s|
s.name = "split"
s.version = Split::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["Andrew Nesbitt"]
s.licenses = ["MIT"]
s.email = ["[email protected]"]
s.homepage = "https://github.com/splitrb/split"
s.summary = "Rack based split testing framework"
s.metadata = {
"homepage_uri" => "https://github.com/splitrb/split",
"changelog_uri" => "https://github.com/splitrb/split/blob/main/CHANGELOG.md",
"source_code_uri" => "https://github.com/splitrb/split",
"bug_tracker_uri" => "https://github.com/splitrb/split/issues",
"wiki_uri" => "https://github.com/splitrb/split/wiki",
"mailing_list_uri" => "https://groups.google.com/d/forum/split-ruby"
}
s.required_ruby_version = ">= 2.5.0"
s.required_rubygems_version = ">= 2.0.0"
end
s.add_development_dependency 'rake'
s.add_development_dependency 'bundler', '~> 1.3'
s.add_development_dependency 'rspec', '~> 2.14'
s.add_development_dependency 'rack-test', '>= 0.5.7'
s.add_development_dependency 'coveralls'
end
s.add_development_dependency "bundler", ">= 1.17"
s.add_development_dependency "simplecov", "~> 0.15"
s.add_development_dependency "rack-test", "~> 2.0"
s.add_development_dependency "rake", "~> 13"
s.add_development_dependency "rspec", "~> 3.7"
s.add_development_dependency "pry", "~> 0.10"
s.add_development_dependency "rails", ">= 5.0"
end
<MSG> Changed all .should calls to expects(thing).to for rspec 3
<DFF> @@ -29,8 +29,8 @@ Gem::Specification.new do |s|
end
s.add_development_dependency 'rake'
- s.add_development_dependency 'bundler', '~> 1.3'
- s.add_development_dependency 'rspec', '~> 2.14'
- s.add_development_dependency 'rack-test', '>= 0.5.7'
+ s.add_development_dependency 'bundler', '~> 1.6.5'
+ s.add_development_dependency 'rspec', '~> 3.0'
+ s.add_development_dependency 'rack-test', '~> 0.6.2'
s.add_development_dependency 'coveralls'
end
| 3 | Changed all .should calls to expects(thing).to for rspec 3 | 3 | .gemspec | gemspec | mit | splitrb/split |
10071600 | <NME> split.gemspec
<BEF> # -*- encoding: utf-8 -*-
# frozen_string_literal: true
$:.push File.expand_path("../lib", __FILE__)
require "split/version"
Gem::Specification.new do |s|
s.name = "split"
s.version = Split::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["Andrew Nesbitt"]
s.licenses = ["MIT"]
s.email = ["[email protected]"]
s.homepage = "https://github.com/splitrb/split"
s.summary = "Rack based split testing framework"
s.metadata = {
"homepage_uri" => "https://github.com/splitrb/split",
"changelog_uri" => "https://github.com/splitrb/split/blob/main/CHANGELOG.md",
"source_code_uri" => "https://github.com/splitrb/split",
"bug_tracker_uri" => "https://github.com/splitrb/split/issues",
"wiki_uri" => "https://github.com/splitrb/split/wiki",
"mailing_list_uri" => "https://groups.google.com/d/forum/split-ruby"
}
s.required_ruby_version = ">= 2.5.0"
s.required_rubygems_version = ">= 2.0.0"
end
s.add_development_dependency 'rake'
s.add_development_dependency 'bundler', '~> 1.3'
s.add_development_dependency 'rspec', '~> 2.14'
s.add_development_dependency 'rack-test', '>= 0.5.7'
s.add_development_dependency 'coveralls'
end
s.add_development_dependency "bundler", ">= 1.17"
s.add_development_dependency "simplecov", "~> 0.15"
s.add_development_dependency "rack-test", "~> 2.0"
s.add_development_dependency "rake", "~> 13"
s.add_development_dependency "rspec", "~> 3.7"
s.add_development_dependency "pry", "~> 0.10"
s.add_development_dependency "rails", ">= 5.0"
end
<MSG> Changed all .should calls to expects(thing).to for rspec 3
<DFF> @@ -29,8 +29,8 @@ Gem::Specification.new do |s|
end
s.add_development_dependency 'rake'
- s.add_development_dependency 'bundler', '~> 1.3'
- s.add_development_dependency 'rspec', '~> 2.14'
- s.add_development_dependency 'rack-test', '>= 0.5.7'
+ s.add_development_dependency 'bundler', '~> 1.6.5'
+ s.add_development_dependency 'rspec', '~> 3.0'
+ s.add_development_dependency 'rack-test', '~> 0.6.2'
s.add_development_dependency 'coveralls'
end
| 3 | Changed all .should calls to expects(thing).to for rspec 3 | 3 | .gemspec | gemspec | mit | splitrb/split |
10071601 | <NME> split.gemspec
<BEF> # -*- encoding: utf-8 -*-
# frozen_string_literal: true
$:.push File.expand_path("../lib", __FILE__)
require "split/version"
Gem::Specification.new do |s|
s.name = "split"
s.version = Split::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["Andrew Nesbitt"]
s.licenses = ["MIT"]
s.email = ["[email protected]"]
s.homepage = "https://github.com/splitrb/split"
s.summary = "Rack based split testing framework"
s.metadata = {
"homepage_uri" => "https://github.com/splitrb/split",
"changelog_uri" => "https://github.com/splitrb/split/blob/main/CHANGELOG.md",
"source_code_uri" => "https://github.com/splitrb/split",
"bug_tracker_uri" => "https://github.com/splitrb/split/issues",
"wiki_uri" => "https://github.com/splitrb/split/wiki",
"mailing_list_uri" => "https://groups.google.com/d/forum/split-ruby"
}
s.required_ruby_version = ">= 2.5.0"
s.required_rubygems_version = ">= 2.0.0"
end
s.add_development_dependency 'rake'
s.add_development_dependency 'bundler', '~> 1.3'
s.add_development_dependency 'rspec', '~> 2.14'
s.add_development_dependency 'rack-test', '>= 0.5.7'
s.add_development_dependency 'coveralls'
end
s.add_development_dependency "bundler", ">= 1.17"
s.add_development_dependency "simplecov", "~> 0.15"
s.add_development_dependency "rack-test", "~> 2.0"
s.add_development_dependency "rake", "~> 13"
s.add_development_dependency "rspec", "~> 3.7"
s.add_development_dependency "pry", "~> 0.10"
s.add_development_dependency "rails", ">= 5.0"
end
<MSG> Changed all .should calls to expects(thing).to for rspec 3
<DFF> @@ -29,8 +29,8 @@ Gem::Specification.new do |s|
end
s.add_development_dependency 'rake'
- s.add_development_dependency 'bundler', '~> 1.3'
- s.add_development_dependency 'rspec', '~> 2.14'
- s.add_development_dependency 'rack-test', '>= 0.5.7'
+ s.add_development_dependency 'bundler', '~> 1.6.5'
+ s.add_development_dependency 'rspec', '~> 3.0'
+ s.add_development_dependency 'rack-test', '~> 0.6.2'
s.add_development_dependency 'coveralls'
end
| 3 | Changed all .should calls to expects(thing).to for rspec 3 | 3 | .gemspec | gemspec | mit | splitrb/split |
10071602 | <NME> README
<BEF> =========================================
ChiShop/DjangoPyPI
=========================================
:Version: 0.1
Installation
============
Install dependencies::
$ python bootstrap.py --distribute
$ ./bin/buildout
Initial configuration
---------------------
::
$ $EDITOR chishop/settings.py
$ ./bin/django syncdb
Run the PyPI server
-------------------
::
$ ./bin/django runserver
Please note that ``chishop/media/dists`` has to be writable by the
user the web-server is running as.
In production
-------------
You may want to copy the file ``chishop/production_example.py`` and modify
for use as your production settings; you will also need to modify
``bin/django.wsgi`` to refer to your production settings.
Using Setuptools
================
Add the following to your ``~/.pypirc`` file::
[distutils]
index-servers =
pypi
local
[pypi]
username:user
password:secret
username:user
password:secret
repository:http://localhost:8000
Pushing a package to local PyPI
-----------------------------------
instead of using register and dist command, you can use "mregister" and "mupload", that are a backport of python 2.6 register and upload commands, that supports multiple servers.
To push the package to the local pypi::
$ python setup.py mregister sdist mupload -r local
If you don't have Python 2.6 please run the command below to install the backport of the extension::
$ easy_install -U collective.dist
.. # vim: syntax=rst expandtab tabstop=4 shiftwidth=4 shiftround
.. # vim: syntax=rst expandtab tabstop=4 shiftwidth=4 shiftround
<MSG> Merge branch 'russell/master'
<DFF> @@ -52,20 +52,27 @@ Add the following to your ``~/.pypirc`` file::
username:user
password:secret
-
repository:http://localhost:8000
-Pushing a package to local PyPI
------------------------------------
-
-instead of using register and dist command, you can use "mregister" and "mupload", that are a backport of python 2.6 register and upload commands, that supports multiple servers.
+Uploading a package: Python >=2.6
+--------------------------------------------
To push the package to the local pypi::
- $ python setup.py mregister sdist mupload -r local
+ $ python setup.py register sdist upload -r local
+
+
+Uploading a package: Python <2.6
+-------------------------------------------
If you don't have Python 2.6 please run the command below to install the backport of the extension::
$ easy_install -U collective.dist
+instead of using register and dist command, you can use "mregister" and "mupload", that are a backport of python 2.6 register and upload commands, that supports multiple servers.
+
+To push the package to the local pypi::
+
+ $ python setup.py mregister sdist mupload -r local
+
.. # vim: syntax=rst expandtab tabstop=4 shiftwidth=4 shiftround
| 13 | Merge branch 'russell/master' | 6 | README | bsd-3-clause | ask/chishop |
|
10071603 | <NME> trial_spec.rb
<BEF> # frozen_string_literal: true
require "spec_helper"
require "split/trial"
describe Split::Trial do
let(:user) { mock_user }
let(:alternatives) { ["basket", "cart"] }
let(:experiment) do
Split::Experiment.new("basket_text", alternatives: alternatives).save
end
it "should be initializeable" do
experiment = double("experiment")
alternative = double("alternative", kind_of?: Split::Alternative)
trial = Split::Trial.new(experiment: experiment, alternative: alternative)
expect(trial.experiment).to eq(experiment)
end
it "should populate alternative with a full alternative object after calling choose" do
experiment = Split::Experiment.new('basket_text', :alternative_names => ['basket', 'cart'])
experiment.save
trial = Split::Trial.new(:experiment => experiment)
trial.choose
alternative: alternative, user: user)
expect(trial).not_to receive(:choose)
end
it "should populate an alternative when only one option is offerred" do
experiment = Split::Experiment.new('basket_text', :alternative_names => ['basket'])
experiment.save
trial = Split::Trial.new(:experiment => experiment)
trial.choose
trial = Split::Trial.new(experiment: experiment, alternative: "basket")
expect(trial.alternative.name).to eq("basket")
end
end
describe "metadata" do
let(:metadata) { Hash[alternatives.map { |k| [k, "Metadata for #{k}"] }] }
let(:experiment) do
Split::Experiment.new("basket_text", alternatives: alternatives, metadata: metadata).save
end
it "has metadata on each trial" do
trial = Split::Trial.new(experiment: experiment, user: user, metadata: metadata["cart"],
override: "cart")
expect(trial.metadata).to eq(metadata["cart"])
describe "alternative_name" do
it "should load the alternative when the alternative name is set" do
experiment = Split::Experiment.new('basket_text', :alternative_names => ['basket', "cart"])
experiment.save
trial = Split::Trial.new(:experiment => experiment, :alternative_name => 'basket')
end
end
describe "#choose!" do
let(:context) { double(on_trial_callback: "test callback") }
let(:trial) do
Split::Trial.new(user: user, experiment: experiment)
end
shared_examples_for "a trial with callbacks" do
it "does not run if on_trial callback is not respondable" do
Split.configuration.on_trial = :foo
allow(context).to receive(:respond_to?).with(:foo, true).and_return false
expect(context).to_not receive(:foo)
trial.choose! context
end
it "runs on_trial callback" do
Split.configuration.on_trial = :on_trial_callback
expect(context).to receive(:on_trial_callback)
trial.choose! context
end
it "does not run nil on_trial callback" do
Split.configuration.on_trial = nil
expect(context).not_to receive(:on_trial_callback)
trial.choose! context
end
end
def expect_alternative(trial, alternative_name)
3.times do
trial.choose! context
expect(alternative_name).to include(trial.alternative.name)
end
end
context "when override is present" do
let(:override) { "cart" }
let(:trial) do
Split::Trial.new(user: user, experiment: experiment, override: override)
end
it_behaves_like "a trial with callbacks"
it "picks the override" do
expect(experiment).to_not receive(:next_alternative)
expect_alternative(trial, override)
end
context "when alternative doesn't exist" do
let(:override) { nil }
it "falls back on next_alternative" do
expect(experiment).to receive(:next_alternative).and_call_original
expect_alternative(trial, alternatives)
end
end
end
context "when disabled option is true" do
let(:trial) do
Split::Trial.new(user: user, experiment: experiment, disabled: true)
end
it "picks the control", :aggregate_failures do
Split.configuration.on_trial = :on_trial_callback
expect(experiment).to_not receive(:next_alternative)
expect(context).not_to receive(:on_trial_callback)
expect_alternative(trial, "basket")
Split.configuration.on_trial = nil
end
end
context "when Split is globally disabled" do
it "picks the control and does not run on_trial callbacks", :aggregate_failures do
Split.configuration.enabled = false
Split.configuration.on_trial = :on_trial_callback
expect(experiment).to_not receive(:next_alternative)
expect(context).not_to receive(:on_trial_callback)
expect_alternative(trial, "basket")
Split.configuration.enabled = true
Split.configuration.on_trial = nil
end
end
context "when experiment has winner" do
let(:trial) do
Split::Trial.new(user: user, experiment: experiment)
end
it_behaves_like "a trial with callbacks"
it "picks the winner" do
experiment.winner = "cart"
expect(experiment).to_not receive(:next_alternative)
expect_alternative(trial, "cart")
end
end
context "when exclude is true" do
let(:trial) do
Split::Trial.new(user: user, experiment: experiment, exclude: true)
end
it_behaves_like "a trial with callbacks"
it "picks the control" do
expect(experiment).to_not receive(:next_alternative)
expect_alternative(trial, "basket")
end
end
context "when user is already participating" do
it_behaves_like "a trial with callbacks"
it "picks the same alternative" do
user[experiment.key] = "basket"
expect(experiment).to_not receive(:next_alternative)
expect_alternative(trial, "basket")
end
context "when alternative is not found" do
it "falls back on next_alternative" do
user[experiment.key] = "notfound"
expect(experiment).to receive(:next_alternative).and_call_original
expect_alternative(trial, alternatives)
end
end
end
context "when user is a new participant" do
it "picks a new alternative and runs on_trial_choose callback", :aggregate_failures do
Split.configuration.on_trial_choose = :on_trial_choose_callback
expect(experiment).to receive(:next_alternative).and_call_original
expect(context).to receive(:on_trial_choose_callback)
trial.choose! context
expect(trial.alternative.name).to_not be_empty
Split.configuration.on_trial_choose = nil
end
it "assigns user to an alternative" do
trial.choose! context
expect(alternatives).to include(user[experiment.name])
end
context "when cohorting is disabled" do
before(:each) { allow(experiment).to receive(:cohorting_disabled?).and_return(true) }
it "picks the control and does not run on_trial callbacks" do
Split.configuration.on_trial = :on_trial_callback
expect(experiment).to_not receive(:next_alternative)
expect(context).not_to receive(:on_trial_callback)
expect_alternative(trial, "basket")
Split.configuration.enabled = true
Split.configuration.on_trial = nil
end
it "user is not assigned an alternative" do
trial.choose! context
expect(user[experiment]).to eq(nil)
end
end
end
end
describe "#complete!" do
context "when there are no goals" do
let(:trial) { Split::Trial.new(user: user, experiment: experiment) }
it "should complete the trial" do
trial.choose!
old_completed_count = trial.alternative.completed_count
trial.complete!
expect(trial.alternative.completed_count).to eq(old_completed_count + 1)
end
end
context "when there are many goals" do
let(:goals) { [ "goal1", "goal2" ] }
let(:trial) { Split::Trial.new(user: user, experiment: experiment, goals: goals) }
it "increments the completed count corresponding to the goals" do
trial.choose!
old_completed_counts = goals.map { |goal| [goal, trial.alternative.completed_count(goal)] }.to_h
trial.complete!
goals.each { | goal | expect(trial.alternative.completed_count(goal)).to eq(old_completed_counts[goal] + 1) }
end
end
context "when there is 1 goal of type string" do
let(:goal) { "goal" }
let(:trial) { Split::Trial.new(user: user, experiment: experiment, goals: goal) }
it "increments the completed count corresponding to the goal" do
trial.choose!
old_completed_count = trial.alternative.completed_count(goal)
trial.complete!
expect(trial.alternative.completed_count(goal)).to eq(old_completed_count + 1)
end
end
end
describe "alternative recording" do
before(:each) { Split.configuration.store_override = false }
context "when override is present" do
it "stores when store_override is true" do
trial = Split::Trial.new(user: user, experiment: experiment, override: "basket")
Split.configuration.store_override = true
expect(user).to receive("[]=")
trial.choose!
expect(trial.alternative.participant_count).to eq(1)
end
it "does not store when store_override is false" do
trial = Split::Trial.new(user: user, experiment: experiment, override: "basket")
expect(user).to_not receive("[]=")
trial.choose!
end
end
context "when disabled is present" do
it "stores when store_override is true" do
trial = Split::Trial.new(user: user, experiment: experiment, disabled: true)
Split.configuration.store_override = true
expect(user).to receive("[]=")
trial.choose!
end
it "does not store when store_override is false" do
trial = Split::Trial.new(user: user, experiment: experiment, disabled: true)
expect(user).to_not receive("[]=")
trial.choose!
end
end
context "when exclude is present" do
it "does not store" do
trial = Split::Trial.new(user: user, experiment: experiment, exclude: true)
expect(user).to_not receive("[]=")
trial.choose!
end
end
context "when experiment has winner" do
let(:trial) do
experiment.winner = "cart"
Split::Trial.new(user: user, experiment: experiment)
end
it "does not store" do
expect(user).to_not receive("[]=")
trial.choose!
end
end
end
end
<MSG> Remove :alternative_names
The distinction between this and :alternatives is no longer needed.
<DFF> @@ -18,7 +18,7 @@ describe Split::Trial do
end
it "should populate alternative with a full alternative object after calling choose" do
- experiment = Split::Experiment.new('basket_text', :alternative_names => ['basket', 'cart'])
+ experiment = Split::Experiment.new('basket_text', :alternatives => ['basket', 'cart'])
experiment.save
trial = Split::Trial.new(:experiment => experiment)
trial.choose
@@ -27,7 +27,7 @@ describe Split::Trial do
end
it "should populate an alternative when only one option is offerred" do
- experiment = Split::Experiment.new('basket_text', :alternative_names => ['basket'])
+ experiment = Split::Experiment.new('basket_text', :alternatives => ['basket'])
experiment.save
trial = Split::Trial.new(:experiment => experiment)
trial.choose
@@ -49,7 +49,7 @@ describe Split::Trial do
describe "alternative_name" do
it "should load the alternative when the alternative name is set" do
- experiment = Split::Experiment.new('basket_text', :alternative_names => ['basket', "cart"])
+ experiment = Split::Experiment.new('basket_text', :alternatives => ['basket', "cart"])
experiment.save
trial = Split::Trial.new(:experiment => experiment, :alternative_name => 'basket')
| 3 | Remove :alternative_names | 3 | .rb | rb | mit | splitrb/split |
10071604 | <NME> trial_spec.rb
<BEF> # frozen_string_literal: true
require "spec_helper"
require "split/trial"
describe Split::Trial do
let(:user) { mock_user }
let(:alternatives) { ["basket", "cart"] }
let(:experiment) do
Split::Experiment.new("basket_text", alternatives: alternatives).save
end
it "should be initializeable" do
experiment = double("experiment")
alternative = double("alternative", kind_of?: Split::Alternative)
trial = Split::Trial.new(experiment: experiment, alternative: alternative)
expect(trial.experiment).to eq(experiment)
end
it "should populate alternative with a full alternative object after calling choose" do
experiment = Split::Experiment.new('basket_text', :alternative_names => ['basket', 'cart'])
experiment.save
trial = Split::Trial.new(:experiment => experiment)
trial.choose
alternative: alternative, user: user)
expect(trial).not_to receive(:choose)
end
it "should populate an alternative when only one option is offerred" do
experiment = Split::Experiment.new('basket_text', :alternative_names => ['basket'])
experiment.save
trial = Split::Trial.new(:experiment => experiment)
trial.choose
trial = Split::Trial.new(experiment: experiment, alternative: "basket")
expect(trial.alternative.name).to eq("basket")
end
end
describe "metadata" do
let(:metadata) { Hash[alternatives.map { |k| [k, "Metadata for #{k}"] }] }
let(:experiment) do
Split::Experiment.new("basket_text", alternatives: alternatives, metadata: metadata).save
end
it "has metadata on each trial" do
trial = Split::Trial.new(experiment: experiment, user: user, metadata: metadata["cart"],
override: "cart")
expect(trial.metadata).to eq(metadata["cart"])
describe "alternative_name" do
it "should load the alternative when the alternative name is set" do
experiment = Split::Experiment.new('basket_text', :alternative_names => ['basket', "cart"])
experiment.save
trial = Split::Trial.new(:experiment => experiment, :alternative_name => 'basket')
end
end
describe "#choose!" do
let(:context) { double(on_trial_callback: "test callback") }
let(:trial) do
Split::Trial.new(user: user, experiment: experiment)
end
shared_examples_for "a trial with callbacks" do
it "does not run if on_trial callback is not respondable" do
Split.configuration.on_trial = :foo
allow(context).to receive(:respond_to?).with(:foo, true).and_return false
expect(context).to_not receive(:foo)
trial.choose! context
end
it "runs on_trial callback" do
Split.configuration.on_trial = :on_trial_callback
expect(context).to receive(:on_trial_callback)
trial.choose! context
end
it "does not run nil on_trial callback" do
Split.configuration.on_trial = nil
expect(context).not_to receive(:on_trial_callback)
trial.choose! context
end
end
def expect_alternative(trial, alternative_name)
3.times do
trial.choose! context
expect(alternative_name).to include(trial.alternative.name)
end
end
context "when override is present" do
let(:override) { "cart" }
let(:trial) do
Split::Trial.new(user: user, experiment: experiment, override: override)
end
it_behaves_like "a trial with callbacks"
it "picks the override" do
expect(experiment).to_not receive(:next_alternative)
expect_alternative(trial, override)
end
context "when alternative doesn't exist" do
let(:override) { nil }
it "falls back on next_alternative" do
expect(experiment).to receive(:next_alternative).and_call_original
expect_alternative(trial, alternatives)
end
end
end
context "when disabled option is true" do
let(:trial) do
Split::Trial.new(user: user, experiment: experiment, disabled: true)
end
it "picks the control", :aggregate_failures do
Split.configuration.on_trial = :on_trial_callback
expect(experiment).to_not receive(:next_alternative)
expect(context).not_to receive(:on_trial_callback)
expect_alternative(trial, "basket")
Split.configuration.on_trial = nil
end
end
context "when Split is globally disabled" do
it "picks the control and does not run on_trial callbacks", :aggregate_failures do
Split.configuration.enabled = false
Split.configuration.on_trial = :on_trial_callback
expect(experiment).to_not receive(:next_alternative)
expect(context).not_to receive(:on_trial_callback)
expect_alternative(trial, "basket")
Split.configuration.enabled = true
Split.configuration.on_trial = nil
end
end
context "when experiment has winner" do
let(:trial) do
Split::Trial.new(user: user, experiment: experiment)
end
it_behaves_like "a trial with callbacks"
it "picks the winner" do
experiment.winner = "cart"
expect(experiment).to_not receive(:next_alternative)
expect_alternative(trial, "cart")
end
end
context "when exclude is true" do
let(:trial) do
Split::Trial.new(user: user, experiment: experiment, exclude: true)
end
it_behaves_like "a trial with callbacks"
it "picks the control" do
expect(experiment).to_not receive(:next_alternative)
expect_alternative(trial, "basket")
end
end
context "when user is already participating" do
it_behaves_like "a trial with callbacks"
it "picks the same alternative" do
user[experiment.key] = "basket"
expect(experiment).to_not receive(:next_alternative)
expect_alternative(trial, "basket")
end
context "when alternative is not found" do
it "falls back on next_alternative" do
user[experiment.key] = "notfound"
expect(experiment).to receive(:next_alternative).and_call_original
expect_alternative(trial, alternatives)
end
end
end
context "when user is a new participant" do
it "picks a new alternative and runs on_trial_choose callback", :aggregate_failures do
Split.configuration.on_trial_choose = :on_trial_choose_callback
expect(experiment).to receive(:next_alternative).and_call_original
expect(context).to receive(:on_trial_choose_callback)
trial.choose! context
expect(trial.alternative.name).to_not be_empty
Split.configuration.on_trial_choose = nil
end
it "assigns user to an alternative" do
trial.choose! context
expect(alternatives).to include(user[experiment.name])
end
context "when cohorting is disabled" do
before(:each) { allow(experiment).to receive(:cohorting_disabled?).and_return(true) }
it "picks the control and does not run on_trial callbacks" do
Split.configuration.on_trial = :on_trial_callback
expect(experiment).to_not receive(:next_alternative)
expect(context).not_to receive(:on_trial_callback)
expect_alternative(trial, "basket")
Split.configuration.enabled = true
Split.configuration.on_trial = nil
end
it "user is not assigned an alternative" do
trial.choose! context
expect(user[experiment]).to eq(nil)
end
end
end
end
describe "#complete!" do
context "when there are no goals" do
let(:trial) { Split::Trial.new(user: user, experiment: experiment) }
it "should complete the trial" do
trial.choose!
old_completed_count = trial.alternative.completed_count
trial.complete!
expect(trial.alternative.completed_count).to eq(old_completed_count + 1)
end
end
context "when there are many goals" do
let(:goals) { [ "goal1", "goal2" ] }
let(:trial) { Split::Trial.new(user: user, experiment: experiment, goals: goals) }
it "increments the completed count corresponding to the goals" do
trial.choose!
old_completed_counts = goals.map { |goal| [goal, trial.alternative.completed_count(goal)] }.to_h
trial.complete!
goals.each { | goal | expect(trial.alternative.completed_count(goal)).to eq(old_completed_counts[goal] + 1) }
end
end
context "when there is 1 goal of type string" do
let(:goal) { "goal" }
let(:trial) { Split::Trial.new(user: user, experiment: experiment, goals: goal) }
it "increments the completed count corresponding to the goal" do
trial.choose!
old_completed_count = trial.alternative.completed_count(goal)
trial.complete!
expect(trial.alternative.completed_count(goal)).to eq(old_completed_count + 1)
end
end
end
describe "alternative recording" do
before(:each) { Split.configuration.store_override = false }
context "when override is present" do
it "stores when store_override is true" do
trial = Split::Trial.new(user: user, experiment: experiment, override: "basket")
Split.configuration.store_override = true
expect(user).to receive("[]=")
trial.choose!
expect(trial.alternative.participant_count).to eq(1)
end
it "does not store when store_override is false" do
trial = Split::Trial.new(user: user, experiment: experiment, override: "basket")
expect(user).to_not receive("[]=")
trial.choose!
end
end
context "when disabled is present" do
it "stores when store_override is true" do
trial = Split::Trial.new(user: user, experiment: experiment, disabled: true)
Split.configuration.store_override = true
expect(user).to receive("[]=")
trial.choose!
end
it "does not store when store_override is false" do
trial = Split::Trial.new(user: user, experiment: experiment, disabled: true)
expect(user).to_not receive("[]=")
trial.choose!
end
end
context "when exclude is present" do
it "does not store" do
trial = Split::Trial.new(user: user, experiment: experiment, exclude: true)
expect(user).to_not receive("[]=")
trial.choose!
end
end
context "when experiment has winner" do
let(:trial) do
experiment.winner = "cart"
Split::Trial.new(user: user, experiment: experiment)
end
it "does not store" do
expect(user).to_not receive("[]=")
trial.choose!
end
end
end
end
<MSG> Remove :alternative_names
The distinction between this and :alternatives is no longer needed.
<DFF> @@ -18,7 +18,7 @@ describe Split::Trial do
end
it "should populate alternative with a full alternative object after calling choose" do
- experiment = Split::Experiment.new('basket_text', :alternative_names => ['basket', 'cart'])
+ experiment = Split::Experiment.new('basket_text', :alternatives => ['basket', 'cart'])
experiment.save
trial = Split::Trial.new(:experiment => experiment)
trial.choose
@@ -27,7 +27,7 @@ describe Split::Trial do
end
it "should populate an alternative when only one option is offerred" do
- experiment = Split::Experiment.new('basket_text', :alternative_names => ['basket'])
+ experiment = Split::Experiment.new('basket_text', :alternatives => ['basket'])
experiment.save
trial = Split::Trial.new(:experiment => experiment)
trial.choose
@@ -49,7 +49,7 @@ describe Split::Trial do
describe "alternative_name" do
it "should load the alternative when the alternative name is set" do
- experiment = Split::Experiment.new('basket_text', :alternative_names => ['basket', "cart"])
+ experiment = Split::Experiment.new('basket_text', :alternatives => ['basket', "cart"])
experiment.save
trial = Split::Trial.new(:experiment => experiment, :alternative_name => 'basket')
| 3 | Remove :alternative_names | 3 | .rb | rb | mit | splitrb/split |
10071605 | <NME> trial_spec.rb
<BEF> # frozen_string_literal: true
require "spec_helper"
require "split/trial"
describe Split::Trial do
let(:user) { mock_user }
let(:alternatives) { ["basket", "cart"] }
let(:experiment) do
Split::Experiment.new("basket_text", alternatives: alternatives).save
end
it "should be initializeable" do
experiment = double("experiment")
alternative = double("alternative", kind_of?: Split::Alternative)
trial = Split::Trial.new(experiment: experiment, alternative: alternative)
expect(trial.experiment).to eq(experiment)
end
it "should populate alternative with a full alternative object after calling choose" do
experiment = Split::Experiment.new('basket_text', :alternative_names => ['basket', 'cart'])
experiment.save
trial = Split::Trial.new(:experiment => experiment)
trial.choose
alternative: alternative, user: user)
expect(trial).not_to receive(:choose)
end
it "should populate an alternative when only one option is offerred" do
experiment = Split::Experiment.new('basket_text', :alternative_names => ['basket'])
experiment.save
trial = Split::Trial.new(:experiment => experiment)
trial.choose
trial = Split::Trial.new(experiment: experiment, alternative: "basket")
expect(trial.alternative.name).to eq("basket")
end
end
describe "metadata" do
let(:metadata) { Hash[alternatives.map { |k| [k, "Metadata for #{k}"] }] }
let(:experiment) do
Split::Experiment.new("basket_text", alternatives: alternatives, metadata: metadata).save
end
it "has metadata on each trial" do
trial = Split::Trial.new(experiment: experiment, user: user, metadata: metadata["cart"],
override: "cart")
expect(trial.metadata).to eq(metadata["cart"])
describe "alternative_name" do
it "should load the alternative when the alternative name is set" do
experiment = Split::Experiment.new('basket_text', :alternative_names => ['basket', "cart"])
experiment.save
trial = Split::Trial.new(:experiment => experiment, :alternative_name => 'basket')
end
end
describe "#choose!" do
let(:context) { double(on_trial_callback: "test callback") }
let(:trial) do
Split::Trial.new(user: user, experiment: experiment)
end
shared_examples_for "a trial with callbacks" do
it "does not run if on_trial callback is not respondable" do
Split.configuration.on_trial = :foo
allow(context).to receive(:respond_to?).with(:foo, true).and_return false
expect(context).to_not receive(:foo)
trial.choose! context
end
it "runs on_trial callback" do
Split.configuration.on_trial = :on_trial_callback
expect(context).to receive(:on_trial_callback)
trial.choose! context
end
it "does not run nil on_trial callback" do
Split.configuration.on_trial = nil
expect(context).not_to receive(:on_trial_callback)
trial.choose! context
end
end
def expect_alternative(trial, alternative_name)
3.times do
trial.choose! context
expect(alternative_name).to include(trial.alternative.name)
end
end
context "when override is present" do
let(:override) { "cart" }
let(:trial) do
Split::Trial.new(user: user, experiment: experiment, override: override)
end
it_behaves_like "a trial with callbacks"
it "picks the override" do
expect(experiment).to_not receive(:next_alternative)
expect_alternative(trial, override)
end
context "when alternative doesn't exist" do
let(:override) { nil }
it "falls back on next_alternative" do
expect(experiment).to receive(:next_alternative).and_call_original
expect_alternative(trial, alternatives)
end
end
end
context "when disabled option is true" do
let(:trial) do
Split::Trial.new(user: user, experiment: experiment, disabled: true)
end
it "picks the control", :aggregate_failures do
Split.configuration.on_trial = :on_trial_callback
expect(experiment).to_not receive(:next_alternative)
expect(context).not_to receive(:on_trial_callback)
expect_alternative(trial, "basket")
Split.configuration.on_trial = nil
end
end
context "when Split is globally disabled" do
it "picks the control and does not run on_trial callbacks", :aggregate_failures do
Split.configuration.enabled = false
Split.configuration.on_trial = :on_trial_callback
expect(experiment).to_not receive(:next_alternative)
expect(context).not_to receive(:on_trial_callback)
expect_alternative(trial, "basket")
Split.configuration.enabled = true
Split.configuration.on_trial = nil
end
end
context "when experiment has winner" do
let(:trial) do
Split::Trial.new(user: user, experiment: experiment)
end
it_behaves_like "a trial with callbacks"
it "picks the winner" do
experiment.winner = "cart"
expect(experiment).to_not receive(:next_alternative)
expect_alternative(trial, "cart")
end
end
context "when exclude is true" do
let(:trial) do
Split::Trial.new(user: user, experiment: experiment, exclude: true)
end
it_behaves_like "a trial with callbacks"
it "picks the control" do
expect(experiment).to_not receive(:next_alternative)
expect_alternative(trial, "basket")
end
end
context "when user is already participating" do
it_behaves_like "a trial with callbacks"
it "picks the same alternative" do
user[experiment.key] = "basket"
expect(experiment).to_not receive(:next_alternative)
expect_alternative(trial, "basket")
end
context "when alternative is not found" do
it "falls back on next_alternative" do
user[experiment.key] = "notfound"
expect(experiment).to receive(:next_alternative).and_call_original
expect_alternative(trial, alternatives)
end
end
end
context "when user is a new participant" do
it "picks a new alternative and runs on_trial_choose callback", :aggregate_failures do
Split.configuration.on_trial_choose = :on_trial_choose_callback
expect(experiment).to receive(:next_alternative).and_call_original
expect(context).to receive(:on_trial_choose_callback)
trial.choose! context
expect(trial.alternative.name).to_not be_empty
Split.configuration.on_trial_choose = nil
end
it "assigns user to an alternative" do
trial.choose! context
expect(alternatives).to include(user[experiment.name])
end
context "when cohorting is disabled" do
before(:each) { allow(experiment).to receive(:cohorting_disabled?).and_return(true) }
it "picks the control and does not run on_trial callbacks" do
Split.configuration.on_trial = :on_trial_callback
expect(experiment).to_not receive(:next_alternative)
expect(context).not_to receive(:on_trial_callback)
expect_alternative(trial, "basket")
Split.configuration.enabled = true
Split.configuration.on_trial = nil
end
it "user is not assigned an alternative" do
trial.choose! context
expect(user[experiment]).to eq(nil)
end
end
end
end
describe "#complete!" do
context "when there are no goals" do
let(:trial) { Split::Trial.new(user: user, experiment: experiment) }
it "should complete the trial" do
trial.choose!
old_completed_count = trial.alternative.completed_count
trial.complete!
expect(trial.alternative.completed_count).to eq(old_completed_count + 1)
end
end
context "when there are many goals" do
let(:goals) { [ "goal1", "goal2" ] }
let(:trial) { Split::Trial.new(user: user, experiment: experiment, goals: goals) }
it "increments the completed count corresponding to the goals" do
trial.choose!
old_completed_counts = goals.map { |goal| [goal, trial.alternative.completed_count(goal)] }.to_h
trial.complete!
goals.each { | goal | expect(trial.alternative.completed_count(goal)).to eq(old_completed_counts[goal] + 1) }
end
end
context "when there is 1 goal of type string" do
let(:goal) { "goal" }
let(:trial) { Split::Trial.new(user: user, experiment: experiment, goals: goal) }
it "increments the completed count corresponding to the goal" do
trial.choose!
old_completed_count = trial.alternative.completed_count(goal)
trial.complete!
expect(trial.alternative.completed_count(goal)).to eq(old_completed_count + 1)
end
end
end
describe "alternative recording" do
before(:each) { Split.configuration.store_override = false }
context "when override is present" do
it "stores when store_override is true" do
trial = Split::Trial.new(user: user, experiment: experiment, override: "basket")
Split.configuration.store_override = true
expect(user).to receive("[]=")
trial.choose!
expect(trial.alternative.participant_count).to eq(1)
end
it "does not store when store_override is false" do
trial = Split::Trial.new(user: user, experiment: experiment, override: "basket")
expect(user).to_not receive("[]=")
trial.choose!
end
end
context "when disabled is present" do
it "stores when store_override is true" do
trial = Split::Trial.new(user: user, experiment: experiment, disabled: true)
Split.configuration.store_override = true
expect(user).to receive("[]=")
trial.choose!
end
it "does not store when store_override is false" do
trial = Split::Trial.new(user: user, experiment: experiment, disabled: true)
expect(user).to_not receive("[]=")
trial.choose!
end
end
context "when exclude is present" do
it "does not store" do
trial = Split::Trial.new(user: user, experiment: experiment, exclude: true)
expect(user).to_not receive("[]=")
trial.choose!
end
end
context "when experiment has winner" do
let(:trial) do
experiment.winner = "cart"
Split::Trial.new(user: user, experiment: experiment)
end
it "does not store" do
expect(user).to_not receive("[]=")
trial.choose!
end
end
end
end
<MSG> Remove :alternative_names
The distinction between this and :alternatives is no longer needed.
<DFF> @@ -18,7 +18,7 @@ describe Split::Trial do
end
it "should populate alternative with a full alternative object after calling choose" do
- experiment = Split::Experiment.new('basket_text', :alternative_names => ['basket', 'cart'])
+ experiment = Split::Experiment.new('basket_text', :alternatives => ['basket', 'cart'])
experiment.save
trial = Split::Trial.new(:experiment => experiment)
trial.choose
@@ -27,7 +27,7 @@ describe Split::Trial do
end
it "should populate an alternative when only one option is offerred" do
- experiment = Split::Experiment.new('basket_text', :alternative_names => ['basket'])
+ experiment = Split::Experiment.new('basket_text', :alternatives => ['basket'])
experiment.save
trial = Split::Trial.new(:experiment => experiment)
trial.choose
@@ -49,7 +49,7 @@ describe Split::Trial do
describe "alternative_name" do
it "should load the alternative when the alternative name is set" do
- experiment = Split::Experiment.new('basket_text', :alternative_names => ['basket', "cart"])
+ experiment = Split::Experiment.new('basket_text', :alternatives => ['basket', "cart"])
experiment.save
trial = Split::Trial.new(:experiment => experiment, :alternative_name => 'basket')
| 3 | Remove :alternative_names | 3 | .rb | rb | mit | splitrb/split |
10071606 | <NME> format.ts
<BEF> import { CSSAbbreviation, CSSProperty, Value, CSSValue, NumberValue } from '@emmetio/css-abbreviation';
import createOutputStream, { OutputStream, push, pushString, pushField, pushNewline } from '../output-stream';
import { Config } from '../config';
import color, { frac } from './color';
import { CSSAbbreviationScope } from './scope';
export default function css(abbr: CSSAbbreviation, config: Config): string {
const out = createOutputStream(config.options);
const format = config.options['output.format'];
if (config.context?.name === CSSAbbreviationScope.Section) {
// For section context, filter out unmatched snippets
abbr = abbr.filter(node => node.snippet);
}
for (let i = 0; i < abbr.length; i++) {
if (format && i !== 0) {
pushNewline(out, true);
}
property(abbr[i], out, config);
}
return out.value;
}
/**
* Outputs given abbreviation node into output stream
*/
function property(node: CSSProperty, out: OutputStream, config: Config) {
const isJSON = config.options['stylesheet.json'];
if (node.name) {
// Itโs a CSS property
const name = isJSON ? toCamelCase(node.name) : node.name;
pushString(out, name + config.options['stylesheet.between']);
if (node.value.length) {
propertyValue(node, out, config);
} else {
pushField(out, 0, '');
}
if (isJSON) {
// For CSS-in-JS, always finalize property with comma
// NB: seems like `important` is not available in CSS-in-JS syntaxes
push(out, ',');
} else {
outputImportant(node, out, true);
push(out, config.options['stylesheet.after']);
}
} else {
// Itโs a regular snippet, output plain tokens without any additional formatting
for (const cssVal of node.value) {
for (const v of cssVal.value) {
outputToken(v, out, config);
}
}
outputImportant(node, out, node.value.length > 0);
}
}
function propertyValue(node: CSSProperty, out: OutputStream, config: Config) {
const isJSON = config.options['stylesheet.json'];
const num = isJSON ? getSingleNumeric(node) : null;
if (num && (!num.unit || num.unit === 'px')) {
// For CSS-in-JS, if property contains single numeric value, output it
// as JS number
push(out, String(num.value));
} else {
const quote = getQuote(config);
isJSON && push(out, quote);
for (let i = 0; i < node.value.length; i++) {
if (i !== 0) {
push(out, ', ');
}
outputValue(node.value[i], out, config);
}
isJSON && push(out, quote);
}
}
function outputImportant(node: CSSProperty, out: OutputStream, separator?: boolean) {
if (node.important) {
if (separator) {
push(out, ' ');
}
push(out, '!important');
}
}
function outputValue(value: CSSValue, out: OutputStream, config: Config) {
for (let i = 0, prevEnd = -1; i < value.value.length; i++) {
const token = value.value[i];
// Handle edge case: a field is written close to previous token like this: `foo${bar}`.
// We should not add delimiter here
if (i !== 0 && (token.type !== 'Field' || token.start !== prevEnd)) {
push(out, ' ');
}
outputToken(token, out, config);
prevEnd = token['end'];
}
}
function outputToken(token: Value, out: OutputStream, config: Config) {
if (token.type === 'ColorValue') {
push(out, color(token, config.options['stylesheet.shortHex']));
} else if (token.type === 'Literal') {
pushString(out, token.value);
} else if (token.type === 'NumberValue') {
pushString(out, frac(token.value, 4) + token.unit);
} else if (token.type === 'StringValue') {
const quote = token.quote === 'double' ? '"' : '\'';
pushString(out, quote + token.value + quote);
} else if (token.type === 'Field') {
pushField(out, token.index!, token.name);
} else if (token.type === 'FunctionCall') {
push(out, token.name + '(');
for (let i = 0; i < token.arguments.length; i++) {
if (i) {
push(out, ', ');
}
outputValue(token.arguments[i], out, config);
}
push(out, ')');
}
}
/**
* If value of given property is a single numeric value, returns this token
*/
function getSingleNumeric(node: CSSProperty): NumberValue | void {
if (node.value.length === 1) {
const cssVal = node.value[0]!;
if (cssVal.value.length === 1 && cssVal.value[0]!.type === 'NumberValue') {
return cssVal.value[0] as NumberValue;
}
}
}
/**
* Converts kebab-case string to camelCase
*/
function toCamelCase(str: string): string {
return str.replace(/\-(\w)/g, (_, letter: string) => letter.toUpperCase());
}
function getQuote(config: Config): string {
return config.options['stylesheet.jsonDoubleQuotes'] ? '"' : '\'';
}
<MSG> Fixed reference to CSSAbbreviationScope
<DFF> @@ -2,7 +2,7 @@ import { CSSAbbreviation, CSSProperty, Value, CSSValue, NumberValue } from '@emm
import createOutputStream, { OutputStream, push, pushString, pushField, pushNewline } from '../output-stream';
import { Config } from '../config';
import color, { frac } from './color';
-import { CSSAbbreviationScope } from './scope';
+import { CSSAbbreviationScope } from './';
export default function css(abbr: CSSAbbreviation, config: Config): string {
const out = createOutputStream(config.options);
| 1 | Fixed reference to CSSAbbreviationScope | 1 | .ts | ts | mit | emmetio/emmet |
10071607 | <NME> format.ts
<BEF> import { CSSAbbreviation, CSSProperty, Value, CSSValue, NumberValue } from '@emmetio/css-abbreviation';
import createOutputStream, { OutputStream, push, pushString, pushField, pushNewline } from '../output-stream';
import { Config } from '../config';
import color, { frac } from './color';
import { CSSAbbreviationScope } from './scope';
export default function css(abbr: CSSAbbreviation, config: Config): string {
const out = createOutputStream(config.options);
const format = config.options['output.format'];
if (config.context?.name === CSSAbbreviationScope.Section) {
// For section context, filter out unmatched snippets
abbr = abbr.filter(node => node.snippet);
}
for (let i = 0; i < abbr.length; i++) {
if (format && i !== 0) {
pushNewline(out, true);
}
property(abbr[i], out, config);
}
return out.value;
}
/**
* Outputs given abbreviation node into output stream
*/
function property(node: CSSProperty, out: OutputStream, config: Config) {
const isJSON = config.options['stylesheet.json'];
if (node.name) {
// Itโs a CSS property
const name = isJSON ? toCamelCase(node.name) : node.name;
pushString(out, name + config.options['stylesheet.between']);
if (node.value.length) {
propertyValue(node, out, config);
} else {
pushField(out, 0, '');
}
if (isJSON) {
// For CSS-in-JS, always finalize property with comma
// NB: seems like `important` is not available in CSS-in-JS syntaxes
push(out, ',');
} else {
outputImportant(node, out, true);
push(out, config.options['stylesheet.after']);
}
} else {
// Itโs a regular snippet, output plain tokens without any additional formatting
for (const cssVal of node.value) {
for (const v of cssVal.value) {
outputToken(v, out, config);
}
}
outputImportant(node, out, node.value.length > 0);
}
}
function propertyValue(node: CSSProperty, out: OutputStream, config: Config) {
const isJSON = config.options['stylesheet.json'];
const num = isJSON ? getSingleNumeric(node) : null;
if (num && (!num.unit || num.unit === 'px')) {
// For CSS-in-JS, if property contains single numeric value, output it
// as JS number
push(out, String(num.value));
} else {
const quote = getQuote(config);
isJSON && push(out, quote);
for (let i = 0; i < node.value.length; i++) {
if (i !== 0) {
push(out, ', ');
}
outputValue(node.value[i], out, config);
}
isJSON && push(out, quote);
}
}
function outputImportant(node: CSSProperty, out: OutputStream, separator?: boolean) {
if (node.important) {
if (separator) {
push(out, ' ');
}
push(out, '!important');
}
}
function outputValue(value: CSSValue, out: OutputStream, config: Config) {
for (let i = 0, prevEnd = -1; i < value.value.length; i++) {
const token = value.value[i];
// Handle edge case: a field is written close to previous token like this: `foo${bar}`.
// We should not add delimiter here
if (i !== 0 && (token.type !== 'Field' || token.start !== prevEnd)) {
push(out, ' ');
}
outputToken(token, out, config);
prevEnd = token['end'];
}
}
function outputToken(token: Value, out: OutputStream, config: Config) {
if (token.type === 'ColorValue') {
push(out, color(token, config.options['stylesheet.shortHex']));
} else if (token.type === 'Literal') {
pushString(out, token.value);
} else if (token.type === 'NumberValue') {
pushString(out, frac(token.value, 4) + token.unit);
} else if (token.type === 'StringValue') {
const quote = token.quote === 'double' ? '"' : '\'';
pushString(out, quote + token.value + quote);
} else if (token.type === 'Field') {
pushField(out, token.index!, token.name);
} else if (token.type === 'FunctionCall') {
push(out, token.name + '(');
for (let i = 0; i < token.arguments.length; i++) {
if (i) {
push(out, ', ');
}
outputValue(token.arguments[i], out, config);
}
push(out, ')');
}
}
/**
* If value of given property is a single numeric value, returns this token
*/
function getSingleNumeric(node: CSSProperty): NumberValue | void {
if (node.value.length === 1) {
const cssVal = node.value[0]!;
if (cssVal.value.length === 1 && cssVal.value[0]!.type === 'NumberValue') {
return cssVal.value[0] as NumberValue;
}
}
}
/**
* Converts kebab-case string to camelCase
*/
function toCamelCase(str: string): string {
return str.replace(/\-(\w)/g, (_, letter: string) => letter.toUpperCase());
}
function getQuote(config: Config): string {
return config.options['stylesheet.jsonDoubleQuotes'] ? '"' : '\'';
}
<MSG> Fixed reference to CSSAbbreviationScope
<DFF> @@ -2,7 +2,7 @@ import { CSSAbbreviation, CSSProperty, Value, CSSValue, NumberValue } from '@emm
import createOutputStream, { OutputStream, push, pushString, pushField, pushNewline } from '../output-stream';
import { Config } from '../config';
import color, { frac } from './color';
-import { CSSAbbreviationScope } from './scope';
+import { CSSAbbreviationScope } from './';
export default function css(abbr: CSSAbbreviation, config: Config): string {
const out = createOutputStream(config.options);
| 1 | Fixed reference to CSSAbbreviationScope | 1 | .ts | ts | mit | emmetio/emmet |
10071608 | <NME> icons.svg <BEF> ADDFILE <MSG> chore(docs-app): Update assets for index page <DFF> @@ -0,0 +1,504 @@ +<?xml version="1.0" standalone="no"?> +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" > +<svg xmlns="http://www.w3.org/2000/svg"> +<metadata></metadata> +<defs> +<font id="fontawesomeregular" horiz-adv-x="1536" > +<font-face units-per-em="1792" ascent="1536" descent="-256" /> +<missing-glyph horiz-adv-x="448" /> +<glyph unicode=" " horiz-adv-x="448" /> +<glyph unicode="	" horiz-adv-x="448" /> +<glyph unicode=" " horiz-adv-x="448" /> +<glyph unicode="¨" horiz-adv-x="1792" /> +<glyph unicode="©" horiz-adv-x="1792" /> +<glyph unicode="®" horiz-adv-x="1792" /> +<glyph unicode="´" horiz-adv-x="1792" /> +<glyph unicode="Æ" horiz-adv-x="1792" /> +<glyph unicode="Ø" horiz-adv-x="1792" /> +<glyph unicode=" " horiz-adv-x="768" /> +<glyph unicode=" " horiz-adv-x="1537" /> +<glyph unicode=" " horiz-adv-x="768" /> +<glyph unicode=" " horiz-adv-x="1537" /> +<glyph unicode=" " horiz-adv-x="512" /> +<glyph unicode=" " horiz-adv-x="384" /> +<glyph unicode=" " horiz-adv-x="256" /> +<glyph unicode=" " horiz-adv-x="256" /> +<glyph unicode=" " horiz-adv-x="192" /> +<glyph unicode=" " horiz-adv-x="307" /> +<glyph unicode=" " horiz-adv-x="85" /> +<glyph unicode=" " horiz-adv-x="307" /> +<glyph unicode=" " horiz-adv-x="384" /> +<glyph unicode="™" horiz-adv-x="1792" /> +<glyph unicode="∞" horiz-adv-x="1792" /> +<glyph unicode="≠" horiz-adv-x="1792" /> +<glyph unicode="◼" horiz-adv-x="500" d="M0 0z" /> +<glyph unicode="" horiz-adv-x="1792" d="M93 1350q0 23 18 36.5t38 17.5t43 4h1408q23 0 43 -4t38 -17.5t18 -36.5q0 -35 -43 -78l-632 -632v-768h320q26 0 45 -19t19 -45t-19 -45t-45 -19h-896q-26 0 -45 19t-19 45t19 45t45 19h320v768l-632 632q-43 43 -43 78z" /> +<glyph unicode="" d="M0 -64q0 50 34 89t86 60.5t103.5 32t96.5 10.5q105 0 192 -39v967q0 31 19 56.5t49 35.5l832 256q12 4 28 4q40 0 68 -28t28 -68v-1120q0 -50 -34 -89t-86 -60.5t-103.5 -32t-96.5 -10.5t-96.5 10.5t-103.5 32t-86 60.5t-34 89t34 89t86 60.5t103.5 32t96.5 10.5 q105 0 192 -39v537l-768 -237v-709q0 -50 -34 -89t-86 -60.5t-103.5 -32t-96.5 -10.5t-96.5 10.5t-103.5 32t-86 60.5t-34 89z" /> +<glyph unicode="" horiz-adv-x="1664" d="M0 704q0 143 55.5 273.5t150 225t225 150t273.5 55.5t273.5 -55.5t225 -150t150 -225t55.5 -273.5q0 -220 -124 -399l343 -343q37 -37 37 -90q0 -52 -38 -90t-90 -38q-54 0 -90 38l-343 342q-179 -124 -399 -124q-143 0 -273.5 55.5t-225 150t-150 225t-55.5 273.5z M256 704q0 -185 131.5 -316.5t316.5 -131.5t316.5 131.5t131.5 316.5t-131.5 316.5t-316.5 131.5t-316.5 -131.5t-131.5 -316.5z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 32v1088q0 66 47 113t113 47h1472q66 0 113 -47t47 -113v-1088q0 -66 -47 -113t-113 -47h-1472q-66 0 -113 47t-47 113zM128 32q0 -13 9.5 -22.5t22.5 -9.5h1472q13 0 22.5 9.5t9.5 22.5v768q-32 -36 -69 -66q-268 -206 -426 -338q-51 -43 -83 -67t-86.5 -48.5 t-102.5 -24.5h-1h-1q-48 0 -102.5 24.5t-86.5 48.5t-83 67q-158 132 -426 338q-37 30 -69 66v-768zM128 1120q0 -168 147 -284q193 -152 401 -317q6 -5 35 -29.5t46 -37.5t44.5 -31.5t50.5 -27.5t43 -9h1h1q20 0 43 9t50.5 27.5t44.5 31.5t46 37.5t35 29.5q208 165 401 317 q54 43 100.5 115.5t46.5 131.5v11v13.5t-0.5 13t-3 12.5t-5.5 9t-9 7.5t-14 2.5h-1472q-13 0 -22.5 -9.5t-9.5 -22.5z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 940q0 220 127 344t351 124q62 0 126.5 -21.5t120 -58t95.5 -68.5t76 -68q36 36 76 68t95.5 68.5t120 58t126.5 21.5q224 0 351 -124t127 -344q0 -221 -229 -450l-623 -600q-18 -18 -44 -18t-44 18l-624 602q-10 8 -27.5 26t-55.5 65.5t-68 97.5t-53.5 121t-23.5 138z " /> +<glyph unicode="" horiz-adv-x="1664" d="M0 889q0 37 56 46l502 73l225 455q19 41 49 41t49 -41l225 -455l502 -73q56 -9 56 -46q0 -22 -26 -48l-363 -354l86 -500q1 -7 1 -20q0 -21 -10.5 -35.5t-30.5 -14.5q-19 0 -40 12l-449 236l-449 -236q-22 -12 -40 -12q-21 0 -31.5 14.5t-10.5 35.5q0 6 2 20l86 500 l-364 354q-25 27 -25 48z" /> +<glyph unicode="" horiz-adv-x="1664" d="M0 889q0 37 56 46l502 73l225 455q19 41 49 41t49 -41l225 -455l502 -73q56 -9 56 -46q0 -22 -26 -48l-363 -354l86 -500q1 -7 1 -20q0 -50 -41 -50q-19 0 -40 12l-449 236l-449 -236q-22 -12 -40 -12q-21 0 -31.5 14.5t-10.5 35.5q0 6 2 20l86 500l-364 354 q-25 27 -25 48zM221 829l306 -297l-73 -421l378 199l377 -199l-72 421l306 297l-422 62l-189 382l-189 -382z" /> +<glyph unicode="" horiz-adv-x="1408" d="M0 131q0 53 3.5 103.5t14 109t26.5 108.5t43 97.5t62 81t85.5 53.5t111.5 20q9 0 42 -21.5t74.5 -48t108 -48t133.5 -21.5t133.5 21.5t108 48t74.5 48t42 21.5q61 0 111.5 -20t85.5 -53.5t62 -81t43 -97.5t26.5 -108.5t14 -109t3.5 -103.5q0 -120 -73 -189.5t-194 -69.5 h-874q-121 0 -194 69.5t-73 189.5zM320 1024q0 159 112.5 271.5t271.5 112.5t271.5 -112.5t112.5 -271.5t-112.5 -271.5t-271.5 -112.5t-271.5 112.5t-112.5 271.5z" /> +<glyph unicode="" horiz-adv-x="1920" d="M0 -96v1344q0 66 47 113t113 47h1600q66 0 113 -47t47 -113v-1344q0 -66 -47 -113t-113 -47h-1600q-66 0 -113 47t-47 113zM128 64v-128q0 -26 19 -45t45 -19h128q26 0 45 19t19 45v128q0 26 -19 45t-45 19h-128q-26 0 -45 -19t-19 -45zM128 320q0 -26 19 -45t45 -19h128 q26 0 45 19t19 45v128q0 26 -19 45t-45 19h-128q-26 0 -45 -19t-19 -45v-128zM128 704q0 -26 19 -45t45 -19h128q26 0 45 19t19 45v128q0 26 -19 45t-45 19h-128q-26 0 -45 -19t-19 -45v-128zM128 1088q0 -26 19 -45t45 -19h128q26 0 45 19t19 45v128q0 26 -19 45t-45 19 h-128q-26 0 -45 -19t-19 -45v-128zM512 -64q0 -26 19 -45t45 -19h768q26 0 45 19t19 45v512q0 26 -19 45t-45 19h-768q-26 0 -45 -19t-19 -45v-512zM512 704q0 -26 19 -45t45 -19h768q26 0 45 19t19 45v512q0 26 -19 45t-45 19h-768q-26 0 -45 -19t-19 -45v-512zM1536 64 v-128q0 -26 19 -45t45 -19h128q26 0 45 19t19 45v128q0 26 -19 45t-45 19h-128q-26 0 -45 -19t-19 -45zM1536 320q0 -26 19 -45t45 -19h128q26 0 45 19t19 45v128q0 26 -19 45t-45 19h-128q-26 0 -45 -19t-19 -45v-128zM1536 704q0 -26 19 -45t45 -19h128q26 0 45 19t19 45 v128q0 26 -19 45t-45 19h-128q-26 0 -45 -19t-19 -45v-128zM1536 1088q0 -26 19 -45t45 -19h128q26 0 45 19t19 45v128q0 26 -19 45t-45 19h-128q-26 0 -45 -19t-19 -45v-128z" /> +<glyph unicode="" horiz-adv-x="1664" d="M0 128v384q0 52 38 90t90 38h512q52 0 90 -38t38 -90v-384q0 -52 -38 -90t-90 -38h-512q-52 0 -90 38t-38 90zM0 896v384q0 52 38 90t90 38h512q52 0 90 -38t38 -90v-384q0 -52 -38 -90t-90 -38h-512q-52 0 -90 38t-38 90zM896 128v384q0 52 38 90t90 38h512q52 0 90 -38 t38 -90v-384q0 -52 -38 -90t-90 -38h-512q-52 0 -90 38t-38 90zM896 896v384q0 52 38 90t90 38h512q52 0 90 -38t38 -90v-384q0 -52 -38 -90t-90 -38h-512q-52 0 -90 38t-38 90z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 96v192q0 40 28 68t68 28h320q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-320q-40 0 -68 28t-28 68zM0 608v192q0 40 28 68t68 28h320q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-320q-40 0 -68 28t-28 68zM0 1120v192q0 40 28 68t68 28h320q40 0 68 -28 t28 -68v-192q0 -40 -28 -68t-68 -28h-320q-40 0 -68 28t-28 68zM640 96v192q0 40 28 68t68 28h320q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-320q-40 0 -68 28t-28 68zM640 608v192q0 40 28 68t68 28h320q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-320 q-40 0 -68 28t-28 68zM640 1120v192q0 40 28 68t68 28h320q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-320q-40 0 -68 28t-28 68zM1280 96v192q0 40 28 68t68 28h320q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-320q-40 0 -68 28t-28 68zM1280 608v192 q0 40 28 68t68 28h320q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-320q-40 0 -68 28t-28 68zM1280 1120v192q0 40 28 68t68 28h320q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-320q-40 0 -68 28t-28 68z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 96v192q0 40 28 68t68 28h320q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-320q-40 0 -68 28t-28 68zM0 608v192q0 40 28 68t68 28h320q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-320q-40 0 -68 28t-28 68zM0 1120v192q0 40 28 68t68 28h320q40 0 68 -28 t28 -68v-192q0 -40 -28 -68t-68 -28h-320q-40 0 -68 28t-28 68zM640 96v192q0 40 28 68t68 28h960q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-960q-40 0 -68 28t-28 68zM640 608v192q0 40 28 68t68 28h960q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-960 q-40 0 -68 28t-28 68zM640 1120v192q0 40 28 68t68 28h960q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-960q-40 0 -68 28t-28 68z" /> +<glyph unicode="" horiz-adv-x="1792" d="M121 608q0 40 28 68l136 136q28 28 68 28t68 -28l294 -295l656 657q28 28 68 28t68 -28l136 -136q28 -28 28 -68t-28 -68l-724 -724l-136 -136q-28 -28 -68 -28t-68 28l-136 136l-362 362q-28 28 -28 68z" /> +<glyph unicode="" horiz-adv-x="1408" d="M110 214q0 40 28 68l294 294l-294 294q-28 28 -28 68t28 68l136 136q28 28 68 28t68 -28l294 -294l294 294q28 28 68 28t68 -28l136 -136q28 -28 28 -68t-28 -68l-294 -294l294 -294q28 -28 28 -68t-28 -68l-136 -136q-28 -28 -68 -28t-68 28l-294 294l-294 -294 q-28 -28 -68 -28t-68 28l-136 136q-28 28 -28 68z" /> +<glyph unicode="" horiz-adv-x="1664" d="M0 704q0 143 55.5 273.5t150 225t225 150t273.5 55.5t273.5 -55.5t225 -150t150 -225t55.5 -273.5q0 -220 -124 -399l343 -343q37 -37 37 -90t-37.5 -90.5t-90.5 -37.5q-54 0 -90 38l-343 342q-179 -124 -399 -124q-143 0 -273.5 55.5t-225 150t-150 225t-55.5 273.5z M256 704q0 -185 131.5 -316.5t316.5 -131.5t316.5 131.5t131.5 316.5t-131.5 316.5t-316.5 131.5t-316.5 -131.5t-131.5 -316.5zM384 672v64q0 13 9.5 22.5t22.5 9.5h224v224q0 13 9.5 22.5t22.5 9.5h64q13 0 22.5 -9.5t9.5 -22.5v-224h224q13 0 22.5 -9.5t9.5 -22.5v-64 q0 -13 -9.5 -22.5t-22.5 -9.5h-224v-224q0 -13 -9.5 -22.5t-22.5 -9.5h-64q-13 0 -22.5 9.5t-9.5 22.5v224h-224q-13 0 -22.5 9.5t-9.5 22.5z" /> +<glyph unicode="" horiz-adv-x="1664" d="M0 704q0 143 55.5 273.5t150 225t225 150t273.5 55.5t273.5 -55.5t225 -150t150 -225t55.5 -273.5q0 -220 -124 -399l343 -343q37 -37 37 -90t-37.5 -90.5t-90.5 -37.5q-54 0 -90 38l-343 342q-179 -124 -399 -124q-143 0 -273.5 55.5t-225 150t-150 225t-55.5 273.5z M256 704q0 -185 131.5 -316.5t316.5 -131.5t316.5 131.5t131.5 316.5t-131.5 316.5t-316.5 131.5t-316.5 -131.5t-131.5 -316.5zM384 672v64q0 13 9.5 22.5t22.5 9.5h576q13 0 22.5 -9.5t9.5 -22.5v-64q0 -13 -9.5 -22.5t-22.5 -9.5h-576q-13 0 -22.5 9.5t-9.5 22.5z" /> +<glyph unicode="" d="M0 640q0 182 80.5 343t226.5 270q43 32 95.5 25t83.5 -50q32 -42 24.5 -94.5t-49.5 -84.5q-98 -74 -151.5 -181t-53.5 -228q0 -104 40.5 -198.5t109.5 -163.5t163.5 -109.5t198.5 -40.5t198.5 40.5t163.5 109.5t109.5 163.5t40.5 198.5q0 121 -53.5 228t-151.5 181 q-42 32 -49.5 84.5t24.5 94.5q31 43 84 50t95 -25q146 -109 226.5 -270t80.5 -343q0 -156 -61 -298t-164 -245t-245 -164t-298 -61t-298 61t-245 164t-164 245t-61 298zM640 768v640q0 52 38 90t90 38t90 -38t38 -90v-640q0 -52 -38 -90t-90 -38t-90 38t-38 90z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 -96v192q0 14 9 23t23 9h192q14 0 23 -9t9 -23v-192q0 -14 -9 -23t-23 -9h-192q-14 0 -23 9t-9 23zM384 -96v320q0 14 9 23t23 9h192q14 0 23 -9t9 -23v-320q0 -14 -9 -23t-23 -9h-192q-14 0 -23 9t-9 23zM768 -96v576q0 14 9 23t23 9h192q14 0 23 -9t9 -23v-576 q0 -14 -9 -23t-23 -9h-192q-14 0 -23 9t-9 23zM1152 -96v960q0 14 9 23t23 9h192q14 0 23 -9t9 -23v-960q0 -14 -9 -23t-23 -9h-192q-14 0 -23 9t-9 23zM1536 -96v1472q0 14 9 23t23 9h192q14 0 23 -9t9 -23v-1472q0 -14 -9 -23t-23 -9h-192q-14 0 -23 9t-9 23z" /> +<glyph unicode="" d="M0 531v222q0 12 8 23t19 13l186 28q14 46 39 92q-40 57 -107 138q-10 12 -10 24q0 10 9 23q26 36 98.5 107.5t94.5 71.5q13 0 26 -10l138 -107q44 23 91 38q16 136 29 186q7 28 36 28h222q14 0 24.5 -8.5t11.5 -21.5l28 -184q49 -16 90 -37l142 107q9 9 24 9q13 0 25 -10 q129 -119 165 -170q7 -8 7 -22q0 -12 -8 -23q-15 -21 -51 -66.5t-54 -70.5q26 -50 41 -98l183 -28q13 -2 21 -12.5t8 -23.5v-222q0 -12 -8 -23t-20 -13l-185 -28q-19 -54 -39 -91q35 -50 107 -138q10 -12 10 -25t-9 -23q-27 -37 -99 -108t-94 -71q-12 0 -26 9l-138 108 q-44 -23 -91 -38q-16 -136 -29 -186q-7 -28 -36 -28h-222q-14 0 -24.5 8.5t-11.5 21.5l-28 184q-49 16 -90 37l-141 -107q-10 -9 -25 -9q-14 0 -25 11q-126 114 -165 168q-7 10 -7 23q0 12 8 23q15 21 51 66.5t54 70.5q-27 50 -41 99l-183 27q-13 2 -21 12.5t-8 23.5z M512 640q0 -106 75 -181t181 -75t181 75t75 181t-75 181t-181 75t-181 -75t-75 -181z" /> +<glyph unicode="" horiz-adv-x="1408" d="M0 1056v64q0 14 9 23t23 9h309l70 167q15 37 54 63t79 26h320q40 0 79 -26t54 -63l70 -167h309q14 0 23 -9t9 -23v-64q0 -14 -9 -23t-23 -9h-96v-948q0 -83 -47 -143.5t-113 -60.5h-832q-66 0 -113 58.5t-47 141.5v952h-96q-14 0 -23 9t-9 23zM256 76q0 -22 7 -40.5 t14.5 -27t10.5 -8.5h832q3 0 10.5 8.5t14.5 27t7 40.5v948h-896v-948zM384 224v576q0 14 9 23t23 9h64q14 0 23 -9t9 -23v-576q0 -14 -9 -23t-23 -9h-64q-14 0 -23 9t-9 23zM480 1152h448l-48 117q-7 9 -17 11h-317q-10 -2 -17 -11zM640 224v576q0 14 9 23t23 9h64 q14 0 23 -9t9 -23v-576q0 -14 -9 -23t-23 -9h-64q-14 0 -23 9t-9 23zM896 224v576q0 14 9 23t23 9h64q14 0 23 -9t9 -23v-576q0 -14 -9 -23t-23 -9h-64q-14 0 -23 9t-9 23z" /> +<glyph unicode="" horiz-adv-x="1664" d="M26 636.5q1 13.5 11 21.5l719 599q32 26 76 26t76 -26l244 -204v195q0 14 9 23t23 9h192q14 0 23 -9t9 -23v-408l219 -182q10 -8 11 -21.5t-7 -23.5l-62 -74q-8 -9 -21 -11h-3q-13 0 -21 7l-692 577l-692 -577q-12 -8 -24 -7q-13 2 -21 11l-62 74q-8 10 -7 23.5zM256 64 v480q0 1 0.5 3t0.5 3l575 474l575 -474q1 -2 1 -6v-480q0 -26 -19 -45t-45 -19h-384v384h-256v-384h-384q-26 0 -45 19t-19 45z" /> +<glyph unicode="" d="M0 -160v1600q0 40 28 68t68 28h896q40 0 88 -20t76 -48l312 -312q28 -28 48 -76t20 -88v-1152q0 -40 -28 -68t-68 -28h-1344q-40 0 -68 28t-28 68zM128 -128h1280v1024h-416q-40 0 -68 28t-28 68v416h-768v-1536zM1024 1024h376q-10 29 -22 41l-313 313q-12 12 -41 22 v-376z" /> +<glyph unicode="" d="M0 640q0 209 103 385.5t279.5 279.5t385.5 103t385.5 -103t279.5 -279.5t103 -385.5t-103 -385.5t-279.5 -279.5t-385.5 -103t-385.5 103t-279.5 279.5t-103 385.5zM224 640q0 -148 73 -273t198 -198t273 -73t273 73t198 198t73 273t-73 273t-198 198t-273 73t-273 -73 t-198 -198t-73 -273zM512 544v64q0 14 9 23t23 9h224v352q0 14 9 23t23 9h64q14 0 23 -9t9 -23v-448q0 -14 -9 -23t-23 -9h-320q-14 0 -23 9t-9 23z" /> +<glyph unicode="" horiz-adv-x="1920" d="M50 73q0 54 26 116l417 1044q8 19 26 33t38 14h339q-13 0 -23 -9.5t-11 -22.5l-15 -192q-1 -14 8 -23t22 -9h166q13 0 22 9t8 23l-15 192q-1 13 -11 22.5t-23 9.5h339q20 0 38 -14t26 -33l417 -1044q26 -62 26 -116q0 -73 -46 -73h-704q13 0 22 9.5t8 22.5l-20 256 q-1 13 -11 22.5t-23 9.5h-272q-13 0 -23 -9.5t-11 -22.5l-20 -256q-1 -13 8 -22.5t22 -9.5h-704q-46 0 -46 73zM809 540q-1 -12 8 -20t21 -8h244q12 0 21 8t8 20v4l-24 320q-1 13 -11 22.5t-23 9.5h-186q-13 0 -23 -9.5t-11 -22.5l-24 -320v-4z" /> +<glyph unicode="" horiz-adv-x="1664" d="M0 96v320q0 40 28 68t68 28h465l135 -136q58 -56 136 -56t136 56l136 136h464q40 0 68 -28t28 -68v-320q0 -40 -28 -68t-68 -28h-1472q-40 0 -68 28t-28 68zM325 985q17 39 59 39h256v448q0 26 19 45t45 19h256q26 0 45 -19t19 -45v-448h256q42 0 59 -39q17 -41 -14 -70 l-448 -448q-18 -19 -45 -19t-45 19l-448 448q-31 29 -14 70zM1152 192q0 -26 19 -45t45 -19t45 19t19 45t-19 45t-45 19t-45 -19t-19 -45zM1408 192q0 -26 19 -45t45 -19t45 19t19 45t-19 45t-45 19t-45 -19t-19 -45z" /> +<glyph unicode="" d="M0 640q0 209 103 385.5t279.5 279.5t385.5 103t385.5 -103t279.5 -279.5t103 -385.5t-103 -385.5t-279.5 -279.5t-385.5 -103t-385.5 103t-279.5 279.5t-103 385.5zM224 640q0 -148 73 -273t198 -198t273 -73t273 73t198 198t73 273t-73 273t-198 198t-273 73t-273 -73 t-198 -198t-73 -273zM418 620q8 20 30 20h192v352q0 14 9 23t23 9h192q14 0 23 -9t9 -23v-352h192q14 0 23 -9t9 -23q0 -12 -10 -24l-319 -319q-11 -9 -23 -9t-23 9l-320 320q-15 16 -7 35z" /> +<glyph unicode="" d="M0 640q0 209 103 385.5t279.5 279.5t385.5 103t385.5 -103t279.5 -279.5t103 -385.5t-103 -385.5t-279.5 -279.5t-385.5 -103t-385.5 103t-279.5 279.5t-103 385.5zM224 640q0 -148 73 -273t198 -198t273 -73t273 73t198 198t73 273t-73 273t-198 198t-273 73t-273 -73 t-198 -198t-73 -273zM416 672q0 12 10 24l319 319q11 9 23 9t23 -9l320 -320q15 -16 7 -35q-8 -20 -30 -20h-192v-352q0 -14 -9 -23t-23 -9h-192q-14 0 -23 9t-9 23v352h-192q-14 0 -23 9t-9 23z" /> +<glyph unicode="" d="M0 64v482q0 62 25 123l238 552q10 25 36.5 42t52.5 17h832q26 0 52.5 -17t36.5 -42l238 -552q25 -61 25 -123v-482q0 -26 -19 -45t-45 -19h-1408q-26 0 -45 19t-19 45zM197 576h316l95 -192h320l95 192h316q-1 3 -2.5 8t-2.5 8l-212 496h-708l-212 -496q-1 -2 -2.5 -8 t-2.5 -8z" /> +<glyph unicode="" d="M0 640q0 209 103 385.5t279.5 279.5t385.5 103t385.5 -103t279.5 -279.5t103 -385.5t-103 -385.5t-279.5 -279.5t-385.5 -103t-385.5 103t-279.5 279.5t-103 385.5zM224 640q0 -148 73 -273t198 -198t273 -73t273 73t198 198t73 273t-73 273t-198 198t-273 73t-273 -73 t-198 -198t-73 -273zM512 320v640q0 37 32 56q33 18 64 -1l544 -320q32 -18 32 -55t-32 -55l-544 -320q-15 -9 -32 -9q-16 0 -32 8q-32 19 -32 56z" /> +<glyph unicode="" d="M0 640q0 156 61 298t164 245t245 164t298 61q147 0 284.5 -55.5t244.5 -156.5l130 129q29 31 70 14q39 -17 39 -59v-448q0 -26 -19 -45t-45 -19h-448q-42 0 -59 40q-17 39 14 69l138 138q-148 137 -349 137q-104 0 -198.5 -40.5t-163.5 -109.5t-109.5 -163.5 t-40.5 -198.5t40.5 -198.5t109.5 -163.5t163.5 -109.5t198.5 -40.5q119 0 225 52t179 147q7 10 23 12q14 0 25 -9l137 -138q9 -8 9.5 -20.5t-7.5 -22.5q-109 -132 -264 -204.5t-327 -72.5q-156 0 -298 61t-245 164t-164 245t-61 298z" /> +<glyph unicode="" d="M0 0v448q0 26 19 45t45 19h448q26 0 45 -19t19 -45t-19 -45l-137 -137q71 -66 161 -102t187 -36q134 0 250 65t186 179q11 17 53 117q8 23 30 23h192q13 0 22.5 -9.5t9.5 -22.5q0 -5 -1 -7q-64 -268 -268 -434.5t-478 -166.5q-146 0 -282.5 55t-243.5 157l-129 -129 q-19 -19 -45 -19t-45 19t-19 45zM18 800v7q65 268 270 434.5t480 166.5q146 0 284 -55.5t245 -156.5l130 129q19 19 45 19t45 -19t19 -45v-448q0 -26 -19 -45t-45 -19h-448q-26 0 -45 19t-19 45t19 45l138 138q-148 137 -349 137q-134 0 -250 -65t-186 -179 q-11 -17 -53 -117q-8 -23 -30 -23h-199q-13 0 -22.5 9.5t-9.5 22.5z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 160v1088q0 66 47 113t113 47h1472q66 0 113 -47t47 -113v-1088q0 -66 -47 -113t-113 -47h-1472q-66 0 -113 47t-47 113zM128 160q0 -13 9.5 -22.5t22.5 -9.5h1472q13 0 22.5 9.5t9.5 22.5v832q0 13 -9.5 22.5t-22.5 9.5h-1472q-13 0 -22.5 -9.5t-9.5 -22.5v-832z M256 288v64q0 13 9.5 22.5t22.5 9.5h64q13 0 22.5 -9.5t9.5 -22.5v-64q0 -13 -9.5 -22.5t-22.5 -9.5h-64q-13 0 -22.5 9.5t-9.5 22.5zM256 544v64q0 13 9.5 22.5t22.5 9.5h64q13 0 22.5 -9.5t9.5 -22.5v-64q0 -13 -9.5 -22.5t-22.5 -9.5h-64q-13 0 -22.5 9.5t-9.5 22.5z M256 800v64q0 13 9.5 22.5t22.5 9.5h64q13 0 22.5 -9.5t9.5 -22.5v-64q0 -13 -9.5 -22.5t-22.5 -9.5h-64q-13 0 -22.5 9.5t-9.5 22.5zM512 288v64q0 13 9.5 22.5t22.5 9.5h960q13 0 22.5 -9.5t9.5 -22.5v-64q0 -13 -9.5 -22.5t-22.5 -9.5h-960q-13 0 -22.5 9.5t-9.5 22.5z M512 544v64q0 13 9.5 22.5t22.5 9.5h960q13 0 22.5 -9.5t9.5 -22.5v-64q0 -13 -9.5 -22.5t-22.5 -9.5h-960q-13 0 -22.5 9.5t-9.5 22.5zM512 800v64q0 13 9.5 22.5t22.5 9.5h960q13 0 22.5 -9.5t9.5 -22.5v-64q0 -13 -9.5 -22.5t-22.5 -9.5h-960q-13 0 -22.5 9.5t-9.5 22.5z " /> +<glyph unicode="" horiz-adv-x="1152" d="M0 96v576q0 40 28 68t68 28h32v192q0 184 132 316t316 132t316 -132t132 -316v-192h32q40 0 68 -28t28 -68v-576q0 -40 -28 -68t-68 -28h-960q-40 0 -68 28t-28 68zM320 768h512v192q0 106 -75 181t-181 75t-181 -75t-75 -181v-192z" /> +<glyph unicode="" horiz-adv-x="1792" d="M64 1280q0 53 37.5 90.5t90.5 37.5t90.5 -37.5t37.5 -90.5q0 -72 -64 -110v-1266q0 -13 -9.5 -22.5t-22.5 -9.5h-64q-13 0 -22.5 9.5t-9.5 22.5v1266q-64 38 -64 110zM320 320v742q0 32 31 55q21 14 79 43q236 120 421 120q107 0 200 -29t219 -88q38 -19 88 -19 q54 0 117.5 21t110 47t88 47t54.5 21q26 0 45 -19t19 -45v-763q0 -25 -12.5 -38.5t-39.5 -27.5q-215 -116 -369 -116q-61 0 -123.5 22t-108.5 48t-115.5 48t-142.5 22q-192 0 -464 -146q-17 -9 -33 -9q-26 0 -45 19t-19 45z" /> +<glyph unicode="" horiz-adv-x="1664" d="M0 650q0 151 67 291t179 242.5t266 163.5t320 61t320 -61t266 -163.5t179 -242.5t67 -291q0 -166 -60 -314l-20 -49l-185 -33q-22 -83 -90.5 -136.5t-156.5 -53.5v-32q0 -14 -9 -23t-23 -9h-64q-14 0 -23 9t-9 23v576q0 14 9 23t23 9h64q14 0 23 -9t9 -23v-32 q71 0 130 -35.5t93 -95.5l68 12q29 95 29 193q0 148 -88 279t-236.5 209t-315.5 78t-315.5 -78t-236.5 -209t-88 -279q0 -98 29 -193l68 -12q34 60 93 95.5t130 35.5v32q0 14 9 23t23 9h64q14 0 23 -9t9 -23v-576q0 -14 -9 -23t-23 -9h-64q-14 0 -23 9t-9 23v32 q-88 0 -156.5 53.5t-90.5 136.5l-185 33l-20 49q-60 148 -60 314z" /> +<glyph unicode="" horiz-adv-x="768" d="M0 448v384q0 26 19 45t45 19h262l333 333q19 19 45 19t45 -19t19 -45v-1088q0 -26 -19 -45t-45 -19t-45 19l-333 333h-262q-26 0 -45 19t-19 45z" /> +<glyph unicode="" horiz-adv-x="1152" d="M0 448v384q0 26 19 45t45 19h262l333 333q19 19 45 19t45 -19t19 -45v-1088q0 -26 -19 -45t-45 -19t-45 19l-333 333h-262q-26 0 -45 19t-19 45zM908 464q0 21 12 35.5t29 25t34 23t29 35.5t12 57t-12 57t-29 35.5t-34 23t-29 25t-12 35.5q0 27 19 45.5t45 18.5 q15 0 25 -5q70 -27 112.5 -93t42.5 -142t-42.5 -141.5t-112.5 -93.5q-10 -5 -25 -5q-26 0 -45 18.5t-19 45.5z" /> +<glyph unicode="" horiz-adv-x="1664" d="M0 448v384q0 26 19 45t45 19h262l333 333q19 19 45 19t45 -19t19 -45v-1088q0 -26 -19 -45t-45 -19t-45 19l-333 333h-262q-26 0 -45 19t-19 45zM908 464q0 21 12 35.5t29 25t34 23t29 35.5t12 57t-12 57t-29 35.5t-34 23t-29 25t-12 35.5q0 27 19 45.5t45 18.5 q15 0 25 -5q70 -27 112.5 -93t42.5 -142t-42.5 -141.5t-112.5 -93.5q-10 -5 -25 -5q-26 0 -45 18.5t-19 45.5zM1008 228q0 39 39 59q56 29 76 44q74 54 115.5 135.5t41.5 173.5t-41.5 173.5t-115.5 135.5q-20 15 -76 44q-39 20 -39 59q0 26 19 45t45 19q13 0 26 -5 q140 -59 225 -188.5t85 -282.5t-85 -282.5t-225 -188.5q-13 -5 -25 -5q-27 0 -46 19t-19 45zM1109 -7q0 36 39 59q7 4 22.5 10.5t22.5 10.5q46 25 82 51q123 91 192 227t69 289t-69 289t-192 227q-36 26 -82 51q-7 4 -22.5 10.5t-22.5 10.5q-39 23 -39 59q0 26 19 45t45 19 q13 0 26 -5q211 -91 338 -283.5t127 -422.5t-127 -422.5t-338 -283.5q-13 -5 -26 -5q-26 0 -45 19t-19 45z" /> +<glyph unicode="" horiz-adv-x="1408" d="M0 0v640h640v-640h-640zM0 768v640h640v-640h-640zM128 129h384v383h-384v-383zM128 896h384v384h-384v-384zM256 256v128h128v-128h-128zM256 1024v128h128v-128h-128zM768 0v640h384v-128h128v128h128v-384h-384v128h-128v-384h-128zM768 768v640h640v-640h-640z M896 896h384v384h-384v-384zM1024 0v128h128v-128h-128zM1024 1024v128h128v-128h-128zM1280 0v128h128v-128h-128z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 0v1408h63v-1408h-63zM94 1v1407h32v-1407h-32zM189 1v1407h31v-1407h-31zM346 1v1407h31v-1407h-31zM472 1v1407h62v-1407h-62zM629 1v1407h31v-1407h-31zM692 1v1407h31v-1407h-31zM755 1v1407h31v-1407h-31zM880 1v1407h63v-1407h-63zM1037 1v1407h63v-1407h-63z M1163 1v1407h63v-1407h-63zM1289 1v1407h63v-1407h-63zM1383 1v1407h63v-1407h-63zM1541 1v1407h94v-1407h-94zM1666 1v1407h32v-1407h-32zM1729 0v1408h63v-1408h-63z" /> +<glyph unicode="" d="M0 864v416q0 52 38 90t90 38h416q53 0 117 -26.5t102 -64.5l715 -714q37 -39 37 -91q0 -53 -37 -90l-491 -492q-39 -37 -91 -37q-53 0 -90 37l-715 716q-38 37 -64.5 101t-26.5 117zM192 1088q0 -53 37.5 -90.5t90.5 -37.5t90.5 37.5t37.5 90.5t-37.5 90.5t-90.5 37.5 t-90.5 -37.5t-37.5 -90.5z" /> +<glyph unicode="" horiz-adv-x="1920" d="M0 864v416q0 52 38 90t90 38h416q53 0 117 -26.5t102 -64.5l715 -714q37 -39 37 -91q0 -53 -37 -90l-491 -492q-39 -37 -91 -37q-53 0 -90 37l-715 716q-38 37 -64.5 101t-26.5 117zM192 1088q0 -53 37.5 -90.5t90.5 -37.5t90.5 37.5t37.5 90.5t-37.5 90.5t-90.5 37.5 t-90.5 -37.5t-37.5 -90.5zM704 1408h224q53 0 117 -26.5t102 -64.5l715 -714q37 -39 37 -91q0 -53 -37 -90l-491 -492q-39 -37 -91 -37q-36 0 -59 14t-53 45l470 470q37 37 37 90q0 52 -37 91l-715 714q-38 38 -102 64.5t-117 26.5z" /> +<glyph unicode="" horiz-adv-x="1664" d="M10 184q0 4 3 27t4 37q1 8 -3 21.5t-3 19.5q2 11 8 21t16.5 23.5t16.5 23.5q23 38 45 91.5t30 91.5q3 10 0.5 30t-0.5 28q3 11 17 28t17 23q21 36 42 92t25 90q1 9 -2.5 32t0.5 28q4 13 22 30.5t22 22.5q19 26 42.5 84.5t27.5 96.5q1 8 -3 25.5t-2 26.5q2 8 9 18t18 23 t17 21q8 12 16.5 30.5t15 35t16 36t19.5 32t26.5 23.5t36 11.5t47.5 -5.5l-1 -3q38 9 51 9h761q74 0 114 -56t18 -130l-274 -906q-36 -119 -71.5 -153.5t-128.5 -34.5h-869q-27 0 -38 -15q-11 -16 -1 -43q24 -70 144 -70h923q29 0 56 15.5t35 41.5l300 987q7 22 5 57 q38 -15 59 -43q40 -57 18 -129l-275 -906q-19 -64 -76.5 -107.5t-122.5 -43.5h-923q-77 0 -148.5 53.5t-99.5 131.5q-24 67 -2 127zM492 800q-4 -13 2 -22.5t20 -9.5h608q13 0 25.5 9.5t16.5 22.5l21 64q4 13 -2 22.5t-20 9.5h-608q-13 0 -25.5 -9.5t-16.5 -22.5zM575 1056 q-4 -13 2 -22.5t20 -9.5h608q13 0 25.5 9.5t16.5 22.5l21 64q4 13 -2 22.5t-20 9.5h-608q-13 0 -25.5 -9.5t-16.5 -22.5z" /> +<glyph unicode="" horiz-adv-x="1280" d="M0 7v1289q0 34 19.5 62t52.5 41q21 9 44 9h1048q23 0 44 -9q33 -13 52.5 -41t19.5 -62v-1289q0 -34 -19.5 -62t-52.5 -41q-19 -8 -44 -8q-48 0 -83 32l-441 424l-441 -424q-36 -33 -83 -33q-23 0 -44 9q-33 13 -52.5 41t-19.5 62z" /> +<glyph unicode="" horiz-adv-x="1664" d="M0 160v416q0 79 56.5 135.5t135.5 56.5h64v544q0 40 28 68t68 28h672q40 0 88 -20t76 -48l152 -152q28 -28 48 -76t20 -88v-256h64q79 0 135.5 -56.5t56.5 -135.5v-416q0 -13 -9.5 -22.5t-22.5 -9.5h-224v-160q0 -40 -28 -68t-68 -28h-960q-40 0 -68 28t-28 68v160h-224 q-13 0 -22.5 9.5t-9.5 22.5zM384 0h896v256h-896v-256zM384 640h896v384h-160q-40 0 -68 28t-28 68v160h-640v-640zM1408 576q0 -26 19 -45t45 -19t45 19t19 45t-19 45t-45 19t-45 -19t-19 -45z" /> +<glyph unicode="" horiz-adv-x="1920" d="M0 128v896q0 106 75 181t181 75h224l51 136q19 49 69.5 84.5t103.5 35.5h512q53 0 103.5 -35.5t69.5 -84.5l51 -136h224q106 0 181 -75t75 -181v-896q0 -106 -75 -181t-181 -75h-1408q-106 0 -181 75t-75 181zM512 576q0 -185 131.5 -316.5t316.5 -131.5t316.5 131.5 t131.5 316.5t-131.5 316.5t-316.5 131.5t-316.5 -131.5t-131.5 -316.5zM672 576q0 119 84.5 203.5t203.5 84.5t203.5 -84.5t84.5 -203.5t-84.5 -203.5t-203.5 -84.5t-203.5 84.5t-84.5 203.5z" /> +<glyph unicode="" horiz-adv-x="1664" d="M0 -128l2 79q23 7 56 12.5t57 10.5t49.5 14.5t44.5 29t31 50.5l237 616l280 724h75h53q8 -14 11 -21l205 -480q33 -78 106 -257.5t114 -274.5q15 -34 58 -144.5t72 -168.5q20 -45 35 -57q19 -15 88 -29.5t84 -20.5q6 -38 6 -57q0 -4 -0.5 -13t-0.5 -13q-63 0 -190 8 t-191 8q-76 0 -215 -7t-178 -8q0 43 4 78l131 28q1 0 12.5 2.5t15.5 3.5t14.5 4.5t15 6.5t11 8t9 11t2.5 14q0 16 -31 96.5t-72 177.5t-42 100l-450 2q-26 -58 -76.5 -195.5t-50.5 -162.5q0 -22 14 -37.5t43.5 -24.5t48.5 -13.5t57 -8.5t41 -4q1 -19 1 -58q0 -9 -2 -27 q-58 0 -174.5 10t-174.5 10q-8 0 -26.5 -4t-21.5 -4q-80 -14 -188 -14zM555 527q33 0 136.5 -2t160.5 -2q19 0 57 2q-87 253 -184 452z" /> +<glyph unicode="" horiz-adv-x="1408" d="M0 -128l2 94q15 4 85 16t106 27q7 12 12.5 27t8.5 33.5t5.5 32.5t3 37.5t0.5 34v35.5v30q0 982 -22 1025q-4 8 -22 14.5t-44.5 11t-49.5 7t-48.5 4.5t-30.5 3l-4 83q98 2 340 11.5t373 9.5q23 0 68.5 -0.5t67.5 -0.5q70 0 136.5 -13t128.5 -42t108 -71t74 -104.5 t28 -137.5q0 -52 -16.5 -95.5t-39 -72t-64.5 -57.5t-73 -45t-84 -40q154 -35 256.5 -134t102.5 -248q0 -100 -35 -179.5t-93.5 -130.5t-138 -85.5t-163.5 -48.5t-176 -14q-44 0 -132 3t-132 3q-106 0 -307 -11t-231 -12zM533 1292q0 -50 4 -151t4 -152q0 -27 -0.5 -80 t-0.5 -79q0 -46 1 -69q42 -7 109 -7q82 0 143 13t110 44.5t74.5 89.5t25.5 142q0 70 -29 122.5t-79 82t-108 43.5t-124 14q-50 0 -130 -13zM538.5 165q0.5 -37 4.5 -83.5t12 -66.5q74 -32 140 -32q376 0 376 335q0 114 -41 180q-27 44 -61.5 74t-67.5 46.5t-80.5 25 t-84 10.5t-94.5 2q-73 0 -101 -10q0 -53 -0.5 -159t-0.5 -158q0 -8 -1 -67.5t-0.5 -96.5z" /> +<glyph unicode="" horiz-adv-x="1024" d="M0 -126l17 85q6 2 81.5 21.5t111.5 37.5q28 35 41 101q1 7 62 289t114 543.5t52 296.5v25q-24 13 -54.5 18.5t-69.5 8t-58 5.5l19 103q33 -2 120 -6.5t149.5 -7t120.5 -2.5q48 0 98.5 2.5t121 7t98.5 6.5q-5 -39 -19 -89q-30 -10 -101.5 -28.5t-108.5 -33.5 q-8 -19 -14 -42.5t-9 -40t-7.5 -45.5t-6.5 -42q-27 -148 -87.5 -419.5t-77.5 -355.5q-2 -9 -13 -58t-20 -90t-16 -83.5t-6 -57.5l1 -18q17 -4 185 -31q-3 -44 -16 -99q-11 0 -32.5 -1.5t-32.5 -1.5q-29 0 -87 10t-86 10q-138 2 -206 2q-51 0 -143 -9t-121 -11z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 1023v383l81 1l54 -27q12 -5 211 -5q44 0 132 2t132 2q36 0 107.5 -0.5t107.5 -0.5h293q6 0 21 -0.5t20.5 0t16 3t17.5 9t15 17.5l42 1q4 0 14 -0.5t14 -0.5q2 -112 2 -336q0 -80 -5 -109q-39 -14 -68 -18q-25 44 -54 128q-3 9 -11 48t-14.5 73.5t-7.5 35.5 q-6 8 -12 12.5t-15.5 6t-13 2.5t-18 0.5t-16.5 -0.5q-17 0 -66.5 0.5t-74.5 0.5t-64 -2t-71 -6q-9 -81 -8 -136q0 -94 2 -388t2 -455q0 -16 -2.5 -71.5t0 -91.5t12.5 -69q40 -21 124 -42.5t120 -37.5q5 -40 5 -50q0 -14 -3 -29l-34 -1q-76 -2 -218 8t-207 10q-50 0 -151 -9 t-152 -9q-3 51 -3 52v9q17 27 61.5 43t98.5 29t78 27q19 42 19 383q0 101 -3 303t-3 303v117q0 2 0.5 15.5t0.5 25t-1 25.5t-3 24t-5 14q-11 12 -162 12q-33 0 -93 -12t-80 -26q-19 -13 -34 -72.5t-31.5 -111t-42.5 -53.5q-42 26 -56 44zM1414 109.5q9 18.5 42 18.5h80v1024 h-80q-33 0 -42 18.5t11 44.5l126 162q20 26 49 26t49 -26l126 -162q20 -26 11 -44.5t-42 -18.5h-80v-1024h80q33 0 42 -18.5t-11 -44.5l-126 -162q-20 -26 -49 -26t-49 26l-126 162q-20 26 -11 44.5z" /> +<glyph unicode="" d="M0 1023v383l81 1l54 -27q12 -5 211 -5q44 0 132 2t132 2q70 0 246.5 1t304.5 0.5t247 -4.5q33 -1 56 31l42 1q4 0 14 -0.5t14 -0.5q2 -112 2 -336q0 -80 -5 -109q-39 -14 -68 -18q-25 44 -54 128q-3 9 -11 47.5t-15 73.5t-7 36q-10 13 -27 19q-5 2 -66 2q-30 0 -93 1 t-103 1t-94 -2t-96 -7q-9 -81 -8 -136l1 -152v52q0 -55 1 -154t1.5 -180t0.5 -153q0 -16 -2.5 -71.5t0 -91.5t12.5 -69q40 -21 124 -42.5t120 -37.5q5 -40 5 -50q0 -14 -3 -29l-34 -1q-76 -2 -218 8t-207 10q-50 0 -151 -9t-152 -9q-3 51 -3 52v9q17 27 61.5 43t98.5 29 t78 27q7 16 11.5 74t6 145.5t1.5 155t-0.5 153.5t-0.5 89q0 7 -2.5 21.5t-2.5 22.5q0 7 0.5 44t1 73t0 76.5t-3 67.5t-6.5 32q-11 12 -162 12q-41 0 -163 -13.5t-138 -24.5q-19 -12 -34 -71.5t-31.5 -111.5t-42.5 -54q-42 26 -56 44zM5 -64q0 28 26 49q4 3 36 30t59.5 49 t57.5 41.5t42 19.5q13 0 20.5 -10.5t10 -28.5t2.5 -33.5t-1.5 -33t-1.5 -19.5h1024q0 2 -1.5 19.5t-1.5 33t2.5 33.5t10 28.5t20.5 10.5q12 0 42 -19.5t57.5 -41.5t59.5 -49t36 -30q26 -21 26 -49t-26 -49q-4 -3 -36 -30t-59.5 -49t-57.5 -41.5t-42 -19.5q-13 0 -20.5 10.5 t-10 28.5t-2.5 33.5t1.5 33t1.5 19.5h-1024q0 -2 1.5 -19.5t1.5 -33t-2.5 -33.5t-10 -28.5t-20.5 -10.5q-12 0 -42 19.5t-57.5 41.5t-59.5 49t-36 30q-26 21 -26 49z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 64v128q0 26 19 45t45 19h1664q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-1664q-26 0 -45 19t-19 45zM0 448v128q0 26 19 45t45 19h1280q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-1280q-26 0 -45 19t-19 45zM0 832v128q0 26 19 45t45 19h1536 q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-1536q-26 0 -45 19t-19 45zM0 1216v128q0 26 19 45t45 19h1152q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-1152q-26 0 -45 19t-19 45z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 64v128q0 26 19 45t45 19h1664q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-1664q-26 0 -45 19t-19 45zM128 832v128q0 26 19 45t45 19h1408q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-1408q-26 0 -45 19t-19 45zM384 448v128q0 26 19 45t45 19h896 q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-896q-26 0 -45 19t-19 45zM512 1216v128q0 26 19 45t45 19h640q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-640q-26 0 -45 19t-19 45z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 64v128q0 26 19 45t45 19h1664q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-1664q-26 0 -45 19t-19 45zM128 832v128q0 26 19 45t45 19h1536q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-1536q-26 0 -45 19t-19 45zM384 448v128q0 26 19 45t45 19h1280 q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-1280q-26 0 -45 19t-19 45zM512 1216v128q0 26 19 45t45 19h1152q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-1152q-26 0 -45 19t-19 45z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 64v128q0 26 19 45t45 19h1664q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-1664q-26 0 -45 19t-19 45zM0 448v128q0 26 19 45t45 19h1664q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-1664q-26 0 -45 19t-19 45zM0 832v128q0 26 19 45t45 19h1664 q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-1664q-26 0 -45 19t-19 45zM0 1216v128q0 26 19 45t45 19h1664q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-1664q-26 0 -45 19t-19 45z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 32v192q0 13 9.5 22.5t22.5 9.5h192q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5t-22.5 -9.5h-192q-13 0 -22.5 9.5t-9.5 22.5zM0 416v192q0 13 9.5 22.5t22.5 9.5h192q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5t-22.5 -9.5h-192q-13 0 -22.5 9.5 t-9.5 22.5zM0 800v192q0 13 9.5 22.5t22.5 9.5h192q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5t-22.5 -9.5h-192q-13 0 -22.5 9.5t-9.5 22.5zM0 1184v192q0 13 9.5 22.5t22.5 9.5h192q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5t-22.5 -9.5h-192 q-13 0 -22.5 9.5t-9.5 22.5zM384 32v192q0 13 9.5 22.5t22.5 9.5h1344q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5t-22.5 -9.5h-1344q-13 0 -22.5 9.5t-9.5 22.5zM384 416v192q0 13 9.5 22.5t22.5 9.5h1344q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5 t-22.5 -9.5h-1344q-13 0 -22.5 9.5t-9.5 22.5zM384 800v192q0 13 9.5 22.5t22.5 9.5h1344q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5t-22.5 -9.5h-1344q-13 0 -22.5 9.5t-9.5 22.5zM384 1184v192q0 13 9.5 22.5t22.5 9.5h1344q13 0 22.5 -9.5t9.5 -22.5v-192 q0 -13 -9.5 -22.5t-22.5 -9.5h-1344q-13 0 -22.5 9.5t-9.5 22.5z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 32v192q0 13 9.5 22.5t22.5 9.5h1728q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5t-22.5 -9.5h-1728q-13 0 -22.5 9.5t-9.5 22.5zM0 1184v192q0 13 9.5 22.5t22.5 9.5h1728q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5t-22.5 -9.5h-1728q-13 0 -22.5 9.5 t-9.5 22.5zM32 704q0 14 9 23l288 288q9 9 23 9q13 0 22.5 -9.5t9.5 -22.5v-576q0 -13 -9.5 -22.5t-22.5 -9.5q-14 0 -23 9l-288 288q-9 9 -9 23zM640 416v192q0 13 9.5 22.5t22.5 9.5h1088q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5t-22.5 -9.5h-1088 q-13 0 -22.5 9.5t-9.5 22.5zM640 800v192q0 13 9.5 22.5t22.5 9.5h1088q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5t-22.5 -9.5h-1088q-13 0 -22.5 9.5t-9.5 22.5z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 32v192q0 13 9.5 22.5t22.5 9.5h1728q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5t-22.5 -9.5h-1728q-13 0 -22.5 9.5t-9.5 22.5zM0 416v576q0 13 9.5 22.5t22.5 9.5q14 0 23 -9l288 -288q9 -9 9 -23t-9 -23l-288 -288q-9 -9 -23 -9q-13 0 -22.5 9.5t-9.5 22.5z M0 1184v192q0 13 9.5 22.5t22.5 9.5h1728q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5t-22.5 -9.5h-1728q-13 0 -22.5 9.5t-9.5 22.5zM640 416v192q0 13 9.5 22.5t22.5 9.5h1088q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5t-22.5 -9.5h-1088q-13 0 -22.5 9.5 t-9.5 22.5zM640 800v192q0 13 9.5 22.5t22.5 9.5h1088q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5t-22.5 -9.5h-1088q-13 0 -22.5 9.5t-9.5 22.5z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 288v704q0 119 84.5 203.5t203.5 84.5h704q119 0 203.5 -84.5t84.5 -203.5v-165l403 402q18 19 45 19q12 0 25 -5q39 -17 39 -59v-1088q0 -42 -39 -59q-13 -5 -25 -5q-27 0 -45 19l-403 403v-166q0 -119 -84.5 -203.5t-203.5 -84.5h-704q-119 0 -203.5 84.5 t-84.5 203.5z" /> +<glyph unicode="" horiz-adv-x="1920" d="M0 32v1216q0 66 47 113t113 47h1600q66 0 113 -47t47 -113v-1216q0 -66 -47 -113t-113 -47h-1600q-66 0 -113 47t-47 113zM128 32q0 -13 9.5 -22.5t22.5 -9.5h1600q13 0 22.5 9.5t9.5 22.5v1216q0 13 -9.5 22.5t-22.5 9.5h-1600q-13 0 -22.5 -9.5t-9.5 -22.5v-1216z M256 128v192l320 320l160 -160l512 512l416 -416v-448h-1408zM256 960q0 80 56 136t136 56t136 -56t56 -136t-56 -136t-136 -56t-136 56t-56 136z" /> +<glyph unicode="" d="M0 -128v416l832 832l416 -416l-832 -832h-416zM128 128h128v-128h107l91 91l-235 235l-91 -91v-107zM298 384q0 -22 22 -22q10 0 17 7l542 542q7 7 7 17q0 22 -22 22q-10 0 -17 -7l-542 -542q-7 -7 -7 -17zM896 1184l166 165q36 38 90 38q53 0 91 -38l235 -234 q37 -39 37 -91q0 -53 -37 -90l-166 -166z" /> +<glyph unicode="" horiz-adv-x="1024" d="M0 896q0 212 150 362t362 150t362 -150t150 -362q0 -109 -33 -179l-364 -774q-16 -33 -47.5 -52t-67.5 -19t-67.5 19t-46.5 52l-365 774q-33 70 -33 179zM256 896q0 -106 75 -181t181 -75t181 75t75 181t-75 181t-181 75t-181 -75t-75 -181z" /> +<glyph unicode="" d="M0 640q0 209 103 385.5t279.5 279.5t385.5 103t385.5 -103t279.5 -279.5t103 -385.5t-103 -385.5t-279.5 -279.5t-385.5 -103t-385.5 103t-279.5 279.5t-103 385.5zM224 640q0 -148 73 -273t198 -198t273 -73v1088q-148 0 -273 -73t-198 -198t-73 -273z" /> +<glyph unicode="" horiz-adv-x="1024" d="M0 512q0 145 81 275q6 9 62.5 90.5t101 151t99.5 178t83 201.5q9 30 34 47t51 17t51.5 -17t33.5 -47q28 -93 83 -201.5t99.5 -178t101 -151t62.5 -90.5q81 -127 81 -275q0 -212 -150 -362t-362 -150t-362 150t-150 362zM256 384q0 -53 37.5 -90.5t90.5 -37.5t90.5 37.5 t37.5 90.5q0 36 -20 69q-1 1 -15.5 22.5t-25.5 38t-25 44t-21 50.5q-4 16 -21 16t-21 -16q-7 -23 -21 -50.5t-25 -44t-25.5 -38t-15.5 -22.5q-20 -33 -20 -69z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 288v832q0 119 84.5 203.5t203.5 84.5h832q63 0 117 -25q15 -7 18 -23q3 -17 -9 -29l-49 -49q-14 -14 -32 -8q-23 6 -45 6h-832q-66 0 -113 -47t-47 -113v-832q0 -66 47 -113t113 -47h832q66 0 113 47t47 113v126q0 13 9 22l64 64q15 15 35 7t20 -29v-190 q0 -119 -84.5 -203.5t-203.5 -84.5h-832q-119 0 -203.5 84.5t-84.5 203.5zM640 256v288l672 672l288 -288l-672 -672h-288zM736 448h96v-96h56l116 116l-152 152l-116 -116v-56zM944 688q16 -16 33 1l350 350q17 17 1 33t-33 -1l-350 -350q-17 -17 -1 -33zM1376 1280l92 92 q28 28 68 28t68 -28l152 -152q28 -28 28 -68t-28 -68l-92 -92z" /> +<glyph unicode="" horiz-adv-x="1664" d="M0 288v832q0 119 84.5 203.5t203.5 84.5h255q13 0 22.5 -9.5t9.5 -22.5q0 -27 -26 -32q-77 -26 -133 -60q-10 -4 -16 -4h-112q-66 0 -113 -47t-47 -113v-832q0 -66 47 -113t113 -47h832q66 0 113 47t47 113v214q0 19 18 29q28 13 54 37q16 16 35 8q21 -9 21 -29v-259 q0 -119 -84.5 -203.5t-203.5 -84.5h-832q-119 0 -203.5 84.5t-84.5 203.5zM256 704q0 49 3.5 91t14 90t28 88t47 81.5t68.5 74t94.5 61.5t124.5 48.5t159.5 30.5t196.5 11h160v192q0 42 39 59q13 5 25 5q26 0 45 -19l384 -384q19 -19 19 -45t-19 -45l-384 -384 q-18 -19 -45 -19q-12 0 -25 5q-39 17 -39 59v192h-160q-323 0 -438 -131q-119 -137 -74 -473q3 -23 -20 -34q-8 -2 -12 -2q-16 0 -26 13q-10 14 -21 31t-39.5 68.5t-49.5 99.5t-38.5 114t-17.5 122z" /> +<glyph unicode="" horiz-adv-x="1664" d="M0 288v832q0 119 84.5 203.5t203.5 84.5h832q63 0 117 -25q15 -7 18 -23q3 -17 -9 -29l-49 -49q-10 -10 -23 -10q-3 0 -9 2q-23 6 -45 6h-832q-66 0 -113 -47t-47 -113v-832q0 -66 47 -113t113 -47h832q66 0 113 47t47 113v254q0 13 9 22l64 64q10 10 23 10q6 0 12 -3 q20 -8 20 -29v-318q0 -119 -84.5 -203.5t-203.5 -84.5h-832q-119 0 -203.5 84.5t-84.5 203.5zM257 768q0 33 24 57l110 110q24 24 57 24t57 -24l263 -263l647 647q24 24 57 24t57 -24l110 -110q24 -24 24 -57t-24 -57l-814 -814q-24 -24 -57 -24t-57 24l-430 430 q-24 24 -24 57z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 640q0 26 19 45l256 256q19 19 45 19t45 -19t19 -45v-128h384v384h-128q-26 0 -45 19t-19 45t19 45l256 256q19 19 45 19t45 -19l256 -256q19 -19 19 -45t-19 -45t-45 -19h-128v-384h384v128q0 26 19 45t45 19t45 -19l256 -256q19 -19 19 -45t-19 -45l-256 -256 q-19 -19 -45 -19t-45 19t-19 45v128h-384v-384h128q26 0 45 -19t19 -45t-19 -45l-256 -256q-19 -19 -45 -19t-45 19l-256 256q-19 19 -19 45t19 45t45 19h128v384h-384v-128q0 -26 -19 -45t-45 -19t-45 19l-256 256q-19 19 -19 45z" /> +<glyph unicode="" horiz-adv-x="1024" d="M0 -64v1408q0 26 19 45t45 19h128q26 0 45 -19t19 -45v-678q4 11 13 19l710 710q19 19 32 13t13 -32v-1472q0 -26 -13 -32t-32 13l-710 710q-9 9 -13 19v-678q0 -26 -19 -45t-45 -19h-128q-26 0 -45 19t-19 45z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 -64v1408q0 26 19 45t45 19h128q26 0 45 -19t19 -45v-678q4 11 13 19l710 710q19 19 32 13t13 -32v-710q4 11 13 19l710 710q19 19 32 13t13 -32v-1472q0 -26 -13 -32t-32 13l-710 710q-9 9 -13 19v-710q0 -26 -13 -32t-32 13l-710 710q-9 9 -13 19v-678q0 -26 -19 -45 t-45 -19h-128q-26 0 -45 19t-19 45z" /> +<glyph unicode="" horiz-adv-x="1664" d="M122 640q0 26 19 45l710 710q19 19 32 13t13 -32v-710q5 11 13 19l710 710q19 19 32 13t13 -32v-1472q0 -26 -13 -32t-32 13l-710 710q-8 9 -13 19v-710q0 -26 -13 -32t-32 13l-710 710q-19 19 -19 45z" /> +<glyph unicode="" horiz-adv-x="1408" d="M0 -96v1472q0 26 16.5 36t39.5 -3l1328 -738q23 -13 23 -31t-23 -31l-1328 -738q-23 -13 -39.5 -3t-16.5 36z" /> +<glyph unicode="" d="M0 -64v1408q0 26 19 45t45 19h512q26 0 45 -19t19 -45v-1408q0 -26 -19 -45t-45 -19h-512q-26 0 -45 19t-19 45zM896 -64v1408q0 26 19 45t45 19h512q26 0 45 -19t19 -45v-1408q0 -26 -19 -45t-45 -19h-512q-26 0 -45 19t-19 45z" /> +<glyph unicode="" d="M0 -64v1408q0 26 19 45t45 19h1408q26 0 45 -19t19 -45v-1408q0 -26 -19 -45t-45 -19h-1408q-26 0 -45 19t-19 45z" /> +<glyph unicode="" horiz-adv-x="1664" d="M0 -96v1472q0 26 13 32t32 -13l710 -710q8 -8 13 -19v710q0 26 13 32t32 -13l710 -710q19 -19 19 -45t-19 -45l-710 -710q-19 -19 -32 -13t-13 32v710q-5 -10 -13 -19l-710 -710q-19 -19 -32 -13t-13 32z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 -96v1472q0 26 13 32t32 -13l710 -710q8 -8 13 -19v710q0 26 13 32t32 -13l710 -710q8 -8 13 -19v678q0 26 19 45t45 19h128q26 0 45 -19t19 -45v-1408q0 -26 -19 -45t-45 -19h-128q-26 0 -45 19t-19 45v678q-5 -10 -13 -19l-710 -710q-19 -19 -32 -13t-13 32v710 q-5 -10 -13 -19l-710 -710q-19 -19 -32 -13t-13 32z" /> +<glyph unicode="" horiz-adv-x="1024" d="M0 -96v1472q0 26 13 32t32 -13l710 -710q8 -8 13 -19v678q0 26 19 45t45 19h128q26 0 45 -19t19 -45v-1408q0 -26 -19 -45t-45 -19h-128q-26 0 -45 19t-19 45v678q-5 -10 -13 -19l-710 -710q-19 -19 -32 -13t-13 32z" /> +<glyph unicode="" horiz-adv-x="1538" d="M1 64v256q0 26 19 45t45 19h1408q26 0 45 -19t19 -45v-256q0 -26 -19 -45t-45 -19h-1408q-26 0 -45 19t-19 45zM1 525q-6 13 13 32l710 710q19 19 45 19t45 -19l710 -710q19 -19 13 -32t-32 -13h-1472q-26 0 -32 13z" /> +<glyph unicode="" horiz-adv-x="1280" d="M154 704q0 26 19 45l742 742q19 19 45 19t45 -19l166 -166q19 -19 19 -45t-19 -45l-531 -531l531 -531q19 -19 19 -45t-19 -45l-166 -166q-19 -19 -45 -19t-45 19l-742 742q-19 19 -19 45z" /> +<glyph unicode="" horiz-adv-x="1280" d="M90 128q0 26 19 45l531 531l-531 531q-19 19 -19 45t19 45l166 166q19 19 45 19t45 -19l742 -742q19 -19 19 -45t-19 -45l-742 -742q-19 -19 -45 -19t-45 19l-166 166q-19 19 -19 45z" /> +<glyph unicode="" d="M0 640q0 209 103 385.5t279.5 279.5t385.5 103t385.5 -103t279.5 -279.5t103 -385.5t-103 -385.5t-279.5 -279.5t-385.5 -103t-385.5 103t-279.5 279.5t-103 385.5zM320 576q0 -26 19 -45t45 -19h256v-256q0 -26 19 -45t45 -19h128q26 0 45 19t19 45v256h256q26 0 45 19 t19 45v128q0 26 -19 45t-45 19h-256v256q0 26 -19 45t-45 19h-128q-26 0 -45 -19t-19 -45v-256h-256q-26 0 -45 -19t-19 -45v-128z" /> +<glyph unicode="" d="M0 640q0 209 103 385.5t279.5 279.5t385.5 103t385.5 -103t279.5 -279.5t103 -385.5t-103 -385.5t-279.5 -279.5t-385.5 -103t-385.5 103t-279.5 279.5t-103 385.5zM320 576q0 -26 19 -45t45 -19h768q26 0 45 19t19 45v128q0 26 -19 45t-45 19h-768q-26 0 -45 -19 t-19 -45v-128z" /> +<glyph unicode="" d="M0 640q0 209 103 385.5t279.5 279.5t385.5 103t385.5 -103t279.5 -279.5t103 -385.5t-103 -385.5t-279.5 -279.5t-385.5 -103t-385.5 103t-279.5 279.5t-103 385.5zM387 414q0 -27 19 -46l90 -90q19 -19 46 -19q26 0 45 19l181 181l181 -181q19 -19 45 -19q27 0 46 19 l90 90q19 19 19 46q0 26 -19 45l-181 181l181 181q19 19 19 45q0 27 -19 46l-90 90q-19 19 -46 19q-26 0 -45 -19l-181 -181l-181 181q-19 19 -45 19q-27 0 -46 -19l-90 -90q-19 -19 -19 -46q0 -26 19 -45l181 -181l-181 -181q-19 -19 -19 -45z" /> +<glyph unicode="" d="M0 640q0 209 103 385.5t279.5 279.5t385.5 103t385.5 -103t279.5 -279.5t103 -385.5t-103 -385.5t-279.5 -279.5t-385.5 -103t-385.5 103t-279.5 279.5t-103 385.5zM252 621q0 -27 18 -45l362 -362q19 -19 45 -19q27 0 46 19l543 543q18 18 18 45q0 28 -18 46l-91 90 q-19 19 -45 19t-45 -19l-408 -407l-226 226q-19 19 -45 19t-45 -19l-91 -90q-18 -18 -18 -46z" /> +<glyph unicode="" d="M0 640q0 209 103 385.5t279.5 279.5t385.5 103t385.5 -103t279.5 -279.5t103 -385.5t-103 -385.5t-279.5 -279.5t-385.5 -103t-385.5 103t-279.5 279.5t-103 385.5zM417 939q-15 -24 8 -42l132 -100q7 -6 19 -6q16 0 25 12q53 68 86 92q34 24 86 24q48 0 85.5 -26 t37.5 -59q0 -38 -20 -61t-68 -45q-63 -28 -115.5 -86.5t-52.5 -125.5v-36q0 -14 9 -23t23 -9h192q14 0 23 9t9 23q0 19 21.5 49.5t54.5 49.5q32 18 49 28.5t46 35t44.5 48t28 60.5t12.5 81q0 88 -55.5 163t-138.5 116t-170 41q-243 0 -371 -213zM640 160q0 -14 9 -23t23 -9 h192q14 0 23 9t9 23v192q0 14 -9 23t-23 9h-192q-14 0 -23 -9t-9 -23v-192z" /> +<glyph unicode="" d="M0 640q0 209 103 385.5t279.5 279.5t385.5 103t385.5 -103t279.5 -279.5t103 -385.5t-103 -385.5t-279.5 -279.5t-385.5 -103t-385.5 103t-279.5 279.5t-103 385.5zM512 160q0 -14 9 -23t23 -9h448q14 0 23 9t9 23v160q0 14 -9 23t-23 9h-96v512q0 14 -9 23t-23 9h-320 q-14 0 -23 -9t-9 -23v-160q0 -14 9 -23t23 -9h96v-320h-96q-14 0 -23 -9t-9 -23v-160zM640 1056q0 -14 9 -23t23 -9h192q14 0 23 9t9 23v160q0 14 -9 23t-23 9h-192q-14 0 -23 -9t-9 -23v-160z" /> +<glyph unicode="" d="M0 576v128q0 26 19 45t45 19h143q37 161 154.5 278.5t278.5 154.5v143q0 26 19 45t45 19h128q26 0 45 -19t19 -45v-143q161 -37 278.5 -154.5t154.5 -278.5h143q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-143q-37 -161 -154.5 -278.5t-278.5 -154.5v-143 q0 -26 -19 -45t-45 -19h-128q-26 0 -45 19t-19 45v143q-161 37 -278.5 154.5t-154.5 278.5h-143q-26 0 -45 19t-19 45zM339 512q32 -108 112.5 -188.5t188.5 -112.5v109q0 26 19 45t45 19h128q26 0 45 -19t19 -45v-109q108 32 188.5 112.5t112.5 188.5h-109q-26 0 -45 19 t-19 45v128q0 26 19 45t45 19h109q-32 108 -112.5 188.5t-188.5 112.5v-109q0 -26 -19 -45t-45 -19h-128q-26 0 -45 19t-19 45v109q-108 -32 -188.5 -112.5t-112.5 -188.5h109q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-109z" /> +<glyph unicode="" d="M0 640q0 209 103 385.5t279.5 279.5t385.5 103t385.5 -103t279.5 -279.5t103 -385.5t-103 -385.5t-279.5 -279.5t-385.5 -103t-385.5 103t-279.5 279.5t-103 385.5zM224 640q0 -148 73 -273t198 -198t273 -73t273 73t198 198t73 273t-73 273t-198 198t-273 73t-273 -73 t-198 -198t-73 -273zM429 480q0 13 10 23l137 137l-137 137q-10 10 -10 23t10 23l146 146q10 10 23 10t23 -10l137 -137l137 137q10 10 23 10t23 -10l146 -146q10 -10 10 -23t-10 -23l-137 -137l137 -137q10 -10 10 -23t-10 -23l-146 -146q-10 -10 -23 -10t-23 10l-137 137 l-137 -137q-10 -10 -23 -10t-23 10l-146 146q-10 10 -10 23z" /> +<glyph unicode="" d="M0 640q0 209 103 385.5t279.5 279.5t385.5 103t385.5 -103t279.5 -279.5t103 -385.5t-103 -385.5t-279.5 -279.5t-385.5 -103t-385.5 103t-279.5 279.5t-103 385.5zM224 640q0 -148 73 -273t198 -198t273 -73t273 73t198 198t73 273t-73 273t-198 198t-273 73t-273 -73 t-198 -198t-73 -273zM346 640q0 26 19 45l102 102q19 19 45 19t45 -19l147 -147l275 275q19 19 45 19t45 -19l102 -102q19 -19 19 -45t-19 -45l-422 -422q-19 -19 -45 -19t-45 19l-294 294q-19 19 -19 45z" /> +<glyph unicode="" d="M0 643q0 157 61 299.5t163.5 245.5t245 164t298.5 61t298.5 -61t245 -164t163.5 -245.5t61 -299.5t-61 -300t-163.5 -246t-245 -164t-298.5 -61t-298.5 61t-245 164t-163.5 246t-61 300zM224 643q0 -162 89 -299l755 754q-135 91 -300 91q-148 0 -273 -73t-198 -199 t-73 -274zM471 185q137 -89 297 -89q111 0 211.5 43.5t173.5 116.5t116 174.5t43 212.5q0 161 -87 295z" /> +<glyph unicode="" d="M64 576q0 52 37 91l651 650q38 38 91 38q52 0 90 -38l75 -74q38 -38 38 -91t-38 -91l-293 -293h704q52 0 84.5 -37.5t32.5 -90.5v-128q0 -53 -32.5 -90.5t-84.5 -37.5h-704l293 -294q38 -36 38 -90t-38 -90l-75 -76q-37 -37 -90 -37q-52 0 -91 37l-651 652q-37 37 -37 90 z" /> +<glyph unicode="" d="M0 512v128q0 53 32.5 90.5t84.5 37.5h704l-293 294q-38 36 -38 90t38 90l75 75q38 38 90 38q53 0 91 -38l651 -651q37 -35 37 -90q0 -54 -37 -91l-651 -651q-39 -37 -91 -37q-51 0 -90 37l-75 75q-38 38 -38 91t38 91l293 293h-704q-52 0 -84.5 37.5t-32.5 90.5z" /> +<glyph unicode="" horiz-adv-x="1664" d="M53 565q0 53 38 91l651 651q35 37 90 37q54 0 91 -37l651 -651q37 -39 37 -91q0 -51 -37 -90l-75 -75q-38 -38 -91 -38q-54 0 -90 38l-294 293v-704q0 -52 -37.5 -84.5t-90.5 -32.5h-128q-53 0 -90.5 32.5t-37.5 84.5v704l-294 -293q-36 -38 -90 -38t-90 38l-75 75 q-38 38 -38 90z" /> +<glyph unicode="" horiz-adv-x="1664" d="M53 704q0 53 38 91l74 75q39 37 91 37q53 0 90 -37l294 -294v704q0 52 38 90t90 38h128q52 0 90 -38t38 -90v-704l294 294q37 37 90 37q52 0 91 -37l75 -75q37 -39 37 -91q0 -53 -37 -90l-651 -652q-39 -37 -91 -37q-53 0 -90 37l-651 652q-38 36 -38 90z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 416q0 199 53 333q162 403 875 403h224v256q0 26 19 45t45 19t45 -19l512 -512q19 -19 19 -45t-19 -45l-512 -512q-19 -19 -45 -19t-45 19t-19 45v256h-224q-98 0 -175.5 -6t-154 -21.5t-133 -42.5t-105.5 -69.5t-80 -101t-48.5 -138.5t-17.5 -181q0 -55 5 -123 q0 -6 2.5 -23.5t2.5 -26.5q0 -15 -8.5 -25t-23.5 -10q-16 0 -28 17q-7 9 -13 22t-13.5 30t-10.5 24q-127 285 -127 451z" /> +<glyph unicode="" d="M0 -64v448q0 26 19 45t45 19t45 -19l144 -144l332 332q10 10 23 10t23 -10l114 -114q10 -10 10 -23t-10 -23l-332 -332l144 -144q19 -19 19 -45t-19 -45t-45 -19h-448q-26 0 -45 19t-19 45zM781 800q0 13 10 23l332 332l-144 144q-19 19 -19 45t19 45t45 19h448 q26 0 45 -19t19 -45v-448q0 -26 -19 -45t-45 -19t-45 19l-144 144l-332 -332q-10 -10 -23 -10t-23 10l-114 114q-10 10 -10 23z" /> +<glyph unicode="" d="M13 32q0 13 10 23l332 332l-144 144q-19 19 -19 45t19 45t45 19h448q26 0 45 -19t19 -45v-448q0 -26 -19 -45t-45 -19t-45 19l-144 144l-332 -332q-10 -10 -23 -10t-23 10l-114 114q-10 10 -10 23zM768 704v448q0 26 19 45t45 19t45 -19l144 -144l332 332q10 10 23 10 t23 -10l114 -114q10 -10 10 -23t-10 -23l-332 -332l144 -144q19 -19 19 -45t-19 -45t-45 -19h-448q-26 0 -45 19t-19 45z" /> +<glyph unicode="" horiz-adv-x="1408" d="M0 608v192q0 40 28 68t68 28h416v416q0 40 28 68t68 28h192q40 0 68 -28t28 -68v-416h416q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-416v-416q0 -40 -28 -68t-68 -28h-192q-40 0 -68 28t-28 68v416h-416q-40 0 -68 28t-28 68z" /> +<glyph unicode="" horiz-adv-x="1408" d="M0 608v192q0 40 28 68t68 28h1216q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-1216q-40 0 -68 28t-28 68z" /> +<glyph unicode="" horiz-adv-x="1664" d="M122.5 408.5q13.5 51.5 59.5 77.5l266 154l-266 154q-46 26 -59.5 77.5t12.5 97.5l64 110q26 46 77.5 59.5t97.5 -12.5l266 -153v307q0 52 38 90t90 38h128q52 0 90 -38t38 -90v-307l266 153q46 26 97.5 12.5t77.5 -59.5l64 -110q26 -46 12.5 -97.5t-59.5 -77.5 l-266 -154l266 -154q46 -26 59.5 -77.5t-12.5 -97.5l-64 -110q-26 -46 -77.5 -59.5t-97.5 12.5l-266 153v-307q0 -52 -38 -90t-90 -38h-128q-52 0 -90 38t-38 90v307l-266 -153q-46 -26 -97.5 -12.5t-77.5 59.5l-64 110q-26 46 -12.5 97.5z" /> +<glyph unicode="" d="M0 640q0 209 103 385.5t279.5 279.5t385.5 103t385.5 -103t279.5 -279.5t103 -385.5t-103 -385.5t-279.5 -279.5t-385.5 -103t-385.5 103t-279.5 279.5t-103 385.5zM624 1126l17 -621q0 -10 10 -17.5t24 -7.5h185q14 0 23.5 7.5t10.5 17.5l18 621q0 12 -10 18 q-10 8 -24 8h-220q-14 0 -24 -8q-10 -6 -10 -18zM640 161q0 -13 10 -23t23 -10h192q13 0 22 9.5t9 23.5v190q0 14 -9 23.5t-22 9.5h-192q-13 0 -23 -10t-10 -23v-190z" /> +<glyph unicode="" d="M0 544v320q0 14 9 23t23 9h440q-93 0 -158.5 65.5t-65.5 158.5t65.5 158.5t158.5 65.5q107 0 168 -77l128 -165l128 165q61 77 168 77q93 0 158.5 -65.5t65.5 -158.5t-65.5 -158.5t-158.5 -65.5h440q14 0 23 -9t9 -23v-320q0 -14 -9 -23t-23 -9h-96v-416q0 -40 -28 -68 t-68 -28h-1088q-40 0 -68 28t-28 68v416h-96q-14 0 -23 9t-9 23zM376 1120q0 -40 28 -68t68 -28h195l-126 161q-26 31 -69 31q-40 0 -68 -28t-28 -68zM608 180q0 -25 18 -38.5t46 -13.5h192q28 0 46 13.5t18 38.5v56v468v192h-320v-192v-468v-56zM870 1024h194q40 0 68 28 t28 68t-28 68t-68 28q-43 0 -69 -31z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 121q0 35 31 73.5t68 65.5t68 56t31 48q0 4 -14 38t-16 44q-9 51 -9 104q0 115 43.5 220t119 184.5t170.5 139t204 95.5q55 18 145 25.5t179.5 9t178.5 6t163.5 24t113.5 56.5l29.5 29.5t29.5 28t27 20t36.5 16t43.5 4.5q39 0 70.5 -46t47.5 -112t24 -124t8 -96 q0 -95 -20 -193q-46 -224 -184.5 -383t-357.5 -268q-214 -108 -438 -108q-148 0 -286 47q-15 5 -88 42t-96 37q-16 0 -39.5 -32t-45 -70t-52.5 -70t-60 -32q-30 0 -51 11t-31 24t-27 42q-2 4 -6 11t-5.5 10t-3 9.5t-1.5 13.5zM384 448q0 -26 19 -45t45 -19q24 0 45 19 q27 24 74 71t67 66q137 124 268.5 176t313.5 52q26 0 45 19t19 45t-19 45t-45 19q-172 0 -318 -49.5t-259.5 -134t-235.5 -219.5q-19 -21 -19 -45z" /> +<glyph unicode="" horiz-adv-x="1408" d="M0 -160q0 13 9.5 22.5t22.5 9.5h1344q13 0 22.5 -9.5t9.5 -22.5v-64q0 -13 -9.5 -22.5t-22.5 -9.5h-1344q-13 0 -22.5 9.5t-9.5 22.5v64zM256 640q0 78 24.5 144t64 112.5t87.5 88t96 77.5t87.5 72t64 81.5t24.5 96.5q0 94 -66 224l3 -1l-1 1q90 -41 160 -83t138.5 -100 t113.5 -122.5t72.5 -150.5t27.5 -184q0 -78 -24.5 -144t-64 -112.5t-87.5 -88t-96 -77.5t-87.5 -72t-64 -81.5t-24.5 -96.5q0 -96 67 -224l-4 1l1 -1q-90 41 -160 83t-138.5 100t-113.5 122.5t-72.5 150.5t-27.5 184z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 576q0 34 20 69q140 229 376.5 368t499.5 139t499.5 -139t376.5 -368q20 -35 20 -69t-20 -69q-140 -230 -376.5 -368.5t-499.5 -138.5t-499.5 139t-376.5 368q-20 35 -20 69zM128 576q133 -205 333.5 -326.5t434.5 -121.5t434.5 121.5t333.5 326.5q-152 236 -381 353 q61 -104 61 -225q0 -185 -131.5 -316.5t-316.5 -131.5t-316.5 131.5t-131.5 316.5q0 121 61 225q-229 -117 -381 -353zM592 704q0 -20 14 -34t34 -14t34 14t14 34q0 86 61 147t147 61q20 0 34 14t14 34t-14 34t-34 14q-125 0 -214.5 -89.5t-89.5 -214.5z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 576q0 38 20 69q153 235 380 371t496 136q89 0 180 -17l54 97q10 16 28 16q5 0 18 -6t31 -15.5t33 -18.5t31.5 -18.5t19.5 -11.5q16 -10 16 -27q0 -7 -1 -9q-105 -188 -315 -566t-316 -567l-49 -89q-10 -16 -28 -16q-12 0 -134 70q-16 10 -16 28q0 12 44 87 q-143 65 -263.5 173t-208.5 245q-20 31 -20 69zM128 576q167 -258 427 -375l78 141q-87 63 -136 159t-49 203q0 121 61 225q-229 -117 -381 -353zM592 704q0 -20 14 -34t34 -14t34 14t14 34q0 86 61 147t147 61q20 0 34 14t14 34t-14 34t-34 14q-125 0 -214.5 -89.5 t-89.5 -214.5zM896 0l74 132q212 18 392.5 137t301.5 307q-115 179 -282 294l63 112q95 -64 182.5 -153t144.5 -184q20 -34 20 -69t-20 -69q-39 -64 -109 -145q-150 -172 -347.5 -267t-419.5 -95zM1056 286l280 502q8 -45 8 -84q0 -139 -79 -253.5t-209 -164.5z" /> +<glyph unicode="" horiz-adv-x="1792" d="M16 61l768 1408q17 31 47 49t65 18t65 -18t47 -49l768 -1408q35 -63 -2 -126q-17 -29 -46.5 -46t-63.5 -17h-1536q-34 0 -63.5 17t-46.5 46q-37 63 -2 126zM752 992l17 -457q0 -10 10 -16.5t24 -6.5h185q14 0 23.5 6.5t10.5 16.5l18 459q0 12 -10 19q-13 11 -24 11h-220 q-11 0 -24 -11q-10 -7 -10 -21zM768 161q0 -14 9.5 -23.5t22.5 -9.5h192q13 0 22.5 9.5t9.5 23.5v190q0 14 -9.5 23.5t-22.5 9.5h-192q-13 0 -22.5 -9.5t-9.5 -23.5v-190z" /> +<glyph unicode="" horiz-adv-x="1408" d="M0 477q-1 13 9 25l96 97q9 9 23 9q6 0 8 -1l194 -53l259 259l-508 279q-14 8 -17 24q-2 16 9 27l128 128q14 13 30 8l665 -159l160 160q76 76 172 108t148 -12q44 -52 12 -148t-108 -172l-161 -161l160 -696q5 -19 -12 -33l-128 -96q-7 -6 -19 -6q-4 0 -7 1q-15 3 -21 16 l-279 508l-259 -259l53 -194q5 -17 -8 -31l-96 -96q-9 -9 -23 -9h-2q-15 2 -24 13l-189 252l-252 189q-11 7 -13 23z" /> +<glyph unicode="" horiz-adv-x="1664" d="M0 -128v1280q0 52 38 90t90 38h128v96q0 66 47 113t113 47h64q66 0 113 -47t47 -113v-96h384v96q0 66 47 113t113 47h64q66 0 113 -47t47 -113v-96h128q52 0 90 -38t38 -90v-1280q0 -52 -38 -90t-90 -38h-1408q-52 0 -90 38t-38 90zM128 -128h288v288h-288v-288zM128 224 h288v320h-288v-320zM128 608h288v288h-288v-288zM384 1088q0 -13 9.5 -22.5t22.5 -9.5h64q13 0 22.5 9.5t9.5 22.5v288q0 13 -9.5 22.5t-22.5 9.5h-64q-13 0 -22.5 -9.5t-9.5 -22.5v-288zM480 -128h320v288h-320v-288zM480 224h320v320h-320v-320zM480 608h320v288h-320 v-288zM864 -128h320v288h-320v-288zM864 224h320v320h-320v-320zM864 608h320v288h-320v-288zM1152 1088q0 -13 9.5 -22.5t22.5 -9.5h64q13 0 22.5 9.5t9.5 22.5v288q0 13 -9.5 22.5t-22.5 9.5h-64q-13 0 -22.5 -9.5t-9.5 -22.5v-288zM1248 -128h288v288h-288v-288z M1248 224h288v320h-288v-320zM1248 608h288v288h-288v-288z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 160v192q0 14 9 23t23 9h224q48 0 87 15t69 45t51 61.5t45 77.5q32 62 78 171q29 66 49.5 111t54 105t64 100t74 83t90 68.5t106.5 42t128 16.5h256v192q0 14 9 23t23 9q12 0 24 -10l319 -319q9 -9 9 -23t-9 -23l-320 -320q-9 -9 -23 -9q-13 0 -22.5 9.5t-9.5 22.5v192 h-256q-48 0 -87 -15t-69 -45t-51 -61.5t-45 -77.5q-32 -62 -78 -171q-29 -66 -49.5 -111t-54 -105t-64 -100t-74 -83t-90 -68.5t-106.5 -42t-128 -16.5h-224q-14 0 -23 9t-9 23zM0 1056v192q0 14 9 23t23 9h224q250 0 410 -225q-60 -92 -137 -273q-22 45 -37 72.5 t-40.5 63.5t-51 56.5t-63 35t-81.5 14.5h-224q-14 0 -23 9t-9 23zM743 353q59 93 136 273q22 -45 37 -72.5t40.5 -63.5t51 -56.5t63 -35t81.5 -14.5h256v192q0 14 9 23t23 9q12 0 24 -10l319 -319q9 -9 9 -23t-9 -23l-320 -320q-9 -9 -23 -9q-13 0 -22.5 9.5t-9.5 22.5v192 q-32 0 -85 -0.5t-81 -1t-73 1t-71 5t-64 10.5t-63 18.5t-58 28.5t-59 40t-55 53.5t-56 69.5z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 640q0 130 71 248.5t191 204.5t286 136.5t348 50.5q244 0 450 -85.5t326 -233t120 -321.5t-120 -321.5t-326 -233t-450 -85.5q-70 0 -145 8q-198 -175 -460 -242q-49 -14 -114 -22q-17 -2 -30.5 9t-17.5 29v1q-3 4 -0.5 12t2 10t4.5 9.5l6 9t7 8.5t8 9q7 8 31 34.5 t34.5 38t31 39.5t32.5 51t27 59t26 76q-157 89 -247.5 220t-90.5 281z" /> +<glyph unicode="" d="M0 576v128q0 26 19 45t45 19h384q26 0 45 -19t19 -45v-128q0 -52 23.5 -90t53.5 -57t71 -30t64 -13t44 -2t44 2t64 13t71 30t53.5 57t23.5 90v128q0 26 19 45t45 19h384q26 0 45 -19t19 -45v-128q0 -201 -98.5 -362t-274 -251.5t-395.5 -90.5t-395.5 90.5t-274 251.5 t-98.5 362zM0 960v384q0 26 19 45t45 19h384q26 0 45 -19t19 -45v-384q0 -26 -19 -45t-45 -19h-384q-26 0 -45 19t-19 45zM1024 960v384q0 26 19 45t45 | 504 | chore(docs-app): Update assets for index page | 0 | .svg | svg | mit | Semantic-Org/Semantic-UI-Angular |
10071609 | <NME> icons.svg <BEF> ADDFILE <MSG> chore(docs-app): Update assets for index page <DFF> @@ -0,0 +1,504 @@ +<?xml version="1.0" standalone="no"?> +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" > +<svg xmlns="http://www.w3.org/2000/svg"> +<metadata></metadata> +<defs> +<font id="fontawesomeregular" horiz-adv-x="1536" > +<font-face units-per-em="1792" ascent="1536" descent="-256" /> +<missing-glyph horiz-adv-x="448" /> +<glyph unicode=" " horiz-adv-x="448" /> +<glyph unicode="	" horiz-adv-x="448" /> +<glyph unicode=" " horiz-adv-x="448" /> +<glyph unicode="¨" horiz-adv-x="1792" /> +<glyph unicode="©" horiz-adv-x="1792" /> +<glyph unicode="®" horiz-adv-x="1792" /> +<glyph unicode="´" horiz-adv-x="1792" /> +<glyph unicode="Æ" horiz-adv-x="1792" /> +<glyph unicode="Ø" horiz-adv-x="1792" /> +<glyph unicode=" " horiz-adv-x="768" /> +<glyph unicode=" " horiz-adv-x="1537" /> +<glyph unicode=" " horiz-adv-x="768" /> +<glyph unicode=" " horiz-adv-x="1537" /> +<glyph unicode=" " horiz-adv-x="512" /> +<glyph unicode=" " horiz-adv-x="384" /> +<glyph unicode=" " horiz-adv-x="256" /> +<glyph unicode=" " horiz-adv-x="256" /> +<glyph unicode=" " horiz-adv-x="192" /> +<glyph unicode=" " horiz-adv-x="307" /> +<glyph unicode=" " horiz-adv-x="85" /> +<glyph unicode=" " horiz-adv-x="307" /> +<glyph unicode=" " horiz-adv-x="384" /> +<glyph unicode="™" horiz-adv-x="1792" /> +<glyph unicode="∞" horiz-adv-x="1792" /> +<glyph unicode="≠" horiz-adv-x="1792" /> +<glyph unicode="◼" horiz-adv-x="500" d="M0 0z" /> +<glyph unicode="" horiz-adv-x="1792" d="M93 1350q0 23 18 36.5t38 17.5t43 4h1408q23 0 43 -4t38 -17.5t18 -36.5q0 -35 -43 -78l-632 -632v-768h320q26 0 45 -19t19 -45t-19 -45t-45 -19h-896q-26 0 -45 19t-19 45t19 45t45 19h320v768l-632 632q-43 43 -43 78z" /> +<glyph unicode="" d="M0 -64q0 50 34 89t86 60.5t103.5 32t96.5 10.5q105 0 192 -39v967q0 31 19 56.5t49 35.5l832 256q12 4 28 4q40 0 68 -28t28 -68v-1120q0 -50 -34 -89t-86 -60.5t-103.5 -32t-96.5 -10.5t-96.5 10.5t-103.5 32t-86 60.5t-34 89t34 89t86 60.5t103.5 32t96.5 10.5 q105 0 192 -39v537l-768 -237v-709q0 -50 -34 -89t-86 -60.5t-103.5 -32t-96.5 -10.5t-96.5 10.5t-103.5 32t-86 60.5t-34 89z" /> +<glyph unicode="" horiz-adv-x="1664" d="M0 704q0 143 55.5 273.5t150 225t225 150t273.5 55.5t273.5 -55.5t225 -150t150 -225t55.5 -273.5q0 -220 -124 -399l343 -343q37 -37 37 -90q0 -52 -38 -90t-90 -38q-54 0 -90 38l-343 342q-179 -124 -399 -124q-143 0 -273.5 55.5t-225 150t-150 225t-55.5 273.5z M256 704q0 -185 131.5 -316.5t316.5 -131.5t316.5 131.5t131.5 316.5t-131.5 316.5t-316.5 131.5t-316.5 -131.5t-131.5 -316.5z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 32v1088q0 66 47 113t113 47h1472q66 0 113 -47t47 -113v-1088q0 -66 -47 -113t-113 -47h-1472q-66 0 -113 47t-47 113zM128 32q0 -13 9.5 -22.5t22.5 -9.5h1472q13 0 22.5 9.5t9.5 22.5v768q-32 -36 -69 -66q-268 -206 -426 -338q-51 -43 -83 -67t-86.5 -48.5 t-102.5 -24.5h-1h-1q-48 0 -102.5 24.5t-86.5 48.5t-83 67q-158 132 -426 338q-37 30 -69 66v-768zM128 1120q0 -168 147 -284q193 -152 401 -317q6 -5 35 -29.5t46 -37.5t44.5 -31.5t50.5 -27.5t43 -9h1h1q20 0 43 9t50.5 27.5t44.5 31.5t46 37.5t35 29.5q208 165 401 317 q54 43 100.5 115.5t46.5 131.5v11v13.5t-0.5 13t-3 12.5t-5.5 9t-9 7.5t-14 2.5h-1472q-13 0 -22.5 -9.5t-9.5 -22.5z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 940q0 220 127 344t351 124q62 0 126.5 -21.5t120 -58t95.5 -68.5t76 -68q36 36 76 68t95.5 68.5t120 58t126.5 21.5q224 0 351 -124t127 -344q0 -221 -229 -450l-623 -600q-18 -18 -44 -18t-44 18l-624 602q-10 8 -27.5 26t-55.5 65.5t-68 97.5t-53.5 121t-23.5 138z " /> +<glyph unicode="" horiz-adv-x="1664" d="M0 889q0 37 56 46l502 73l225 455q19 41 49 41t49 -41l225 -455l502 -73q56 -9 56 -46q0 -22 -26 -48l-363 -354l86 -500q1 -7 1 -20q0 -21 -10.5 -35.5t-30.5 -14.5q-19 0 -40 12l-449 236l-449 -236q-22 -12 -40 -12q-21 0 -31.5 14.5t-10.5 35.5q0 6 2 20l86 500 l-364 354q-25 27 -25 48z" /> +<glyph unicode="" horiz-adv-x="1664" d="M0 889q0 37 56 46l502 73l225 455q19 41 49 41t49 -41l225 -455l502 -73q56 -9 56 -46q0 -22 -26 -48l-363 -354l86 -500q1 -7 1 -20q0 -50 -41 -50q-19 0 -40 12l-449 236l-449 -236q-22 -12 -40 -12q-21 0 -31.5 14.5t-10.5 35.5q0 6 2 20l86 500l-364 354 q-25 27 -25 48zM221 829l306 -297l-73 -421l378 199l377 -199l-72 421l306 297l-422 62l-189 382l-189 -382z" /> +<glyph unicode="" horiz-adv-x="1408" d="M0 131q0 53 3.5 103.5t14 109t26.5 108.5t43 97.5t62 81t85.5 53.5t111.5 20q9 0 42 -21.5t74.5 -48t108 -48t133.5 -21.5t133.5 21.5t108 48t74.5 48t42 21.5q61 0 111.5 -20t85.5 -53.5t62 -81t43 -97.5t26.5 -108.5t14 -109t3.5 -103.5q0 -120 -73 -189.5t-194 -69.5 h-874q-121 0 -194 69.5t-73 189.5zM320 1024q0 159 112.5 271.5t271.5 112.5t271.5 -112.5t112.5 -271.5t-112.5 -271.5t-271.5 -112.5t-271.5 112.5t-112.5 271.5z" /> +<glyph unicode="" horiz-adv-x="1920" d="M0 -96v1344q0 66 47 113t113 47h1600q66 0 113 -47t47 -113v-1344q0 -66 -47 -113t-113 -47h-1600q-66 0 -113 47t-47 113zM128 64v-128q0 -26 19 -45t45 -19h128q26 0 45 19t19 45v128q0 26 -19 45t-45 19h-128q-26 0 -45 -19t-19 -45zM128 320q0 -26 19 -45t45 -19h128 q26 0 45 19t19 45v128q0 26 -19 45t-45 19h-128q-26 0 -45 -19t-19 -45v-128zM128 704q0 -26 19 -45t45 -19h128q26 0 45 19t19 45v128q0 26 -19 45t-45 19h-128q-26 0 -45 -19t-19 -45v-128zM128 1088q0 -26 19 -45t45 -19h128q26 0 45 19t19 45v128q0 26 -19 45t-45 19 h-128q-26 0 -45 -19t-19 -45v-128zM512 -64q0 -26 19 -45t45 -19h768q26 0 45 19t19 45v512q0 26 -19 45t-45 19h-768q-26 0 -45 -19t-19 -45v-512zM512 704q0 -26 19 -45t45 -19h768q26 0 45 19t19 45v512q0 26 -19 45t-45 19h-768q-26 0 -45 -19t-19 -45v-512zM1536 64 v-128q0 -26 19 -45t45 -19h128q26 0 45 19t19 45v128q0 26 -19 45t-45 19h-128q-26 0 -45 -19t-19 -45zM1536 320q0 -26 19 -45t45 -19h128q26 0 45 19t19 45v128q0 26 -19 45t-45 19h-128q-26 0 -45 -19t-19 -45v-128zM1536 704q0 -26 19 -45t45 -19h128q26 0 45 19t19 45 v128q0 26 -19 45t-45 19h-128q-26 0 -45 -19t-19 -45v-128zM1536 1088q0 -26 19 -45t45 -19h128q26 0 45 19t19 45v128q0 26 -19 45t-45 19h-128q-26 0 -45 -19t-19 -45v-128z" /> +<glyph unicode="" horiz-adv-x="1664" d="M0 128v384q0 52 38 90t90 38h512q52 0 90 -38t38 -90v-384q0 -52 -38 -90t-90 -38h-512q-52 0 -90 38t-38 90zM0 896v384q0 52 38 90t90 38h512q52 0 90 -38t38 -90v-384q0 -52 -38 -90t-90 -38h-512q-52 0 -90 38t-38 90zM896 128v384q0 52 38 90t90 38h512q52 0 90 -38 t38 -90v-384q0 -52 -38 -90t-90 -38h-512q-52 0 -90 38t-38 90zM896 896v384q0 52 38 90t90 38h512q52 0 90 -38t38 -90v-384q0 -52 -38 -90t-90 -38h-512q-52 0 -90 38t-38 90z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 96v192q0 40 28 68t68 28h320q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-320q-40 0 -68 28t-28 68zM0 608v192q0 40 28 68t68 28h320q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-320q-40 0 -68 28t-28 68zM0 1120v192q0 40 28 68t68 28h320q40 0 68 -28 t28 -68v-192q0 -40 -28 -68t-68 -28h-320q-40 0 -68 28t-28 68zM640 96v192q0 40 28 68t68 28h320q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-320q-40 0 -68 28t-28 68zM640 608v192q0 40 28 68t68 28h320q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-320 q-40 0 -68 28t-28 68zM640 1120v192q0 40 28 68t68 28h320q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-320q-40 0 -68 28t-28 68zM1280 96v192q0 40 28 68t68 28h320q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-320q-40 0 -68 28t-28 68zM1280 608v192 q0 40 28 68t68 28h320q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-320q-40 0 -68 28t-28 68zM1280 1120v192q0 40 28 68t68 28h320q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-320q-40 0 -68 28t-28 68z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 96v192q0 40 28 68t68 28h320q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-320q-40 0 -68 28t-28 68zM0 608v192q0 40 28 68t68 28h320q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-320q-40 0 -68 28t-28 68zM0 1120v192q0 40 28 68t68 28h320q40 0 68 -28 t28 -68v-192q0 -40 -28 -68t-68 -28h-320q-40 0 -68 28t-28 68zM640 96v192q0 40 28 68t68 28h960q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-960q-40 0 -68 28t-28 68zM640 608v192q0 40 28 68t68 28h960q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-960 q-40 0 -68 28t-28 68zM640 1120v192q0 40 28 68t68 28h960q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-960q-40 0 -68 28t-28 68z" /> +<glyph unicode="" horiz-adv-x="1792" d="M121 608q0 40 28 68l136 136q28 28 68 28t68 -28l294 -295l656 657q28 28 68 28t68 -28l136 -136q28 -28 28 -68t-28 -68l-724 -724l-136 -136q-28 -28 -68 -28t-68 28l-136 136l-362 362q-28 28 -28 68z" /> +<glyph unicode="" horiz-adv-x="1408" d="M110 214q0 40 28 68l294 294l-294 294q-28 28 -28 68t28 68l136 136q28 28 68 28t68 -28l294 -294l294 294q28 28 68 28t68 -28l136 -136q28 -28 28 -68t-28 -68l-294 -294l294 -294q28 -28 28 -68t-28 -68l-136 -136q-28 -28 -68 -28t-68 28l-294 294l-294 -294 q-28 -28 -68 -28t-68 28l-136 136q-28 28 -28 68z" /> +<glyph unicode="" horiz-adv-x="1664" d="M0 704q0 143 55.5 273.5t150 225t225 150t273.5 55.5t273.5 -55.5t225 -150t150 -225t55.5 -273.5q0 -220 -124 -399l343 -343q37 -37 37 -90t-37.5 -90.5t-90.5 -37.5q-54 0 -90 38l-343 342q-179 -124 -399 -124q-143 0 -273.5 55.5t-225 150t-150 225t-55.5 273.5z M256 704q0 -185 131.5 -316.5t316.5 -131.5t316.5 131.5t131.5 316.5t-131.5 316.5t-316.5 131.5t-316.5 -131.5t-131.5 -316.5zM384 672v64q0 13 9.5 22.5t22.5 9.5h224v224q0 13 9.5 22.5t22.5 9.5h64q13 0 22.5 -9.5t9.5 -22.5v-224h224q13 0 22.5 -9.5t9.5 -22.5v-64 q0 -13 -9.5 -22.5t-22.5 -9.5h-224v-224q0 -13 -9.5 -22.5t-22.5 -9.5h-64q-13 0 -22.5 9.5t-9.5 22.5v224h-224q-13 0 -22.5 9.5t-9.5 22.5z" /> +<glyph unicode="" horiz-adv-x="1664" d="M0 704q0 143 55.5 273.5t150 225t225 150t273.5 55.5t273.5 -55.5t225 -150t150 -225t55.5 -273.5q0 -220 -124 -399l343 -343q37 -37 37 -90t-37.5 -90.5t-90.5 -37.5q-54 0 -90 38l-343 342q-179 -124 -399 -124q-143 0 -273.5 55.5t-225 150t-150 225t-55.5 273.5z M256 704q0 -185 131.5 -316.5t316.5 -131.5t316.5 131.5t131.5 316.5t-131.5 316.5t-316.5 131.5t-316.5 -131.5t-131.5 -316.5zM384 672v64q0 13 9.5 22.5t22.5 9.5h576q13 0 22.5 -9.5t9.5 -22.5v-64q0 -13 -9.5 -22.5t-22.5 -9.5h-576q-13 0 -22.5 9.5t-9.5 22.5z" /> +<glyph unicode="" d="M0 640q0 182 80.5 343t226.5 270q43 32 95.5 25t83.5 -50q32 -42 24.5 -94.5t-49.5 -84.5q-98 -74 -151.5 -181t-53.5 -228q0 -104 40.5 -198.5t109.5 -163.5t163.5 -109.5t198.5 -40.5t198.5 40.5t163.5 109.5t109.5 163.5t40.5 198.5q0 121 -53.5 228t-151.5 181 q-42 32 -49.5 84.5t24.5 94.5q31 43 84 50t95 -25q146 -109 226.5 -270t80.5 -343q0 -156 -61 -298t-164 -245t-245 -164t-298 -61t-298 61t-245 164t-164 245t-61 298zM640 768v640q0 52 38 90t90 38t90 -38t38 -90v-640q0 -52 -38 -90t-90 -38t-90 38t-38 90z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 -96v192q0 14 9 23t23 9h192q14 0 23 -9t9 -23v-192q0 -14 -9 -23t-23 -9h-192q-14 0 -23 9t-9 23zM384 -96v320q0 14 9 23t23 9h192q14 0 23 -9t9 -23v-320q0 -14 -9 -23t-23 -9h-192q-14 0 -23 9t-9 23zM768 -96v576q0 14 9 23t23 9h192q14 0 23 -9t9 -23v-576 q0 -14 -9 -23t-23 -9h-192q-14 0 -23 9t-9 23zM1152 -96v960q0 14 9 23t23 9h192q14 0 23 -9t9 -23v-960q0 -14 -9 -23t-23 -9h-192q-14 0 -23 9t-9 23zM1536 -96v1472q0 14 9 23t23 9h192q14 0 23 -9t9 -23v-1472q0 -14 -9 -23t-23 -9h-192q-14 0 -23 9t-9 23z" /> +<glyph unicode="" d="M0 531v222q0 12 8 23t19 13l186 28q14 46 39 92q-40 57 -107 138q-10 12 -10 24q0 10 9 23q26 36 98.5 107.5t94.5 71.5q13 0 26 -10l138 -107q44 23 91 38q16 136 29 186q7 28 36 28h222q14 0 24.5 -8.5t11.5 -21.5l28 -184q49 -16 90 -37l142 107q9 9 24 9q13 0 25 -10 q129 -119 165 -170q7 -8 7 -22q0 -12 -8 -23q-15 -21 -51 -66.5t-54 -70.5q26 -50 41 -98l183 -28q13 -2 21 -12.5t8 -23.5v-222q0 -12 -8 -23t-20 -13l-185 -28q-19 -54 -39 -91q35 -50 107 -138q10 -12 10 -25t-9 -23q-27 -37 -99 -108t-94 -71q-12 0 -26 9l-138 108 q-44 -23 -91 -38q-16 -136 -29 -186q-7 -28 -36 -28h-222q-14 0 -24.5 8.5t-11.5 21.5l-28 184q-49 16 -90 37l-141 -107q-10 -9 -25 -9q-14 0 -25 11q-126 114 -165 168q-7 10 -7 23q0 12 8 23q15 21 51 66.5t54 70.5q-27 50 -41 99l-183 27q-13 2 -21 12.5t-8 23.5z M512 640q0 -106 75 -181t181 -75t181 75t75 181t-75 181t-181 75t-181 -75t-75 -181z" /> +<glyph unicode="" horiz-adv-x="1408" d="M0 1056v64q0 14 9 23t23 9h309l70 167q15 37 54 63t79 26h320q40 0 79 -26t54 -63l70 -167h309q14 0 23 -9t9 -23v-64q0 -14 -9 -23t-23 -9h-96v-948q0 -83 -47 -143.5t-113 -60.5h-832q-66 0 -113 58.5t-47 141.5v952h-96q-14 0 -23 9t-9 23zM256 76q0 -22 7 -40.5 t14.5 -27t10.5 -8.5h832q3 0 10.5 8.5t14.5 27t7 40.5v948h-896v-948zM384 224v576q0 14 9 23t23 9h64q14 0 23 -9t9 -23v-576q0 -14 -9 -23t-23 -9h-64q-14 0 -23 9t-9 23zM480 1152h448l-48 117q-7 9 -17 11h-317q-10 -2 -17 -11zM640 224v576q0 14 9 23t23 9h64 q14 0 23 -9t9 -23v-576q0 -14 -9 -23t-23 -9h-64q-14 0 -23 9t-9 23zM896 224v576q0 14 9 23t23 9h64q14 0 23 -9t9 -23v-576q0 -14 -9 -23t-23 -9h-64q-14 0 -23 9t-9 23z" /> +<glyph unicode="" horiz-adv-x="1664" d="M26 636.5q1 13.5 11 21.5l719 599q32 26 76 26t76 -26l244 -204v195q0 14 9 23t23 9h192q14 0 23 -9t9 -23v-408l219 -182q10 -8 11 -21.5t-7 -23.5l-62 -74q-8 -9 -21 -11h-3q-13 0 -21 7l-692 577l-692 -577q-12 -8 -24 -7q-13 2 -21 11l-62 74q-8 10 -7 23.5zM256 64 v480q0 1 0.5 3t0.5 3l575 474l575 -474q1 -2 1 -6v-480q0 -26 -19 -45t-45 -19h-384v384h-256v-384h-384q-26 0 -45 19t-19 45z" /> +<glyph unicode="" d="M0 -160v1600q0 40 28 68t68 28h896q40 0 88 -20t76 -48l312 -312q28 -28 48 -76t20 -88v-1152q0 -40 -28 -68t-68 -28h-1344q-40 0 -68 28t-28 68zM128 -128h1280v1024h-416q-40 0 -68 28t-28 68v416h-768v-1536zM1024 1024h376q-10 29 -22 41l-313 313q-12 12 -41 22 v-376z" /> +<glyph unicode="" d="M0 640q0 209 103 385.5t279.5 279.5t385.5 103t385.5 -103t279.5 -279.5t103 -385.5t-103 -385.5t-279.5 -279.5t-385.5 -103t-385.5 103t-279.5 279.5t-103 385.5zM224 640q0 -148 73 -273t198 -198t273 -73t273 73t198 198t73 273t-73 273t-198 198t-273 73t-273 -73 t-198 -198t-73 -273zM512 544v64q0 14 9 23t23 9h224v352q0 14 9 23t23 9h64q14 0 23 -9t9 -23v-448q0 -14 -9 -23t-23 -9h-320q-14 0 -23 9t-9 23z" /> +<glyph unicode="" horiz-adv-x="1920" d="M50 73q0 54 26 116l417 1044q8 19 26 33t38 14h339q-13 0 -23 -9.5t-11 -22.5l-15 -192q-1 -14 8 -23t22 -9h166q13 0 22 9t8 23l-15 192q-1 13 -11 22.5t-23 9.5h339q20 0 38 -14t26 -33l417 -1044q26 -62 26 -116q0 -73 -46 -73h-704q13 0 22 9.5t8 22.5l-20 256 q-1 13 -11 22.5t-23 9.5h-272q-13 0 -23 -9.5t-11 -22.5l-20 -256q-1 -13 8 -22.5t22 -9.5h-704q-46 0 -46 73zM809 540q-1 -12 8 -20t21 -8h244q12 0 21 8t8 20v4l-24 320q-1 13 -11 22.5t-23 9.5h-186q-13 0 -23 -9.5t-11 -22.5l-24 -320v-4z" /> +<glyph unicode="" horiz-adv-x="1664" d="M0 96v320q0 40 28 68t68 28h465l135 -136q58 -56 136 -56t136 56l136 136h464q40 0 68 -28t28 -68v-320q0 -40 -28 -68t-68 -28h-1472q-40 0 -68 28t-28 68zM325 985q17 39 59 39h256v448q0 26 19 45t45 19h256q26 0 45 -19t19 -45v-448h256q42 0 59 -39q17 -41 -14 -70 l-448 -448q-18 -19 -45 -19t-45 19l-448 448q-31 29 -14 70zM1152 192q0 -26 19 -45t45 -19t45 19t19 45t-19 45t-45 19t-45 -19t-19 -45zM1408 192q0 -26 19 -45t45 -19t45 19t19 45t-19 45t-45 19t-45 -19t-19 -45z" /> +<glyph unicode="" d="M0 640q0 209 103 385.5t279.5 279.5t385.5 103t385.5 -103t279.5 -279.5t103 -385.5t-103 -385.5t-279.5 -279.5t-385.5 -103t-385.5 103t-279.5 279.5t-103 385.5zM224 640q0 -148 73 -273t198 -198t273 -73t273 73t198 198t73 273t-73 273t-198 198t-273 73t-273 -73 t-198 -198t-73 -273zM418 620q8 20 30 20h192v352q0 14 9 23t23 9h192q14 0 23 -9t9 -23v-352h192q14 0 23 -9t9 -23q0 -12 -10 -24l-319 -319q-11 -9 -23 -9t-23 9l-320 320q-15 16 -7 35z" /> +<glyph unicode="" d="M0 640q0 209 103 385.5t279.5 279.5t385.5 103t385.5 -103t279.5 -279.5t103 -385.5t-103 -385.5t-279.5 -279.5t-385.5 -103t-385.5 103t-279.5 279.5t-103 385.5zM224 640q0 -148 73 -273t198 -198t273 -73t273 73t198 198t73 273t-73 273t-198 198t-273 73t-273 -73 t-198 -198t-73 -273zM416 672q0 12 10 24l319 319q11 9 23 9t23 -9l320 -320q15 -16 7 -35q-8 -20 -30 -20h-192v-352q0 -14 -9 -23t-23 -9h-192q-14 0 -23 9t-9 23v352h-192q-14 0 -23 9t-9 23z" /> +<glyph unicode="" d="M0 64v482q0 62 25 123l238 552q10 25 36.5 42t52.5 17h832q26 0 52.5 -17t36.5 -42l238 -552q25 -61 25 -123v-482q0 -26 -19 -45t-45 -19h-1408q-26 0 -45 19t-19 45zM197 576h316l95 -192h320l95 192h316q-1 3 -2.5 8t-2.5 8l-212 496h-708l-212 -496q-1 -2 -2.5 -8 t-2.5 -8z" /> +<glyph unicode="" d="M0 640q0 209 103 385.5t279.5 279.5t385.5 103t385.5 -103t279.5 -279.5t103 -385.5t-103 -385.5t-279.5 -279.5t-385.5 -103t-385.5 103t-279.5 279.5t-103 385.5zM224 640q0 -148 73 -273t198 -198t273 -73t273 73t198 198t73 273t-73 273t-198 198t-273 73t-273 -73 t-198 -198t-73 -273zM512 320v640q0 37 32 56q33 18 64 -1l544 -320q32 -18 32 -55t-32 -55l-544 -320q-15 -9 -32 -9q-16 0 -32 8q-32 19 -32 56z" /> +<glyph unicode="" d="M0 640q0 156 61 298t164 245t245 164t298 61q147 0 284.5 -55.5t244.5 -156.5l130 129q29 31 70 14q39 -17 39 -59v-448q0 -26 -19 -45t-45 -19h-448q-42 0 -59 40q-17 39 14 69l138 138q-148 137 -349 137q-104 0 -198.5 -40.5t-163.5 -109.5t-109.5 -163.5 t-40.5 -198.5t40.5 -198.5t109.5 -163.5t163.5 -109.5t198.5 -40.5q119 0 225 52t179 147q7 10 23 12q14 0 25 -9l137 -138q9 -8 9.5 -20.5t-7.5 -22.5q-109 -132 -264 -204.5t-327 -72.5q-156 0 -298 61t-245 164t-164 245t-61 298z" /> +<glyph unicode="" d="M0 0v448q0 26 19 45t45 19h448q26 0 45 -19t19 -45t-19 -45l-137 -137q71 -66 161 -102t187 -36q134 0 250 65t186 179q11 17 53 117q8 23 30 23h192q13 0 22.5 -9.5t9.5 -22.5q0 -5 -1 -7q-64 -268 -268 -434.5t-478 -166.5q-146 0 -282.5 55t-243.5 157l-129 -129 q-19 -19 -45 -19t-45 19t-19 45zM18 800v7q65 268 270 434.5t480 166.5q146 0 284 -55.5t245 -156.5l130 129q19 19 45 19t45 -19t19 -45v-448q0 -26 -19 -45t-45 -19h-448q-26 0 -45 19t-19 45t19 45l138 138q-148 137 -349 137q-134 0 -250 -65t-186 -179 q-11 -17 -53 -117q-8 -23 -30 -23h-199q-13 0 -22.5 9.5t-9.5 22.5z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 160v1088q0 66 47 113t113 47h1472q66 0 113 -47t47 -113v-1088q0 -66 -47 -113t-113 -47h-1472q-66 0 -113 47t-47 113zM128 160q0 -13 9.5 -22.5t22.5 -9.5h1472q13 0 22.5 9.5t9.5 22.5v832q0 13 -9.5 22.5t-22.5 9.5h-1472q-13 0 -22.5 -9.5t-9.5 -22.5v-832z M256 288v64q0 13 9.5 22.5t22.5 9.5h64q13 0 22.5 -9.5t9.5 -22.5v-64q0 -13 -9.5 -22.5t-22.5 -9.5h-64q-13 0 -22.5 9.5t-9.5 22.5zM256 544v64q0 13 9.5 22.5t22.5 9.5h64q13 0 22.5 -9.5t9.5 -22.5v-64q0 -13 -9.5 -22.5t-22.5 -9.5h-64q-13 0 -22.5 9.5t-9.5 22.5z M256 800v64q0 13 9.5 22.5t22.5 9.5h64q13 0 22.5 -9.5t9.5 -22.5v-64q0 -13 -9.5 -22.5t-22.5 -9.5h-64q-13 0 -22.5 9.5t-9.5 22.5zM512 288v64q0 13 9.5 22.5t22.5 9.5h960q13 0 22.5 -9.5t9.5 -22.5v-64q0 -13 -9.5 -22.5t-22.5 -9.5h-960q-13 0 -22.5 9.5t-9.5 22.5z M512 544v64q0 13 9.5 22.5t22.5 9.5h960q13 0 22.5 -9.5t9.5 -22.5v-64q0 -13 -9.5 -22.5t-22.5 -9.5h-960q-13 0 -22.5 9.5t-9.5 22.5zM512 800v64q0 13 9.5 22.5t22.5 9.5h960q13 0 22.5 -9.5t9.5 -22.5v-64q0 -13 -9.5 -22.5t-22.5 -9.5h-960q-13 0 -22.5 9.5t-9.5 22.5z " /> +<glyph unicode="" horiz-adv-x="1152" d="M0 96v576q0 40 28 68t68 28h32v192q0 184 132 316t316 132t316 -132t132 -316v-192h32q40 0 68 -28t28 -68v-576q0 -40 -28 -68t-68 -28h-960q-40 0 -68 28t-28 68zM320 768h512v192q0 106 -75 181t-181 75t-181 -75t-75 -181v-192z" /> +<glyph unicode="" horiz-adv-x="1792" d="M64 1280q0 53 37.5 90.5t90.5 37.5t90.5 -37.5t37.5 -90.5q0 -72 -64 -110v-1266q0 -13 -9.5 -22.5t-22.5 -9.5h-64q-13 0 -22.5 9.5t-9.5 22.5v1266q-64 38 -64 110zM320 320v742q0 32 31 55q21 14 79 43q236 120 421 120q107 0 200 -29t219 -88q38 -19 88 -19 q54 0 117.5 21t110 47t88 47t54.5 21q26 0 45 -19t19 -45v-763q0 -25 -12.5 -38.5t-39.5 -27.5q-215 -116 -369 -116q-61 0 -123.5 22t-108.5 48t-115.5 48t-142.5 22q-192 0 -464 -146q-17 -9 -33 -9q-26 0 -45 19t-19 45z" /> +<glyph unicode="" horiz-adv-x="1664" d="M0 650q0 151 67 291t179 242.5t266 163.5t320 61t320 -61t266 -163.5t179 -242.5t67 -291q0 -166 -60 -314l-20 -49l-185 -33q-22 -83 -90.5 -136.5t-156.5 -53.5v-32q0 -14 -9 -23t-23 -9h-64q-14 0 -23 9t-9 23v576q0 14 9 23t23 9h64q14 0 23 -9t9 -23v-32 q71 0 130 -35.5t93 -95.5l68 12q29 95 29 193q0 148 -88 279t-236.5 209t-315.5 78t-315.5 -78t-236.5 -209t-88 -279q0 -98 29 -193l68 -12q34 60 93 95.5t130 35.5v32q0 14 9 23t23 9h64q14 0 23 -9t9 -23v-576q0 -14 -9 -23t-23 -9h-64q-14 0 -23 9t-9 23v32 q-88 0 -156.5 53.5t-90.5 136.5l-185 33l-20 49q-60 148 -60 314z" /> +<glyph unicode="" horiz-adv-x="768" d="M0 448v384q0 26 19 45t45 19h262l333 333q19 19 45 19t45 -19t19 -45v-1088q0 -26 -19 -45t-45 -19t-45 19l-333 333h-262q-26 0 -45 19t-19 45z" /> +<glyph unicode="" horiz-adv-x="1152" d="M0 448v384q0 26 19 45t45 19h262l333 333q19 19 45 19t45 -19t19 -45v-1088q0 -26 -19 -45t-45 -19t-45 19l-333 333h-262q-26 0 -45 19t-19 45zM908 464q0 21 12 35.5t29 25t34 23t29 35.5t12 57t-12 57t-29 35.5t-34 23t-29 25t-12 35.5q0 27 19 45.5t45 18.5 q15 0 25 -5q70 -27 112.5 -93t42.5 -142t-42.5 -141.5t-112.5 -93.5q-10 -5 -25 -5q-26 0 -45 18.5t-19 45.5z" /> +<glyph unicode="" horiz-adv-x="1664" d="M0 448v384q0 26 19 45t45 19h262l333 333q19 19 45 19t45 -19t19 -45v-1088q0 -26 -19 -45t-45 -19t-45 19l-333 333h-262q-26 0 -45 19t-19 45zM908 464q0 21 12 35.5t29 25t34 23t29 35.5t12 57t-12 57t-29 35.5t-34 23t-29 25t-12 35.5q0 27 19 45.5t45 18.5 q15 0 25 -5q70 -27 112.5 -93t42.5 -142t-42.5 -141.5t-112.5 -93.5q-10 -5 -25 -5q-26 0 -45 18.5t-19 45.5zM1008 228q0 39 39 59q56 29 76 44q74 54 115.5 135.5t41.5 173.5t-41.5 173.5t-115.5 135.5q-20 15 -76 44q-39 20 -39 59q0 26 19 45t45 19q13 0 26 -5 q140 -59 225 -188.5t85 -282.5t-85 -282.5t-225 -188.5q-13 -5 -25 -5q-27 0 -46 19t-19 45zM1109 -7q0 36 39 59q7 4 22.5 10.5t22.5 10.5q46 25 82 51q123 91 192 227t69 289t-69 289t-192 227q-36 26 -82 51q-7 4 -22.5 10.5t-22.5 10.5q-39 23 -39 59q0 26 19 45t45 19 q13 0 26 -5q211 -91 338 -283.5t127 -422.5t-127 -422.5t-338 -283.5q-13 -5 -26 -5q-26 0 -45 19t-19 45z" /> +<glyph unicode="" horiz-adv-x="1408" d="M0 0v640h640v-640h-640zM0 768v640h640v-640h-640zM128 129h384v383h-384v-383zM128 896h384v384h-384v-384zM256 256v128h128v-128h-128zM256 1024v128h128v-128h-128zM768 0v640h384v-128h128v128h128v-384h-384v128h-128v-384h-128zM768 768v640h640v-640h-640z M896 896h384v384h-384v-384zM1024 0v128h128v-128h-128zM1024 1024v128h128v-128h-128zM1280 0v128h128v-128h-128z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 0v1408h63v-1408h-63zM94 1v1407h32v-1407h-32zM189 1v1407h31v-1407h-31zM346 1v1407h31v-1407h-31zM472 1v1407h62v-1407h-62zM629 1v1407h31v-1407h-31zM692 1v1407h31v-1407h-31zM755 1v1407h31v-1407h-31zM880 1v1407h63v-1407h-63zM1037 1v1407h63v-1407h-63z M1163 1v1407h63v-1407h-63zM1289 1v1407h63v-1407h-63zM1383 1v1407h63v-1407h-63zM1541 1v1407h94v-1407h-94zM1666 1v1407h32v-1407h-32zM1729 0v1408h63v-1408h-63z" /> +<glyph unicode="" d="M0 864v416q0 52 38 90t90 38h416q53 0 117 -26.5t102 -64.5l715 -714q37 -39 37 -91q0 -53 -37 -90l-491 -492q-39 -37 -91 -37q-53 0 -90 37l-715 716q-38 37 -64.5 101t-26.5 117zM192 1088q0 -53 37.5 -90.5t90.5 -37.5t90.5 37.5t37.5 90.5t-37.5 90.5t-90.5 37.5 t-90.5 -37.5t-37.5 -90.5z" /> +<glyph unicode="" horiz-adv-x="1920" d="M0 864v416q0 52 38 90t90 38h416q53 0 117 -26.5t102 -64.5l715 -714q37 -39 37 -91q0 -53 -37 -90l-491 -492q-39 -37 -91 -37q-53 0 -90 37l-715 716q-38 37 -64.5 101t-26.5 117zM192 1088q0 -53 37.5 -90.5t90.5 -37.5t90.5 37.5t37.5 90.5t-37.5 90.5t-90.5 37.5 t-90.5 -37.5t-37.5 -90.5zM704 1408h224q53 0 117 -26.5t102 -64.5l715 -714q37 -39 37 -91q0 -53 -37 -90l-491 -492q-39 -37 -91 -37q-36 0 -59 14t-53 45l470 470q37 37 37 90q0 52 -37 91l-715 714q-38 38 -102 64.5t-117 26.5z" /> +<glyph unicode="" horiz-adv-x="1664" d="M10 184q0 4 3 27t4 37q1 8 -3 21.5t-3 19.5q2 11 8 21t16.5 23.5t16.5 23.5q23 38 45 91.5t30 91.5q3 10 0.5 30t-0.5 28q3 11 17 28t17 23q21 36 42 92t25 90q1 9 -2.5 32t0.5 28q4 13 22 30.5t22 22.5q19 26 42.5 84.5t27.5 96.5q1 8 -3 25.5t-2 26.5q2 8 9 18t18 23 t17 21q8 12 16.5 30.5t15 35t16 36t19.5 32t26.5 23.5t36 11.5t47.5 -5.5l-1 -3q38 9 51 9h761q74 0 114 -56t18 -130l-274 -906q-36 -119 -71.5 -153.5t-128.5 -34.5h-869q-27 0 -38 -15q-11 -16 -1 -43q24 -70 144 -70h923q29 0 56 15.5t35 41.5l300 987q7 22 5 57 q38 -15 59 -43q40 -57 18 -129l-275 -906q-19 -64 -76.5 -107.5t-122.5 -43.5h-923q-77 0 -148.5 53.5t-99.5 131.5q-24 67 -2 127zM492 800q-4 -13 2 -22.5t20 -9.5h608q13 0 25.5 9.5t16.5 22.5l21 64q4 13 -2 22.5t-20 9.5h-608q-13 0 -25.5 -9.5t-16.5 -22.5zM575 1056 q-4 -13 2 -22.5t20 -9.5h608q13 0 25.5 9.5t16.5 22.5l21 64q4 13 -2 22.5t-20 9.5h-608q-13 0 -25.5 -9.5t-16.5 -22.5z" /> +<glyph unicode="" horiz-adv-x="1280" d="M0 7v1289q0 34 19.5 62t52.5 41q21 9 44 9h1048q23 0 44 -9q33 -13 52.5 -41t19.5 -62v-1289q0 -34 -19.5 -62t-52.5 -41q-19 -8 -44 -8q-48 0 -83 32l-441 424l-441 -424q-36 -33 -83 -33q-23 0 -44 9q-33 13 -52.5 41t-19.5 62z" /> +<glyph unicode="" horiz-adv-x="1664" d="M0 160v416q0 79 56.5 135.5t135.5 56.5h64v544q0 40 28 68t68 28h672q40 0 88 -20t76 -48l152 -152q28 -28 48 -76t20 -88v-256h64q79 0 135.5 -56.5t56.5 -135.5v-416q0 -13 -9.5 -22.5t-22.5 -9.5h-224v-160q0 -40 -28 -68t-68 -28h-960q-40 0 -68 28t-28 68v160h-224 q-13 0 -22.5 9.5t-9.5 22.5zM384 0h896v256h-896v-256zM384 640h896v384h-160q-40 0 -68 28t-28 68v160h-640v-640zM1408 576q0 -26 19 -45t45 -19t45 19t19 45t-19 45t-45 19t-45 -19t-19 -45z" /> +<glyph unicode="" horiz-adv-x="1920" d="M0 128v896q0 106 75 181t181 75h224l51 136q19 49 69.5 84.5t103.5 35.5h512q53 0 103.5 -35.5t69.5 -84.5l51 -136h224q106 0 181 -75t75 -181v-896q0 -106 -75 -181t-181 -75h-1408q-106 0 -181 75t-75 181zM512 576q0 -185 131.5 -316.5t316.5 -131.5t316.5 131.5 t131.5 316.5t-131.5 316.5t-316.5 131.5t-316.5 -131.5t-131.5 -316.5zM672 576q0 119 84.5 203.5t203.5 84.5t203.5 -84.5t84.5 -203.5t-84.5 -203.5t-203.5 -84.5t-203.5 84.5t-84.5 203.5z" /> +<glyph unicode="" horiz-adv-x="1664" d="M0 -128l2 79q23 7 56 12.5t57 10.5t49.5 14.5t44.5 29t31 50.5l237 616l280 724h75h53q8 -14 11 -21l205 -480q33 -78 106 -257.5t114 -274.5q15 -34 58 -144.5t72 -168.5q20 -45 35 -57q19 -15 88 -29.5t84 -20.5q6 -38 6 -57q0 -4 -0.5 -13t-0.5 -13q-63 0 -190 8 t-191 8q-76 0 -215 -7t-178 -8q0 43 4 78l131 28q1 0 12.5 2.5t15.5 3.5t14.5 4.5t15 6.5t11 8t9 11t2.5 14q0 16 -31 96.5t-72 177.5t-42 100l-450 2q-26 -58 -76.5 -195.5t-50.5 -162.5q0 -22 14 -37.5t43.5 -24.5t48.5 -13.5t57 -8.5t41 -4q1 -19 1 -58q0 -9 -2 -27 q-58 0 -174.5 10t-174.5 10q-8 0 -26.5 -4t-21.5 -4q-80 -14 -188 -14zM555 527q33 0 136.5 -2t160.5 -2q19 0 57 2q-87 253 -184 452z" /> +<glyph unicode="" horiz-adv-x="1408" d="M0 -128l2 94q15 4 85 16t106 27q7 12 12.5 27t8.5 33.5t5.5 32.5t3 37.5t0.5 34v35.5v30q0 982 -22 1025q-4 8 -22 14.5t-44.5 11t-49.5 7t-48.5 4.5t-30.5 3l-4 83q98 2 340 11.5t373 9.5q23 0 68.5 -0.5t67.5 -0.5q70 0 136.5 -13t128.5 -42t108 -71t74 -104.5 t28 -137.5q0 -52 -16.5 -95.5t-39 -72t-64.5 -57.5t-73 -45t-84 -40q154 -35 256.5 -134t102.5 -248q0 -100 -35 -179.5t-93.5 -130.5t-138 -85.5t-163.5 -48.5t-176 -14q-44 0 -132 3t-132 3q-106 0 -307 -11t-231 -12zM533 1292q0 -50 4 -151t4 -152q0 -27 -0.5 -80 t-0.5 -79q0 -46 1 -69q42 -7 109 -7q82 0 143 13t110 44.5t74.5 89.5t25.5 142q0 70 -29 122.5t-79 82t-108 43.5t-124 14q-50 0 -130 -13zM538.5 165q0.5 -37 4.5 -83.5t12 -66.5q74 -32 140 -32q376 0 376 335q0 114 -41 180q-27 44 -61.5 74t-67.5 46.5t-80.5 25 t-84 10.5t-94.5 2q-73 0 -101 -10q0 -53 -0.5 -159t-0.5 -158q0 -8 -1 -67.5t-0.5 -96.5z" /> +<glyph unicode="" horiz-adv-x="1024" d="M0 -126l17 85q6 2 81.5 21.5t111.5 37.5q28 35 41 101q1 7 62 289t114 543.5t52 296.5v25q-24 13 -54.5 18.5t-69.5 8t-58 5.5l19 103q33 -2 120 -6.5t149.5 -7t120.5 -2.5q48 0 98.5 2.5t121 7t98.5 6.5q-5 -39 -19 -89q-30 -10 -101.5 -28.5t-108.5 -33.5 q-8 -19 -14 -42.5t-9 -40t-7.5 -45.5t-6.5 -42q-27 -148 -87.5 -419.5t-77.5 -355.5q-2 -9 -13 -58t-20 -90t-16 -83.5t-6 -57.5l1 -18q17 -4 185 -31q-3 -44 -16 -99q-11 0 -32.5 -1.5t-32.5 -1.5q-29 0 -87 10t-86 10q-138 2 -206 2q-51 0 -143 -9t-121 -11z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 1023v383l81 1l54 -27q12 -5 211 -5q44 0 132 2t132 2q36 0 107.5 -0.5t107.5 -0.5h293q6 0 21 -0.5t20.5 0t16 3t17.5 9t15 17.5l42 1q4 0 14 -0.5t14 -0.5q2 -112 2 -336q0 -80 -5 -109q-39 -14 -68 -18q-25 44 -54 128q-3 9 -11 48t-14.5 73.5t-7.5 35.5 q-6 8 -12 12.5t-15.5 6t-13 2.5t-18 0.5t-16.5 -0.5q-17 0 -66.5 0.5t-74.5 0.5t-64 -2t-71 -6q-9 -81 -8 -136q0 -94 2 -388t2 -455q0 -16 -2.5 -71.5t0 -91.5t12.5 -69q40 -21 124 -42.5t120 -37.5q5 -40 5 -50q0 -14 -3 -29l-34 -1q-76 -2 -218 8t-207 10q-50 0 -151 -9 t-152 -9q-3 51 -3 52v9q17 27 61.5 43t98.5 29t78 27q19 42 19 383q0 101 -3 303t-3 303v117q0 2 0.5 15.5t0.5 25t-1 25.5t-3 24t-5 14q-11 12 -162 12q-33 0 -93 -12t-80 -26q-19 -13 -34 -72.5t-31.5 -111t-42.5 -53.5q-42 26 -56 44zM1414 109.5q9 18.5 42 18.5h80v1024 h-80q-33 0 -42 18.5t11 44.5l126 162q20 26 49 26t49 -26l126 -162q20 -26 11 -44.5t-42 -18.5h-80v-1024h80q33 0 42 -18.5t-11 -44.5l-126 -162q-20 -26 -49 -26t-49 26l-126 162q-20 26 -11 44.5z" /> +<glyph unicode="" d="M0 1023v383l81 1l54 -27q12 -5 211 -5q44 0 132 2t132 2q70 0 246.5 1t304.5 0.5t247 -4.5q33 -1 56 31l42 1q4 0 14 -0.5t14 -0.5q2 -112 2 -336q0 -80 -5 -109q-39 -14 -68 -18q-25 44 -54 128q-3 9 -11 47.5t-15 73.5t-7 36q-10 13 -27 19q-5 2 -66 2q-30 0 -93 1 t-103 1t-94 -2t-96 -7q-9 -81 -8 -136l1 -152v52q0 -55 1 -154t1.5 -180t0.5 -153q0 -16 -2.5 -71.5t0 -91.5t12.5 -69q40 -21 124 -42.5t120 -37.5q5 -40 5 -50q0 -14 -3 -29l-34 -1q-76 -2 -218 8t-207 10q-50 0 -151 -9t-152 -9q-3 51 -3 52v9q17 27 61.5 43t98.5 29 t78 27q7 16 11.5 74t6 145.5t1.5 155t-0.5 153.5t-0.5 89q0 7 -2.5 21.5t-2.5 22.5q0 7 0.5 44t1 73t0 76.5t-3 67.5t-6.5 32q-11 12 -162 12q-41 0 -163 -13.5t-138 -24.5q-19 -12 -34 -71.5t-31.5 -111.5t-42.5 -54q-42 26 -56 44zM5 -64q0 28 26 49q4 3 36 30t59.5 49 t57.5 41.5t42 19.5q13 0 20.5 -10.5t10 -28.5t2.5 -33.5t-1.5 -33t-1.5 -19.5h1024q0 2 -1.5 19.5t-1.5 33t2.5 33.5t10 28.5t20.5 10.5q12 0 42 -19.5t57.5 -41.5t59.5 -49t36 -30q26 -21 26 -49t-26 -49q-4 -3 -36 -30t-59.5 -49t-57.5 -41.5t-42 -19.5q-13 0 -20.5 10.5 t-10 28.5t-2.5 33.5t1.5 33t1.5 19.5h-1024q0 -2 1.5 -19.5t1.5 -33t-2.5 -33.5t-10 -28.5t-20.5 -10.5q-12 0 -42 19.5t-57.5 41.5t-59.5 49t-36 30q-26 21 -26 49z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 64v128q0 26 19 45t45 19h1664q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-1664q-26 0 -45 19t-19 45zM0 448v128q0 26 19 45t45 19h1280q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-1280q-26 0 -45 19t-19 45zM0 832v128q0 26 19 45t45 19h1536 q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-1536q-26 0 -45 19t-19 45zM0 1216v128q0 26 19 45t45 19h1152q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-1152q-26 0 -45 19t-19 45z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 64v128q0 26 19 45t45 19h1664q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-1664q-26 0 -45 19t-19 45zM128 832v128q0 26 19 45t45 19h1408q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-1408q-26 0 -45 19t-19 45zM384 448v128q0 26 19 45t45 19h896 q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-896q-26 0 -45 19t-19 45zM512 1216v128q0 26 19 45t45 19h640q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-640q-26 0 -45 19t-19 45z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 64v128q0 26 19 45t45 19h1664q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-1664q-26 0 -45 19t-19 45zM128 832v128q0 26 19 45t45 19h1536q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-1536q-26 0 -45 19t-19 45zM384 448v128q0 26 19 45t45 19h1280 q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-1280q-26 0 -45 19t-19 45zM512 1216v128q0 26 19 45t45 19h1152q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-1152q-26 0 -45 19t-19 45z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 64v128q0 26 19 45t45 19h1664q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-1664q-26 0 -45 19t-19 45zM0 448v128q0 26 19 45t45 19h1664q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-1664q-26 0 -45 19t-19 45zM0 832v128q0 26 19 45t45 19h1664 q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-1664q-26 0 -45 19t-19 45zM0 1216v128q0 26 19 45t45 19h1664q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-1664q-26 0 -45 19t-19 45z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 32v192q0 13 9.5 22.5t22.5 9.5h192q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5t-22.5 -9.5h-192q-13 0 -22.5 9.5t-9.5 22.5zM0 416v192q0 13 9.5 22.5t22.5 9.5h192q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5t-22.5 -9.5h-192q-13 0 -22.5 9.5 t-9.5 22.5zM0 800v192q0 13 9.5 22.5t22.5 9.5h192q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5t-22.5 -9.5h-192q-13 0 -22.5 9.5t-9.5 22.5zM0 1184v192q0 13 9.5 22.5t22.5 9.5h192q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5t-22.5 -9.5h-192 q-13 0 -22.5 9.5t-9.5 22.5zM384 32v192q0 13 9.5 22.5t22.5 9.5h1344q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5t-22.5 -9.5h-1344q-13 0 -22.5 9.5t-9.5 22.5zM384 416v192q0 13 9.5 22.5t22.5 9.5h1344q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5 t-22.5 -9.5h-1344q-13 0 -22.5 9.5t-9.5 22.5zM384 800v192q0 13 9.5 22.5t22.5 9.5h1344q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5t-22.5 -9.5h-1344q-13 0 -22.5 9.5t-9.5 22.5zM384 1184v192q0 13 9.5 22.5t22.5 9.5h1344q13 0 22.5 -9.5t9.5 -22.5v-192 q0 -13 -9.5 -22.5t-22.5 -9.5h-1344q-13 0 -22.5 9.5t-9.5 22.5z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 32v192q0 13 9.5 22.5t22.5 9.5h1728q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5t-22.5 -9.5h-1728q-13 0 -22.5 9.5t-9.5 22.5zM0 1184v192q0 13 9.5 22.5t22.5 9.5h1728q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5t-22.5 -9.5h-1728q-13 0 -22.5 9.5 t-9.5 22.5zM32 704q0 14 9 23l288 288q9 9 23 9q13 0 22.5 -9.5t9.5 -22.5v-576q0 -13 -9.5 -22.5t-22.5 -9.5q-14 0 -23 9l-288 288q-9 9 -9 23zM640 416v192q0 13 9.5 22.5t22.5 9.5h1088q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5t-22.5 -9.5h-1088 q-13 0 -22.5 9.5t-9.5 22.5zM640 800v192q0 13 9.5 22.5t22.5 9.5h1088q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5t-22.5 -9.5h-1088q-13 0 -22.5 9.5t-9.5 22.5z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 32v192q0 13 9.5 22.5t22.5 9.5h1728q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5t-22.5 -9.5h-1728q-13 0 -22.5 9.5t-9.5 22.5zM0 416v576q0 13 9.5 22.5t22.5 9.5q14 0 23 -9l288 -288q9 -9 9 -23t-9 -23l-288 -288q-9 -9 -23 -9q-13 0 -22.5 9.5t-9.5 22.5z M0 1184v192q0 13 9.5 22.5t22.5 9.5h1728q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5t-22.5 -9.5h-1728q-13 0 -22.5 9.5t-9.5 22.5zM640 416v192q0 13 9.5 22.5t22.5 9.5h1088q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5t-22.5 -9.5h-1088q-13 0 -22.5 9.5 t-9.5 22.5zM640 800v192q0 13 9.5 22.5t22.5 9.5h1088q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5t-22.5 -9.5h-1088q-13 0 -22.5 9.5t-9.5 22.5z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 288v704q0 119 84.5 203.5t203.5 84.5h704q119 0 203.5 -84.5t84.5 -203.5v-165l403 402q18 19 45 19q12 0 25 -5q39 -17 39 -59v-1088q0 -42 -39 -59q-13 -5 -25 -5q-27 0 -45 19l-403 403v-166q0 -119 -84.5 -203.5t-203.5 -84.5h-704q-119 0 -203.5 84.5 t-84.5 203.5z" /> +<glyph unicode="" horiz-adv-x="1920" d="M0 32v1216q0 66 47 113t113 47h1600q66 0 113 -47t47 -113v-1216q0 -66 -47 -113t-113 -47h-1600q-66 0 -113 47t-47 113zM128 32q0 -13 9.5 -22.5t22.5 -9.5h1600q13 0 22.5 9.5t9.5 22.5v1216q0 13 -9.5 22.5t-22.5 9.5h-1600q-13 0 -22.5 -9.5t-9.5 -22.5v-1216z M256 128v192l320 320l160 -160l512 512l416 -416v-448h-1408zM256 960q0 80 56 136t136 56t136 -56t56 -136t-56 -136t-136 -56t-136 56t-56 136z" /> +<glyph unicode="" d="M0 -128v416l832 832l416 -416l-832 -832h-416zM128 128h128v-128h107l91 91l-235 235l-91 -91v-107zM298 384q0 -22 22 -22q10 0 17 7l542 542q7 7 7 17q0 22 -22 22q-10 0 -17 -7l-542 -542q-7 -7 -7 -17zM896 1184l166 165q36 38 90 38q53 0 91 -38l235 -234 q37 -39 37 -91q0 -53 -37 -90l-166 -166z" /> +<glyph unicode="" horiz-adv-x="1024" d="M0 896q0 212 150 362t362 150t362 -150t150 -362q0 -109 -33 -179l-364 -774q-16 -33 -47.5 -52t-67.5 -19t-67.5 19t-46.5 52l-365 774q-33 70 -33 179zM256 896q0 -106 75 -181t181 -75t181 75t75 181t-75 181t-181 75t-181 -75t-75 -181z" /> +<glyph unicode="" d="M0 640q0 209 103 385.5t279.5 279.5t385.5 103t385.5 -103t279.5 -279.5t103 -385.5t-103 -385.5t-279.5 -279.5t-385.5 -103t-385.5 103t-279.5 279.5t-103 385.5zM224 640q0 -148 73 -273t198 -198t273 -73v1088q-148 0 -273 -73t-198 -198t-73 -273z" /> +<glyph unicode="" horiz-adv-x="1024" d="M0 512q0 145 81 275q6 9 62.5 90.5t101 151t99.5 178t83 201.5q9 30 34 47t51 17t51.5 -17t33.5 -47q28 -93 83 -201.5t99.5 -178t101 -151t62.5 -90.5q81 -127 81 -275q0 -212 -150 -362t-362 -150t-362 150t-150 362zM256 384q0 -53 37.5 -90.5t90.5 -37.5t90.5 37.5 t37.5 90.5q0 36 -20 69q-1 1 -15.5 22.5t-25.5 38t-25 44t-21 50.5q-4 16 -21 16t-21 -16q-7 -23 -21 -50.5t-25 -44t-25.5 -38t-15.5 -22.5q-20 -33 -20 -69z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 288v832q0 119 84.5 203.5t203.5 84.5h832q63 0 117 -25q15 -7 18 -23q3 -17 -9 -29l-49 -49q-14 -14 -32 -8q-23 6 -45 6h-832q-66 0 -113 -47t-47 -113v-832q0 -66 47 -113t113 -47h832q66 0 113 47t47 113v126q0 13 9 22l64 64q15 15 35 7t20 -29v-190 q0 -119 -84.5 -203.5t-203.5 -84.5h-832q-119 0 -203.5 84.5t-84.5 203.5zM640 256v288l672 672l288 -288l-672 -672h-288zM736 448h96v-96h56l116 116l-152 152l-116 -116v-56zM944 688q16 -16 33 1l350 350q17 17 1 33t-33 -1l-350 -350q-17 -17 -1 -33zM1376 1280l92 92 q28 28 68 28t68 -28l152 -152q28 -28 28 -68t-28 -68l-92 -92z" /> +<glyph unicode="" horiz-adv-x="1664" d="M0 288v832q0 119 84.5 203.5t203.5 84.5h255q13 0 22.5 -9.5t9.5 -22.5q0 -27 -26 -32q-77 -26 -133 -60q-10 -4 -16 -4h-112q-66 0 -113 -47t-47 -113v-832q0 -66 47 -113t113 -47h832q66 0 113 47t47 113v214q0 19 18 29q28 13 54 37q16 16 35 8q21 -9 21 -29v-259 q0 -119 -84.5 -203.5t-203.5 -84.5h-832q-119 0 -203.5 84.5t-84.5 203.5zM256 704q0 49 3.5 91t14 90t28 88t47 81.5t68.5 74t94.5 61.5t124.5 48.5t159.5 30.5t196.5 11h160v192q0 42 39 59q13 5 25 5q26 0 45 -19l384 -384q19 -19 19 -45t-19 -45l-384 -384 q-18 -19 -45 -19q-12 0 -25 5q-39 17 -39 59v192h-160q-323 0 -438 -131q-119 -137 -74 -473q3 -23 -20 -34q-8 -2 -12 -2q-16 0 -26 13q-10 14 -21 31t-39.5 68.5t-49.5 99.5t-38.5 114t-17.5 122z" /> +<glyph unicode="" horiz-adv-x="1664" d="M0 288v832q0 119 84.5 203.5t203.5 84.5h832q63 0 117 -25q15 -7 18 -23q3 -17 -9 -29l-49 -49q-10 -10 -23 -10q-3 0 -9 2q-23 6 -45 6h-832q-66 0 -113 -47t-47 -113v-832q0 -66 47 -113t113 -47h832q66 0 113 47t47 113v254q0 13 9 22l64 64q10 10 23 10q6 0 12 -3 q20 -8 20 -29v-318q0 -119 -84.5 -203.5t-203.5 -84.5h-832q-119 0 -203.5 84.5t-84.5 203.5zM257 768q0 33 24 57l110 110q24 24 57 24t57 -24l263 -263l647 647q24 24 57 24t57 -24l110 -110q24 -24 24 -57t-24 -57l-814 -814q-24 -24 -57 -24t-57 24l-430 430 q-24 24 -24 57z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 640q0 26 19 45l256 256q19 19 45 19t45 -19t19 -45v-128h384v384h-128q-26 0 -45 19t-19 45t19 45l256 256q19 19 45 19t45 -19l256 -256q19 -19 19 -45t-19 -45t-45 -19h-128v-384h384v128q0 26 19 45t45 19t45 -19l256 -256q19 -19 19 -45t-19 -45l-256 -256 q-19 -19 -45 -19t-45 19t-19 45v128h-384v-384h128q26 0 45 -19t19 -45t-19 -45l-256 -256q-19 -19 -45 -19t-45 19l-256 256q-19 19 -19 45t19 45t45 19h128v384h-384v-128q0 -26 -19 -45t-45 -19t-45 19l-256 256q-19 19 -19 45z" /> +<glyph unicode="" horiz-adv-x="1024" d="M0 -64v1408q0 26 19 45t45 19h128q26 0 45 -19t19 -45v-678q4 11 13 19l710 710q19 19 32 13t13 -32v-1472q0 -26 -13 -32t-32 13l-710 710q-9 9 -13 19v-678q0 -26 -19 -45t-45 -19h-128q-26 0 -45 19t-19 45z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 -64v1408q0 26 19 45t45 19h128q26 0 45 -19t19 -45v-678q4 11 13 19l710 710q19 19 32 13t13 -32v-710q4 11 13 19l710 710q19 19 32 13t13 -32v-1472q0 -26 -13 -32t-32 13l-710 710q-9 9 -13 19v-710q0 -26 -13 -32t-32 13l-710 710q-9 9 -13 19v-678q0 -26 -19 -45 t-45 -19h-128q-26 0 -45 19t-19 45z" /> +<glyph unicode="" horiz-adv-x="1664" d="M122 640q0 26 19 45l710 710q19 19 32 13t13 -32v-710q5 11 13 19l710 710q19 19 32 13t13 -32v-1472q0 -26 -13 -32t-32 13l-710 710q-8 9 -13 19v-710q0 -26 -13 -32t-32 13l-710 710q-19 19 -19 45z" /> +<glyph unicode="" horiz-adv-x="1408" d="M0 -96v1472q0 26 16.5 36t39.5 -3l1328 -738q23 -13 23 -31t-23 -31l-1328 -738q-23 -13 -39.5 -3t-16.5 36z" /> +<glyph unicode="" d="M0 -64v1408q0 26 19 45t45 19h512q26 0 45 -19t19 -45v-1408q0 -26 -19 -45t-45 -19h-512q-26 0 -45 19t-19 45zM896 -64v1408q0 26 19 45t45 19h512q26 0 45 -19t19 -45v-1408q0 -26 -19 -45t-45 -19h-512q-26 0 -45 19t-19 45z" /> +<glyph unicode="" d="M0 -64v1408q0 26 19 45t45 19h1408q26 0 45 -19t19 -45v-1408q0 -26 -19 -45t-45 -19h-1408q-26 0 -45 19t-19 45z" /> +<glyph unicode="" horiz-adv-x="1664" d="M0 -96v1472q0 26 13 32t32 -13l710 -710q8 -8 13 -19v710q0 26 13 32t32 -13l710 -710q19 -19 19 -45t-19 -45l-710 -710q-19 -19 -32 -13t-13 32v710q-5 -10 -13 -19l-710 -710q-19 -19 -32 -13t-13 32z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 -96v1472q0 26 13 32t32 -13l710 -710q8 -8 13 -19v710q0 26 13 32t32 -13l710 -710q8 -8 13 -19v678q0 26 19 45t45 19h128q26 0 45 -19t19 -45v-1408q0 -26 -19 -45t-45 -19h-128q-26 0 -45 19t-19 45v678q-5 -10 -13 -19l-710 -710q-19 -19 -32 -13t-13 32v710 q-5 -10 -13 -19l-710 -710q-19 -19 -32 -13t-13 32z" /> +<glyph unicode="" horiz-adv-x="1024" d="M0 -96v1472q0 26 13 32t32 -13l710 -710q8 -8 13 -19v678q0 26 19 45t45 19h128q26 0 45 -19t19 -45v-1408q0 -26 -19 -45t-45 -19h-128q-26 0 -45 19t-19 45v678q-5 -10 -13 -19l-710 -710q-19 -19 -32 -13t-13 32z" /> +<glyph unicode="" horiz-adv-x="1538" d="M1 64v256q0 26 19 45t45 19h1408q26 0 45 -19t19 -45v-256q0 -26 -19 -45t-45 -19h-1408q-26 0 -45 19t-19 45zM1 525q-6 13 13 32l710 710q19 19 45 19t45 -19l710 -710q19 -19 13 -32t-32 -13h-1472q-26 0 -32 13z" /> +<glyph unicode="" horiz-adv-x="1280" d="M154 704q0 26 19 45l742 742q19 19 45 19t45 -19l166 -166q19 -19 19 -45t-19 -45l-531 -531l531 -531q19 -19 19 -45t-19 -45l-166 -166q-19 -19 -45 -19t-45 19l-742 742q-19 19 -19 45z" /> +<glyph unicode="" horiz-adv-x="1280" d="M90 128q0 26 19 45l531 531l-531 531q-19 19 -19 45t19 45l166 166q19 19 45 19t45 -19l742 -742q19 -19 19 -45t-19 -45l-742 -742q-19 -19 -45 -19t-45 19l-166 166q-19 19 -19 45z" /> +<glyph unicode="" d="M0 640q0 209 103 385.5t279.5 279.5t385.5 103t385.5 -103t279.5 -279.5t103 -385.5t-103 -385.5t-279.5 -279.5t-385.5 -103t-385.5 103t-279.5 279.5t-103 385.5zM320 576q0 -26 19 -45t45 -19h256v-256q0 -26 19 -45t45 -19h128q26 0 45 19t19 45v256h256q26 0 45 19 t19 45v128q0 26 -19 45t-45 19h-256v256q0 26 -19 45t-45 19h-128q-26 0 -45 -19t-19 -45v-256h-256q-26 0 -45 -19t-19 -45v-128z" /> +<glyph unicode="" d="M0 640q0 209 103 385.5t279.5 279.5t385.5 103t385.5 -103t279.5 -279.5t103 -385.5t-103 -385.5t-279.5 -279.5t-385.5 -103t-385.5 103t-279.5 279.5t-103 385.5zM320 576q0 -26 19 -45t45 -19h768q26 0 45 19t19 45v128q0 26 -19 45t-45 19h-768q-26 0 -45 -19 t-19 -45v-128z" /> +<glyph unicode="" d="M0 640q0 209 103 385.5t279.5 279.5t385.5 103t385.5 -103t279.5 -279.5t103 -385.5t-103 -385.5t-279.5 -279.5t-385.5 -103t-385.5 103t-279.5 279.5t-103 385.5zM387 414q0 -27 19 -46l90 -90q19 -19 46 -19q26 0 45 19l181 181l181 -181q19 -19 45 -19q27 0 46 19 l90 90q19 19 19 46q0 26 -19 45l-181 181l181 181q19 19 19 45q0 27 -19 46l-90 90q-19 19 -46 19q-26 0 -45 -19l-181 -181l-181 181q-19 19 -45 19q-27 0 -46 -19l-90 -90q-19 -19 -19 -46q0 -26 19 -45l181 -181l-181 -181q-19 -19 -19 -45z" /> +<glyph unicode="" d="M0 640q0 209 103 385.5t279.5 279.5t385.5 103t385.5 -103t279.5 -279.5t103 -385.5t-103 -385.5t-279.5 -279.5t-385.5 -103t-385.5 103t-279.5 279.5t-103 385.5zM252 621q0 -27 18 -45l362 -362q19 -19 45 -19q27 0 46 19l543 543q18 18 18 45q0 28 -18 46l-91 90 q-19 19 -45 19t-45 -19l-408 -407l-226 226q-19 19 -45 19t-45 -19l-91 -90q-18 -18 -18 -46z" /> +<glyph unicode="" d="M0 640q0 209 103 385.5t279.5 279.5t385.5 103t385.5 -103t279.5 -279.5t103 -385.5t-103 -385.5t-279.5 -279.5t-385.5 -103t-385.5 103t-279.5 279.5t-103 385.5zM417 939q-15 -24 8 -42l132 -100q7 -6 19 -6q16 0 25 12q53 68 86 92q34 24 86 24q48 0 85.5 -26 t37.5 -59q0 -38 -20 -61t-68 -45q-63 -28 -115.5 -86.5t-52.5 -125.5v-36q0 -14 9 -23t23 -9h192q14 0 23 9t9 23q0 19 21.5 49.5t54.5 49.5q32 18 49 28.5t46 35t44.5 48t28 60.5t12.5 81q0 88 -55.5 163t-138.5 116t-170 41q-243 0 -371 -213zM640 160q0 -14 9 -23t23 -9 h192q14 0 23 9t9 23v192q0 14 -9 23t-23 9h-192q-14 0 -23 -9t-9 -23v-192z" /> +<glyph unicode="" d="M0 640q0 209 103 385.5t279.5 279.5t385.5 103t385.5 -103t279.5 -279.5t103 -385.5t-103 -385.5t-279.5 -279.5t-385.5 -103t-385.5 103t-279.5 279.5t-103 385.5zM512 160q0 -14 9 -23t23 -9h448q14 0 23 9t9 23v160q0 14 -9 23t-23 9h-96v512q0 14 -9 23t-23 9h-320 q-14 0 -23 -9t-9 -23v-160q0 -14 9 -23t23 -9h96v-320h-96q-14 0 -23 -9t-9 -23v-160zM640 1056q0 -14 9 -23t23 -9h192q14 0 23 9t9 23v160q0 14 -9 23t-23 9h-192q-14 0 -23 -9t-9 -23v-160z" /> +<glyph unicode="" d="M0 576v128q0 26 19 45t45 19h143q37 161 154.5 278.5t278.5 154.5v143q0 26 19 45t45 19h128q26 0 45 -19t19 -45v-143q161 -37 278.5 -154.5t154.5 -278.5h143q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-143q-37 -161 -154.5 -278.5t-278.5 -154.5v-143 q0 -26 -19 -45t-45 -19h-128q-26 0 -45 19t-19 45v143q-161 37 -278.5 154.5t-154.5 278.5h-143q-26 0 -45 19t-19 45zM339 512q32 -108 112.5 -188.5t188.5 -112.5v109q0 26 19 45t45 19h128q26 0 45 -19t19 -45v-109q108 32 188.5 112.5t112.5 188.5h-109q-26 0 -45 19 t-19 45v128q0 26 19 45t45 19h109q-32 108 -112.5 188.5t-188.5 112.5v-109q0 -26 -19 -45t-45 -19h-128q-26 0 -45 19t-19 45v109q-108 -32 -188.5 -112.5t-112.5 -188.5h109q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-109z" /> +<glyph unicode="" d="M0 640q0 209 103 385.5t279.5 279.5t385.5 103t385.5 -103t279.5 -279.5t103 -385.5t-103 -385.5t-279.5 -279.5t-385.5 -103t-385.5 103t-279.5 279.5t-103 385.5zM224 640q0 -148 73 -273t198 -198t273 -73t273 73t198 198t73 273t-73 273t-198 198t-273 73t-273 -73 t-198 -198t-73 -273zM429 480q0 13 10 23l137 137l-137 137q-10 10 -10 23t10 23l146 146q10 10 23 10t23 -10l137 -137l137 137q10 10 23 10t23 -10l146 -146q10 -10 10 -23t-10 -23l-137 -137l137 -137q10 -10 10 -23t-10 -23l-146 -146q-10 -10 -23 -10t-23 10l-137 137 l-137 -137q-10 -10 -23 -10t-23 10l-146 146q-10 10 -10 23z" /> +<glyph unicode="" d="M0 640q0 209 103 385.5t279.5 279.5t385.5 103t385.5 -103t279.5 -279.5t103 -385.5t-103 -385.5t-279.5 -279.5t-385.5 -103t-385.5 103t-279.5 279.5t-103 385.5zM224 640q0 -148 73 -273t198 -198t273 -73t273 73t198 198t73 273t-73 273t-198 198t-273 73t-273 -73 t-198 -198t-73 -273zM346 640q0 26 19 45l102 102q19 19 45 19t45 -19l147 -147l275 275q19 19 45 19t45 -19l102 -102q19 -19 19 -45t-19 -45l-422 -422q-19 -19 -45 -19t-45 19l-294 294q-19 19 -19 45z" /> +<glyph unicode="" d="M0 643q0 157 61 299.5t163.5 245.5t245 164t298.5 61t298.5 -61t245 -164t163.5 -245.5t61 -299.5t-61 -300t-163.5 -246t-245 -164t-298.5 -61t-298.5 61t-245 164t-163.5 246t-61 300zM224 643q0 -162 89 -299l755 754q-135 91 -300 91q-148 0 -273 -73t-198 -199 t-73 -274zM471 185q137 -89 297 -89q111 0 211.5 43.5t173.5 116.5t116 174.5t43 212.5q0 161 -87 295z" /> +<glyph unicode="" d="M64 576q0 52 37 91l651 650q38 38 91 38q52 0 90 -38l75 -74q38 -38 38 -91t-38 -91l-293 -293h704q52 0 84.5 -37.5t32.5 -90.5v-128q0 -53 -32.5 -90.5t-84.5 -37.5h-704l293 -294q38 -36 38 -90t-38 -90l-75 -76q-37 -37 -90 -37q-52 0 -91 37l-651 652q-37 37 -37 90 z" /> +<glyph unicode="" d="M0 512v128q0 53 32.5 90.5t84.5 37.5h704l-293 294q-38 36 -38 90t38 90l75 75q38 38 90 38q53 0 91 -38l651 -651q37 -35 37 -90q0 -54 -37 -91l-651 -651q-39 -37 -91 -37q-51 0 -90 37l-75 75q-38 38 -38 91t38 91l293 293h-704q-52 0 -84.5 37.5t-32.5 90.5z" /> +<glyph unicode="" horiz-adv-x="1664" d="M53 565q0 53 38 91l651 651q35 37 90 37q54 0 91 -37l651 -651q37 -39 37 -91q0 -51 -37 -90l-75 -75q-38 -38 -91 -38q-54 0 -90 38l-294 293v-704q0 -52 -37.5 -84.5t-90.5 -32.5h-128q-53 0 -90.5 32.5t-37.5 84.5v704l-294 -293q-36 -38 -90 -38t-90 38l-75 75 q-38 38 -38 90z" /> +<glyph unicode="" horiz-adv-x="1664" d="M53 704q0 53 38 91l74 75q39 37 91 37q53 0 90 -37l294 -294v704q0 52 38 90t90 38h128q52 0 90 -38t38 -90v-704l294 294q37 37 90 37q52 0 91 -37l75 -75q37 -39 37 -91q0 -53 -37 -90l-651 -652q-39 -37 -91 -37q-53 0 -90 37l-651 652q-38 36 -38 90z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 416q0 199 53 333q162 403 875 403h224v256q0 26 19 45t45 19t45 -19l512 -512q19 -19 19 -45t-19 -45l-512 -512q-19 -19 -45 -19t-45 19t-19 45v256h-224q-98 0 -175.5 -6t-154 -21.5t-133 -42.5t-105.5 -69.5t-80 -101t-48.5 -138.5t-17.5 -181q0 -55 5 -123 q0 -6 2.5 -23.5t2.5 -26.5q0 -15 -8.5 -25t-23.5 -10q-16 0 -28 17q-7 9 -13 22t-13.5 30t-10.5 24q-127 285 -127 451z" /> +<glyph unicode="" d="M0 -64v448q0 26 19 45t45 19t45 -19l144 -144l332 332q10 10 23 10t23 -10l114 -114q10 -10 10 -23t-10 -23l-332 -332l144 -144q19 -19 19 -45t-19 -45t-45 -19h-448q-26 0 -45 19t-19 45zM781 800q0 13 10 23l332 332l-144 144q-19 19 -19 45t19 45t45 19h448 q26 0 45 -19t19 -45v-448q0 -26 -19 -45t-45 -19t-45 19l-144 144l-332 -332q-10 -10 -23 -10t-23 10l-114 114q-10 10 -10 23z" /> +<glyph unicode="" d="M13 32q0 13 10 23l332 332l-144 144q-19 19 -19 45t19 45t45 19h448q26 0 45 -19t19 -45v-448q0 -26 -19 -45t-45 -19t-45 19l-144 144l-332 -332q-10 -10 -23 -10t-23 10l-114 114q-10 10 -10 23zM768 704v448q0 26 19 45t45 19t45 -19l144 -144l332 332q10 10 23 10 t23 -10l114 -114q10 -10 10 -23t-10 -23l-332 -332l144 -144q19 -19 19 -45t-19 -45t-45 -19h-448q-26 0 -45 19t-19 45z" /> +<glyph unicode="" horiz-adv-x="1408" d="M0 608v192q0 40 28 68t68 28h416v416q0 40 28 68t68 28h192q40 0 68 -28t28 -68v-416h416q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-416v-416q0 -40 -28 -68t-68 -28h-192q-40 0 -68 28t-28 68v416h-416q-40 0 -68 28t-28 68z" /> +<glyph unicode="" horiz-adv-x="1408" d="M0 608v192q0 40 28 68t68 28h1216q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-1216q-40 0 -68 28t-28 68z" /> +<glyph unicode="" horiz-adv-x="1664" d="M122.5 408.5q13.5 51.5 59.5 77.5l266 154l-266 154q-46 26 -59.5 77.5t12.5 97.5l64 110q26 46 77.5 59.5t97.5 -12.5l266 -153v307q0 52 38 90t90 38h128q52 0 90 -38t38 -90v-307l266 153q46 26 97.5 12.5t77.5 -59.5l64 -110q26 -46 12.5 -97.5t-59.5 -77.5 l-266 -154l266 -154q46 -26 59.5 -77.5t-12.5 -97.5l-64 -110q-26 -46 -77.5 -59.5t-97.5 12.5l-266 153v-307q0 -52 -38 -90t-90 -38h-128q-52 0 -90 38t-38 90v307l-266 -153q-46 -26 -97.5 -12.5t-77.5 59.5l-64 110q-26 46 -12.5 97.5z" /> +<glyph unicode="" d="M0 640q0 209 103 385.5t279.5 279.5t385.5 103t385.5 -103t279.5 -279.5t103 -385.5t-103 -385.5t-279.5 -279.5t-385.5 -103t-385.5 103t-279.5 279.5t-103 385.5zM624 1126l17 -621q0 -10 10 -17.5t24 -7.5h185q14 0 23.5 7.5t10.5 17.5l18 621q0 12 -10 18 q-10 8 -24 8h-220q-14 0 -24 -8q-10 -6 -10 -18zM640 161q0 -13 10 -23t23 -10h192q13 0 22 9.5t9 23.5v190q0 14 -9 23.5t-22 9.5h-192q-13 0 -23 -10t-10 -23v-190z" /> +<glyph unicode="" d="M0 544v320q0 14 9 23t23 9h440q-93 0 -158.5 65.5t-65.5 158.5t65.5 158.5t158.5 65.5q107 0 168 -77l128 -165l128 165q61 77 168 77q93 0 158.5 -65.5t65.5 -158.5t-65.5 -158.5t-158.5 -65.5h440q14 0 23 -9t9 -23v-320q0 -14 -9 -23t-23 -9h-96v-416q0 -40 -28 -68 t-68 -28h-1088q-40 0 -68 28t-28 68v416h-96q-14 0 -23 9t-9 23zM376 1120q0 -40 28 -68t68 -28h195l-126 161q-26 31 -69 31q-40 0 -68 -28t-28 -68zM608 180q0 -25 18 -38.5t46 -13.5h192q28 0 46 13.5t18 38.5v56v468v192h-320v-192v-468v-56zM870 1024h194q40 0 68 28 t28 68t-28 68t-68 28q-43 0 -69 -31z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 121q0 35 31 73.5t68 65.5t68 56t31 48q0 4 -14 38t-16 44q-9 51 -9 104q0 115 43.5 220t119 184.5t170.5 139t204 95.5q55 18 145 25.5t179.5 9t178.5 6t163.5 24t113.5 56.5l29.5 29.5t29.5 28t27 20t36.5 16t43.5 4.5q39 0 70.5 -46t47.5 -112t24 -124t8 -96 q0 -95 -20 -193q-46 -224 -184.5 -383t-357.5 -268q-214 -108 -438 -108q-148 0 -286 47q-15 5 -88 42t-96 37q-16 0 -39.5 -32t-45 -70t-52.5 -70t-60 -32q-30 0 -51 11t-31 24t-27 42q-2 4 -6 11t-5.5 10t-3 9.5t-1.5 13.5zM384 448q0 -26 19 -45t45 -19q24 0 45 19 q27 24 74 71t67 66q137 124 268.5 176t313.5 52q26 0 45 19t19 45t-19 45t-45 19q-172 0 -318 -49.5t-259.5 -134t-235.5 -219.5q-19 -21 -19 -45z" /> +<glyph unicode="" horiz-adv-x="1408" d="M0 -160q0 13 9.5 22.5t22.5 9.5h1344q13 0 22.5 -9.5t9.5 -22.5v-64q0 -13 -9.5 -22.5t-22.5 -9.5h-1344q-13 0 -22.5 9.5t-9.5 22.5v64zM256 640q0 78 24.5 144t64 112.5t87.5 88t96 77.5t87.5 72t64 81.5t24.5 96.5q0 94 -66 224l3 -1l-1 1q90 -41 160 -83t138.5 -100 t113.5 -122.5t72.5 -150.5t27.5 -184q0 -78 -24.5 -144t-64 -112.5t-87.5 -88t-96 -77.5t-87.5 -72t-64 -81.5t-24.5 -96.5q0 -96 67 -224l-4 1l1 -1q-90 41 -160 83t-138.5 100t-113.5 122.5t-72.5 150.5t-27.5 184z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 576q0 34 20 69q140 229 376.5 368t499.5 139t499.5 -139t376.5 -368q20 -35 20 -69t-20 -69q-140 -230 -376.5 -368.5t-499.5 -138.5t-499.5 139t-376.5 368q-20 35 -20 69zM128 576q133 -205 333.5 -326.5t434.5 -121.5t434.5 121.5t333.5 326.5q-152 236 -381 353 q61 -104 61 -225q0 -185 -131.5 -316.5t-316.5 -131.5t-316.5 131.5t-131.5 316.5q0 121 61 225q-229 -117 -381 -353zM592 704q0 -20 14 -34t34 -14t34 14t14 34q0 86 61 147t147 61q20 0 34 14t14 34t-14 34t-34 14q-125 0 -214.5 -89.5t-89.5 -214.5z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 576q0 38 20 69q153 235 380 371t496 136q89 0 180 -17l54 97q10 16 28 16q5 0 18 -6t31 -15.5t33 -18.5t31.5 -18.5t19.5 -11.5q16 -10 16 -27q0 -7 -1 -9q-105 -188 -315 -566t-316 -567l-49 -89q-10 -16 -28 -16q-12 0 -134 70q-16 10 -16 28q0 12 44 87 q-143 65 -263.5 173t-208.5 245q-20 31 -20 69zM128 576q167 -258 427 -375l78 141q-87 63 -136 159t-49 203q0 121 61 225q-229 -117 -381 -353zM592 704q0 -20 14 -34t34 -14t34 14t14 34q0 86 61 147t147 61q20 0 34 14t14 34t-14 34t-34 14q-125 0 -214.5 -89.5 t-89.5 -214.5zM896 0l74 132q212 18 392.5 137t301.5 307q-115 179 -282 294l63 112q95 -64 182.5 -153t144.5 -184q20 -34 20 -69t-20 -69q-39 -64 -109 -145q-150 -172 -347.5 -267t-419.5 -95zM1056 286l280 502q8 -45 8 -84q0 -139 -79 -253.5t-209 -164.5z" /> +<glyph unicode="" horiz-adv-x="1792" d="M16 61l768 1408q17 31 47 49t65 18t65 -18t47 -49l768 -1408q35 -63 -2 -126q-17 -29 -46.5 -46t-63.5 -17h-1536q-34 0 -63.5 17t-46.5 46q-37 63 -2 126zM752 992l17 -457q0 -10 10 -16.5t24 -6.5h185q14 0 23.5 6.5t10.5 16.5l18 459q0 12 -10 19q-13 11 -24 11h-220 q-11 0 -24 -11q-10 -7 -10 -21zM768 161q0 -14 9.5 -23.5t22.5 -9.5h192q13 0 22.5 9.5t9.5 23.5v190q0 14 -9.5 23.5t-22.5 9.5h-192q-13 0 -22.5 -9.5t-9.5 -23.5v-190z" /> +<glyph unicode="" horiz-adv-x="1408" d="M0 477q-1 13 9 25l96 97q9 9 23 9q6 0 8 -1l194 -53l259 259l-508 279q-14 8 -17 24q-2 16 9 27l128 128q14 13 30 8l665 -159l160 160q76 76 172 108t148 -12q44 -52 12 -148t-108 -172l-161 -161l160 -696q5 -19 -12 -33l-128 -96q-7 -6 -19 -6q-4 0 -7 1q-15 3 -21 16 l-279 508l-259 -259l53 -194q5 -17 -8 -31l-96 -96q-9 -9 -23 -9h-2q-15 2 -24 13l-189 252l-252 189q-11 7 -13 23z" /> +<glyph unicode="" horiz-adv-x="1664" d="M0 -128v1280q0 52 38 90t90 38h128v96q0 66 47 113t113 47h64q66 0 113 -47t47 -113v-96h384v96q0 66 47 113t113 47h64q66 0 113 -47t47 -113v-96h128q52 0 90 -38t38 -90v-1280q0 -52 -38 -90t-90 -38h-1408q-52 0 -90 38t-38 90zM128 -128h288v288h-288v-288zM128 224 h288v320h-288v-320zM128 608h288v288h-288v-288zM384 1088q0 -13 9.5 -22.5t22.5 -9.5h64q13 0 22.5 9.5t9.5 22.5v288q0 13 -9.5 22.5t-22.5 9.5h-64q-13 0 -22.5 -9.5t-9.5 -22.5v-288zM480 -128h320v288h-320v-288zM480 224h320v320h-320v-320zM480 608h320v288h-320 v-288zM864 -128h320v288h-320v-288zM864 224h320v320h-320v-320zM864 608h320v288h-320v-288zM1152 1088q0 -13 9.5 -22.5t22.5 -9.5h64q13 0 22.5 9.5t9.5 22.5v288q0 13 -9.5 22.5t-22.5 9.5h-64q-13 0 -22.5 -9.5t-9.5 -22.5v-288zM1248 -128h288v288h-288v-288z M1248 224h288v320h-288v-320zM1248 608h288v288h-288v-288z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 160v192q0 14 9 23t23 9h224q48 0 87 15t69 45t51 61.5t45 77.5q32 62 78 171q29 66 49.5 111t54 105t64 100t74 83t90 68.5t106.5 42t128 16.5h256v192q0 14 9 23t23 9q12 0 24 -10l319 -319q9 -9 9 -23t-9 -23l-320 -320q-9 -9 -23 -9q-13 0 -22.5 9.5t-9.5 22.5v192 h-256q-48 0 -87 -15t-69 -45t-51 -61.5t-45 -77.5q-32 -62 -78 -171q-29 -66 -49.5 -111t-54 -105t-64 -100t-74 -83t-90 -68.5t-106.5 -42t-128 -16.5h-224q-14 0 -23 9t-9 23zM0 1056v192q0 14 9 23t23 9h224q250 0 410 -225q-60 -92 -137 -273q-22 45 -37 72.5 t-40.5 63.5t-51 56.5t-63 35t-81.5 14.5h-224q-14 0 -23 9t-9 23zM743 353q59 93 136 273q22 -45 37 -72.5t40.5 -63.5t51 -56.5t63 -35t81.5 -14.5h256v192q0 14 9 23t23 9q12 0 24 -10l319 -319q9 -9 9 -23t-9 -23l-320 -320q-9 -9 -23 -9q-13 0 -22.5 9.5t-9.5 22.5v192 q-32 0 -85 -0.5t-81 -1t-73 1t-71 5t-64 10.5t-63 18.5t-58 28.5t-59 40t-55 53.5t-56 69.5z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 640q0 130 71 248.5t191 204.5t286 136.5t348 50.5q244 0 450 -85.5t326 -233t120 -321.5t-120 -321.5t-326 -233t-450 -85.5q-70 0 -145 8q-198 -175 -460 -242q-49 -14 -114 -22q-17 -2 -30.5 9t-17.5 29v1q-3 4 -0.5 12t2 10t4.5 9.5l6 9t7 8.5t8 9q7 8 31 34.5 t34.5 38t31 39.5t32.5 51t27 59t26 76q-157 89 -247.5 220t-90.5 281z" /> +<glyph unicode="" d="M0 576v128q0 26 19 45t45 19h384q26 0 45 -19t19 -45v-128q0 -52 23.5 -90t53.5 -57t71 -30t64 -13t44 -2t44 2t64 13t71 30t53.5 57t23.5 90v128q0 26 19 45t45 19h384q26 0 45 -19t19 -45v-128q0 -201 -98.5 -362t-274 -251.5t-395.5 -90.5t-395.5 90.5t-274 251.5 t-98.5 362zM0 960v384q0 26 19 45t45 19h384q26 0 45 -19t19 -45v-384q0 -26 -19 -45t-45 -19h-384q-26 0 -45 19t-19 45zM1024 960v384q0 26 19 45t45 | 504 | chore(docs-app): Update assets for index page | 0 | .svg | svg | mit | Semantic-Org/Semantic-UI-Angular |
10071610 | <NME> icons.svg <BEF> ADDFILE <MSG> chore(docs-app): Update assets for index page <DFF> @@ -0,0 +1,504 @@ +<?xml version="1.0" standalone="no"?> +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" > +<svg xmlns="http://www.w3.org/2000/svg"> +<metadata></metadata> +<defs> +<font id="fontawesomeregular" horiz-adv-x="1536" > +<font-face units-per-em="1792" ascent="1536" descent="-256" /> +<missing-glyph horiz-adv-x="448" /> +<glyph unicode=" " horiz-adv-x="448" /> +<glyph unicode="	" horiz-adv-x="448" /> +<glyph unicode=" " horiz-adv-x="448" /> +<glyph unicode="¨" horiz-adv-x="1792" /> +<glyph unicode="©" horiz-adv-x="1792" /> +<glyph unicode="®" horiz-adv-x="1792" /> +<glyph unicode="´" horiz-adv-x="1792" /> +<glyph unicode="Æ" horiz-adv-x="1792" /> +<glyph unicode="Ø" horiz-adv-x="1792" /> +<glyph unicode=" " horiz-adv-x="768" /> +<glyph unicode=" " horiz-adv-x="1537" /> +<glyph unicode=" " horiz-adv-x="768" /> +<glyph unicode=" " horiz-adv-x="1537" /> +<glyph unicode=" " horiz-adv-x="512" /> +<glyph unicode=" " horiz-adv-x="384" /> +<glyph unicode=" " horiz-adv-x="256" /> +<glyph unicode=" " horiz-adv-x="256" /> +<glyph unicode=" " horiz-adv-x="192" /> +<glyph unicode=" " horiz-adv-x="307" /> +<glyph unicode=" " horiz-adv-x="85" /> +<glyph unicode=" " horiz-adv-x="307" /> +<glyph unicode=" " horiz-adv-x="384" /> +<glyph unicode="™" horiz-adv-x="1792" /> +<glyph unicode="∞" horiz-adv-x="1792" /> +<glyph unicode="≠" horiz-adv-x="1792" /> +<glyph unicode="◼" horiz-adv-x="500" d="M0 0z" /> +<glyph unicode="" horiz-adv-x="1792" d="M93 1350q0 23 18 36.5t38 17.5t43 4h1408q23 0 43 -4t38 -17.5t18 -36.5q0 -35 -43 -78l-632 -632v-768h320q26 0 45 -19t19 -45t-19 -45t-45 -19h-896q-26 0 -45 19t-19 45t19 45t45 19h320v768l-632 632q-43 43 -43 78z" /> +<glyph unicode="" d="M0 -64q0 50 34 89t86 60.5t103.5 32t96.5 10.5q105 0 192 -39v967q0 31 19 56.5t49 35.5l832 256q12 4 28 4q40 0 68 -28t28 -68v-1120q0 -50 -34 -89t-86 -60.5t-103.5 -32t-96.5 -10.5t-96.5 10.5t-103.5 32t-86 60.5t-34 89t34 89t86 60.5t103.5 32t96.5 10.5 q105 0 192 -39v537l-768 -237v-709q0 -50 -34 -89t-86 -60.5t-103.5 -32t-96.5 -10.5t-96.5 10.5t-103.5 32t-86 60.5t-34 89z" /> +<glyph unicode="" horiz-adv-x="1664" d="M0 704q0 143 55.5 273.5t150 225t225 150t273.5 55.5t273.5 -55.5t225 -150t150 -225t55.5 -273.5q0 -220 -124 -399l343 -343q37 -37 37 -90q0 -52 -38 -90t-90 -38q-54 0 -90 38l-343 342q-179 -124 -399 -124q-143 0 -273.5 55.5t-225 150t-150 225t-55.5 273.5z M256 704q0 -185 131.5 -316.5t316.5 -131.5t316.5 131.5t131.5 316.5t-131.5 316.5t-316.5 131.5t-316.5 -131.5t-131.5 -316.5z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 32v1088q0 66 47 113t113 47h1472q66 0 113 -47t47 -113v-1088q0 -66 -47 -113t-113 -47h-1472q-66 0 -113 47t-47 113zM128 32q0 -13 9.5 -22.5t22.5 -9.5h1472q13 0 22.5 9.5t9.5 22.5v768q-32 -36 -69 -66q-268 -206 -426 -338q-51 -43 -83 -67t-86.5 -48.5 t-102.5 -24.5h-1h-1q-48 0 -102.5 24.5t-86.5 48.5t-83 67q-158 132 -426 338q-37 30 -69 66v-768zM128 1120q0 -168 147 -284q193 -152 401 -317q6 -5 35 -29.5t46 -37.5t44.5 -31.5t50.5 -27.5t43 -9h1h1q20 0 43 9t50.5 27.5t44.5 31.5t46 37.5t35 29.5q208 165 401 317 q54 43 100.5 115.5t46.5 131.5v11v13.5t-0.5 13t-3 12.5t-5.5 9t-9 7.5t-14 2.5h-1472q-13 0 -22.5 -9.5t-9.5 -22.5z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 940q0 220 127 344t351 124q62 0 126.5 -21.5t120 -58t95.5 -68.5t76 -68q36 36 76 68t95.5 68.5t120 58t126.5 21.5q224 0 351 -124t127 -344q0 -221 -229 -450l-623 -600q-18 -18 -44 -18t-44 18l-624 602q-10 8 -27.5 26t-55.5 65.5t-68 97.5t-53.5 121t-23.5 138z " /> +<glyph unicode="" horiz-adv-x="1664" d="M0 889q0 37 56 46l502 73l225 455q19 41 49 41t49 -41l225 -455l502 -73q56 -9 56 -46q0 -22 -26 -48l-363 -354l86 -500q1 -7 1 -20q0 -21 -10.5 -35.5t-30.5 -14.5q-19 0 -40 12l-449 236l-449 -236q-22 -12 -40 -12q-21 0 -31.5 14.5t-10.5 35.5q0 6 2 20l86 500 l-364 354q-25 27 -25 48z" /> +<glyph unicode="" horiz-adv-x="1664" d="M0 889q0 37 56 46l502 73l225 455q19 41 49 41t49 -41l225 -455l502 -73q56 -9 56 -46q0 -22 -26 -48l-363 -354l86 -500q1 -7 1 -20q0 -50 -41 -50q-19 0 -40 12l-449 236l-449 -236q-22 -12 -40 -12q-21 0 -31.5 14.5t-10.5 35.5q0 6 2 20l86 500l-364 354 q-25 27 -25 48zM221 829l306 -297l-73 -421l378 199l377 -199l-72 421l306 297l-422 62l-189 382l-189 -382z" /> +<glyph unicode="" horiz-adv-x="1408" d="M0 131q0 53 3.5 103.5t14 109t26.5 108.5t43 97.5t62 81t85.5 53.5t111.5 20q9 0 42 -21.5t74.5 -48t108 -48t133.5 -21.5t133.5 21.5t108 48t74.5 48t42 21.5q61 0 111.5 -20t85.5 -53.5t62 -81t43 -97.5t26.5 -108.5t14 -109t3.5 -103.5q0 -120 -73 -189.5t-194 -69.5 h-874q-121 0 -194 69.5t-73 189.5zM320 1024q0 159 112.5 271.5t271.5 112.5t271.5 -112.5t112.5 -271.5t-112.5 -271.5t-271.5 -112.5t-271.5 112.5t-112.5 271.5z" /> +<glyph unicode="" horiz-adv-x="1920" d="M0 -96v1344q0 66 47 113t113 47h1600q66 0 113 -47t47 -113v-1344q0 -66 -47 -113t-113 -47h-1600q-66 0 -113 47t-47 113zM128 64v-128q0 -26 19 -45t45 -19h128q26 0 45 19t19 45v128q0 26 -19 45t-45 19h-128q-26 0 -45 -19t-19 -45zM128 320q0 -26 19 -45t45 -19h128 q26 0 45 19t19 45v128q0 26 -19 45t-45 19h-128q-26 0 -45 -19t-19 -45v-128zM128 704q0 -26 19 -45t45 -19h128q26 0 45 19t19 45v128q0 26 -19 45t-45 19h-128q-26 0 -45 -19t-19 -45v-128zM128 1088q0 -26 19 -45t45 -19h128q26 0 45 19t19 45v128q0 26 -19 45t-45 19 h-128q-26 0 -45 -19t-19 -45v-128zM512 -64q0 -26 19 -45t45 -19h768q26 0 45 19t19 45v512q0 26 -19 45t-45 19h-768q-26 0 -45 -19t-19 -45v-512zM512 704q0 -26 19 -45t45 -19h768q26 0 45 19t19 45v512q0 26 -19 45t-45 19h-768q-26 0 -45 -19t-19 -45v-512zM1536 64 v-128q0 -26 19 -45t45 -19h128q26 0 45 19t19 45v128q0 26 -19 45t-45 19h-128q-26 0 -45 -19t-19 -45zM1536 320q0 -26 19 -45t45 -19h128q26 0 45 19t19 45v128q0 26 -19 45t-45 19h-128q-26 0 -45 -19t-19 -45v-128zM1536 704q0 -26 19 -45t45 -19h128q26 0 45 19t19 45 v128q0 26 -19 45t-45 19h-128q-26 0 -45 -19t-19 -45v-128zM1536 1088q0 -26 19 -45t45 -19h128q26 0 45 19t19 45v128q0 26 -19 45t-45 19h-128q-26 0 -45 -19t-19 -45v-128z" /> +<glyph unicode="" horiz-adv-x="1664" d="M0 128v384q0 52 38 90t90 38h512q52 0 90 -38t38 -90v-384q0 -52 -38 -90t-90 -38h-512q-52 0 -90 38t-38 90zM0 896v384q0 52 38 90t90 38h512q52 0 90 -38t38 -90v-384q0 -52 -38 -90t-90 -38h-512q-52 0 -90 38t-38 90zM896 128v384q0 52 38 90t90 38h512q52 0 90 -38 t38 -90v-384q0 -52 -38 -90t-90 -38h-512q-52 0 -90 38t-38 90zM896 896v384q0 52 38 90t90 38h512q52 0 90 -38t38 -90v-384q0 -52 -38 -90t-90 -38h-512q-52 0 -90 38t-38 90z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 96v192q0 40 28 68t68 28h320q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-320q-40 0 -68 28t-28 68zM0 608v192q0 40 28 68t68 28h320q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-320q-40 0 -68 28t-28 68zM0 1120v192q0 40 28 68t68 28h320q40 0 68 -28 t28 -68v-192q0 -40 -28 -68t-68 -28h-320q-40 0 -68 28t-28 68zM640 96v192q0 40 28 68t68 28h320q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-320q-40 0 -68 28t-28 68zM640 608v192q0 40 28 68t68 28h320q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-320 q-40 0 -68 28t-28 68zM640 1120v192q0 40 28 68t68 28h320q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-320q-40 0 -68 28t-28 68zM1280 96v192q0 40 28 68t68 28h320q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-320q-40 0 -68 28t-28 68zM1280 608v192 q0 40 28 68t68 28h320q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-320q-40 0 -68 28t-28 68zM1280 1120v192q0 40 28 68t68 28h320q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-320q-40 0 -68 28t-28 68z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 96v192q0 40 28 68t68 28h320q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-320q-40 0 -68 28t-28 68zM0 608v192q0 40 28 68t68 28h320q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-320q-40 0 -68 28t-28 68zM0 1120v192q0 40 28 68t68 28h320q40 0 68 -28 t28 -68v-192q0 -40 -28 -68t-68 -28h-320q-40 0 -68 28t-28 68zM640 96v192q0 40 28 68t68 28h960q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-960q-40 0 -68 28t-28 68zM640 608v192q0 40 28 68t68 28h960q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-960 q-40 0 -68 28t-28 68zM640 1120v192q0 40 28 68t68 28h960q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-960q-40 0 -68 28t-28 68z" /> +<glyph unicode="" horiz-adv-x="1792" d="M121 608q0 40 28 68l136 136q28 28 68 28t68 -28l294 -295l656 657q28 28 68 28t68 -28l136 -136q28 -28 28 -68t-28 -68l-724 -724l-136 -136q-28 -28 -68 -28t-68 28l-136 136l-362 362q-28 28 -28 68z" /> +<glyph unicode="" horiz-adv-x="1408" d="M110 214q0 40 28 68l294 294l-294 294q-28 28 -28 68t28 68l136 136q28 28 68 28t68 -28l294 -294l294 294q28 28 68 28t68 -28l136 -136q28 -28 28 -68t-28 -68l-294 -294l294 -294q28 -28 28 -68t-28 -68l-136 -136q-28 -28 -68 -28t-68 28l-294 294l-294 -294 q-28 -28 -68 -28t-68 28l-136 136q-28 28 -28 68z" /> +<glyph unicode="" horiz-adv-x="1664" d="M0 704q0 143 55.5 273.5t150 225t225 150t273.5 55.5t273.5 -55.5t225 -150t150 -225t55.5 -273.5q0 -220 -124 -399l343 -343q37 -37 37 -90t-37.5 -90.5t-90.5 -37.5q-54 0 -90 38l-343 342q-179 -124 -399 -124q-143 0 -273.5 55.5t-225 150t-150 225t-55.5 273.5z M256 704q0 -185 131.5 -316.5t316.5 -131.5t316.5 131.5t131.5 316.5t-131.5 316.5t-316.5 131.5t-316.5 -131.5t-131.5 -316.5zM384 672v64q0 13 9.5 22.5t22.5 9.5h224v224q0 13 9.5 22.5t22.5 9.5h64q13 0 22.5 -9.5t9.5 -22.5v-224h224q13 0 22.5 -9.5t9.5 -22.5v-64 q0 -13 -9.5 -22.5t-22.5 -9.5h-224v-224q0 -13 -9.5 -22.5t-22.5 -9.5h-64q-13 0 -22.5 9.5t-9.5 22.5v224h-224q-13 0 -22.5 9.5t-9.5 22.5z" /> +<glyph unicode="" horiz-adv-x="1664" d="M0 704q0 143 55.5 273.5t150 225t225 150t273.5 55.5t273.5 -55.5t225 -150t150 -225t55.5 -273.5q0 -220 -124 -399l343 -343q37 -37 37 -90t-37.5 -90.5t-90.5 -37.5q-54 0 -90 38l-343 342q-179 -124 -399 -124q-143 0 -273.5 55.5t-225 150t-150 225t-55.5 273.5z M256 704q0 -185 131.5 -316.5t316.5 -131.5t316.5 131.5t131.5 316.5t-131.5 316.5t-316.5 131.5t-316.5 -131.5t-131.5 -316.5zM384 672v64q0 13 9.5 22.5t22.5 9.5h576q13 0 22.5 -9.5t9.5 -22.5v-64q0 -13 -9.5 -22.5t-22.5 -9.5h-576q-13 0 -22.5 9.5t-9.5 22.5z" /> +<glyph unicode="" d="M0 640q0 182 80.5 343t226.5 270q43 32 95.5 25t83.5 -50q32 -42 24.5 -94.5t-49.5 -84.5q-98 -74 -151.5 -181t-53.5 -228q0 -104 40.5 -198.5t109.5 -163.5t163.5 -109.5t198.5 -40.5t198.5 40.5t163.5 109.5t109.5 163.5t40.5 198.5q0 121 -53.5 228t-151.5 181 q-42 32 -49.5 84.5t24.5 94.5q31 43 84 50t95 -25q146 -109 226.5 -270t80.5 -343q0 -156 -61 -298t-164 -245t-245 -164t-298 -61t-298 61t-245 164t-164 245t-61 298zM640 768v640q0 52 38 90t90 38t90 -38t38 -90v-640q0 -52 -38 -90t-90 -38t-90 38t-38 90z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 -96v192q0 14 9 23t23 9h192q14 0 23 -9t9 -23v-192q0 -14 -9 -23t-23 -9h-192q-14 0 -23 9t-9 23zM384 -96v320q0 14 9 23t23 9h192q14 0 23 -9t9 -23v-320q0 -14 -9 -23t-23 -9h-192q-14 0 -23 9t-9 23zM768 -96v576q0 14 9 23t23 9h192q14 0 23 -9t9 -23v-576 q0 -14 -9 -23t-23 -9h-192q-14 0 -23 9t-9 23zM1152 -96v960q0 14 9 23t23 9h192q14 0 23 -9t9 -23v-960q0 -14 -9 -23t-23 -9h-192q-14 0 -23 9t-9 23zM1536 -96v1472q0 14 9 23t23 9h192q14 0 23 -9t9 -23v-1472q0 -14 -9 -23t-23 -9h-192q-14 0 -23 9t-9 23z" /> +<glyph unicode="" d="M0 531v222q0 12 8 23t19 13l186 28q14 46 39 92q-40 57 -107 138q-10 12 -10 24q0 10 9 23q26 36 98.5 107.5t94.5 71.5q13 0 26 -10l138 -107q44 23 91 38q16 136 29 186q7 28 36 28h222q14 0 24.5 -8.5t11.5 -21.5l28 -184q49 -16 90 -37l142 107q9 9 24 9q13 0 25 -10 q129 -119 165 -170q7 -8 7 -22q0 -12 -8 -23q-15 -21 -51 -66.5t-54 -70.5q26 -50 41 -98l183 -28q13 -2 21 -12.5t8 -23.5v-222q0 -12 -8 -23t-20 -13l-185 -28q-19 -54 -39 -91q35 -50 107 -138q10 -12 10 -25t-9 -23q-27 -37 -99 -108t-94 -71q-12 0 -26 9l-138 108 q-44 -23 -91 -38q-16 -136 -29 -186q-7 -28 -36 -28h-222q-14 0 -24.5 8.5t-11.5 21.5l-28 184q-49 16 -90 37l-141 -107q-10 -9 -25 -9q-14 0 -25 11q-126 114 -165 168q-7 10 -7 23q0 12 8 23q15 21 51 66.5t54 70.5q-27 50 -41 99l-183 27q-13 2 -21 12.5t-8 23.5z M512 640q0 -106 75 -181t181 -75t181 75t75 181t-75 181t-181 75t-181 -75t-75 -181z" /> +<glyph unicode="" horiz-adv-x="1408" d="M0 1056v64q0 14 9 23t23 9h309l70 167q15 37 54 63t79 26h320q40 0 79 -26t54 -63l70 -167h309q14 0 23 -9t9 -23v-64q0 -14 -9 -23t-23 -9h-96v-948q0 -83 -47 -143.5t-113 -60.5h-832q-66 0 -113 58.5t-47 141.5v952h-96q-14 0 -23 9t-9 23zM256 76q0 -22 7 -40.5 t14.5 -27t10.5 -8.5h832q3 0 10.5 8.5t14.5 27t7 40.5v948h-896v-948zM384 224v576q0 14 9 23t23 9h64q14 0 23 -9t9 -23v-576q0 -14 -9 -23t-23 -9h-64q-14 0 -23 9t-9 23zM480 1152h448l-48 117q-7 9 -17 11h-317q-10 -2 -17 -11zM640 224v576q0 14 9 23t23 9h64 q14 0 23 -9t9 -23v-576q0 -14 -9 -23t-23 -9h-64q-14 0 -23 9t-9 23zM896 224v576q0 14 9 23t23 9h64q14 0 23 -9t9 -23v-576q0 -14 -9 -23t-23 -9h-64q-14 0 -23 9t-9 23z" /> +<glyph unicode="" horiz-adv-x="1664" d="M26 636.5q1 13.5 11 21.5l719 599q32 26 76 26t76 -26l244 -204v195q0 14 9 23t23 9h192q14 0 23 -9t9 -23v-408l219 -182q10 -8 11 -21.5t-7 -23.5l-62 -74q-8 -9 -21 -11h-3q-13 0 -21 7l-692 577l-692 -577q-12 -8 -24 -7q-13 2 -21 11l-62 74q-8 10 -7 23.5zM256 64 v480q0 1 0.5 3t0.5 3l575 474l575 -474q1 -2 1 -6v-480q0 -26 -19 -45t-45 -19h-384v384h-256v-384h-384q-26 0 -45 19t-19 45z" /> +<glyph unicode="" d="M0 -160v1600q0 40 28 68t68 28h896q40 0 88 -20t76 -48l312 -312q28 -28 48 -76t20 -88v-1152q0 -40 -28 -68t-68 -28h-1344q-40 0 -68 28t-28 68zM128 -128h1280v1024h-416q-40 0 -68 28t-28 68v416h-768v-1536zM1024 1024h376q-10 29 -22 41l-313 313q-12 12 -41 22 v-376z" /> +<glyph unicode="" d="M0 640q0 209 103 385.5t279.5 279.5t385.5 103t385.5 -103t279.5 -279.5t103 -385.5t-103 -385.5t-279.5 -279.5t-385.5 -103t-385.5 103t-279.5 279.5t-103 385.5zM224 640q0 -148 73 -273t198 -198t273 -73t273 73t198 198t73 273t-73 273t-198 198t-273 73t-273 -73 t-198 -198t-73 -273zM512 544v64q0 14 9 23t23 9h224v352q0 14 9 23t23 9h64q14 0 23 -9t9 -23v-448q0 -14 -9 -23t-23 -9h-320q-14 0 -23 9t-9 23z" /> +<glyph unicode="" horiz-adv-x="1920" d="M50 73q0 54 26 116l417 1044q8 19 26 33t38 14h339q-13 0 -23 -9.5t-11 -22.5l-15 -192q-1 -14 8 -23t22 -9h166q13 0 22 9t8 23l-15 192q-1 13 -11 22.5t-23 9.5h339q20 0 38 -14t26 -33l417 -1044q26 -62 26 -116q0 -73 -46 -73h-704q13 0 22 9.5t8 22.5l-20 256 q-1 13 -11 22.5t-23 9.5h-272q-13 0 -23 -9.5t-11 -22.5l-20 -256q-1 -13 8 -22.5t22 -9.5h-704q-46 0 -46 73zM809 540q-1 -12 8 -20t21 -8h244q12 0 21 8t8 20v4l-24 320q-1 13 -11 22.5t-23 9.5h-186q-13 0 -23 -9.5t-11 -22.5l-24 -320v-4z" /> +<glyph unicode="" horiz-adv-x="1664" d="M0 96v320q0 40 28 68t68 28h465l135 -136q58 -56 136 -56t136 56l136 136h464q40 0 68 -28t28 -68v-320q0 -40 -28 -68t-68 -28h-1472q-40 0 -68 28t-28 68zM325 985q17 39 59 39h256v448q0 26 19 45t45 19h256q26 0 45 -19t19 -45v-448h256q42 0 59 -39q17 -41 -14 -70 l-448 -448q-18 -19 -45 -19t-45 19l-448 448q-31 29 -14 70zM1152 192q0 -26 19 -45t45 -19t45 19t19 45t-19 45t-45 19t-45 -19t-19 -45zM1408 192q0 -26 19 -45t45 -19t45 19t19 45t-19 45t-45 19t-45 -19t-19 -45z" /> +<glyph unicode="" d="M0 640q0 209 103 385.5t279.5 279.5t385.5 103t385.5 -103t279.5 -279.5t103 -385.5t-103 -385.5t-279.5 -279.5t-385.5 -103t-385.5 103t-279.5 279.5t-103 385.5zM224 640q0 -148 73 -273t198 -198t273 -73t273 73t198 198t73 273t-73 273t-198 198t-273 73t-273 -73 t-198 -198t-73 -273zM418 620q8 20 30 20h192v352q0 14 9 23t23 9h192q14 0 23 -9t9 -23v-352h192q14 0 23 -9t9 -23q0 -12 -10 -24l-319 -319q-11 -9 -23 -9t-23 9l-320 320q-15 16 -7 35z" /> +<glyph unicode="" d="M0 640q0 209 103 385.5t279.5 279.5t385.5 103t385.5 -103t279.5 -279.5t103 -385.5t-103 -385.5t-279.5 -279.5t-385.5 -103t-385.5 103t-279.5 279.5t-103 385.5zM224 640q0 -148 73 -273t198 -198t273 -73t273 73t198 198t73 273t-73 273t-198 198t-273 73t-273 -73 t-198 -198t-73 -273zM416 672q0 12 10 24l319 319q11 9 23 9t23 -9l320 -320q15 -16 7 -35q-8 -20 -30 -20h-192v-352q0 -14 -9 -23t-23 -9h-192q-14 0 -23 9t-9 23v352h-192q-14 0 -23 9t-9 23z" /> +<glyph unicode="" d="M0 64v482q0 62 25 123l238 552q10 25 36.5 42t52.5 17h832q26 0 52.5 -17t36.5 -42l238 -552q25 -61 25 -123v-482q0 -26 -19 -45t-45 -19h-1408q-26 0 -45 19t-19 45zM197 576h316l95 -192h320l95 192h316q-1 3 -2.5 8t-2.5 8l-212 496h-708l-212 -496q-1 -2 -2.5 -8 t-2.5 -8z" /> +<glyph unicode="" d="M0 640q0 209 103 385.5t279.5 279.5t385.5 103t385.5 -103t279.5 -279.5t103 -385.5t-103 -385.5t-279.5 -279.5t-385.5 -103t-385.5 103t-279.5 279.5t-103 385.5zM224 640q0 -148 73 -273t198 -198t273 -73t273 73t198 198t73 273t-73 273t-198 198t-273 73t-273 -73 t-198 -198t-73 -273zM512 320v640q0 37 32 56q33 18 64 -1l544 -320q32 -18 32 -55t-32 -55l-544 -320q-15 -9 -32 -9q-16 0 -32 8q-32 19 -32 56z" /> +<glyph unicode="" d="M0 640q0 156 61 298t164 245t245 164t298 61q147 0 284.5 -55.5t244.5 -156.5l130 129q29 31 70 14q39 -17 39 -59v-448q0 -26 -19 -45t-45 -19h-448q-42 0 -59 40q-17 39 14 69l138 138q-148 137 -349 137q-104 0 -198.5 -40.5t-163.5 -109.5t-109.5 -163.5 t-40.5 -198.5t40.5 -198.5t109.5 -163.5t163.5 -109.5t198.5 -40.5q119 0 225 52t179 147q7 10 23 12q14 0 25 -9l137 -138q9 -8 9.5 -20.5t-7.5 -22.5q-109 -132 -264 -204.5t-327 -72.5q-156 0 -298 61t-245 164t-164 245t-61 298z" /> +<glyph unicode="" d="M0 0v448q0 26 19 45t45 19h448q26 0 45 -19t19 -45t-19 -45l-137 -137q71 -66 161 -102t187 -36q134 0 250 65t186 179q11 17 53 117q8 23 30 23h192q13 0 22.5 -9.5t9.5 -22.5q0 -5 -1 -7q-64 -268 -268 -434.5t-478 -166.5q-146 0 -282.5 55t-243.5 157l-129 -129 q-19 -19 -45 -19t-45 19t-19 45zM18 800v7q65 268 270 434.5t480 166.5q146 0 284 -55.5t245 -156.5l130 129q19 19 45 19t45 -19t19 -45v-448q0 -26 -19 -45t-45 -19h-448q-26 0 -45 19t-19 45t19 45l138 138q-148 137 -349 137q-134 0 -250 -65t-186 -179 q-11 -17 -53 -117q-8 -23 -30 -23h-199q-13 0 -22.5 9.5t-9.5 22.5z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 160v1088q0 66 47 113t113 47h1472q66 0 113 -47t47 -113v-1088q0 -66 -47 -113t-113 -47h-1472q-66 0 -113 47t-47 113zM128 160q0 -13 9.5 -22.5t22.5 -9.5h1472q13 0 22.5 9.5t9.5 22.5v832q0 13 -9.5 22.5t-22.5 9.5h-1472q-13 0 -22.5 -9.5t-9.5 -22.5v-832z M256 288v64q0 13 9.5 22.5t22.5 9.5h64q13 0 22.5 -9.5t9.5 -22.5v-64q0 -13 -9.5 -22.5t-22.5 -9.5h-64q-13 0 -22.5 9.5t-9.5 22.5zM256 544v64q0 13 9.5 22.5t22.5 9.5h64q13 0 22.5 -9.5t9.5 -22.5v-64q0 -13 -9.5 -22.5t-22.5 -9.5h-64q-13 0 -22.5 9.5t-9.5 22.5z M256 800v64q0 13 9.5 22.5t22.5 9.5h64q13 0 22.5 -9.5t9.5 -22.5v-64q0 -13 -9.5 -22.5t-22.5 -9.5h-64q-13 0 -22.5 9.5t-9.5 22.5zM512 288v64q0 13 9.5 22.5t22.5 9.5h960q13 0 22.5 -9.5t9.5 -22.5v-64q0 -13 -9.5 -22.5t-22.5 -9.5h-960q-13 0 -22.5 9.5t-9.5 22.5z M512 544v64q0 13 9.5 22.5t22.5 9.5h960q13 0 22.5 -9.5t9.5 -22.5v-64q0 -13 -9.5 -22.5t-22.5 -9.5h-960q-13 0 -22.5 9.5t-9.5 22.5zM512 800v64q0 13 9.5 22.5t22.5 9.5h960q13 0 22.5 -9.5t9.5 -22.5v-64q0 -13 -9.5 -22.5t-22.5 -9.5h-960q-13 0 -22.5 9.5t-9.5 22.5z " /> +<glyph unicode="" horiz-adv-x="1152" d="M0 96v576q0 40 28 68t68 28h32v192q0 184 132 316t316 132t316 -132t132 -316v-192h32q40 0 68 -28t28 -68v-576q0 -40 -28 -68t-68 -28h-960q-40 0 -68 28t-28 68zM320 768h512v192q0 106 -75 181t-181 75t-181 -75t-75 -181v-192z" /> +<glyph unicode="" horiz-adv-x="1792" d="M64 1280q0 53 37.5 90.5t90.5 37.5t90.5 -37.5t37.5 -90.5q0 -72 -64 -110v-1266q0 -13 -9.5 -22.5t-22.5 -9.5h-64q-13 0 -22.5 9.5t-9.5 22.5v1266q-64 38 -64 110zM320 320v742q0 32 31 55q21 14 79 43q236 120 421 120q107 0 200 -29t219 -88q38 -19 88 -19 q54 0 117.5 21t110 47t88 47t54.5 21q26 0 45 -19t19 -45v-763q0 -25 -12.5 -38.5t-39.5 -27.5q-215 -116 -369 -116q-61 0 -123.5 22t-108.5 48t-115.5 48t-142.5 22q-192 0 -464 -146q-17 -9 -33 -9q-26 0 -45 19t-19 45z" /> +<glyph unicode="" horiz-adv-x="1664" d="M0 650q0 151 67 291t179 242.5t266 163.5t320 61t320 -61t266 -163.5t179 -242.5t67 -291q0 -166 -60 -314l-20 -49l-185 -33q-22 -83 -90.5 -136.5t-156.5 -53.5v-32q0 -14 -9 -23t-23 -9h-64q-14 0 -23 9t-9 23v576q0 14 9 23t23 9h64q14 0 23 -9t9 -23v-32 q71 0 130 -35.5t93 -95.5l68 12q29 95 29 193q0 148 -88 279t-236.5 209t-315.5 78t-315.5 -78t-236.5 -209t-88 -279q0 -98 29 -193l68 -12q34 60 93 95.5t130 35.5v32q0 14 9 23t23 9h64q14 0 23 -9t9 -23v-576q0 -14 -9 -23t-23 -9h-64q-14 0 -23 9t-9 23v32 q-88 0 -156.5 53.5t-90.5 136.5l-185 33l-20 49q-60 148 -60 314z" /> +<glyph unicode="" horiz-adv-x="768" d="M0 448v384q0 26 19 45t45 19h262l333 333q19 19 45 19t45 -19t19 -45v-1088q0 -26 -19 -45t-45 -19t-45 19l-333 333h-262q-26 0 -45 19t-19 45z" /> +<glyph unicode="" horiz-adv-x="1152" d="M0 448v384q0 26 19 45t45 19h262l333 333q19 19 45 19t45 -19t19 -45v-1088q0 -26 -19 -45t-45 -19t-45 19l-333 333h-262q-26 0 -45 19t-19 45zM908 464q0 21 12 35.5t29 25t34 23t29 35.5t12 57t-12 57t-29 35.5t-34 23t-29 25t-12 35.5q0 27 19 45.5t45 18.5 q15 0 25 -5q70 -27 112.5 -93t42.5 -142t-42.5 -141.5t-112.5 -93.5q-10 -5 -25 -5q-26 0 -45 18.5t-19 45.5z" /> +<glyph unicode="" horiz-adv-x="1664" d="M0 448v384q0 26 19 45t45 19h262l333 333q19 19 45 19t45 -19t19 -45v-1088q0 -26 -19 -45t-45 -19t-45 19l-333 333h-262q-26 0 -45 19t-19 45zM908 464q0 21 12 35.5t29 25t34 23t29 35.5t12 57t-12 57t-29 35.5t-34 23t-29 25t-12 35.5q0 27 19 45.5t45 18.5 q15 0 25 -5q70 -27 112.5 -93t42.5 -142t-42.5 -141.5t-112.5 -93.5q-10 -5 -25 -5q-26 0 -45 18.5t-19 45.5zM1008 228q0 39 39 59q56 29 76 44q74 54 115.5 135.5t41.5 173.5t-41.5 173.5t-115.5 135.5q-20 15 -76 44q-39 20 -39 59q0 26 19 45t45 19q13 0 26 -5 q140 -59 225 -188.5t85 -282.5t-85 -282.5t-225 -188.5q-13 -5 -25 -5q-27 0 -46 19t-19 45zM1109 -7q0 36 39 59q7 4 22.5 10.5t22.5 10.5q46 25 82 51q123 91 192 227t69 289t-69 289t-192 227q-36 26 -82 51q-7 4 -22.5 10.5t-22.5 10.5q-39 23 -39 59q0 26 19 45t45 19 q13 0 26 -5q211 -91 338 -283.5t127 -422.5t-127 -422.5t-338 -283.5q-13 -5 -26 -5q-26 0 -45 19t-19 45z" /> +<glyph unicode="" horiz-adv-x="1408" d="M0 0v640h640v-640h-640zM0 768v640h640v-640h-640zM128 129h384v383h-384v-383zM128 896h384v384h-384v-384zM256 256v128h128v-128h-128zM256 1024v128h128v-128h-128zM768 0v640h384v-128h128v128h128v-384h-384v128h-128v-384h-128zM768 768v640h640v-640h-640z M896 896h384v384h-384v-384zM1024 0v128h128v-128h-128zM1024 1024v128h128v-128h-128zM1280 0v128h128v-128h-128z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 0v1408h63v-1408h-63zM94 1v1407h32v-1407h-32zM189 1v1407h31v-1407h-31zM346 1v1407h31v-1407h-31zM472 1v1407h62v-1407h-62zM629 1v1407h31v-1407h-31zM692 1v1407h31v-1407h-31zM755 1v1407h31v-1407h-31zM880 1v1407h63v-1407h-63zM1037 1v1407h63v-1407h-63z M1163 1v1407h63v-1407h-63zM1289 1v1407h63v-1407h-63zM1383 1v1407h63v-1407h-63zM1541 1v1407h94v-1407h-94zM1666 1v1407h32v-1407h-32zM1729 0v1408h63v-1408h-63z" /> +<glyph unicode="" d="M0 864v416q0 52 38 90t90 38h416q53 0 117 -26.5t102 -64.5l715 -714q37 -39 37 -91q0 -53 -37 -90l-491 -492q-39 -37 -91 -37q-53 0 -90 37l-715 716q-38 37 -64.5 101t-26.5 117zM192 1088q0 -53 37.5 -90.5t90.5 -37.5t90.5 37.5t37.5 90.5t-37.5 90.5t-90.5 37.5 t-90.5 -37.5t-37.5 -90.5z" /> +<glyph unicode="" horiz-adv-x="1920" d="M0 864v416q0 52 38 90t90 38h416q53 0 117 -26.5t102 -64.5l715 -714q37 -39 37 -91q0 -53 -37 -90l-491 -492q-39 -37 -91 -37q-53 0 -90 37l-715 716q-38 37 -64.5 101t-26.5 117zM192 1088q0 -53 37.5 -90.5t90.5 -37.5t90.5 37.5t37.5 90.5t-37.5 90.5t-90.5 37.5 t-90.5 -37.5t-37.5 -90.5zM704 1408h224q53 0 117 -26.5t102 -64.5l715 -714q37 -39 37 -91q0 -53 -37 -90l-491 -492q-39 -37 -91 -37q-36 0 -59 14t-53 45l470 470q37 37 37 90q0 52 -37 91l-715 714q-38 38 -102 64.5t-117 26.5z" /> +<glyph unicode="" horiz-adv-x="1664" d="M10 184q0 4 3 27t4 37q1 8 -3 21.5t-3 19.5q2 11 8 21t16.5 23.5t16.5 23.5q23 38 45 91.5t30 91.5q3 10 0.5 30t-0.5 28q3 11 17 28t17 23q21 36 42 92t25 90q1 9 -2.5 32t0.5 28q4 13 22 30.5t22 22.5q19 26 42.5 84.5t27.5 96.5q1 8 -3 25.5t-2 26.5q2 8 9 18t18 23 t17 21q8 12 16.5 30.5t15 35t16 36t19.5 32t26.5 23.5t36 11.5t47.5 -5.5l-1 -3q38 9 51 9h761q74 0 114 -56t18 -130l-274 -906q-36 -119 -71.5 -153.5t-128.5 -34.5h-869q-27 0 -38 -15q-11 -16 -1 -43q24 -70 144 -70h923q29 0 56 15.5t35 41.5l300 987q7 22 5 57 q38 -15 59 -43q40 -57 18 -129l-275 -906q-19 -64 -76.5 -107.5t-122.5 -43.5h-923q-77 0 -148.5 53.5t-99.5 131.5q-24 67 -2 127zM492 800q-4 -13 2 -22.5t20 -9.5h608q13 0 25.5 9.5t16.5 22.5l21 64q4 13 -2 22.5t-20 9.5h-608q-13 0 -25.5 -9.5t-16.5 -22.5zM575 1056 q-4 -13 2 -22.5t20 -9.5h608q13 0 25.5 9.5t16.5 22.5l21 64q4 13 -2 22.5t-20 9.5h-608q-13 0 -25.5 -9.5t-16.5 -22.5z" /> +<glyph unicode="" horiz-adv-x="1280" d="M0 7v1289q0 34 19.5 62t52.5 41q21 9 44 9h1048q23 0 44 -9q33 -13 52.5 -41t19.5 -62v-1289q0 -34 -19.5 -62t-52.5 -41q-19 -8 -44 -8q-48 0 -83 32l-441 424l-441 -424q-36 -33 -83 -33q-23 0 -44 9q-33 13 -52.5 41t-19.5 62z" /> +<glyph unicode="" horiz-adv-x="1664" d="M0 160v416q0 79 56.5 135.5t135.5 56.5h64v544q0 40 28 68t68 28h672q40 0 88 -20t76 -48l152 -152q28 -28 48 -76t20 -88v-256h64q79 0 135.5 -56.5t56.5 -135.5v-416q0 -13 -9.5 -22.5t-22.5 -9.5h-224v-160q0 -40 -28 -68t-68 -28h-960q-40 0 -68 28t-28 68v160h-224 q-13 0 -22.5 9.5t-9.5 22.5zM384 0h896v256h-896v-256zM384 640h896v384h-160q-40 0 -68 28t-28 68v160h-640v-640zM1408 576q0 -26 19 -45t45 -19t45 19t19 45t-19 45t-45 19t-45 -19t-19 -45z" /> +<glyph unicode="" horiz-adv-x="1920" d="M0 128v896q0 106 75 181t181 75h224l51 136q19 49 69.5 84.5t103.5 35.5h512q53 0 103.5 -35.5t69.5 -84.5l51 -136h224q106 0 181 -75t75 -181v-896q0 -106 -75 -181t-181 -75h-1408q-106 0 -181 75t-75 181zM512 576q0 -185 131.5 -316.5t316.5 -131.5t316.5 131.5 t131.5 316.5t-131.5 316.5t-316.5 131.5t-316.5 -131.5t-131.5 -316.5zM672 576q0 119 84.5 203.5t203.5 84.5t203.5 -84.5t84.5 -203.5t-84.5 -203.5t-203.5 -84.5t-203.5 84.5t-84.5 203.5z" /> +<glyph unicode="" horiz-adv-x="1664" d="M0 -128l2 79q23 7 56 12.5t57 10.5t49.5 14.5t44.5 29t31 50.5l237 616l280 724h75h53q8 -14 11 -21l205 -480q33 -78 106 -257.5t114 -274.5q15 -34 58 -144.5t72 -168.5q20 -45 35 -57q19 -15 88 -29.5t84 -20.5q6 -38 6 -57q0 -4 -0.5 -13t-0.5 -13q-63 0 -190 8 t-191 8q-76 0 -215 -7t-178 -8q0 43 4 78l131 28q1 0 12.5 2.5t15.5 3.5t14.5 4.5t15 6.5t11 8t9 11t2.5 14q0 16 -31 96.5t-72 177.5t-42 100l-450 2q-26 -58 -76.5 -195.5t-50.5 -162.5q0 -22 14 -37.5t43.5 -24.5t48.5 -13.5t57 -8.5t41 -4q1 -19 1 -58q0 -9 -2 -27 q-58 0 -174.5 10t-174.5 10q-8 0 -26.5 -4t-21.5 -4q-80 -14 -188 -14zM555 527q33 0 136.5 -2t160.5 -2q19 0 57 2q-87 253 -184 452z" /> +<glyph unicode="" horiz-adv-x="1408" d="M0 -128l2 94q15 4 85 16t106 27q7 12 12.5 27t8.5 33.5t5.5 32.5t3 37.5t0.5 34v35.5v30q0 982 -22 1025q-4 8 -22 14.5t-44.5 11t-49.5 7t-48.5 4.5t-30.5 3l-4 83q98 2 340 11.5t373 9.5q23 0 68.5 -0.5t67.5 -0.5q70 0 136.5 -13t128.5 -42t108 -71t74 -104.5 t28 -137.5q0 -52 -16.5 -95.5t-39 -72t-64.5 -57.5t-73 -45t-84 -40q154 -35 256.5 -134t102.5 -248q0 -100 -35 -179.5t-93.5 -130.5t-138 -85.5t-163.5 -48.5t-176 -14q-44 0 -132 3t-132 3q-106 0 -307 -11t-231 -12zM533 1292q0 -50 4 -151t4 -152q0 -27 -0.5 -80 t-0.5 -79q0 -46 1 -69q42 -7 109 -7q82 0 143 13t110 44.5t74.5 89.5t25.5 142q0 70 -29 122.5t-79 82t-108 43.5t-124 14q-50 0 -130 -13zM538.5 165q0.5 -37 4.5 -83.5t12 -66.5q74 -32 140 -32q376 0 376 335q0 114 -41 180q-27 44 -61.5 74t-67.5 46.5t-80.5 25 t-84 10.5t-94.5 2q-73 0 -101 -10q0 -53 -0.5 -159t-0.5 -158q0 -8 -1 -67.5t-0.5 -96.5z" /> +<glyph unicode="" horiz-adv-x="1024" d="M0 -126l17 85q6 2 81.5 21.5t111.5 37.5q28 35 41 101q1 7 62 289t114 543.5t52 296.5v25q-24 13 -54.5 18.5t-69.5 8t-58 5.5l19 103q33 -2 120 -6.5t149.5 -7t120.5 -2.5q48 0 98.5 2.5t121 7t98.5 6.5q-5 -39 -19 -89q-30 -10 -101.5 -28.5t-108.5 -33.5 q-8 -19 -14 -42.5t-9 -40t-7.5 -45.5t-6.5 -42q-27 -148 -87.5 -419.5t-77.5 -355.5q-2 -9 -13 -58t-20 -90t-16 -83.5t-6 -57.5l1 -18q17 -4 185 -31q-3 -44 -16 -99q-11 0 -32.5 -1.5t-32.5 -1.5q-29 0 -87 10t-86 10q-138 2 -206 2q-51 0 -143 -9t-121 -11z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 1023v383l81 1l54 -27q12 -5 211 -5q44 0 132 2t132 2q36 0 107.5 -0.5t107.5 -0.5h293q6 0 21 -0.5t20.5 0t16 3t17.5 9t15 17.5l42 1q4 0 14 -0.5t14 -0.5q2 -112 2 -336q0 -80 -5 -109q-39 -14 -68 -18q-25 44 -54 128q-3 9 -11 48t-14.5 73.5t-7.5 35.5 q-6 8 -12 12.5t-15.5 6t-13 2.5t-18 0.5t-16.5 -0.5q-17 0 -66.5 0.5t-74.5 0.5t-64 -2t-71 -6q-9 -81 -8 -136q0 -94 2 -388t2 -455q0 -16 -2.5 -71.5t0 -91.5t12.5 -69q40 -21 124 -42.5t120 -37.5q5 -40 5 -50q0 -14 -3 -29l-34 -1q-76 -2 -218 8t-207 10q-50 0 -151 -9 t-152 -9q-3 51 -3 52v9q17 27 61.5 43t98.5 29t78 27q19 42 19 383q0 101 -3 303t-3 303v117q0 2 0.5 15.5t0.5 25t-1 25.5t-3 24t-5 14q-11 12 -162 12q-33 0 -93 -12t-80 -26q-19 -13 -34 -72.5t-31.5 -111t-42.5 -53.5q-42 26 -56 44zM1414 109.5q9 18.5 42 18.5h80v1024 h-80q-33 0 -42 18.5t11 44.5l126 162q20 26 49 26t49 -26l126 -162q20 -26 11 -44.5t-42 -18.5h-80v-1024h80q33 0 42 -18.5t-11 -44.5l-126 -162q-20 -26 -49 -26t-49 26l-126 162q-20 26 -11 44.5z" /> +<glyph unicode="" d="M0 1023v383l81 1l54 -27q12 -5 211 -5q44 0 132 2t132 2q70 0 246.5 1t304.5 0.5t247 -4.5q33 -1 56 31l42 1q4 0 14 -0.5t14 -0.5q2 -112 2 -336q0 -80 -5 -109q-39 -14 -68 -18q-25 44 -54 128q-3 9 -11 47.5t-15 73.5t-7 36q-10 13 -27 19q-5 2 -66 2q-30 0 -93 1 t-103 1t-94 -2t-96 -7q-9 -81 -8 -136l1 -152v52q0 -55 1 -154t1.5 -180t0.5 -153q0 -16 -2.5 -71.5t0 -91.5t12.5 -69q40 -21 124 -42.5t120 -37.5q5 -40 5 -50q0 -14 -3 -29l-34 -1q-76 -2 -218 8t-207 10q-50 0 -151 -9t-152 -9q-3 51 -3 52v9q17 27 61.5 43t98.5 29 t78 27q7 16 11.5 74t6 145.5t1.5 155t-0.5 153.5t-0.5 89q0 7 -2.5 21.5t-2.5 22.5q0 7 0.5 44t1 73t0 76.5t-3 67.5t-6.5 32q-11 12 -162 12q-41 0 -163 -13.5t-138 -24.5q-19 -12 -34 -71.5t-31.5 -111.5t-42.5 -54q-42 26 -56 44zM5 -64q0 28 26 49q4 3 36 30t59.5 49 t57.5 41.5t42 19.5q13 0 20.5 -10.5t10 -28.5t2.5 -33.5t-1.5 -33t-1.5 -19.5h1024q0 2 -1.5 19.5t-1.5 33t2.5 33.5t10 28.5t20.5 10.5q12 0 42 -19.5t57.5 -41.5t59.5 -49t36 -30q26 -21 26 -49t-26 -49q-4 -3 -36 -30t-59.5 -49t-57.5 -41.5t-42 -19.5q-13 0 -20.5 10.5 t-10 28.5t-2.5 33.5t1.5 33t1.5 19.5h-1024q0 -2 1.5 -19.5t1.5 -33t-2.5 -33.5t-10 -28.5t-20.5 -10.5q-12 0 -42 19.5t-57.5 41.5t-59.5 49t-36 30q-26 21 -26 49z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 64v128q0 26 19 45t45 19h1664q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-1664q-26 0 -45 19t-19 45zM0 448v128q0 26 19 45t45 19h1280q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-1280q-26 0 -45 19t-19 45zM0 832v128q0 26 19 45t45 19h1536 q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-1536q-26 0 -45 19t-19 45zM0 1216v128q0 26 19 45t45 19h1152q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-1152q-26 0 -45 19t-19 45z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 64v128q0 26 19 45t45 19h1664q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-1664q-26 0 -45 19t-19 45zM128 832v128q0 26 19 45t45 19h1408q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-1408q-26 0 -45 19t-19 45zM384 448v128q0 26 19 45t45 19h896 q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-896q-26 0 -45 19t-19 45zM512 1216v128q0 26 19 45t45 19h640q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-640q-26 0 -45 19t-19 45z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 64v128q0 26 19 45t45 19h1664q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-1664q-26 0 -45 19t-19 45zM128 832v128q0 26 19 45t45 19h1536q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-1536q-26 0 -45 19t-19 45zM384 448v128q0 26 19 45t45 19h1280 q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-1280q-26 0 -45 19t-19 45zM512 1216v128q0 26 19 45t45 19h1152q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-1152q-26 0 -45 19t-19 45z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 64v128q0 26 19 45t45 19h1664q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-1664q-26 0 -45 19t-19 45zM0 448v128q0 26 19 45t45 19h1664q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-1664q-26 0 -45 19t-19 45zM0 832v128q0 26 19 45t45 19h1664 q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-1664q-26 0 -45 19t-19 45zM0 1216v128q0 26 19 45t45 19h1664q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-1664q-26 0 -45 19t-19 45z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 32v192q0 13 9.5 22.5t22.5 9.5h192q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5t-22.5 -9.5h-192q-13 0 -22.5 9.5t-9.5 22.5zM0 416v192q0 13 9.5 22.5t22.5 9.5h192q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5t-22.5 -9.5h-192q-13 0 -22.5 9.5 t-9.5 22.5zM0 800v192q0 13 9.5 22.5t22.5 9.5h192q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5t-22.5 -9.5h-192q-13 0 -22.5 9.5t-9.5 22.5zM0 1184v192q0 13 9.5 22.5t22.5 9.5h192q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5t-22.5 -9.5h-192 q-13 0 -22.5 9.5t-9.5 22.5zM384 32v192q0 13 9.5 22.5t22.5 9.5h1344q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5t-22.5 -9.5h-1344q-13 0 -22.5 9.5t-9.5 22.5zM384 416v192q0 13 9.5 22.5t22.5 9.5h1344q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5 t-22.5 -9.5h-1344q-13 0 -22.5 9.5t-9.5 22.5zM384 800v192q0 13 9.5 22.5t22.5 9.5h1344q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5t-22.5 -9.5h-1344q-13 0 -22.5 9.5t-9.5 22.5zM384 1184v192q0 13 9.5 22.5t22.5 9.5h1344q13 0 22.5 -9.5t9.5 -22.5v-192 q0 -13 -9.5 -22.5t-22.5 -9.5h-1344q-13 0 -22.5 9.5t-9.5 22.5z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 32v192q0 13 9.5 22.5t22.5 9.5h1728q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5t-22.5 -9.5h-1728q-13 0 -22.5 9.5t-9.5 22.5zM0 1184v192q0 13 9.5 22.5t22.5 9.5h1728q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5t-22.5 -9.5h-1728q-13 0 -22.5 9.5 t-9.5 22.5zM32 704q0 14 9 23l288 288q9 9 23 9q13 0 22.5 -9.5t9.5 -22.5v-576q0 -13 -9.5 -22.5t-22.5 -9.5q-14 0 -23 9l-288 288q-9 9 -9 23zM640 416v192q0 13 9.5 22.5t22.5 9.5h1088q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5t-22.5 -9.5h-1088 q-13 0 -22.5 9.5t-9.5 22.5zM640 800v192q0 13 9.5 22.5t22.5 9.5h1088q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5t-22.5 -9.5h-1088q-13 0 -22.5 9.5t-9.5 22.5z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 32v192q0 13 9.5 22.5t22.5 9.5h1728q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5t-22.5 -9.5h-1728q-13 0 -22.5 9.5t-9.5 22.5zM0 416v576q0 13 9.5 22.5t22.5 9.5q14 0 23 -9l288 -288q9 -9 9 -23t-9 -23l-288 -288q-9 -9 -23 -9q-13 0 -22.5 9.5t-9.5 22.5z M0 1184v192q0 13 9.5 22.5t22.5 9.5h1728q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5t-22.5 -9.5h-1728q-13 0 -22.5 9.5t-9.5 22.5zM640 416v192q0 13 9.5 22.5t22.5 9.5h1088q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5t-22.5 -9.5h-1088q-13 0 -22.5 9.5 t-9.5 22.5zM640 800v192q0 13 9.5 22.5t22.5 9.5h1088q13 0 22.5 -9.5t9.5 -22.5v-192q0 -13 -9.5 -22.5t-22.5 -9.5h-1088q-13 0 -22.5 9.5t-9.5 22.5z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 288v704q0 119 84.5 203.5t203.5 84.5h704q119 0 203.5 -84.5t84.5 -203.5v-165l403 402q18 19 45 19q12 0 25 -5q39 -17 39 -59v-1088q0 -42 -39 -59q-13 -5 -25 -5q-27 0 -45 19l-403 403v-166q0 -119 -84.5 -203.5t-203.5 -84.5h-704q-119 0 -203.5 84.5 t-84.5 203.5z" /> +<glyph unicode="" horiz-adv-x="1920" d="M0 32v1216q0 66 47 113t113 47h1600q66 0 113 -47t47 -113v-1216q0 -66 -47 -113t-113 -47h-1600q-66 0 -113 47t-47 113zM128 32q0 -13 9.5 -22.5t22.5 -9.5h1600q13 0 22.5 9.5t9.5 22.5v1216q0 13 -9.5 22.5t-22.5 9.5h-1600q-13 0 -22.5 -9.5t-9.5 -22.5v-1216z M256 128v192l320 320l160 -160l512 512l416 -416v-448h-1408zM256 960q0 80 56 136t136 56t136 -56t56 -136t-56 -136t-136 -56t-136 56t-56 136z" /> +<glyph unicode="" d="M0 -128v416l832 832l416 -416l-832 -832h-416zM128 128h128v-128h107l91 91l-235 235l-91 -91v-107zM298 384q0 -22 22 -22q10 0 17 7l542 542q7 7 7 17q0 22 -22 22q-10 0 -17 -7l-542 -542q-7 -7 -7 -17zM896 1184l166 165q36 38 90 38q53 0 91 -38l235 -234 q37 -39 37 -91q0 -53 -37 -90l-166 -166z" /> +<glyph unicode="" horiz-adv-x="1024" d="M0 896q0 212 150 362t362 150t362 -150t150 -362q0 -109 -33 -179l-364 -774q-16 -33 -47.5 -52t-67.5 -19t-67.5 19t-46.5 52l-365 774q-33 70 -33 179zM256 896q0 -106 75 -181t181 -75t181 75t75 181t-75 181t-181 75t-181 -75t-75 -181z" /> +<glyph unicode="" d="M0 640q0 209 103 385.5t279.5 279.5t385.5 103t385.5 -103t279.5 -279.5t103 -385.5t-103 -385.5t-279.5 -279.5t-385.5 -103t-385.5 103t-279.5 279.5t-103 385.5zM224 640q0 -148 73 -273t198 -198t273 -73v1088q-148 0 -273 -73t-198 -198t-73 -273z" /> +<glyph unicode="" horiz-adv-x="1024" d="M0 512q0 145 81 275q6 9 62.5 90.5t101 151t99.5 178t83 201.5q9 30 34 47t51 17t51.5 -17t33.5 -47q28 -93 83 -201.5t99.5 -178t101 -151t62.5 -90.5q81 -127 81 -275q0 -212 -150 -362t-362 -150t-362 150t-150 362zM256 384q0 -53 37.5 -90.5t90.5 -37.5t90.5 37.5 t37.5 90.5q0 36 -20 69q-1 1 -15.5 22.5t-25.5 38t-25 44t-21 50.5q-4 16 -21 16t-21 -16q-7 -23 -21 -50.5t-25 -44t-25.5 -38t-15.5 -22.5q-20 -33 -20 -69z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 288v832q0 119 84.5 203.5t203.5 84.5h832q63 0 117 -25q15 -7 18 -23q3 -17 -9 -29l-49 -49q-14 -14 -32 -8q-23 6 -45 6h-832q-66 0 -113 -47t-47 -113v-832q0 -66 47 -113t113 -47h832q66 0 113 47t47 113v126q0 13 9 22l64 64q15 15 35 7t20 -29v-190 q0 -119 -84.5 -203.5t-203.5 -84.5h-832q-119 0 -203.5 84.5t-84.5 203.5zM640 256v288l672 672l288 -288l-672 -672h-288zM736 448h96v-96h56l116 116l-152 152l-116 -116v-56zM944 688q16 -16 33 1l350 350q17 17 1 33t-33 -1l-350 -350q-17 -17 -1 -33zM1376 1280l92 92 q28 28 68 28t68 -28l152 -152q28 -28 28 -68t-28 -68l-92 -92z" /> +<glyph unicode="" horiz-adv-x="1664" d="M0 288v832q0 119 84.5 203.5t203.5 84.5h255q13 0 22.5 -9.5t9.5 -22.5q0 -27 -26 -32q-77 -26 -133 -60q-10 -4 -16 -4h-112q-66 0 -113 -47t-47 -113v-832q0 -66 47 -113t113 -47h832q66 0 113 47t47 113v214q0 19 18 29q28 13 54 37q16 16 35 8q21 -9 21 -29v-259 q0 -119 -84.5 -203.5t-203.5 -84.5h-832q-119 0 -203.5 84.5t-84.5 203.5zM256 704q0 49 3.5 91t14 90t28 88t47 81.5t68.5 74t94.5 61.5t124.5 48.5t159.5 30.5t196.5 11h160v192q0 42 39 59q13 5 25 5q26 0 45 -19l384 -384q19 -19 19 -45t-19 -45l-384 -384 q-18 -19 -45 -19q-12 0 -25 5q-39 17 -39 59v192h-160q-323 0 -438 -131q-119 -137 -74 -473q3 -23 -20 -34q-8 -2 -12 -2q-16 0 -26 13q-10 14 -21 31t-39.5 68.5t-49.5 99.5t-38.5 114t-17.5 122z" /> +<glyph unicode="" horiz-adv-x="1664" d="M0 288v832q0 119 84.5 203.5t203.5 84.5h832q63 0 117 -25q15 -7 18 -23q3 -17 -9 -29l-49 -49q-10 -10 -23 -10q-3 0 -9 2q-23 6 -45 6h-832q-66 0 -113 -47t-47 -113v-832q0 -66 47 -113t113 -47h832q66 0 113 47t47 113v254q0 13 9 22l64 64q10 10 23 10q6 0 12 -3 q20 -8 20 -29v-318q0 -119 -84.5 -203.5t-203.5 -84.5h-832q-119 0 -203.5 84.5t-84.5 203.5zM257 768q0 33 24 57l110 110q24 24 57 24t57 -24l263 -263l647 647q24 24 57 24t57 -24l110 -110q24 -24 24 -57t-24 -57l-814 -814q-24 -24 -57 -24t-57 24l-430 430 q-24 24 -24 57z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 640q0 26 19 45l256 256q19 19 45 19t45 -19t19 -45v-128h384v384h-128q-26 0 -45 19t-19 45t19 45l256 256q19 19 45 19t45 -19l256 -256q19 -19 19 -45t-19 -45t-45 -19h-128v-384h384v128q0 26 19 45t45 19t45 -19l256 -256q19 -19 19 -45t-19 -45l-256 -256 q-19 -19 -45 -19t-45 19t-19 45v128h-384v-384h128q26 0 45 -19t19 -45t-19 -45l-256 -256q-19 -19 -45 -19t-45 19l-256 256q-19 19 -19 45t19 45t45 19h128v384h-384v-128q0 -26 -19 -45t-45 -19t-45 19l-256 256q-19 19 -19 45z" /> +<glyph unicode="" horiz-adv-x="1024" d="M0 -64v1408q0 26 19 45t45 19h128q26 0 45 -19t19 -45v-678q4 11 13 19l710 710q19 19 32 13t13 -32v-1472q0 -26 -13 -32t-32 13l-710 710q-9 9 -13 19v-678q0 -26 -19 -45t-45 -19h-128q-26 0 -45 19t-19 45z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 -64v1408q0 26 19 45t45 19h128q26 0 45 -19t19 -45v-678q4 11 13 19l710 710q19 19 32 13t13 -32v-710q4 11 13 19l710 710q19 19 32 13t13 -32v-1472q0 -26 -13 -32t-32 13l-710 710q-9 9 -13 19v-710q0 -26 -13 -32t-32 13l-710 710q-9 9 -13 19v-678q0 -26 -19 -45 t-45 -19h-128q-26 0 -45 19t-19 45z" /> +<glyph unicode="" horiz-adv-x="1664" d="M122 640q0 26 19 45l710 710q19 19 32 13t13 -32v-710q5 11 13 19l710 710q19 19 32 13t13 -32v-1472q0 -26 -13 -32t-32 13l-710 710q-8 9 -13 19v-710q0 -26 -13 -32t-32 13l-710 710q-19 19 -19 45z" /> +<glyph unicode="" horiz-adv-x="1408" d="M0 -96v1472q0 26 16.5 36t39.5 -3l1328 -738q23 -13 23 -31t-23 -31l-1328 -738q-23 -13 -39.5 -3t-16.5 36z" /> +<glyph unicode="" d="M0 -64v1408q0 26 19 45t45 19h512q26 0 45 -19t19 -45v-1408q0 -26 -19 -45t-45 -19h-512q-26 0 -45 19t-19 45zM896 -64v1408q0 26 19 45t45 19h512q26 0 45 -19t19 -45v-1408q0 -26 -19 -45t-45 -19h-512q-26 0 -45 19t-19 45z" /> +<glyph unicode="" d="M0 -64v1408q0 26 19 45t45 19h1408q26 0 45 -19t19 -45v-1408q0 -26 -19 -45t-45 -19h-1408q-26 0 -45 19t-19 45z" /> +<glyph unicode="" horiz-adv-x="1664" d="M0 -96v1472q0 26 13 32t32 -13l710 -710q8 -8 13 -19v710q0 26 13 32t32 -13l710 -710q19 -19 19 -45t-19 -45l-710 -710q-19 -19 -32 -13t-13 32v710q-5 -10 -13 -19l-710 -710q-19 -19 -32 -13t-13 32z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 -96v1472q0 26 13 32t32 -13l710 -710q8 -8 13 -19v710q0 26 13 32t32 -13l710 -710q8 -8 13 -19v678q0 26 19 45t45 19h128q26 0 45 -19t19 -45v-1408q0 -26 -19 -45t-45 -19h-128q-26 0 -45 19t-19 45v678q-5 -10 -13 -19l-710 -710q-19 -19 -32 -13t-13 32v710 q-5 -10 -13 -19l-710 -710q-19 -19 -32 -13t-13 32z" /> +<glyph unicode="" horiz-adv-x="1024" d="M0 -96v1472q0 26 13 32t32 -13l710 -710q8 -8 13 -19v678q0 26 19 45t45 19h128q26 0 45 -19t19 -45v-1408q0 -26 -19 -45t-45 -19h-128q-26 0 -45 19t-19 45v678q-5 -10 -13 -19l-710 -710q-19 -19 -32 -13t-13 32z" /> +<glyph unicode="" horiz-adv-x="1538" d="M1 64v256q0 26 19 45t45 19h1408q26 0 45 -19t19 -45v-256q0 -26 -19 -45t-45 -19h-1408q-26 0 -45 19t-19 45zM1 525q-6 13 13 32l710 710q19 19 45 19t45 -19l710 -710q19 -19 13 -32t-32 -13h-1472q-26 0 -32 13z" /> +<glyph unicode="" horiz-adv-x="1280" d="M154 704q0 26 19 45l742 742q19 19 45 19t45 -19l166 -166q19 -19 19 -45t-19 -45l-531 -531l531 -531q19 -19 19 -45t-19 -45l-166 -166q-19 -19 -45 -19t-45 19l-742 742q-19 19 -19 45z" /> +<glyph unicode="" horiz-adv-x="1280" d="M90 128q0 26 19 45l531 531l-531 531q-19 19 -19 45t19 45l166 166q19 19 45 19t45 -19l742 -742q19 -19 19 -45t-19 -45l-742 -742q-19 -19 -45 -19t-45 19l-166 166q-19 19 -19 45z" /> +<glyph unicode="" d="M0 640q0 209 103 385.5t279.5 279.5t385.5 103t385.5 -103t279.5 -279.5t103 -385.5t-103 -385.5t-279.5 -279.5t-385.5 -103t-385.5 103t-279.5 279.5t-103 385.5zM320 576q0 -26 19 -45t45 -19h256v-256q0 -26 19 -45t45 -19h128q26 0 45 19t19 45v256h256q26 0 45 19 t19 45v128q0 26 -19 45t-45 19h-256v256q0 26 -19 45t-45 19h-128q-26 0 -45 -19t-19 -45v-256h-256q-26 0 -45 -19t-19 -45v-128z" /> +<glyph unicode="" d="M0 640q0 209 103 385.5t279.5 279.5t385.5 103t385.5 -103t279.5 -279.5t103 -385.5t-103 -385.5t-279.5 -279.5t-385.5 -103t-385.5 103t-279.5 279.5t-103 385.5zM320 576q0 -26 19 -45t45 -19h768q26 0 45 19t19 45v128q0 26 -19 45t-45 19h-768q-26 0 -45 -19 t-19 -45v-128z" /> +<glyph unicode="" d="M0 640q0 209 103 385.5t279.5 279.5t385.5 103t385.5 -103t279.5 -279.5t103 -385.5t-103 -385.5t-279.5 -279.5t-385.5 -103t-385.5 103t-279.5 279.5t-103 385.5zM387 414q0 -27 19 -46l90 -90q19 -19 46 -19q26 0 45 19l181 181l181 -181q19 -19 45 -19q27 0 46 19 l90 90q19 19 19 46q0 26 -19 45l-181 181l181 181q19 19 19 45q0 27 -19 46l-90 90q-19 19 -46 19q-26 0 -45 -19l-181 -181l-181 181q-19 19 -45 19q-27 0 -46 -19l-90 -90q-19 -19 -19 -46q0 -26 19 -45l181 -181l-181 -181q-19 -19 -19 -45z" /> +<glyph unicode="" d="M0 640q0 209 103 385.5t279.5 279.5t385.5 103t385.5 -103t279.5 -279.5t103 -385.5t-103 -385.5t-279.5 -279.5t-385.5 -103t-385.5 103t-279.5 279.5t-103 385.5zM252 621q0 -27 18 -45l362 -362q19 -19 45 -19q27 0 46 19l543 543q18 18 18 45q0 28 -18 46l-91 90 q-19 19 -45 19t-45 -19l-408 -407l-226 226q-19 19 -45 19t-45 -19l-91 -90q-18 -18 -18 -46z" /> +<glyph unicode="" d="M0 640q0 209 103 385.5t279.5 279.5t385.5 103t385.5 -103t279.5 -279.5t103 -385.5t-103 -385.5t-279.5 -279.5t-385.5 -103t-385.5 103t-279.5 279.5t-103 385.5zM417 939q-15 -24 8 -42l132 -100q7 -6 19 -6q16 0 25 12q53 68 86 92q34 24 86 24q48 0 85.5 -26 t37.5 -59q0 -38 -20 -61t-68 -45q-63 -28 -115.5 -86.5t-52.5 -125.5v-36q0 -14 9 -23t23 -9h192q14 0 23 9t9 23q0 19 21.5 49.5t54.5 49.5q32 18 49 28.5t46 35t44.5 48t28 60.5t12.5 81q0 88 -55.5 163t-138.5 116t-170 41q-243 0 -371 -213zM640 160q0 -14 9 -23t23 -9 h192q14 0 23 9t9 23v192q0 14 -9 23t-23 9h-192q-14 0 -23 -9t-9 -23v-192z" /> +<glyph unicode="" d="M0 640q0 209 103 385.5t279.5 279.5t385.5 103t385.5 -103t279.5 -279.5t103 -385.5t-103 -385.5t-279.5 -279.5t-385.5 -103t-385.5 103t-279.5 279.5t-103 385.5zM512 160q0 -14 9 -23t23 -9h448q14 0 23 9t9 23v160q0 14 -9 23t-23 9h-96v512q0 14 -9 23t-23 9h-320 q-14 0 -23 -9t-9 -23v-160q0 -14 9 -23t23 -9h96v-320h-96q-14 0 -23 -9t-9 -23v-160zM640 1056q0 -14 9 -23t23 -9h192q14 0 23 9t9 23v160q0 14 -9 23t-23 9h-192q-14 0 -23 -9t-9 -23v-160z" /> +<glyph unicode="" d="M0 576v128q0 26 19 45t45 19h143q37 161 154.5 278.5t278.5 154.5v143q0 26 19 45t45 19h128q26 0 45 -19t19 -45v-143q161 -37 278.5 -154.5t154.5 -278.5h143q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-143q-37 -161 -154.5 -278.5t-278.5 -154.5v-143 q0 -26 -19 -45t-45 -19h-128q-26 0 -45 19t-19 45v143q-161 37 -278.5 154.5t-154.5 278.5h-143q-26 0 -45 19t-19 45zM339 512q32 -108 112.5 -188.5t188.5 -112.5v109q0 26 19 45t45 19h128q26 0 45 -19t19 -45v-109q108 32 188.5 112.5t112.5 188.5h-109q-26 0 -45 19 t-19 45v128q0 26 19 45t45 19h109q-32 108 -112.5 188.5t-188.5 112.5v-109q0 -26 -19 -45t-45 -19h-128q-26 0 -45 19t-19 45v109q-108 -32 -188.5 -112.5t-112.5 -188.5h109q26 0 45 -19t19 -45v-128q0 -26 -19 -45t-45 -19h-109z" /> +<glyph unicode="" d="M0 640q0 209 103 385.5t279.5 279.5t385.5 103t385.5 -103t279.5 -279.5t103 -385.5t-103 -385.5t-279.5 -279.5t-385.5 -103t-385.5 103t-279.5 279.5t-103 385.5zM224 640q0 -148 73 -273t198 -198t273 -73t273 73t198 198t73 273t-73 273t-198 198t-273 73t-273 -73 t-198 -198t-73 -273zM429 480q0 13 10 23l137 137l-137 137q-10 10 -10 23t10 23l146 146q10 10 23 10t23 -10l137 -137l137 137q10 10 23 10t23 -10l146 -146q10 -10 10 -23t-10 -23l-137 -137l137 -137q10 -10 10 -23t-10 -23l-146 -146q-10 -10 -23 -10t-23 10l-137 137 l-137 -137q-10 -10 -23 -10t-23 10l-146 146q-10 10 -10 23z" /> +<glyph unicode="" d="M0 640q0 209 103 385.5t279.5 279.5t385.5 103t385.5 -103t279.5 -279.5t103 -385.5t-103 -385.5t-279.5 -279.5t-385.5 -103t-385.5 103t-279.5 279.5t-103 385.5zM224 640q0 -148 73 -273t198 -198t273 -73t273 73t198 198t73 273t-73 273t-198 198t-273 73t-273 -73 t-198 -198t-73 -273zM346 640q0 26 19 45l102 102q19 19 45 19t45 -19l147 -147l275 275q19 19 45 19t45 -19l102 -102q19 -19 19 -45t-19 -45l-422 -422q-19 -19 -45 -19t-45 19l-294 294q-19 19 -19 45z" /> +<glyph unicode="" d="M0 643q0 157 61 299.5t163.5 245.5t245 164t298.5 61t298.5 -61t245 -164t163.5 -245.5t61 -299.5t-61 -300t-163.5 -246t-245 -164t-298.5 -61t-298.5 61t-245 164t-163.5 246t-61 300zM224 643q0 -162 89 -299l755 754q-135 91 -300 91q-148 0 -273 -73t-198 -199 t-73 -274zM471 185q137 -89 297 -89q111 0 211.5 43.5t173.5 116.5t116 174.5t43 212.5q0 161 -87 295z" /> +<glyph unicode="" d="M64 576q0 52 37 91l651 650q38 38 91 38q52 0 90 -38l75 -74q38 -38 38 -91t-38 -91l-293 -293h704q52 0 84.5 -37.5t32.5 -90.5v-128q0 -53 -32.5 -90.5t-84.5 -37.5h-704l293 -294q38 -36 38 -90t-38 -90l-75 -76q-37 -37 -90 -37q-52 0 -91 37l-651 652q-37 37 -37 90 z" /> +<glyph unicode="" d="M0 512v128q0 53 32.5 90.5t84.5 37.5h704l-293 294q-38 36 -38 90t38 90l75 75q38 38 90 38q53 0 91 -38l651 -651q37 -35 37 -90q0 -54 -37 -91l-651 -651q-39 -37 -91 -37q-51 0 -90 37l-75 75q-38 38 -38 91t38 91l293 293h-704q-52 0 -84.5 37.5t-32.5 90.5z" /> +<glyph unicode="" horiz-adv-x="1664" d="M53 565q0 53 38 91l651 651q35 37 90 37q54 0 91 -37l651 -651q37 -39 37 -91q0 -51 -37 -90l-75 -75q-38 -38 -91 -38q-54 0 -90 38l-294 293v-704q0 -52 -37.5 -84.5t-90.5 -32.5h-128q-53 0 -90.5 32.5t-37.5 84.5v704l-294 -293q-36 -38 -90 -38t-90 38l-75 75 q-38 38 -38 90z" /> +<glyph unicode="" horiz-adv-x="1664" d="M53 704q0 53 38 91l74 75q39 37 91 37q53 0 90 -37l294 -294v704q0 52 38 90t90 38h128q52 0 90 -38t38 -90v-704l294 294q37 37 90 37q52 0 91 -37l75 -75q37 -39 37 -91q0 -53 -37 -90l-651 -652q-39 -37 -91 -37q-53 0 -90 37l-651 652q-38 36 -38 90z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 416q0 199 53 333q162 403 875 403h224v256q0 26 19 45t45 19t45 -19l512 -512q19 -19 19 -45t-19 -45l-512 -512q-19 -19 -45 -19t-45 19t-19 45v256h-224q-98 0 -175.5 -6t-154 -21.5t-133 -42.5t-105.5 -69.5t-80 -101t-48.5 -138.5t-17.5 -181q0 -55 5 -123 q0 -6 2.5 -23.5t2.5 -26.5q0 -15 -8.5 -25t-23.5 -10q-16 0 -28 17q-7 9 -13 22t-13.5 30t-10.5 24q-127 285 -127 451z" /> +<glyph unicode="" d="M0 -64v448q0 26 19 45t45 19t45 -19l144 -144l332 332q10 10 23 10t23 -10l114 -114q10 -10 10 -23t-10 -23l-332 -332l144 -144q19 -19 19 -45t-19 -45t-45 -19h-448q-26 0 -45 19t-19 45zM781 800q0 13 10 23l332 332l-144 144q-19 19 -19 45t19 45t45 19h448 q26 0 45 -19t19 -45v-448q0 -26 -19 -45t-45 -19t-45 19l-144 144l-332 -332q-10 -10 -23 -10t-23 10l-114 114q-10 10 -10 23z" /> +<glyph unicode="" d="M13 32q0 13 10 23l332 332l-144 144q-19 19 -19 45t19 45t45 19h448q26 0 45 -19t19 -45v-448q0 -26 -19 -45t-45 -19t-45 19l-144 144l-332 -332q-10 -10 -23 -10t-23 10l-114 114q-10 10 -10 23zM768 704v448q0 26 19 45t45 19t45 -19l144 -144l332 332q10 10 23 10 t23 -10l114 -114q10 -10 10 -23t-10 -23l-332 -332l144 -144q19 -19 19 -45t-19 -45t-45 -19h-448q-26 0 -45 19t-19 45z" /> +<glyph unicode="" horiz-adv-x="1408" d="M0 608v192q0 40 28 68t68 28h416v416q0 40 28 68t68 28h192q40 0 68 -28t28 -68v-416h416q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-416v-416q0 -40 -28 -68t-68 -28h-192q-40 0 -68 28t-28 68v416h-416q-40 0 -68 28t-28 68z" /> +<glyph unicode="" horiz-adv-x="1408" d="M0 608v192q0 40 28 68t68 28h1216q40 0 68 -28t28 -68v-192q0 -40 -28 -68t-68 -28h-1216q-40 0 -68 28t-28 68z" /> +<glyph unicode="" horiz-adv-x="1664" d="M122.5 408.5q13.5 51.5 59.5 77.5l266 154l-266 154q-46 26 -59.5 77.5t12.5 97.5l64 110q26 46 77.5 59.5t97.5 -12.5l266 -153v307q0 52 38 90t90 38h128q52 0 90 -38t38 -90v-307l266 153q46 26 97.5 12.5t77.5 -59.5l64 -110q26 -46 12.5 -97.5t-59.5 -77.5 l-266 -154l266 -154q46 -26 59.5 -77.5t-12.5 -97.5l-64 -110q-26 -46 -77.5 -59.5t-97.5 12.5l-266 153v-307q0 -52 -38 -90t-90 -38h-128q-52 0 -90 38t-38 90v307l-266 -153q-46 -26 -97.5 -12.5t-77.5 59.5l-64 110q-26 46 -12.5 97.5z" /> +<glyph unicode="" d="M0 640q0 209 103 385.5t279.5 279.5t385.5 103t385.5 -103t279.5 -279.5t103 -385.5t-103 -385.5t-279.5 -279.5t-385.5 -103t-385.5 103t-279.5 279.5t-103 385.5zM624 1126l17 -621q0 -10 10 -17.5t24 -7.5h185q14 0 23.5 7.5t10.5 17.5l18 621q0 12 -10 18 q-10 8 -24 8h-220q-14 0 -24 -8q-10 -6 -10 -18zM640 161q0 -13 10 -23t23 -10h192q13 0 22 9.5t9 23.5v190q0 14 -9 23.5t-22 9.5h-192q-13 0 -23 -10t-10 -23v-190z" /> +<glyph unicode="" d="M0 544v320q0 14 9 23t23 9h440q-93 0 -158.5 65.5t-65.5 158.5t65.5 158.5t158.5 65.5q107 0 168 -77l128 -165l128 165q61 77 168 77q93 0 158.5 -65.5t65.5 -158.5t-65.5 -158.5t-158.5 -65.5h440q14 0 23 -9t9 -23v-320q0 -14 -9 -23t-23 -9h-96v-416q0 -40 -28 -68 t-68 -28h-1088q-40 0 -68 28t-28 68v416h-96q-14 0 -23 9t-9 23zM376 1120q0 -40 28 -68t68 -28h195l-126 161q-26 31 -69 31q-40 0 -68 -28t-28 -68zM608 180q0 -25 18 -38.5t46 -13.5h192q28 0 46 13.5t18 38.5v56v468v192h-320v-192v-468v-56zM870 1024h194q40 0 68 28 t28 68t-28 68t-68 28q-43 0 -69 -31z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 121q0 35 31 73.5t68 65.5t68 56t31 48q0 4 -14 38t-16 44q-9 51 -9 104q0 115 43.5 220t119 184.5t170.5 139t204 95.5q55 18 145 25.5t179.5 9t178.5 6t163.5 24t113.5 56.5l29.5 29.5t29.5 28t27 20t36.5 16t43.5 4.5q39 0 70.5 -46t47.5 -112t24 -124t8 -96 q0 -95 -20 -193q-46 -224 -184.5 -383t-357.5 -268q-214 -108 -438 -108q-148 0 -286 47q-15 5 -88 42t-96 37q-16 0 -39.5 -32t-45 -70t-52.5 -70t-60 -32q-30 0 -51 11t-31 24t-27 42q-2 4 -6 11t-5.5 10t-3 9.5t-1.5 13.5zM384 448q0 -26 19 -45t45 -19q24 0 45 19 q27 24 74 71t67 66q137 124 268.5 176t313.5 52q26 0 45 19t19 45t-19 45t-45 19q-172 0 -318 -49.5t-259.5 -134t-235.5 -219.5q-19 -21 -19 -45z" /> +<glyph unicode="" horiz-adv-x="1408" d="M0 -160q0 13 9.5 22.5t22.5 9.5h1344q13 0 22.5 -9.5t9.5 -22.5v-64q0 -13 -9.5 -22.5t-22.5 -9.5h-1344q-13 0 -22.5 9.5t-9.5 22.5v64zM256 640q0 78 24.5 144t64 112.5t87.5 88t96 77.5t87.5 72t64 81.5t24.5 96.5q0 94 -66 224l3 -1l-1 1q90 -41 160 -83t138.5 -100 t113.5 -122.5t72.5 -150.5t27.5 -184q0 -78 -24.5 -144t-64 -112.5t-87.5 -88t-96 -77.5t-87.5 -72t-64 -81.5t-24.5 -96.5q0 -96 67 -224l-4 1l1 -1q-90 41 -160 83t-138.5 100t-113.5 122.5t-72.5 150.5t-27.5 184z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 576q0 34 20 69q140 229 376.5 368t499.5 139t499.5 -139t376.5 -368q20 -35 20 -69t-20 -69q-140 -230 -376.5 -368.5t-499.5 -138.5t-499.5 139t-376.5 368q-20 35 -20 69zM128 576q133 -205 333.5 -326.5t434.5 -121.5t434.5 121.5t333.5 326.5q-152 236 -381 353 q61 -104 61 -225q0 -185 -131.5 -316.5t-316.5 -131.5t-316.5 131.5t-131.5 316.5q0 121 61 225q-229 -117 -381 -353zM592 704q0 -20 14 -34t34 -14t34 14t14 34q0 86 61 147t147 61q20 0 34 14t14 34t-14 34t-34 14q-125 0 -214.5 -89.5t-89.5 -214.5z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 576q0 38 20 69q153 235 380 371t496 136q89 0 180 -17l54 97q10 16 28 16q5 0 18 -6t31 -15.5t33 -18.5t31.5 -18.5t19.5 -11.5q16 -10 16 -27q0 -7 -1 -9q-105 -188 -315 -566t-316 -567l-49 -89q-10 -16 -28 -16q-12 0 -134 70q-16 10 -16 28q0 12 44 87 q-143 65 -263.5 173t-208.5 245q-20 31 -20 69zM128 576q167 -258 427 -375l78 141q-87 63 -136 159t-49 203q0 121 61 225q-229 -117 -381 -353zM592 704q0 -20 14 -34t34 -14t34 14t14 34q0 86 61 147t147 61q20 0 34 14t14 34t-14 34t-34 14q-125 0 -214.5 -89.5 t-89.5 -214.5zM896 0l74 132q212 18 392.5 137t301.5 307q-115 179 -282 294l63 112q95 -64 182.5 -153t144.5 -184q20 -34 20 -69t-20 -69q-39 -64 -109 -145q-150 -172 -347.5 -267t-419.5 -95zM1056 286l280 502q8 -45 8 -84q0 -139 -79 -253.5t-209 -164.5z" /> +<glyph unicode="" horiz-adv-x="1792" d="M16 61l768 1408q17 31 47 49t65 18t65 -18t47 -49l768 -1408q35 -63 -2 -126q-17 -29 -46.5 -46t-63.5 -17h-1536q-34 0 -63.5 17t-46.5 46q-37 63 -2 126zM752 992l17 -457q0 -10 10 -16.5t24 -6.5h185q14 0 23.5 6.5t10.5 16.5l18 459q0 12 -10 19q-13 11 -24 11h-220 q-11 0 -24 -11q-10 -7 -10 -21zM768 161q0 -14 9.5 -23.5t22.5 -9.5h192q13 0 22.5 9.5t9.5 23.5v190q0 14 -9.5 23.5t-22.5 9.5h-192q-13 0 -22.5 -9.5t-9.5 -23.5v-190z" /> +<glyph unicode="" horiz-adv-x="1408" d="M0 477q-1 13 9 25l96 97q9 9 23 9q6 0 8 -1l194 -53l259 259l-508 279q-14 8 -17 24q-2 16 9 27l128 128q14 13 30 8l665 -159l160 160q76 76 172 108t148 -12q44 -52 12 -148t-108 -172l-161 -161l160 -696q5 -19 -12 -33l-128 -96q-7 -6 -19 -6q-4 0 -7 1q-15 3 -21 16 l-279 508l-259 -259l53 -194q5 -17 -8 -31l-96 -96q-9 -9 -23 -9h-2q-15 2 -24 13l-189 252l-252 189q-11 7 -13 23z" /> +<glyph unicode="" horiz-adv-x="1664" d="M0 -128v1280q0 52 38 90t90 38h128v96q0 66 47 113t113 47h64q66 0 113 -47t47 -113v-96h384v96q0 66 47 113t113 47h64q66 0 113 -47t47 -113v-96h128q52 0 90 -38t38 -90v-1280q0 -52 -38 -90t-90 -38h-1408q-52 0 -90 38t-38 90zM128 -128h288v288h-288v-288zM128 224 h288v320h-288v-320zM128 608h288v288h-288v-288zM384 1088q0 -13 9.5 -22.5t22.5 -9.5h64q13 0 22.5 9.5t9.5 22.5v288q0 13 -9.5 22.5t-22.5 9.5h-64q-13 0 -22.5 -9.5t-9.5 -22.5v-288zM480 -128h320v288h-320v-288zM480 224h320v320h-320v-320zM480 608h320v288h-320 v-288zM864 -128h320v288h-320v-288zM864 224h320v320h-320v-320zM864 608h320v288h-320v-288zM1152 1088q0 -13 9.5 -22.5t22.5 -9.5h64q13 0 22.5 9.5t9.5 22.5v288q0 13 -9.5 22.5t-22.5 9.5h-64q-13 0 -22.5 -9.5t-9.5 -22.5v-288zM1248 -128h288v288h-288v-288z M1248 224h288v320h-288v-320zM1248 608h288v288h-288v-288z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 160v192q0 14 9 23t23 9h224q48 0 87 15t69 45t51 61.5t45 77.5q32 62 78 171q29 66 49.5 111t54 105t64 100t74 83t90 68.5t106.5 42t128 16.5h256v192q0 14 9 23t23 9q12 0 24 -10l319 -319q9 -9 9 -23t-9 -23l-320 -320q-9 -9 -23 -9q-13 0 -22.5 9.5t-9.5 22.5v192 h-256q-48 0 -87 -15t-69 -45t-51 -61.5t-45 -77.5q-32 -62 -78 -171q-29 -66 -49.5 -111t-54 -105t-64 -100t-74 -83t-90 -68.5t-106.5 -42t-128 -16.5h-224q-14 0 -23 9t-9 23zM0 1056v192q0 14 9 23t23 9h224q250 0 410 -225q-60 -92 -137 -273q-22 45 -37 72.5 t-40.5 63.5t-51 56.5t-63 35t-81.5 14.5h-224q-14 0 -23 9t-9 23zM743 353q59 93 136 273q22 -45 37 -72.5t40.5 -63.5t51 -56.5t63 -35t81.5 -14.5h256v192q0 14 9 23t23 9q12 0 24 -10l319 -319q9 -9 9 -23t-9 -23l-320 -320q-9 -9 -23 -9q-13 0 -22.5 9.5t-9.5 22.5v192 q-32 0 -85 -0.5t-81 -1t-73 1t-71 5t-64 10.5t-63 18.5t-58 28.5t-59 40t-55 53.5t-56 69.5z" /> +<glyph unicode="" horiz-adv-x="1792" d="M0 640q0 130 71 248.5t191 204.5t286 136.5t348 50.5q244 0 450 -85.5t326 -233t120 -321.5t-120 -321.5t-326 -233t-450 -85.5q-70 0 -145 8q-198 -175 -460 -242q-49 -14 -114 -22q-17 -2 -30.5 9t-17.5 29v1q-3 4 -0.5 12t2 10t4.5 9.5l6 9t7 8.5t8 9q7 8 31 34.5 t34.5 38t31 39.5t32.5 51t27 59t26 76q-157 89 -247.5 220t-90.5 281z" /> +<glyph unicode="" d="M0 576v128q0 26 19 45t45 19h384q26 0 45 -19t19 -45v-128q0 -52 23.5 -90t53.5 -57t71 -30t64 -13t44 -2t44 2t64 13t71 30t53.5 57t23.5 90v128q0 26 19 45t45 19h384q26 0 45 -19t19 -45v-128q0 -201 -98.5 -362t-274 -251.5t-395.5 -90.5t-395.5 90.5t-274 251.5 t-98.5 362zM0 960v384q0 26 19 45t45 19h384q26 0 45 -19t19 -45v-384q0 -26 -19 -45t-45 -19h-384q-26 0 -45 19t-19 45zM1024 960v384q0 26 19 45t45 | 504 | chore(docs-app): Update assets for index page | 0 | .svg | svg | mit | Semantic-Org/Semantic-UI-Angular |
10071611 | <NME> transducers.js
<BEF>
// basic protocol helpers
var symbolExists = typeof Symbol !== 'undefined';
var protocols = {
iterator: symbolExists ? Symbol.iterator : '@@iterator'
};
function throwProtocolError(name, coll) {
throw new Error("don't know how to " + name + " collection: " +
coll);
}
function fulfillsProtocol(obj, name) {
if(name === 'iterator') {
// Accept ill-formed iterators that don't conform to the
// protocol by accepting just next()
return obj[protocols.iterator] || obj.next;
}
return obj[protocols[name]];
}
function getProtocolProperty(obj, name) {
return obj[protocols[name]];
}
function iterator(coll) {
var iter = getProtocolProperty(coll, 'iterator');
if(iter) {
return iter.call(coll);
}
else if(coll.next) {
// Basic duck typing to accept an ill-formed iterator that doesn't
// conform to the iterator protocol (all iterators should have the
// @@iterator method and return themselves, but some engines don't
// have that on generators like older v8)
return coll;
}
else if(isArray(coll)) {
return new ArrayIterator(coll);
}
else if(isObject(coll)) {
return new ObjectIterator(coll);
}
}
function ArrayIterator(arr) {
this.arr = arr;
this.index = 0;
}
ArrayIterator.prototype.next = function() {
if(this.index < this.arr.length) {
return {
value: this.arr[this.index++],
done: false
};
}
return {
done: true
}
};
function ObjectIterator(obj) {
this.obj = obj;
this.keys = Object.keys(obj);
this.index = 0;
}
ObjectIterator.prototype.next = function() {
if(this.index < this.keys.length) {
var k = this.keys[this.index++];
return {
value: [k, this.obj[k]],
done: false
};
}
return {
done: true
}
};
// helpers
var toString = Object.prototype.toString;
var isArray = typeof Array.isArray === 'function' ? Array.isArray : function(obj) {
return toString.call(obj) == '[object Array]';
};
function isFunction(x) {
return typeof x === 'function';
}
function isObject(x) {
return x instanceof Object &&
Object.getPrototypeOf(x) === Object.getPrototypeOf({});
}
function isNumber(x) {
return typeof x === 'number';
}
function Reduced(value) {
this['@@transducer/reduced'] = true;
this['@@transducer/value'] = value;
}
function isReduced(x) {
return (x instanceof Reduced) || (x && x['@@transducer/reduced']);
}
function deref(x) {
return x['@@transducer/value'];
}
/**
* This is for transforms that may call their nested transforms before
* Reduced-wrapping the result (e.g. "take"), to avoid nested Reduced.
*/
function ensureReduced(val) {
if(isReduced(val)) {
return val;
} else {
return new Reduced(val);
}
}
/**
* This is for tranforms that call their nested transforms when
* performing completion (like "partition"), to avoid signaling
* termination after already completing.
*/
function ensureUnreduced(v) {
if(isReduced(v)) {
return deref(v);
} else {
return v;
}
}
function reduce(coll, xform, init) {
if(isArray(coll)) {
var result = init;
var index = -1;
var len = coll.length;
while(++index < len) {
result = xform['@@transducer/step'](result, coll[index]);
if(isReduced(result)) {
result = deref(result);
break;
}
}
return xform['@@transducer/result'](result);
}
else if(isObject(coll) || fulfillsProtocol(coll, 'iterator')) {
var result = init;
var iter = iterator(coll);
var val = iter.next();
while(!val.done) {
result = xform['@@transducer/step'](result, val.value);
if(isReduced(result)) {
result = deref(result);
break;
}
val = iter.next();
}
return xform['@@transducer/result'](result);
}
throwProtocolError('iterate', coll);
}
function transduce(coll, xform, reducer, init) {
xform = xform(reducer);
if(init === undefined) {
init = xform['@@transducer/init']();
}
return reduce(coll, xform, init);
}
function compose() {
var funcs = Array.prototype.slice.call(arguments);
return function(r) {
var value = r;
for(var i=funcs.length-1; i>=0; i--) {
value = funcs[i](value);
}
return value;
}
}
// transformations
function transformer(f) {
var t = {};
t['@@transducer/init'] = function() {
throw new Error('init value unavailable');
};
t['@@transducer/result'] = function(v) {
return v;
};
t['@@transducer/step'] = f;
return t;
}
function bound(f, ctx, count) {
count = count != null ? count : 1;
if(!ctx) {
return f;
}
else {
switch(count) {
case 1:
return function(x) {
return f.call(ctx, x);
}
case 2:
return function(x, y) {
return f.call(ctx, x, y);
}
default:
return f.bind(ctx);
}
}
}
function arrayMap(arr, f, ctx) {
var index = -1;
var length = arr.length;
var result = Array(length);
f = bound(f, ctx, 2);
while (++index < length) {
result[index] = f(arr[index], index);
}
return result;
}
function arrayFilter(arr, f, ctx) {
var len = arr.length;
var result = [];
f = bound(f, ctx, 2);
for(var i=0; i<len; i++) {
if(f(arr[i], i)) {
result.push(arr[i]);
}
}
return result;
}
function Map(f, xform) {
this.xform = xform;
this.f = f;
}
Map.prototype['@@transducer/init'] = function() {
return this.xform['@@transducer/init']();
};
Map.prototype['@@transducer/result'] = function(v) {
return this.xform['@@transducer/result'](v);
};
Map.prototype['@@transducer/step'] = function(res, input) {
return this.xform['@@transducer/step'](res, this.f(input));
};
function map(coll, f, ctx) {
if(isFunction(coll)) { ctx = f; f = coll; coll = null; }
f = bound(f, ctx);
if(coll) {
if(isArray(coll)) {
return arrayMap(coll, f, ctx);
}
return seq(coll, map(f));
}
return function(xform) {
return new Map(f, xform);
}
}
function Filter(f, xform) {
this.xform = xform;
this.f = f;
}
Filter.prototype['@@transducer/init'] = function() {
return this.xform['@@transducer/init']();
};
Filter.prototype['@@transducer/result'] = function(v) {
return this.xform['@@transducer/result'](v);
};
Filter.prototype['@@transducer/step'] = function(res, input) {
if(this.f(input)) {
return this.xform['@@transducer/step'](res, input);
}
return res;
};
function filter(coll, f, ctx) {
if(isFunction(coll)) { ctx = f; f = coll; coll = null; }
f = bound(f, ctx);
if(coll) {
if(isArray(coll)) {
return arrayFilter(coll, f, ctx);
}
return seq(coll, filter(f));
}
return function(xform) {
return new Filter(f, xform);
};
}
function remove(coll, f, ctx) {
if(isFunction(coll)) { ctx = f; f = coll; coll = null; }
f = bound(f, ctx);
return filter(coll, function(x) { return !f(x); });
}
function keep(coll) {
return filter(coll, function(x) { return x != null });
}
function Dedupe(xform) {
this.xform = xform;
this.last = undefined;
}
Dedupe.prototype['@@transducer/init'] = function() {
return this.xform['@@transducer/init']();
};
Dedupe.prototype['@@transducer/result'] = function(v) {
return this.xform['@@transducer/result'](v);
};
Dedupe.prototype['@@transducer/step'] = function(result, input) {
if(input !== this.last) {
this.last = input;
return this.xform['@@transducer/step'](result, input);
}
return result;
};
function dedupe(coll) {
if(coll) {
return seq(coll, dedupe());
}
return function(xform) {
return new Dedupe(xform);
}
}
function TakeWhile(f, xform) {
this.xform = xform;
this.f = f;
}
TakeWhile.prototype['@@transducer/init'] = function() {
return this.xform['@@transducer/init']();
};
TakeWhile.prototype['@@transducer/result'] = function(v) {
return this.xform['@@transducer/result'](v);
};
TakeWhile.prototype['@@transducer/step'] = function(result, input) {
if(this.f(input)) {
return this.xform['@@transducer/step'](result, input);
}
return new Reduced(result);
};
function takeWhile(coll, f, ctx) {
if(isFunction(coll)) { ctx = f; f = coll; coll = null; }
f = bound(f, ctx);
if(coll) {
return seq(coll, takeWhile(f));
}
return function(xform) {
return new TakeWhile(f, xform);
}
}
function Take(n, xform) {
this.n = n;
this.i = 0;
this.xform = xform;
}
Take.prototype['@@transducer/init'] = function() {
return this.xform['@@transducer/init']();
};
Take.prototype['@@transducer/result'] = function(v) {
return this.xform['@@transducer/result'](v);
};
Take.prototype['@@transducer/step'] = function(result, input) {
if (this.i < this.n) {
result = this.xform['@@transducer/step'](result, input);
if(this.i + 1 >= this.n) {
// Finish reducing on the same step as the final value. TODO:
// double-check that this doesn't break any semantics
result = ensureReduced(result);
}
}
this.i++;
return result;
};
function take(coll, n) {
if(isNumber(coll)) { n = coll; coll = null }
if(coll) {
return seq(coll, take(n));
}
return function(xform) {
return new Take(n, xform);
}
}
function Drop(n, xform) {
this.n = n;
this.i = 0;
this.xform = xform;
}
Drop.prototype['@@transducer/init'] = function() {
return this.xform['@@transducer/init']();
};
Drop.prototype['@@transducer/result'] = function(v) {
return this.xform['@@transducer/result'](v);
};
Drop.prototype['@@transducer/step'] = function(result, input) {
if(this.i++ < this.n) {
return result;
}
return this.xform['@@transducer/step'](result, input);
};
function drop(coll, n) {
if(isNumber(coll)) { n = coll; coll = null }
if(coll) {
return seq(coll, drop(n));
}
return function(xform) {
return new Drop(n, xform);
}
}
function DropWhile(f, xform) {
this.xform = xform;
this.f = f;
this.dropping = true;
}
DropWhile.prototype['@@transducer/init'] = function() {
return this.xform['@@transducer/init']();
};
DropWhile.prototype['@@transducer/result'] = function(v) {
return this.xform['@@transducer/result'](v);
};
DropWhile.prototype['@@transducer/step'] = function(result, input) {
if(this.dropping) {
if(this.f(input)) {
return result;
}
else {
this.dropping = false;
}
}
return this.xform['@@transducer/step'](result, input);
};
function dropWhile(coll, f, ctx) {
if(isFunction(coll)) { ctx = f; f = coll; coll = null; }
f = bound(f, ctx);
if(coll) {
return seq(coll, dropWhile(f));
}
return function(xform) {
return new DropWhile(f, xform);
}
}
function Partition(n, xform) {
this.n = n;
this.i = 0;
this.xform = xform;
this.part = new Array(n);
}
Partition.prototype['@@transducer/init'] = function() {
return this.xform['@@transducer/init']();
};
Partition.prototype['@@transducer/result'] = function(v) {
if (this.i > 0) {
return ensureUnreduced(this.xform['@@transducer/step'](v, this.part.slice(0, this.i)));
}
return this.xform['@@transducer/result'](v);
};
Partition.prototype['@@transducer/step'] = function(result, input) {
this.part[this.i] = input;
this.i += 1;
if (this.i === this.n) {
var out = this.part.slice(0, this.n);
this.part = new Array(this.n);
this.i = 0;
return this.xform['@@transducer/step'](result, out);
}
return result;
};
function partition(coll, n) {
if (isNumber(coll)) {
n = coll; coll = null;
}
if (coll) {
return seq(coll, partition(n));
}
return function(xform) {
return new Partition(n, xform);
};
}
var NOTHING = {};
function PartitionBy(f, xform) {
// TODO: take an "opts" object that allows the user to specify
// equality
this.f = f;
this.xform = xform;
this.part = [];
this.last = NOTHING;
}
PartitionBy.prototype['@@transducer/init'] = function() {
return this.xform['@@transducer/init']();
};
PartitionBy.prototype['@@transducer/result'] = function(v) {
var l = this.part.length;
if (l > 0) {
return ensureUnreduced(this.xform['@@transducer/step'](v, this.part.slice(0, l)));
}
return this.xform['@@transducer/result'](v);
};
PartitionBy.prototype['@@transducer/step'] = function(result, input) {
var current = this.f(input);
if (current === this.last || this.last === NOTHING) {
this.part.push(input);
} else {
result = this.xform['@@transducer/step'](result, this.part);
this.part = [input];
}
this.last = current;
return result;
};
function partitionBy(coll, f, ctx) {
if (isFunction(coll)) { ctx = f; f = coll; coll = null; }
f = bound(f, ctx);
if (coll) {
return seq(coll, partitionBy(f));
}
return function(xform) {
return new PartitionBy(f, xform);
};
};
}
// pure transducers (cannot take collections)
function Cat(xform) {
}
Cat.prototype['@@transducer/init'] = function() {
return this.xform['@@transducer/init']();
};
Cat.prototype['@@transducer/result'] = function(v) {
return this.xform['@@transducer/result'](v);
};
Cat.prototype['@@transducer/step'] = function(result, input) {
var xform = this.xform;
var newxform = {};
newxform['@@transducer/init'] = function() {
return xform['@@transducer/init']();
};
newxform['@@transducer/result'] = function(v) {
return v;
};
newxform['@@transducer/step'] = function(result, input) {
var val = xform['@@transducer/step'](result, input);
return isReduced(val) ? deref(val) : val;
};
return reduce(input, newxform, result);
};
function cat(xform) {
return new Cat(xform);
}
function mapcat(f, ctx) {
f = bound(f, ctx);
return compose(map(f), cat);
}
// collection helpers
function push(arr, x) {
arr.push(x);
return arr;
}
function merge(obj, x) {
if(isArray(x) && x.length === 2) {
obj[x[0]] = x[1];
}
else {
var keys = Object.keys(x);
var len = keys.length;
for(var i=0; i<len; i++) {
obj[keys[i]] = x[keys[i]];
}
}
return obj;
}
var arrayReducer = {};
arrayReducer['@@transducer/init'] = function() {
return [];
};
arrayReducer['@@transducer/result'] = function(v) {
return v;
};
arrayReducer['@@transducer/step'] = push;
var objReducer = {};
objReducer['@@transducer/init'] = function() {
return {};
};
objReducer['@@transducer/result'] = function(v) {
return v;
};
objReducer['@@transducer/step'] = merge;
// building new collections
function toArray(coll, xform) {
if(!xform) {
return reduce(coll, arrayReducer, []);
}
return transduce(coll, xform, arrayReducer, []);
}
function toObj(coll, xform) {
if(!xform) {
return reduce(coll, objReducer, {});
}
return transduce(coll, xform, objReducer, {});
}
function toIter(coll, xform) {
if(!xform) {
return iterator(coll);
}
return new LazyTransformer(xform, coll);
}
function seq(coll, xform) {
if(isArray(coll)) {
return transduce(coll, xform, arrayReducer, []);
}
else if(isObject(coll)) {
return transduce(coll, xform, objReducer, {});
}
else if(coll['@@transducer/step']) {
var init;
if(coll['@@transducer/init']) {
init = coll['@@transducer/init']();
}
else {
init = new coll.constructor();
}
return transduce(coll, xform, coll, init);
}
else if(fulfillsProtocol(coll, 'iterator')) {
return new LazyTransformer(xform, coll);
}
throwProtocolError('sequence', coll);
}
function into(to, xform, from) {
if(isArray(to)) {
return transduce(from, xform, arrayReducer, to);
}
else if(isObject(to)) {
return transduce(from, xform, objReducer, to);
}
else if(to['@@transducer/step']) {
return transduce(from,
xform,
to,
to);
}
throwProtocolError('into', to);
}
// laziness
var stepper = {};
stepper['@@transducer/result'] = function(v) {
return isReduced(v) ? deref(v) : v;
};
stepper['@@transducer/step'] = function(lt, x) {
lt.items.push(x);
return lt.rest;
};
function Stepper(xform, iter) {
this.xform = xform(stepper);
this.iter = iter;
}
Stepper.prototype['@@transducer/step'] = function(lt) {
var len = lt.items.length;
while(lt.items.length === len) {
var n = this.iter.next();
if(n.done || isReduced(n.value)) {
// finalize
this.xform['@@transducer/result'](this);
break;
}
// step
this.xform['@@transducer/step'](lt, n.value);
}
}
function LazyTransformer(xform, coll) {
this.iter = iterator(coll);
this.items = [];
this.stepper = new Stepper(xform, iterator(coll));
}
LazyTransformer.prototype[protocols.iterator] = function() {
return this;
}
LazyTransformer.prototype.next = function() {
this['@@transducer/step']();
if(this.items.length) {
return {
value: this.items.pop(),
done: false
}
}
else {
return { done: true };
}
};
LazyTransformer.prototype['@@transducer/step'] = function() {
if(!this.items.length) {
this.stepper['@@transducer/step'](this);
}
}
// util
function range(n) {
var arr = new Array(n);
for(var i=0; i<arr.length; i++) {
arr[i] = i;
}
return arr;
}
module.exports = {
reduce: reduce,
transformer: transformer,
Reduced: Reduced,
isReduced: isReduced,
iterator: iterator,
push: push,
merge: merge,
transduce: transduce,
seq: seq,
toArray: toArray,
toObj: toObj,
toIter: toIter,
into: into,
compose: compose,
map: map,
filter: filter,
remove: remove,
cat: cat,
mapcat: mapcat,
keep: keep,
dedupe: dedupe,
take: take,
takeWhile: takeWhile,
takeNth: takeNth,
drop: drop,
dropWhile: dropWhile,
partition: partition,
partitionBy: partitionBy,
interpose: interpose,
repeat: repeat,
range: range,
dedupe: dedupe,
take: take,
takeWhile: takeWhile,
drop: drop,
dropWhile: dropWhile,
partition: partition,
partitionBy: partitionBy,
range: range,
protocols: protocols,
<MSG> add interpose, repeat, takeNth
<DFF> @@ -598,6 +598,125 @@ function partitionBy(coll, f, ctx) {
};
}
+function Interpose(sep, xform) {
+ this.sep = sep;
+ this.xform = xform;
+ this.started = false;
+}
+
+Interpose.prototype.init = function() {
+ return this.xform.init();
+};
+
+Interpose.prototype.result = function(v) {
+ return this.xform.result(v);
+};
+
+Interpose.prototype.step = function(result, input) {
+ if (this.started) {
+ var withSep = this.xform.step(result, this.sep);
+ if (isReduced(withSep)) {
+ return withSep;
+ } else {
+ return this.xform.step(withSep, input);
+ }
+ } else {
+ this.started = true;
+ return this.xform.step(result, input);
+ }
+};
+
+/**
+ * Returns a new collection containing elements of the given
+ * collection, separated by the specified separator. Returns a
+ * transducer if a collection is not provided.
+ */
+function interpose(coll, separator) {
+ if (arguments.length === 1) {
+ separator = coll;
+ return function(xform) {
+ return new Interpose(separator, xform);
+ };
+ }
+ return seq(coll, interpose(separator));
+}
+
+function Repeat(n, xform) {
+ this.xform = xform;
+ this.n = n;
+}
+
+Repeat.prototype.init = function() {
+ return this.xform.init();
+};
+
+Repeat.prototype.result = function(v) {
+ return this.xform.result(v);
+};
+
+Repeat.prototype.step = function(result, input) {
+ var n = this.n;
+ var r = result;
+ for (var i = 0; i < n; i++) {
+ r = this.xform.step(r, input);
+ if (isReduced(r)) {
+ break;
+ }
+ }
+ return r;
+};
+
+/**
+ * Returns a new collection containing elements of the given
+ * collection, each repeated n times. Returns a transducer if a
+ * collection is not provided.
+ */
+function repeat(coll, n) {
+ if (arguments.length === 1) {
+ n = coll;
+ return function(xform) {
+ return new Repeat(n, xform);
+ };
+ }
+ return seq(coll, repeat(n));
+}
+
+function TakeNth(n, xform) {
+ this.xform = xform;
+ this.n = n;
+ this.i = -1;
+}
+
+TakeNth.prototype.init = function() {
+ return this.xform.init();
+};
+
+TakeNth.prototype.result = function(v) {
+ return this.xform.result(v);
+};
+
+TakeNth.prototype.step = function(result, input) {
+ this.i += 1;
+ if (this.i % this.n === 0) {
+ return this.xform.step(result, input);
+ }
+ return result;
+};
+
+/**
+ * Returns a new collection of every nth element of the given
+ * collection. Returns a transducer if a collection is not provided.
+ */
+function takeNth(coll, nth) {
+ if (arguments.length === 1) {
+ nth = coll;
+ return function(xform) {
+ return new TakeNth(nth, xform);
+ };
+ }
+ return seq(coll, takeNth(nth));
+}
+
// pure transducers (cannot take collections)
function Cat(xform) {
@@ -845,10 +964,13 @@ module.exports = {
dedupe: dedupe,
take: take,
takeWhile: takeWhile,
+ takeNth: takeNth,
drop: drop,
dropWhile: dropWhile,
partition: partition,
partitionBy: partitionBy,
+ interpose: interpose,
+ repeat: repeat,
range: range,
protocols: protocols,
| 122 | add interpose, repeat, takeNth | 0 | .js | js | bsd-2-clause | jlongster/transducers.js |
10071612 | <NME> jquery.meow.blackcat.css
<BEF> ADDFILE
<MSG> Merge pull request #13 from shpoonj/master
Merge Flip's theme
<DFF> @@ -0,0 +1,120 @@
+/* blackcat theme by Flip Stewart | github.com/shpoonj */
+
+.meows {
+ position: fixed;
+ top: 0;
+ right: 0;
+}
+
+.meow {
+ position: relative;
+ margin: 12px 12px 0 0;
+}
+
+.meow .inner {
+ display: block;
+ width: 280px;
+ min-height: 48px;
+ padding: 9px;
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
+ font-size: 13px;
+ line-height: 24px;
+ color: #ffffff;
+ text-shadow: 0 1px 0 #000000;
+ background: rgba(20, 20, 20, 0.8);
+ border: 2px solid rgba(255, 255, 255, 0.8);
+ -webkit-border-radius: 6px;
+ -khtml-border-radius: 6px;
+ -moz-border-radius: 6px;
+ -ms-border-radius: 6px;
+ -o-border-radius: 6px;
+ border-radius: 6px;
+ zoom: 1;
+ -webkit-box-shadow: 0 0 6px rgba(0, 0, 0, 0.25);
+ -khtml-box-shadow: 0 0 6px rgba(0, 0, 0, 0.25);
+ -moz-box-shadow: 0 0 6px rgba(0, 0, 0, 0.25);
+ -ms-box-shadow: 0 0 6px rgba(0, 0, 0, 0.25);
+ -o-box-shadow: 0 0 6px rgba(0, 0, 0, 0.25);
+ box-shadow: 0 0 6px rgba(0, 0, 0, 0.25);
+}
+
+.meow .inner:hover {
+ background: rgba(20, 20, 20, 0.9);
+ border: 2px solid rgba(255, 255, 255, 0.9);
+}
+
+.meow .inner:hover .close {
+ position: absolute;
+ top: -6px;
+ right: -6px;
+ display: block;
+ width: 18px;
+ height: 18px;
+ font-size: 15px;
+ font-weight: bold;
+ line-height: 14px;
+ color: #fff;
+ text-align: center;
+ text-decoration: none;
+ text-shadow: 0 1px 0 #000000;
+ background: rgba(25, 25, 25, 0.8);
+ border: 2px solid rgba(255, 255, 255, 0.8);
+ -webkit-border-radius: 100%;
+ -khtml-border-radius: 100%;
+ -moz-border-radius: 100%;
+ -ms-border-radius: 100%;
+ -o-border-radius: 100%;
+ border-radius: 100%;
+ -webkit-opacity: 0.8;
+ -khtml-opacity: 0.8;
+ -moz-opacity: 0.8;
+ -ms-opacity: 0.8;
+ -o-opacity: 0.8;
+ opacity: 0.8;
+ zoom: 1;
+ -webkit-box-shadow: 0 0 6px rgba(0, 0, 0, 0.25);
+ -khtml-box-shadow: 0 0 6px rgba(0, 0, 0, 0.25);
+ -moz-box-shadow: 0 0 6px rgba(0, 0, 0, 0.25);
+ -ms-box-shadow: 0 0 6px rgba(0, 0, 0, 0.25);
+ -o-box-shadow: 0 0 6px rgba(0, 0, 0, 0.25);
+ box-shadow: 0 0 6px rgba(0, 0, 0, 0.25);
+}
+
+.meow .inner:hover .close:hover {
+ background: rgba(25, 25, 25, 0.9);
+ border: 2px solid rgba(255, 255, 255, 0.9);
+}
+
+.meow .inner .icon {
+ float: left;
+ height: 48px;
+ min-width: 48px;
+ margin-right: 9px;
+}
+
+.meow .inner .icon img {
+ width: 48px;
+ height: 48px;
+}
+
+.meow .inner h1 {
+ margin: 0;
+ font-size: 13px;
+ font-weight: bold;
+ line-height: 24px;
+ color: #ffffff;
+ text-shadow: 0 1px 0 #000000;
+}
+
+.meow .inner .close {
+ display: none;
+}
+
+.meow .inner:after {
+ display: block;
+ height: 0;
+ clear: both;
+ line-height: 0;
+ content: "\0200";
+ visibility: hidden;
+}
| 120 | Merge pull request #13 from shpoonj/master | 0 | .css | meow | mit | zacstewart/Meow |
10071613 | <NME> jquery.meow.blackcat.css
<BEF> ADDFILE
<MSG> Merge pull request #13 from shpoonj/master
Merge Flip's theme
<DFF> @@ -0,0 +1,120 @@
+/* blackcat theme by Flip Stewart | github.com/shpoonj */
+
+.meows {
+ position: fixed;
+ top: 0;
+ right: 0;
+}
+
+.meow {
+ position: relative;
+ margin: 12px 12px 0 0;
+}
+
+.meow .inner {
+ display: block;
+ width: 280px;
+ min-height: 48px;
+ padding: 9px;
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
+ font-size: 13px;
+ line-height: 24px;
+ color: #ffffff;
+ text-shadow: 0 1px 0 #000000;
+ background: rgba(20, 20, 20, 0.8);
+ border: 2px solid rgba(255, 255, 255, 0.8);
+ -webkit-border-radius: 6px;
+ -khtml-border-radius: 6px;
+ -moz-border-radius: 6px;
+ -ms-border-radius: 6px;
+ -o-border-radius: 6px;
+ border-radius: 6px;
+ zoom: 1;
+ -webkit-box-shadow: 0 0 6px rgba(0, 0, 0, 0.25);
+ -khtml-box-shadow: 0 0 6px rgba(0, 0, 0, 0.25);
+ -moz-box-shadow: 0 0 6px rgba(0, 0, 0, 0.25);
+ -ms-box-shadow: 0 0 6px rgba(0, 0, 0, 0.25);
+ -o-box-shadow: 0 0 6px rgba(0, 0, 0, 0.25);
+ box-shadow: 0 0 6px rgba(0, 0, 0, 0.25);
+}
+
+.meow .inner:hover {
+ background: rgba(20, 20, 20, 0.9);
+ border: 2px solid rgba(255, 255, 255, 0.9);
+}
+
+.meow .inner:hover .close {
+ position: absolute;
+ top: -6px;
+ right: -6px;
+ display: block;
+ width: 18px;
+ height: 18px;
+ font-size: 15px;
+ font-weight: bold;
+ line-height: 14px;
+ color: #fff;
+ text-align: center;
+ text-decoration: none;
+ text-shadow: 0 1px 0 #000000;
+ background: rgba(25, 25, 25, 0.8);
+ border: 2px solid rgba(255, 255, 255, 0.8);
+ -webkit-border-radius: 100%;
+ -khtml-border-radius: 100%;
+ -moz-border-radius: 100%;
+ -ms-border-radius: 100%;
+ -o-border-radius: 100%;
+ border-radius: 100%;
+ -webkit-opacity: 0.8;
+ -khtml-opacity: 0.8;
+ -moz-opacity: 0.8;
+ -ms-opacity: 0.8;
+ -o-opacity: 0.8;
+ opacity: 0.8;
+ zoom: 1;
+ -webkit-box-shadow: 0 0 6px rgba(0, 0, 0, 0.25);
+ -khtml-box-shadow: 0 0 6px rgba(0, 0, 0, 0.25);
+ -moz-box-shadow: 0 0 6px rgba(0, 0, 0, 0.25);
+ -ms-box-shadow: 0 0 6px rgba(0, 0, 0, 0.25);
+ -o-box-shadow: 0 0 6px rgba(0, 0, 0, 0.25);
+ box-shadow: 0 0 6px rgba(0, 0, 0, 0.25);
+}
+
+.meow .inner:hover .close:hover {
+ background: rgba(25, 25, 25, 0.9);
+ border: 2px solid rgba(255, 255, 255, 0.9);
+}
+
+.meow .inner .icon {
+ float: left;
+ height: 48px;
+ min-width: 48px;
+ margin-right: 9px;
+}
+
+.meow .inner .icon img {
+ width: 48px;
+ height: 48px;
+}
+
+.meow .inner h1 {
+ margin: 0;
+ font-size: 13px;
+ font-weight: bold;
+ line-height: 24px;
+ color: #ffffff;
+ text-shadow: 0 1px 0 #000000;
+}
+
+.meow .inner .close {
+ display: none;
+}
+
+.meow .inner:after {
+ display: block;
+ height: 0;
+ clear: both;
+ line-height: 0;
+ content: "\0200";
+ visibility: hidden;
+}
| 120 | Merge pull request #13 from shpoonj/master | 0 | .css | meow | mit | zacstewart/Meow |
10071614 | <NME> dashboard_helpers_spec.rb
<BEF> # frozen_string_literal: true
require "spec_helper"
require "split/dashboard/helpers"
describe Split::DashboardHelpers do
describe 'confidence_level' do
it 'should handle very small numbers' do
confidence_level(Complex(2e-18, -0.03)).should eql('No Change')
end
it "should consider a z-score of 1.645 < z < 1.96 as 95% confident" do
confidence_level(1.80).should eql('95% confidence')
end
end
end
it "should consider a z-score of 1.96 <= z < 2.58 as 95% confident" do
expect(confidence_level(1.96)).to eq("95% confidence")
expect(confidence_level(2.00)).to eq("95% confidence")
end
it "should consider a z-score of z >= 2.58 as 99% confident" do
expect(confidence_level(2.58)).to eq("99% confidence")
expect(confidence_level(3.00)).to eq("99% confidence")
end
describe "#round" do
it "can round number strings" do
expect(round("3.1415")).to eq BigDecimal("3.14")
end
it "can round number strings for precsion" do
expect(round("3.1415", 1)).to eq BigDecimal("3.1")
end
it "can handle invalid number strings" do
expect(round("N/A")).to be_zero
end
end
end
end
<MSG> Rewrote z_score algorithm.
<DFF> @@ -6,11 +6,11 @@ include Split::DashboardHelpers
describe Split::DashboardHelpers do
describe 'confidence_level' do
it 'should handle very small numbers' do
- confidence_level(Complex(2e-18, -0.03)).should eql('No Change')
+ confidence_level(Complex(2e-18, -0.03)).should eql('Insufficient confidence')
end
- it "should consider a z-score of 1.645 < z < 1.96 as 95% confident" do
- confidence_level(1.80).should eql('95% confidence')
+ it "should consider a z-score of 1.645 < z < 1.96 as 90% confident" do
+ confidence_level(1.80).should eql('90% confidence')
end
end
| 3 | Rewrote z_score algorithm. | 3 | .rb | rb | mit | splitrb/split |
10071615 | <NME> dashboard_helpers_spec.rb
<BEF> # frozen_string_literal: true
require "spec_helper"
require "split/dashboard/helpers"
describe Split::DashboardHelpers do
describe 'confidence_level' do
it 'should handle very small numbers' do
confidence_level(Complex(2e-18, -0.03)).should eql('No Change')
end
it "should consider a z-score of 1.645 < z < 1.96 as 95% confident" do
confidence_level(1.80).should eql('95% confidence')
end
end
end
it "should consider a z-score of 1.96 <= z < 2.58 as 95% confident" do
expect(confidence_level(1.96)).to eq("95% confidence")
expect(confidence_level(2.00)).to eq("95% confidence")
end
it "should consider a z-score of z >= 2.58 as 99% confident" do
expect(confidence_level(2.58)).to eq("99% confidence")
expect(confidence_level(3.00)).to eq("99% confidence")
end
describe "#round" do
it "can round number strings" do
expect(round("3.1415")).to eq BigDecimal("3.14")
end
it "can round number strings for precsion" do
expect(round("3.1415", 1)).to eq BigDecimal("3.1")
end
it "can handle invalid number strings" do
expect(round("N/A")).to be_zero
end
end
end
end
<MSG> Rewrote z_score algorithm.
<DFF> @@ -6,11 +6,11 @@ include Split::DashboardHelpers
describe Split::DashboardHelpers do
describe 'confidence_level' do
it 'should handle very small numbers' do
- confidence_level(Complex(2e-18, -0.03)).should eql('No Change')
+ confidence_level(Complex(2e-18, -0.03)).should eql('Insufficient confidence')
end
- it "should consider a z-score of 1.645 < z < 1.96 as 95% confident" do
- confidence_level(1.80).should eql('95% confidence')
+ it "should consider a z-score of 1.645 < z < 1.96 as 90% confident" do
+ confidence_level(1.80).should eql('90% confidence')
end
end
| 3 | Rewrote z_score algorithm. | 3 | .rb | rb | mit | splitrb/split |
10071616 | <NME> dashboard_helpers_spec.rb
<BEF> # frozen_string_literal: true
require "spec_helper"
require "split/dashboard/helpers"
describe Split::DashboardHelpers do
describe 'confidence_level' do
it 'should handle very small numbers' do
confidence_level(Complex(2e-18, -0.03)).should eql('No Change')
end
it "should consider a z-score of 1.645 < z < 1.96 as 95% confident" do
confidence_level(1.80).should eql('95% confidence')
end
end
end
it "should consider a z-score of 1.96 <= z < 2.58 as 95% confident" do
expect(confidence_level(1.96)).to eq("95% confidence")
expect(confidence_level(2.00)).to eq("95% confidence")
end
it "should consider a z-score of z >= 2.58 as 99% confident" do
expect(confidence_level(2.58)).to eq("99% confidence")
expect(confidence_level(3.00)).to eq("99% confidence")
end
describe "#round" do
it "can round number strings" do
expect(round("3.1415")).to eq BigDecimal("3.14")
end
it "can round number strings for precsion" do
expect(round("3.1415", 1)).to eq BigDecimal("3.1")
end
it "can handle invalid number strings" do
expect(round("N/A")).to be_zero
end
end
end
end
<MSG> Rewrote z_score algorithm.
<DFF> @@ -6,11 +6,11 @@ include Split::DashboardHelpers
describe Split::DashboardHelpers do
describe 'confidence_level' do
it 'should handle very small numbers' do
- confidence_level(Complex(2e-18, -0.03)).should eql('No Change')
+ confidence_level(Complex(2e-18, -0.03)).should eql('Insufficient confidence')
end
- it "should consider a z-score of 1.645 < z < 1.96 as 95% confident" do
- confidence_level(1.80).should eql('95% confidence')
+ it "should consider a z-score of 1.645 < z < 1.96 as 90% confident" do
+ confidence_level(1.80).should eql('90% confidence')
end
end
| 3 | Rewrote z_score algorithm. | 3 | .rb | rb | mit | splitrb/split |
10071617 | <NME> experiment_spec.rb
<BEF> # frozen_string_literal: true
require "spec_helper"
require "time"
describe Split::Experiment do
def new_experiment(goals = [])
Split::Experiment.new("link_color", alternatives: ["blue", "red", "green"], goals: goals)
end
def alternative(color)
Split::Alternative.new(color, "link_color")
end
let(:experiment) { new_experiment }
let(:blue) { alternative("blue") }
let(:green) { alternative("green") }
context "with an experiment" do
let(:experiment) { Split::Experiment.new("basket_text", alternatives: ["Basket", "Cart"]) }
it "should have a name" do
expect(experiment.name).to eq("basket_text")
end
it "should have alternatives" do
expect(experiment.alternatives.length).to be 2
end
it "should have alternatives with correct names" do
expect(experiment.alternatives.collect { |a| a.name }).to eq(["Basket", "Cart"])
end
it "should be resettable by default" do
expect(experiment.resettable).to be_truthy
end
it "should save to redis" do
experiment.save
expect(Split.redis.exists?("basket_text")).to be true
end
it "should save the start time to redis" do
experiment_start_time = Time.at(1372167761)
expect(Time).to receive(:now).and_return(experiment_start_time)
experiment.save
expect(Split::ExperimentCatalog.find("basket_text").start_time).to eq(experiment_start_time)
end
it "should not save the start time to redis when start_manually is enabled" do
expect(Split.configuration).to receive(:start_manually).and_return(true)
experiment.save
expect(Split::ExperimentCatalog.find("basket_text").start_time).to be_nil
end
it "should save the selected algorithm to redis" do
experiment_algorithm = Split::Algorithms::Whiplash
experiment.algorithm = experiment_algorithm
experiment.save
expect(Split::ExperimentCatalog.find("basket_text").algorithm).to eq(experiment_algorithm)
end
it "should handle having a start time stored as a string" do
experiment_start_time = Time.parse("Sat Mar 03 14:01:03")
expect(Time).to receive(:now).twice.and_return(experiment_start_time)
experiment.save
Split.redis.hset(:experiment_start_times, experiment.name, experiment_start_time.to_s)
expect(Split::ExperimentCatalog.find("basket_text").start_time).to eq(experiment_start_time)
end
it "should handle not having a start time" do
experiment_start_time = Time.parse("Sat Mar 03 14:01:03")
expect(Time).to receive(:now).and_return(experiment_start_time)
experiment.save
Split.redis.hdel(:experiment_start_times, experiment.name)
expect(Split::ExperimentCatalog.find("basket_text").start_time).to be_nil
end
it "should not create duplicates when saving multiple times" do
experiment.save
experiment.save
expect(Split.redis.exists?("basket_text")).to be true
expect(Split.redis.lrange("basket_text", 0, -1)).to eq(['{"Basket":1}', '{"Cart":1}'])
end
describe "new record?" do
it "should know if it hasn't been saved yet" do
expect(experiment.new_record?).to be_truthy
end
it "should know if it has been saved yet" do
experiment.save
expect(experiment.new_record?).to be_falsey
end
end
describe "control" do
it "should be the first alternative" do
experiment.save
expect(experiment.control.name).to eq("Basket")
end
end
end
describe "initialization" do
it "should set the algorithm when passed as an option to the initializer" do
experiment = Split::Experiment.new("basket_text", alternatives: ["Basket", "Cart"], algorithm: Split::Algorithms::Whiplash)
expect(experiment.algorithm).to eq(Split::Algorithms::Whiplash)
end
it "should be possible to make an experiment not resettable" do
experiment = Split::Experiment.new("basket_text", alternatives: ["Basket", "Cart"], resettable: false)
expect(experiment.resettable).to be_falsey
end
context "from configuration" do
let(:experiment_name) { :my_experiment }
let(:experiments) do
{
experiment_name => {
alternatives: ["Control Opt", "Alt one"]
}
}
end
before { Split.configuration.experiments = experiments }
it "assigns default values to the experiment" do
expect(Split::Experiment.new(experiment_name).resettable).to eq(true)
end
end
e.should == experiment
e.algorithm.should == Split::Algorithms::Whiplash
end
end
describe 'deleting' do
before do
experiment.save
end
it "should delete the key when metadata is removed" do
experiment.metadata = nil
experiment.save
expect(Split.redis.exists?(experiment.metadata_key)).to be_falsey
end
context "simple hash" do
let(:meta) { { "basket" => "a", "cart" => "b" } }
it "should persist metadata in redis" do
e = Split::ExperimentCatalog.find("basket_text")
expect(e).to eq(experiment)
expect(e.metadata).to eq(meta)
end
end
context "nested hash" do
let(:meta) { { "basket" => { "one" => "two" }, "cart" => "b" } }
it "should persist metadata in redis" do
e = Split::ExperimentCatalog.find("basket_text")
expect(e).to eq(experiment)
expect(e.metadata).to eq(meta)
end
end
end
it "should persist algorithm in redis" do
experiment = Split::Experiment.new("basket_text", alternatives: ["Basket", "Cart"], algorithm: Split::Algorithms::Whiplash)
experiment.save
e = Split::ExperimentCatalog.find("basket_text")
expect(e).to eq(experiment)
expect(e.algorithm).to eq(Split::Algorithms::Whiplash)
end
it "should persist a new experiment in redis, that does not exist in the configuration file" do
experiment = Split::Experiment.new("foobar", alternatives: ["tra", "la"], algorithm: Split::Algorithms::Whiplash)
experiment.save
e = Split::ExperimentCatalog.find("foobar")
expect(e).to eq(experiment)
expect(e.alternatives.collect { |a| a.name }).to eq(["tra", "la"])
end
end
describe "deleting" do
it "should delete itself" do
experiment = Split::Experiment.new("basket_text", alternatives: [ "Basket", "Cart"])
experiment.save
experiment.delete
expect(Split.redis.exists?("link_color")).to be false
expect(Split::ExperimentCatalog.find("link_color")).to be_nil
end
it "should increment the version" do
expect(experiment.version).to eq(0)
experiment.delete
expect(experiment.version).to eq(1)
end
it "should call the on_experiment_delete hook" do
expect(Split.configuration.on_experiment_delete).to receive(:call)
experiment.delete
end
it "should call the on_before_experiment_delete hook" do
expect(Split.configuration.on_before_experiment_delete).to receive(:call)
experiment.delete
end
it "should reset the start time if the experiment should be manually started" do
Split.configuration.start_manually = true
experiment.start
experiment.delete
expect(experiment.start_time).to be_nil
end
it "should default cohorting back to false" do
experiment.disable_cohorting
expect(experiment.cohorting_disabled?).to eq(true)
experiment.delete
expect(experiment.cohorting_disabled?).to eq(false)
end
end
describe "winner" do
it "should have no winner initially" do
expect(experiment.winner).to be_nil
end
end
describe "winner=" do
it "should allow you to specify a winner" do
experiment.save
experiment.winner = "red"
expect(experiment.winner.name).to eq("red")
end
it "should call the on_experiment_winner_choose hook" do
expect(Split.configuration.on_experiment_winner_choose).to receive(:call)
experiment.winner = "green"
end
context "when has_winner state is memoized" do
before { expect(experiment).to_not have_winner }
it "should keep has_winner state consistent" do
experiment.winner = "red"
expect(experiment).to have_winner
end
end
end
describe "reset_winner" do
before { experiment.winner = "green" }
it "should reset the winner" do
experiment.reset_winner
expect(experiment.winner).to be_nil
end
context "when has_winner state is memoized" do
before { expect(experiment).to have_winner }
it "should keep has_winner state consistent" do
experiment.reset_winner
expect(experiment).to_not have_winner
end
end
end
describe "has_winner?" do
context "with winner" do
before { experiment.winner = "red" }
it "returns true" do
expect(experiment).to have_winner
end
end
context "without winner" do
it "returns false" do
expect(experiment).to_not have_winner
end
end
it "memoizes has_winner state" do
expect(experiment).to receive(:winner).once
expect(experiment).to_not have_winner
expect(experiment).to_not have_winner
end
end
describe "reset" do
let(:reset_manually) { false }
before do
allow(Split.configuration).to receive(:reset_manually).and_return(reset_manually)
experiment.save
green.increment_participation
green.increment_participation
end
it "should reset all alternatives" do
experiment.winner = "green"
expect(experiment.next_alternative.name).to eq("green")
green.increment_participation
experiment.reset
expect(green.participant_count).to eq(0)
expect(green.completed_count).to eq(0)
end
it "should reset the winner" do
experiment.winner = "green"
expect(experiment.next_alternative.name).to eq("green")
green.increment_participation
experiment.reset
expect(experiment.winner).to be_nil
end
it "should increment the version" do
expect(experiment.version).to eq(0)
experiment.reset
expect(experiment.version).to eq(1)
end
it "should call the on_experiment_reset hook" do
expect(Split.configuration.on_experiment_reset).to receive(:call)
experiment.reset
end
it "should call the on_before_experiment_reset hook" do
expect(Split.configuration.on_before_experiment_reset).to receive(:call)
experiment.reset
end
end
describe "algorithm" do
let(:experiment) { Split::ExperimentCatalog.find_or_create("link_color", "blue", "red", "green") }
it "should use the default algorithm if none is specified" do
expect(experiment.algorithm).to eq(Split.configuration.algorithm)
end
it "should use the user specified algorithm for this experiment if specified" do
experiment.algorithm = Split::Algorithms::Whiplash
expect(experiment.algorithm).to eq(Split::Algorithms::Whiplash)
end
end
describe "#next_alternative" do
context "with multiple alternatives" do
let(:experiment) { Split::ExperimentCatalog.find_or_create("link_color", "blue", "red", "green") }
context "with winner" do
it "should always return the winner" do
green = Split::Alternative.new("green", "link_color")
experiment.winner = "green"
expect(experiment.next_alternative.name).to eq("green")
green.increment_participation
expect(experiment.next_alternative.name).to eq("green")
end
end
context "without winner" do
it "should use the specified algorithm" do
experiment.algorithm = Split::Algorithms::Whiplash
expect(experiment.algorithm).to receive(:choose_alternative).and_return(Split::Alternative.new("green", "link_color"))
expect(experiment.next_alternative.name).to eq("green")
end
end
end
context "with single alternative" do
let(:experiment) { Split::ExperimentCatalog.find_or_create("link_color", "blue") }
it "should always return the only alternative" do
expect(experiment.next_alternative.name).to eq("blue")
expect(experiment.next_alternative.name).to eq("blue")
end
end
end
describe "#cohorting_disabled?" do
it "returns false when nothing has been configured" do
expect(experiment.cohorting_disabled?).to eq false
end
it "returns true when enable_cohorting is performed" do
experiment.enable_cohorting
expect(experiment.cohorting_disabled?).to eq false
end
it "returns false when nothing has been configured" do
experiment.disable_cohorting
expect(experiment.cohorting_disabled?).to eq true
end
end
describe "changing an existing experiment" do
def same_but_different_alternative
Split::ExperimentCatalog.find_or_create("link_color", "blue", "yellow", "orange")
end
it "should reset an experiment if it is loaded with different alternatives" do
experiment.save
blue.participant_count = 5
same_experiment = same_but_different_alternative
expect(same_experiment.alternatives.map(&:name)).to eq(["blue", "yellow", "orange"])
expect(blue.participant_count).to eq(0)
end
it "should only reset once" do
experiment.save
expect(experiment.version).to eq(0)
same_experiment = same_but_different_alternative
expect(same_experiment.version).to eq(1)
same_experiment_again = same_but_different_alternative
expect(same_experiment_again.version).to eq(1)
end
context "when metadata is changed" do
it "should increase version" do
experiment.save
experiment.metadata = { "foo" => "bar" }
expect { experiment.save }.to change { experiment.version }.by(1)
end
it "does not increase version" do
experiment.metadata = nil
experiment.save
expect { experiment.save }.to change { experiment.version }.by(0)
end
end
context "when experiment configuration is changed" do
let(:reset_manually) { false }
before do
experiment.save
allow(Split.configuration).to receive(:reset_manually).and_return(reset_manually)
green.increment_participation
green.increment_participation
experiment.set_alternatives_and_options(alternatives: %w(blue red green zip),
goals: %w(purchase))
experiment.save
end
it "resets all alternatives" do
expect(green.participant_count).to eq(0)
expect(green.completed_count).to eq(0)
end
context "when reset_manually is set" do
let(:reset_manually) { true }
it "does not reset alternatives" do
expect(green.participant_count).to eq(2)
expect(green.completed_count).to eq(0)
end
end
end
end
describe "alternatives passed as non-strings" do
it "should throw an exception if an alternative is passed that is not a string" do
expect { Split::ExperimentCatalog.find_or_create("link_color", :blue, :red) }.to raise_error(ArgumentError)
expect { Split::ExperimentCatalog.find_or_create("link_enabled", true, false) }.to raise_error(ArgumentError)
end
end
describe "specifying weights" do
let(:experiment_with_weight) {
Split::ExperimentCatalog.find_or_create("link_color", { "blue" => 1 }, { "red" => 2 })
}
it "should work for a new experiment" do
expect(experiment_with_weight.alternatives.map(&:weight)).to eq([1, 2])
end
it "should work for an existing experiment" do
experiment.save
expect(experiment_with_weight.alternatives.map(&:weight)).to eq([1, 2])
end
end
describe "specifying goals" do
let(:experiment) {
new_experiment(["purchase"])
}
context "saving experiment" do
let(:same_but_different_goals) { Split::ExperimentCatalog.find_or_create({ "link_color" => ["purchase", "refund"] }, "blue", "red", "green") }
before { experiment.save }
it "can find existing experiment" do
expect(Split::ExperimentCatalog.find("link_color").name).to eq("link_color")
end
it "should reset an experiment if it is loaded with different goals" do
same_but_different_goals
expect(Split::ExperimentCatalog.find("link_color").goals).to eq(["purchase", "refund"])
end
end
it "should have goals" do
expect(experiment.goals).to eq(["purchase"])
end
context "find or create experiment" do
it "should have correct goals" do
experiment = Split::ExperimentCatalog.find_or_create({ "link_color3" => ["purchase", "refund"] }, "blue", "red", "green")
expect(experiment.goals).to eq(["purchase", "refund"])
experiment = Split::ExperimentCatalog.find_or_create("link_color3", "blue", "red", "green")
expect(experiment.goals).to eq([])
end
end
end
describe "beta probability calculation" do
it "should return a hash with the probability of each alternative being the best" do
experiment = Split::ExperimentCatalog.find_or_create("mathematicians", "bernoulli", "poisson", "lagrange")
experiment.calc_winning_alternatives
expect(experiment.alternative_probabilities).not_to be_nil
end
it "should return between 46% and 54% probability for an experiment with 2 alternatives and no data" do
experiment = Split::ExperimentCatalog.find_or_create("scientists", "einstein", "bohr")
experiment.calc_winning_alternatives
expect(experiment.alternatives[0].p_winner).to be_within(0.04).of(0.50)
end
it "should calculate the probability of being the winning alternative separately for each goal", skip: true do
experiment = Split::ExperimentCatalog.find_or_create({ "link_color3" => ["purchase", "refund"] }, "blue", "red", "green")
goal1 = experiment.goals[0]
goal2 = experiment.goals[1]
experiment.alternatives.each do |alternative|
alternative.participant_count = 50
alternative.set_completed_count(10, goal1)
alternative.set_completed_count(15+rand(30), goal2)
end
experiment.calc_winning_alternatives
alt = experiment.alternatives[0]
p_goal1 = alt.p_winner(goal1)
p_goal2 = alt.p_winner(goal2)
expect(p_goal1).not_to be_within(0.04).of(p_goal2)
end
it "should return nil and not re-calculate probabilities if they have already been calculated today" do
experiment = Split::ExperimentCatalog.find_or_create({ "link_color3" => ["purchase", "refund"] }, "blue", "red", "green")
expect(experiment.calc_winning_alternatives).not_to be nil
expect(experiment.calc_winning_alternatives).to be nil
end
end
end
<MSG> yet another spec.
<DFF> @@ -139,6 +139,15 @@ describe Split::Experiment do
e.should == experiment
e.algorithm.should == Split::Algorithms::Whiplash
end
+
+ it "should persist a new experiment in redis, that does not exist in the configuration file" do
+ experiment = Split::Experiment.new('foobar', :alternatives => ['tra', 'la'], :algorithm => Split::Algorithms::Whiplash)
+ experiment.save
+
+ e = Split::Experiment.find('foobar')
+ e.should == experiment
+ e.alternatives.collect{|a| a.name}.should == ['tra', 'la']
+ end
end
describe 'deleting' do
| 9 | yet another spec. | 0 | .rb | rb | mit | splitrb/split |
10071618 | <NME> experiment_spec.rb
<BEF> # frozen_string_literal: true
require "spec_helper"
require "time"
describe Split::Experiment do
def new_experiment(goals = [])
Split::Experiment.new("link_color", alternatives: ["blue", "red", "green"], goals: goals)
end
def alternative(color)
Split::Alternative.new(color, "link_color")
end
let(:experiment) { new_experiment }
let(:blue) { alternative("blue") }
let(:green) { alternative("green") }
context "with an experiment" do
let(:experiment) { Split::Experiment.new("basket_text", alternatives: ["Basket", "Cart"]) }
it "should have a name" do
expect(experiment.name).to eq("basket_text")
end
it "should have alternatives" do
expect(experiment.alternatives.length).to be 2
end
it "should have alternatives with correct names" do
expect(experiment.alternatives.collect { |a| a.name }).to eq(["Basket", "Cart"])
end
it "should be resettable by default" do
expect(experiment.resettable).to be_truthy
end
it "should save to redis" do
experiment.save
expect(Split.redis.exists?("basket_text")).to be true
end
it "should save the start time to redis" do
experiment_start_time = Time.at(1372167761)
expect(Time).to receive(:now).and_return(experiment_start_time)
experiment.save
expect(Split::ExperimentCatalog.find("basket_text").start_time).to eq(experiment_start_time)
end
it "should not save the start time to redis when start_manually is enabled" do
expect(Split.configuration).to receive(:start_manually).and_return(true)
experiment.save
expect(Split::ExperimentCatalog.find("basket_text").start_time).to be_nil
end
it "should save the selected algorithm to redis" do
experiment_algorithm = Split::Algorithms::Whiplash
experiment.algorithm = experiment_algorithm
experiment.save
expect(Split::ExperimentCatalog.find("basket_text").algorithm).to eq(experiment_algorithm)
end
it "should handle having a start time stored as a string" do
experiment_start_time = Time.parse("Sat Mar 03 14:01:03")
expect(Time).to receive(:now).twice.and_return(experiment_start_time)
experiment.save
Split.redis.hset(:experiment_start_times, experiment.name, experiment_start_time.to_s)
expect(Split::ExperimentCatalog.find("basket_text").start_time).to eq(experiment_start_time)
end
it "should handle not having a start time" do
experiment_start_time = Time.parse("Sat Mar 03 14:01:03")
expect(Time).to receive(:now).and_return(experiment_start_time)
experiment.save
Split.redis.hdel(:experiment_start_times, experiment.name)
expect(Split::ExperimentCatalog.find("basket_text").start_time).to be_nil
end
it "should not create duplicates when saving multiple times" do
experiment.save
experiment.save
expect(Split.redis.exists?("basket_text")).to be true
expect(Split.redis.lrange("basket_text", 0, -1)).to eq(['{"Basket":1}', '{"Cart":1}'])
end
describe "new record?" do
it "should know if it hasn't been saved yet" do
expect(experiment.new_record?).to be_truthy
end
it "should know if it has been saved yet" do
experiment.save
expect(experiment.new_record?).to be_falsey
end
end
describe "control" do
it "should be the first alternative" do
experiment.save
expect(experiment.control.name).to eq("Basket")
end
end
end
describe "initialization" do
it "should set the algorithm when passed as an option to the initializer" do
experiment = Split::Experiment.new("basket_text", alternatives: ["Basket", "Cart"], algorithm: Split::Algorithms::Whiplash)
expect(experiment.algorithm).to eq(Split::Algorithms::Whiplash)
end
it "should be possible to make an experiment not resettable" do
experiment = Split::Experiment.new("basket_text", alternatives: ["Basket", "Cart"], resettable: false)
expect(experiment.resettable).to be_falsey
end
context "from configuration" do
let(:experiment_name) { :my_experiment }
let(:experiments) do
{
experiment_name => {
alternatives: ["Control Opt", "Alt one"]
}
}
end
before { Split.configuration.experiments = experiments }
it "assigns default values to the experiment" do
expect(Split::Experiment.new(experiment_name).resettable).to eq(true)
end
end
e.should == experiment
e.algorithm.should == Split::Algorithms::Whiplash
end
end
describe 'deleting' do
before do
experiment.save
end
it "should delete the key when metadata is removed" do
experiment.metadata = nil
experiment.save
expect(Split.redis.exists?(experiment.metadata_key)).to be_falsey
end
context "simple hash" do
let(:meta) { { "basket" => "a", "cart" => "b" } }
it "should persist metadata in redis" do
e = Split::ExperimentCatalog.find("basket_text")
expect(e).to eq(experiment)
expect(e.metadata).to eq(meta)
end
end
context "nested hash" do
let(:meta) { { "basket" => { "one" => "two" }, "cart" => "b" } }
it "should persist metadata in redis" do
e = Split::ExperimentCatalog.find("basket_text")
expect(e).to eq(experiment)
expect(e.metadata).to eq(meta)
end
end
end
it "should persist algorithm in redis" do
experiment = Split::Experiment.new("basket_text", alternatives: ["Basket", "Cart"], algorithm: Split::Algorithms::Whiplash)
experiment.save
e = Split::ExperimentCatalog.find("basket_text")
expect(e).to eq(experiment)
expect(e.algorithm).to eq(Split::Algorithms::Whiplash)
end
it "should persist a new experiment in redis, that does not exist in the configuration file" do
experiment = Split::Experiment.new("foobar", alternatives: ["tra", "la"], algorithm: Split::Algorithms::Whiplash)
experiment.save
e = Split::ExperimentCatalog.find("foobar")
expect(e).to eq(experiment)
expect(e.alternatives.collect { |a| a.name }).to eq(["tra", "la"])
end
end
describe "deleting" do
it "should delete itself" do
experiment = Split::Experiment.new("basket_text", alternatives: [ "Basket", "Cart"])
experiment.save
experiment.delete
expect(Split.redis.exists?("link_color")).to be false
expect(Split::ExperimentCatalog.find("link_color")).to be_nil
end
it "should increment the version" do
expect(experiment.version).to eq(0)
experiment.delete
expect(experiment.version).to eq(1)
end
it "should call the on_experiment_delete hook" do
expect(Split.configuration.on_experiment_delete).to receive(:call)
experiment.delete
end
it "should call the on_before_experiment_delete hook" do
expect(Split.configuration.on_before_experiment_delete).to receive(:call)
experiment.delete
end
it "should reset the start time if the experiment should be manually started" do
Split.configuration.start_manually = true
experiment.start
experiment.delete
expect(experiment.start_time).to be_nil
end
it "should default cohorting back to false" do
experiment.disable_cohorting
expect(experiment.cohorting_disabled?).to eq(true)
experiment.delete
expect(experiment.cohorting_disabled?).to eq(false)
end
end
describe "winner" do
it "should have no winner initially" do
expect(experiment.winner).to be_nil
end
end
describe "winner=" do
it "should allow you to specify a winner" do
experiment.save
experiment.winner = "red"
expect(experiment.winner.name).to eq("red")
end
it "should call the on_experiment_winner_choose hook" do
expect(Split.configuration.on_experiment_winner_choose).to receive(:call)
experiment.winner = "green"
end
context "when has_winner state is memoized" do
before { expect(experiment).to_not have_winner }
it "should keep has_winner state consistent" do
experiment.winner = "red"
expect(experiment).to have_winner
end
end
end
describe "reset_winner" do
before { experiment.winner = "green" }
it "should reset the winner" do
experiment.reset_winner
expect(experiment.winner).to be_nil
end
context "when has_winner state is memoized" do
before { expect(experiment).to have_winner }
it "should keep has_winner state consistent" do
experiment.reset_winner
expect(experiment).to_not have_winner
end
end
end
describe "has_winner?" do
context "with winner" do
before { experiment.winner = "red" }
it "returns true" do
expect(experiment).to have_winner
end
end
context "without winner" do
it "returns false" do
expect(experiment).to_not have_winner
end
end
it "memoizes has_winner state" do
expect(experiment).to receive(:winner).once
expect(experiment).to_not have_winner
expect(experiment).to_not have_winner
end
end
describe "reset" do
let(:reset_manually) { false }
before do
allow(Split.configuration).to receive(:reset_manually).and_return(reset_manually)
experiment.save
green.increment_participation
green.increment_participation
end
it "should reset all alternatives" do
experiment.winner = "green"
expect(experiment.next_alternative.name).to eq("green")
green.increment_participation
experiment.reset
expect(green.participant_count).to eq(0)
expect(green.completed_count).to eq(0)
end
it "should reset the winner" do
experiment.winner = "green"
expect(experiment.next_alternative.name).to eq("green")
green.increment_participation
experiment.reset
expect(experiment.winner).to be_nil
end
it "should increment the version" do
expect(experiment.version).to eq(0)
experiment.reset
expect(experiment.version).to eq(1)
end
it "should call the on_experiment_reset hook" do
expect(Split.configuration.on_experiment_reset).to receive(:call)
experiment.reset
end
it "should call the on_before_experiment_reset hook" do
expect(Split.configuration.on_before_experiment_reset).to receive(:call)
experiment.reset
end
end
describe "algorithm" do
let(:experiment) { Split::ExperimentCatalog.find_or_create("link_color", "blue", "red", "green") }
it "should use the default algorithm if none is specified" do
expect(experiment.algorithm).to eq(Split.configuration.algorithm)
end
it "should use the user specified algorithm for this experiment if specified" do
experiment.algorithm = Split::Algorithms::Whiplash
expect(experiment.algorithm).to eq(Split::Algorithms::Whiplash)
end
end
describe "#next_alternative" do
context "with multiple alternatives" do
let(:experiment) { Split::ExperimentCatalog.find_or_create("link_color", "blue", "red", "green") }
context "with winner" do
it "should always return the winner" do
green = Split::Alternative.new("green", "link_color")
experiment.winner = "green"
expect(experiment.next_alternative.name).to eq("green")
green.increment_participation
expect(experiment.next_alternative.name).to eq("green")
end
end
context "without winner" do
it "should use the specified algorithm" do
experiment.algorithm = Split::Algorithms::Whiplash
expect(experiment.algorithm).to receive(:choose_alternative).and_return(Split::Alternative.new("green", "link_color"))
expect(experiment.next_alternative.name).to eq("green")
end
end
end
context "with single alternative" do
let(:experiment) { Split::ExperimentCatalog.find_or_create("link_color", "blue") }
it "should always return the only alternative" do
expect(experiment.next_alternative.name).to eq("blue")
expect(experiment.next_alternative.name).to eq("blue")
end
end
end
describe "#cohorting_disabled?" do
it "returns false when nothing has been configured" do
expect(experiment.cohorting_disabled?).to eq false
end
it "returns true when enable_cohorting is performed" do
experiment.enable_cohorting
expect(experiment.cohorting_disabled?).to eq false
end
it "returns false when nothing has been configured" do
experiment.disable_cohorting
expect(experiment.cohorting_disabled?).to eq true
end
end
describe "changing an existing experiment" do
def same_but_different_alternative
Split::ExperimentCatalog.find_or_create("link_color", "blue", "yellow", "orange")
end
it "should reset an experiment if it is loaded with different alternatives" do
experiment.save
blue.participant_count = 5
same_experiment = same_but_different_alternative
expect(same_experiment.alternatives.map(&:name)).to eq(["blue", "yellow", "orange"])
expect(blue.participant_count).to eq(0)
end
it "should only reset once" do
experiment.save
expect(experiment.version).to eq(0)
same_experiment = same_but_different_alternative
expect(same_experiment.version).to eq(1)
same_experiment_again = same_but_different_alternative
expect(same_experiment_again.version).to eq(1)
end
context "when metadata is changed" do
it "should increase version" do
experiment.save
experiment.metadata = { "foo" => "bar" }
expect { experiment.save }.to change { experiment.version }.by(1)
end
it "does not increase version" do
experiment.metadata = nil
experiment.save
expect { experiment.save }.to change { experiment.version }.by(0)
end
end
context "when experiment configuration is changed" do
let(:reset_manually) { false }
before do
experiment.save
allow(Split.configuration).to receive(:reset_manually).and_return(reset_manually)
green.increment_participation
green.increment_participation
experiment.set_alternatives_and_options(alternatives: %w(blue red green zip),
goals: %w(purchase))
experiment.save
end
it "resets all alternatives" do
expect(green.participant_count).to eq(0)
expect(green.completed_count).to eq(0)
end
context "when reset_manually is set" do
let(:reset_manually) { true }
it "does not reset alternatives" do
expect(green.participant_count).to eq(2)
expect(green.completed_count).to eq(0)
end
end
end
end
describe "alternatives passed as non-strings" do
it "should throw an exception if an alternative is passed that is not a string" do
expect { Split::ExperimentCatalog.find_or_create("link_color", :blue, :red) }.to raise_error(ArgumentError)
expect { Split::ExperimentCatalog.find_or_create("link_enabled", true, false) }.to raise_error(ArgumentError)
end
end
describe "specifying weights" do
let(:experiment_with_weight) {
Split::ExperimentCatalog.find_or_create("link_color", { "blue" => 1 }, { "red" => 2 })
}
it "should work for a new experiment" do
expect(experiment_with_weight.alternatives.map(&:weight)).to eq([1, 2])
end
it "should work for an existing experiment" do
experiment.save
expect(experiment_with_weight.alternatives.map(&:weight)).to eq([1, 2])
end
end
describe "specifying goals" do
let(:experiment) {
new_experiment(["purchase"])
}
context "saving experiment" do
let(:same_but_different_goals) { Split::ExperimentCatalog.find_or_create({ "link_color" => ["purchase", "refund"] }, "blue", "red", "green") }
before { experiment.save }
it "can find existing experiment" do
expect(Split::ExperimentCatalog.find("link_color").name).to eq("link_color")
end
it "should reset an experiment if it is loaded with different goals" do
same_but_different_goals
expect(Split::ExperimentCatalog.find("link_color").goals).to eq(["purchase", "refund"])
end
end
it "should have goals" do
expect(experiment.goals).to eq(["purchase"])
end
context "find or create experiment" do
it "should have correct goals" do
experiment = Split::ExperimentCatalog.find_or_create({ "link_color3" => ["purchase", "refund"] }, "blue", "red", "green")
expect(experiment.goals).to eq(["purchase", "refund"])
experiment = Split::ExperimentCatalog.find_or_create("link_color3", "blue", "red", "green")
expect(experiment.goals).to eq([])
end
end
end
describe "beta probability calculation" do
it "should return a hash with the probability of each alternative being the best" do
experiment = Split::ExperimentCatalog.find_or_create("mathematicians", "bernoulli", "poisson", "lagrange")
experiment.calc_winning_alternatives
expect(experiment.alternative_probabilities).not_to be_nil
end
it "should return between 46% and 54% probability for an experiment with 2 alternatives and no data" do
experiment = Split::ExperimentCatalog.find_or_create("scientists", "einstein", "bohr")
experiment.calc_winning_alternatives
expect(experiment.alternatives[0].p_winner).to be_within(0.04).of(0.50)
end
it "should calculate the probability of being the winning alternative separately for each goal", skip: true do
experiment = Split::ExperimentCatalog.find_or_create({ "link_color3" => ["purchase", "refund"] }, "blue", "red", "green")
goal1 = experiment.goals[0]
goal2 = experiment.goals[1]
experiment.alternatives.each do |alternative|
alternative.participant_count = 50
alternative.set_completed_count(10, goal1)
alternative.set_completed_count(15+rand(30), goal2)
end
experiment.calc_winning_alternatives
alt = experiment.alternatives[0]
p_goal1 = alt.p_winner(goal1)
p_goal2 = alt.p_winner(goal2)
expect(p_goal1).not_to be_within(0.04).of(p_goal2)
end
it "should return nil and not re-calculate probabilities if they have already been calculated today" do
experiment = Split::ExperimentCatalog.find_or_create({ "link_color3" => ["purchase", "refund"] }, "blue", "red", "green")
expect(experiment.calc_winning_alternatives).not_to be nil
expect(experiment.calc_winning_alternatives).to be nil
end
end
end
<MSG> yet another spec.
<DFF> @@ -139,6 +139,15 @@ describe Split::Experiment do
e.should == experiment
e.algorithm.should == Split::Algorithms::Whiplash
end
+
+ it "should persist a new experiment in redis, that does not exist in the configuration file" do
+ experiment = Split::Experiment.new('foobar', :alternatives => ['tra', 'la'], :algorithm => Split::Algorithms::Whiplash)
+ experiment.save
+
+ e = Split::Experiment.find('foobar')
+ e.should == experiment
+ e.alternatives.collect{|a| a.name}.should == ['tra', 'la']
+ end
end
describe 'deleting' do
| 9 | yet another spec. | 0 | .rb | rb | mit | splitrb/split |
10071619 | <NME> experiment_spec.rb
<BEF> # frozen_string_literal: true
require "spec_helper"
require "time"
describe Split::Experiment do
def new_experiment(goals = [])
Split::Experiment.new("link_color", alternatives: ["blue", "red", "green"], goals: goals)
end
def alternative(color)
Split::Alternative.new(color, "link_color")
end
let(:experiment) { new_experiment }
let(:blue) { alternative("blue") }
let(:green) { alternative("green") }
context "with an experiment" do
let(:experiment) { Split::Experiment.new("basket_text", alternatives: ["Basket", "Cart"]) }
it "should have a name" do
expect(experiment.name).to eq("basket_text")
end
it "should have alternatives" do
expect(experiment.alternatives.length).to be 2
end
it "should have alternatives with correct names" do
expect(experiment.alternatives.collect { |a| a.name }).to eq(["Basket", "Cart"])
end
it "should be resettable by default" do
expect(experiment.resettable).to be_truthy
end
it "should save to redis" do
experiment.save
expect(Split.redis.exists?("basket_text")).to be true
end
it "should save the start time to redis" do
experiment_start_time = Time.at(1372167761)
expect(Time).to receive(:now).and_return(experiment_start_time)
experiment.save
expect(Split::ExperimentCatalog.find("basket_text").start_time).to eq(experiment_start_time)
end
it "should not save the start time to redis when start_manually is enabled" do
expect(Split.configuration).to receive(:start_manually).and_return(true)
experiment.save
expect(Split::ExperimentCatalog.find("basket_text").start_time).to be_nil
end
it "should save the selected algorithm to redis" do
experiment_algorithm = Split::Algorithms::Whiplash
experiment.algorithm = experiment_algorithm
experiment.save
expect(Split::ExperimentCatalog.find("basket_text").algorithm).to eq(experiment_algorithm)
end
it "should handle having a start time stored as a string" do
experiment_start_time = Time.parse("Sat Mar 03 14:01:03")
expect(Time).to receive(:now).twice.and_return(experiment_start_time)
experiment.save
Split.redis.hset(:experiment_start_times, experiment.name, experiment_start_time.to_s)
expect(Split::ExperimentCatalog.find("basket_text").start_time).to eq(experiment_start_time)
end
it "should handle not having a start time" do
experiment_start_time = Time.parse("Sat Mar 03 14:01:03")
expect(Time).to receive(:now).and_return(experiment_start_time)
experiment.save
Split.redis.hdel(:experiment_start_times, experiment.name)
expect(Split::ExperimentCatalog.find("basket_text").start_time).to be_nil
end
it "should not create duplicates when saving multiple times" do
experiment.save
experiment.save
expect(Split.redis.exists?("basket_text")).to be true
expect(Split.redis.lrange("basket_text", 0, -1)).to eq(['{"Basket":1}', '{"Cart":1}'])
end
describe "new record?" do
it "should know if it hasn't been saved yet" do
expect(experiment.new_record?).to be_truthy
end
it "should know if it has been saved yet" do
experiment.save
expect(experiment.new_record?).to be_falsey
end
end
describe "control" do
it "should be the first alternative" do
experiment.save
expect(experiment.control.name).to eq("Basket")
end
end
end
describe "initialization" do
it "should set the algorithm when passed as an option to the initializer" do
experiment = Split::Experiment.new("basket_text", alternatives: ["Basket", "Cart"], algorithm: Split::Algorithms::Whiplash)
expect(experiment.algorithm).to eq(Split::Algorithms::Whiplash)
end
it "should be possible to make an experiment not resettable" do
experiment = Split::Experiment.new("basket_text", alternatives: ["Basket", "Cart"], resettable: false)
expect(experiment.resettable).to be_falsey
end
context "from configuration" do
let(:experiment_name) { :my_experiment }
let(:experiments) do
{
experiment_name => {
alternatives: ["Control Opt", "Alt one"]
}
}
end
before { Split.configuration.experiments = experiments }
it "assigns default values to the experiment" do
expect(Split::Experiment.new(experiment_name).resettable).to eq(true)
end
end
e.should == experiment
e.algorithm.should == Split::Algorithms::Whiplash
end
end
describe 'deleting' do
before do
experiment.save
end
it "should delete the key when metadata is removed" do
experiment.metadata = nil
experiment.save
expect(Split.redis.exists?(experiment.metadata_key)).to be_falsey
end
context "simple hash" do
let(:meta) { { "basket" => "a", "cart" => "b" } }
it "should persist metadata in redis" do
e = Split::ExperimentCatalog.find("basket_text")
expect(e).to eq(experiment)
expect(e.metadata).to eq(meta)
end
end
context "nested hash" do
let(:meta) { { "basket" => { "one" => "two" }, "cart" => "b" } }
it "should persist metadata in redis" do
e = Split::ExperimentCatalog.find("basket_text")
expect(e).to eq(experiment)
expect(e.metadata).to eq(meta)
end
end
end
it "should persist algorithm in redis" do
experiment = Split::Experiment.new("basket_text", alternatives: ["Basket", "Cart"], algorithm: Split::Algorithms::Whiplash)
experiment.save
e = Split::ExperimentCatalog.find("basket_text")
expect(e).to eq(experiment)
expect(e.algorithm).to eq(Split::Algorithms::Whiplash)
end
it "should persist a new experiment in redis, that does not exist in the configuration file" do
experiment = Split::Experiment.new("foobar", alternatives: ["tra", "la"], algorithm: Split::Algorithms::Whiplash)
experiment.save
e = Split::ExperimentCatalog.find("foobar")
expect(e).to eq(experiment)
expect(e.alternatives.collect { |a| a.name }).to eq(["tra", "la"])
end
end
describe "deleting" do
it "should delete itself" do
experiment = Split::Experiment.new("basket_text", alternatives: [ "Basket", "Cart"])
experiment.save
experiment.delete
expect(Split.redis.exists?("link_color")).to be false
expect(Split::ExperimentCatalog.find("link_color")).to be_nil
end
it "should increment the version" do
expect(experiment.version).to eq(0)
experiment.delete
expect(experiment.version).to eq(1)
end
it "should call the on_experiment_delete hook" do
expect(Split.configuration.on_experiment_delete).to receive(:call)
experiment.delete
end
it "should call the on_before_experiment_delete hook" do
expect(Split.configuration.on_before_experiment_delete).to receive(:call)
experiment.delete
end
it "should reset the start time if the experiment should be manually started" do
Split.configuration.start_manually = true
experiment.start
experiment.delete
expect(experiment.start_time).to be_nil
end
it "should default cohorting back to false" do
experiment.disable_cohorting
expect(experiment.cohorting_disabled?).to eq(true)
experiment.delete
expect(experiment.cohorting_disabled?).to eq(false)
end
end
describe "winner" do
it "should have no winner initially" do
expect(experiment.winner).to be_nil
end
end
describe "winner=" do
it "should allow you to specify a winner" do
experiment.save
experiment.winner = "red"
expect(experiment.winner.name).to eq("red")
end
it "should call the on_experiment_winner_choose hook" do
expect(Split.configuration.on_experiment_winner_choose).to receive(:call)
experiment.winner = "green"
end
context "when has_winner state is memoized" do
before { expect(experiment).to_not have_winner }
it "should keep has_winner state consistent" do
experiment.winner = "red"
expect(experiment).to have_winner
end
end
end
describe "reset_winner" do
before { experiment.winner = "green" }
it "should reset the winner" do
experiment.reset_winner
expect(experiment.winner).to be_nil
end
context "when has_winner state is memoized" do
before { expect(experiment).to have_winner }
it "should keep has_winner state consistent" do
experiment.reset_winner
expect(experiment).to_not have_winner
end
end
end
describe "has_winner?" do
context "with winner" do
before { experiment.winner = "red" }
it "returns true" do
expect(experiment).to have_winner
end
end
context "without winner" do
it "returns false" do
expect(experiment).to_not have_winner
end
end
it "memoizes has_winner state" do
expect(experiment).to receive(:winner).once
expect(experiment).to_not have_winner
expect(experiment).to_not have_winner
end
end
describe "reset" do
let(:reset_manually) { false }
before do
allow(Split.configuration).to receive(:reset_manually).and_return(reset_manually)
experiment.save
green.increment_participation
green.increment_participation
end
it "should reset all alternatives" do
experiment.winner = "green"
expect(experiment.next_alternative.name).to eq("green")
green.increment_participation
experiment.reset
expect(green.participant_count).to eq(0)
expect(green.completed_count).to eq(0)
end
it "should reset the winner" do
experiment.winner = "green"
expect(experiment.next_alternative.name).to eq("green")
green.increment_participation
experiment.reset
expect(experiment.winner).to be_nil
end
it "should increment the version" do
expect(experiment.version).to eq(0)
experiment.reset
expect(experiment.version).to eq(1)
end
it "should call the on_experiment_reset hook" do
expect(Split.configuration.on_experiment_reset).to receive(:call)
experiment.reset
end
it "should call the on_before_experiment_reset hook" do
expect(Split.configuration.on_before_experiment_reset).to receive(:call)
experiment.reset
end
end
describe "algorithm" do
let(:experiment) { Split::ExperimentCatalog.find_or_create("link_color", "blue", "red", "green") }
it "should use the default algorithm if none is specified" do
expect(experiment.algorithm).to eq(Split.configuration.algorithm)
end
it "should use the user specified algorithm for this experiment if specified" do
experiment.algorithm = Split::Algorithms::Whiplash
expect(experiment.algorithm).to eq(Split::Algorithms::Whiplash)
end
end
describe "#next_alternative" do
context "with multiple alternatives" do
let(:experiment) { Split::ExperimentCatalog.find_or_create("link_color", "blue", "red", "green") }
context "with winner" do
it "should always return the winner" do
green = Split::Alternative.new("green", "link_color")
experiment.winner = "green"
expect(experiment.next_alternative.name).to eq("green")
green.increment_participation
expect(experiment.next_alternative.name).to eq("green")
end
end
context "without winner" do
it "should use the specified algorithm" do
experiment.algorithm = Split::Algorithms::Whiplash
expect(experiment.algorithm).to receive(:choose_alternative).and_return(Split::Alternative.new("green", "link_color"))
expect(experiment.next_alternative.name).to eq("green")
end
end
end
context "with single alternative" do
let(:experiment) { Split::ExperimentCatalog.find_or_create("link_color", "blue") }
it "should always return the only alternative" do
expect(experiment.next_alternative.name).to eq("blue")
expect(experiment.next_alternative.name).to eq("blue")
end
end
end
describe "#cohorting_disabled?" do
it "returns false when nothing has been configured" do
expect(experiment.cohorting_disabled?).to eq false
end
it "returns true when enable_cohorting is performed" do
experiment.enable_cohorting
expect(experiment.cohorting_disabled?).to eq false
end
it "returns false when nothing has been configured" do
experiment.disable_cohorting
expect(experiment.cohorting_disabled?).to eq true
end
end
describe "changing an existing experiment" do
def same_but_different_alternative
Split::ExperimentCatalog.find_or_create("link_color", "blue", "yellow", "orange")
end
it "should reset an experiment if it is loaded with different alternatives" do
experiment.save
blue.participant_count = 5
same_experiment = same_but_different_alternative
expect(same_experiment.alternatives.map(&:name)).to eq(["blue", "yellow", "orange"])
expect(blue.participant_count).to eq(0)
end
it "should only reset once" do
experiment.save
expect(experiment.version).to eq(0)
same_experiment = same_but_different_alternative
expect(same_experiment.version).to eq(1)
same_experiment_again = same_but_different_alternative
expect(same_experiment_again.version).to eq(1)
end
context "when metadata is changed" do
it "should increase version" do
experiment.save
experiment.metadata = { "foo" => "bar" }
expect { experiment.save }.to change { experiment.version }.by(1)
end
it "does not increase version" do
experiment.metadata = nil
experiment.save
expect { experiment.save }.to change { experiment.version }.by(0)
end
end
context "when experiment configuration is changed" do
let(:reset_manually) { false }
before do
experiment.save
allow(Split.configuration).to receive(:reset_manually).and_return(reset_manually)
green.increment_participation
green.increment_participation
experiment.set_alternatives_and_options(alternatives: %w(blue red green zip),
goals: %w(purchase))
experiment.save
end
it "resets all alternatives" do
expect(green.participant_count).to eq(0)
expect(green.completed_count).to eq(0)
end
context "when reset_manually is set" do
let(:reset_manually) { true }
it "does not reset alternatives" do
expect(green.participant_count).to eq(2)
expect(green.completed_count).to eq(0)
end
end
end
end
describe "alternatives passed as non-strings" do
it "should throw an exception if an alternative is passed that is not a string" do
expect { Split::ExperimentCatalog.find_or_create("link_color", :blue, :red) }.to raise_error(ArgumentError)
expect { Split::ExperimentCatalog.find_or_create("link_enabled", true, false) }.to raise_error(ArgumentError)
end
end
describe "specifying weights" do
let(:experiment_with_weight) {
Split::ExperimentCatalog.find_or_create("link_color", { "blue" => 1 }, { "red" => 2 })
}
it "should work for a new experiment" do
expect(experiment_with_weight.alternatives.map(&:weight)).to eq([1, 2])
end
it "should work for an existing experiment" do
experiment.save
expect(experiment_with_weight.alternatives.map(&:weight)).to eq([1, 2])
end
end
describe "specifying goals" do
let(:experiment) {
new_experiment(["purchase"])
}
context "saving experiment" do
let(:same_but_different_goals) { Split::ExperimentCatalog.find_or_create({ "link_color" => ["purchase", "refund"] }, "blue", "red", "green") }
before { experiment.save }
it "can find existing experiment" do
expect(Split::ExperimentCatalog.find("link_color").name).to eq("link_color")
end
it "should reset an experiment if it is loaded with different goals" do
same_but_different_goals
expect(Split::ExperimentCatalog.find("link_color").goals).to eq(["purchase", "refund"])
end
end
it "should have goals" do
expect(experiment.goals).to eq(["purchase"])
end
context "find or create experiment" do
it "should have correct goals" do
experiment = Split::ExperimentCatalog.find_or_create({ "link_color3" => ["purchase", "refund"] }, "blue", "red", "green")
expect(experiment.goals).to eq(["purchase", "refund"])
experiment = Split::ExperimentCatalog.find_or_create("link_color3", "blue", "red", "green")
expect(experiment.goals).to eq([])
end
end
end
describe "beta probability calculation" do
it "should return a hash with the probability of each alternative being the best" do
experiment = Split::ExperimentCatalog.find_or_create("mathematicians", "bernoulli", "poisson", "lagrange")
experiment.calc_winning_alternatives
expect(experiment.alternative_probabilities).not_to be_nil
end
it "should return between 46% and 54% probability for an experiment with 2 alternatives and no data" do
experiment = Split::ExperimentCatalog.find_or_create("scientists", "einstein", "bohr")
experiment.calc_winning_alternatives
expect(experiment.alternatives[0].p_winner).to be_within(0.04).of(0.50)
end
it "should calculate the probability of being the winning alternative separately for each goal", skip: true do
experiment = Split::ExperimentCatalog.find_or_create({ "link_color3" => ["purchase", "refund"] }, "blue", "red", "green")
goal1 = experiment.goals[0]
goal2 = experiment.goals[1]
experiment.alternatives.each do |alternative|
alternative.participant_count = 50
alternative.set_completed_count(10, goal1)
alternative.set_completed_count(15+rand(30), goal2)
end
experiment.calc_winning_alternatives
alt = experiment.alternatives[0]
p_goal1 = alt.p_winner(goal1)
p_goal2 = alt.p_winner(goal2)
expect(p_goal1).not_to be_within(0.04).of(p_goal2)
end
it "should return nil and not re-calculate probabilities if they have already been calculated today" do
experiment = Split::ExperimentCatalog.find_or_create({ "link_color3" => ["purchase", "refund"] }, "blue", "red", "green")
expect(experiment.calc_winning_alternatives).not_to be nil
expect(experiment.calc_winning_alternatives).to be nil
end
end
end
<MSG> yet another spec.
<DFF> @@ -139,6 +139,15 @@ describe Split::Experiment do
e.should == experiment
e.algorithm.should == Split::Algorithms::Whiplash
end
+
+ it "should persist a new experiment in redis, that does not exist in the configuration file" do
+ experiment = Split::Experiment.new('foobar', :alternatives => ['tra', 'la'], :algorithm => Split::Algorithms::Whiplash)
+ experiment.save
+
+ e = Split::Experiment.find('foobar')
+ e.should == experiment
+ e.alternatives.collect{|a| a.name}.should == ['tra', 'la']
+ end
end
describe 'deleting' do
| 9 | yet another spec. | 0 | .rb | rb | mit | splitrb/split |
10071620 | <NME> tokenizer.ts
<BEF> import { deepEqual, throws } from 'assert';
import tokenize from '../src/tokenizer';
describe('Tokenizer', () => {
it('numeric values', () => {
deepEqual(tokenize('p10'), [
{ type: 'Literal', value: 'p', start: 0, end: 1 },
{ type: 'NumberValue', value: 10, rawValue: '10', unit: '', start: 1, end: 3 }
]);
deepEqual(tokenize('p-10'), [
{ type: 'Literal', value: 'p', start: 0, end: 1 },
{ type: 'NumberValue', value: -10, rawValue: '-10', unit: '', start: 1, end: 4 }
]);
deepEqual(tokenize('p-10-'), [
{ type: 'Literal', value: 'p', start: 0, end: 1 },
{ type: 'NumberValue', value: -10, rawValue: '-10', unit: '', start: 1, end: 4 },
{ type: 'Operator', operator: '-', start: 4, end: 5 }
]);
deepEqual(tokenize('p-10-20'), [
{ type: 'Literal', value: 'p', start: 0, end: 1 },
{ type: 'NumberValue', value: -10, rawValue: '-10', unit: '', start: 1, end: 4 },
{ type: 'Operator', operator: '-', start: 4, end: 5 },
{ type: 'NumberValue', value: 20, rawValue: '20', unit: '', start: 5, end: 7 }
]);
deepEqual(tokenize('p-10--20'), [
{ type: 'Literal', value: 'p', start: 0, end: 1 },
{ type: 'NumberValue', value: -10, rawValue: '-10', unit: '', start: 1, end: 4 },
{ type: 'Operator', operator: '-', start: 4, end: 5 },
{ type: 'NumberValue', value: -20, rawValue: '-20', unit: '', start: 5, end: 8 }
]);
deepEqual(tokenize('p-10-20--30'), [
{ type: 'Literal', value: 'p', start: 0, end: 1 },
{ type: 'NumberValue', value: -10, rawValue: '-10', unit: '', start: 1, end: 4 },
{ type: 'Operator', operator: '-', start: 4, end: 5 },
{ type: 'NumberValue', value: 20, rawValue: '20', unit: '', start: 5, end: 7 },
{ type: 'Operator', operator: '-', start: 7, end: 8 },
{ type: 'NumberValue', value: -30, rawValue: '-30', unit: '', start: 8, end: 11 }
]);
deepEqual(tokenize('p-10p-20--30'), [
{ type: 'Literal', value: 'p', start: 0, end: 1 },
{ type: 'NumberValue', value: -10, rawValue: '-10', unit: 'p', start: 1, end: 5 },
{ type: 'NumberValue', value: -20, rawValue: '-20', unit: '', start: 5, end: 8 },
{ type: 'Operator', operator: '-', start: 8, end: 9 },
{ type: 'NumberValue', value: -30, rawValue: '-30', unit: '', start: 9, end: 12 }
]);
deepEqual(tokenize('p-10%-20--30'), [
{ type: 'Literal', value: 'p', start: 0, end: 1 },
{ type: 'NumberValue', value: -10, rawValue: '-10', unit: '%', start: 1, end: 5 },
{ type: 'NumberValue', value: -20, rawValue: '-20', unit: '', start: 5, end: 8 },
{ type: 'Operator', operator: '-', start: 8, end: 9 },
{ type: 'NumberValue', value: -30, rawValue: '-30', unit: '', start: 9, end: 12 }
]);
});
it('float values', () => {
deepEqual(tokenize('p.5'), [
{ type: 'Literal', value: 'p', start: 0, end: 1 },
{ type: 'NumberValue', value: 0.5, rawValue: '.5', unit: '', start: 1, end: 3 }
]);
deepEqual(tokenize('p-.5'), [
{ type: 'Literal', value: 'p', start: 0, end: 1 },
{ type: 'NumberValue', value: -0.5, rawValue: '-.5', unit: '', start: 1, end: 4 }
]);
deepEqual(tokenize('p.1.2.3'), [
{ type: 'Literal', value: 'p', start: 0, end: 1 },
{ type: 'NumberValue', value: 0.1, rawValue: '.1', unit: '', start: 1, end: 3 },
{ type: 'NumberValue', value: 0.2, rawValue: '.2', unit: '', start: 3, end: 5 },
{ type: 'NumberValue', value: 0.3, rawValue: '.3', unit: '', start: 5, end: 7 }
]);
deepEqual(tokenize('p.1-.2.3'), [
{ type: 'Literal', value: 'p', start: 0, end: 1 },
{ type: 'NumberValue', value: 0.1, rawValue: '.1', unit: '', start: 1, end: 3 },
{ type: 'Operator', operator: '-', start: 3, end: 4 },
{ type: 'NumberValue', value: 0.2, rawValue: '.2', unit: '', start: 4, end: 6 },
{ type: 'NumberValue', value: 0.3, rawValue: '.3', unit: '', start: 6, end: 8 }
]);
deepEqual(tokenize('p.1--.2.3'), [
{ type: 'Literal', value: 'p', start: 0, end: 1 },
{ type: 'NumberValue', value: 0.1, rawValue: '.1', unit: '', start: 1, end: 3 },
{ type: 'Operator', operator: '-', start: 3, end: 4 },
{ type: 'NumberValue', value: -0.2, rawValue: '-.2', unit: '', start: 4, end: 7 },
{ type: 'NumberValue', value: 0.3, rawValue: '.3', unit: '', start: 7, end: 9 }
]);
deepEqual(tokenize('10'), [
{ type: 'NumberValue', value: 10, rawValue: '10', unit: '', start: 0, end: 2 },
]);
deepEqual(tokenize('.1'), [
{ type: 'NumberValue', value: 0.1, rawValue: '.1', unit: '', start: 0, end: 2 },
]);
throws(() => tokenize('.foo'), /Unexpected character at 1/);
});
it('color values', () => {
deepEqual(tokenize('c#'), [
{ type: 'Literal', value: 'c', start: 0, end: 1 },
{ type: 'ColorValue', r: 0, g: 0, b: 0, a: 1, raw: '', start: 1, end: 2 }
]);
deepEqual(tokenize('c#1'), [
{ type: 'Literal', value: 'c', start: 0, end: 1 },
{ type: 'ColorValue', r: 17, g: 17, b: 17, a: 1, raw: '1', start: 1, end: 3 }
]);
deepEqual(tokenize('c#.'), [
{ type: 'Literal', value: 'c', start: 0, end: 1 },
{ type: 'ColorValue', r: 0, g: 0, b: 0, a: 1, raw: '.', start: 1, end: 3 }
]);
deepEqual(tokenize('c#f'), [
{ type: 'Literal', value: 'c', start: 0, end: 1 },
{ type: 'ColorValue', r: 255, g: 255, b: 255, a: 1, raw: 'f', start: 1, end: 3 }
]);
deepEqual(tokenize('c#a#b#c'), [
{ type: 'Literal', value: 'c', start: 0, end: 1 },
{ type: 'ColorValue', r: 170, g: 170, b: 170, a: 1, raw: 'a', start: 1, end: 3 },
{ type: 'ColorValue', r: 187, g: 187, b: 187, a: 1, raw: 'b', start: 3, end: 5 },
{ type: 'ColorValue', r: 204, g: 204, b: 204, a: 1, raw: 'c', start: 5, end: 7 }
]);
deepEqual(tokenize('c#af'), [
{ type: 'Literal', value: 'c', start: 0, end: 1 },
{ type: 'ColorValue', r: 175, g: 175, b: 175, a: 1, raw: 'af', start: 1, end: 4 }
]);
deepEqual(tokenize('c#fc0'), [
{ type: 'Literal', value: 'c', start: 0, end: 1 },
{ type: 'ColorValue', r: 255, g: 204, b: 0, a: 1, raw: 'fc0', start: 1, end: 5 }
]);
deepEqual(tokenize('c#11.5'), [
{ type: 'Literal', value: 'c', start: 0, end: 1 },
{ type: 'ColorValue', r: 17, g: 17, b: 17, a: 0.5, raw: '11.5', start: 1, end: 6 }
]);
deepEqual(tokenize('c#.99'), [
{ type: 'Literal', value: 'c', start: 0, end: 1 },
{ type: 'ColorValue', r: 0, g: 0, b: 0, a: 0.99, raw: '.99', start: 1, end: 5 }
]);
deepEqual(tokenize('c#t'), [
{ type: 'Literal', value: 'c', start: 0, end: 1 },
{ type: 'ColorValue', r: 0, g: 0, b: 0, a: 0, raw: 't', start: 1, end: 3 }
]);
deepEqual(tokenize('c#${fff}'), [
{ type: 'Literal', value: 'c', start: 0, end: 1 },
{ type: 'Literal', value: '#', start: 1, end: 2 },
{ type: 'Field', index: undefined, name: 'fff', start: 2, end: 8 }
]);
});
it('keywords', () => {
deepEqual(tokenize('m:a'), [
{ type: 'Literal', value: 'm', start: 0, end: 1 },
{ type: 'Operator', operator: ':', start: 1, end: 2 },
{ type: 'Literal', value: 'a', start: 2, end: 3 }
]);
deepEqual(tokenize('m-a'), [
{ type: 'Literal', value: 'm', start: 0, end: 1 },
{ type: 'Operator', operator: '-', start: 1, end: 2 },
{ type: 'Literal', value: 'a', start: 2, end: 3 }
]);
deepEqual(tokenize('m-abc'), [
{ type: 'Literal', value: 'm', start: 0, end: 1 },
{ type: 'Operator', operator: '-', start: 1, end: 2 },
{ type: 'Literal', value: 'abc', start: 2, end: 5 }
]);
deepEqual(tokenize('m-a0'), [
{ type: 'Literal', value: 'm', start: 0, end: 1 },
{ type: 'Operator', operator: '-', start: 1, end: 2 },
{ type: 'Literal', value: 'a', start: 2, end: 3 },
{ type: 'NumberValue', value: 0, rawValue: '0', unit: '', start: 3, end: 4 }
]);
deepEqual(tokenize('m-a0-a'), [
{ type: 'Literal', value: 'm', start: 0, end: 1 },
{ type: 'Operator', operator: '-', start: 1, end: 2 },
{ type: 'Literal', value: 'a', start: 2, end: 3 },
{ type: 'NumberValue', value: 0, rawValue: '0', unit: '', start: 3, end: 4 },
{ type: 'Operator', operator: '-', start: 4, end: 5 },
{ type: 'Literal', value: 'a', start: 5, end: 6 }
]);
});
it('arguments', () => {
deepEqual(tokenize('lg(top, "red, black", rgb(0, 0, 0) 10%)'), [
{ type: 'Literal', value: 'lg', start: 0, end: 2 },
{ type: 'Bracket', open: true, start: 2, end: 3 },
{ type: 'Literal', value: 'top', start: 3, end: 6 },
{ type: 'Operator', operator: ',', start: 6, end: 7 },
{ type: 'WhiteSpace', start: 7, end: 8 },
{ type: 'StringValue', value: 'red, black', quote: 'double', start: 8, end: 20 },
{ type: 'Operator', operator: ',', start: 20, end: 21 },
{ type: 'WhiteSpace', start: 21, end: 22 },
{ type: 'Literal', value: 'rgb', start: 22, end: 25 },
{ type: 'Bracket', open: true, start: 25, end: 26 },
{ type: 'NumberValue', value: 0, rawValue: '0', unit: '', start: 26, end: 27 },
{ type: 'Operator', operator: ',', start: 27, end: 28 },
{ type: 'WhiteSpace', start: 28, end: 29 },
{ type: 'NumberValue', value: 0, rawValue: '0', unit: '', start: 29, end: 30 },
{ type: 'Operator', operator: ',', start: 30, end: 31 },
{ type: 'WhiteSpace', start: 31, end: 32 },
{ type: 'NumberValue', value: 0, rawValue: '0', unit: '', start: 32, end: 33 },
{ type: 'Bracket', open: false, start: 33, end: 34 },
{ type: 'WhiteSpace', start: 34, end: 35 },
{ type: 'NumberValue', value: 10, rawValue: '10', unit: '%', start: 35, end: 38 },
{ type: 'Bracket', open: false, start: 38, end: 39 }
]);
});
it('important', () => {
deepEqual(tokenize('!'), [
{ type: 'Operator', operator: '!', start: 0, end: 1 }
]);
deepEqual(tokenize('p!'), [
{ type: 'Literal', value: 'p', start: 0, end: 1 },
{ type: 'Operator', operator: '!', start: 1, end: 2 }
]);
deepEqual(tokenize('p10!'), [
{ type: 'Literal', value: 'p', start: 0, end: 1 },
{ type: 'NumberValue', value: 10, rawValue: '10', unit: '', start: 1, end: 3 },
{ type: 'Operator', operator: '!', start: 3, end: 4 }
]);
});
it('mixed', () => {
deepEqual(tokenize('bd1-s#fc0'), [
{ type: 'Literal', value: 'bd', start: 0, end: 2 },
{ type: 'NumberValue', value: 1, rawValue: '1', unit: '', start: 2, end: 3 },
{ type: 'Operator', operator: '-', start: 3, end: 4 },
{ type: 'Literal', value: 's', start: 4, end: 5 },
{ type: 'ColorValue', r: 255, g: 204, b: 0, a: 1, raw: 'fc0', start: 5, end: 9 }
]);
deepEqual(tokenize('bd#fc0-1'), [
{ type: 'Literal', value: 'bd', start: 0, end: 2 },
{ type: 'ColorValue', r: 255, g: 204, b: 0, a: 1, raw: 'fc0', start: 2, end: 6 },
{ type: 'Operator', operator: '-', start: 6, end: 7 },
{ type: 'NumberValue', value: 1, rawValue: '1', unit: '', start: 7, end: 8 }
]);
deepEqual(tokenize('p0+m0'), [
{ type: 'Literal', value: 'p', start: 0, end: 1 },
{ type: 'NumberValue', value: 0, rawValue: '0', unit: '', start: 1, end: 2 },
{ type: 'Operator', operator: '+', start: 2, end: 3 },
{ type: 'Operator', operator: '!', start: 6, end: 7 }
]);
deepEqual(tokenize("${2:0}%"), [
{ type: 'Field', index: 2, name: '0', start: 0, end: 6 },
{ type: 'Literal', value: '%', start: 6, end: 7 }
]);
});
it('embedded variables', () => {
{ type: 'Field', index: 2, name: '0', start: 0, end: 6 },
{ type: 'Literal', value: '%', start: 6, end: 7 }
]);
deepEqual(tokenize('.${1:5}'), [
{ type: 'Literal', value: '.', start: 0, end: 1 },
{ type: 'Field', index: 1, name: '5', start: 1, end: 7 },
]);
});
it('embedded variables', () => {
deepEqual(tokenize('foo$bar'), [
{ type: 'Literal', value: 'foo', start: 0, end: 3 },
{ type: 'Literal', value: '$bar', start: 3, end: 7 }
]);
deepEqual(tokenize('foo$bar-2'), [
{ type: 'Literal', value: 'foo', start: 0, end: 3 },
{ type: 'Literal', value: '$bar-2', start: 3, end: 9 }
]);
deepEqual(tokenize('foo$bar@bam'), [
{ type: 'Literal', value: 'foo', start: 0, end: 3 },
{ type: 'Literal', value: '$bar', start: 3, end: 7 },
{ type: 'Literal', value: '@bam', start: 7, end: 11 }
]);
deepEqual(tokenize('@k10'), [
{ type: 'Literal', value: '@k', start: 0, end: 2 },
{ type: 'NumberValue', value: 10, rawValue: '10', unit: '', start: 2, end: 4 }
]);
});
});
<MSG> More generic method for consuming literals
<DFF> @@ -1,4 +1,4 @@
-import { deepEqual, throws } from 'assert';
+import { deepEqual } from 'assert';
import tokenize from '../src/tokenizer';
describe('Tokenizer', () => {
@@ -101,7 +101,8 @@ describe('Tokenizer', () => {
{ type: 'NumberValue', value: 0.1, rawValue: '.1', unit: '', start: 0, end: 2 },
]);
- throws(() => tokenize('.foo'), /Unexpected character at 1/);
+ // NB: now dot should be a part of literal
+ // throws(() => tokenize('.foo'), /Unexpected character at 1/);
});
it('color values', () => {
@@ -266,10 +267,15 @@ describe('Tokenizer', () => {
{ type: 'Operator', operator: '!', start: 6, end: 7 }
]);
- deepEqual(tokenize("${2:0}%"), [
+ deepEqual(tokenize('${2:0}%'), [
{ type: 'Field', index: 2, name: '0', start: 0, end: 6 },
{ type: 'Literal', value: '%', start: 6, end: 7 }
]);
+
+ deepEqual(tokenize('.${1:5}'), [
+ { type: 'Literal', value: '.', start: 0, end: 1 },
+ { type: 'Field', index: 1, name: '5', start: 1, end: 7 },
+ ]);
});
it('embedded variables', () => {
| 9 | More generic method for consuming literals | 3 | .ts | ts | mit | emmetio/emmet |
10071621 | <NME> tokenizer.ts
<BEF> import { deepEqual, throws } from 'assert';
import tokenize from '../src/tokenizer';
describe('Tokenizer', () => {
it('numeric values', () => {
deepEqual(tokenize('p10'), [
{ type: 'Literal', value: 'p', start: 0, end: 1 },
{ type: 'NumberValue', value: 10, rawValue: '10', unit: '', start: 1, end: 3 }
]);
deepEqual(tokenize('p-10'), [
{ type: 'Literal', value: 'p', start: 0, end: 1 },
{ type: 'NumberValue', value: -10, rawValue: '-10', unit: '', start: 1, end: 4 }
]);
deepEqual(tokenize('p-10-'), [
{ type: 'Literal', value: 'p', start: 0, end: 1 },
{ type: 'NumberValue', value: -10, rawValue: '-10', unit: '', start: 1, end: 4 },
{ type: 'Operator', operator: '-', start: 4, end: 5 }
]);
deepEqual(tokenize('p-10-20'), [
{ type: 'Literal', value: 'p', start: 0, end: 1 },
{ type: 'NumberValue', value: -10, rawValue: '-10', unit: '', start: 1, end: 4 },
{ type: 'Operator', operator: '-', start: 4, end: 5 },
{ type: 'NumberValue', value: 20, rawValue: '20', unit: '', start: 5, end: 7 }
]);
deepEqual(tokenize('p-10--20'), [
{ type: 'Literal', value: 'p', start: 0, end: 1 },
{ type: 'NumberValue', value: -10, rawValue: '-10', unit: '', start: 1, end: 4 },
{ type: 'Operator', operator: '-', start: 4, end: 5 },
{ type: 'NumberValue', value: -20, rawValue: '-20', unit: '', start: 5, end: 8 }
]);
deepEqual(tokenize('p-10-20--30'), [
{ type: 'Literal', value: 'p', start: 0, end: 1 },
{ type: 'NumberValue', value: -10, rawValue: '-10', unit: '', start: 1, end: 4 },
{ type: 'Operator', operator: '-', start: 4, end: 5 },
{ type: 'NumberValue', value: 20, rawValue: '20', unit: '', start: 5, end: 7 },
{ type: 'Operator', operator: '-', start: 7, end: 8 },
{ type: 'NumberValue', value: -30, rawValue: '-30', unit: '', start: 8, end: 11 }
]);
deepEqual(tokenize('p-10p-20--30'), [
{ type: 'Literal', value: 'p', start: 0, end: 1 },
{ type: 'NumberValue', value: -10, rawValue: '-10', unit: 'p', start: 1, end: 5 },
{ type: 'NumberValue', value: -20, rawValue: '-20', unit: '', start: 5, end: 8 },
{ type: 'Operator', operator: '-', start: 8, end: 9 },
{ type: 'NumberValue', value: -30, rawValue: '-30', unit: '', start: 9, end: 12 }
]);
deepEqual(tokenize('p-10%-20--30'), [
{ type: 'Literal', value: 'p', start: 0, end: 1 },
{ type: 'NumberValue', value: -10, rawValue: '-10', unit: '%', start: 1, end: 5 },
{ type: 'NumberValue', value: -20, rawValue: '-20', unit: '', start: 5, end: 8 },
{ type: 'Operator', operator: '-', start: 8, end: 9 },
{ type: 'NumberValue', value: -30, rawValue: '-30', unit: '', start: 9, end: 12 }
]);
});
it('float values', () => {
deepEqual(tokenize('p.5'), [
{ type: 'Literal', value: 'p', start: 0, end: 1 },
{ type: 'NumberValue', value: 0.5, rawValue: '.5', unit: '', start: 1, end: 3 }
]);
deepEqual(tokenize('p-.5'), [
{ type: 'Literal', value: 'p', start: 0, end: 1 },
{ type: 'NumberValue', value: -0.5, rawValue: '-.5', unit: '', start: 1, end: 4 }
]);
deepEqual(tokenize('p.1.2.3'), [
{ type: 'Literal', value: 'p', start: 0, end: 1 },
{ type: 'NumberValue', value: 0.1, rawValue: '.1', unit: '', start: 1, end: 3 },
{ type: 'NumberValue', value: 0.2, rawValue: '.2', unit: '', start: 3, end: 5 },
{ type: 'NumberValue', value: 0.3, rawValue: '.3', unit: '', start: 5, end: 7 }
]);
deepEqual(tokenize('p.1-.2.3'), [
{ type: 'Literal', value: 'p', start: 0, end: 1 },
{ type: 'NumberValue', value: 0.1, rawValue: '.1', unit: '', start: 1, end: 3 },
{ type: 'Operator', operator: '-', start: 3, end: 4 },
{ type: 'NumberValue', value: 0.2, rawValue: '.2', unit: '', start: 4, end: 6 },
{ type: 'NumberValue', value: 0.3, rawValue: '.3', unit: '', start: 6, end: 8 }
]);
deepEqual(tokenize('p.1--.2.3'), [
{ type: 'Literal', value: 'p', start: 0, end: 1 },
{ type: 'NumberValue', value: 0.1, rawValue: '.1', unit: '', start: 1, end: 3 },
{ type: 'Operator', operator: '-', start: 3, end: 4 },
{ type: 'NumberValue', value: -0.2, rawValue: '-.2', unit: '', start: 4, end: 7 },
{ type: 'NumberValue', value: 0.3, rawValue: '.3', unit: '', start: 7, end: 9 }
]);
deepEqual(tokenize('10'), [
{ type: 'NumberValue', value: 10, rawValue: '10', unit: '', start: 0, end: 2 },
]);
deepEqual(tokenize('.1'), [
{ type: 'NumberValue', value: 0.1, rawValue: '.1', unit: '', start: 0, end: 2 },
]);
throws(() => tokenize('.foo'), /Unexpected character at 1/);
});
it('color values', () => {
deepEqual(tokenize('c#'), [
{ type: 'Literal', value: 'c', start: 0, end: 1 },
{ type: 'ColorValue', r: 0, g: 0, b: 0, a: 1, raw: '', start: 1, end: 2 }
]);
deepEqual(tokenize('c#1'), [
{ type: 'Literal', value: 'c', start: 0, end: 1 },
{ type: 'ColorValue', r: 17, g: 17, b: 17, a: 1, raw: '1', start: 1, end: 3 }
]);
deepEqual(tokenize('c#.'), [
{ type: 'Literal', value: 'c', start: 0, end: 1 },
{ type: 'ColorValue', r: 0, g: 0, b: 0, a: 1, raw: '.', start: 1, end: 3 }
]);
deepEqual(tokenize('c#f'), [
{ type: 'Literal', value: 'c', start: 0, end: 1 },
{ type: 'ColorValue', r: 255, g: 255, b: 255, a: 1, raw: 'f', start: 1, end: 3 }
]);
deepEqual(tokenize('c#a#b#c'), [
{ type: 'Literal', value: 'c', start: 0, end: 1 },
{ type: 'ColorValue', r: 170, g: 170, b: 170, a: 1, raw: 'a', start: 1, end: 3 },
{ type: 'ColorValue', r: 187, g: 187, b: 187, a: 1, raw: 'b', start: 3, end: 5 },
{ type: 'ColorValue', r: 204, g: 204, b: 204, a: 1, raw: 'c', start: 5, end: 7 }
]);
deepEqual(tokenize('c#af'), [
{ type: 'Literal', value: 'c', start: 0, end: 1 },
{ type: 'ColorValue', r: 175, g: 175, b: 175, a: 1, raw: 'af', start: 1, end: 4 }
]);
deepEqual(tokenize('c#fc0'), [
{ type: 'Literal', value: 'c', start: 0, end: 1 },
{ type: 'ColorValue', r: 255, g: 204, b: 0, a: 1, raw: 'fc0', start: 1, end: 5 }
]);
deepEqual(tokenize('c#11.5'), [
{ type: 'Literal', value: 'c', start: 0, end: 1 },
{ type: 'ColorValue', r: 17, g: 17, b: 17, a: 0.5, raw: '11.5', start: 1, end: 6 }
]);
deepEqual(tokenize('c#.99'), [
{ type: 'Literal', value: 'c', start: 0, end: 1 },
{ type: 'ColorValue', r: 0, g: 0, b: 0, a: 0.99, raw: '.99', start: 1, end: 5 }
]);
deepEqual(tokenize('c#t'), [
{ type: 'Literal', value: 'c', start: 0, end: 1 },
{ type: 'ColorValue', r: 0, g: 0, b: 0, a: 0, raw: 't', start: 1, end: 3 }
]);
deepEqual(tokenize('c#${fff}'), [
{ type: 'Literal', value: 'c', start: 0, end: 1 },
{ type: 'Literal', value: '#', start: 1, end: 2 },
{ type: 'Field', index: undefined, name: 'fff', start: 2, end: 8 }
]);
});
it('keywords', () => {
deepEqual(tokenize('m:a'), [
{ type: 'Literal', value: 'm', start: 0, end: 1 },
{ type: 'Operator', operator: ':', start: 1, end: 2 },
{ type: 'Literal', value: 'a', start: 2, end: 3 }
]);
deepEqual(tokenize('m-a'), [
{ type: 'Literal', value: 'm', start: 0, end: 1 },
{ type: 'Operator', operator: '-', start: 1, end: 2 },
{ type: 'Literal', value: 'a', start: 2, end: 3 }
]);
deepEqual(tokenize('m-abc'), [
{ type: 'Literal', value: 'm', start: 0, end: 1 },
{ type: 'Operator', operator: '-', start: 1, end: 2 },
{ type: 'Literal', value: 'abc', start: 2, end: 5 }
]);
deepEqual(tokenize('m-a0'), [
{ type: 'Literal', value: 'm', start: 0, end: 1 },
{ type: 'Operator', operator: '-', start: 1, end: 2 },
{ type: 'Literal', value: 'a', start: 2, end: 3 },
{ type: 'NumberValue', value: 0, rawValue: '0', unit: '', start: 3, end: 4 }
]);
deepEqual(tokenize('m-a0-a'), [
{ type: 'Literal', value: 'm', start: 0, end: 1 },
{ type: 'Operator', operator: '-', start: 1, end: 2 },
{ type: 'Literal', value: 'a', start: 2, end: 3 },
{ type: 'NumberValue', value: 0, rawValue: '0', unit: '', start: 3, end: 4 },
{ type: 'Operator', operator: '-', start: 4, end: 5 },
{ type: 'Literal', value: 'a', start: 5, end: 6 }
]);
});
it('arguments', () => {
deepEqual(tokenize('lg(top, "red, black", rgb(0, 0, 0) 10%)'), [
{ type: 'Literal', value: 'lg', start: 0, end: 2 },
{ type: 'Bracket', open: true, start: 2, end: 3 },
{ type: 'Literal', value: 'top', start: 3, end: 6 },
{ type: 'Operator', operator: ',', start: 6, end: 7 },
{ type: 'WhiteSpace', start: 7, end: 8 },
{ type: 'StringValue', value: 'red, black', quote: 'double', start: 8, end: 20 },
{ type: 'Operator', operator: ',', start: 20, end: 21 },
{ type: 'WhiteSpace', start: 21, end: 22 },
{ type: 'Literal', value: 'rgb', start: 22, end: 25 },
{ type: 'Bracket', open: true, start: 25, end: 26 },
{ type: 'NumberValue', value: 0, rawValue: '0', unit: '', start: 26, end: 27 },
{ type: 'Operator', operator: ',', start: 27, end: 28 },
{ type: 'WhiteSpace', start: 28, end: 29 },
{ type: 'NumberValue', value: 0, rawValue: '0', unit: '', start: 29, end: 30 },
{ type: 'Operator', operator: ',', start: 30, end: 31 },
{ type: 'WhiteSpace', start: 31, end: 32 },
{ type: 'NumberValue', value: 0, rawValue: '0', unit: '', start: 32, end: 33 },
{ type: 'Bracket', open: false, start: 33, end: 34 },
{ type: 'WhiteSpace', start: 34, end: 35 },
{ type: 'NumberValue', value: 10, rawValue: '10', unit: '%', start: 35, end: 38 },
{ type: 'Bracket', open: false, start: 38, end: 39 }
]);
});
it('important', () => {
deepEqual(tokenize('!'), [
{ type: 'Operator', operator: '!', start: 0, end: 1 }
]);
deepEqual(tokenize('p!'), [
{ type: 'Literal', value: 'p', start: 0, end: 1 },
{ type: 'Operator', operator: '!', start: 1, end: 2 }
]);
deepEqual(tokenize('p10!'), [
{ type: 'Literal', value: 'p', start: 0, end: 1 },
{ type: 'NumberValue', value: 10, rawValue: '10', unit: '', start: 1, end: 3 },
{ type: 'Operator', operator: '!', start: 3, end: 4 }
]);
});
it('mixed', () => {
deepEqual(tokenize('bd1-s#fc0'), [
{ type: 'Literal', value: 'bd', start: 0, end: 2 },
{ type: 'NumberValue', value: 1, rawValue: '1', unit: '', start: 2, end: 3 },
{ type: 'Operator', operator: '-', start: 3, end: 4 },
{ type: 'Literal', value: 's', start: 4, end: 5 },
{ type: 'ColorValue', r: 255, g: 204, b: 0, a: 1, raw: 'fc0', start: 5, end: 9 }
]);
deepEqual(tokenize('bd#fc0-1'), [
{ type: 'Literal', value: 'bd', start: 0, end: 2 },
{ type: 'ColorValue', r: 255, g: 204, b: 0, a: 1, raw: 'fc0', start: 2, end: 6 },
{ type: 'Operator', operator: '-', start: 6, end: 7 },
{ type: 'NumberValue', value: 1, rawValue: '1', unit: '', start: 7, end: 8 }
]);
deepEqual(tokenize('p0+m0'), [
{ type: 'Literal', value: 'p', start: 0, end: 1 },
{ type: 'NumberValue', value: 0, rawValue: '0', unit: '', start: 1, end: 2 },
{ type: 'Operator', operator: '+', start: 2, end: 3 },
{ type: 'Operator', operator: '!', start: 6, end: 7 }
]);
deepEqual(tokenize("${2:0}%"), [
{ type: 'Field', index: 2, name: '0', start: 0, end: 6 },
{ type: 'Literal', value: '%', start: 6, end: 7 }
]);
});
it('embedded variables', () => {
{ type: 'Field', index: 2, name: '0', start: 0, end: 6 },
{ type: 'Literal', value: '%', start: 6, end: 7 }
]);
deepEqual(tokenize('.${1:5}'), [
{ type: 'Literal', value: '.', start: 0, end: 1 },
{ type: 'Field', index: 1, name: '5', start: 1, end: 7 },
]);
});
it('embedded variables', () => {
deepEqual(tokenize('foo$bar'), [
{ type: 'Literal', value: 'foo', start: 0, end: 3 },
{ type: 'Literal', value: '$bar', start: 3, end: 7 }
]);
deepEqual(tokenize('foo$bar-2'), [
{ type: 'Literal', value: 'foo', start: 0, end: 3 },
{ type: 'Literal', value: '$bar-2', start: 3, end: 9 }
]);
deepEqual(tokenize('foo$bar@bam'), [
{ type: 'Literal', value: 'foo', start: 0, end: 3 },
{ type: 'Literal', value: '$bar', start: 3, end: 7 },
{ type: 'Literal', value: '@bam', start: 7, end: 11 }
]);
deepEqual(tokenize('@k10'), [
{ type: 'Literal', value: '@k', start: 0, end: 2 },
{ type: 'NumberValue', value: 10, rawValue: '10', unit: '', start: 2, end: 4 }
]);
});
});
<MSG> More generic method for consuming literals
<DFF> @@ -1,4 +1,4 @@
-import { deepEqual, throws } from 'assert';
+import { deepEqual } from 'assert';
import tokenize from '../src/tokenizer';
describe('Tokenizer', () => {
@@ -101,7 +101,8 @@ describe('Tokenizer', () => {
{ type: 'NumberValue', value: 0.1, rawValue: '.1', unit: '', start: 0, end: 2 },
]);
- throws(() => tokenize('.foo'), /Unexpected character at 1/);
+ // NB: now dot should be a part of literal
+ // throws(() => tokenize('.foo'), /Unexpected character at 1/);
});
it('color values', () => {
@@ -266,10 +267,15 @@ describe('Tokenizer', () => {
{ type: 'Operator', operator: '!', start: 6, end: 7 }
]);
- deepEqual(tokenize("${2:0}%"), [
+ deepEqual(tokenize('${2:0}%'), [
{ type: 'Field', index: 2, name: '0', start: 0, end: 6 },
{ type: 'Literal', value: '%', start: 6, end: 7 }
]);
+
+ deepEqual(tokenize('.${1:5}'), [
+ { type: 'Literal', value: '.', start: 0, end: 1 },
+ { type: 'Field', index: 1, name: '5', start: 1, end: 7 },
+ ]);
});
it('embedded variables', () => {
| 9 | More generic method for consuming literals | 3 | .ts | ts | mit | emmetio/emmet |
10071622 | <NME> spec_helper.rb
<BEF> # frozen_string_literal: true
ENV["RACK_ENV"] = "test"
require 'bundler/setup'
require 'split'
require 'ostruct'
def session
@session ||= {}
require "split"
require "ostruct"
require "yaml"
Dir["./spec/support/*.rb"].each { |f| require f }
module GlobalSharedContext
extend RSpec::SharedContext
let(:mock_user) { Split::User.new(double(session: {})) }
before(:each) do
Split.configuration = Split::Configuration.new
Split.redis = Redis.new
Split.redis.select(10)
Split.redis.flushdb
Split::Cache.clear
@ab_user = mock_user
@params = nil
end
end
RSpec.configure do |config|
config.order = "random"
config.include GlobalSharedContext
config.raise_errors_for_deprecations!
end
def session
@session ||= {}
end
def params
@params ||= {}
end
def request(ua = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; de-de) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27")
@request ||= begin
r = OpenStruct.new
r.user_agent = ua
r.ip = "192.168.1.1"
r
end
end
<MSG> Fixed specs in 1.8.x
<DFF> @@ -4,6 +4,7 @@ require 'rubygems'
require 'bundler/setup'
require 'split'
require 'ostruct'
+require 'complex' if RUBY_VERSION.match(/1\.8/)
def session
@session ||= {}
| 1 | Fixed specs in 1.8.x | 0 | .rb | rb | mit | splitrb/split |
10071623 | <NME> spec_helper.rb
<BEF> # frozen_string_literal: true
ENV["RACK_ENV"] = "test"
require 'bundler/setup'
require 'split'
require 'ostruct'
def session
@session ||= {}
require "split"
require "ostruct"
require "yaml"
Dir["./spec/support/*.rb"].each { |f| require f }
module GlobalSharedContext
extend RSpec::SharedContext
let(:mock_user) { Split::User.new(double(session: {})) }
before(:each) do
Split.configuration = Split::Configuration.new
Split.redis = Redis.new
Split.redis.select(10)
Split.redis.flushdb
Split::Cache.clear
@ab_user = mock_user
@params = nil
end
end
RSpec.configure do |config|
config.order = "random"
config.include GlobalSharedContext
config.raise_errors_for_deprecations!
end
def session
@session ||= {}
end
def params
@params ||= {}
end
def request(ua = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; de-de) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27")
@request ||= begin
r = OpenStruct.new
r.user_agent = ua
r.ip = "192.168.1.1"
r
end
end
<MSG> Fixed specs in 1.8.x
<DFF> @@ -4,6 +4,7 @@ require 'rubygems'
require 'bundler/setup'
require 'split'
require 'ostruct'
+require 'complex' if RUBY_VERSION.match(/1\.8/)
def session
@session ||= {}
| 1 | Fixed specs in 1.8.x | 0 | .rb | rb | mit | splitrb/split |
10071624 | <NME> spec_helper.rb
<BEF> # frozen_string_literal: true
ENV["RACK_ENV"] = "test"
require 'bundler/setup'
require 'split'
require 'ostruct'
def session
@session ||= {}
require "split"
require "ostruct"
require "yaml"
Dir["./spec/support/*.rb"].each { |f| require f }
module GlobalSharedContext
extend RSpec::SharedContext
let(:mock_user) { Split::User.new(double(session: {})) }
before(:each) do
Split.configuration = Split::Configuration.new
Split.redis = Redis.new
Split.redis.select(10)
Split.redis.flushdb
Split::Cache.clear
@ab_user = mock_user
@params = nil
end
end
RSpec.configure do |config|
config.order = "random"
config.include GlobalSharedContext
config.raise_errors_for_deprecations!
end
def session
@session ||= {}
end
def params
@params ||= {}
end
def request(ua = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; de-de) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27")
@request ||= begin
r = OpenStruct.new
r.user_agent = ua
r.ip = "192.168.1.1"
r
end
end
<MSG> Fixed specs in 1.8.x
<DFF> @@ -4,6 +4,7 @@ require 'rubygems'
require 'bundler/setup'
require 'split'
require 'ostruct'
+require 'complex' if RUBY_VERSION.match(/1\.8/)
def session
@session ||= {}
| 1 | Fixed specs in 1.8.x | 0 | .rb | rb | mit | splitrb/split |
10071625 | <NME> helper.rb
<BEF> # frozen_string_literal: true
module Split
module Helper
OVERRIDE_PARAM_NAME = "ab_test"
module_function
def ab_test(metric_descriptor, control = nil, *alternatives)
begin
experiment = ExperimentCatalog.find_or_initialize(metric_descriptor, control, *alternatives)
alternative = if Split.configuration.enabled && !exclude_visitor?
experiment.save
raise(Split::InvalidExperimentsFormatError) unless (Split.configuration.experiments || {}).fetch(experiment.name.to_sym, {})[:combined_experiments].nil?
trial = Trial.new(user: ab_user, experiment: experiment,
override: override_alternative(experiment.name), exclude: exclude_visitor?,
disabled: split_generically_disabled?)
alt = trial.choose!(self)
alt ? alt.name : nil
else
control_variable(experiment.control)
end
rescue Errno::ECONNREFUSED, Redis::BaseError, SocketError => e
raise(e) unless Split.configuration.db_failover
Split.configuration.db_failover_on_db_error.call(e)
else
control_variable(control)
end
rescue => e
raise(e) unless Split.configuration.db_failover
Split.configuration.db_failover_on_db_error.call(e)
if block_given?
metadata = experiment.metadata[alternative] if experiment.metadata
yield(alternative, metadata || {})
else
alternative
end
end
def reset!(experiment)
ab_user.delete(experiment.key)
end
def finish_experiment(experiment, options = { reset: true })
return false if active_experiments[experiment.name].nil?
return true if experiment.has_winner?
should_reset = experiment.resettable? && options[:reset]
if ab_user[experiment.finished_key] && !should_reset
true
else
alternative_name = ab_user[experiment.key]
trial = Trial.new(
user: ab_user,
experiment: experiment,
alternative: alternative_name,
goals: options[:goals],
)
trial.complete!(self)
if should_reset
reset!(experiment)
else
ab_user[experiment.finished_key] = true
end
end
end
def ab_finished(metric_descriptor, options = { reset: true })
return if exclude_visitor? || Split.configuration.disabled?
metric_descriptor, goals = normalize_metric(metric_descriptor)
experiments = Metric.possible_experiments(metric_descriptor)
if experiments.any?
experiments.each do |experiment|
next if override_present?(experiment.key)
finish_experiment(experiment, options.merge(goals: goals))
end
end
rescue => e
raise unless Split.configuration.db_failover
Split.configuration.db_failover_on_db_error.call(e)
end
def ab_record_extra_info(metric_descriptor, key, value = 1)
return if exclude_visitor? || Split.configuration.disabled?
metric_descriptor, _ = normalize_metric(metric_descriptor)
experiments = Metric.possible_experiments(metric_descriptor)
if experiments.any?
experiments.each do |experiment|
alternative_name = ab_user[experiment.key]
if alternative_name
alternative = experiment.alternatives.find { |alt| alt.name == alternative_name }
alternative.record_extra_info(key, value) if alternative
end
end
end
rescue => e
raise unless Split.configuration.db_failover
Split.configuration.db_failover_on_db_error.call(e)
end
def ab_active_experiments
ab_user.active_experiments
rescue => e
raise unless Split.configuration.db_failover
Split.configuration.db_failover_on_db_error.call(e)
end
def override_present?(experiment_name)
override_alternative_by_params(experiment_name) || override_alternative_by_cookies(experiment_name)
end
def override_alternative(experiment_name)
override_alternative_by_params(experiment_name) || override_alternative_by_cookies(experiment_name)
end
def override_alternative_by_params(experiment_name)
defined?(params) && params[OVERRIDE_PARAM_NAME] && params[OVERRIDE_PARAM_NAME][experiment_name]
end
def override_alternative_by_cookies(experiment_name)
return unless defined?(request)
if request.cookies && request.cookies.key?("split_override")
experiments = JSON.parse(request.cookies["split_override"]) rescue {}
experiments[experiment_name]
end
end
def split_generically_disabled?
defined?(params) && params["SPLIT_DISABLE"]
end
def ab_user
@ab_user ||= User.new(self)
end
def exclude_visitor?
defined?(request) && (instance_exec(request, &Split.configuration.ignore_filter) || is_ignored_ip_address? || is_robot? || is_preview?)
end
def is_robot?
defined?(request) && request.user_agent =~ Split.configuration.robot_regex
end
def is_preview?
defined?(request) && defined?(request.headers) && request.headers["x-purpose"] == "preview"
end
def is_ignored_ip_address?
return false if Split.configuration.ignore_ip_addresses.empty?
Split.configuration.ignore_ip_addresses.each do |ip|
return true if defined?(request) && (request.ip == ip || (ip.class == Regexp && request.ip =~ ip))
end
false
end
def active_experiments
ab_user.active_experiments
end
def normalize_metric(metric_descriptor)
if Hash === metric_descriptor
experiment_name = metric_descriptor.keys.first
goals = Array(metric_descriptor.values.first)
else
experiment_name = metric_descriptor
goals = []
end
return experiment_name, goals
end
def control_variable(control)
Hash === control ? control.keys.first.to_s : control.to_s
end
end
end
<MSG> Only rescue from known expected error
<DFF> @@ -27,7 +27,7 @@ module Split
else
control_variable(control)
end
- rescue => e
+ rescue Errno::ECONNREFUSED => e
raise(e) unless Split.configuration.db_failover
Split.configuration.db_failover_on_db_error.call(e)
| 1 | Only rescue from known expected error | 1 | .rb | rb | mit | splitrb/split |
10071626 | <NME> helper.rb
<BEF> # frozen_string_literal: true
module Split
module Helper
OVERRIDE_PARAM_NAME = "ab_test"
module_function
def ab_test(metric_descriptor, control = nil, *alternatives)
begin
experiment = ExperimentCatalog.find_or_initialize(metric_descriptor, control, *alternatives)
alternative = if Split.configuration.enabled && !exclude_visitor?
experiment.save
raise(Split::InvalidExperimentsFormatError) unless (Split.configuration.experiments || {}).fetch(experiment.name.to_sym, {})[:combined_experiments].nil?
trial = Trial.new(user: ab_user, experiment: experiment,
override: override_alternative(experiment.name), exclude: exclude_visitor?,
disabled: split_generically_disabled?)
alt = trial.choose!(self)
alt ? alt.name : nil
else
control_variable(experiment.control)
end
rescue Errno::ECONNREFUSED, Redis::BaseError, SocketError => e
raise(e) unless Split.configuration.db_failover
Split.configuration.db_failover_on_db_error.call(e)
else
control_variable(control)
end
rescue => e
raise(e) unless Split.configuration.db_failover
Split.configuration.db_failover_on_db_error.call(e)
if block_given?
metadata = experiment.metadata[alternative] if experiment.metadata
yield(alternative, metadata || {})
else
alternative
end
end
def reset!(experiment)
ab_user.delete(experiment.key)
end
def finish_experiment(experiment, options = { reset: true })
return false if active_experiments[experiment.name].nil?
return true if experiment.has_winner?
should_reset = experiment.resettable? && options[:reset]
if ab_user[experiment.finished_key] && !should_reset
true
else
alternative_name = ab_user[experiment.key]
trial = Trial.new(
user: ab_user,
experiment: experiment,
alternative: alternative_name,
goals: options[:goals],
)
trial.complete!(self)
if should_reset
reset!(experiment)
else
ab_user[experiment.finished_key] = true
end
end
end
def ab_finished(metric_descriptor, options = { reset: true })
return if exclude_visitor? || Split.configuration.disabled?
metric_descriptor, goals = normalize_metric(metric_descriptor)
experiments = Metric.possible_experiments(metric_descriptor)
if experiments.any?
experiments.each do |experiment|
next if override_present?(experiment.key)
finish_experiment(experiment, options.merge(goals: goals))
end
end
rescue => e
raise unless Split.configuration.db_failover
Split.configuration.db_failover_on_db_error.call(e)
end
def ab_record_extra_info(metric_descriptor, key, value = 1)
return if exclude_visitor? || Split.configuration.disabled?
metric_descriptor, _ = normalize_metric(metric_descriptor)
experiments = Metric.possible_experiments(metric_descriptor)
if experiments.any?
experiments.each do |experiment|
alternative_name = ab_user[experiment.key]
if alternative_name
alternative = experiment.alternatives.find { |alt| alt.name == alternative_name }
alternative.record_extra_info(key, value) if alternative
end
end
end
rescue => e
raise unless Split.configuration.db_failover
Split.configuration.db_failover_on_db_error.call(e)
end
def ab_active_experiments
ab_user.active_experiments
rescue => e
raise unless Split.configuration.db_failover
Split.configuration.db_failover_on_db_error.call(e)
end
def override_present?(experiment_name)
override_alternative_by_params(experiment_name) || override_alternative_by_cookies(experiment_name)
end
def override_alternative(experiment_name)
override_alternative_by_params(experiment_name) || override_alternative_by_cookies(experiment_name)
end
def override_alternative_by_params(experiment_name)
defined?(params) && params[OVERRIDE_PARAM_NAME] && params[OVERRIDE_PARAM_NAME][experiment_name]
end
def override_alternative_by_cookies(experiment_name)
return unless defined?(request)
if request.cookies && request.cookies.key?("split_override")
experiments = JSON.parse(request.cookies["split_override"]) rescue {}
experiments[experiment_name]
end
end
def split_generically_disabled?
defined?(params) && params["SPLIT_DISABLE"]
end
def ab_user
@ab_user ||= User.new(self)
end
def exclude_visitor?
defined?(request) && (instance_exec(request, &Split.configuration.ignore_filter) || is_ignored_ip_address? || is_robot? || is_preview?)
end
def is_robot?
defined?(request) && request.user_agent =~ Split.configuration.robot_regex
end
def is_preview?
defined?(request) && defined?(request.headers) && request.headers["x-purpose"] == "preview"
end
def is_ignored_ip_address?
return false if Split.configuration.ignore_ip_addresses.empty?
Split.configuration.ignore_ip_addresses.each do |ip|
return true if defined?(request) && (request.ip == ip || (ip.class == Regexp && request.ip =~ ip))
end
false
end
def active_experiments
ab_user.active_experiments
end
def normalize_metric(metric_descriptor)
if Hash === metric_descriptor
experiment_name = metric_descriptor.keys.first
goals = Array(metric_descriptor.values.first)
else
experiment_name = metric_descriptor
goals = []
end
return experiment_name, goals
end
def control_variable(control)
Hash === control ? control.keys.first.to_s : control.to_s
end
end
end
<MSG> Only rescue from known expected error
<DFF> @@ -27,7 +27,7 @@ module Split
else
control_variable(control)
end
- rescue => e
+ rescue Errno::ECONNREFUSED => e
raise(e) unless Split.configuration.db_failover
Split.configuration.db_failover_on_db_error.call(e)
| 1 | Only rescue from known expected error | 1 | .rb | rb | mit | splitrb/split |
10071627 | <NME> helper.rb
<BEF> # frozen_string_literal: true
module Split
module Helper
OVERRIDE_PARAM_NAME = "ab_test"
module_function
def ab_test(metric_descriptor, control = nil, *alternatives)
begin
experiment = ExperimentCatalog.find_or_initialize(metric_descriptor, control, *alternatives)
alternative = if Split.configuration.enabled && !exclude_visitor?
experiment.save
raise(Split::InvalidExperimentsFormatError) unless (Split.configuration.experiments || {}).fetch(experiment.name.to_sym, {})[:combined_experiments].nil?
trial = Trial.new(user: ab_user, experiment: experiment,
override: override_alternative(experiment.name), exclude: exclude_visitor?,
disabled: split_generically_disabled?)
alt = trial.choose!(self)
alt ? alt.name : nil
else
control_variable(experiment.control)
end
rescue Errno::ECONNREFUSED, Redis::BaseError, SocketError => e
raise(e) unless Split.configuration.db_failover
Split.configuration.db_failover_on_db_error.call(e)
else
control_variable(control)
end
rescue => e
raise(e) unless Split.configuration.db_failover
Split.configuration.db_failover_on_db_error.call(e)
if block_given?
metadata = experiment.metadata[alternative] if experiment.metadata
yield(alternative, metadata || {})
else
alternative
end
end
def reset!(experiment)
ab_user.delete(experiment.key)
end
def finish_experiment(experiment, options = { reset: true })
return false if active_experiments[experiment.name].nil?
return true if experiment.has_winner?
should_reset = experiment.resettable? && options[:reset]
if ab_user[experiment.finished_key] && !should_reset
true
else
alternative_name = ab_user[experiment.key]
trial = Trial.new(
user: ab_user,
experiment: experiment,
alternative: alternative_name,
goals: options[:goals],
)
trial.complete!(self)
if should_reset
reset!(experiment)
else
ab_user[experiment.finished_key] = true
end
end
end
def ab_finished(metric_descriptor, options = { reset: true })
return if exclude_visitor? || Split.configuration.disabled?
metric_descriptor, goals = normalize_metric(metric_descriptor)
experiments = Metric.possible_experiments(metric_descriptor)
if experiments.any?
experiments.each do |experiment|
next if override_present?(experiment.key)
finish_experiment(experiment, options.merge(goals: goals))
end
end
rescue => e
raise unless Split.configuration.db_failover
Split.configuration.db_failover_on_db_error.call(e)
end
def ab_record_extra_info(metric_descriptor, key, value = 1)
return if exclude_visitor? || Split.configuration.disabled?
metric_descriptor, _ = normalize_metric(metric_descriptor)
experiments = Metric.possible_experiments(metric_descriptor)
if experiments.any?
experiments.each do |experiment|
alternative_name = ab_user[experiment.key]
if alternative_name
alternative = experiment.alternatives.find { |alt| alt.name == alternative_name }
alternative.record_extra_info(key, value) if alternative
end
end
end
rescue => e
raise unless Split.configuration.db_failover
Split.configuration.db_failover_on_db_error.call(e)
end
def ab_active_experiments
ab_user.active_experiments
rescue => e
raise unless Split.configuration.db_failover
Split.configuration.db_failover_on_db_error.call(e)
end
def override_present?(experiment_name)
override_alternative_by_params(experiment_name) || override_alternative_by_cookies(experiment_name)
end
def override_alternative(experiment_name)
override_alternative_by_params(experiment_name) || override_alternative_by_cookies(experiment_name)
end
def override_alternative_by_params(experiment_name)
defined?(params) && params[OVERRIDE_PARAM_NAME] && params[OVERRIDE_PARAM_NAME][experiment_name]
end
def override_alternative_by_cookies(experiment_name)
return unless defined?(request)
if request.cookies && request.cookies.key?("split_override")
experiments = JSON.parse(request.cookies["split_override"]) rescue {}
experiments[experiment_name]
end
end
def split_generically_disabled?
defined?(params) && params["SPLIT_DISABLE"]
end
def ab_user
@ab_user ||= User.new(self)
end
def exclude_visitor?
defined?(request) && (instance_exec(request, &Split.configuration.ignore_filter) || is_ignored_ip_address? || is_robot? || is_preview?)
end
def is_robot?
defined?(request) && request.user_agent =~ Split.configuration.robot_regex
end
def is_preview?
defined?(request) && defined?(request.headers) && request.headers["x-purpose"] == "preview"
end
def is_ignored_ip_address?
return false if Split.configuration.ignore_ip_addresses.empty?
Split.configuration.ignore_ip_addresses.each do |ip|
return true if defined?(request) && (request.ip == ip || (ip.class == Regexp && request.ip =~ ip))
end
false
end
def active_experiments
ab_user.active_experiments
end
def normalize_metric(metric_descriptor)
if Hash === metric_descriptor
experiment_name = metric_descriptor.keys.first
goals = Array(metric_descriptor.values.first)
else
experiment_name = metric_descriptor
goals = []
end
return experiment_name, goals
end
def control_variable(control)
Hash === control ? control.keys.first.to_s : control.to_s
end
end
end
<MSG> Only rescue from known expected error
<DFF> @@ -27,7 +27,7 @@ module Split
else
control_variable(control)
end
- rescue => e
+ rescue Errno::ECONNREFUSED => e
raise(e) unless Split.configuration.db_failover
Split.configuration.db_failover_on_db_error.call(e)
| 1 | Only rescue from known expected error | 1 | .rb | rb | mit | splitrb/split |
10071628 | <NME> spec_helper.rb
<BEF> require 'rubygems'
require 'bundler/setup'
require 'split'
require "bundler/setup"
require "simplecov"
SimpleCov.start
require "split"
require "ostruct"
require "yaml"
Dir["./spec/support/*.rb"].each { |f| require f }
module GlobalSharedContext
extend RSpec::SharedContext
let(:mock_user) { Split::User.new(double(session: {})) }
before(:each) do
Split.configuration = Split::Configuration.new
Split.redis = Redis.new
Split.redis.select(10)
Split.redis.flushdb
Split::Cache.clear
@ab_user = mock_user
@params = nil
end
end
RSpec.configure do |config|
config.order = "random"
config.include GlobalSharedContext
config.raise_errors_for_deprecations!
end
def session
@session ||= {}
end
def params
@params ||= {}
end
def request(ua = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; de-de) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27")
@request ||= begin
r = OpenStruct.new
r.user_agent = ua
r.ip = "192.168.1.1"
r
end
end
<MSG> Made testing the dashboard a little easier
<DFF> @@ -1,3 +1,5 @@
+ENV['RACK_ENV'] = "test"
+
require 'rubygems'
require 'bundler/setup'
require 'split'
| 2 | Made testing the dashboard a little easier | 0 | .rb | rb | mit | splitrb/split |
10071629 | <NME> spec_helper.rb
<BEF> require 'rubygems'
require 'bundler/setup'
require 'split'
require "bundler/setup"
require "simplecov"
SimpleCov.start
require "split"
require "ostruct"
require "yaml"
Dir["./spec/support/*.rb"].each { |f| require f }
module GlobalSharedContext
extend RSpec::SharedContext
let(:mock_user) { Split::User.new(double(session: {})) }
before(:each) do
Split.configuration = Split::Configuration.new
Split.redis = Redis.new
Split.redis.select(10)
Split.redis.flushdb
Split::Cache.clear
@ab_user = mock_user
@params = nil
end
end
RSpec.configure do |config|
config.order = "random"
config.include GlobalSharedContext
config.raise_errors_for_deprecations!
end
def session
@session ||= {}
end
def params
@params ||= {}
end
def request(ua = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; de-de) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27")
@request ||= begin
r = OpenStruct.new
r.user_agent = ua
r.ip = "192.168.1.1"
r
end
end
<MSG> Made testing the dashboard a little easier
<DFF> @@ -1,3 +1,5 @@
+ENV['RACK_ENV'] = "test"
+
require 'rubygems'
require 'bundler/setup'
require 'split'
| 2 | Made testing the dashboard a little easier | 0 | .rb | rb | mit | splitrb/split |
10071630 | <NME> spec_helper.rb
<BEF> require 'rubygems'
require 'bundler/setup'
require 'split'
require "bundler/setup"
require "simplecov"
SimpleCov.start
require "split"
require "ostruct"
require "yaml"
Dir["./spec/support/*.rb"].each { |f| require f }
module GlobalSharedContext
extend RSpec::SharedContext
let(:mock_user) { Split::User.new(double(session: {})) }
before(:each) do
Split.configuration = Split::Configuration.new
Split.redis = Redis.new
Split.redis.select(10)
Split.redis.flushdb
Split::Cache.clear
@ab_user = mock_user
@params = nil
end
end
RSpec.configure do |config|
config.order = "random"
config.include GlobalSharedContext
config.raise_errors_for_deprecations!
end
def session
@session ||= {}
end
def params
@params ||= {}
end
def request(ua = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; de-de) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27")
@request ||= begin
r = OpenStruct.new
r.user_agent = ua
r.ip = "192.168.1.1"
r
end
end
<MSG> Made testing the dashboard a little easier
<DFF> @@ -1,3 +1,5 @@
+ENV['RACK_ENV'] = "test"
+
require 'rubygems'
require 'bundler/setup'
require 'split'
| 2 | Made testing the dashboard a little easier | 0 | .rb | rb | mit | splitrb/split |
10071631 | <NME> configuration.rb
<BEF> # frozen_string_literal: true
module Split
class Configuration
attr_accessor :ignore_ip_addresses
attr_accessor :ignore_filter
attr_accessor :db_failover
attr_accessor :db_failover_on_db_error
attr_accessor :db_failover_allow_parameter_override
attr_accessor :allow_multiple_experiments
attr_accessor :enabled
attr_accessor :persistence
attr_accessor :persistence_cookie_length
attr_accessor :persistence_cookie_domain
attr_accessor :algorithm
attr_accessor :store_override
attr_accessor :start_manually
attr_accessor :reset_manually
attr_accessor :on_trial
attr_accessor :on_trial_choose
attr_accessor :on_trial_complete
attr_accessor :on_experiment_reset
attr_accessor :on_experiment_delete
attr_accessor :on_before_experiment_reset
attr_accessor :on_experiment_winner_choose
attr_accessor :on_before_experiment_delete
attr_accessor :include_rails_helper
attr_accessor :beta_probability_simulations
attr_accessor :winning_alternative_recalculation_interval
attr_accessor :redis
attr_accessor :dashboard_pagination_default_per_page
attr_accessor :cache
attr_reader :experiments
attr_writer :bots
attr_writer :robot_regex
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",
# 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",
# URL expanders / previewers
"awe.sm" => "Awe.sm URL expander",
"bitlybot" => "bit.ly bot",
"[email protected]" => "Linkfluence bot",
'LinkedInBot' => 'LinkedIn bot',
'LongURL' => 'URL expander service',
'NING' => 'NING - Yet Another Twitter Swarmer',
'Pinterest' => 'Pinterest Bot',
'redditbot' => 'Reddit Bot',
'ShortLinkTranslate' => 'Link shortener',
'Slackbot' => 'Slackbot link expander',
"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",
# ???
"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)
@experiments = experiments
end
def disabled?
!enabled
end
def experiment_for(name)
if normalized_experiments
# TODO symbols
normalized_experiments[name.to_sym]
end
end
def metrics
return @metrics if defined?(@metrics)
@metrics = {}
if self.experiments
self.experiments.each do |key, value|
metrics = value_for(value, :metric) rescue nil
Array(metrics).each do |metric_name|
if metric_name
@metrics[metric_name.to_sym] ||= []
@metrics[metric_name.to_sym] << Split::Experiment.new(key)
end
end
end
end
@metrics
end
def normalized_experiments
return nil if @experiments.nil?
experiment_config = {}
@experiments.keys.each do |name|
experiment_config[name.to_sym] = {}
end
@experiments.each do |experiment_name, settings|
alternatives = if (alts = value_for(settings, :alternatives))
normalize_alternatives(alts)
end
experiment_data = {
alternatives: alternatives,
goals: value_for(settings, :goals),
metadata: value_for(settings, :metadata),
algorithm: value_for(settings, :algorithm),
resettable: value_for(settings, :resettable)
}
experiment_data.each do |name, value|
experiment_config[experiment_name.to_sym][name] = value if value != nil
end
end
experiment_config
end
def normalize_alternatives(alternatives)
given_probability, num_with_probability = alternatives.inject([0, 0]) do |a, v|
p, n = a
if percent = value_for(v, :percent)
[p + percent, n + 1]
else
a
end
end
num_without_probability = alternatives.length - num_with_probability
unassigned_probability = ((100.0 - given_probability) / num_without_probability / 100.0)
if num_with_probability.nonzero?
alternatives = alternatives.map do |v|
if (name = value_for(v, :name)) && (percent = value_for(v, :percent))
{ name => percent / 100.0 }
elsif name = value_for(v, :name)
{ name => unassigned_probability }
else
{ v => unassigned_probability }
end
end
[alternatives.shift, alternatives]
else
alternatives = alternatives.dup
[alternatives.shift, alternatives]
end
end
def robot_regex
@robot_regex ||= /\b(?:#{escaped_bots.join('|')})\b|\A\W*\z/i
end
def initialize
@ignore_ip_addresses = []
@ignore_filter = proc { |request| is_robot? || is_ignored_ip_address? }
@db_failover = false
@db_failover_on_db_error = proc { |error| } # e.g. use Rails logger here
@on_experiment_reset = proc { |experiment| }
@on_experiment_delete = proc { |experiment| }
@on_before_experiment_reset = proc { |experiment| }
@on_before_experiment_delete = proc { |experiment| }
@on_experiment_winner_choose = proc { |experiment| }
@db_failover_allow_parameter_override = false
@allow_multiple_experiments = false
@enabled = true
@experiments = {}
@persistence = Split::Persistence::SessionAdapter
@persistence_cookie_length = 31536000 # One year from now
@persistence_cookie_domain = nil
@algorithm = Split::Algorithms::WeightedSample
@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")
@dashboard_pagination_default_per_page = 10
end
private
def value_for(hash, key)
if hash.kind_of?(Hash)
hash.has_key?(key.to_s) ? hash[key.to_s] : hash[key.to_sym]
end
end
def escaped_bots
bots.map { |key, _| Regexp.escape(key) }
end
end
end
<MSG> Merge pull request #606 from huoxito/pinterestbot
Only block Pinterest bot
<DFF> @@ -84,7 +84,7 @@ module Split
'LinkedInBot' => 'LinkedIn bot',
'LongURL' => 'URL expander service',
'NING' => 'NING - Yet Another Twitter Swarmer',
- 'Pinterest' => 'Pinterest Bot',
+ 'Pinterestbot' => 'Pinterest Bot',
'redditbot' => 'Reddit Bot',
'ShortLinkTranslate' => 'Link shortener',
'Slackbot' => 'Slackbot link expander',
| 1 | Merge pull request #606 from huoxito/pinterestbot | 1 | .rb | rb | mit | splitrb/split |
10071632 | <NME> configuration.rb
<BEF> # frozen_string_literal: true
module Split
class Configuration
attr_accessor :ignore_ip_addresses
attr_accessor :ignore_filter
attr_accessor :db_failover
attr_accessor :db_failover_on_db_error
attr_accessor :db_failover_allow_parameter_override
attr_accessor :allow_multiple_experiments
attr_accessor :enabled
attr_accessor :persistence
attr_accessor :persistence_cookie_length
attr_accessor :persistence_cookie_domain
attr_accessor :algorithm
attr_accessor :store_override
attr_accessor :start_manually
attr_accessor :reset_manually
attr_accessor :on_trial
attr_accessor :on_trial_choose
attr_accessor :on_trial_complete
attr_accessor :on_experiment_reset
attr_accessor :on_experiment_delete
attr_accessor :on_before_experiment_reset
attr_accessor :on_experiment_winner_choose
attr_accessor :on_before_experiment_delete
attr_accessor :include_rails_helper
attr_accessor :beta_probability_simulations
attr_accessor :winning_alternative_recalculation_interval
attr_accessor :redis
attr_accessor :dashboard_pagination_default_per_page
attr_accessor :cache
attr_reader :experiments
attr_writer :bots
attr_writer :robot_regex
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",
# 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",
# URL expanders / previewers
"awe.sm" => "Awe.sm URL expander",
"bitlybot" => "bit.ly bot",
"[email protected]" => "Linkfluence bot",
'LinkedInBot' => 'LinkedIn bot',
'LongURL' => 'URL expander service',
'NING' => 'NING - Yet Another Twitter Swarmer',
'Pinterest' => 'Pinterest Bot',
'redditbot' => 'Reddit Bot',
'ShortLinkTranslate' => 'Link shortener',
'Slackbot' => 'Slackbot link expander',
"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",
# ???
"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)
@experiments = experiments
end
def disabled?
!enabled
end
def experiment_for(name)
if normalized_experiments
# TODO symbols
normalized_experiments[name.to_sym]
end
end
def metrics
return @metrics if defined?(@metrics)
@metrics = {}
if self.experiments
self.experiments.each do |key, value|
metrics = value_for(value, :metric) rescue nil
Array(metrics).each do |metric_name|
if metric_name
@metrics[metric_name.to_sym] ||= []
@metrics[metric_name.to_sym] << Split::Experiment.new(key)
end
end
end
end
@metrics
end
def normalized_experiments
return nil if @experiments.nil?
experiment_config = {}
@experiments.keys.each do |name|
experiment_config[name.to_sym] = {}
end
@experiments.each do |experiment_name, settings|
alternatives = if (alts = value_for(settings, :alternatives))
normalize_alternatives(alts)
end
experiment_data = {
alternatives: alternatives,
goals: value_for(settings, :goals),
metadata: value_for(settings, :metadata),
algorithm: value_for(settings, :algorithm),
resettable: value_for(settings, :resettable)
}
experiment_data.each do |name, value|
experiment_config[experiment_name.to_sym][name] = value if value != nil
end
end
experiment_config
end
def normalize_alternatives(alternatives)
given_probability, num_with_probability = alternatives.inject([0, 0]) do |a, v|
p, n = a
if percent = value_for(v, :percent)
[p + percent, n + 1]
else
a
end
end
num_without_probability = alternatives.length - num_with_probability
unassigned_probability = ((100.0 - given_probability) / num_without_probability / 100.0)
if num_with_probability.nonzero?
alternatives = alternatives.map do |v|
if (name = value_for(v, :name)) && (percent = value_for(v, :percent))
{ name => percent / 100.0 }
elsif name = value_for(v, :name)
{ name => unassigned_probability }
else
{ v => unassigned_probability }
end
end
[alternatives.shift, alternatives]
else
alternatives = alternatives.dup
[alternatives.shift, alternatives]
end
end
def robot_regex
@robot_regex ||= /\b(?:#{escaped_bots.join('|')})\b|\A\W*\z/i
end
def initialize
@ignore_ip_addresses = []
@ignore_filter = proc { |request| is_robot? || is_ignored_ip_address? }
@db_failover = false
@db_failover_on_db_error = proc { |error| } # e.g. use Rails logger here
@on_experiment_reset = proc { |experiment| }
@on_experiment_delete = proc { |experiment| }
@on_before_experiment_reset = proc { |experiment| }
@on_before_experiment_delete = proc { |experiment| }
@on_experiment_winner_choose = proc { |experiment| }
@db_failover_allow_parameter_override = false
@allow_multiple_experiments = false
@enabled = true
@experiments = {}
@persistence = Split::Persistence::SessionAdapter
@persistence_cookie_length = 31536000 # One year from now
@persistence_cookie_domain = nil
@algorithm = Split::Algorithms::WeightedSample
@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")
@dashboard_pagination_default_per_page = 10
end
private
def value_for(hash, key)
if hash.kind_of?(Hash)
hash.has_key?(key.to_s) ? hash[key.to_s] : hash[key.to_sym]
end
end
def escaped_bots
bots.map { |key, _| Regexp.escape(key) }
end
end
end
<MSG> Merge pull request #606 from huoxito/pinterestbot
Only block Pinterest bot
<DFF> @@ -84,7 +84,7 @@ module Split
'LinkedInBot' => 'LinkedIn bot',
'LongURL' => 'URL expander service',
'NING' => 'NING - Yet Another Twitter Swarmer',
- 'Pinterest' => 'Pinterest Bot',
+ 'Pinterestbot' => 'Pinterest Bot',
'redditbot' => 'Reddit Bot',
'ShortLinkTranslate' => 'Link shortener',
'Slackbot' => 'Slackbot link expander',
| 1 | Merge pull request #606 from huoxito/pinterestbot | 1 | .rb | rb | mit | splitrb/split |
10071633 | <NME> configuration.rb
<BEF> # frozen_string_literal: true
module Split
class Configuration
attr_accessor :ignore_ip_addresses
attr_accessor :ignore_filter
attr_accessor :db_failover
attr_accessor :db_failover_on_db_error
attr_accessor :db_failover_allow_parameter_override
attr_accessor :allow_multiple_experiments
attr_accessor :enabled
attr_accessor :persistence
attr_accessor :persistence_cookie_length
attr_accessor :persistence_cookie_domain
attr_accessor :algorithm
attr_accessor :store_override
attr_accessor :start_manually
attr_accessor :reset_manually
attr_accessor :on_trial
attr_accessor :on_trial_choose
attr_accessor :on_trial_complete
attr_accessor :on_experiment_reset
attr_accessor :on_experiment_delete
attr_accessor :on_before_experiment_reset
attr_accessor :on_experiment_winner_choose
attr_accessor :on_before_experiment_delete
attr_accessor :include_rails_helper
attr_accessor :beta_probability_simulations
attr_accessor :winning_alternative_recalculation_interval
attr_accessor :redis
attr_accessor :dashboard_pagination_default_per_page
attr_accessor :cache
attr_reader :experiments
attr_writer :bots
attr_writer :robot_regex
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",
# 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",
# URL expanders / previewers
"awe.sm" => "Awe.sm URL expander",
"bitlybot" => "bit.ly bot",
"[email protected]" => "Linkfluence bot",
'LinkedInBot' => 'LinkedIn bot',
'LongURL' => 'URL expander service',
'NING' => 'NING - Yet Another Twitter Swarmer',
'Pinterest' => 'Pinterest Bot',
'redditbot' => 'Reddit Bot',
'ShortLinkTranslate' => 'Link shortener',
'Slackbot' => 'Slackbot link expander',
"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",
# ???
"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)
@experiments = experiments
end
def disabled?
!enabled
end
def experiment_for(name)
if normalized_experiments
# TODO symbols
normalized_experiments[name.to_sym]
end
end
def metrics
return @metrics if defined?(@metrics)
@metrics = {}
if self.experiments
self.experiments.each do |key, value|
metrics = value_for(value, :metric) rescue nil
Array(metrics).each do |metric_name|
if metric_name
@metrics[metric_name.to_sym] ||= []
@metrics[metric_name.to_sym] << Split::Experiment.new(key)
end
end
end
end
@metrics
end
def normalized_experiments
return nil if @experiments.nil?
experiment_config = {}
@experiments.keys.each do |name|
experiment_config[name.to_sym] = {}
end
@experiments.each do |experiment_name, settings|
alternatives = if (alts = value_for(settings, :alternatives))
normalize_alternatives(alts)
end
experiment_data = {
alternatives: alternatives,
goals: value_for(settings, :goals),
metadata: value_for(settings, :metadata),
algorithm: value_for(settings, :algorithm),
resettable: value_for(settings, :resettable)
}
experiment_data.each do |name, value|
experiment_config[experiment_name.to_sym][name] = value if value != nil
end
end
experiment_config
end
def normalize_alternatives(alternatives)
given_probability, num_with_probability = alternatives.inject([0, 0]) do |a, v|
p, n = a
if percent = value_for(v, :percent)
[p + percent, n + 1]
else
a
end
end
num_without_probability = alternatives.length - num_with_probability
unassigned_probability = ((100.0 - given_probability) / num_without_probability / 100.0)
if num_with_probability.nonzero?
alternatives = alternatives.map do |v|
if (name = value_for(v, :name)) && (percent = value_for(v, :percent))
{ name => percent / 100.0 }
elsif name = value_for(v, :name)
{ name => unassigned_probability }
else
{ v => unassigned_probability }
end
end
[alternatives.shift, alternatives]
else
alternatives = alternatives.dup
[alternatives.shift, alternatives]
end
end
def robot_regex
@robot_regex ||= /\b(?:#{escaped_bots.join('|')})\b|\A\W*\z/i
end
def initialize
@ignore_ip_addresses = []
@ignore_filter = proc { |request| is_robot? || is_ignored_ip_address? }
@db_failover = false
@db_failover_on_db_error = proc { |error| } # e.g. use Rails logger here
@on_experiment_reset = proc { |experiment| }
@on_experiment_delete = proc { |experiment| }
@on_before_experiment_reset = proc { |experiment| }
@on_before_experiment_delete = proc { |experiment| }
@on_experiment_winner_choose = proc { |experiment| }
@db_failover_allow_parameter_override = false
@allow_multiple_experiments = false
@enabled = true
@experiments = {}
@persistence = Split::Persistence::SessionAdapter
@persistence_cookie_length = 31536000 # One year from now
@persistence_cookie_domain = nil
@algorithm = Split::Algorithms::WeightedSample
@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")
@dashboard_pagination_default_per_page = 10
end
private
def value_for(hash, key)
if hash.kind_of?(Hash)
hash.has_key?(key.to_s) ? hash[key.to_s] : hash[key.to_sym]
end
end
def escaped_bots
bots.map { |key, _| Regexp.escape(key) }
end
end
end
<MSG> Merge pull request #606 from huoxito/pinterestbot
Only block Pinterest bot
<DFF> @@ -84,7 +84,7 @@ module Split
'LinkedInBot' => 'LinkedIn bot',
'LongURL' => 'URL expander service',
'NING' => 'NING - Yet Another Twitter Swarmer',
- 'Pinterest' => 'Pinterest Bot',
+ 'Pinterestbot' => 'Pinterest Bot',
'redditbot' => 'Reddit Bot',
'ShortLinkTranslate' => 'Link shortener',
'Slackbot' => 'Slackbot link expander',
| 1 | Merge pull request #606 from huoxito/pinterestbot | 1 | .rb | rb | mit | splitrb/split |
10071634 | <NME> helper_spec.rb
<BEF> # frozen_string_literal: true
require "spec_helper"
# TODO change some of these tests to use Rack::Test
describe Split::Helper do
include Split::Helper
let(:experiment) {
Split::ExperimentCatalog.find_or_create("link_color", "blue", "red")
}
describe "ab_test" do
it "should not raise an error when passed strings for alternatives" do
expect { ab_test("xyz", "1", "2", "3") }.not_to raise_error
end
it "should not raise an error when passed an array for alternatives" do
expect { ab_test("xyz", ["1", "2", "3"]) }.not_to raise_error
end
it "should raise the appropriate error when passed integers for alternatives" do
expect { ab_test("xyz", 1, 2, 3) }.to raise_error(ArgumentError)
end
lambda { ab_test({'link_color' => ["purchase", "refund"]}, 'blue', 'red') }.should_not raise_error
end
it "should raise the appropriate error when passed string for goals" do
lambda { ab_test({'link_color' => "purchase"}, 'blue', 'red') }.should raise_error(ArgumentError)
end
it "should assign a random alternative to a new user when there are an equal number of alternatives assigned" do
it "should not raise error when passed just one goal" do
expect { ab_test({ "link_color" => "purchase" }, "blue", "red") }.not_to raise_error
end
it "raises an appropriate error when processing combined expirements" do
Split.configuration.experiments = {
combined_exp_1: {
alternatives: [ { name: "control", percent: 50 }, { name: "test-alt", percent: 50 } ],
metric: :my_metric,
combined_experiments: [:combined_exp_1_sub_1]
}
}
Split::ExperimentCatalog.find_or_create("combined_exp_1")
expect { ab_test("combined_exp_1") }.to raise_error(Split::InvalidExperimentsFormatError)
end
it "should assign a random alternative to a new user when there are an equal number of alternatives assigned" do
ab_test("link_color", "blue", "red")
expect(["red", "blue"]).to include(ab_user["link_color"])
end
it "should increment the participation counter after assignment to a new user" do
previous_red_count = Split::Alternative.new("red", "link_color").participant_count
previous_blue_count = Split::Alternative.new("blue", "link_color").participant_count
ab_test("link_color", "blue", "red")
new_red_count = Split::Alternative.new("red", "link_color").participant_count
new_blue_count = Split::Alternative.new("blue", "link_color").participant_count
expect((new_red_count + new_blue_count)).to eq(previous_red_count + previous_blue_count + 1)
end
it "should not increment the counter for an experiment that the user is not participating in" do
ab_test("link_color", "blue", "red")
e = Split::ExperimentCatalog.find_or_create("button_size", "small", "big")
expect {
# User shouldn't participate in this second experiment
ab_test("button_size", "small", "big")
}.not_to change { e.participant_count }
end
it "should not increment the counter for an ended experiment" do
e = Split::ExperimentCatalog.find_or_create("button_size", "small", "big")
e.winner = "small"
expect {
a = ab_test("button_size", "small", "big")
expect(a).to eq("small")
}.not_to change { e.participant_count }
end
it "should not increment the counter for an not started experiment" do
expect(Split.configuration).to receive(:start_manually).and_return(true)
e = Split::ExperimentCatalog.find_or_create("button_size", "small", "big")
expect {
a = ab_test("button_size", "small", "big")
expect(a).to eq("small")
}.not_to change { e.participant_count }
end
it "should return the given alternative for an existing user" do
expect(ab_test("link_color", "blue", "red")).to eq ab_test("link_color", "blue", "red")
end
it "should always return the winner if one is present" do
experiment.winner = "orange"
expect(ab_test("link_color", "blue", "red")).to eq("orange")
end
it "should allow the alternative to be forced by passing it in the params" do
# ?ab_test[link_color]=blue
@params = { "ab_test" => { "link_color" => "blue" } }
alternative = ab_test("link_color", "blue", "red")
expect(alternative).to eq("blue")
alternative = ab_test("link_color", { "blue" => 1 }, "red" => 5)
expect(alternative).to eq("blue")
@params = { "ab_test" => { "link_color" => "red" } }
alternative = ab_test("link_color", "blue", "red")
expect(alternative).to eq("red")
alternative = ab_test("link_color", { "blue" => 5 }, "red" => 1)
expect(alternative).to eq("red")
end
it "should not allow an arbitrary alternative" do
@params = { "ab_test" => { "link_color" => "pink" } }
alternative = ab_test("link_color", "blue")
expect(alternative).to eq("blue")
end
it "should not store the split when a param forced alternative" do
@params = { "ab_test" => { "link_color" => "blue" } }
expect(ab_user).not_to receive(:[]=)
ab_test("link_color", "blue", "red")
end
it "SPLIT_DISABLE query parameter should also force the alternative (uses control)" do
@params = { "SPLIT_DISABLE" => "true" }
alternative = ab_test("link_color", "blue", "red")
expect(alternative).to eq("blue")
alternative = ab_test("link_color", { "blue" => 1 }, "red" => 5)
expect(alternative).to eq("blue")
alternative = ab_test("link_color", "red", "blue")
expect(alternative).to eq("red")
alternative = ab_test("link_color", { "red" => 5 }, "blue" => 1)
expect(alternative).to eq("red")
end
it "should not store the split when Split generically disabled" do
@params = { "SPLIT_DISABLE" => "true" }
expect(ab_user).not_to receive(:[]=)
ab_test("link_color", "blue", "red")
end
context "when store_override is set" do
before { Split.configuration.store_override = true }
it "should store the forced alternative" do
@params = { "ab_test" => { "link_color" => "blue" } }
expect(ab_user).to receive(:[]=).with("link_color", "blue")
ab_test("link_color", "blue", "red")
end
end
context "when on_trial_choose is set" do
before { Split.configuration.on_trial_choose = :some_method }
it "should call the method" do
expect(self).to receive(:some_method)
ab_test("link_color", "blue", "red")
end
end
it "should allow passing a block" do
alt = ab_test("link_color", "blue", "red")
ret = ab_test("link_color", "blue", "red") { |alternative| "shared/#{alternative}" }
expect(ret).to eq("shared/#{alt}")
end
it "should allow the share of visitors see an alternative to be specified" do
ab_test("link_color", { "blue" => 0.8 }, { "red" => 20 })
expect(["red", "blue"]).to include(ab_user["link_color"])
end
it "should allow alternative weighting interface as a single hash" do
ab_test("link_color", { "blue" => 0.01 }, "red" => 0.2)
experiment = Split::ExperimentCatalog.find("link_color")
expect(experiment.alternatives.map(&:name)).to eq(["blue", "red"])
expect(experiment.alternatives.collect { |a| a.weight }).to match_array([0.01, 0.2])
end
it "should only let a user participate in one experiment at a time" do
link_color = ab_test("link_color", "blue", "red")
ab_test("button_size", "small", "big")
expect(ab_user["link_color"]).to eq(link_color)
big = Split::Alternative.new("big", "button_size")
expect(big.participant_count).to eq(0)
small = Split::Alternative.new("small", "button_size")
expect(small.participant_count).to eq(0)
end
it "should let a user participate in many experiment with allow_multiple_experiments option" do
Split.configure do |config|
config.allow_multiple_experiments = true
end
link_color = ab_test("link_color", "blue", "red")
button_size = ab_test("button_size", "small", "big")
expect(ab_user["link_color"]).to eq(link_color)
expect(ab_user["button_size"]).to eq(button_size)
button_size_alt = Split::Alternative.new(button_size, "button_size")
expect(button_size_alt.participant_count).to eq(1)
end
context "with allow_multiple_experiments = 'control'" do
it "should let a user participate in many experiment with one non-'control' alternative" do
Split.configure do |config|
config.allow_multiple_experiments = "control"
end
groups = 100.times.map do |n|
ab_test("test#{n}".to_sym, { "control" => (100 - n) }, { "test#{n}-alt" => n })
end
experiments = ab_user.active_experiments
expect(experiments.size).to be > 1
count_control = experiments.values.count { |g| g == "control" }
expect(count_control).to eq(experiments.size - 1)
count_alts = groups.count { |g| g != "control" }
expect(count_alts).to eq(1)
end
context "when user already has experiment" do
let(:mock_user) { Split::User.new(self, { "test_0" => "test-alt" }) }
before do
Split.configure do |config|
config.allow_multiple_experiments = "control"
end
Split::ExperimentCatalog.find_or_initialize("test_0", "control", "test-alt").save
Split::ExperimentCatalog.find_or_initialize("test_1", "control", "test-alt").save
end
it "should restore previously selected alternative" do
expect(ab_user.active_experiments.size).to eq 1
expect(ab_test(:test_0, { "control" => 100 }, { "test-alt" => 1 })).to eq "test-alt"
expect(ab_test(:test_0, { "control" => 1 }, { "test-alt" => 100 })).to eq "test-alt"
end
it "should select the correct alternatives after experiment resets" do
experiment = Split::ExperimentCatalog.find(:test_0)
experiment.reset
mock_user[experiment.key] = "test-alt"
expect(ab_user.active_experiments.size).to eq 1
expect(ab_test(:test_0, { "control" => 100 }, { "test-alt" => 1 })).to eq "test-alt"
expect(ab_test(:test_0, { "control" => 0 }, { "test-alt" => 100 })).to eq "test-alt"
end
it "lets override existing choice" do
pending "this requires user store reset on first call not depending on whelther it is current trial"
@params = { "ab_test" => { "test_1" => "test-alt" } }
expect(ab_test(:test_0, { "control" => 0 }, { "test-alt" => 100 })).to eq "control"
expect(ab_test(:test_1, { "control" => 100 }, { "test-alt" => 1 })).to eq "test-alt"
end
end
end
it "should not over-write a finished key when an experiment is on a later version" do
experiment.increment_version
ab_user = { experiment.key => "blue", experiment.finished_key => true }
finished_session = ab_user.dup
ab_test("link_color", "blue", "red")
expect(ab_user).to eq(finished_session)
end
end
describe "metadata" do
context "is defined" do
before do
Split.configuration.experiments = {
my_experiment: {
alternatives: ["one", "two"],
resettable: false,
metadata: { "one" => "Meta1", "two" => "Meta2" }
}
}
end
it "should be passed to helper block" do
@params = { "ab_test" => { "my_experiment" => "two" } }
expect(ab_test("my_experiment")).to eq "two"
expect(ab_test("my_experiment") do |alternative, meta|
meta
end).to eq("Meta2")
end
it "should pass control metadata helper block if library disabled" do
Split.configure do |config|
config.enabled = false
end
expect(ab_test("my_experiment")).to eq "one"
expect(ab_test("my_experiment") do |_, meta|
meta
end).to eq("Meta1")
end
end
context "is not defined" do
before do
Split.configuration.experiments = {
my_experiment: {
alternatives: ["one", "two"],
resettable: false,
metadata: nil
}
}
end
it "should be passed to helper block" do
expect(ab_test("my_experiment") do |alternative, meta|
meta
end).to eq({})
end
it "should pass control metadata helper block if library disabled" do
Split.configure do |config|
config.enabled = false
end
expect(ab_test("my_experiment") do |_, meta|
meta
end).to eq({})
end
end
end
describe "ab_finished" do
context "for an experiment that the user participates in" do
before(:each) do
@experiment_name = "link_color"
@alternatives = ["blue", "red"]
@experiment = Split::ExperimentCatalog.find_or_create(@experiment_name, *@alternatives)
@alternative_name = ab_test(@experiment_name, *@alternatives)
@previous_completion_count = Split::Alternative.new(@alternative_name, @experiment_name).completed_count
end
it "should increment the counter for the completed alternative" do
ab_finished(@experiment_name)
new_completion_count = Split::Alternative.new(@alternative_name, @experiment_name).completed_count
expect(new_completion_count).to eq(@previous_completion_count + 1)
end
it "should set experiment's finished key if reset is false" do
ab_finished(@experiment_name, { reset: false })
expect(ab_user[@experiment.key]).to eq(@alternative_name)
expect(ab_user[@experiment.finished_key]).to eq(true)
end
it "should not increment the counter if reset is false and the experiment has been already finished" do
2.times { ab_finished(@experiment_name, { reset: false }) }
new_completion_count = Split::Alternative.new(@alternative_name, @experiment_name).completed_count
expect(new_completion_count).to eq(@previous_completion_count + 1)
end
it "should not increment the counter for an ended experiment" do
e = Split::ExperimentCatalog.find_or_create("button_size", "small", "big")
e.winner = "small"
a = ab_test("button_size", "small", "big")
expect(a).to eq("small")
expect {
ab_finished("button_size")
}.not_to change { Split::Alternative.new(a, "button_size").completed_count }
end
it "should clear out the user's participation from their session" do
expect(ab_user[@experiment.key]).to eq(@alternative_name)
ab_finished(@experiment_name)
expect(ab_user.keys).to be_empty
end
it "should not clear out the users session if reset is false" do
expect(ab_user[@experiment.key]).to eq(@alternative_name)
ab_finished(@experiment_name, { reset: false })
expect(ab_user[@experiment.key]).to eq(@alternative_name)
expect(ab_user[@experiment.finished_key]).to eq(true)
end
it "should reset the users session when experiment is not versioned" do
expect(ab_user[@experiment.key]).to eq(@alternative_name)
ab_finished(@experiment_name)
expect(ab_user.keys).to be_empty
end
it "should reset the users session when experiment is versioned" do
@experiment.increment_version
@alternative_name = ab_test(@experiment_name, *@alternatives)
expect(ab_user[@experiment.key]).to eq(@alternative_name)
ab_finished(@experiment_name)
expect(ab_user.keys).to be_empty
end
context "when on_trial_complete is set" do
before { Split.configuration.on_trial_complete = :some_method }
it "should call the method" do
expect(self).to receive(:some_method)
ab_finished(@experiment_name)
end
it "should not call the method without alternative" do
ab_user[@experiment.key] = nil
expect(self).not_to receive(:some_method)
ab_finished(@experiment_name)
end
end
end
context "for an experiment that the user is excluded from" do
before do
alternative = ab_test("link_color", "blue", "red")
expect(Split::Alternative.new(alternative, "link_color").participant_count).to eq(1)
alternative = ab_test("button_size", "small", "big")
expect(Split::Alternative.new(alternative, "button_size").participant_count).to eq(0)
end
it "should not increment the completed counter" do
# So, user should be participating in the link_color experiment and
# receive the control for button_size. As the user is not participating in
# the button size experiment, finishing it should not increase the
# completion count for that alternative.
expect {
ab_finished("button_size")
}.not_to change { Split::Alternative.new("small", "button_size").completed_count }
end
end
context "for an experiment that the user does not participate in" do
before do
Split::ExperimentCatalog.find_or_create(:not_started_experiment, "control", "alt")
end
it "should not raise an exception" do
expect { ab_finished(:not_started_experiment) }.not_to raise_exception
end
it "should not change the user state when reset is false" do
expect { ab_finished(:not_started_experiment, reset: false) }.not_to change { ab_user.keys }.from([])
end
it "should not change the user state when reset is true" do
expect(self).not_to receive(:reset!)
ab_finished(:not_started_experiment)
end
it "should not increment the completed counter" do
ab_finished(:not_started_experiment)
expect(Split::Alternative.new("control", :not_started_experiment).completed_count).to eq(0)
expect(Split::Alternative.new("alt", :not_started_experiment).completed_count).to eq(0)
end
end
end
context "finished with config" do
it "passes reset option" do
Split.configuration.experiments = {
my_experiment: {
alternatives: ["one", "two"],
resettable: false,
}
}
alternative = ab_test(:my_experiment)
experiment = Split::ExperimentCatalog.find :my_experiment
ab_finished :my_experiment
expect(ab_user[experiment.key]).to eq(alternative)
expect(ab_user[experiment.finished_key]).to eq(true)
end
end
context "finished with metric name" do
before { Split.configuration.experiments = {} }
before { expect(Split::Alternative).to receive(:new).at_least(1).times.and_call_original }
def should_finish_experiment(experiment_name, should_finish = true)
alts = Split.configuration.experiments[experiment_name][:alternatives]
experiment = Split::ExperimentCatalog.find_or_create(experiment_name, *alts)
alt_name = ab_user[experiment.key] = alts.first
alt = double("alternative")
expect(alt).to receive(:name).at_most(1).times.and_return(alt_name)
expect(Split::Alternative).to receive(:new).at_most(1).times.with(alt_name, experiment_name.to_s).and_return(alt)
if should_finish
expect(alt).to receive(:increment_completion).at_most(1).times
else
expect(alt).not_to receive(:increment_completion)
end
end
it "completes the test" do
Split.configuration.experiments[:my_experiment] = {
alternatives: [ "control_opt", "other_opt" ],
metric: :my_metric
}
should_finish_experiment :my_experiment
ab_finished :my_metric
end
it "completes all relevant tests" do
Split.configuration.experiments = {
exp_1: {
alternatives: [ "1-1", "1-2" ],
metric: :my_metric
},
exp_2: {
alternatives: [ "2-1", "2-2" ],
metric: :another_metric
},
exp_3: {
alternatives: [ "3-1", "3-2" ],
metric: :my_metric
},
}
should_finish_experiment :exp_1
should_finish_experiment :exp_2, false
should_finish_experiment :exp_3
ab_finished :my_metric
end
it "passes reset option" do
Split.configuration.experiments = {
my_exp: {
alternatives: ["one", "two"],
metric: :my_metric,
resettable: false,
}
}
alternative_name = ab_test(:my_exp)
exp = Split::ExperimentCatalog.find :my_exp
ab_finished :my_metric
expect(ab_user[exp.key]).to eq(alternative_name)
expect(ab_user[exp.finished_key]).to be_truthy
end
it "passes through options" do
Split.configuration.experiments = {
my_exp: {
alternatives: ["one", "two"],
metric: :my_metric,
}
}
alternative_name = ab_test(:my_exp)
exp = Split::ExperimentCatalog.find :my_exp
ab_finished :my_metric, reset: false
expect(ab_user[exp.key]).to eq(alternative_name)
expect(ab_user[exp.finished_key]).to be_truthy
end
end
describe "conversions" do
it "should return a conversion rate for an alternative" do
alternative_name = ab_test("link_color", "blue", "red")
previous_convertion_rate = Split::Alternative.new(alternative_name, "link_color").conversion_rate
expect(previous_convertion_rate).to eq(0.0)
ab_finished("link_color")
new_convertion_rate = Split::Alternative.new(alternative_name, "link_color").conversion_rate
expect(new_convertion_rate).to eq(1.0)
end
end
describe "active experiments" do
it "should show an active test" do
alternative = ab_test("def", "4", "5", "6")
expect(active_experiments.count).to eq 1
expect(active_experiments.first[0]).to eq "def"
expect(active_experiments.first[1]).to eq alternative
end
it "should show a finished test" do
alternative = ab_test("def", "4", "5", "6")
ab_finished("def", { reset: false })
expect(active_experiments.count).to eq 1
expect(active_experiments.first[0]).to eq "def"
expect(active_experiments.first[1]).to eq alternative
end
it "should show an active test when an experiment is on a later version" do
experiment.reset
expect(experiment.version).to eq(1)
ab_test("link_color", "blue", "red")
expect(active_experiments.count).to eq 1
expect(active_experiments.first[0]).to eq "link_color"
end
it "should show versioned tests properly" do
10.times { experiment.reset }
alternative = ab_test(experiment.name, "blue", "red")
ab_finished(experiment.name, reset: false)
expect(experiment.version).to eq(10)
expect(active_experiments.count).to eq 1
expect(active_experiments).to eq({ "link_color" => alternative })
end
it "should show multiple tests" do
Split.configure do |config|
config.allow_multiple_experiments = true
end
alternative = ab_test("def", "4", "5", "6")
another_alternative = ab_test("ghi", "7", "8", "9")
expect(active_experiments.count).to eq 2
expect(active_experiments["def"]).to eq alternative
expect(active_experiments["ghi"]).to eq another_alternative
end
it "should not show tests with winners" do
Split.configure do |config|
config.allow_multiple_experiments = true
end
e = Split::ExperimentCatalog.find_or_create("def", "4", "5", "6")
e.winner = "4"
ab_test("def", "4", "5", "6")
another_alternative = ab_test("ghi", "7", "8", "9")
expect(active_experiments.count).to eq 1
expect(active_experiments.first[0]).to eq "ghi"
expect(active_experiments.first[1]).to eq another_alternative
end
end
describe "when user is a robot" do
before(:each) do
@request = OpenStruct.new(user_agent: "Googlebot/2.1 (+http://www.google.com/bot.html)")
end
describe "ab_test" do
it "should return the control" do
alternative = ab_test("link_color", "blue", "red")
expect(alternative).to eq experiment.control.name
end
it "should not create a experiment" do
ab_test("link_color", "blue", "red")
expect(Split::Experiment.new("link_color")).to be_a_new_record
end
it "should not increment the participation count" do
previous_red_count = Split::Alternative.new("red", "link_color").participant_count
previous_blue_count = Split::Alternative.new("blue", "link_color").participant_count
ab_test("link_color", "blue", "red")
new_red_count = Split::Alternative.new("red", "link_color").participant_count
new_blue_count = Split::Alternative.new("blue", "link_color").participant_count
expect((new_red_count + new_blue_count)).to eq(previous_red_count + previous_blue_count)
end
end
describe "finished" do
it "should not increment the completed count" do
alternative_name = ab_test("link_color", "blue", "red")
previous_completion_count = Split::Alternative.new(alternative_name, "link_color").completed_count
ab_finished("link_color")
new_completion_count = Split::Alternative.new(alternative_name, "link_color").completed_count
expect(new_completion_count).to eq(previous_completion_count)
end
end
end
describe "when providing custom ignore logic" do
context "using a proc to configure custom logic" do
before(:each) do
Split.configure do |c|
c.ignore_filter = proc { |request| true } # ignore everything
end
end
it "ignores the ab_test" do
ab_test("link_color", "blue", "red")
red_count = Split::Alternative.new("red", "link_color").participant_count
blue_count = Split::Alternative.new("blue", "link_color").participant_count
expect((red_count + blue_count)).to be(0)
end
end
end
shared_examples_for "a disabled test" do
describe "ab_test" do
it "should return the control" do
alternative = ab_test("link_color", "blue", "red")
expect(alternative).to eq experiment.control.name
end
it "should not increment the participation count" do
previous_red_count = Split::Alternative.new("red", "link_color").participant_count
previous_blue_count = Split::Alternative.new("blue", "link_color").participant_count
ab_test("link_color", "blue", "red")
new_red_count = Split::Alternative.new("red", "link_color").participant_count
new_blue_count = Split::Alternative.new("blue", "link_color").participant_count
expect((new_red_count + new_blue_count)).to eq(previous_red_count + previous_blue_count)
end
end
describe "finished" do
it "should not increment the completed count" do
alternative_name = ab_test("link_color", "blue", "red")
previous_completion_count = Split::Alternative.new(alternative_name, "link_color").completed_count
ab_finished("link_color")
new_completion_count = Split::Alternative.new(alternative_name, "link_color").completed_count
expect(new_completion_count).to eq(previous_completion_count)
end
end
end
describe "when ip address is ignored" do
context "individually" do
before(:each) do
@request = OpenStruct.new(ip: "81.19.48.130")
Split.configure do |c|
c.ignore_ip_addresses << "81.19.48.130"
end
end
it_behaves_like "a disabled test"
end
context "for a range" do
before(:each) do
@request = OpenStruct.new(ip: "81.19.48.129")
Split.configure do |c|
c.ignore_ip_addresses << /81\.19\.48\.[0-9]+/
end
end
it_behaves_like "a disabled test"
end
context "using both a range and a specific value" do
before(:each) do
@request = OpenStruct.new(ip: "81.19.48.128")
Split.configure do |c|
c.ignore_ip_addresses << "81.19.48.130"
c.ignore_ip_addresses << /81\.19\.48\.[0-9]+/
end
end
it_behaves_like "a disabled test"
end
context "when ignored other address" do
before do
@request = OpenStruct.new(ip: "1.1.1.1")
Split.configure do |c|
c.ignore_ip_addresses << "81.19.48.130"
end
end
it "works as usual" do
alternative_name = ab_test("link_color", "red", "blue")
expect {
ab_finished("link_color")
}.to change(Split::Alternative.new(alternative_name, "link_color"), :completed_count).by(1)
end
end
end
describe "when user is previewing" do
before(:each) do
@request = OpenStruct.new(headers: { "x-purpose" => "preview" })
end
it_behaves_like "a disabled test"
end
describe "versioned experiments" do
it "should use version zero if no version is present" do
alternative_name = ab_test("link_color", "blue", "red")
expect(experiment.version).to eq(0)
expect(ab_user["link_color"]).to eq(alternative_name)
end
it "should save the version of the experiment to the session" do
experiment.reset
expect(experiment.version).to eq(1)
alternative_name = ab_test("link_color", "blue", "red")
expect(ab_user["link_color:1"]).to eq(alternative_name)
end
it "should load the experiment even if the version is not 0" do
experiment.reset
expect(experiment.version).to eq(1)
alternative_name = ab_test("link_color", "blue", "red")
expect(ab_user["link_color:1"]).to eq(alternative_name)
return_alternative_name = ab_test("link_color", "blue", "red")
expect(return_alternative_name).to eq(alternative_name)
end
it "should reset the session of a user on an older version of the experiment" do
alternative_name = ab_test("link_color", "blue", "red")
expect(ab_user["link_color"]).to eq(alternative_name)
alternative = Split::Alternative.new(alternative_name, "link_color")
expect(alternative.participant_count).to eq(1)
experiment.reset
expect(experiment.version).to eq(1)
alternative = Split::Alternative.new(alternative_name, "link_color")
expect(alternative.participant_count).to eq(0)
new_alternative_name = ab_test("link_color", "blue", "red")
expect(ab_user["link_color:1"]).to eq(new_alternative_name)
new_alternative = Split::Alternative.new(new_alternative_name, "link_color")
expect(new_alternative.participant_count).to eq(1)
end
it "should cleanup old versions of experiments from the session" do
alternative_name = ab_test("link_color", "blue", "red")
expect(ab_user["link_color"]).to eq(alternative_name)
alternative = Split::Alternative.new(alternative_name, "link_color")
expect(alternative.participant_count).to eq(1)
experiment.reset
expect(experiment.version).to eq(1)
alternative = Split::Alternative.new(alternative_name, "link_color")
expect(alternative.participant_count).to eq(0)
new_alternative_name = ab_test("link_color", "blue", "red")
expect(ab_user["link_color:1"]).to eq(new_alternative_name)
end
it "should only count completion of users on the current version" do
alternative_name = ab_test("link_color", "blue", "red")
expect(ab_user["link_color"]).to eq(alternative_name)
Split::Alternative.new(alternative_name, "link_color")
it "should increment the counter for the specified-goal completed alternative" do
@previous_completion_count_for_goal1 = Split::Alternative.new(@alternative_name, @experiment_name).completed_count(@goal1)
@previous_completion_count_for_goal2 = Split::Alternative.new(@alternative_name, @experiment_name).completed_count(@goal2)
finished({"link_color" => ["purchase"]})
new_completion_count_for_goal1 = Split::Alternative.new(@alternative_name, @experiment_name).completed_count(@goal1)
new_completion_count_for_goal1.should eql(@previous_completion_count_for_goal1 + 1)
new_completion_count_for_goal2 = Split::Alternative.new(@alternative_name, @experiment_name).completed_count(@goal2)
end
context "when redis is not available" do
before(:each) do
expect(Split).to receive(:redis).at_most(5).times.and_raise(Errno::ECONNREFUSED.new)
end
context "and db_failover config option is turned off" do
before(:each) do
Split.configure do |config|
config.db_failover = false
end
end
describe "ab_test" do
it "should raise an exception" do
expect { ab_test("link_color", "blue", "red") }.to raise_error(Errno::ECONNREFUSED)
end
end
describe "finished" do
it "should raise an exception" do
expect { ab_finished("link_color") }.to raise_error(Errno::ECONNREFUSED)
end
end
describe "disable split testing" do
before(:each) do
Split.configure do |config|
config.enabled = false
end
end
it "should not attempt to connect to redis" do
expect { ab_test("link_color", "blue", "red") }.not_to raise_error
end
it "should return control variable" do
expect(ab_test("link_color", "blue", "red")).to eq("blue")
expect { ab_finished("link_color") }.not_to raise_error
end
end
end
context "and db_failover config option is turned on" do
before(:each) do
Split.configure do |config|
config.db_failover = true
end
end
describe "ab_test" do
it "should not raise an exception" do
expect { ab_test("link_color", "blue", "red") }.not_to raise_error
end
it "should call db_failover_on_db_error proc with error as parameter" do
Split.configure do |config|
config.db_failover_on_db_error = proc do |error|
expect(error).to be_a(Errno::ECONNREFUSED)
end
end
expect(Split.configuration.db_failover_on_db_error).to receive(:call).and_call_original
ab_test("link_color", "blue", "red")
end
it "should always use first alternative" do
expect(ab_test("link_color", "blue", "red")).to eq("blue")
expect(ab_test("link_color", { "blue" => 0.01 }, "red" => 0.2)).to eq("blue")
expect(ab_test("link_color", { "blue" => 0.8 }, { "red" => 20 })).to eq("blue")
expect(ab_test("link_color", "blue", "red") do |alternative|
"shared/#{alternative}"
end).to eq("shared/blue")
end
context "and db_failover_allow_parameter_override config option is turned on" do
before(:each) do
Split.configure do |config|
config.db_failover_allow_parameter_override = true
end
end
context "and given an override parameter" do
it "should use given override instead of the first alternative" do
@params = { "ab_test" => { "link_color" => "red" } }
expect(ab_test("link_color", "blue", "red")).to eq("red")
expect(ab_test("link_color", "blue", "red", "green")).to eq("red")
expect(ab_test("link_color", { "blue" => 0.01 }, "red" => 0.2)).to eq("red")
expect(ab_test("link_color", { "blue" => 0.8 }, { "red" => 20 })).to eq("red")
expect(ab_test("link_color", "blue", "red") do |alternative|
"shared/#{alternative}"
end).to eq("shared/red")
end
end
end
context "and preloaded config given" do
before do
Split.configuration.experiments[:link_color] = {
alternatives: [ "blue", "red" ],
}
end
it "uses first alternative" do
expect(ab_test(:link_color)).to eq("blue")
end
end
end
describe "finished" do
it "should not raise an exception" do
expect { ab_finished("link_color") }.not_to raise_error
end
it "should call db_failover_on_db_error proc with error as parameter" do
Split.configure do |config|
config.db_failover_on_db_error = proc do |error|
expect(error).to be_a(Errno::ECONNREFUSED)
end
end
expect(Split.configuration.db_failover_on_db_error).to receive(:call).and_call_original
ab_finished("link_color")
end
end
end
end
context "with preloaded config" do
before { Split.configuration.experiments = {} }
it "pulls options from config file" do
Split.configuration.experiments[:my_experiment] = {
alternatives: [ "control_opt", "other_opt" ],
goals: ["goal1", "goal2"]
}
ab_test :my_experiment
expect(Split::Experiment.new(:my_experiment).alternatives.map(&:name)).to eq([ "control_opt", "other_opt" ])
expect(Split::Experiment.new(:my_experiment).goals).to eq([ "goal1", "goal2" ])
end
it "can be called multiple times" do
Split.configuration.experiments[:my_experiment] = {
alternatives: [ "control_opt", "other_opt" ],
goals: ["goal1", "goal2"]
}
5.times { ab_test :my_experiment }
experiment = Split::Experiment.new(:my_experiment)
expect(experiment.alternatives.map(&:name)).to eq([ "control_opt", "other_opt" ])
expect(experiment.goals).to eq([ "goal1", "goal2" ])
expect(experiment.participant_count).to eq(1)
end
it "accepts multiple goals" do
Split.configuration.experiments[:my_experiment] = {
alternatives: [ "control_opt", "other_opt" ],
goals: [ "goal1", "goal2", "goal3" ]
}
ab_test :my_experiment
experiment = Split::Experiment.new(:my_experiment)
expect(experiment.goals).to eq([ "goal1", "goal2", "goal3" ])
end
it "allow specifying goals to be optional" do
Split.configuration.experiments[:my_experiment] = {
alternatives: [ "control_opt", "other_opt" ]
}
experiment = Split::Experiment.new(:my_experiment)
expect(experiment.goals).to eq([])
end
it "accepts multiple alternatives" do
Split.configuration.experiments[:my_experiment] = {
alternatives: [ "control_opt", "second_opt", "third_opt" ],
}
ab_test :my_experiment
experiment = Split::Experiment.new(:my_experiment)
expect(experiment.alternatives.map(&:name)).to eq([ "control_opt", "second_opt", "third_opt" ])
end
it "accepts probability on alternatives" do
Split.configuration.experiments[:my_experiment] = {
alternatives: [
{ name: "control_opt", percent: 67 },
{ name: "second_opt", percent: 10 },
{ name: "third_opt", percent: 23 },
],
}
ab_test :my_experiment
experiment = Split::Experiment.new(:my_experiment)
expect(experiment.alternatives.collect { |a| [a.name, a.weight] }).to eq([["control_opt", 0.67], ["second_opt", 0.1], ["third_opt", 0.23]])
end
it "accepts probability on some alternatives" do
Split.configuration.experiments[:my_experiment] = {
alternatives: [
{ name: "control_opt", percent: 34 },
"second_opt",
{ name: "third_opt", percent: 23 },
"fourth_opt",
],
}
ab_test :my_experiment
experiment = Split::Experiment.new(:my_experiment)
names_and_weights = experiment.alternatives.collect { |a| [a.name, a.weight] }
expect(names_and_weights).to eq([["control_opt", 0.34], ["second_opt", 0.215], ["third_opt", 0.23], ["fourth_opt", 0.215]])
expect(names_and_weights.inject(0) { |sum, nw| sum + nw[1] }).to eq(1.0)
end
it "allows name param without probability" do
Split.configuration.experiments[:my_experiment] = {
alternatives: [
{ name: "control_opt" },
"second_opt",
{ name: "third_opt", percent: 64 },
],
}
ab_test :my_experiment
experiment = Split::Experiment.new(:my_experiment)
names_and_weights = experiment.alternatives.collect { |a| [a.name, a.weight] }
expect(names_and_weights).to eq([["control_opt", 0.18], ["second_opt", 0.18], ["third_opt", 0.64]])
expect(names_and_weights.inject(0) { |sum, nw| sum + nw[1] }).to eq(1.0)
end
it "fails gracefully if config is missing experiment" do
Split.configuration.experiments = { other_experiment: { foo: "Bar" } }
expect { ab_test :my_experiment }.to raise_error(Split::ExperimentNotFound)
end
it "fails gracefully if config is missing" do
expect { Split.configuration.experiments = nil }.to raise_error(Split::InvalidExperimentsFormatError)
end
it "fails gracefully if config is missing alternatives" do
Split.configuration.experiments[:my_experiment] = { foo: "Bar" }
expect { ab_test :my_experiment }.to raise_error(NoMethodError)
end
end
it "should handle multiple experiments correctly" do
experiment2 = Split::ExperimentCatalog.find_or_create("link_color2", "blue", "red")
ab_test("link_color", "blue", "red")
ab_test("link_color2", "blue", "red")
ab_finished("link_color2")
experiment2.alternatives.each do |alt|
expect(alt.unfinished_count).to eq(0)
end
end
context "with goals" do
before do
@experiment = { "link_color" => ["purchase", "refund"] }
@alternatives = ["blue", "red"]
@experiment_name, @goals = normalize_metric(@experiment)
@goal1 = @goals[0]
@goal2 = @goals[1]
end
it "should normalize experiment" do
expect(@experiment_name).to eq("link_color")
expect(@goals).to eq(["purchase", "refund"])
end
describe "ab_test" do
it "should allow experiment goals interface as a single hash" do
ab_test(@experiment, *@alternatives)
experiment = Split::ExperimentCatalog.find("link_color")
expect(experiment.goals).to eq(["purchase", "refund"])
end
end
describe "ab_finished" do
before do
@alternative_name = ab_test(@experiment, *@alternatives)
end
it "should increment the counter for the specified-goal completed alternative" do
expect { ab_finished({ "link_color" => ["purchase"] }) }
.to change { Split::Alternative.new(@alternative_name, @experiment_name).completed_count(@goal2) }.by(0)
.and change { Split::Alternative.new(@alternative_name, @experiment_name).completed_count(@goal1) }.by(1)
end
end
end
end
<MSG> Merge pull request #151 from andrew/goals_no_array
finished method accept goals that are not passed as arrays
<DFF> @@ -27,8 +27,8 @@ describe Split::Helper do
lambda { ab_test({'link_color' => ["purchase", "refund"]}, 'blue', 'red') }.should_not raise_error
end
- it "should raise the appropriate error when passed string for goals" do
- lambda { ab_test({'link_color' => "purchase"}, 'blue', 'red') }.should raise_error(ArgumentError)
+ it "should not raise error when passed just one goal" do
+ lambda { ab_test({'link_color' => "purchase"}, 'blue', 'red') }.should_not raise_error
end
it "should assign a random alternative to a new user when there are an equal number of alternatives assigned" do
@@ -852,7 +852,7 @@ describe Split::Helper do
it "should increment the counter for the specified-goal completed alternative" do
@previous_completion_count_for_goal1 = Split::Alternative.new(@alternative_name, @experiment_name).completed_count(@goal1)
@previous_completion_count_for_goal2 = Split::Alternative.new(@alternative_name, @experiment_name).completed_count(@goal2)
- finished({"link_color" => ["purchase"]})
+ finished({"link_color" => "purchase"})
new_completion_count_for_goal1 = Split::Alternative.new(@alternative_name, @experiment_name).completed_count(@goal1)
new_completion_count_for_goal1.should eql(@previous_completion_count_for_goal1 + 1)
new_completion_count_for_goal2 = Split::Alternative.new(@alternative_name, @experiment_name).completed_count(@goal2)
| 3 | Merge pull request #151 from andrew/goals_no_array | 3 | .rb | rb | mit | splitrb/split |
10071635 | <NME> helper_spec.rb
<BEF> # frozen_string_literal: true
require "spec_helper"
# TODO change some of these tests to use Rack::Test
describe Split::Helper do
include Split::Helper
let(:experiment) {
Split::ExperimentCatalog.find_or_create("link_color", "blue", "red")
}
describe "ab_test" do
it "should not raise an error when passed strings for alternatives" do
expect { ab_test("xyz", "1", "2", "3") }.not_to raise_error
end
it "should not raise an error when passed an array for alternatives" do
expect { ab_test("xyz", ["1", "2", "3"]) }.not_to raise_error
end
it "should raise the appropriate error when passed integers for alternatives" do
expect { ab_test("xyz", 1, 2, 3) }.to raise_error(ArgumentError)
end
lambda { ab_test({'link_color' => ["purchase", "refund"]}, 'blue', 'red') }.should_not raise_error
end
it "should raise the appropriate error when passed string for goals" do
lambda { ab_test({'link_color' => "purchase"}, 'blue', 'red') }.should raise_error(ArgumentError)
end
it "should assign a random alternative to a new user when there are an equal number of alternatives assigned" do
it "should not raise error when passed just one goal" do
expect { ab_test({ "link_color" => "purchase" }, "blue", "red") }.not_to raise_error
end
it "raises an appropriate error when processing combined expirements" do
Split.configuration.experiments = {
combined_exp_1: {
alternatives: [ { name: "control", percent: 50 }, { name: "test-alt", percent: 50 } ],
metric: :my_metric,
combined_experiments: [:combined_exp_1_sub_1]
}
}
Split::ExperimentCatalog.find_or_create("combined_exp_1")
expect { ab_test("combined_exp_1") }.to raise_error(Split::InvalidExperimentsFormatError)
end
it "should assign a random alternative to a new user when there are an equal number of alternatives assigned" do
ab_test("link_color", "blue", "red")
expect(["red", "blue"]).to include(ab_user["link_color"])
end
it "should increment the participation counter after assignment to a new user" do
previous_red_count = Split::Alternative.new("red", "link_color").participant_count
previous_blue_count = Split::Alternative.new("blue", "link_color").participant_count
ab_test("link_color", "blue", "red")
new_red_count = Split::Alternative.new("red", "link_color").participant_count
new_blue_count = Split::Alternative.new("blue", "link_color").participant_count
expect((new_red_count + new_blue_count)).to eq(previous_red_count + previous_blue_count + 1)
end
it "should not increment the counter for an experiment that the user is not participating in" do
ab_test("link_color", "blue", "red")
e = Split::ExperimentCatalog.find_or_create("button_size", "small", "big")
expect {
# User shouldn't participate in this second experiment
ab_test("button_size", "small", "big")
}.not_to change { e.participant_count }
end
it "should not increment the counter for an ended experiment" do
e = Split::ExperimentCatalog.find_or_create("button_size", "small", "big")
e.winner = "small"
expect {
a = ab_test("button_size", "small", "big")
expect(a).to eq("small")
}.not_to change { e.participant_count }
end
it "should not increment the counter for an not started experiment" do
expect(Split.configuration).to receive(:start_manually).and_return(true)
e = Split::ExperimentCatalog.find_or_create("button_size", "small", "big")
expect {
a = ab_test("button_size", "small", "big")
expect(a).to eq("small")
}.not_to change { e.participant_count }
end
it "should return the given alternative for an existing user" do
expect(ab_test("link_color", "blue", "red")).to eq ab_test("link_color", "blue", "red")
end
it "should always return the winner if one is present" do
experiment.winner = "orange"
expect(ab_test("link_color", "blue", "red")).to eq("orange")
end
it "should allow the alternative to be forced by passing it in the params" do
# ?ab_test[link_color]=blue
@params = { "ab_test" => { "link_color" => "blue" } }
alternative = ab_test("link_color", "blue", "red")
expect(alternative).to eq("blue")
alternative = ab_test("link_color", { "blue" => 1 }, "red" => 5)
expect(alternative).to eq("blue")
@params = { "ab_test" => { "link_color" => "red" } }
alternative = ab_test("link_color", "blue", "red")
expect(alternative).to eq("red")
alternative = ab_test("link_color", { "blue" => 5 }, "red" => 1)
expect(alternative).to eq("red")
end
it "should not allow an arbitrary alternative" do
@params = { "ab_test" => { "link_color" => "pink" } }
alternative = ab_test("link_color", "blue")
expect(alternative).to eq("blue")
end
it "should not store the split when a param forced alternative" do
@params = { "ab_test" => { "link_color" => "blue" } }
expect(ab_user).not_to receive(:[]=)
ab_test("link_color", "blue", "red")
end
it "SPLIT_DISABLE query parameter should also force the alternative (uses control)" do
@params = { "SPLIT_DISABLE" => "true" }
alternative = ab_test("link_color", "blue", "red")
expect(alternative).to eq("blue")
alternative = ab_test("link_color", { "blue" => 1 }, "red" => 5)
expect(alternative).to eq("blue")
alternative = ab_test("link_color", "red", "blue")
expect(alternative).to eq("red")
alternative = ab_test("link_color", { "red" => 5 }, "blue" => 1)
expect(alternative).to eq("red")
end
it "should not store the split when Split generically disabled" do
@params = { "SPLIT_DISABLE" => "true" }
expect(ab_user).not_to receive(:[]=)
ab_test("link_color", "blue", "red")
end
context "when store_override is set" do
before { Split.configuration.store_override = true }
it "should store the forced alternative" do
@params = { "ab_test" => { "link_color" => "blue" } }
expect(ab_user).to receive(:[]=).with("link_color", "blue")
ab_test("link_color", "blue", "red")
end
end
context "when on_trial_choose is set" do
before { Split.configuration.on_trial_choose = :some_method }
it "should call the method" do
expect(self).to receive(:some_method)
ab_test("link_color", "blue", "red")
end
end
it "should allow passing a block" do
alt = ab_test("link_color", "blue", "red")
ret = ab_test("link_color", "blue", "red") { |alternative| "shared/#{alternative}" }
expect(ret).to eq("shared/#{alt}")
end
it "should allow the share of visitors see an alternative to be specified" do
ab_test("link_color", { "blue" => 0.8 }, { "red" => 20 })
expect(["red", "blue"]).to include(ab_user["link_color"])
end
it "should allow alternative weighting interface as a single hash" do
ab_test("link_color", { "blue" => 0.01 }, "red" => 0.2)
experiment = Split::ExperimentCatalog.find("link_color")
expect(experiment.alternatives.map(&:name)).to eq(["blue", "red"])
expect(experiment.alternatives.collect { |a| a.weight }).to match_array([0.01, 0.2])
end
it "should only let a user participate in one experiment at a time" do
link_color = ab_test("link_color", "blue", "red")
ab_test("button_size", "small", "big")
expect(ab_user["link_color"]).to eq(link_color)
big = Split::Alternative.new("big", "button_size")
expect(big.participant_count).to eq(0)
small = Split::Alternative.new("small", "button_size")
expect(small.participant_count).to eq(0)
end
it "should let a user participate in many experiment with allow_multiple_experiments option" do
Split.configure do |config|
config.allow_multiple_experiments = true
end
link_color = ab_test("link_color", "blue", "red")
button_size = ab_test("button_size", "small", "big")
expect(ab_user["link_color"]).to eq(link_color)
expect(ab_user["button_size"]).to eq(button_size)
button_size_alt = Split::Alternative.new(button_size, "button_size")
expect(button_size_alt.participant_count).to eq(1)
end
context "with allow_multiple_experiments = 'control'" do
it "should let a user participate in many experiment with one non-'control' alternative" do
Split.configure do |config|
config.allow_multiple_experiments = "control"
end
groups = 100.times.map do |n|
ab_test("test#{n}".to_sym, { "control" => (100 - n) }, { "test#{n}-alt" => n })
end
experiments = ab_user.active_experiments
expect(experiments.size).to be > 1
count_control = experiments.values.count { |g| g == "control" }
expect(count_control).to eq(experiments.size - 1)
count_alts = groups.count { |g| g != "control" }
expect(count_alts).to eq(1)
end
context "when user already has experiment" do
let(:mock_user) { Split::User.new(self, { "test_0" => "test-alt" }) }
before do
Split.configure do |config|
config.allow_multiple_experiments = "control"
end
Split::ExperimentCatalog.find_or_initialize("test_0", "control", "test-alt").save
Split::ExperimentCatalog.find_or_initialize("test_1", "control", "test-alt").save
end
it "should restore previously selected alternative" do
expect(ab_user.active_experiments.size).to eq 1
expect(ab_test(:test_0, { "control" => 100 }, { "test-alt" => 1 })).to eq "test-alt"
expect(ab_test(:test_0, { "control" => 1 }, { "test-alt" => 100 })).to eq "test-alt"
end
it "should select the correct alternatives after experiment resets" do
experiment = Split::ExperimentCatalog.find(:test_0)
experiment.reset
mock_user[experiment.key] = "test-alt"
expect(ab_user.active_experiments.size).to eq 1
expect(ab_test(:test_0, { "control" => 100 }, { "test-alt" => 1 })).to eq "test-alt"
expect(ab_test(:test_0, { "control" => 0 }, { "test-alt" => 100 })).to eq "test-alt"
end
it "lets override existing choice" do
pending "this requires user store reset on first call not depending on whelther it is current trial"
@params = { "ab_test" => { "test_1" => "test-alt" } }
expect(ab_test(:test_0, { "control" => 0 }, { "test-alt" => 100 })).to eq "control"
expect(ab_test(:test_1, { "control" => 100 }, { "test-alt" => 1 })).to eq "test-alt"
end
end
end
it "should not over-write a finished key when an experiment is on a later version" do
experiment.increment_version
ab_user = { experiment.key => "blue", experiment.finished_key => true }
finished_session = ab_user.dup
ab_test("link_color", "blue", "red")
expect(ab_user).to eq(finished_session)
end
end
describe "metadata" do
context "is defined" do
before do
Split.configuration.experiments = {
my_experiment: {
alternatives: ["one", "two"],
resettable: false,
metadata: { "one" => "Meta1", "two" => "Meta2" }
}
}
end
it "should be passed to helper block" do
@params = { "ab_test" => { "my_experiment" => "two" } }
expect(ab_test("my_experiment")).to eq "two"
expect(ab_test("my_experiment") do |alternative, meta|
meta
end).to eq("Meta2")
end
it "should pass control metadata helper block if library disabled" do
Split.configure do |config|
config.enabled = false
end
expect(ab_test("my_experiment")).to eq "one"
expect(ab_test("my_experiment") do |_, meta|
meta
end).to eq("Meta1")
end
end
context "is not defined" do
before do
Split.configuration.experiments = {
my_experiment: {
alternatives: ["one", "two"],
resettable: false,
metadata: nil
}
}
end
it "should be passed to helper block" do
expect(ab_test("my_experiment") do |alternative, meta|
meta
end).to eq({})
end
it "should pass control metadata helper block if library disabled" do
Split.configure do |config|
config.enabled = false
end
expect(ab_test("my_experiment") do |_, meta|
meta
end).to eq({})
end
end
end
describe "ab_finished" do
context "for an experiment that the user participates in" do
before(:each) do
@experiment_name = "link_color"
@alternatives = ["blue", "red"]
@experiment = Split::ExperimentCatalog.find_or_create(@experiment_name, *@alternatives)
@alternative_name = ab_test(@experiment_name, *@alternatives)
@previous_completion_count = Split::Alternative.new(@alternative_name, @experiment_name).completed_count
end
it "should increment the counter for the completed alternative" do
ab_finished(@experiment_name)
new_completion_count = Split::Alternative.new(@alternative_name, @experiment_name).completed_count
expect(new_completion_count).to eq(@previous_completion_count + 1)
end
it "should set experiment's finished key if reset is false" do
ab_finished(@experiment_name, { reset: false })
expect(ab_user[@experiment.key]).to eq(@alternative_name)
expect(ab_user[@experiment.finished_key]).to eq(true)
end
it "should not increment the counter if reset is false and the experiment has been already finished" do
2.times { ab_finished(@experiment_name, { reset: false }) }
new_completion_count = Split::Alternative.new(@alternative_name, @experiment_name).completed_count
expect(new_completion_count).to eq(@previous_completion_count + 1)
end
it "should not increment the counter for an ended experiment" do
e = Split::ExperimentCatalog.find_or_create("button_size", "small", "big")
e.winner = "small"
a = ab_test("button_size", "small", "big")
expect(a).to eq("small")
expect {
ab_finished("button_size")
}.not_to change { Split::Alternative.new(a, "button_size").completed_count }
end
it "should clear out the user's participation from their session" do
expect(ab_user[@experiment.key]).to eq(@alternative_name)
ab_finished(@experiment_name)
expect(ab_user.keys).to be_empty
end
it "should not clear out the users session if reset is false" do
expect(ab_user[@experiment.key]).to eq(@alternative_name)
ab_finished(@experiment_name, { reset: false })
expect(ab_user[@experiment.key]).to eq(@alternative_name)
expect(ab_user[@experiment.finished_key]).to eq(true)
end
it "should reset the users session when experiment is not versioned" do
expect(ab_user[@experiment.key]).to eq(@alternative_name)
ab_finished(@experiment_name)
expect(ab_user.keys).to be_empty
end
it "should reset the users session when experiment is versioned" do
@experiment.increment_version
@alternative_name = ab_test(@experiment_name, *@alternatives)
expect(ab_user[@experiment.key]).to eq(@alternative_name)
ab_finished(@experiment_name)
expect(ab_user.keys).to be_empty
end
context "when on_trial_complete is set" do
before { Split.configuration.on_trial_complete = :some_method }
it "should call the method" do
expect(self).to receive(:some_method)
ab_finished(@experiment_name)
end
it "should not call the method without alternative" do
ab_user[@experiment.key] = nil
expect(self).not_to receive(:some_method)
ab_finished(@experiment_name)
end
end
end
context "for an experiment that the user is excluded from" do
before do
alternative = ab_test("link_color", "blue", "red")
expect(Split::Alternative.new(alternative, "link_color").participant_count).to eq(1)
alternative = ab_test("button_size", "small", "big")
expect(Split::Alternative.new(alternative, "button_size").participant_count).to eq(0)
end
it "should not increment the completed counter" do
# So, user should be participating in the link_color experiment and
# receive the control for button_size. As the user is not participating in
# the button size experiment, finishing it should not increase the
# completion count for that alternative.
expect {
ab_finished("button_size")
}.not_to change { Split::Alternative.new("small", "button_size").completed_count }
end
end
context "for an experiment that the user does not participate in" do
before do
Split::ExperimentCatalog.find_or_create(:not_started_experiment, "control", "alt")
end
it "should not raise an exception" do
expect { ab_finished(:not_started_experiment) }.not_to raise_exception
end
it "should not change the user state when reset is false" do
expect { ab_finished(:not_started_experiment, reset: false) }.not_to change { ab_user.keys }.from([])
end
it "should not change the user state when reset is true" do
expect(self).not_to receive(:reset!)
ab_finished(:not_started_experiment)
end
it "should not increment the completed counter" do
ab_finished(:not_started_experiment)
expect(Split::Alternative.new("control", :not_started_experiment).completed_count).to eq(0)
expect(Split::Alternative.new("alt", :not_started_experiment).completed_count).to eq(0)
end
end
end
context "finished with config" do
it "passes reset option" do
Split.configuration.experiments = {
my_experiment: {
alternatives: ["one", "two"],
resettable: false,
}
}
alternative = ab_test(:my_experiment)
experiment = Split::ExperimentCatalog.find :my_experiment
ab_finished :my_experiment
expect(ab_user[experiment.key]).to eq(alternative)
expect(ab_user[experiment.finished_key]).to eq(true)
end
end
context "finished with metric name" do
before { Split.configuration.experiments = {} }
before { expect(Split::Alternative).to receive(:new).at_least(1).times.and_call_original }
def should_finish_experiment(experiment_name, should_finish = true)
alts = Split.configuration.experiments[experiment_name][:alternatives]
experiment = Split::ExperimentCatalog.find_or_create(experiment_name, *alts)
alt_name = ab_user[experiment.key] = alts.first
alt = double("alternative")
expect(alt).to receive(:name).at_most(1).times.and_return(alt_name)
expect(Split::Alternative).to receive(:new).at_most(1).times.with(alt_name, experiment_name.to_s).and_return(alt)
if should_finish
expect(alt).to receive(:increment_completion).at_most(1).times
else
expect(alt).not_to receive(:increment_completion)
end
end
it "completes the test" do
Split.configuration.experiments[:my_experiment] = {
alternatives: [ "control_opt", "other_opt" ],
metric: :my_metric
}
should_finish_experiment :my_experiment
ab_finished :my_metric
end
it "completes all relevant tests" do
Split.configuration.experiments = {
exp_1: {
alternatives: [ "1-1", "1-2" ],
metric: :my_metric
},
exp_2: {
alternatives: [ "2-1", "2-2" ],
metric: :another_metric
},
exp_3: {
alternatives: [ "3-1", "3-2" ],
metric: :my_metric
},
}
should_finish_experiment :exp_1
should_finish_experiment :exp_2, false
should_finish_experiment :exp_3
ab_finished :my_metric
end
it "passes reset option" do
Split.configuration.experiments = {
my_exp: {
alternatives: ["one", "two"],
metric: :my_metric,
resettable: false,
}
}
alternative_name = ab_test(:my_exp)
exp = Split::ExperimentCatalog.find :my_exp
ab_finished :my_metric
expect(ab_user[exp.key]).to eq(alternative_name)
expect(ab_user[exp.finished_key]).to be_truthy
end
it "passes through options" do
Split.configuration.experiments = {
my_exp: {
alternatives: ["one", "two"],
metric: :my_metric,
}
}
alternative_name = ab_test(:my_exp)
exp = Split::ExperimentCatalog.find :my_exp
ab_finished :my_metric, reset: false
expect(ab_user[exp.key]).to eq(alternative_name)
expect(ab_user[exp.finished_key]).to be_truthy
end
end
describe "conversions" do
it "should return a conversion rate for an alternative" do
alternative_name = ab_test("link_color", "blue", "red")
previous_convertion_rate = Split::Alternative.new(alternative_name, "link_color").conversion_rate
expect(previous_convertion_rate).to eq(0.0)
ab_finished("link_color")
new_convertion_rate = Split::Alternative.new(alternative_name, "link_color").conversion_rate
expect(new_convertion_rate).to eq(1.0)
end
end
describe "active experiments" do
it "should show an active test" do
alternative = ab_test("def", "4", "5", "6")
expect(active_experiments.count).to eq 1
expect(active_experiments.first[0]).to eq "def"
expect(active_experiments.first[1]).to eq alternative
end
it "should show a finished test" do
alternative = ab_test("def", "4", "5", "6")
ab_finished("def", { reset: false })
expect(active_experiments.count).to eq 1
expect(active_experiments.first[0]).to eq "def"
expect(active_experiments.first[1]).to eq alternative
end
it "should show an active test when an experiment is on a later version" do
experiment.reset
expect(experiment.version).to eq(1)
ab_test("link_color", "blue", "red")
expect(active_experiments.count).to eq 1
expect(active_experiments.first[0]).to eq "link_color"
end
it "should show versioned tests properly" do
10.times { experiment.reset }
alternative = ab_test(experiment.name, "blue", "red")
ab_finished(experiment.name, reset: false)
expect(experiment.version).to eq(10)
expect(active_experiments.count).to eq 1
expect(active_experiments).to eq({ "link_color" => alternative })
end
it "should show multiple tests" do
Split.configure do |config|
config.allow_multiple_experiments = true
end
alternative = ab_test("def", "4", "5", "6")
another_alternative = ab_test("ghi", "7", "8", "9")
expect(active_experiments.count).to eq 2
expect(active_experiments["def"]).to eq alternative
expect(active_experiments["ghi"]).to eq another_alternative
end
it "should not show tests with winners" do
Split.configure do |config|
config.allow_multiple_experiments = true
end
e = Split::ExperimentCatalog.find_or_create("def", "4", "5", "6")
e.winner = "4"
ab_test("def", "4", "5", "6")
another_alternative = ab_test("ghi", "7", "8", "9")
expect(active_experiments.count).to eq 1
expect(active_experiments.first[0]).to eq "ghi"
expect(active_experiments.first[1]).to eq another_alternative
end
end
describe "when user is a robot" do
before(:each) do
@request = OpenStruct.new(user_agent: "Googlebot/2.1 (+http://www.google.com/bot.html)")
end
describe "ab_test" do
it "should return the control" do
alternative = ab_test("link_color", "blue", "red")
expect(alternative).to eq experiment.control.name
end
it "should not create a experiment" do
ab_test("link_color", "blue", "red")
expect(Split::Experiment.new("link_color")).to be_a_new_record
end
it "should not increment the participation count" do
previous_red_count = Split::Alternative.new("red", "link_color").participant_count
previous_blue_count = Split::Alternative.new("blue", "link_color").participant_count
ab_test("link_color", "blue", "red")
new_red_count = Split::Alternative.new("red", "link_color").participant_count
new_blue_count = Split::Alternative.new("blue", "link_color").participant_count
expect((new_red_count + new_blue_count)).to eq(previous_red_count + previous_blue_count)
end
end
describe "finished" do
it "should not increment the completed count" do
alternative_name = ab_test("link_color", "blue", "red")
previous_completion_count = Split::Alternative.new(alternative_name, "link_color").completed_count
ab_finished("link_color")
new_completion_count = Split::Alternative.new(alternative_name, "link_color").completed_count
expect(new_completion_count).to eq(previous_completion_count)
end
end
end
describe "when providing custom ignore logic" do
context "using a proc to configure custom logic" do
before(:each) do
Split.configure do |c|
c.ignore_filter = proc { |request| true } # ignore everything
end
end
it "ignores the ab_test" do
ab_test("link_color", "blue", "red")
red_count = Split::Alternative.new("red", "link_color").participant_count
blue_count = Split::Alternative.new("blue", "link_color").participant_count
expect((red_count + blue_count)).to be(0)
end
end
end
shared_examples_for "a disabled test" do
describe "ab_test" do
it "should return the control" do
alternative = ab_test("link_color", "blue", "red")
expect(alternative).to eq experiment.control.name
end
it "should not increment the participation count" do
previous_red_count = Split::Alternative.new("red", "link_color").participant_count
previous_blue_count = Split::Alternative.new("blue", "link_color").participant_count
ab_test("link_color", "blue", "red")
new_red_count = Split::Alternative.new("red", "link_color").participant_count
new_blue_count = Split::Alternative.new("blue", "link_color").participant_count
expect((new_red_count + new_blue_count)).to eq(previous_red_count + previous_blue_count)
end
end
describe "finished" do
it "should not increment the completed count" do
alternative_name = ab_test("link_color", "blue", "red")
previous_completion_count = Split::Alternative.new(alternative_name, "link_color").completed_count
ab_finished("link_color")
new_completion_count = Split::Alternative.new(alternative_name, "link_color").completed_count
expect(new_completion_count).to eq(previous_completion_count)
end
end
end
describe "when ip address is ignored" do
context "individually" do
before(:each) do
@request = OpenStruct.new(ip: "81.19.48.130")
Split.configure do |c|
c.ignore_ip_addresses << "81.19.48.130"
end
end
it_behaves_like "a disabled test"
end
context "for a range" do
before(:each) do
@request = OpenStruct.new(ip: "81.19.48.129")
Split.configure do |c|
c.ignore_ip_addresses << /81\.19\.48\.[0-9]+/
end
end
it_behaves_like "a disabled test"
end
context "using both a range and a specific value" do
before(:each) do
@request = OpenStruct.new(ip: "81.19.48.128")
Split.configure do |c|
c.ignore_ip_addresses << "81.19.48.130"
c.ignore_ip_addresses << /81\.19\.48\.[0-9]+/
end
end
it_behaves_like "a disabled test"
end
context "when ignored other address" do
before do
@request = OpenStruct.new(ip: "1.1.1.1")
Split.configure do |c|
c.ignore_ip_addresses << "81.19.48.130"
end
end
it "works as usual" do
alternative_name = ab_test("link_color", "red", "blue")
expect {
ab_finished("link_color")
}.to change(Split::Alternative.new(alternative_name, "link_color"), :completed_count).by(1)
end
end
end
describe "when user is previewing" do
before(:each) do
@request = OpenStruct.new(headers: { "x-purpose" => "preview" })
end
it_behaves_like "a disabled test"
end
describe "versioned experiments" do
it "should use version zero if no version is present" do
alternative_name = ab_test("link_color", "blue", "red")
expect(experiment.version).to eq(0)
expect(ab_user["link_color"]).to eq(alternative_name)
end
it "should save the version of the experiment to the session" do
experiment.reset
expect(experiment.version).to eq(1)
alternative_name = ab_test("link_color", "blue", "red")
expect(ab_user["link_color:1"]).to eq(alternative_name)
end
it "should load the experiment even if the version is not 0" do
experiment.reset
expect(experiment.version).to eq(1)
alternative_name = ab_test("link_color", "blue", "red")
expect(ab_user["link_color:1"]).to eq(alternative_name)
return_alternative_name = ab_test("link_color", "blue", "red")
expect(return_alternative_name).to eq(alternative_name)
end
it "should reset the session of a user on an older version of the experiment" do
alternative_name = ab_test("link_color", "blue", "red")
expect(ab_user["link_color"]).to eq(alternative_name)
alternative = Split::Alternative.new(alternative_name, "link_color")
expect(alternative.participant_count).to eq(1)
experiment.reset
expect(experiment.version).to eq(1)
alternative = Split::Alternative.new(alternative_name, "link_color")
expect(alternative.participant_count).to eq(0)
new_alternative_name = ab_test("link_color", "blue", "red")
expect(ab_user["link_color:1"]).to eq(new_alternative_name)
new_alternative = Split::Alternative.new(new_alternative_name, "link_color")
expect(new_alternative.participant_count).to eq(1)
end
it "should cleanup old versions of experiments from the session" do
alternative_name = ab_test("link_color", "blue", "red")
expect(ab_user["link_color"]).to eq(alternative_name)
alternative = Split::Alternative.new(alternative_name, "link_color")
expect(alternative.participant_count).to eq(1)
experiment.reset
expect(experiment.version).to eq(1)
alternative = Split::Alternative.new(alternative_name, "link_color")
expect(alternative.participant_count).to eq(0)
new_alternative_name = ab_test("link_color", "blue", "red")
expect(ab_user["link_color:1"]).to eq(new_alternative_name)
end
it "should only count completion of users on the current version" do
alternative_name = ab_test("link_color", "blue", "red")
expect(ab_user["link_color"]).to eq(alternative_name)
Split::Alternative.new(alternative_name, "link_color")
it "should increment the counter for the specified-goal completed alternative" do
@previous_completion_count_for_goal1 = Split::Alternative.new(@alternative_name, @experiment_name).completed_count(@goal1)
@previous_completion_count_for_goal2 = Split::Alternative.new(@alternative_name, @experiment_name).completed_count(@goal2)
finished({"link_color" => ["purchase"]})
new_completion_count_for_goal1 = Split::Alternative.new(@alternative_name, @experiment_name).completed_count(@goal1)
new_completion_count_for_goal1.should eql(@previous_completion_count_for_goal1 + 1)
new_completion_count_for_goal2 = Split::Alternative.new(@alternative_name, @experiment_name).completed_count(@goal2)
end
context "when redis is not available" do
before(:each) do
expect(Split).to receive(:redis).at_most(5).times.and_raise(Errno::ECONNREFUSED.new)
end
context "and db_failover config option is turned off" do
before(:each) do
Split.configure do |config|
config.db_failover = false
end
end
describe "ab_test" do
it "should raise an exception" do
expect { ab_test("link_color", "blue", "red") }.to raise_error(Errno::ECONNREFUSED)
end
end
describe "finished" do
it "should raise an exception" do
expect { ab_finished("link_color") }.to raise_error(Errno::ECONNREFUSED)
end
end
describe "disable split testing" do
before(:each) do
Split.configure do |config|
config.enabled = false
end
end
it "should not attempt to connect to redis" do
expect { ab_test("link_color", "blue", "red") }.not_to raise_error
end
it "should return control variable" do
expect(ab_test("link_color", "blue", "red")).to eq("blue")
expect { ab_finished("link_color") }.not_to raise_error
end
end
end
context "and db_failover config option is turned on" do
before(:each) do
Split.configure do |config|
config.db_failover = true
end
end
describe "ab_test" do
it "should not raise an exception" do
expect { ab_test("link_color", "blue", "red") }.not_to raise_error
end
it "should call db_failover_on_db_error proc with error as parameter" do
Split.configure do |config|
config.db_failover_on_db_error = proc do |error|
expect(error).to be_a(Errno::ECONNREFUSED)
end
end
expect(Split.configuration.db_failover_on_db_error).to receive(:call).and_call_original
ab_test("link_color", "blue", "red")
end
it "should always use first alternative" do
expect(ab_test("link_color", "blue", "red")).to eq("blue")
expect(ab_test("link_color", { "blue" => 0.01 }, "red" => 0.2)).to eq("blue")
expect(ab_test("link_color", { "blue" => 0.8 }, { "red" => 20 })).to eq("blue")
expect(ab_test("link_color", "blue", "red") do |alternative|
"shared/#{alternative}"
end).to eq("shared/blue")
end
context "and db_failover_allow_parameter_override config option is turned on" do
before(:each) do
Split.configure do |config|
config.db_failover_allow_parameter_override = true
end
end
context "and given an override parameter" do
it "should use given override instead of the first alternative" do
@params = { "ab_test" => { "link_color" => "red" } }
expect(ab_test("link_color", "blue", "red")).to eq("red")
expect(ab_test("link_color", "blue", "red", "green")).to eq("red")
expect(ab_test("link_color", { "blue" => 0.01 }, "red" => 0.2)).to eq("red")
expect(ab_test("link_color", { "blue" => 0.8 }, { "red" => 20 })).to eq("red")
expect(ab_test("link_color", "blue", "red") do |alternative|
"shared/#{alternative}"
end).to eq("shared/red")
end
end
end
context "and preloaded config given" do
before do
Split.configuration.experiments[:link_color] = {
alternatives: [ "blue", "red" ],
}
end
it "uses first alternative" do
expect(ab_test(:link_color)).to eq("blue")
end
end
end
describe "finished" do
it "should not raise an exception" do
expect { ab_finished("link_color") }.not_to raise_error
end
it "should call db_failover_on_db_error proc with error as parameter" do
Split.configure do |config|
config.db_failover_on_db_error = proc do |error|
expect(error).to be_a(Errno::ECONNREFUSED)
end
end
expect(Split.configuration.db_failover_on_db_error).to receive(:call).and_call_original
ab_finished("link_color")
end
end
end
end
context "with preloaded config" do
before { Split.configuration.experiments = {} }
it "pulls options from config file" do
Split.configuration.experiments[:my_experiment] = {
alternatives: [ "control_opt", "other_opt" ],
goals: ["goal1", "goal2"]
}
ab_test :my_experiment
expect(Split::Experiment.new(:my_experiment).alternatives.map(&:name)).to eq([ "control_opt", "other_opt" ])
expect(Split::Experiment.new(:my_experiment).goals).to eq([ "goal1", "goal2" ])
end
it "can be called multiple times" do
Split.configuration.experiments[:my_experiment] = {
alternatives: [ "control_opt", "other_opt" ],
goals: ["goal1", "goal2"]
}
5.times { ab_test :my_experiment }
experiment = Split::Experiment.new(:my_experiment)
expect(experiment.alternatives.map(&:name)).to eq([ "control_opt", "other_opt" ])
expect(experiment.goals).to eq([ "goal1", "goal2" ])
expect(experiment.participant_count).to eq(1)
end
it "accepts multiple goals" do
Split.configuration.experiments[:my_experiment] = {
alternatives: [ "control_opt", "other_opt" ],
goals: [ "goal1", "goal2", "goal3" ]
}
ab_test :my_experiment
experiment = Split::Experiment.new(:my_experiment)
expect(experiment.goals).to eq([ "goal1", "goal2", "goal3" ])
end
it "allow specifying goals to be optional" do
Split.configuration.experiments[:my_experiment] = {
alternatives: [ "control_opt", "other_opt" ]
}
experiment = Split::Experiment.new(:my_experiment)
expect(experiment.goals).to eq([])
end
it "accepts multiple alternatives" do
Split.configuration.experiments[:my_experiment] = {
alternatives: [ "control_opt", "second_opt", "third_opt" ],
}
ab_test :my_experiment
experiment = Split::Experiment.new(:my_experiment)
expect(experiment.alternatives.map(&:name)).to eq([ "control_opt", "second_opt", "third_opt" ])
end
it "accepts probability on alternatives" do
Split.configuration.experiments[:my_experiment] = {
alternatives: [
{ name: "control_opt", percent: 67 },
{ name: "second_opt", percent: 10 },
{ name: "third_opt", percent: 23 },
],
}
ab_test :my_experiment
experiment = Split::Experiment.new(:my_experiment)
expect(experiment.alternatives.collect { |a| [a.name, a.weight] }).to eq([["control_opt", 0.67], ["second_opt", 0.1], ["third_opt", 0.23]])
end
it "accepts probability on some alternatives" do
Split.configuration.experiments[:my_experiment] = {
alternatives: [
{ name: "control_opt", percent: 34 },
"second_opt",
{ name: "third_opt", percent: 23 },
"fourth_opt",
],
}
ab_test :my_experiment
experiment = Split::Experiment.new(:my_experiment)
names_and_weights = experiment.alternatives.collect { |a| [a.name, a.weight] }
expect(names_and_weights).to eq([["control_opt", 0.34], ["second_opt", 0.215], ["third_opt", 0.23], ["fourth_opt", 0.215]])
expect(names_and_weights.inject(0) { |sum, nw| sum + nw[1] }).to eq(1.0)
end
it "allows name param without probability" do
Split.configuration.experiments[:my_experiment] = {
alternatives: [
{ name: "control_opt" },
"second_opt",
{ name: "third_opt", percent: 64 },
],
}
ab_test :my_experiment
experiment = Split::Experiment.new(:my_experiment)
names_and_weights = experiment.alternatives.collect { |a| [a.name, a.weight] }
expect(names_and_weights).to eq([["control_opt", 0.18], ["second_opt", 0.18], ["third_opt", 0.64]])
expect(names_and_weights.inject(0) { |sum, nw| sum + nw[1] }).to eq(1.0)
end
it "fails gracefully if config is missing experiment" do
Split.configuration.experiments = { other_experiment: { foo: "Bar" } }
expect { ab_test :my_experiment }.to raise_error(Split::ExperimentNotFound)
end
it "fails gracefully if config is missing" do
expect { Split.configuration.experiments = nil }.to raise_error(Split::InvalidExperimentsFormatError)
end
it "fails gracefully if config is missing alternatives" do
Split.configuration.experiments[:my_experiment] = { foo: "Bar" }
expect { ab_test :my_experiment }.to raise_error(NoMethodError)
end
end
it "should handle multiple experiments correctly" do
experiment2 = Split::ExperimentCatalog.find_or_create("link_color2", "blue", "red")
ab_test("link_color", "blue", "red")
ab_test("link_color2", "blue", "red")
ab_finished("link_color2")
experiment2.alternatives.each do |alt|
expect(alt.unfinished_count).to eq(0)
end
end
context "with goals" do
before do
@experiment = { "link_color" => ["purchase", "refund"] }
@alternatives = ["blue", "red"]
@experiment_name, @goals = normalize_metric(@experiment)
@goal1 = @goals[0]
@goal2 = @goals[1]
end
it "should normalize experiment" do
expect(@experiment_name).to eq("link_color")
expect(@goals).to eq(["purchase", "refund"])
end
describe "ab_test" do
it "should allow experiment goals interface as a single hash" do
ab_test(@experiment, *@alternatives)
experiment = Split::ExperimentCatalog.find("link_color")
expect(experiment.goals).to eq(["purchase", "refund"])
end
end
describe "ab_finished" do
before do
@alternative_name = ab_test(@experiment, *@alternatives)
end
it "should increment the counter for the specified-goal completed alternative" do
expect { ab_finished({ "link_color" => ["purchase"] }) }
.to change { Split::Alternative.new(@alternative_name, @experiment_name).completed_count(@goal2) }.by(0)
.and change { Split::Alternative.new(@alternative_name, @experiment_name).completed_count(@goal1) }.by(1)
end
end
end
end
<MSG> Merge pull request #151 from andrew/goals_no_array
finished method accept goals that are not passed as arrays
<DFF> @@ -27,8 +27,8 @@ describe Split::Helper do
lambda { ab_test({'link_color' => ["purchase", "refund"]}, 'blue', 'red') }.should_not raise_error
end
- it "should raise the appropriate error when passed string for goals" do
- lambda { ab_test({'link_color' => "purchase"}, 'blue', 'red') }.should raise_error(ArgumentError)
+ it "should not raise error when passed just one goal" do
+ lambda { ab_test({'link_color' => "purchase"}, 'blue', 'red') }.should_not raise_error
end
it "should assign a random alternative to a new user when there are an equal number of alternatives assigned" do
@@ -852,7 +852,7 @@ describe Split::Helper do
it "should increment the counter for the specified-goal completed alternative" do
@previous_completion_count_for_goal1 = Split::Alternative.new(@alternative_name, @experiment_name).completed_count(@goal1)
@previous_completion_count_for_goal2 = Split::Alternative.new(@alternative_name, @experiment_name).completed_count(@goal2)
- finished({"link_color" => ["purchase"]})
+ finished({"link_color" => "purchase"})
new_completion_count_for_goal1 = Split::Alternative.new(@alternative_name, @experiment_name).completed_count(@goal1)
new_completion_count_for_goal1.should eql(@previous_completion_count_for_goal1 + 1)
new_completion_count_for_goal2 = Split::Alternative.new(@alternative_name, @experiment_name).completed_count(@goal2)
| 3 | Merge pull request #151 from andrew/goals_no_array | 3 | .rb | rb | mit | splitrb/split |
10071636 | <NME> helper_spec.rb
<BEF> # frozen_string_literal: true
require "spec_helper"
# TODO change some of these tests to use Rack::Test
describe Split::Helper do
include Split::Helper
let(:experiment) {
Split::ExperimentCatalog.find_or_create("link_color", "blue", "red")
}
describe "ab_test" do
it "should not raise an error when passed strings for alternatives" do
expect { ab_test("xyz", "1", "2", "3") }.not_to raise_error
end
it "should not raise an error when passed an array for alternatives" do
expect { ab_test("xyz", ["1", "2", "3"]) }.not_to raise_error
end
it "should raise the appropriate error when passed integers for alternatives" do
expect { ab_test("xyz", 1, 2, 3) }.to raise_error(ArgumentError)
end
lambda { ab_test({'link_color' => ["purchase", "refund"]}, 'blue', 'red') }.should_not raise_error
end
it "should raise the appropriate error when passed string for goals" do
lambda { ab_test({'link_color' => "purchase"}, 'blue', 'red') }.should raise_error(ArgumentError)
end
it "should assign a random alternative to a new user when there are an equal number of alternatives assigned" do
it "should not raise error when passed just one goal" do
expect { ab_test({ "link_color" => "purchase" }, "blue", "red") }.not_to raise_error
end
it "raises an appropriate error when processing combined expirements" do
Split.configuration.experiments = {
combined_exp_1: {
alternatives: [ { name: "control", percent: 50 }, { name: "test-alt", percent: 50 } ],
metric: :my_metric,
combined_experiments: [:combined_exp_1_sub_1]
}
}
Split::ExperimentCatalog.find_or_create("combined_exp_1")
expect { ab_test("combined_exp_1") }.to raise_error(Split::InvalidExperimentsFormatError)
end
it "should assign a random alternative to a new user when there are an equal number of alternatives assigned" do
ab_test("link_color", "blue", "red")
expect(["red", "blue"]).to include(ab_user["link_color"])
end
it "should increment the participation counter after assignment to a new user" do
previous_red_count = Split::Alternative.new("red", "link_color").participant_count
previous_blue_count = Split::Alternative.new("blue", "link_color").participant_count
ab_test("link_color", "blue", "red")
new_red_count = Split::Alternative.new("red", "link_color").participant_count
new_blue_count = Split::Alternative.new("blue", "link_color").participant_count
expect((new_red_count + new_blue_count)).to eq(previous_red_count + previous_blue_count + 1)
end
it "should not increment the counter for an experiment that the user is not participating in" do
ab_test("link_color", "blue", "red")
e = Split::ExperimentCatalog.find_or_create("button_size", "small", "big")
expect {
# User shouldn't participate in this second experiment
ab_test("button_size", "small", "big")
}.not_to change { e.participant_count }
end
it "should not increment the counter for an ended experiment" do
e = Split::ExperimentCatalog.find_or_create("button_size", "small", "big")
e.winner = "small"
expect {
a = ab_test("button_size", "small", "big")
expect(a).to eq("small")
}.not_to change { e.participant_count }
end
it "should not increment the counter for an not started experiment" do
expect(Split.configuration).to receive(:start_manually).and_return(true)
e = Split::ExperimentCatalog.find_or_create("button_size", "small", "big")
expect {
a = ab_test("button_size", "small", "big")
expect(a).to eq("small")
}.not_to change { e.participant_count }
end
it "should return the given alternative for an existing user" do
expect(ab_test("link_color", "blue", "red")).to eq ab_test("link_color", "blue", "red")
end
it "should always return the winner if one is present" do
experiment.winner = "orange"
expect(ab_test("link_color", "blue", "red")).to eq("orange")
end
it "should allow the alternative to be forced by passing it in the params" do
# ?ab_test[link_color]=blue
@params = { "ab_test" => { "link_color" => "blue" } }
alternative = ab_test("link_color", "blue", "red")
expect(alternative).to eq("blue")
alternative = ab_test("link_color", { "blue" => 1 }, "red" => 5)
expect(alternative).to eq("blue")
@params = { "ab_test" => { "link_color" => "red" } }
alternative = ab_test("link_color", "blue", "red")
expect(alternative).to eq("red")
alternative = ab_test("link_color", { "blue" => 5 }, "red" => 1)
expect(alternative).to eq("red")
end
it "should not allow an arbitrary alternative" do
@params = { "ab_test" => { "link_color" => "pink" } }
alternative = ab_test("link_color", "blue")
expect(alternative).to eq("blue")
end
it "should not store the split when a param forced alternative" do
@params = { "ab_test" => { "link_color" => "blue" } }
expect(ab_user).not_to receive(:[]=)
ab_test("link_color", "blue", "red")
end
it "SPLIT_DISABLE query parameter should also force the alternative (uses control)" do
@params = { "SPLIT_DISABLE" => "true" }
alternative = ab_test("link_color", "blue", "red")
expect(alternative).to eq("blue")
alternative = ab_test("link_color", { "blue" => 1 }, "red" => 5)
expect(alternative).to eq("blue")
alternative = ab_test("link_color", "red", "blue")
expect(alternative).to eq("red")
alternative = ab_test("link_color", { "red" => 5 }, "blue" => 1)
expect(alternative).to eq("red")
end
it "should not store the split when Split generically disabled" do
@params = { "SPLIT_DISABLE" => "true" }
expect(ab_user).not_to receive(:[]=)
ab_test("link_color", "blue", "red")
end
context "when store_override is set" do
before { Split.configuration.store_override = true }
it "should store the forced alternative" do
@params = { "ab_test" => { "link_color" => "blue" } }
expect(ab_user).to receive(:[]=).with("link_color", "blue")
ab_test("link_color", "blue", "red")
end
end
context "when on_trial_choose is set" do
before { Split.configuration.on_trial_choose = :some_method }
it "should call the method" do
expect(self).to receive(:some_method)
ab_test("link_color", "blue", "red")
end
end
it "should allow passing a block" do
alt = ab_test("link_color", "blue", "red")
ret = ab_test("link_color", "blue", "red") { |alternative| "shared/#{alternative}" }
expect(ret).to eq("shared/#{alt}")
end
it "should allow the share of visitors see an alternative to be specified" do
ab_test("link_color", { "blue" => 0.8 }, { "red" => 20 })
expect(["red", "blue"]).to include(ab_user["link_color"])
end
it "should allow alternative weighting interface as a single hash" do
ab_test("link_color", { "blue" => 0.01 }, "red" => 0.2)
experiment = Split::ExperimentCatalog.find("link_color")
expect(experiment.alternatives.map(&:name)).to eq(["blue", "red"])
expect(experiment.alternatives.collect { |a| a.weight }).to match_array([0.01, 0.2])
end
it "should only let a user participate in one experiment at a time" do
link_color = ab_test("link_color", "blue", "red")
ab_test("button_size", "small", "big")
expect(ab_user["link_color"]).to eq(link_color)
big = Split::Alternative.new("big", "button_size")
expect(big.participant_count).to eq(0)
small = Split::Alternative.new("small", "button_size")
expect(small.participant_count).to eq(0)
end
it "should let a user participate in many experiment with allow_multiple_experiments option" do
Split.configure do |config|
config.allow_multiple_experiments = true
end
link_color = ab_test("link_color", "blue", "red")
button_size = ab_test("button_size", "small", "big")
expect(ab_user["link_color"]).to eq(link_color)
expect(ab_user["button_size"]).to eq(button_size)
button_size_alt = Split::Alternative.new(button_size, "button_size")
expect(button_size_alt.participant_count).to eq(1)
end
context "with allow_multiple_experiments = 'control'" do
it "should let a user participate in many experiment with one non-'control' alternative" do
Split.configure do |config|
config.allow_multiple_experiments = "control"
end
groups = 100.times.map do |n|
ab_test("test#{n}".to_sym, { "control" => (100 - n) }, { "test#{n}-alt" => n })
end
experiments = ab_user.active_experiments
expect(experiments.size).to be > 1
count_control = experiments.values.count { |g| g == "control" }
expect(count_control).to eq(experiments.size - 1)
count_alts = groups.count { |g| g != "control" }
expect(count_alts).to eq(1)
end
context "when user already has experiment" do
let(:mock_user) { Split::User.new(self, { "test_0" => "test-alt" }) }
before do
Split.configure do |config|
config.allow_multiple_experiments = "control"
end
Split::ExperimentCatalog.find_or_initialize("test_0", "control", "test-alt").save
Split::ExperimentCatalog.find_or_initialize("test_1", "control", "test-alt").save
end
it "should restore previously selected alternative" do
expect(ab_user.active_experiments.size).to eq 1
expect(ab_test(:test_0, { "control" => 100 }, { "test-alt" => 1 })).to eq "test-alt"
expect(ab_test(:test_0, { "control" => 1 }, { "test-alt" => 100 })).to eq "test-alt"
end
it "should select the correct alternatives after experiment resets" do
experiment = Split::ExperimentCatalog.find(:test_0)
experiment.reset
mock_user[experiment.key] = "test-alt"
expect(ab_user.active_experiments.size).to eq 1
expect(ab_test(:test_0, { "control" => 100 }, { "test-alt" => 1 })).to eq "test-alt"
expect(ab_test(:test_0, { "control" => 0 }, { "test-alt" => 100 })).to eq "test-alt"
end
it "lets override existing choice" do
pending "this requires user store reset on first call not depending on whelther it is current trial"
@params = { "ab_test" => { "test_1" => "test-alt" } }
expect(ab_test(:test_0, { "control" => 0 }, { "test-alt" => 100 })).to eq "control"
expect(ab_test(:test_1, { "control" => 100 }, { "test-alt" => 1 })).to eq "test-alt"
end
end
end
it "should not over-write a finished key when an experiment is on a later version" do
experiment.increment_version
ab_user = { experiment.key => "blue", experiment.finished_key => true }
finished_session = ab_user.dup
ab_test("link_color", "blue", "red")
expect(ab_user).to eq(finished_session)
end
end
describe "metadata" do
context "is defined" do
before do
Split.configuration.experiments = {
my_experiment: {
alternatives: ["one", "two"],
resettable: false,
metadata: { "one" => "Meta1", "two" => "Meta2" }
}
}
end
it "should be passed to helper block" do
@params = { "ab_test" => { "my_experiment" => "two" } }
expect(ab_test("my_experiment")).to eq "two"
expect(ab_test("my_experiment") do |alternative, meta|
meta
end).to eq("Meta2")
end
it "should pass control metadata helper block if library disabled" do
Split.configure do |config|
config.enabled = false
end
expect(ab_test("my_experiment")).to eq "one"
expect(ab_test("my_experiment") do |_, meta|
meta
end).to eq("Meta1")
end
end
context "is not defined" do
before do
Split.configuration.experiments = {
my_experiment: {
alternatives: ["one", "two"],
resettable: false,
metadata: nil
}
}
end
it "should be passed to helper block" do
expect(ab_test("my_experiment") do |alternative, meta|
meta
end).to eq({})
end
it "should pass control metadata helper block if library disabled" do
Split.configure do |config|
config.enabled = false
end
expect(ab_test("my_experiment") do |_, meta|
meta
end).to eq({})
end
end
end
describe "ab_finished" do
context "for an experiment that the user participates in" do
before(:each) do
@experiment_name = "link_color"
@alternatives = ["blue", "red"]
@experiment = Split::ExperimentCatalog.find_or_create(@experiment_name, *@alternatives)
@alternative_name = ab_test(@experiment_name, *@alternatives)
@previous_completion_count = Split::Alternative.new(@alternative_name, @experiment_name).completed_count
end
it "should increment the counter for the completed alternative" do
ab_finished(@experiment_name)
new_completion_count = Split::Alternative.new(@alternative_name, @experiment_name).completed_count
expect(new_completion_count).to eq(@previous_completion_count + 1)
end
it "should set experiment's finished key if reset is false" do
ab_finished(@experiment_name, { reset: false })
expect(ab_user[@experiment.key]).to eq(@alternative_name)
expect(ab_user[@experiment.finished_key]).to eq(true)
end
it "should not increment the counter if reset is false and the experiment has been already finished" do
2.times { ab_finished(@experiment_name, { reset: false }) }
new_completion_count = Split::Alternative.new(@alternative_name, @experiment_name).completed_count
expect(new_completion_count).to eq(@previous_completion_count + 1)
end
it "should not increment the counter for an ended experiment" do
e = Split::ExperimentCatalog.find_or_create("button_size", "small", "big")
e.winner = "small"
a = ab_test("button_size", "small", "big")
expect(a).to eq("small")
expect {
ab_finished("button_size")
}.not_to change { Split::Alternative.new(a, "button_size").completed_count }
end
it "should clear out the user's participation from their session" do
expect(ab_user[@experiment.key]).to eq(@alternative_name)
ab_finished(@experiment_name)
expect(ab_user.keys).to be_empty
end
it "should not clear out the users session if reset is false" do
expect(ab_user[@experiment.key]).to eq(@alternative_name)
ab_finished(@experiment_name, { reset: false })
expect(ab_user[@experiment.key]).to eq(@alternative_name)
expect(ab_user[@experiment.finished_key]).to eq(true)
end
it "should reset the users session when experiment is not versioned" do
expect(ab_user[@experiment.key]).to eq(@alternative_name)
ab_finished(@experiment_name)
expect(ab_user.keys).to be_empty
end
it "should reset the users session when experiment is versioned" do
@experiment.increment_version
@alternative_name = ab_test(@experiment_name, *@alternatives)
expect(ab_user[@experiment.key]).to eq(@alternative_name)
ab_finished(@experiment_name)
expect(ab_user.keys).to be_empty
end
context "when on_trial_complete is set" do
before { Split.configuration.on_trial_complete = :some_method }
it "should call the method" do
expect(self).to receive(:some_method)
ab_finished(@experiment_name)
end
it "should not call the method without alternative" do
ab_user[@experiment.key] = nil
expect(self).not_to receive(:some_method)
ab_finished(@experiment_name)
end
end
end
context "for an experiment that the user is excluded from" do
before do
alternative = ab_test("link_color", "blue", "red")
expect(Split::Alternative.new(alternative, "link_color").participant_count).to eq(1)
alternative = ab_test("button_size", "small", "big")
expect(Split::Alternative.new(alternative, "button_size").participant_count).to eq(0)
end
it "should not increment the completed counter" do
# So, user should be participating in the link_color experiment and
# receive the control for button_size. As the user is not participating in
# the button size experiment, finishing it should not increase the
# completion count for that alternative.
expect {
ab_finished("button_size")
}.not_to change { Split::Alternative.new("small", "button_size").completed_count }
end
end
context "for an experiment that the user does not participate in" do
before do
Split::ExperimentCatalog.find_or_create(:not_started_experiment, "control", "alt")
end
it "should not raise an exception" do
expect { ab_finished(:not_started_experiment) }.not_to raise_exception
end
it "should not change the user state when reset is false" do
expect { ab_finished(:not_started_experiment, reset: false) }.not_to change { ab_user.keys }.from([])
end
it "should not change the user state when reset is true" do
expect(self).not_to receive(:reset!)
ab_finished(:not_started_experiment)
end
it "should not increment the completed counter" do
ab_finished(:not_started_experiment)
expect(Split::Alternative.new("control", :not_started_experiment).completed_count).to eq(0)
expect(Split::Alternative.new("alt", :not_started_experiment).completed_count).to eq(0)
end
end
end
context "finished with config" do
it "passes reset option" do
Split.configuration.experiments = {
my_experiment: {
alternatives: ["one", "two"],
resettable: false,
}
}
alternative = ab_test(:my_experiment)
experiment = Split::ExperimentCatalog.find :my_experiment
ab_finished :my_experiment
expect(ab_user[experiment.key]).to eq(alternative)
expect(ab_user[experiment.finished_key]).to eq(true)
end
end
context "finished with metric name" do
before { Split.configuration.experiments = {} }
before { expect(Split::Alternative).to receive(:new).at_least(1).times.and_call_original }
def should_finish_experiment(experiment_name, should_finish = true)
alts = Split.configuration.experiments[experiment_name][:alternatives]
experiment = Split::ExperimentCatalog.find_or_create(experiment_name, *alts)
alt_name = ab_user[experiment.key] = alts.first
alt = double("alternative")
expect(alt).to receive(:name).at_most(1).times.and_return(alt_name)
expect(Split::Alternative).to receive(:new).at_most(1).times.with(alt_name, experiment_name.to_s).and_return(alt)
if should_finish
expect(alt).to receive(:increment_completion).at_most(1).times
else
expect(alt).not_to receive(:increment_completion)
end
end
it "completes the test" do
Split.configuration.experiments[:my_experiment] = {
alternatives: [ "control_opt", "other_opt" ],
metric: :my_metric
}
should_finish_experiment :my_experiment
ab_finished :my_metric
end
it "completes all relevant tests" do
Split.configuration.experiments = {
exp_1: {
alternatives: [ "1-1", "1-2" ],
metric: :my_metric
},
exp_2: {
alternatives: [ "2-1", "2-2" ],
metric: :another_metric
},
exp_3: {
alternatives: [ "3-1", "3-2" ],
metric: :my_metric
},
}
should_finish_experiment :exp_1
should_finish_experiment :exp_2, false
should_finish_experiment :exp_3
ab_finished :my_metric
end
it "passes reset option" do
Split.configuration.experiments = {
my_exp: {
alternatives: ["one", "two"],
metric: :my_metric,
resettable: false,
}
}
alternative_name = ab_test(:my_exp)
exp = Split::ExperimentCatalog.find :my_exp
ab_finished :my_metric
expect(ab_user[exp.key]).to eq(alternative_name)
expect(ab_user[exp.finished_key]).to be_truthy
end
it "passes through options" do
Split.configuration.experiments = {
my_exp: {
alternatives: ["one", "two"],
metric: :my_metric,
}
}
alternative_name = ab_test(:my_exp)
exp = Split::ExperimentCatalog.find :my_exp
ab_finished :my_metric, reset: false
expect(ab_user[exp.key]).to eq(alternative_name)
expect(ab_user[exp.finished_key]).to be_truthy
end
end
describe "conversions" do
it "should return a conversion rate for an alternative" do
alternative_name = ab_test("link_color", "blue", "red")
previous_convertion_rate = Split::Alternative.new(alternative_name, "link_color").conversion_rate
expect(previous_convertion_rate).to eq(0.0)
ab_finished("link_color")
new_convertion_rate = Split::Alternative.new(alternative_name, "link_color").conversion_rate
expect(new_convertion_rate).to eq(1.0)
end
end
describe "active experiments" do
it "should show an active test" do
alternative = ab_test("def", "4", "5", "6")
expect(active_experiments.count).to eq 1
expect(active_experiments.first[0]).to eq "def"
expect(active_experiments.first[1]).to eq alternative
end
it "should show a finished test" do
alternative = ab_test("def", "4", "5", "6")
ab_finished("def", { reset: false })
expect(active_experiments.count).to eq 1
expect(active_experiments.first[0]).to eq "def"
expect(active_experiments.first[1]).to eq alternative
end
it "should show an active test when an experiment is on a later version" do
experiment.reset
expect(experiment.version).to eq(1)
ab_test("link_color", "blue", "red")
expect(active_experiments.count).to eq 1
expect(active_experiments.first[0]).to eq "link_color"
end
it "should show versioned tests properly" do
10.times { experiment.reset }
alternative = ab_test(experiment.name, "blue", "red")
ab_finished(experiment.name, reset: false)
expect(experiment.version).to eq(10)
expect(active_experiments.count).to eq 1
expect(active_experiments).to eq({ "link_color" => alternative })
end
it "should show multiple tests" do
Split.configure do |config|
config.allow_multiple_experiments = true
end
alternative = ab_test("def", "4", "5", "6")
another_alternative = ab_test("ghi", "7", "8", "9")
expect(active_experiments.count).to eq 2
expect(active_experiments["def"]).to eq alternative
expect(active_experiments["ghi"]).to eq another_alternative
end
it "should not show tests with winners" do
Split.configure do |config|
config.allow_multiple_experiments = true
end
e = Split::ExperimentCatalog.find_or_create("def", "4", "5", "6")
e.winner = "4"
ab_test("def", "4", "5", "6")
another_alternative = ab_test("ghi", "7", "8", "9")
expect(active_experiments.count).to eq 1
expect(active_experiments.first[0]).to eq "ghi"
expect(active_experiments.first[1]).to eq another_alternative
end
end
describe "when user is a robot" do
before(:each) do
@request = OpenStruct.new(user_agent: "Googlebot/2.1 (+http://www.google.com/bot.html)")
end
describe "ab_test" do
it "should return the control" do
alternative = ab_test("link_color", "blue", "red")
expect(alternative).to eq experiment.control.name
end
it "should not create a experiment" do
ab_test("link_color", "blue", "red")
expect(Split::Experiment.new("link_color")).to be_a_new_record
end
it "should not increment the participation count" do
previous_red_count = Split::Alternative.new("red", "link_color").participant_count
previous_blue_count = Split::Alternative.new("blue", "link_color").participant_count
ab_test("link_color", "blue", "red")
new_red_count = Split::Alternative.new("red", "link_color").participant_count
new_blue_count = Split::Alternative.new("blue", "link_color").participant_count
expect((new_red_count + new_blue_count)).to eq(previous_red_count + previous_blue_count)
end
end
describe "finished" do
it "should not increment the completed count" do
alternative_name = ab_test("link_color", "blue", "red")
previous_completion_count = Split::Alternative.new(alternative_name, "link_color").completed_count
ab_finished("link_color")
new_completion_count = Split::Alternative.new(alternative_name, "link_color").completed_count
expect(new_completion_count).to eq(previous_completion_count)
end
end
end
describe "when providing custom ignore logic" do
context "using a proc to configure custom logic" do
before(:each) do
Split.configure do |c|
c.ignore_filter = proc { |request| true } # ignore everything
end
end
it "ignores the ab_test" do
ab_test("link_color", "blue", "red")
red_count = Split::Alternative.new("red", "link_color").participant_count
blue_count = Split::Alternative.new("blue", "link_color").participant_count
expect((red_count + blue_count)).to be(0)
end
end
end
shared_examples_for "a disabled test" do
describe "ab_test" do
it "should return the control" do
alternative = ab_test("link_color", "blue", "red")
expect(alternative).to eq experiment.control.name
end
it "should not increment the participation count" do
previous_red_count = Split::Alternative.new("red", "link_color").participant_count
previous_blue_count = Split::Alternative.new("blue", "link_color").participant_count
ab_test("link_color", "blue", "red")
new_red_count = Split::Alternative.new("red", "link_color").participant_count
new_blue_count = Split::Alternative.new("blue", "link_color").participant_count
expect((new_red_count + new_blue_count)).to eq(previous_red_count + previous_blue_count)
end
end
describe "finished" do
it "should not increment the completed count" do
alternative_name = ab_test("link_color", "blue", "red")
previous_completion_count = Split::Alternative.new(alternative_name, "link_color").completed_count
ab_finished("link_color")
new_completion_count = Split::Alternative.new(alternative_name, "link_color").completed_count
expect(new_completion_count).to eq(previous_completion_count)
end
end
end
describe "when ip address is ignored" do
context "individually" do
before(:each) do
@request = OpenStruct.new(ip: "81.19.48.130")
Split.configure do |c|
c.ignore_ip_addresses << "81.19.48.130"
end
end
it_behaves_like "a disabled test"
end
context "for a range" do
before(:each) do
@request = OpenStruct.new(ip: "81.19.48.129")
Split.configure do |c|
c.ignore_ip_addresses << /81\.19\.48\.[0-9]+/
end
end
it_behaves_like "a disabled test"
end
context "using both a range and a specific value" do
before(:each) do
@request = OpenStruct.new(ip: "81.19.48.128")
Split.configure do |c|
c.ignore_ip_addresses << "81.19.48.130"
c.ignore_ip_addresses << /81\.19\.48\.[0-9]+/
end
end
it_behaves_like "a disabled test"
end
context "when ignored other address" do
before do
@request = OpenStruct.new(ip: "1.1.1.1")
Split.configure do |c|
c.ignore_ip_addresses << "81.19.48.130"
end
end
it "works as usual" do
alternative_name = ab_test("link_color", "red", "blue")
expect {
ab_finished("link_color")
}.to change(Split::Alternative.new(alternative_name, "link_color"), :completed_count).by(1)
end
end
end
describe "when user is previewing" do
before(:each) do
@request = OpenStruct.new(headers: { "x-purpose" => "preview" })
end
it_behaves_like "a disabled test"
end
describe "versioned experiments" do
it "should use version zero if no version is present" do
alternative_name = ab_test("link_color", "blue", "red")
expect(experiment.version).to eq(0)
expect(ab_user["link_color"]).to eq(alternative_name)
end
it "should save the version of the experiment to the session" do
experiment.reset
expect(experiment.version).to eq(1)
alternative_name = ab_test("link_color", "blue", "red")
expect(ab_user["link_color:1"]).to eq(alternative_name)
end
it "should load the experiment even if the version is not 0" do
experiment.reset
expect(experiment.version).to eq(1)
alternative_name = ab_test("link_color", "blue", "red")
expect(ab_user["link_color:1"]).to eq(alternative_name)
return_alternative_name = ab_test("link_color", "blue", "red")
expect(return_alternative_name).to eq(alternative_name)
end
it "should reset the session of a user on an older version of the experiment" do
alternative_name = ab_test("link_color", "blue", "red")
expect(ab_user["link_color"]).to eq(alternative_name)
alternative = Split::Alternative.new(alternative_name, "link_color")
expect(alternative.participant_count).to eq(1)
experiment.reset
expect(experiment.version).to eq(1)
alternative = Split::Alternative.new(alternative_name, "link_color")
expect(alternative.participant_count).to eq(0)
new_alternative_name = ab_test("link_color", "blue", "red")
expect(ab_user["link_color:1"]).to eq(new_alternative_name)
new_alternative = Split::Alternative.new(new_alternative_name, "link_color")
expect(new_alternative.participant_count).to eq(1)
end
it "should cleanup old versions of experiments from the session" do
alternative_name = ab_test("link_color", "blue", "red")
expect(ab_user["link_color"]).to eq(alternative_name)
alternative = Split::Alternative.new(alternative_name, "link_color")
expect(alternative.participant_count).to eq(1)
experiment.reset
expect(experiment.version).to eq(1)
alternative = Split::Alternative.new(alternative_name, "link_color")
expect(alternative.participant_count).to eq(0)
new_alternative_name = ab_test("link_color", "blue", "red")
expect(ab_user["link_color:1"]).to eq(new_alternative_name)
end
it "should only count completion of users on the current version" do
alternative_name = ab_test("link_color", "blue", "red")
expect(ab_user["link_color"]).to eq(alternative_name)
Split::Alternative.new(alternative_name, "link_color")
it "should increment the counter for the specified-goal completed alternative" do
@previous_completion_count_for_goal1 = Split::Alternative.new(@alternative_name, @experiment_name).completed_count(@goal1)
@previous_completion_count_for_goal2 = Split::Alternative.new(@alternative_name, @experiment_name).completed_count(@goal2)
finished({"link_color" => ["purchase"]})
new_completion_count_for_goal1 = Split::Alternative.new(@alternative_name, @experiment_name).completed_count(@goal1)
new_completion_count_for_goal1.should eql(@previous_completion_count_for_goal1 + 1)
new_completion_count_for_goal2 = Split::Alternative.new(@alternative_name, @experiment_name).completed_count(@goal2)
end
context "when redis is not available" do
before(:each) do
expect(Split).to receive(:redis).at_most(5).times.and_raise(Errno::ECONNREFUSED.new)
end
context "and db_failover config option is turned off" do
before(:each) do
Split.configure do |config|
config.db_failover = false
end
end
describe "ab_test" do
it "should raise an exception" do
expect { ab_test("link_color", "blue", "red") }.to raise_error(Errno::ECONNREFUSED)
end
end
describe "finished" do
it "should raise an exception" do
expect { ab_finished("link_color") }.to raise_error(Errno::ECONNREFUSED)
end
end
describe "disable split testing" do
before(:each) do
Split.configure do |config|
config.enabled = false
end
end
it "should not attempt to connect to redis" do
expect { ab_test("link_color", "blue", "red") }.not_to raise_error
end
it "should return control variable" do
expect(ab_test("link_color", "blue", "red")).to eq("blue")
expect { ab_finished("link_color") }.not_to raise_error
end
end
end
context "and db_failover config option is turned on" do
before(:each) do
Split.configure do |config|
config.db_failover = true
end
end
describe "ab_test" do
it "should not raise an exception" do
expect { ab_test("link_color", "blue", "red") }.not_to raise_error
end
it "should call db_failover_on_db_error proc with error as parameter" do
Split.configure do |config|
config.db_failover_on_db_error = proc do |error|
expect(error).to be_a(Errno::ECONNREFUSED)
end
end
expect(Split.configuration.db_failover_on_db_error).to receive(:call).and_call_original
ab_test("link_color", "blue", "red")
end
it "should always use first alternative" do
expect(ab_test("link_color", "blue", "red")).to eq("blue")
expect(ab_test("link_color", { "blue" => 0.01 }, "red" => 0.2)).to eq("blue")
expect(ab_test("link_color", { "blue" => 0.8 }, { "red" => 20 })).to eq("blue")
expect(ab_test("link_color", "blue", "red") do |alternative|
"shared/#{alternative}"
end).to eq("shared/blue")
end
context "and db_failover_allow_parameter_override config option is turned on" do
before(:each) do
Split.configure do |config|
config.db_failover_allow_parameter_override = true
end
end
context "and given an override parameter" do
it "should use given override instead of the first alternative" do
@params = { "ab_test" => { "link_color" => "red" } }
expect(ab_test("link_color", "blue", "red")).to eq("red")
expect(ab_test("link_color", "blue", "red", "green")).to eq("red")
expect(ab_test("link_color", { "blue" => 0.01 }, "red" => 0.2)).to eq("red")
expect(ab_test("link_color", { "blue" => 0.8 }, { "red" => 20 })).to eq("red")
expect(ab_test("link_color", "blue", "red") do |alternative|
"shared/#{alternative}"
end).to eq("shared/red")
end
end
end
context "and preloaded config given" do
before do
Split.configuration.experiments[:link_color] = {
alternatives: [ "blue", "red" ],
}
end
it "uses first alternative" do
expect(ab_test(:link_color)).to eq("blue")
end
end
end
describe "finished" do
it "should not raise an exception" do
expect { ab_finished("link_color") }.not_to raise_error
end
it "should call db_failover_on_db_error proc with error as parameter" do
Split.configure do |config|
config.db_failover_on_db_error = proc do |error|
expect(error).to be_a(Errno::ECONNREFUSED)
end
end
expect(Split.configuration.db_failover_on_db_error).to receive(:call).and_call_original
ab_finished("link_color")
end
end
end
end
context "with preloaded config" do
before { Split.configuration.experiments = {} }
it "pulls options from config file" do
Split.configuration.experiments[:my_experiment] = {
alternatives: [ "control_opt", "other_opt" ],
goals: ["goal1", "goal2"]
}
ab_test :my_experiment
expect(Split::Experiment.new(:my_experiment).alternatives.map(&:name)).to eq([ "control_opt", "other_opt" ])
expect(Split::Experiment.new(:my_experiment).goals).to eq([ "goal1", "goal2" ])
end
it "can be called multiple times" do
Split.configuration.experiments[:my_experiment] = {
alternatives: [ "control_opt", "other_opt" ],
goals: ["goal1", "goal2"]
}
5.times { ab_test :my_experiment }
experiment = Split::Experiment.new(:my_experiment)
expect(experiment.alternatives.map(&:name)).to eq([ "control_opt", "other_opt" ])
expect(experiment.goals).to eq([ "goal1", "goal2" ])
expect(experiment.participant_count).to eq(1)
end
it "accepts multiple goals" do
Split.configuration.experiments[:my_experiment] = {
alternatives: [ "control_opt", "other_opt" ],
goals: [ "goal1", "goal2", "goal3" ]
}
ab_test :my_experiment
experiment = Split::Experiment.new(:my_experiment)
expect(experiment.goals).to eq([ "goal1", "goal2", "goal3" ])
end
it "allow specifying goals to be optional" do
Split.configuration.experiments[:my_experiment] = {
alternatives: [ "control_opt", "other_opt" ]
}
experiment = Split::Experiment.new(:my_experiment)
expect(experiment.goals).to eq([])
end
it "accepts multiple alternatives" do
Split.configuration.experiments[:my_experiment] = {
alternatives: [ "control_opt", "second_opt", "third_opt" ],
}
ab_test :my_experiment
experiment = Split::Experiment.new(:my_experiment)
expect(experiment.alternatives.map(&:name)).to eq([ "control_opt", "second_opt", "third_opt" ])
end
it "accepts probability on alternatives" do
Split.configuration.experiments[:my_experiment] = {
alternatives: [
{ name: "control_opt", percent: 67 },
{ name: "second_opt", percent: 10 },
{ name: "third_opt", percent: 23 },
],
}
ab_test :my_experiment
experiment = Split::Experiment.new(:my_experiment)
expect(experiment.alternatives.collect { |a| [a.name, a.weight] }).to eq([["control_opt", 0.67], ["second_opt", 0.1], ["third_opt", 0.23]])
end
it "accepts probability on some alternatives" do
Split.configuration.experiments[:my_experiment] = {
alternatives: [
{ name: "control_opt", percent: 34 },
"second_opt",
{ name: "third_opt", percent: 23 },
"fourth_opt",
],
}
ab_test :my_experiment
experiment = Split::Experiment.new(:my_experiment)
names_and_weights = experiment.alternatives.collect { |a| [a.name, a.weight] }
expect(names_and_weights).to eq([["control_opt", 0.34], ["second_opt", 0.215], ["third_opt", 0.23], ["fourth_opt", 0.215]])
expect(names_and_weights.inject(0) { |sum, nw| sum + nw[1] }).to eq(1.0)
end
it "allows name param without probability" do
Split.configuration.experiments[:my_experiment] = {
alternatives: [
{ name: "control_opt" },
"second_opt",
{ name: "third_opt", percent: 64 },
],
}
ab_test :my_experiment
experiment = Split::Experiment.new(:my_experiment)
names_and_weights = experiment.alternatives.collect { |a| [a.name, a.weight] }
expect(names_and_weights).to eq([["control_opt", 0.18], ["second_opt", 0.18], ["third_opt", 0.64]])
expect(names_and_weights.inject(0) { |sum, nw| sum + nw[1] }).to eq(1.0)
end
it "fails gracefully if config is missing experiment" do
Split.configuration.experiments = { other_experiment: { foo: "Bar" } }
expect { ab_test :my_experiment }.to raise_error(Split::ExperimentNotFound)
end
it "fails gracefully if config is missing" do
expect { Split.configuration.experiments = nil }.to raise_error(Split::InvalidExperimentsFormatError)
end
it "fails gracefully if config is missing alternatives" do
Split.configuration.experiments[:my_experiment] = { foo: "Bar" }
expect { ab_test :my_experiment }.to raise_error(NoMethodError)
end
end
it "should handle multiple experiments correctly" do
experiment2 = Split::ExperimentCatalog.find_or_create("link_color2", "blue", "red")
ab_test("link_color", "blue", "red")
ab_test("link_color2", "blue", "red")
ab_finished("link_color2")
experiment2.alternatives.each do |alt|
expect(alt.unfinished_count).to eq(0)
end
end
context "with goals" do
before do
@experiment = { "link_color" => ["purchase", "refund"] }
@alternatives = ["blue", "red"]
@experiment_name, @goals = normalize_metric(@experiment)
@goal1 = @goals[0]
@goal2 = @goals[1]
end
it "should normalize experiment" do
expect(@experiment_name).to eq("link_color")
expect(@goals).to eq(["purchase", "refund"])
end
describe "ab_test" do
it "should allow experiment goals interface as a single hash" do
ab_test(@experiment, *@alternatives)
experiment = Split::ExperimentCatalog.find("link_color")
expect(experiment.goals).to eq(["purchase", "refund"])
end
end
describe "ab_finished" do
before do
@alternative_name = ab_test(@experiment, *@alternatives)
end
it "should increment the counter for the specified-goal completed alternative" do
expect { ab_finished({ "link_color" => ["purchase"] }) }
.to change { Split::Alternative.new(@alternative_name, @experiment_name).completed_count(@goal2) }.by(0)
.and change { Split::Alternative.new(@alternative_name, @experiment_name).completed_count(@goal1) }.by(1)
end
end
end
end
<MSG> Merge pull request #151 from andrew/goals_no_array
finished method accept goals that are not passed as arrays
<DFF> @@ -27,8 +27,8 @@ describe Split::Helper do
lambda { ab_test({'link_color' => ["purchase", "refund"]}, 'blue', 'red') }.should_not raise_error
end
- it "should raise the appropriate error when passed string for goals" do
- lambda { ab_test({'link_color' => "purchase"}, 'blue', 'red') }.should raise_error(ArgumentError)
+ it "should not raise error when passed just one goal" do
+ lambda { ab_test({'link_color' => "purchase"}, 'blue', 'red') }.should_not raise_error
end
it "should assign a random alternative to a new user when there are an equal number of alternatives assigned" do
@@ -852,7 +852,7 @@ describe Split::Helper do
it "should increment the counter for the specified-goal completed alternative" do
@previous_completion_count_for_goal1 = Split::Alternative.new(@alternative_name, @experiment_name).completed_count(@goal1)
@previous_completion_count_for_goal2 = Split::Alternative.new(@alternative_name, @experiment_name).completed_count(@goal2)
- finished({"link_color" => ["purchase"]})
+ finished({"link_color" => "purchase"})
new_completion_count_for_goal1 = Split::Alternative.new(@alternative_name, @experiment_name).completed_count(@goal1)
new_completion_count_for_goal1.should eql(@previous_completion_count_for_goal1 + 1)
new_completion_count_for_goal2 = Split::Alternative.new(@alternative_name, @experiment_name).completed_count(@goal2)
| 3 | Merge pull request #151 from andrew/goals_no_array | 3 | .rb | rb | mit | splitrb/split |
10071637 | <NME> parser.ts
<BEF> import { strictEqual as equal, throws } from 'assert';
import parser from '../src/parser';
import tokenizer from '../src/tokenizer';
import stringify from './assets/stringify';
import { ParserOptions } from '../src';
const parse = (abbr: string, options?: ParserOptions) => parser(tokenizer(abbr), options);
const str = (abbr: string, options?: ParserOptions) => stringify(parse(abbr, options));
describe('Parser', () => {
it('basic abbreviations', () => {
equal(str('p'), '<p></p>');
equal(str('p{text}'), '<p>text</p>');
equal(str('h$'), '<h$></h$>');
equal(str('.nav'), '<? class=nav></?>');
equal(str('div.width1\\/2'), '<div class=width1/2></div>');
equal(str('#sample*3'), '<?*3 id=sample></?>');
// https://github.com/emmetio/emmet/issues/562
equal(str('li[repeat.for="todo of todoList"]'), '<li repeat.for="todo of todoList"></li>', 'Dots in attribute names');
equal(str('a>b'), '<a><b></b></a>');
equal(str('a+b'), '<a></a><b></b>');
equal(str('a+b>c+d'), '<a></a><b><c></c><d></d></b>');
equal(str('a>b>c+e'), '<a><b><c></c><e></e></b></a>');
equal(str('a>b>c^d'), '<a><b><c></c></b><d></d></a>');
equal(str('a>b>c^^^^d'), '<a><b><c></c></b></a><d></d>');
equal(str('a:b>c'), '<a:b><c></c></a:b>');
equal(str('ul.nav[title="foo"]'), '<ul class=nav title="foo"></ul>');
});
it('groups', () => {
equal(str('a>(b>c)+d'), '<a>(<b><c></c></b>)<d></d></a>');
equal(str('(a>b)+(c>d)'), '(<a><b></b></a>)(<c><d></d></c>)');
equal(str('a>((b>c)(d>e))f'), '<a>((<b><c></c></b>)(<d><e></e></d>))<f></f></a>');
equal(str('a>((((b>c))))+d'), '<a>((((<b><c></c></b>))))<d></d></a>');
equal(str('a>(((b>c))*4)+d'), '<a>(((<b><c></c></b>))*4)<d></d></a>');
equal(str('(div>dl>(dt+dd)*2)'), '(<div><dl>(<dt></dt><dd></dd>)*2</dl></div>)');
equal(str('a>()'), '<a>()</a>');
});
it('attributes', () => {
equal(str('[].foo'), '<? class=foo></?>');
equal(str('[a]'), '<? a></?>');
equal(str('[a b c [d]]'), '<? a b c [d]></?>');
equal(str('[a=b]'), '<? a=b></?>');
equal(str('[a=b c= d=e]'), '<? a=b c d=e></?>');
equal(str('[a=b.c d=ัะตัั]'), '<? a=b.c d=ัะตัั></?>');
equal(str('[[a]=b (c)=d]'), '<? [a]=b (c)=d></?>');
// Quoted attribute values
equal(str('[a="b"]'), '<? a="b"></?>');
equal(str('[a="b" c=\'d\' e=""]'), '<? a="b" c=\'d\' e=""></?>');
equal(str('[[a]="b" (c)=\'d\']'), '<? [a]="b" (c)=\'d\'></?>');
// Mixed quoted
equal(str('[a="foo\'bar" b=\'foo"bar\' c="foo\\\"bar"]'), '<? a="foo\'bar" b=\'foo"bar\' c="foo"bar"></?>');
// Boolean & implied attributes
equal(str('[a. b.]'), '<? a. b.></?>');
equal(str('[!a !b.]'), '<? !a !b.></?>');
// Default values
equal(str('["a.b"]'), '<? ?="a.b"></?>');
equal(str('[\'a.b\' "c=d" foo=bar "./test.html"]'), '<? ?=\'a.b\' ?="c=d" foo=bar ?="./test.html"></?>');
// Expressions as values
equal(str('[foo={1 + 2} bar={fn(1, "foo")}]'), '<? foo={1 + 2} bar={fn(1, "foo")}></?>');
// Tabstops as unquoted values
equal(str('[name=${1} value=${2:test}]'), '<? name=${1} value=${2:test}></?>');
});
it('malformed attributes', () => {
equal(str('[a'), '<? a></?>');
equal(str('[a={foo]'), '<? a={foo]></?>');
throws(() => str('[a="foo]'), /Unclosed quote/);
throws(() => str('[a=b=c]'), /Unexpected "Operator" token/);
});
it('elements', () => {
equal(str('div'), '<div></div>');
equal(str('div.foo'), '<div class=foo></div>');
equal(str('div#foo'), '<div id=foo></div>');
equal(str('div#foo.bar'), '<div id=foo class=bar></div>');
equal(str('div.foo#bar'), '<div class=foo id=bar></div>');
equal(str('div.foo.bar.baz'), '<div class=foo class=bar class=baz></div>');
equal(str('.foo'), '<? class=foo></?>');
equal(str('#foo'), '<? id=foo></?>');
equal(str('.foo_bar'), '<? class=foo_bar></?>');
equal(str('#foo.bar'), '<? id=foo class=bar></?>');
// Attribute shorthands
equal(str('.'), '<? class></?>');
equal(str('#'), '<? id></?>');
equal(str('#.'), '<? id class></?>');
equal(str('.#.'), '<? class id class></?>');
equal(str('.a..'), '<? class=a class></?>');
// Elements with attributes
equal(str('div[foo=bar]'), '<div foo=bar></div>');
equal(str('div.a[b=c]'), '<div class=a b=c></div>');
equal(str('div[b=c].a'), '<div b=c class=a></div>');
equal(str('div[a=b][c="d"]'), '<div a=b c="d"></div>');
equal(str('[b=c]'), '<? b=c></?>');
equal(str('.a[b=c]'), '<? class=a b=c></?>');
equal(str('[b=c].a#d'), '<? b=c class=a id=d></?>');
equal(str('[b=c]a'), '<? b=c></?><a></a>', 'Do not consume node name after attribute set');
// Element with text
equal(str('div{foo}'), '<div>foo</div>');
equal(str('{foo}'), '<?>foo</?>');
// Mixed
equal(str('div.foo{bar}'), '<div class=foo>bar</div>');
equal(str('.foo{bar}#baz'), '<? class=foo id=baz>bar</?>');
equal(str('.foo[b=c]{bar}'), '<? class=foo b=c>bar</?>');
// Repeated element
equal(str('div.foo*3'), '<div*3 class=foo></div>');
equal(str('.foo*'), '<?* class=foo></?>');
equal(str('.a[b=c]*10'), '<?*10 class=a b=c></?>');
equal(str('.a*10[b=c]'), '<?*10 class=a b=c></?>');
equal(str('.a*10{text}'), '<?*10 class=a>text</?>');
// Self-closing element
equal(str('div/'), '<div />');
equal(str('.foo/'), '<? class=foo />');
equal(str('.foo[bar]/'), '<? class=foo bar />');
equal(str('.foo/*3'), '<?*3 class=foo />');
equal(str('.foo*3/'), '<?*3 class=foo />');
throws(() => parse('/'), /Unexpected character/);
});
it('JSX', () => {
equal(str('foo.bar', opt), '<foo class=bar></foo>');
equal(str('Foo.bar', opt), '<Foo class=bar></Foo>');
equal(str('Foo.Bar', opt), '<Foo.Bar></Foo.Bar>');
equal(str('Foo.Bar.baz', opt), '<Foo.Bar class=baz></Foo.Bar>');
equal(str('Foo.Bar.Baz', opt), '<Foo.Bar.Baz></Foo.Bar.Baz>');
equal(str('.{theme.class}', opt), '<? class=theme.class></?>');
equal(str('#{id}', opt), '<? id=id></?>');
equal(str('Foo.{theme.class}', opt), '<Foo class=theme.class></Foo>');
});
it('errors', () => {
throws(() => parse('str?'), /Unexpected character at 4/);
throws(() => parse('foo,bar'), /Unexpected character at 4/);
equal(str('foo\\,bar'), '<foo,bar></foo,bar>');
equal(str('foo\\'), '<foo></foo>');
});
it('missing braces', () => {
// Do not throw errors on missing closing braces
equal(str('div[title="test"'), '<div title="test"></div>');
equal(str('div(foo'), '<div></div>(<foo></foo>)');
equal(str('div{foo'), '<div>foo</div>');
});
});
<MSG> [jsx] Fixed error when consuming camel-cased JSX tag names
<DFF> @@ -138,6 +138,7 @@ describe('Parser', () => {
equal(str('foo.bar', opt), '<foo class=bar></foo>');
equal(str('Foo.bar', opt), '<Foo class=bar></Foo>');
equal(str('Foo.Bar', opt), '<Foo.Bar></Foo.Bar>');
+ equal(str('Foo.', opt), '<Foo class></Foo>');
equal(str('Foo.Bar.baz', opt), '<Foo.Bar class=baz></Foo.Bar>');
equal(str('Foo.Bar.Baz', opt), '<Foo.Bar.Baz></Foo.Bar.Baz>');
| 1 | [jsx] Fixed error when consuming camel-cased JSX tag names | 0 | .ts | ts | mit | emmetio/emmet |
10071638 | <NME> parser.ts
<BEF> import { strictEqual as equal, throws } from 'assert';
import parser from '../src/parser';
import tokenizer from '../src/tokenizer';
import stringify from './assets/stringify';
import { ParserOptions } from '../src';
const parse = (abbr: string, options?: ParserOptions) => parser(tokenizer(abbr), options);
const str = (abbr: string, options?: ParserOptions) => stringify(parse(abbr, options));
describe('Parser', () => {
it('basic abbreviations', () => {
equal(str('p'), '<p></p>');
equal(str('p{text}'), '<p>text</p>');
equal(str('h$'), '<h$></h$>');
equal(str('.nav'), '<? class=nav></?>');
equal(str('div.width1\\/2'), '<div class=width1/2></div>');
equal(str('#sample*3'), '<?*3 id=sample></?>');
// https://github.com/emmetio/emmet/issues/562
equal(str('li[repeat.for="todo of todoList"]'), '<li repeat.for="todo of todoList"></li>', 'Dots in attribute names');
equal(str('a>b'), '<a><b></b></a>');
equal(str('a+b'), '<a></a><b></b>');
equal(str('a+b>c+d'), '<a></a><b><c></c><d></d></b>');
equal(str('a>b>c+e'), '<a><b><c></c><e></e></b></a>');
equal(str('a>b>c^d'), '<a><b><c></c></b><d></d></a>');
equal(str('a>b>c^^^^d'), '<a><b><c></c></b></a><d></d>');
equal(str('a:b>c'), '<a:b><c></c></a:b>');
equal(str('ul.nav[title="foo"]'), '<ul class=nav title="foo"></ul>');
});
it('groups', () => {
equal(str('a>(b>c)+d'), '<a>(<b><c></c></b>)<d></d></a>');
equal(str('(a>b)+(c>d)'), '(<a><b></b></a>)(<c><d></d></c>)');
equal(str('a>((b>c)(d>e))f'), '<a>((<b><c></c></b>)(<d><e></e></d>))<f></f></a>');
equal(str('a>((((b>c))))+d'), '<a>((((<b><c></c></b>))))<d></d></a>');
equal(str('a>(((b>c))*4)+d'), '<a>(((<b><c></c></b>))*4)<d></d></a>');
equal(str('(div>dl>(dt+dd)*2)'), '(<div><dl>(<dt></dt><dd></dd>)*2</dl></div>)');
equal(str('a>()'), '<a>()</a>');
});
it('attributes', () => {
equal(str('[].foo'), '<? class=foo></?>');
equal(str('[a]'), '<? a></?>');
equal(str('[a b c [d]]'), '<? a b c [d]></?>');
equal(str('[a=b]'), '<? a=b></?>');
equal(str('[a=b c= d=e]'), '<? a=b c d=e></?>');
equal(str('[a=b.c d=ัะตัั]'), '<? a=b.c d=ัะตัั></?>');
equal(str('[[a]=b (c)=d]'), '<? [a]=b (c)=d></?>');
// Quoted attribute values
equal(str('[a="b"]'), '<? a="b"></?>');
equal(str('[a="b" c=\'d\' e=""]'), '<? a="b" c=\'d\' e=""></?>');
equal(str('[[a]="b" (c)=\'d\']'), '<? [a]="b" (c)=\'d\'></?>');
// Mixed quoted
equal(str('[a="foo\'bar" b=\'foo"bar\' c="foo\\\"bar"]'), '<? a="foo\'bar" b=\'foo"bar\' c="foo"bar"></?>');
// Boolean & implied attributes
equal(str('[a. b.]'), '<? a. b.></?>');
equal(str('[!a !b.]'), '<? !a !b.></?>');
// Default values
equal(str('["a.b"]'), '<? ?="a.b"></?>');
equal(str('[\'a.b\' "c=d" foo=bar "./test.html"]'), '<? ?=\'a.b\' ?="c=d" foo=bar ?="./test.html"></?>');
// Expressions as values
equal(str('[foo={1 + 2} bar={fn(1, "foo")}]'), '<? foo={1 + 2} bar={fn(1, "foo")}></?>');
// Tabstops as unquoted values
equal(str('[name=${1} value=${2:test}]'), '<? name=${1} value=${2:test}></?>');
});
it('malformed attributes', () => {
equal(str('[a'), '<? a></?>');
equal(str('[a={foo]'), '<? a={foo]></?>');
throws(() => str('[a="foo]'), /Unclosed quote/);
throws(() => str('[a=b=c]'), /Unexpected "Operator" token/);
});
it('elements', () => {
equal(str('div'), '<div></div>');
equal(str('div.foo'), '<div class=foo></div>');
equal(str('div#foo'), '<div id=foo></div>');
equal(str('div#foo.bar'), '<div id=foo class=bar></div>');
equal(str('div.foo#bar'), '<div class=foo id=bar></div>');
equal(str('div.foo.bar.baz'), '<div class=foo class=bar class=baz></div>');
equal(str('.foo'), '<? class=foo></?>');
equal(str('#foo'), '<? id=foo></?>');
equal(str('.foo_bar'), '<? class=foo_bar></?>');
equal(str('#foo.bar'), '<? id=foo class=bar></?>');
// Attribute shorthands
equal(str('.'), '<? class></?>');
equal(str('#'), '<? id></?>');
equal(str('#.'), '<? id class></?>');
equal(str('.#.'), '<? class id class></?>');
equal(str('.a..'), '<? class=a class></?>');
// Elements with attributes
equal(str('div[foo=bar]'), '<div foo=bar></div>');
equal(str('div.a[b=c]'), '<div class=a b=c></div>');
equal(str('div[b=c].a'), '<div b=c class=a></div>');
equal(str('div[a=b][c="d"]'), '<div a=b c="d"></div>');
equal(str('[b=c]'), '<? b=c></?>');
equal(str('.a[b=c]'), '<? class=a b=c></?>');
equal(str('[b=c].a#d'), '<? b=c class=a id=d></?>');
equal(str('[b=c]a'), '<? b=c></?><a></a>', 'Do not consume node name after attribute set');
// Element with text
equal(str('div{foo}'), '<div>foo</div>');
equal(str('{foo}'), '<?>foo</?>');
// Mixed
equal(str('div.foo{bar}'), '<div class=foo>bar</div>');
equal(str('.foo{bar}#baz'), '<? class=foo id=baz>bar</?>');
equal(str('.foo[b=c]{bar}'), '<? class=foo b=c>bar</?>');
// Repeated element
equal(str('div.foo*3'), '<div*3 class=foo></div>');
equal(str('.foo*'), '<?* class=foo></?>');
equal(str('.a[b=c]*10'), '<?*10 class=a b=c></?>');
equal(str('.a*10[b=c]'), '<?*10 class=a b=c></?>');
equal(str('.a*10{text}'), '<?*10 class=a>text</?>');
// Self-closing element
equal(str('div/'), '<div />');
equal(str('.foo/'), '<? class=foo />');
equal(str('.foo[bar]/'), '<? class=foo bar />');
equal(str('.foo/*3'), '<?*3 class=foo />');
equal(str('.foo*3/'), '<?*3 class=foo />');
throws(() => parse('/'), /Unexpected character/);
});
it('JSX', () => {
equal(str('foo.bar', opt), '<foo class=bar></foo>');
equal(str('Foo.bar', opt), '<Foo class=bar></Foo>');
equal(str('Foo.Bar', opt), '<Foo.Bar></Foo.Bar>');
equal(str('Foo.Bar.baz', opt), '<Foo.Bar class=baz></Foo.Bar>');
equal(str('Foo.Bar.Baz', opt), '<Foo.Bar.Baz></Foo.Bar.Baz>');
equal(str('.{theme.class}', opt), '<? class=theme.class></?>');
equal(str('#{id}', opt), '<? id=id></?>');
equal(str('Foo.{theme.class}', opt), '<Foo class=theme.class></Foo>');
});
it('errors', () => {
throws(() => parse('str?'), /Unexpected character at 4/);
throws(() => parse('foo,bar'), /Unexpected character at 4/);
equal(str('foo\\,bar'), '<foo,bar></foo,bar>');
equal(str('foo\\'), '<foo></foo>');
});
it('missing braces', () => {
// Do not throw errors on missing closing braces
equal(str('div[title="test"'), '<div title="test"></div>');
equal(str('div(foo'), '<div></div>(<foo></foo>)');
equal(str('div{foo'), '<div>foo</div>');
});
});
<MSG> [jsx] Fixed error when consuming camel-cased JSX tag names
<DFF> @@ -138,6 +138,7 @@ describe('Parser', () => {
equal(str('foo.bar', opt), '<foo class=bar></foo>');
equal(str('Foo.bar', opt), '<Foo class=bar></Foo>');
equal(str('Foo.Bar', opt), '<Foo.Bar></Foo.Bar>');
+ equal(str('Foo.', opt), '<Foo class></Foo>');
equal(str('Foo.Bar.baz', opt), '<Foo.Bar class=baz></Foo.Bar>');
equal(str('Foo.Bar.Baz', opt), '<Foo.Bar.Baz></Foo.Bar.Baz>');
| 1 | [jsx] Fixed error when consuming camel-cased JSX tag names | 0 | .ts | ts | mit | emmetio/emmet |
10071639 | <NME> .gitignore
<BEF> .idea
*.html.js
.DS_Store
.grunt
/node_modules
/dist
*-SNAPSHOT*
.vscode
src/**/*.js
src/**/*.map
<MSG> chore(.gitignore): Exclude external libs
<DFF> @@ -4,5 +4,6 @@
.grunt
/node_modules
/dist
+/lib
*-SNAPSHOT*
| 1 | chore(.gitignore): Exclude external libs | 0 | gitignore | mit | Semantic-Org/Semantic-UI-Angular |
|
10071640 | <NME> .gitignore
<BEF> .idea
*.html.js
.DS_Store
.grunt
/node_modules
/dist
*-SNAPSHOT*
.vscode
src/**/*.js
src/**/*.map
<MSG> chore(.gitignore): Exclude external libs
<DFF> @@ -4,5 +4,6 @@
.grunt
/node_modules
/dist
+/lib
*-SNAPSHOT*
| 1 | chore(.gitignore): Exclude external libs | 0 | gitignore | mit | Semantic-Org/Semantic-UI-Angular |
|
10071641 | <NME> .gitignore
<BEF> .idea
*.html.js
.DS_Store
.grunt
/node_modules
/dist
*-SNAPSHOT*
.vscode
src/**/*.js
src/**/*.map
<MSG> chore(.gitignore): Exclude external libs
<DFF> @@ -4,5 +4,6 @@
.grunt
/node_modules
/dist
+/lib
*-SNAPSHOT*
| 1 | chore(.gitignore): Exclude external libs | 0 | gitignore | mit | Semantic-Org/Semantic-UI-Angular |
|
10071642 | <NME> forms.py
<BEF> import os
from django import forms
from django.conf import settings
from djangopypi.models import Project, Classifier, Release
from django.utils.translation import ugettext_lazy as _
class ProjectForm(forms.ModelForm):
class Meta:
model = Project
exclude = ['owner', 'classifiers']
class ReleaseForm(forms.ModelForm):
class Meta:
model = Release
exclude = ['project'] # filename, however with .tar.gz files django does the "wrong" thing
# and saves it as project-0.1.2.tar_.gz. So remove it before
# django sees anything.
allow_overwrite = getattr(settings,
"DJANGOPYPI_ALLOW_VERSION_OVERWRITE", False)
<MSG> Whitespace fix.
<DFF> @@ -91,7 +91,6 @@ class ProjectRegisterForm(forms.Form):
# filename, however with .tar.gz files django does the "wrong" thing
# and saves it as project-0.1.2.tar_.gz. So remove it before
# django sees anything.
-
allow_overwrite = getattr(settings,
"DJANGOPYPI_ALLOW_VERSION_OVERWRITE", False)
| 0 | Whitespace fix. | 1 | .py | py | bsd-3-clause | ask/chishop |
10071643 | <NME> stylesheet.ts
<BEF> import { strictEqual as equal, ok } from 'assert';
import { stylesheet as expandAbbreviation, resolveConfig, CSSAbbreviationScope } from '../src';
import score from '../src/stylesheet/score';
const defaultConfig = resolveConfig({
type: 'stylesheet',
options: {
'output.field': (index, placeholder) => `\${${index}${placeholder ? ':' + placeholder : ''}}`,
'stylesheet.fuzzySearchMinScore': 0
},
snippets: {
mten: 'margin: 10px;',
fsz: 'font-size',
gt: 'grid-template: repeat(2,auto) / repeat(auto-fit, minmax(250px, 1fr))'
},
cache: {},
});
function expand(abbr: string, config = defaultConfig) {
return expandAbbreviation(abbr, config);
}
describe('Stylesheet abbreviations', () => {
describe('Scoring', () => {
const pick = (abbr: string, items: string[]) => items
.map(item => ({ item, score: score(abbr, item, true) }))
.filter(obj => obj.score)
.sort((a, b) => b.score - a.score)
.map(obj => obj.item)[0];
it('compare scores', () => {
equal(score('aaa', 'aaa'), 1);
equal(score('baa', 'aaa'), 0);
ok(!score('b', 'aaa'));
ok(score('a', 'aaa'));
ok(score('a', 'abc'));
ok(score('ac', 'abc'));
ok(score('a', 'aaa') < score('aa', 'aaa'));
ok(score('ab', 'abc') > score('ab', 'acb'));
// acronym bonus
ok(score('ab', 'a-b') > score('ab', 'acb'));
});
it('pick padding or position', () => {
const items = ['p', 'pb', 'pl', 'pos', 'pa', 'oa', 'soa', 'pr', 'pt'];
equal(pick('p', items), 'p');
equal(pick('poa', items), 'pos');
});
});
it('keywords', () => {
equal(expand('bd1-s'), 'border: 1px solid;');
equal(expand('dib'), 'display: inline-block;');
equal(expand('bxsz'), 'box-sizing: ${1:border-box};');
equal(expand('bxz'), 'box-sizing: ${1:border-box};');
equal(expand('bxzc'), 'box-sizing: content-box;');
equal(expand('fl'), 'float: ${1:left};');
equal(expand('fll'), 'float: left;');
equal(expand('pos'), 'position: ${1:relative};');
equal(expand('poa'), 'position: absolute;');
equal(expand('por'), 'position: relative;');
equal(expand('pof'), 'position: fixed;');
equal(expand('pos-a'), 'position: absolute;');
equal(expand('m'), 'margin: ${0};');
equal(expand('m0'), 'margin: 0;');
// use `auto` as global keyword
equal(expand('m0-a'), 'margin: 0 auto;');
equal(expand('m-a'), 'margin: auto;');
equal(expand('bg'), 'background: ${1:#000};');
equal(expand('bd'), 'border: ${1:1px} ${2:solid} ${3:#000};');
equal(expand('bd0-s#fc0'), 'border: 0 solid #fc0;');
equal(expand('bd0-dd#fc0'), 'border: 0 dot-dash #fc0;');
equal(expand('bd0-h#fc0'), 'border: 0 hidden #fc0;');
equal(expand('trf-trs'), 'transform: translate(${1:x}, ${2:y});');
// https://github.com/emmetio/emmet/issues/610
equal(expand('c'), 'color: ${1:#000};');
equal(expand('cr'), 'color: rgb(${1:0}, ${2:0}, ${3:0});');
equal(expand('cra'), 'color: rgba(${1:0}, ${2:0}, ${3:0}, ${4:.5});');
// https://github.com/emmetio/emmet/issues/647
equal(expand('gtc'), 'grid-template-columns: repeat(${0});');
equal(expand('gtr'), 'grid-template-rows: repeat(${0});');
equal(expand('lis:n'), 'list-style: none;');
equal(expand('list:n'), 'list-style-type: none;');
equal(expand('bdt:n'), 'border-top: none;');
equal(expand('bgi:n'), 'background-image: none;');
equal(expand('q:n'), 'quotes: none;');
});
it('numeric', () => {
equal(expand('p0'), 'padding: 0;', 'No unit for 0');
equal(expand('p10'), 'padding: 10px;', '`px` unit for integers');
equal(expand('p.4'), 'padding: 0.4em;', '`em` for floats');
equal(expand('fz10'), 'font-size: 10px;', '`px` for integers');
equal(expand('fz1.'), 'font-size: 1em;', '`em` for explicit float');
equal(expand('p10p'), 'padding: 10%;', 'unit alias');
equal(expand('z10'), 'z-index: 10;', 'Unitless property');
equal(expand('p10r'), 'padding: 10rem;', 'unit alias');
equal(expand('mten'), 'margin: 10px;', 'Ignore terminating `;` in snippet');
// https://github.com/microsoft/vscode/issues/59951
equal(expand('fz'), 'font-size: ${0};');
equal(expand('fz12'), 'font-size: 12px;');
equal(expand('fsz'), 'font-size: ${0};');
equal(expand('fsz12'), 'font-size: 12px;');
equal(expand('fs'), 'font-style: ${1:italic};');
// https://github.com/emmetio/emmet/issues/558
equal(expand('us'), 'user-select: none;');
// https://github.com/microsoft/vscode/issues/105697
equal(expand('opa1'), 'opacity: 1;', 'Unitless property');
equal(expand('opa.1'), 'opacity: 0.1;', 'Unitless property');
equal(expand('opa.a'), 'opacity: .a;', 'Unitless property');
});
it('numeric with format options', () => {
const config = resolveConfig({
type: 'stylesheet',
options: {
equal(expand('p0!'), 'padding: 0 !important;');
});
it('snippets', () => {
equal(expand('@'), '@media ${1:screen} {\n\t${0}\n}');
equal(expand('p10p', config), 'padding: 10%;', 'unit alias');
equal(expand('z10', config), 'z-index: 10;', 'Unitless property');
equal(expand('p10r', config), 'padding: 10 / @rem;', 'unit alias');
});
it('important', () => {
equal(expand('!'), '!important');
equal(expand('p!'), 'padding: ${0} !important;');
equal(expand('p0!'), 'padding: 0 !important;');
});
it('color', () => {
equal(expand('c'), 'color: ${1:#000};');
equal(expand('c#'), 'color: #000;');
equal(expand('c#f.5'), 'color: rgba(255, 255, 255, 0.5);');
equal(expand('c#f.5!'), 'color: rgba(255, 255, 255, 0.5) !important;');
equal(expand('bgc'), 'background-color: #${1:fff};');
});
it('snippets', () => {
equal(expand('@'), '@media ${1:screen} {\n\t${0}\n}');
// Insert value into snippet fields
equal(expand('@k-name'), '@keyframes name {\n\t${2}\n}');
equal(expand('@k-name10'), '@keyframes name {\n\t10\n}');
equal(expand('gt'), 'grid-template: repeat(2, auto) / repeat(auto-fit, minmax(250px, 1fr));');
});
it('multiple properties', () => {
equal(expand('p10+m10-20'), 'padding: 10px;\nmargin: 10px 20px;');
equal(expand('p+bd'), 'padding: ${0};\nborder: ${1:1px} ${2:solid} ${3:#000};');
});
it('functions', () => {
equal(expand('trf-s(2)'), 'transform: scale(2, ${2:y});');
equal(expand('trf-s(2, 3)'), 'transform: scale(2, 3);');
});
it('case insensitive matches', () => {
equal(expand('trf:rx'), 'transform: rotateX(${1:angle});');
});
it('gradient resolver', () => {
equal(expand('lg'), 'background-image: linear-gradient(${0});');
equal(expand('lg(to right, #0, #f00.5)'), 'background-image: linear-gradient(to right, #000, rgba(255, 0, 0, 0.5));');
});
it('unmatched abbreviation', () => {
// This example is useless: itโs unexpected to receive `align-self: unset`
// for `auto` snippet
// equal(expand('auto', resolveConfig({
// type: 'stylesheet',
// options: { 'stylesheet.fuzzySearchMinScore': 0 }
// })), 'align-self: unset;');
equal(expand('auto'), 'auto: ${0};');
});
it('CSS-in-JS', () => {
const config = resolveConfig({
type: 'stylesheet',
options: {
'stylesheet.json': true,
'stylesheet.between': ': '
}
});
equal(expand('p10+mt10-20', config), 'padding: 10,\nmarginTop: \'10px 20px\',');
equal(expand('bgc', config), 'backgroundColor: \'#fff\',');
});
it('resolve context value', () => {
const config = resolveConfig({
type: 'stylesheet',
context: { name: 'align-content' }
});
equal(expand('s', config), 'start');
equal(expand('a', config), 'auto');
});
it('limit snippets by scope', () => {
const sectionScope = resolveConfig({
type: 'stylesheet',
context: { name: CSSAbbreviationScope.Section },
snippets: {
mten: 'margin: 10px;',
fsz: 'font-size',
myCenterAwesome: 'body {\n\tdisplay: grid;\n}'
}
});
const propertyScope = resolveConfig({
type: 'stylesheet',
context: { name: CSSAbbreviationScope.Property },
snippets: {
mten: 'margin: 10px;',
fsz: 'font-size',
myCenterAwesome: 'body {\n\tdisplay: grid;\n}'
}
});
equal(expand('m', sectionScope), 'body {\n\tdisplay: grid;\n}');
equal(expand('b', sectionScope), '');
equal(expand('m', propertyScope), 'margin: ;');
});
});
<MSG> Test abbreviations with color
<DFF> @@ -132,6 +132,13 @@ describe('Stylesheet abbreviations', () => {
equal(expand('p0!'), 'padding: 0 !important;');
});
+ it('color', () => {
+ equal(expand('c'), 'color: ${1:#000};');
+ equal(expand('c#'), 'color: #000;');
+ equal(expand('c#f.5'), 'color: rgba(255, 255, 255, 0.5);');
+ equal(expand('c#f.5!'), 'color: rgba(255, 255, 255, 0.5) !important;');
+ });
+
it('snippets', () => {
equal(expand('@'), '@media ${1:screen} {\n\t${0}\n}');
| 7 | Test abbreviations with color | 0 | .ts | ts | mit | emmetio/emmet |
10071644 | <NME> stylesheet.ts
<BEF> import { strictEqual as equal, ok } from 'assert';
import { stylesheet as expandAbbreviation, resolveConfig, CSSAbbreviationScope } from '../src';
import score from '../src/stylesheet/score';
const defaultConfig = resolveConfig({
type: 'stylesheet',
options: {
'output.field': (index, placeholder) => `\${${index}${placeholder ? ':' + placeholder : ''}}`,
'stylesheet.fuzzySearchMinScore': 0
},
snippets: {
mten: 'margin: 10px;',
fsz: 'font-size',
gt: 'grid-template: repeat(2,auto) / repeat(auto-fit, minmax(250px, 1fr))'
},
cache: {},
});
function expand(abbr: string, config = defaultConfig) {
return expandAbbreviation(abbr, config);
}
describe('Stylesheet abbreviations', () => {
describe('Scoring', () => {
const pick = (abbr: string, items: string[]) => items
.map(item => ({ item, score: score(abbr, item, true) }))
.filter(obj => obj.score)
.sort((a, b) => b.score - a.score)
.map(obj => obj.item)[0];
it('compare scores', () => {
equal(score('aaa', 'aaa'), 1);
equal(score('baa', 'aaa'), 0);
ok(!score('b', 'aaa'));
ok(score('a', 'aaa'));
ok(score('a', 'abc'));
ok(score('ac', 'abc'));
ok(score('a', 'aaa') < score('aa', 'aaa'));
ok(score('ab', 'abc') > score('ab', 'acb'));
// acronym bonus
ok(score('ab', 'a-b') > score('ab', 'acb'));
});
it('pick padding or position', () => {
const items = ['p', 'pb', 'pl', 'pos', 'pa', 'oa', 'soa', 'pr', 'pt'];
equal(pick('p', items), 'p');
equal(pick('poa', items), 'pos');
});
});
it('keywords', () => {
equal(expand('bd1-s'), 'border: 1px solid;');
equal(expand('dib'), 'display: inline-block;');
equal(expand('bxsz'), 'box-sizing: ${1:border-box};');
equal(expand('bxz'), 'box-sizing: ${1:border-box};');
equal(expand('bxzc'), 'box-sizing: content-box;');
equal(expand('fl'), 'float: ${1:left};');
equal(expand('fll'), 'float: left;');
equal(expand('pos'), 'position: ${1:relative};');
equal(expand('poa'), 'position: absolute;');
equal(expand('por'), 'position: relative;');
equal(expand('pof'), 'position: fixed;');
equal(expand('pos-a'), 'position: absolute;');
equal(expand('m'), 'margin: ${0};');
equal(expand('m0'), 'margin: 0;');
// use `auto` as global keyword
equal(expand('m0-a'), 'margin: 0 auto;');
equal(expand('m-a'), 'margin: auto;');
equal(expand('bg'), 'background: ${1:#000};');
equal(expand('bd'), 'border: ${1:1px} ${2:solid} ${3:#000};');
equal(expand('bd0-s#fc0'), 'border: 0 solid #fc0;');
equal(expand('bd0-dd#fc0'), 'border: 0 dot-dash #fc0;');
equal(expand('bd0-h#fc0'), 'border: 0 hidden #fc0;');
equal(expand('trf-trs'), 'transform: translate(${1:x}, ${2:y});');
// https://github.com/emmetio/emmet/issues/610
equal(expand('c'), 'color: ${1:#000};');
equal(expand('cr'), 'color: rgb(${1:0}, ${2:0}, ${3:0});');
equal(expand('cra'), 'color: rgba(${1:0}, ${2:0}, ${3:0}, ${4:.5});');
// https://github.com/emmetio/emmet/issues/647
equal(expand('gtc'), 'grid-template-columns: repeat(${0});');
equal(expand('gtr'), 'grid-template-rows: repeat(${0});');
equal(expand('lis:n'), 'list-style: none;');
equal(expand('list:n'), 'list-style-type: none;');
equal(expand('bdt:n'), 'border-top: none;');
equal(expand('bgi:n'), 'background-image: none;');
equal(expand('q:n'), 'quotes: none;');
});
it('numeric', () => {
equal(expand('p0'), 'padding: 0;', 'No unit for 0');
equal(expand('p10'), 'padding: 10px;', '`px` unit for integers');
equal(expand('p.4'), 'padding: 0.4em;', '`em` for floats');
equal(expand('fz10'), 'font-size: 10px;', '`px` for integers');
equal(expand('fz1.'), 'font-size: 1em;', '`em` for explicit float');
equal(expand('p10p'), 'padding: 10%;', 'unit alias');
equal(expand('z10'), 'z-index: 10;', 'Unitless property');
equal(expand('p10r'), 'padding: 10rem;', 'unit alias');
equal(expand('mten'), 'margin: 10px;', 'Ignore terminating `;` in snippet');
// https://github.com/microsoft/vscode/issues/59951
equal(expand('fz'), 'font-size: ${0};');
equal(expand('fz12'), 'font-size: 12px;');
equal(expand('fsz'), 'font-size: ${0};');
equal(expand('fsz12'), 'font-size: 12px;');
equal(expand('fs'), 'font-style: ${1:italic};');
// https://github.com/emmetio/emmet/issues/558
equal(expand('us'), 'user-select: none;');
// https://github.com/microsoft/vscode/issues/105697
equal(expand('opa1'), 'opacity: 1;', 'Unitless property');
equal(expand('opa.1'), 'opacity: 0.1;', 'Unitless property');
equal(expand('opa.a'), 'opacity: .a;', 'Unitless property');
});
it('numeric with format options', () => {
const config = resolveConfig({
type: 'stylesheet',
options: {
equal(expand('p0!'), 'padding: 0 !important;');
});
it('snippets', () => {
equal(expand('@'), '@media ${1:screen} {\n\t${0}\n}');
equal(expand('p10p', config), 'padding: 10%;', 'unit alias');
equal(expand('z10', config), 'z-index: 10;', 'Unitless property');
equal(expand('p10r', config), 'padding: 10 / @rem;', 'unit alias');
});
it('important', () => {
equal(expand('!'), '!important');
equal(expand('p!'), 'padding: ${0} !important;');
equal(expand('p0!'), 'padding: 0 !important;');
});
it('color', () => {
equal(expand('c'), 'color: ${1:#000};');
equal(expand('c#'), 'color: #000;');
equal(expand('c#f.5'), 'color: rgba(255, 255, 255, 0.5);');
equal(expand('c#f.5!'), 'color: rgba(255, 255, 255, 0.5) !important;');
equal(expand('bgc'), 'background-color: #${1:fff};');
});
it('snippets', () => {
equal(expand('@'), '@media ${1:screen} {\n\t${0}\n}');
// Insert value into snippet fields
equal(expand('@k-name'), '@keyframes name {\n\t${2}\n}');
equal(expand('@k-name10'), '@keyframes name {\n\t10\n}');
equal(expand('gt'), 'grid-template: repeat(2, auto) / repeat(auto-fit, minmax(250px, 1fr));');
});
it('multiple properties', () => {
equal(expand('p10+m10-20'), 'padding: 10px;\nmargin: 10px 20px;');
equal(expand('p+bd'), 'padding: ${0};\nborder: ${1:1px} ${2:solid} ${3:#000};');
});
it('functions', () => {
equal(expand('trf-s(2)'), 'transform: scale(2, ${2:y});');
equal(expand('trf-s(2, 3)'), 'transform: scale(2, 3);');
});
it('case insensitive matches', () => {
equal(expand('trf:rx'), 'transform: rotateX(${1:angle});');
});
it('gradient resolver', () => {
equal(expand('lg'), 'background-image: linear-gradient(${0});');
equal(expand('lg(to right, #0, #f00.5)'), 'background-image: linear-gradient(to right, #000, rgba(255, 0, 0, 0.5));');
});
it('unmatched abbreviation', () => {
// This example is useless: itโs unexpected to receive `align-self: unset`
// for `auto` snippet
// equal(expand('auto', resolveConfig({
// type: 'stylesheet',
// options: { 'stylesheet.fuzzySearchMinScore': 0 }
// })), 'align-self: unset;');
equal(expand('auto'), 'auto: ${0};');
});
it('CSS-in-JS', () => {
const config = resolveConfig({
type: 'stylesheet',
options: {
'stylesheet.json': true,
'stylesheet.between': ': '
}
});
equal(expand('p10+mt10-20', config), 'padding: 10,\nmarginTop: \'10px 20px\',');
equal(expand('bgc', config), 'backgroundColor: \'#fff\',');
});
it('resolve context value', () => {
const config = resolveConfig({
type: 'stylesheet',
context: { name: 'align-content' }
});
equal(expand('s', config), 'start');
equal(expand('a', config), 'auto');
});
it('limit snippets by scope', () => {
const sectionScope = resolveConfig({
type: 'stylesheet',
context: { name: CSSAbbreviationScope.Section },
snippets: {
mten: 'margin: 10px;',
fsz: 'font-size',
myCenterAwesome: 'body {\n\tdisplay: grid;\n}'
}
});
const propertyScope = resolveConfig({
type: 'stylesheet',
context: { name: CSSAbbreviationScope.Property },
snippets: {
mten: 'margin: 10px;',
fsz: 'font-size',
myCenterAwesome: 'body {\n\tdisplay: grid;\n}'
}
});
equal(expand('m', sectionScope), 'body {\n\tdisplay: grid;\n}');
equal(expand('b', sectionScope), '');
equal(expand('m', propertyScope), 'margin: ;');
});
});
<MSG> Test abbreviations with color
<DFF> @@ -132,6 +132,13 @@ describe('Stylesheet abbreviations', () => {
equal(expand('p0!'), 'padding: 0 !important;');
});
+ it('color', () => {
+ equal(expand('c'), 'color: ${1:#000};');
+ equal(expand('c#'), 'color: #000;');
+ equal(expand('c#f.5'), 'color: rgba(255, 255, 255, 0.5);');
+ equal(expand('c#f.5!'), 'color: rgba(255, 255, 255, 0.5) !important;');
+ });
+
it('snippets', () => {
equal(expand('@'), '@media ${1:screen} {\n\t${0}\n}');
| 7 | Test abbreviations with color | 0 | .ts | ts | mit | emmetio/emmet |
10071645 | <NME> experiment_spec.rb
<BEF> # frozen_string_literal: true
require "spec_helper"
require "time"
describe Split::Experiment do
def new_experiment(goals = [])
Split::Experiment.new("link_color", alternatives: ["blue", "red", "green"], goals: goals)
end
def alternative(color)
Split::Alternative.new(color, "link_color")
end
let(:experiment) { new_experiment }
let(:blue) { alternative("blue") }
let(:green) { alternative("green") }
Split.redis.exists('basket_text').should be true
end
it "should not create duplicates when saving multiple times" do
experiment = Split::Experiment.new('basket_text', 'Basket', "Cart")
experiment.save
it "should be resettable by default" do
expect(experiment.resettable).to be_truthy
end
it "should save to redis" do
experiment.save
expect(Split.redis.exists?("basket_text")).to be true
end
it "should save the start time to redis" do
experiment_start_time = Time.at(1372167761)
expect(Time).to receive(:now).and_return(experiment_start_time)
experiment.save
expect(Split::ExperimentCatalog.find("basket_text").start_time).to eq(experiment_start_time)
end
it "should not save the start time to redis when start_manually is enabled" do
expect(Split.configuration).to receive(:start_manually).and_return(true)
experiment.save
expect(Split::ExperimentCatalog.find("basket_text").start_time).to be_nil
end
it "should save the selected algorithm to redis" do
experiment_algorithm = Split::Algorithms::Whiplash
experiment.algorithm = experiment_algorithm
experiment.save
expect(Split::ExperimentCatalog.find("basket_text").algorithm).to eq(experiment_algorithm)
end
it "should handle having a start time stored as a string" do
experiment_start_time = Time.parse("Sat Mar 03 14:01:03")
expect(Time).to receive(:now).twice.and_return(experiment_start_time)
experiment.save
Split.redis.hset(:experiment_start_times, experiment.name, experiment_start_time.to_s)
expect(Split::ExperimentCatalog.find("basket_text").start_time).to eq(experiment_start_time)
end
it "should handle not having a start time" do
experiment_start_time = Time.parse("Sat Mar 03 14:01:03")
expect(Time).to receive(:now).and_return(experiment_start_time)
experiment.save
Split.redis.hdel(:experiment_start_times, experiment.name)
expect(Split::ExperimentCatalog.find("basket_text").start_time).to be_nil
end
it "should not create duplicates when saving multiple times" do
experiment.save
experiment.save
expect(Split.redis.exists?("basket_text")).to be true
expect(Split.redis.lrange("basket_text", 0, -1)).to eq(['{"Basket":1}', '{"Cart":1}'])
end
describe "new record?" do
it "should know if it hasn't been saved yet" do
expect(experiment.new_record?).to be_truthy
end
it "should know if it has been saved yet" do
experiment.save
expect(experiment.new_record?).to be_falsey
end
end
describe "control" do
it "should be the first alternative" do
experiment.save
expect(experiment.control.name).to eq("Basket")
end
end
end
describe "initialization" do
it "should set the algorithm when passed as an option to the initializer" do
experiment = Split::Experiment.new("basket_text", alternatives: ["Basket", "Cart"], algorithm: Split::Algorithms::Whiplash)
expect(experiment.algorithm).to eq(Split::Algorithms::Whiplash)
end
it "should be possible to make an experiment not resettable" do
experiment = Split::Experiment.new("basket_text", alternatives: ["Basket", "Cart"], resettable: false)
expect(experiment.resettable).to be_falsey
end
context "from configuration" do
let(:experiment_name) { :my_experiment }
let(:experiments) do
{
experiment_name => {
alternatives: ["Control Opt", "Alt one"]
}
}
end
before { Split.configuration.experiments = experiments }
it "assigns default values to the experiment" do
expect(Split::Experiment.new(experiment_name).resettable).to eq(true)
end
end
end
describe "persistent configuration" do
it "should persist resettable in redis" do
experiment = Split::Experiment.new("basket_text", alternatives: ["Basket", "Cart"], resettable: false)
experiment.save
e = Split::ExperimentCatalog.find("basket_text")
expect(e).to eq(experiment)
expect(e.resettable).to be_falsey
end
describe "#metadata" do
let(:experiment) { Split::Experiment.new("basket_text", alternatives: ["Basket", "Cart"], algorithm: Split::Algorithms::Whiplash, metadata: meta) }
let(:meta) { { a: "b" } }
before do
experiment.save
end
it "should delete the key when metadata is removed" do
experiment.metadata = nil
experiment.save
expect(Split.redis.exists?(experiment.metadata_key)).to be_falsey
end
context "simple hash" do
let(:meta) { { "basket" => "a", "cart" => "b" } }
it "should persist metadata in redis" do
e = Split::ExperimentCatalog.find("basket_text")
expect(e).to eq(experiment)
expect(e.metadata).to eq(meta)
end
end
context "nested hash" do
let(:meta) { { "basket" => { "one" => "two" }, "cart" => "b" } }
it "should persist metadata in redis" do
e = Split::ExperimentCatalog.find("basket_text")
expect(e).to eq(experiment)
expect(e.metadata).to eq(meta)
end
end
end
it "should persist algorithm in redis" do
experiment = Split::Experiment.new("basket_text", alternatives: ["Basket", "Cart"], algorithm: Split::Algorithms::Whiplash)
experiment.save
e = Split::ExperimentCatalog.find("basket_text")
expect(e).to eq(experiment)
expect(e.algorithm).to eq(Split::Algorithms::Whiplash)
end
it "should persist a new experiment in redis, that does not exist in the configuration file" do
experiment = Split::Experiment.new("foobar", alternatives: ["tra", "la"], algorithm: Split::Algorithms::Whiplash)
experiment.save
e = Split::ExperimentCatalog.find("foobar")
expect(e).to eq(experiment)
expect(e.alternatives.collect { |a| a.name }).to eq(["tra", "la"])
end
end
describe "deleting" do
it "should delete itself" do
experiment = Split::Experiment.new("basket_text", alternatives: [ "Basket", "Cart"])
experiment.save
experiment.delete
expect(Split.redis.exists?("link_color")).to be false
expect(Split::ExperimentCatalog.find("link_color")).to be_nil
end
it "should increment the version" do
expect(experiment.version).to eq(0)
experiment.delete
expect(experiment.version).to eq(1)
end
it "should call the on_experiment_delete hook" do
expect(Split.configuration.on_experiment_delete).to receive(:call)
experiment.delete
end
it "should call the on_before_experiment_delete hook" do
expect(Split.configuration.on_before_experiment_delete).to receive(:call)
experiment.delete
end
it "should reset the start time if the experiment should be manually started" do
Split.configuration.start_manually = true
experiment.start
experiment.delete
expect(experiment.start_time).to be_nil
end
it "should default cohorting back to false" do
experiment.disable_cohorting
expect(experiment.cohorting_disabled?).to eq(true)
experiment.delete
expect(experiment.cohorting_disabled?).to eq(false)
end
end
describe "winner" do
it "should have no winner initially" do
expect(experiment.winner).to be_nil
end
end
describe "winner=" do
it "should allow you to specify a winner" do
experiment.save
experiment.winner = "red"
expect(experiment.winner.name).to eq("red")
end
it "should call the on_experiment_winner_choose hook" do
expect(Split.configuration.on_experiment_winner_choose).to receive(:call)
experiment.winner = "green"
end
context "when has_winner state is memoized" do
before { expect(experiment).to_not have_winner }
it "should keep has_winner state consistent" do
experiment.winner = "red"
expect(experiment).to have_winner
end
end
end
describe "reset_winner" do
before { experiment.winner = "green" }
it "should reset the winner" do
experiment.reset_winner
expect(experiment.winner).to be_nil
end
context "when has_winner state is memoized" do
before { expect(experiment).to have_winner }
it "should keep has_winner state consistent" do
experiment.reset_winner
expect(experiment).to_not have_winner
end
end
end
describe "has_winner?" do
context "with winner" do
before { experiment.winner = "red" }
it "returns true" do
expect(experiment).to have_winner
end
end
context "without winner" do
it "returns false" do
expect(experiment).to_not have_winner
end
end
it "memoizes has_winner state" do
expect(experiment).to receive(:winner).once
expect(experiment).to_not have_winner
expect(experiment).to_not have_winner
end
end
describe "reset" do
let(:reset_manually) { false }
before do
allow(Split.configuration).to receive(:reset_manually).and_return(reset_manually)
experiment.save
green.increment_participation
green.increment_participation
end
it "should reset all alternatives" do
experiment.winner = "green"
expect(experiment.next_alternative.name).to eq("green")
green.increment_participation
experiment.reset
expect(green.participant_count).to eq(0)
expect(green.completed_count).to eq(0)
end
it "should reset the winner" do
experiment.winner = "green"
expect(experiment.next_alternative.name).to eq("green")
green.increment_participation
experiment.reset
expect(experiment.winner).to be_nil
end
it "should increment the version" do
expect(experiment.version).to eq(0)
experiment.reset
expect(experiment.version).to eq(1)
end
it "should call the on_experiment_reset hook" do
expect(Split.configuration.on_experiment_reset).to receive(:call)
experiment.reset
end
it "should call the on_before_experiment_reset hook" do
expect(Split.configuration.on_before_experiment_reset).to receive(:call)
experiment.reset
end
end
describe "algorithm" do
let(:experiment) { Split::ExperimentCatalog.find_or_create("link_color", "blue", "red", "green") }
it "should use the default algorithm if none is specified" do
expect(experiment.algorithm).to eq(Split.configuration.algorithm)
end
it "should use the user specified algorithm for this experiment if specified" do
experiment.algorithm = Split::Algorithms::Whiplash
expect(experiment.algorithm).to eq(Split::Algorithms::Whiplash)
end
end
describe "#next_alternative" do
context "with multiple alternatives" do
let(:experiment) { Split::ExperimentCatalog.find_or_create("link_color", "blue", "red", "green") }
context "with winner" do
it "should always return the winner" do
green = Split::Alternative.new("green", "link_color")
experiment.winner = "green"
expect(experiment.next_alternative.name).to eq("green")
green.increment_participation
expect(experiment.next_alternative.name).to eq("green")
end
end
context "without winner" do
it "should use the specified algorithm" do
experiment.algorithm = Split::Algorithms::Whiplash
expect(experiment.algorithm).to receive(:choose_alternative).and_return(Split::Alternative.new("green", "link_color"))
expect(experiment.next_alternative.name).to eq("green")
end
end
end
context "with single alternative" do
let(:experiment) { Split::ExperimentCatalog.find_or_create("link_color", "blue") }
it "should always return the only alternative" do
expect(experiment.next_alternative.name).to eq("blue")
expect(experiment.next_alternative.name).to eq("blue")
end
end
end
describe "#cohorting_disabled?" do
it "returns false when nothing has been configured" do
expect(experiment.cohorting_disabled?).to eq false
end
it "returns true when enable_cohorting is performed" do
experiment.enable_cohorting
expect(experiment.cohorting_disabled?).to eq false
end
it "returns false when nothing has been configured" do
experiment.disable_cohorting
expect(experiment.cohorting_disabled?).to eq true
end
end
describe "changing an existing experiment" do
def same_but_different_alternative
Split::ExperimentCatalog.find_or_create("link_color", "blue", "yellow", "orange")
end
it "should reset an experiment if it is loaded with different alternatives" do
experiment.save
blue.participant_count = 5
same_experiment = same_but_different_alternative
expect(same_experiment.alternatives.map(&:name)).to eq(["blue", "yellow", "orange"])
expect(blue.participant_count).to eq(0)
end
it "should only reset once" do
experiment.save
expect(experiment.version).to eq(0)
same_experiment = same_but_different_alternative
expect(same_experiment.version).to eq(1)
same_experiment_again = same_but_different_alternative
expect(same_experiment_again.version).to eq(1)
end
context "when metadata is changed" do
it "should increase version" do
experiment.save
experiment.metadata = { "foo" => "bar" }
expect { experiment.save }.to change { experiment.version }.by(1)
end
it "does not increase version" do
experiment.metadata = nil
experiment.save
expect { experiment.save }.to change { experiment.version }.by(0)
end
end
context "when experiment configuration is changed" do
let(:reset_manually) { false }
before do
experiment.save
allow(Split.configuration).to receive(:reset_manually).and_return(reset_manually)
green.increment_participation
green.increment_participation
experiment.set_alternatives_and_options(alternatives: %w(blue red green zip),
goals: %w(purchase))
experiment.save
end
it "resets all alternatives" do
expect(green.participant_count).to eq(0)
expect(green.completed_count).to eq(0)
end
context "when reset_manually is set" do
let(:reset_manually) { true }
it "does not reset alternatives" do
expect(green.participant_count).to eq(2)
expect(green.completed_count).to eq(0)
end
end
end
end
describe "alternatives passed as non-strings" do
it "should throw an exception if an alternative is passed that is not a string" do
expect { Split::ExperimentCatalog.find_or_create("link_color", :blue, :red) }.to raise_error(ArgumentError)
expect { Split::ExperimentCatalog.find_or_create("link_enabled", true, false) }.to raise_error(ArgumentError)
end
end
describe "specifying weights" do
let(:experiment_with_weight) {
Split::ExperimentCatalog.find_or_create("link_color", { "blue" => 1 }, { "red" => 2 })
}
it "should work for a new experiment" do
expect(experiment_with_weight.alternatives.map(&:weight)).to eq([1, 2])
end
it "should work for an existing experiment" do
experiment.save
expect(experiment_with_weight.alternatives.map(&:weight)).to eq([1, 2])
end
end
describe "specifying goals" do
let(:experiment) {
new_experiment(["purchase"])
}
context "saving experiment" do
let(:same_but_different_goals) { Split::ExperimentCatalog.find_or_create({ "link_color" => ["purchase", "refund"] }, "blue", "red", "green") }
before { experiment.save }
it "can find existing experiment" do
expect(Split::ExperimentCatalog.find("link_color").name).to eq("link_color")
end
it "should reset an experiment if it is loaded with different goals" do
same_but_different_goals
expect(Split::ExperimentCatalog.find("link_color").goals).to eq(["purchase", "refund"])
end
end
it "should have goals" do
expect(experiment.goals).to eq(["purchase"])
end
context "find or create experiment" do
it "should have correct goals" do
experiment = Split::ExperimentCatalog.find_or_create({ "link_color3" => ["purchase", "refund"] }, "blue", "red", "green")
expect(experiment.goals).to eq(["purchase", "refund"])
experiment = Split::ExperimentCatalog.find_or_create("link_color3", "blue", "red", "green")
expect(experiment.goals).to eq([])
end
end
end
describe "beta probability calculation" do
it "should return a hash with the probability of each alternative being the best" do
experiment = Split::ExperimentCatalog.find_or_create("mathematicians", "bernoulli", "poisson", "lagrange")
experiment.calc_winning_alternatives
expect(experiment.alternative_probabilities).not_to be_nil
end
it "should return between 46% and 54% probability for an experiment with 2 alternatives and no data" do
experiment = Split::ExperimentCatalog.find_or_create("scientists", "einstein", "bohr")
experiment.calc_winning_alternatives
expect(experiment.alternatives[0].p_winner).to be_within(0.04).of(0.50)
end
it "should calculate the probability of being the winning alternative separately for each goal", skip: true do
experiment = Split::ExperimentCatalog.find_or_create({ "link_color3" => ["purchase", "refund"] }, "blue", "red", "green")
goal1 = experiment.goals[0]
goal2 = experiment.goals[1]
experiment.alternatives.each do |alternative|
alternative.participant_count = 50
alternative.set_completed_count(10, goal1)
alternative.set_completed_count(15+rand(30), goal2)
end
experiment.calc_winning_alternatives
alt = experiment.alternatives[0]
p_goal1 = alt.p_winner(goal1)
p_goal2 = alt.p_winner(goal2)
expect(p_goal1).not_to be_within(0.04).of(p_goal2)
end
it "should return nil and not re-calculate probabilities if they have already been calculated today" do
experiment = Split::ExperimentCatalog.find_or_create({ "link_color3" => ["purchase", "refund"] }, "blue", "red", "green")
expect(experiment.calc_winning_alternatives).not_to be nil
expect(experiment.calc_winning_alternatives).to be nil
end
end
end
<MSG> Merge pull request #35 from vrish88/master
Add experiment start date #12
<DFF> @@ -20,6 +20,15 @@ describe Split::Experiment do
Split.redis.exists('basket_text').should be true
end
+ it "should save the start time to redis" do
+ experiment_start_time = Time.parse("Sat Mar 03 14:01:03")
+ Time.stub(:now => experiment_start_time)
+ experiment = Split::Experiment.new('basket_text', 'Basket', "Cart")
+ experiment.save
+
+ Split::Experiment.find('basket_text').start_time.should == experiment_start_time
+ end
+
it "should not create duplicates when saving multiple times" do
experiment = Split::Experiment.new('basket_text', 'Basket', "Cart")
experiment.save
| 9 | Merge pull request #35 from vrish88/master | 0 | .rb | rb | mit | splitrb/split |
10071646 | <NME> experiment_spec.rb
<BEF> # frozen_string_literal: true
require "spec_helper"
require "time"
describe Split::Experiment do
def new_experiment(goals = [])
Split::Experiment.new("link_color", alternatives: ["blue", "red", "green"], goals: goals)
end
def alternative(color)
Split::Alternative.new(color, "link_color")
end
let(:experiment) { new_experiment }
let(:blue) { alternative("blue") }
let(:green) { alternative("green") }
Split.redis.exists('basket_text').should be true
end
it "should not create duplicates when saving multiple times" do
experiment = Split::Experiment.new('basket_text', 'Basket', "Cart")
experiment.save
it "should be resettable by default" do
expect(experiment.resettable).to be_truthy
end
it "should save to redis" do
experiment.save
expect(Split.redis.exists?("basket_text")).to be true
end
it "should save the start time to redis" do
experiment_start_time = Time.at(1372167761)
expect(Time).to receive(:now).and_return(experiment_start_time)
experiment.save
expect(Split::ExperimentCatalog.find("basket_text").start_time).to eq(experiment_start_time)
end
it "should not save the start time to redis when start_manually is enabled" do
expect(Split.configuration).to receive(:start_manually).and_return(true)
experiment.save
expect(Split::ExperimentCatalog.find("basket_text").start_time).to be_nil
end
it "should save the selected algorithm to redis" do
experiment_algorithm = Split::Algorithms::Whiplash
experiment.algorithm = experiment_algorithm
experiment.save
expect(Split::ExperimentCatalog.find("basket_text").algorithm).to eq(experiment_algorithm)
end
it "should handle having a start time stored as a string" do
experiment_start_time = Time.parse("Sat Mar 03 14:01:03")
expect(Time).to receive(:now).twice.and_return(experiment_start_time)
experiment.save
Split.redis.hset(:experiment_start_times, experiment.name, experiment_start_time.to_s)
expect(Split::ExperimentCatalog.find("basket_text").start_time).to eq(experiment_start_time)
end
it "should handle not having a start time" do
experiment_start_time = Time.parse("Sat Mar 03 14:01:03")
expect(Time).to receive(:now).and_return(experiment_start_time)
experiment.save
Split.redis.hdel(:experiment_start_times, experiment.name)
expect(Split::ExperimentCatalog.find("basket_text").start_time).to be_nil
end
it "should not create duplicates when saving multiple times" do
experiment.save
experiment.save
expect(Split.redis.exists?("basket_text")).to be true
expect(Split.redis.lrange("basket_text", 0, -1)).to eq(['{"Basket":1}', '{"Cart":1}'])
end
describe "new record?" do
it "should know if it hasn't been saved yet" do
expect(experiment.new_record?).to be_truthy
end
it "should know if it has been saved yet" do
experiment.save
expect(experiment.new_record?).to be_falsey
end
end
describe "control" do
it "should be the first alternative" do
experiment.save
expect(experiment.control.name).to eq("Basket")
end
end
end
describe "initialization" do
it "should set the algorithm when passed as an option to the initializer" do
experiment = Split::Experiment.new("basket_text", alternatives: ["Basket", "Cart"], algorithm: Split::Algorithms::Whiplash)
expect(experiment.algorithm).to eq(Split::Algorithms::Whiplash)
end
it "should be possible to make an experiment not resettable" do
experiment = Split::Experiment.new("basket_text", alternatives: ["Basket", "Cart"], resettable: false)
expect(experiment.resettable).to be_falsey
end
context "from configuration" do
let(:experiment_name) { :my_experiment }
let(:experiments) do
{
experiment_name => {
alternatives: ["Control Opt", "Alt one"]
}
}
end
before { Split.configuration.experiments = experiments }
it "assigns default values to the experiment" do
expect(Split::Experiment.new(experiment_name).resettable).to eq(true)
end
end
end
describe "persistent configuration" do
it "should persist resettable in redis" do
experiment = Split::Experiment.new("basket_text", alternatives: ["Basket", "Cart"], resettable: false)
experiment.save
e = Split::ExperimentCatalog.find("basket_text")
expect(e).to eq(experiment)
expect(e.resettable).to be_falsey
end
describe "#metadata" do
let(:experiment) { Split::Experiment.new("basket_text", alternatives: ["Basket", "Cart"], algorithm: Split::Algorithms::Whiplash, metadata: meta) }
let(:meta) { { a: "b" } }
before do
experiment.save
end
it "should delete the key when metadata is removed" do
experiment.metadata = nil
experiment.save
expect(Split.redis.exists?(experiment.metadata_key)).to be_falsey
end
context "simple hash" do
let(:meta) { { "basket" => "a", "cart" => "b" } }
it "should persist metadata in redis" do
e = Split::ExperimentCatalog.find("basket_text")
expect(e).to eq(experiment)
expect(e.metadata).to eq(meta)
end
end
context "nested hash" do
let(:meta) { { "basket" => { "one" => "two" }, "cart" => "b" } }
it "should persist metadata in redis" do
e = Split::ExperimentCatalog.find("basket_text")
expect(e).to eq(experiment)
expect(e.metadata).to eq(meta)
end
end
end
it "should persist algorithm in redis" do
experiment = Split::Experiment.new("basket_text", alternatives: ["Basket", "Cart"], algorithm: Split::Algorithms::Whiplash)
experiment.save
e = Split::ExperimentCatalog.find("basket_text")
expect(e).to eq(experiment)
expect(e.algorithm).to eq(Split::Algorithms::Whiplash)
end
it "should persist a new experiment in redis, that does not exist in the configuration file" do
experiment = Split::Experiment.new("foobar", alternatives: ["tra", "la"], algorithm: Split::Algorithms::Whiplash)
experiment.save
e = Split::ExperimentCatalog.find("foobar")
expect(e).to eq(experiment)
expect(e.alternatives.collect { |a| a.name }).to eq(["tra", "la"])
end
end
describe "deleting" do
it "should delete itself" do
experiment = Split::Experiment.new("basket_text", alternatives: [ "Basket", "Cart"])
experiment.save
experiment.delete
expect(Split.redis.exists?("link_color")).to be false
expect(Split::ExperimentCatalog.find("link_color")).to be_nil
end
it "should increment the version" do
expect(experiment.version).to eq(0)
experiment.delete
expect(experiment.version).to eq(1)
end
it "should call the on_experiment_delete hook" do
expect(Split.configuration.on_experiment_delete).to receive(:call)
experiment.delete
end
it "should call the on_before_experiment_delete hook" do
expect(Split.configuration.on_before_experiment_delete).to receive(:call)
experiment.delete
end
it "should reset the start time if the experiment should be manually started" do
Split.configuration.start_manually = true
experiment.start
experiment.delete
expect(experiment.start_time).to be_nil
end
it "should default cohorting back to false" do
experiment.disable_cohorting
expect(experiment.cohorting_disabled?).to eq(true)
experiment.delete
expect(experiment.cohorting_disabled?).to eq(false)
end
end
describe "winner" do
it "should have no winner initially" do
expect(experiment.winner).to be_nil
end
end
describe "winner=" do
it "should allow you to specify a winner" do
experiment.save
experiment.winner = "red"
expect(experiment.winner.name).to eq("red")
end
it "should call the on_experiment_winner_choose hook" do
expect(Split.configuration.on_experiment_winner_choose).to receive(:call)
experiment.winner = "green"
end
context "when has_winner state is memoized" do
before { expect(experiment).to_not have_winner }
it "should keep has_winner state consistent" do
experiment.winner = "red"
expect(experiment).to have_winner
end
end
end
describe "reset_winner" do
before { experiment.winner = "green" }
it "should reset the winner" do
experiment.reset_winner
expect(experiment.winner).to be_nil
end
context "when has_winner state is memoized" do
before { expect(experiment).to have_winner }
it "should keep has_winner state consistent" do
experiment.reset_winner
expect(experiment).to_not have_winner
end
end
end
describe "has_winner?" do
context "with winner" do
before { experiment.winner = "red" }
it "returns true" do
expect(experiment).to have_winner
end
end
context "without winner" do
it "returns false" do
expect(experiment).to_not have_winner
end
end
it "memoizes has_winner state" do
expect(experiment).to receive(:winner).once
expect(experiment).to_not have_winner
expect(experiment).to_not have_winner
end
end
describe "reset" do
let(:reset_manually) { false }
before do
allow(Split.configuration).to receive(:reset_manually).and_return(reset_manually)
experiment.save
green.increment_participation
green.increment_participation
end
it "should reset all alternatives" do
experiment.winner = "green"
expect(experiment.next_alternative.name).to eq("green")
green.increment_participation
experiment.reset
expect(green.participant_count).to eq(0)
expect(green.completed_count).to eq(0)
end
it "should reset the winner" do
experiment.winner = "green"
expect(experiment.next_alternative.name).to eq("green")
green.increment_participation
experiment.reset
expect(experiment.winner).to be_nil
end
it "should increment the version" do
expect(experiment.version).to eq(0)
experiment.reset
expect(experiment.version).to eq(1)
end
it "should call the on_experiment_reset hook" do
expect(Split.configuration.on_experiment_reset).to receive(:call)
experiment.reset
end
it "should call the on_before_experiment_reset hook" do
expect(Split.configuration.on_before_experiment_reset).to receive(:call)
experiment.reset
end
end
describe "algorithm" do
let(:experiment) { Split::ExperimentCatalog.find_or_create("link_color", "blue", "red", "green") }
it "should use the default algorithm if none is specified" do
expect(experiment.algorithm).to eq(Split.configuration.algorithm)
end
it "should use the user specified algorithm for this experiment if specified" do
experiment.algorithm = Split::Algorithms::Whiplash
expect(experiment.algorithm).to eq(Split::Algorithms::Whiplash)
end
end
describe "#next_alternative" do
context "with multiple alternatives" do
let(:experiment) { Split::ExperimentCatalog.find_or_create("link_color", "blue", "red", "green") }
context "with winner" do
it "should always return the winner" do
green = Split::Alternative.new("green", "link_color")
experiment.winner = "green"
expect(experiment.next_alternative.name).to eq("green")
green.increment_participation
expect(experiment.next_alternative.name).to eq("green")
end
end
context "without winner" do
it "should use the specified algorithm" do
experiment.algorithm = Split::Algorithms::Whiplash
expect(experiment.algorithm).to receive(:choose_alternative).and_return(Split::Alternative.new("green", "link_color"))
expect(experiment.next_alternative.name).to eq("green")
end
end
end
context "with single alternative" do
let(:experiment) { Split::ExperimentCatalog.find_or_create("link_color", "blue") }
it "should always return the only alternative" do
expect(experiment.next_alternative.name).to eq("blue")
expect(experiment.next_alternative.name).to eq("blue")
end
end
end
describe "#cohorting_disabled?" do
it "returns false when nothing has been configured" do
expect(experiment.cohorting_disabled?).to eq false
end
it "returns true when enable_cohorting is performed" do
experiment.enable_cohorting
expect(experiment.cohorting_disabled?).to eq false
end
it "returns false when nothing has been configured" do
experiment.disable_cohorting
expect(experiment.cohorting_disabled?).to eq true
end
end
describe "changing an existing experiment" do
def same_but_different_alternative
Split::ExperimentCatalog.find_or_create("link_color", "blue", "yellow", "orange")
end
it "should reset an experiment if it is loaded with different alternatives" do
experiment.save
blue.participant_count = 5
same_experiment = same_but_different_alternative
expect(same_experiment.alternatives.map(&:name)).to eq(["blue", "yellow", "orange"])
expect(blue.participant_count).to eq(0)
end
it "should only reset once" do
experiment.save
expect(experiment.version).to eq(0)
same_experiment = same_but_different_alternative
expect(same_experiment.version).to eq(1)
same_experiment_again = same_but_different_alternative
expect(same_experiment_again.version).to eq(1)
end
context "when metadata is changed" do
it "should increase version" do
experiment.save
experiment.metadata = { "foo" => "bar" }
expect { experiment.save }.to change { experiment.version }.by(1)
end
it "does not increase version" do
experiment.metadata = nil
experiment.save
expect { experiment.save }.to change { experiment.version }.by(0)
end
end
context "when experiment configuration is changed" do
let(:reset_manually) { false }
before do
experiment.save
allow(Split.configuration).to receive(:reset_manually).and_return(reset_manually)
green.increment_participation
green.increment_participation
experiment.set_alternatives_and_options(alternatives: %w(blue red green zip),
goals: %w(purchase))
experiment.save
end
it "resets all alternatives" do
expect(green.participant_count).to eq(0)
expect(green.completed_count).to eq(0)
end
context "when reset_manually is set" do
let(:reset_manually) { true }
it "does not reset alternatives" do
expect(green.participant_count).to eq(2)
expect(green.completed_count).to eq(0)
end
end
end
end
describe "alternatives passed as non-strings" do
it "should throw an exception if an alternative is passed that is not a string" do
expect { Split::ExperimentCatalog.find_or_create("link_color", :blue, :red) }.to raise_error(ArgumentError)
expect { Split::ExperimentCatalog.find_or_create("link_enabled", true, false) }.to raise_error(ArgumentError)
end
end
describe "specifying weights" do
let(:experiment_with_weight) {
Split::ExperimentCatalog.find_or_create("link_color", { "blue" => 1 }, { "red" => 2 })
}
it "should work for a new experiment" do
expect(experiment_with_weight.alternatives.map(&:weight)).to eq([1, 2])
end
it "should work for an existing experiment" do
experiment.save
expect(experiment_with_weight.alternatives.map(&:weight)).to eq([1, 2])
end
end
describe "specifying goals" do
let(:experiment) {
new_experiment(["purchase"])
}
context "saving experiment" do
let(:same_but_different_goals) { Split::ExperimentCatalog.find_or_create({ "link_color" => ["purchase", "refund"] }, "blue", "red", "green") }
before { experiment.save }
it "can find existing experiment" do
expect(Split::ExperimentCatalog.find("link_color").name).to eq("link_color")
end
it "should reset an experiment if it is loaded with different goals" do
same_but_different_goals
expect(Split::ExperimentCatalog.find("link_color").goals).to eq(["purchase", "refund"])
end
end
it "should have goals" do
expect(experiment.goals).to eq(["purchase"])
end
context "find or create experiment" do
it "should have correct goals" do
experiment = Split::ExperimentCatalog.find_or_create({ "link_color3" => ["purchase", "refund"] }, "blue", "red", "green")
expect(experiment.goals).to eq(["purchase", "refund"])
experiment = Split::ExperimentCatalog.find_or_create("link_color3", "blue", "red", "green")
expect(experiment.goals).to eq([])
end
end
end
describe "beta probability calculation" do
it "should return a hash with the probability of each alternative being the best" do
experiment = Split::ExperimentCatalog.find_or_create("mathematicians", "bernoulli", "poisson", "lagrange")
experiment.calc_winning_alternatives
expect(experiment.alternative_probabilities).not_to be_nil
end
it "should return between 46% and 54% probability for an experiment with 2 alternatives and no data" do
experiment = Split::ExperimentCatalog.find_or_create("scientists", "einstein", "bohr")
experiment.calc_winning_alternatives
expect(experiment.alternatives[0].p_winner).to be_within(0.04).of(0.50)
end
it "should calculate the probability of being the winning alternative separately for each goal", skip: true do
experiment = Split::ExperimentCatalog.find_or_create({ "link_color3" => ["purchase", "refund"] }, "blue", "red", "green")
goal1 = experiment.goals[0]
goal2 = experiment.goals[1]
experiment.alternatives.each do |alternative|
alternative.participant_count = 50
alternative.set_completed_count(10, goal1)
alternative.set_completed_count(15+rand(30), goal2)
end
experiment.calc_winning_alternatives
alt = experiment.alternatives[0]
p_goal1 = alt.p_winner(goal1)
p_goal2 = alt.p_winner(goal2)
expect(p_goal1).not_to be_within(0.04).of(p_goal2)
end
it "should return nil and not re-calculate probabilities if they have already been calculated today" do
experiment = Split::ExperimentCatalog.find_or_create({ "link_color3" => ["purchase", "refund"] }, "blue", "red", "green")
expect(experiment.calc_winning_alternatives).not_to be nil
expect(experiment.calc_winning_alternatives).to be nil
end
end
end
<MSG> Merge pull request #35 from vrish88/master
Add experiment start date #12
<DFF> @@ -20,6 +20,15 @@ describe Split::Experiment do
Split.redis.exists('basket_text').should be true
end
+ it "should save the start time to redis" do
+ experiment_start_time = Time.parse("Sat Mar 03 14:01:03")
+ Time.stub(:now => experiment_start_time)
+ experiment = Split::Experiment.new('basket_text', 'Basket', "Cart")
+ experiment.save
+
+ Split::Experiment.find('basket_text').start_time.should == experiment_start_time
+ end
+
it "should not create duplicates when saving multiple times" do
experiment = Split::Experiment.new('basket_text', 'Basket', "Cart")
experiment.save
| 9 | Merge pull request #35 from vrish88/master | 0 | .rb | rb | mit | splitrb/split |
10071647 | <NME> experiment_spec.rb
<BEF> # frozen_string_literal: true
require "spec_helper"
require "time"
describe Split::Experiment do
def new_experiment(goals = [])
Split::Experiment.new("link_color", alternatives: ["blue", "red", "green"], goals: goals)
end
def alternative(color)
Split::Alternative.new(color, "link_color")
end
let(:experiment) { new_experiment }
let(:blue) { alternative("blue") }
let(:green) { alternative("green") }
Split.redis.exists('basket_text').should be true
end
it "should not create duplicates when saving multiple times" do
experiment = Split::Experiment.new('basket_text', 'Basket', "Cart")
experiment.save
it "should be resettable by default" do
expect(experiment.resettable).to be_truthy
end
it "should save to redis" do
experiment.save
expect(Split.redis.exists?("basket_text")).to be true
end
it "should save the start time to redis" do
experiment_start_time = Time.at(1372167761)
expect(Time).to receive(:now).and_return(experiment_start_time)
experiment.save
expect(Split::ExperimentCatalog.find("basket_text").start_time).to eq(experiment_start_time)
end
it "should not save the start time to redis when start_manually is enabled" do
expect(Split.configuration).to receive(:start_manually).and_return(true)
experiment.save
expect(Split::ExperimentCatalog.find("basket_text").start_time).to be_nil
end
it "should save the selected algorithm to redis" do
experiment_algorithm = Split::Algorithms::Whiplash
experiment.algorithm = experiment_algorithm
experiment.save
expect(Split::ExperimentCatalog.find("basket_text").algorithm).to eq(experiment_algorithm)
end
it "should handle having a start time stored as a string" do
experiment_start_time = Time.parse("Sat Mar 03 14:01:03")
expect(Time).to receive(:now).twice.and_return(experiment_start_time)
experiment.save
Split.redis.hset(:experiment_start_times, experiment.name, experiment_start_time.to_s)
expect(Split::ExperimentCatalog.find("basket_text").start_time).to eq(experiment_start_time)
end
it "should handle not having a start time" do
experiment_start_time = Time.parse("Sat Mar 03 14:01:03")
expect(Time).to receive(:now).and_return(experiment_start_time)
experiment.save
Split.redis.hdel(:experiment_start_times, experiment.name)
expect(Split::ExperimentCatalog.find("basket_text").start_time).to be_nil
end
it "should not create duplicates when saving multiple times" do
experiment.save
experiment.save
expect(Split.redis.exists?("basket_text")).to be true
expect(Split.redis.lrange("basket_text", 0, -1)).to eq(['{"Basket":1}', '{"Cart":1}'])
end
describe "new record?" do
it "should know if it hasn't been saved yet" do
expect(experiment.new_record?).to be_truthy
end
it "should know if it has been saved yet" do
experiment.save
expect(experiment.new_record?).to be_falsey
end
end
describe "control" do
it "should be the first alternative" do
experiment.save
expect(experiment.control.name).to eq("Basket")
end
end
end
describe "initialization" do
it "should set the algorithm when passed as an option to the initializer" do
experiment = Split::Experiment.new("basket_text", alternatives: ["Basket", "Cart"], algorithm: Split::Algorithms::Whiplash)
expect(experiment.algorithm).to eq(Split::Algorithms::Whiplash)
end
it "should be possible to make an experiment not resettable" do
experiment = Split::Experiment.new("basket_text", alternatives: ["Basket", "Cart"], resettable: false)
expect(experiment.resettable).to be_falsey
end
context "from configuration" do
let(:experiment_name) { :my_experiment }
let(:experiments) do
{
experiment_name => {
alternatives: ["Control Opt", "Alt one"]
}
}
end
before { Split.configuration.experiments = experiments }
it "assigns default values to the experiment" do
expect(Split::Experiment.new(experiment_name).resettable).to eq(true)
end
end
end
describe "persistent configuration" do
it "should persist resettable in redis" do
experiment = Split::Experiment.new("basket_text", alternatives: ["Basket", "Cart"], resettable: false)
experiment.save
e = Split::ExperimentCatalog.find("basket_text")
expect(e).to eq(experiment)
expect(e.resettable).to be_falsey
end
describe "#metadata" do
let(:experiment) { Split::Experiment.new("basket_text", alternatives: ["Basket", "Cart"], algorithm: Split::Algorithms::Whiplash, metadata: meta) }
let(:meta) { { a: "b" } }
before do
experiment.save
end
it "should delete the key when metadata is removed" do
experiment.metadata = nil
experiment.save
expect(Split.redis.exists?(experiment.metadata_key)).to be_falsey
end
context "simple hash" do
let(:meta) { { "basket" => "a", "cart" => "b" } }
it "should persist metadata in redis" do
e = Split::ExperimentCatalog.find("basket_text")
expect(e).to eq(experiment)
expect(e.metadata).to eq(meta)
end
end
context "nested hash" do
let(:meta) { { "basket" => { "one" => "two" }, "cart" => "b" } }
it "should persist metadata in redis" do
e = Split::ExperimentCatalog.find("basket_text")
expect(e).to eq(experiment)
expect(e.metadata).to eq(meta)
end
end
end
it "should persist algorithm in redis" do
experiment = Split::Experiment.new("basket_text", alternatives: ["Basket", "Cart"], algorithm: Split::Algorithms::Whiplash)
experiment.save
e = Split::ExperimentCatalog.find("basket_text")
expect(e).to eq(experiment)
expect(e.algorithm).to eq(Split::Algorithms::Whiplash)
end
it "should persist a new experiment in redis, that does not exist in the configuration file" do
experiment = Split::Experiment.new("foobar", alternatives: ["tra", "la"], algorithm: Split::Algorithms::Whiplash)
experiment.save
e = Split::ExperimentCatalog.find("foobar")
expect(e).to eq(experiment)
expect(e.alternatives.collect { |a| a.name }).to eq(["tra", "la"])
end
end
describe "deleting" do
it "should delete itself" do
experiment = Split::Experiment.new("basket_text", alternatives: [ "Basket", "Cart"])
experiment.save
experiment.delete
expect(Split.redis.exists?("link_color")).to be false
expect(Split::ExperimentCatalog.find("link_color")).to be_nil
end
it "should increment the version" do
expect(experiment.version).to eq(0)
experiment.delete
expect(experiment.version).to eq(1)
end
it "should call the on_experiment_delete hook" do
expect(Split.configuration.on_experiment_delete).to receive(:call)
experiment.delete
end
it "should call the on_before_experiment_delete hook" do
expect(Split.configuration.on_before_experiment_delete).to receive(:call)
experiment.delete
end
it "should reset the start time if the experiment should be manually started" do
Split.configuration.start_manually = true
experiment.start
experiment.delete
expect(experiment.start_time).to be_nil
end
it "should default cohorting back to false" do
experiment.disable_cohorting
expect(experiment.cohorting_disabled?).to eq(true)
experiment.delete
expect(experiment.cohorting_disabled?).to eq(false)
end
end
describe "winner" do
it "should have no winner initially" do
expect(experiment.winner).to be_nil
end
end
describe "winner=" do
it "should allow you to specify a winner" do
experiment.save
experiment.winner = "red"
expect(experiment.winner.name).to eq("red")
end
it "should call the on_experiment_winner_choose hook" do
expect(Split.configuration.on_experiment_winner_choose).to receive(:call)
experiment.winner = "green"
end
context "when has_winner state is memoized" do
before { expect(experiment).to_not have_winner }
it "should keep has_winner state consistent" do
experiment.winner = "red"
expect(experiment).to have_winner
end
end
end
describe "reset_winner" do
before { experiment.winner = "green" }
it "should reset the winner" do
experiment.reset_winner
expect(experiment.winner).to be_nil
end
context "when has_winner state is memoized" do
before { expect(experiment).to have_winner }
it "should keep has_winner state consistent" do
experiment.reset_winner
expect(experiment).to_not have_winner
end
end
end
describe "has_winner?" do
context "with winner" do
before { experiment.winner = "red" }
it "returns true" do
expect(experiment).to have_winner
end
end
context "without winner" do
it "returns false" do
expect(experiment).to_not have_winner
end
end
it "memoizes has_winner state" do
expect(experiment).to receive(:winner).once
expect(experiment).to_not have_winner
expect(experiment).to_not have_winner
end
end
describe "reset" do
let(:reset_manually) { false }
before do
allow(Split.configuration).to receive(:reset_manually).and_return(reset_manually)
experiment.save
green.increment_participation
green.increment_participation
end
it "should reset all alternatives" do
experiment.winner = "green"
expect(experiment.next_alternative.name).to eq("green")
green.increment_participation
experiment.reset
expect(green.participant_count).to eq(0)
expect(green.completed_count).to eq(0)
end
it "should reset the winner" do
experiment.winner = "green"
expect(experiment.next_alternative.name).to eq("green")
green.increment_participation
experiment.reset
expect(experiment.winner).to be_nil
end
it "should increment the version" do
expect(experiment.version).to eq(0)
experiment.reset
expect(experiment.version).to eq(1)
end
it "should call the on_experiment_reset hook" do
expect(Split.configuration.on_experiment_reset).to receive(:call)
experiment.reset
end
it "should call the on_before_experiment_reset hook" do
expect(Split.configuration.on_before_experiment_reset).to receive(:call)
experiment.reset
end
end
describe "algorithm" do
let(:experiment) { Split::ExperimentCatalog.find_or_create("link_color", "blue", "red", "green") }
it "should use the default algorithm if none is specified" do
expect(experiment.algorithm).to eq(Split.configuration.algorithm)
end
it "should use the user specified algorithm for this experiment if specified" do
experiment.algorithm = Split::Algorithms::Whiplash
expect(experiment.algorithm).to eq(Split::Algorithms::Whiplash)
end
end
describe "#next_alternative" do
context "with multiple alternatives" do
let(:experiment) { Split::ExperimentCatalog.find_or_create("link_color", "blue", "red", "green") }
context "with winner" do
it "should always return the winner" do
green = Split::Alternative.new("green", "link_color")
experiment.winner = "green"
expect(experiment.next_alternative.name).to eq("green")
green.increment_participation
expect(experiment.next_alternative.name).to eq("green")
end
end
context "without winner" do
it "should use the specified algorithm" do
experiment.algorithm = Split::Algorithms::Whiplash
expect(experiment.algorithm).to receive(:choose_alternative).and_return(Split::Alternative.new("green", "link_color"))
expect(experiment.next_alternative.name).to eq("green")
end
end
end
context "with single alternative" do
let(:experiment) { Split::ExperimentCatalog.find_or_create("link_color", "blue") }
it "should always return the only alternative" do
expect(experiment.next_alternative.name).to eq("blue")
expect(experiment.next_alternative.name).to eq("blue")
end
end
end
describe "#cohorting_disabled?" do
it "returns false when nothing has been configured" do
expect(experiment.cohorting_disabled?).to eq false
end
it "returns true when enable_cohorting is performed" do
experiment.enable_cohorting
expect(experiment.cohorting_disabled?).to eq false
end
it "returns false when nothing has been configured" do
experiment.disable_cohorting
expect(experiment.cohorting_disabled?).to eq true
end
end
describe "changing an existing experiment" do
def same_but_different_alternative
Split::ExperimentCatalog.find_or_create("link_color", "blue", "yellow", "orange")
end
it "should reset an experiment if it is loaded with different alternatives" do
experiment.save
blue.participant_count = 5
same_experiment = same_but_different_alternative
expect(same_experiment.alternatives.map(&:name)).to eq(["blue", "yellow", "orange"])
expect(blue.participant_count).to eq(0)
end
it "should only reset once" do
experiment.save
expect(experiment.version).to eq(0)
same_experiment = same_but_different_alternative
expect(same_experiment.version).to eq(1)
same_experiment_again = same_but_different_alternative
expect(same_experiment_again.version).to eq(1)
end
context "when metadata is changed" do
it "should increase version" do
experiment.save
experiment.metadata = { "foo" => "bar" }
expect { experiment.save }.to change { experiment.version }.by(1)
end
it "does not increase version" do
experiment.metadata = nil
experiment.save
expect { experiment.save }.to change { experiment.version }.by(0)
end
end
context "when experiment configuration is changed" do
let(:reset_manually) { false }
before do
experiment.save
allow(Split.configuration).to receive(:reset_manually).and_return(reset_manually)
green.increment_participation
green.increment_participation
experiment.set_alternatives_and_options(alternatives: %w(blue red green zip),
goals: %w(purchase))
experiment.save
end
it "resets all alternatives" do
expect(green.participant_count).to eq(0)
expect(green.completed_count).to eq(0)
end
context "when reset_manually is set" do
let(:reset_manually) { true }
it "does not reset alternatives" do
expect(green.participant_count).to eq(2)
expect(green.completed_count).to eq(0)
end
end
end
end
describe "alternatives passed as non-strings" do
it "should throw an exception if an alternative is passed that is not a string" do
expect { Split::ExperimentCatalog.find_or_create("link_color", :blue, :red) }.to raise_error(ArgumentError)
expect { Split::ExperimentCatalog.find_or_create("link_enabled", true, false) }.to raise_error(ArgumentError)
end
end
describe "specifying weights" do
let(:experiment_with_weight) {
Split::ExperimentCatalog.find_or_create("link_color", { "blue" => 1 }, { "red" => 2 })
}
it "should work for a new experiment" do
expect(experiment_with_weight.alternatives.map(&:weight)).to eq([1, 2])
end
it "should work for an existing experiment" do
experiment.save
expect(experiment_with_weight.alternatives.map(&:weight)).to eq([1, 2])
end
end
describe "specifying goals" do
let(:experiment) {
new_experiment(["purchase"])
}
context "saving experiment" do
let(:same_but_different_goals) { Split::ExperimentCatalog.find_or_create({ "link_color" => ["purchase", "refund"] }, "blue", "red", "green") }
before { experiment.save }
it "can find existing experiment" do
expect(Split::ExperimentCatalog.find("link_color").name).to eq("link_color")
end
it "should reset an experiment if it is loaded with different goals" do
same_but_different_goals
expect(Split::ExperimentCatalog.find("link_color").goals).to eq(["purchase", "refund"])
end
end
it "should have goals" do
expect(experiment.goals).to eq(["purchase"])
end
context "find or create experiment" do
it "should have correct goals" do
experiment = Split::ExperimentCatalog.find_or_create({ "link_color3" => ["purchase", "refund"] }, "blue", "red", "green")
expect(experiment.goals).to eq(["purchase", "refund"])
experiment = Split::ExperimentCatalog.find_or_create("link_color3", "blue", "red", "green")
expect(experiment.goals).to eq([])
end
end
end
describe "beta probability calculation" do
it "should return a hash with the probability of each alternative being the best" do
experiment = Split::ExperimentCatalog.find_or_create("mathematicians", "bernoulli", "poisson", "lagrange")
experiment.calc_winning_alternatives
expect(experiment.alternative_probabilities).not_to be_nil
end
it "should return between 46% and 54% probability for an experiment with 2 alternatives and no data" do
experiment = Split::ExperimentCatalog.find_or_create("scientists", "einstein", "bohr")
experiment.calc_winning_alternatives
expect(experiment.alternatives[0].p_winner).to be_within(0.04).of(0.50)
end
it "should calculate the probability of being the winning alternative separately for each goal", skip: true do
experiment = Split::ExperimentCatalog.find_or_create({ "link_color3" => ["purchase", "refund"] }, "blue", "red", "green")
goal1 = experiment.goals[0]
goal2 = experiment.goals[1]
experiment.alternatives.each do |alternative|
alternative.participant_count = 50
alternative.set_completed_count(10, goal1)
alternative.set_completed_count(15+rand(30), goal2)
end
experiment.calc_winning_alternatives
alt = experiment.alternatives[0]
p_goal1 = alt.p_winner(goal1)
p_goal2 = alt.p_winner(goal2)
expect(p_goal1).not_to be_within(0.04).of(p_goal2)
end
it "should return nil and not re-calculate probabilities if they have already been calculated today" do
experiment = Split::ExperimentCatalog.find_or_create({ "link_color3" => ["purchase", "refund"] }, "blue", "red", "green")
expect(experiment.calc_winning_alternatives).not_to be nil
expect(experiment.calc_winning_alternatives).to be nil
end
end
end
<MSG> Merge pull request #35 from vrish88/master
Add experiment start date #12
<DFF> @@ -20,6 +20,15 @@ describe Split::Experiment do
Split.redis.exists('basket_text').should be true
end
+ it "should save the start time to redis" do
+ experiment_start_time = Time.parse("Sat Mar 03 14:01:03")
+ Time.stub(:now => experiment_start_time)
+ experiment = Split::Experiment.new('basket_text', 'Basket', "Cart")
+ experiment.save
+
+ Split::Experiment.find('basket_text').start_time.should == experiment_start_time
+ end
+
it "should not create duplicates when saving multiple times" do
experiment = Split::Experiment.new('basket_text', 'Basket', "Cart")
experiment.save
| 9 | Merge pull request #35 from vrish88/master | 0 | .rb | rb | mit | splitrb/split |
10071648 | <NME> parser.ts
<BEF> import { equal } from 'assert';
import parser from '../src/parser';
import expander from '../src/index';
import stringify from './assets/stringify';
describe('Parser', () => {
const parse = (str: string) => stringify(parser(str));
const expand = (str: string) => stringify(expander(str));
describe('Parse', () => {
it('basic abbreviations', () => {
equal(parse('a>b'), '<a><b></b></a>');
equal(parse('a+b'), '<a></a><b></b>');
equal(parse('a+b>c+d'), '<a></a><b><c></c><d></d></b>');
equal(parse('a>b>c+e'), '<a><b><c></c><e></e></b></a>');
equal(parse('a>b>c^d'), '<a><b><c></c></b><d></d></a>');
equal(parse('a>b>c^^^^d'), '<a><b><c></c></b></a><d></d>');
});
it('groups', () => {
equal(parse('a>(b>c)+d'), '<a><b><c></c></b><d></d></a>');
equal(parse('(a>b)+(c>d)'), '<a><b></b></a><c><d></d></c>');
equal(parse('a>((b>c)(d>e))f'), '<a><b><c></c></b><d><e></e></d><f></f></a>');
equal(parse('a>((((b>c))))+d'), '<a><b><c></c></b><d></d></a>');
equal(parse('a>(((b>c))*4)+d'), '<a>(<b><c></c></b>)*4<d></d></a>');
equal(parse('(div>dl>(dt+dd)*2)'), '<div><dl>(<dt></dt><dd></dd>)*2</dl></div>');
});
});
describe('Expand', () => {
it('unroll repeated elements', () => {
equal(expand('a*2>b*3'), '<a*2@1><b*3@1></b><b*3@2></b><b*3@3></b></a><a*2@2><b*3@1></b><b*3@2></b><b*3@3></b></a>');
equal(expand('a>(b+c)*2'), '<a><b*2@1></b><c*2@1></c><b*2@2></b><c*2@2></c></a>');
});
});
});
equal(str('a:b>c'), '<a:b><c></c></a:b>');
equal(str('ul.nav[title="foo"]'), '<ul class=nav title="foo"></ul>');
});
it('groups', () => {
equal(str('a>(b>c)+d'), '<a>(<b><c></c></b>)<d></d></a>');
equal(str('(a>b)+(c>d)'), '(<a><b></b></a>)(<c><d></d></c>)');
equal(str('a>((b>c)(d>e))f'), '<a>((<b><c></c></b>)(<d><e></e></d>))<f></f></a>');
equal(str('a>((((b>c))))+d'), '<a>((((<b><c></c></b>))))<d></d></a>');
equal(str('a>(((b>c))*4)+d'), '<a>(((<b><c></c></b>))*4)<d></d></a>');
equal(str('(div>dl>(dt+dd)*2)'), '(<div><dl>(<dt></dt><dd></dd>)*2</dl></div>)');
equal(str('a>()'), '<a>()</a>');
});
it('attributes', () => {
equal(str('[].foo'), '<? class=foo></?>');
equal(str('[a]'), '<? a></?>');
equal(str('[a b c [d]]'), '<? a b c [d]></?>');
equal(str('[a=b]'), '<? a=b></?>');
equal(str('[a=b c= d=e]'), '<? a=b c d=e></?>');
equal(str('[a=b.c d=ัะตัั]'), '<? a=b.c d=ัะตัั></?>');
equal(str('[[a]=b (c)=d]'), '<? [a]=b (c)=d></?>');
// Quoted attribute values
equal(str('[a="b"]'), '<? a="b"></?>');
equal(str('[a="b" c=\'d\' e=""]'), '<? a="b" c=\'d\' e=""></?>');
equal(str('[[a]="b" (c)=\'d\']'), '<? [a]="b" (c)=\'d\'></?>');
// Mixed quoted
equal(str('[a="foo\'bar" b=\'foo"bar\' c="foo\\\"bar"]'), '<? a="foo\'bar" b=\'foo"bar\' c="foo"bar"></?>');
// Boolean & implied attributes
equal(str('[a. b.]'), '<? a. b.></?>');
equal(str('[!a !b.]'), '<? !a !b.></?>');
// Default values
equal(str('["a.b"]'), '<? ?="a.b"></?>');
equal(str('[\'a.b\' "c=d" foo=bar "./test.html"]'), '<? ?=\'a.b\' ?="c=d" foo=bar ?="./test.html"></?>');
// Expressions as values
equal(str('[foo={1 + 2} bar={fn(1, "foo")}]'), '<? foo={1 + 2} bar={fn(1, "foo")}></?>');
// Tabstops as unquoted values
equal(str('[name=${1} value=${2:test}]'), '<? name=${1} value=${2:test}></?>');
});
it('malformed attributes', () => {
equal(str('[a'), '<? a></?>');
equal(str('[a={foo]'), '<? a={foo]></?>');
throws(() => str('[a="foo]'), /Unclosed quote/);
throws(() => str('[a=b=c]'), /Unexpected "Operator" token/);
});
it('elements', () => {
equal(str('div'), '<div></div>');
equal(str('div.foo'), '<div class=foo></div>');
equal(str('div#foo'), '<div id=foo></div>');
equal(str('div#foo.bar'), '<div id=foo class=bar></div>');
equal(str('div.foo#bar'), '<div class=foo id=bar></div>');
equal(str('div.foo.bar.baz'), '<div class=foo class=bar class=baz></div>');
equal(str('.foo'), '<? class=foo></?>');
equal(str('#foo'), '<? id=foo></?>');
equal(str('.foo_bar'), '<? class=foo_bar></?>');
equal(str('#foo.bar'), '<? id=foo class=bar></?>');
// Attribute shorthands
equal(str('.'), '<? class></?>');
equal(str('#'), '<? id></?>');
equal(str('#.'), '<? id class></?>');
equal(str('.#.'), '<? class id class></?>');
equal(str('.a..'), '<? class=a class></?>');
// Elements with attributes
equal(str('div[foo=bar]'), '<div foo=bar></div>');
equal(str('div.a[b=c]'), '<div class=a b=c></div>');
equal(str('div[b=c].a'), '<div b=c class=a></div>');
equal(str('div[a=b][c="d"]'), '<div a=b c="d"></div>');
equal(str('[b=c]'), '<? b=c></?>');
equal(str('.a[b=c]'), '<? class=a b=c></?>');
equal(str('[b=c].a#d'), '<? b=c class=a id=d></?>');
equal(str('[b=c]a'), '<? b=c></?><a></a>', 'Do not consume node name after attribute set');
// Element with text
equal(str('div{foo}'), '<div>foo</div>');
equal(str('{foo}'), '<?>foo</?>');
// Mixed
equal(str('div.foo{bar}'), '<div class=foo>bar</div>');
equal(str('.foo{bar}#baz'), '<? class=foo id=baz>bar</?>');
equal(str('.foo[b=c]{bar}'), '<? class=foo b=c>bar</?>');
// Repeated element
equal(str('div.foo*3'), '<div*3 class=foo></div>');
equal(str('.foo*'), '<?* class=foo></?>');
equal(str('.a[b=c]*10'), '<?*10 class=a b=c></?>');
equal(str('.a*10[b=c]'), '<?*10 class=a b=c></?>');
equal(str('.a*10{text}'), '<?*10 class=a>text</?>');
// Self-closing element
equal(str('div/'), '<div />');
equal(str('.foo/'), '<? class=foo />');
equal(str('.foo[bar]/'), '<? class=foo bar />');
equal(str('.foo/*3'), '<?*3 class=foo />');
equal(str('.foo*3/'), '<?*3 class=foo />');
throws(() => parse('/'), /Unexpected character/);
});
it('JSX', () => {
const opt = { jsx: true };
equal(str('foo.bar', opt), '<foo class=bar></foo>');
equal(str('Foo.bar', opt), '<Foo class=bar></Foo>');
equal(str('Foo.Bar', opt), '<Foo.Bar></Foo.Bar>');
equal(str('Foo.', opt), '<Foo class></Foo>');
equal(str('Foo.Bar.baz', opt), '<Foo.Bar class=baz></Foo.Bar>');
equal(str('Foo.Bar.Baz', opt), '<Foo.Bar.Baz></Foo.Bar.Baz>');
equal(str('.{theme.class}', opt), '<? class=theme.class></?>');
equal(str('#{id}', opt), '<? id=id></?>');
equal(str('Foo.{theme.class}', opt), '<Foo class=theme.class></Foo>');
});
it('errors', () => {
throws(() => parse('str?'), /Unexpected character at 4/);
throws(() => parse('foo,bar'), /Unexpected character at 4/);
equal(str('foo\\,bar'), '<foo,bar></foo,bar>');
equal(str('foo\\'), '<foo></foo>');
});
it('missing braces', () => {
// Do not throw errors on missing closing braces
equal(str('div[title="test"'), '<div title="test"></div>');
equal(str('div(foo'), '<div></div>(<foo></foo>)');
equal(str('div{foo'), '<div>foo</div>');
});
});
<MSG> New abbreviation parser implementation
Now it parses abbreviation into plain serializable AST
<DFF> @@ -1,36 +1,27 @@
import { equal } from 'assert';
-import parser from '../src/parser';
-import expander from '../src/index';
+import parser from '../src/index';
import stringify from './assets/stringify';
describe('Parser', () => {
const parse = (str: string) => stringify(parser(str));
- const expand = (str: string) => stringify(expander(str));
- describe('Parse', () => {
- it('basic abbreviations', () => {
- equal(parse('a>b'), '<a><b></b></a>');
- equal(parse('a+b'), '<a></a><b></b>');
- equal(parse('a+b>c+d'), '<a></a><b><c></c><d></d></b>');
- equal(parse('a>b>c+e'), '<a><b><c></c><e></e></b></a>');
- equal(parse('a>b>c^d'), '<a><b><c></c></b><d></d></a>');
- equal(parse('a>b>c^^^^d'), '<a><b><c></c></b></a><d></d>');
- });
-
- it('groups', () => {
- equal(parse('a>(b>c)+d'), '<a><b><c></c></b><d></d></a>');
- equal(parse('(a>b)+(c>d)'), '<a><b></b></a><c><d></d></c>');
- equal(parse('a>((b>c)(d>e))f'), '<a><b><c></c></b><d><e></e></d><f></f></a>');
- equal(parse('a>((((b>c))))+d'), '<a><b><c></c></b><d></d></a>');
- equal(parse('a>(((b>c))*4)+d'), '<a>(<b><c></c></b>)*4<d></d></a>');
- equal(parse('(div>dl>(dt+dd)*2)'), '<div><dl>(<dt></dt><dd></dd>)*2</dl></div>');
- });
+ it('basic abbreviations', () => {
+ equal(parse('a>b'), '<a><b></b></a>');
+ equal(parse('a+b'), '<a></a><b></b>');
+ equal(parse('a+b>c+d'), '<a></a><b><c></c><d></d></b>');
+ equal(parse('a>b>c+e'), '<a><b><c></c><e></e></b></a>');
+ equal(parse('a>b>c^d'), '<a><b><c></c></b><d></d></a>');
+ equal(parse('a>b>c^^^^d'), '<a><b><c></c></b></a><d></d>');
});
- describe('Expand', () => {
- it('unroll repeated elements', () => {
- equal(expand('a*2>b*3'), '<a*2@1><b*3@1></b><b*3@2></b><b*3@3></b></a><a*2@2><b*3@1></b><b*3@2></b><b*3@3></b></a>');
- equal(expand('a>(b+c)*2'), '<a><b*2@1></b><c*2@1></c><b*2@2></b><c*2@2></c></a>');
- });
+ it('groups', () => {
+ equal(parse('a>(b>c)+d'), '<a>(<b><c></c></b>)<d></d></a>');
+ equal(parse('(a>b)+(c>d)'), '(<a><b></b></a>)(<c><d></d></c>)');
+ equal(parse('a>((b>c)(d>e))f'), '<a>((<b><c></c></b>)(<d><e></e></d>))<f></f></a>');
+ equal(parse('a>((((b>c))))+d'), '<a>((((<b><c></c></b>))))<d></d></a>');
+ equal(parse('a>(((b>c))*4)+d'), '<a>(((<b><c></c></b>))*4)<d></d></a>');
+ equal(parse('(div>dl>(dt+dd)*2)'), '(<div><dl>(<dt></dt><dd></dd>)*2</dl></div>)');
+ equal(parse('a>()'), '<a>()</a>');
+
});
});
| 17 | New abbreviation parser implementation | 26 | .ts | ts | mit | emmetio/emmet |
10071649 | <NME> parser.ts
<BEF> import { equal } from 'assert';
import parser from '../src/parser';
import expander from '../src/index';
import stringify from './assets/stringify';
describe('Parser', () => {
const parse = (str: string) => stringify(parser(str));
const expand = (str: string) => stringify(expander(str));
describe('Parse', () => {
it('basic abbreviations', () => {
equal(parse('a>b'), '<a><b></b></a>');
equal(parse('a+b'), '<a></a><b></b>');
equal(parse('a+b>c+d'), '<a></a><b><c></c><d></d></b>');
equal(parse('a>b>c+e'), '<a><b><c></c><e></e></b></a>');
equal(parse('a>b>c^d'), '<a><b><c></c></b><d></d></a>');
equal(parse('a>b>c^^^^d'), '<a><b><c></c></b></a><d></d>');
});
it('groups', () => {
equal(parse('a>(b>c)+d'), '<a><b><c></c></b><d></d></a>');
equal(parse('(a>b)+(c>d)'), '<a><b></b></a><c><d></d></c>');
equal(parse('a>((b>c)(d>e))f'), '<a><b><c></c></b><d><e></e></d><f></f></a>');
equal(parse('a>((((b>c))))+d'), '<a><b><c></c></b><d></d></a>');
equal(parse('a>(((b>c))*4)+d'), '<a>(<b><c></c></b>)*4<d></d></a>');
equal(parse('(div>dl>(dt+dd)*2)'), '<div><dl>(<dt></dt><dd></dd>)*2</dl></div>');
});
});
describe('Expand', () => {
it('unroll repeated elements', () => {
equal(expand('a*2>b*3'), '<a*2@1><b*3@1></b><b*3@2></b><b*3@3></b></a><a*2@2><b*3@1></b><b*3@2></b><b*3@3></b></a>');
equal(expand('a>(b+c)*2'), '<a><b*2@1></b><c*2@1></c><b*2@2></b><c*2@2></c></a>');
});
});
});
equal(str('a:b>c'), '<a:b><c></c></a:b>');
equal(str('ul.nav[title="foo"]'), '<ul class=nav title="foo"></ul>');
});
it('groups', () => {
equal(str('a>(b>c)+d'), '<a>(<b><c></c></b>)<d></d></a>');
equal(str('(a>b)+(c>d)'), '(<a><b></b></a>)(<c><d></d></c>)');
equal(str('a>((b>c)(d>e))f'), '<a>((<b><c></c></b>)(<d><e></e></d>))<f></f></a>');
equal(str('a>((((b>c))))+d'), '<a>((((<b><c></c></b>))))<d></d></a>');
equal(str('a>(((b>c))*4)+d'), '<a>(((<b><c></c></b>))*4)<d></d></a>');
equal(str('(div>dl>(dt+dd)*2)'), '(<div><dl>(<dt></dt><dd></dd>)*2</dl></div>)');
equal(str('a>()'), '<a>()</a>');
});
it('attributes', () => {
equal(str('[].foo'), '<? class=foo></?>');
equal(str('[a]'), '<? a></?>');
equal(str('[a b c [d]]'), '<? a b c [d]></?>');
equal(str('[a=b]'), '<? a=b></?>');
equal(str('[a=b c= d=e]'), '<? a=b c d=e></?>');
equal(str('[a=b.c d=ัะตัั]'), '<? a=b.c d=ัะตัั></?>');
equal(str('[[a]=b (c)=d]'), '<? [a]=b (c)=d></?>');
// Quoted attribute values
equal(str('[a="b"]'), '<? a="b"></?>');
equal(str('[a="b" c=\'d\' e=""]'), '<? a="b" c=\'d\' e=""></?>');
equal(str('[[a]="b" (c)=\'d\']'), '<? [a]="b" (c)=\'d\'></?>');
// Mixed quoted
equal(str('[a="foo\'bar" b=\'foo"bar\' c="foo\\\"bar"]'), '<? a="foo\'bar" b=\'foo"bar\' c="foo"bar"></?>');
// Boolean & implied attributes
equal(str('[a. b.]'), '<? a. b.></?>');
equal(str('[!a !b.]'), '<? !a !b.></?>');
// Default values
equal(str('["a.b"]'), '<? ?="a.b"></?>');
equal(str('[\'a.b\' "c=d" foo=bar "./test.html"]'), '<? ?=\'a.b\' ?="c=d" foo=bar ?="./test.html"></?>');
// Expressions as values
equal(str('[foo={1 + 2} bar={fn(1, "foo")}]'), '<? foo={1 + 2} bar={fn(1, "foo")}></?>');
// Tabstops as unquoted values
equal(str('[name=${1} value=${2:test}]'), '<? name=${1} value=${2:test}></?>');
});
it('malformed attributes', () => {
equal(str('[a'), '<? a></?>');
equal(str('[a={foo]'), '<? a={foo]></?>');
throws(() => str('[a="foo]'), /Unclosed quote/);
throws(() => str('[a=b=c]'), /Unexpected "Operator" token/);
});
it('elements', () => {
equal(str('div'), '<div></div>');
equal(str('div.foo'), '<div class=foo></div>');
equal(str('div#foo'), '<div id=foo></div>');
equal(str('div#foo.bar'), '<div id=foo class=bar></div>');
equal(str('div.foo#bar'), '<div class=foo id=bar></div>');
equal(str('div.foo.bar.baz'), '<div class=foo class=bar class=baz></div>');
equal(str('.foo'), '<? class=foo></?>');
equal(str('#foo'), '<? id=foo></?>');
equal(str('.foo_bar'), '<? class=foo_bar></?>');
equal(str('#foo.bar'), '<? id=foo class=bar></?>');
// Attribute shorthands
equal(str('.'), '<? class></?>');
equal(str('#'), '<? id></?>');
equal(str('#.'), '<? id class></?>');
equal(str('.#.'), '<? class id class></?>');
equal(str('.a..'), '<? class=a class></?>');
// Elements with attributes
equal(str('div[foo=bar]'), '<div foo=bar></div>');
equal(str('div.a[b=c]'), '<div class=a b=c></div>');
equal(str('div[b=c].a'), '<div b=c class=a></div>');
equal(str('div[a=b][c="d"]'), '<div a=b c="d"></div>');
equal(str('[b=c]'), '<? b=c></?>');
equal(str('.a[b=c]'), '<? class=a b=c></?>');
equal(str('[b=c].a#d'), '<? b=c class=a id=d></?>');
equal(str('[b=c]a'), '<? b=c></?><a></a>', 'Do not consume node name after attribute set');
// Element with text
equal(str('div{foo}'), '<div>foo</div>');
equal(str('{foo}'), '<?>foo</?>');
// Mixed
equal(str('div.foo{bar}'), '<div class=foo>bar</div>');
equal(str('.foo{bar}#baz'), '<? class=foo id=baz>bar</?>');
equal(str('.foo[b=c]{bar}'), '<? class=foo b=c>bar</?>');
// Repeated element
equal(str('div.foo*3'), '<div*3 class=foo></div>');
equal(str('.foo*'), '<?* class=foo></?>');
equal(str('.a[b=c]*10'), '<?*10 class=a b=c></?>');
equal(str('.a*10[b=c]'), '<?*10 class=a b=c></?>');
equal(str('.a*10{text}'), '<?*10 class=a>text</?>');
// Self-closing element
equal(str('div/'), '<div />');
equal(str('.foo/'), '<? class=foo />');
equal(str('.foo[bar]/'), '<? class=foo bar />');
equal(str('.foo/*3'), '<?*3 class=foo />');
equal(str('.foo*3/'), '<?*3 class=foo />');
throws(() => parse('/'), /Unexpected character/);
});
it('JSX', () => {
const opt = { jsx: true };
equal(str('foo.bar', opt), '<foo class=bar></foo>');
equal(str('Foo.bar', opt), '<Foo class=bar></Foo>');
equal(str('Foo.Bar', opt), '<Foo.Bar></Foo.Bar>');
equal(str('Foo.', opt), '<Foo class></Foo>');
equal(str('Foo.Bar.baz', opt), '<Foo.Bar class=baz></Foo.Bar>');
equal(str('Foo.Bar.Baz', opt), '<Foo.Bar.Baz></Foo.Bar.Baz>');
equal(str('.{theme.class}', opt), '<? class=theme.class></?>');
equal(str('#{id}', opt), '<? id=id></?>');
equal(str('Foo.{theme.class}', opt), '<Foo class=theme.class></Foo>');
});
it('errors', () => {
throws(() => parse('str?'), /Unexpected character at 4/);
throws(() => parse('foo,bar'), /Unexpected character at 4/);
equal(str('foo\\,bar'), '<foo,bar></foo,bar>');
equal(str('foo\\'), '<foo></foo>');
});
it('missing braces', () => {
// Do not throw errors on missing closing braces
equal(str('div[title="test"'), '<div title="test"></div>');
equal(str('div(foo'), '<div></div>(<foo></foo>)');
equal(str('div{foo'), '<div>foo</div>');
});
});
<MSG> New abbreviation parser implementation
Now it parses abbreviation into plain serializable AST
<DFF> @@ -1,36 +1,27 @@
import { equal } from 'assert';
-import parser from '../src/parser';
-import expander from '../src/index';
+import parser from '../src/index';
import stringify from './assets/stringify';
describe('Parser', () => {
const parse = (str: string) => stringify(parser(str));
- const expand = (str: string) => stringify(expander(str));
- describe('Parse', () => {
- it('basic abbreviations', () => {
- equal(parse('a>b'), '<a><b></b></a>');
- equal(parse('a+b'), '<a></a><b></b>');
- equal(parse('a+b>c+d'), '<a></a><b><c></c><d></d></b>');
- equal(parse('a>b>c+e'), '<a><b><c></c><e></e></b></a>');
- equal(parse('a>b>c^d'), '<a><b><c></c></b><d></d></a>');
- equal(parse('a>b>c^^^^d'), '<a><b><c></c></b></a><d></d>');
- });
-
- it('groups', () => {
- equal(parse('a>(b>c)+d'), '<a><b><c></c></b><d></d></a>');
- equal(parse('(a>b)+(c>d)'), '<a><b></b></a><c><d></d></c>');
- equal(parse('a>((b>c)(d>e))f'), '<a><b><c></c></b><d><e></e></d><f></f></a>');
- equal(parse('a>((((b>c))))+d'), '<a><b><c></c></b><d></d></a>');
- equal(parse('a>(((b>c))*4)+d'), '<a>(<b><c></c></b>)*4<d></d></a>');
- equal(parse('(div>dl>(dt+dd)*2)'), '<div><dl>(<dt></dt><dd></dd>)*2</dl></div>');
- });
+ it('basic abbreviations', () => {
+ equal(parse('a>b'), '<a><b></b></a>');
+ equal(parse('a+b'), '<a></a><b></b>');
+ equal(parse('a+b>c+d'), '<a></a><b><c></c><d></d></b>');
+ equal(parse('a>b>c+e'), '<a><b><c></c><e></e></b></a>');
+ equal(parse('a>b>c^d'), '<a><b><c></c></b><d></d></a>');
+ equal(parse('a>b>c^^^^d'), '<a><b><c></c></b></a><d></d>');
});
- describe('Expand', () => {
- it('unroll repeated elements', () => {
- equal(expand('a*2>b*3'), '<a*2@1><b*3@1></b><b*3@2></b><b*3@3></b></a><a*2@2><b*3@1></b><b*3@2></b><b*3@3></b></a>');
- equal(expand('a>(b+c)*2'), '<a><b*2@1></b><c*2@1></c><b*2@2></b><c*2@2></c></a>');
- });
+ it('groups', () => {
+ equal(parse('a>(b>c)+d'), '<a>(<b><c></c></b>)<d></d></a>');
+ equal(parse('(a>b)+(c>d)'), '(<a><b></b></a>)(<c><d></d></c>)');
+ equal(parse('a>((b>c)(d>e))f'), '<a>((<b><c></c></b>)(<d><e></e></d>))<f></f></a>');
+ equal(parse('a>((((b>c))))+d'), '<a>((((<b><c></c></b>))))<d></d></a>');
+ equal(parse('a>(((b>c))*4)+d'), '<a>(((<b><c></c></b>))*4)<d></d></a>');
+ equal(parse('(div>dl>(dt+dd)*2)'), '(<div><dl>(<dt></dt><dd></dd>)*2</dl></div>)');
+ equal(parse('a>()'), '<a>()</a>');
+
});
});
| 17 | New abbreviation parser implementation | 26 | .ts | ts | mit | emmetio/emmet |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.