canary_labs 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/canary_labs.rb +26 -0
- data/lib/canary_labs/version.rb +1 -1
- data/test/canary_labs_test.rb +49 -0
- data/test/dummy/log/test.log +46 -0
- data/test/{beta_test.rb → feature_test.rb} +0 -0
- metadata +7 -8
- data/lib/experiment_repo.rb +0 -30
- data/test/betas_test.rb +0 -7
- data/test/experiment_repo_test.rb +0 -59
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '078f2fad26d4635f85ac16816ec3c3a06a4e9ef514dfc4d001619aab7b55fcfe'
|
4
|
+
data.tar.gz: 6eb10e300a0f83434d26d3a928fdc1efc8e185b493fc93ba581933c7e6a8be88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d49bb7c90d22730e15bfe9a2fe57205f7548021e7287b88c8323af8412683d99f367fbf89db2aeec727090ed3c6e9b3e1993f8e591081368a33890fead4012ac
|
7
|
+
data.tar.gz: '0846f61ad177c82548302eb1477cf364613c11f79cc440c207ebda1ac33a324d538817b792c336cd09075a9bd4b9539c6f03c6778c1b9835aea28ff5aa913f61'
|
data/lib/canary_labs.rb
CHANGED
@@ -1,2 +1,28 @@
|
|
1
1
|
module CanaryLabs
|
2
|
+
mattr_accessor :default_participation
|
3
|
+
|
4
|
+
def self.setup default_participation: true
|
5
|
+
@@experiments = {}
|
6
|
+
@@default_participation = default_participation
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.participating? feat_name, id
|
10
|
+
experiment = @@experiments[feat_name]
|
11
|
+
|
12
|
+
return @@default_participation if experiment.nil?
|
13
|
+
|
14
|
+
experiment.participating? id
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.add name, desc, resolver
|
18
|
+
@@experiments[name] = Feature.new name, desc, resolver
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.find name
|
22
|
+
@@experiments[name]
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.all
|
26
|
+
@@experiments.values
|
27
|
+
end
|
2
28
|
end
|
data/lib/canary_labs/version.rb
CHANGED
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'feature'
|
3
|
+
require 'resolvers/group'
|
4
|
+
|
5
|
+
class CanaryLabsTest < ActiveSupport::TestCase
|
6
|
+
setup do
|
7
|
+
CanaryLabs.setup
|
8
|
+
end
|
9
|
+
|
10
|
+
test "truth" do
|
11
|
+
assert_kind_of Module, CanaryLabs
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_add_feature
|
15
|
+
CanaryLabs.add :added_feat, '', CanaryLabs::Resolvers::Group.new([])
|
16
|
+
|
17
|
+
assert_includes(
|
18
|
+
CanaryLabs.all,
|
19
|
+
Feature.new(:added_feat, '', CanaryLabs::Resolvers::Group.new([])),
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_find_feature_by_name
|
24
|
+
CanaryLabs.add :feat_to_find, '', CanaryLabs::Resolvers::Group.new([])
|
25
|
+
|
26
|
+
assert_equal(
|
27
|
+
Feature.new(:feat_to_find, '', CanaryLabs::Resolvers::Group.new([])),
|
28
|
+
CanaryLabs.find(:feat_to_find),
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_participating_by_name
|
33
|
+
CanaryLabs.add :feat, '', CanaryLabs::Resolvers::Group.new(['my_id'])
|
34
|
+
|
35
|
+
assert CanaryLabs.participating? :feat, 'my_id'
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_participating_with_bad_name
|
39
|
+
assert CanaryLabs.participating? :bad_name, 'my_id'
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_list_all_feats
|
43
|
+
CanaryLabs.add :feat_a, '', CanaryLabs::Resolvers::Group.new([])
|
44
|
+
|
45
|
+
all_feats = CanaryLabs.all
|
46
|
+
|
47
|
+
assert_includes all_feats, Feature.new(:feat_a, '', CanaryLabs::Resolvers::Group.new([]))
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
2
|
+
[1m[36m (1.3ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
3
|
+
[1m[35m (0.0ms)[0m select sqlite_version(*)
|
4
|
+
[1m[36m (0.7ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
5
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
6
|
+
[1m[36m (0.8ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
7
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
8
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
9
|
+
--------------------------------
|
10
|
+
CanaryLabsTest: test_add_feature
|
11
|
+
--------------------------------
|
12
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
13
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
14
|
+
[1m[36m (1.1ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
15
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
16
|
+
[1m[36m (0.9ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
17
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
18
|
+
[1m[36m (0.7ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
19
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
20
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
21
|
+
--------------------------------
|
22
|
+
CanaryLabsTest: test_add_feature
|
23
|
+
--------------------------------
|
24
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
25
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
26
|
+
-----------------------------------------
|
27
|
+
CanaryLabsTest: test_find_feature_by_name
|
28
|
+
-----------------------------------------
|
29
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
30
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
31
|
+
--------------------------
|
32
|
+
CanaryLabsTest: test_truth
|
33
|
+
--------------------------
|
34
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
35
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
36
|
+
[1m[36m (1.2ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
37
|
+
[1m[35m (0.0ms)[0m select sqlite_version(*)
|
38
|
+
[1m[36m (0.7ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
39
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
40
|
+
[1m[36m (0.7ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
41
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
42
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
43
|
+
------------------------------------------
|
44
|
+
CanaryLabsTest: test_participating_by_name
|
45
|
+
------------------------------------------
|
46
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: canary_labs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Davis Kimoto
|
@@ -50,7 +50,6 @@ files:
|
|
50
50
|
- Rakefile
|
51
51
|
- lib/canary_labs.rb
|
52
52
|
- lib/canary_labs/version.rb
|
53
|
-
- lib/experiment_repo.rb
|
54
53
|
- lib/feature.rb
|
55
54
|
- lib/generators/initializer/USAGE
|
56
55
|
- lib/generators/initializer/initializer_generator.rb
|
@@ -58,8 +57,7 @@ files:
|
|
58
57
|
- lib/resolvers/group.rb
|
59
58
|
- lib/resolvers/percentage.rb
|
60
59
|
- lib/tasks/canary_labs_tasks.rake
|
61
|
-
- test/
|
62
|
-
- test/betas_test.rb
|
60
|
+
- test/canary_labs_test.rb
|
63
61
|
- test/dummy/README.rdoc
|
64
62
|
- test/dummy/Rakefile
|
65
63
|
- test/dummy/app/assets/config/manifest.js
|
@@ -95,11 +93,12 @@ files:
|
|
95
93
|
- test/dummy/db/development.sqlite3
|
96
94
|
- test/dummy/db/schema.rb
|
97
95
|
- test/dummy/db/test.sqlite3
|
96
|
+
- test/dummy/log/test.log
|
98
97
|
- test/dummy/public/404.html
|
99
98
|
- test/dummy/public/422.html
|
100
99
|
- test/dummy/public/500.html
|
101
100
|
- test/dummy/public/favicon.ico
|
102
|
-
- test/
|
101
|
+
- test/feature_test.rb
|
103
102
|
- test/resolvers/group_test.rb
|
104
103
|
- test/resolvers/percentage_test.rb
|
105
104
|
- test/test_helper.rb
|
@@ -165,10 +164,10 @@ test_files:
|
|
165
164
|
- test/dummy/db/schema.rb
|
166
165
|
- test/dummy/db/test.sqlite3
|
167
166
|
- test/dummy/db/development.sqlite3
|
167
|
+
- test/dummy/log/test.log
|
168
168
|
- test/dummy/README.rdoc
|
169
169
|
- test/resolvers/group_test.rb
|
170
170
|
- test/resolvers/percentage_test.rb
|
171
|
-
- test/
|
172
|
-
- test/experiment_repo_test.rb
|
171
|
+
- test/feature_test.rb
|
173
172
|
- test/test_helper.rb
|
174
|
-
- test/
|
173
|
+
- test/canary_labs_test.rb
|
data/lib/experiment_repo.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
module CanaryLabs
|
2
|
-
class ExperimentRepo
|
3
|
-
attr_reader :default_participation
|
4
|
-
|
5
|
-
def initialize default_participation: true
|
6
|
-
@betas = {}
|
7
|
-
@default_participation = default_participation
|
8
|
-
end
|
9
|
-
|
10
|
-
def participating? beta_name, id
|
11
|
-
b = @betas[beta_name]
|
12
|
-
|
13
|
-
return @default_participation if b.nil?
|
14
|
-
|
15
|
-
b.participating? id
|
16
|
-
end
|
17
|
-
|
18
|
-
def add name, desc, resolver
|
19
|
-
@betas[name] = Feature.new name, desc, resolver
|
20
|
-
end
|
21
|
-
|
22
|
-
def find name
|
23
|
-
@betas[name]
|
24
|
-
end
|
25
|
-
|
26
|
-
def all
|
27
|
-
@betas.values
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
data/test/betas_test.rb
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'experiment_repo'
|
3
|
-
require 'feature'
|
4
|
-
require 'resolvers/group'
|
5
|
-
|
6
|
-
module CanaryLabs
|
7
|
-
class ExperimentRepoTest < ActiveSupport::TestCase
|
8
|
-
def test_add_beta
|
9
|
-
repo = new_repo
|
10
|
-
repo.add :added_beta, '', CanaryLabs::Resolvers::Group.new([])
|
11
|
-
|
12
|
-
assert_includes(
|
13
|
-
repo.all,
|
14
|
-
Feature.new(:added_beta, '', CanaryLabs::Resolvers::Group.new([])),
|
15
|
-
)
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_find_beta_by_name
|
19
|
-
repo = new_repo
|
20
|
-
repo.add :beta_to_find, '', CanaryLabs::Resolvers::Group.new([])
|
21
|
-
|
22
|
-
assert_equal(
|
23
|
-
Feature.new(:beta_to_find, '', CanaryLabs::Resolvers::Group.new([])),
|
24
|
-
repo.find(:beta_to_find)
|
25
|
-
)
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_participating_by_name
|
29
|
-
repo = new_repo
|
30
|
-
repo.add :participatable_beta, '', CanaryLabs::Resolvers::Group.new(['my_id'])
|
31
|
-
|
32
|
-
assert repo.participating? :participatable_beta, 'my_id'
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_participating_with_bad_name
|
36
|
-
repo = new_repo
|
37
|
-
|
38
|
-
assert repo.participating? :bad_name, 'my_id'
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_list_all_betas
|
42
|
-
repo = new_repo
|
43
|
-
repo.add :beta_a, '', CanaryLabs::Resolvers::Group.new([])
|
44
|
-
repo.add :beta_b, '', CanaryLabs::Resolvers::Group.new([])
|
45
|
-
repo.add :beta_c, '', CanaryLabs::Resolvers::Group.new([])
|
46
|
-
|
47
|
-
all_betas = repo.all
|
48
|
-
|
49
|
-
assert_equal 3, all_betas.length
|
50
|
-
assert_includes all_betas, Feature.new(:beta_a, '', CanaryLabs::Resolvers::Group.new([]))
|
51
|
-
end
|
52
|
-
|
53
|
-
private
|
54
|
-
|
55
|
-
def new_repo
|
56
|
-
CanaryLabs::ExperimentRepo.new
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|