Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails 6 #8

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }

gemspec

gem "rails"
gem "rails", "~> 5.2.5"
gem "puma"

gem "minitest"
Expand Down
223 changes: 98 additions & 125 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,105 +2,84 @@ PATH
remote: .
specs:
activeexperiment (0.1.1.alpha)
activesupport (>= 7.0.4)
activesupport (>= 5.0.0)
globalid (>= 0.3.6)

GEM
remote: https://rubygems.org/
specs:
actioncable (7.0.4)
actionpack (= 7.0.4)
activesupport (= 7.0.4)
actioncable (5.2.8.1)
actionpack (= 5.2.8.1)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (7.0.4)
actionpack (= 7.0.4)
activejob (= 7.0.4)
activerecord (= 7.0.4)
activestorage (= 7.0.4)
activesupport (= 7.0.4)
mail (>= 2.7.1)
net-imap
net-pop
net-smtp
actionmailer (7.0.4)
actionpack (= 7.0.4)
actionview (= 7.0.4)
activejob (= 7.0.4)
activesupport (= 7.0.4)
actionmailer (5.2.8.1)
actionpack (= 5.2.8.1)
actionview (= 5.2.8.1)
activejob (= 5.2.8.1)
mail (~> 2.5, >= 2.5.4)
net-imap
net-pop
net-smtp
rails-dom-testing (~> 2.0)
actionpack (7.0.4)
actionview (= 7.0.4)
activesupport (= 7.0.4)
rack (~> 2.0, >= 2.2.0)
actionpack (5.2.8.1)
actionview (= 5.2.8.1)
activesupport (= 5.2.8.1)
rack (~> 2.0, >= 2.0.8)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (7.0.4)
actionpack (= 7.0.4)
activerecord (= 7.0.4)
activestorage (= 7.0.4)
activesupport (= 7.0.4)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (7.0.4)
activesupport (= 7.0.4)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.2.8.1)
activesupport (= 5.2.8.1)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (7.0.4)
activesupport (= 7.0.4)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.2.8.1)
activesupport (= 5.2.8.1)
globalid (>= 0.3.6)
activemodel (7.0.4)
activesupport (= 7.0.4)
activerecord (7.0.4)
activemodel (= 7.0.4)
activesupport (= 7.0.4)
activestorage (7.0.4)
actionpack (= 7.0.4)
activejob (= 7.0.4)
activerecord (= 7.0.4)
activesupport (= 7.0.4)
marcel (~> 1.0)
mini_mime (>= 1.1.0)
activesupport (7.0.4)
activemodel (5.2.8.1)
activesupport (= 5.2.8.1)
activerecord (5.2.8.1)
activemodel (= 5.2.8.1)
activesupport (= 5.2.8.1)
arel (>= 9.0)
activestorage (5.2.8.1)
actionpack (= 5.2.8.1)
activerecord (= 5.2.8.1)
marcel (~> 1.0.0)
activesupport (5.2.8.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
arel (9.0.0)
ast (2.4.2)
bootsnap (1.15.0)
bootsnap (1.16.0)
msgpack (~> 1.2)
builder (3.2.4)
concurrent-ruby (1.1.10)
concurrent-ruby (1.2.2)
connection_pool (2.3.0)
crass (1.0.6)
date (3.3.3)
docile (1.4.0)
erubi (1.11.0)
globalid (1.0.0)
erubi (1.12.0)
globalid (1.1.0)
activesupport (>= 5.0)
i18n (1.12.0)
concurrent-ruby (~> 1.0)
json (2.6.2)
loofah (2.19.0)
json (2.6.3)
loofah (2.19.1)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.8.0)
mail (2.8.1)
mini_mime (>= 0.1.1)
net-imap
net-pop
net-smtp
marcel (1.0.2)
method_source (1.0.0)
mini_mime (1.1.2)
minitest (5.16.3)
msgpack (1.6.0)
net-imap (0.3.1)
minitest (5.18.0)
msgpack (1.6.1)
net-imap (0.3.4)
date
net-protocol
net-pop (0.1.2)
net-protocol
Expand All @@ -109,117 +88,111 @@ GEM
net-smtp (0.3.3)
net-protocol
nio4r (2.5.8)
nokogiri (1.13.10-arm64-darwin)
racc (~> 1.4)
nokogiri (1.13.10-x86_64-darwin)
nokogiri (1.14.2-x86_64-darwin)
racc (~> 1.4)
parallel (1.22.1)
parser (3.1.3.0)
parser (3.2.1.1)
ast (~> 2.4.1)
psych (4.0.6)
psych (5.1.0)
stringio
puma (6.0.0)
puma (6.1.1)
nio4r (~> 2.0)
racc (1.6.1)
rack (2.2.4)
rack-test (2.0.2)
racc (1.6.2)
rack (2.2.6.4)
rack-test (2.1.0)
rack (>= 1.3)
rails (7.0.4)
actioncable (= 7.0.4)
actionmailbox (= 7.0.4)
actionmailer (= 7.0.4)
actionpack (= 7.0.4)
actiontext (= 7.0.4)
actionview (= 7.0.4)
activejob (= 7.0.4)
activemodel (= 7.0.4)
activerecord (= 7.0.4)
activestorage (= 7.0.4)
activesupport (= 7.0.4)
bundler (>= 1.15.0)
railties (= 7.0.4)
rails (5.2.8.1)
actioncable (= 5.2.8.1)
actionmailer (= 5.2.8.1)
actionpack (= 5.2.8.1)
actionview (= 5.2.8.1)
activejob (= 5.2.8.1)
activemodel (= 5.2.8.1)
activerecord (= 5.2.8.1)
activestorage (= 5.2.8.1)
activesupport (= 5.2.8.1)
bundler (>= 1.3.0)
railties (= 5.2.8.1)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.4.3)
loofah (~> 2.3)
railties (7.0.4)
actionpack (= 7.0.4)
activesupport (= 7.0.4)
rails-html-sanitizer (1.5.0)
loofah (~> 2.19, >= 2.19.1)
railties (5.2.8.1)
actionpack (= 5.2.8.1)
activesupport (= 5.2.8.1)
method_source
rake (>= 12.2)
thor (~> 1.0)
zeitwerk (~> 2.5)
rake (>= 0.8.7)
thor (>= 0.19.0, < 2.0)
rainbow (3.1.1)
rake (13.0.6)
rdoc (6.4.0)
rdoc (6.5.0)
psych (>= 4.0.0)
redis (5.0.5)
redis (5.0.6)
redis-client (>= 0.9.0)
redis-client (0.11.2)
redis-client (0.14.0)
connection_pool
regexp_parser (2.6.1)
regexp_parser (2.7.0)
rexml (3.2.5)
rubocop (1.39.0)
rubocop (1.48.1)
json (~> 2.3)
parallel (~> 1.10)
parser (>= 3.1.2.1)
parser (>= 3.2.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.23.0, < 2.0)
rubocop-ast (>= 1.26.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.24.0)
parser (>= 3.1.1.0)
rubocop-minitest (0.24.0)
rubocop (>= 0.90, < 2.0)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.27.0)
parser (>= 3.2.1.0)
rubocop-minitest (0.29.0)
rubocop (>= 1.39, < 2.0)
rubocop-packaging (0.5.2)
rubocop (>= 1.33, < 2.0)
rubocop-performance (1.15.1)
rubocop-performance (1.16.0)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
rubocop-rails (2.17.3)
rubocop-rails (2.18.0)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
ruby-progressbar (1.11.0)
simplecov (0.21.2)
ruby-progressbar (1.13.0)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.4)
sprockets (4.1.1)
sprockets (4.2.0)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
rack (>= 2.2.4, < 4)
sprockets-rails (3.4.2)
actionpack (>= 5.2)
activesupport (>= 5.2)
sprockets (>= 3.0.0)
sqlite3 (1.5.4-arm64-darwin)
sqlite3 (1.5.4-x86_64-darwin)
stringio (3.0.2)
sqlite3 (1.6.1-x86_64-darwin)
stringio (3.0.5)
thor (1.2.1)
timeout (0.3.1)
tzinfo (2.0.5)
concurrent-ruby (~> 1.0)
unicode-display_width (2.3.0)
thread_safe (0.3.6)
timeout (0.3.2)
tzinfo (1.2.11)
thread_safe (~> 0.1)
unicode-display_width (2.4.2)
websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
zeitwerk (2.6.6)

PLATFORMS
arm64-darwin-22
x86_64-darwin-21

DEPENDENCIES
activeexperiment!
bootsnap
minitest
puma
rails
rails (~> 5.2.5)
rdoc
redis
rubocop (>= 1.25.1)
Expand All @@ -232,4 +205,4 @@ DEPENDENCIES
sqlite3 (~> 1.4)

BUNDLED WITH
2.3.24
2.3.13
2 changes: 1 addition & 1 deletion activeexperiment.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ Gem::Specification.new do |s|
"rubygems_mfa_required" => "true",
}

s.add_dependency "activesupport", ">= 7.0.4" # TODO: use `version` here
s.add_dependency "activesupport", ">= 5.0.0" # TODO: use `version` here
s.add_dependency "globalid", ">= 0.3.6"
end
8 changes: 4 additions & 4 deletions lib/active_experiment/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ def experiment_name
end

private
def control(...)
variant(:control, ...)
def control(*filters, **options, &block)
variant(:control, *filters, **options, &block)
end

def variant(name, ...)
register_variant_callback(name, ...)
def variant(name, *filters, **options, &block)
register_variant_callback(name, *filters, **options, &block)
end
end

Expand Down
3 changes: 3 additions & 0 deletions lib/active_experiment/instrumentation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ def instrument(operation, **payload, &block)
return ActiveSupport::Notifications.instrument(operation, payload) unless block.present?

ActiveSupport::Notifications.instrument(operation, payload) do |event_payload|
@variant = nil unless defined?(@variant)
@halted_callback = nil unless defined?(@halted_callback)

variant = @variant
results = block.call

Expand Down
2 changes: 1 addition & 1 deletion lib/active_experiment/rollouts/percent_rollout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module Rollouts
# ActiveExperiment::Base.default_rollout = :percent
# Rails.application.config.active_experiment.default_rollout = :percent
class PercentRollout < BaseRollout
def initialize(experiment_class, ...) # :nodoc:
def initialize(experiment_class, *args, **options, &block) # :nodoc:
super

validate!(experiment_class)
Expand Down
2 changes: 1 addition & 1 deletion lib/active_experiment/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def assert_experiment_with(experiment_class, context: nil, options: nil, variant
# stub out the rollout of an experiment in a test. It can also be inherited
# and customized.
class MockRollout < Rollouts::BaseRollout
def initialize(...)
def initialize(experiment_class, *args, **options, &block)
@assigned = 0
super
end
Expand Down