flipper 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +4 -0
- data/examples/group_with_members.rb +94 -0
- data/lib/flipper/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 843d4702915781ed5862b1e06ad68f1bbc70edab
|
4
|
+
data.tar.gz: b3709b9a9bddaee1e6847eca0401f4bbcfe09944
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06713185ad986e260ab2e409f9b995267c938823c8f7a7193ce82e618a753849e813d3a34f5af3100aed44e79d5c2874b1acf9cef09fc588505ecc8f1cf59892
|
7
|
+
data.tar.gz: f1dab95196ab81477d3eb0e2c667fa36341763417582efc6181a40d5f64f60c24d118fd840a7bde4155b820301a6991e25975c8a88faa8ff4cb495e5946061e4
|
data/Changelog.md
CHANGED
@@ -0,0 +1,94 @@
|
|
1
|
+
require File.expand_path('../example_setup', __FILE__)
|
2
|
+
|
3
|
+
require 'flipper'
|
4
|
+
require 'flipper/adapters/memory'
|
5
|
+
|
6
|
+
adapter = Flipper::Adapters::Memory.new
|
7
|
+
flipper = Flipper.new(adapter)
|
8
|
+
stats = flipper[:stats]
|
9
|
+
|
10
|
+
# Register group
|
11
|
+
Flipper.register(:team_actor) do |actor|
|
12
|
+
actor.is_a?(TeamActor) && actor.allowed?
|
13
|
+
end
|
14
|
+
|
15
|
+
# Some class that represents actor that will be trying to do something
|
16
|
+
class User
|
17
|
+
attr_reader :id
|
18
|
+
|
19
|
+
def initialize(id)
|
20
|
+
@id = id
|
21
|
+
end
|
22
|
+
|
23
|
+
# Must respond to flipper_id
|
24
|
+
alias_method :flipper_id, :id
|
25
|
+
end
|
26
|
+
|
27
|
+
class Team
|
28
|
+
attr_reader :name
|
29
|
+
|
30
|
+
def initialize(name, members)
|
31
|
+
@name = name
|
32
|
+
@members = members
|
33
|
+
end
|
34
|
+
|
35
|
+
def id
|
36
|
+
@name
|
37
|
+
end
|
38
|
+
|
39
|
+
def member?(actor)
|
40
|
+
@members.include?(actor)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
class TeamActor
|
45
|
+
def initialize(team, actor)
|
46
|
+
@team = team
|
47
|
+
@actor = actor
|
48
|
+
end
|
49
|
+
|
50
|
+
def allowed?
|
51
|
+
@team.member?(@actor)
|
52
|
+
end
|
53
|
+
|
54
|
+
def flipper_id
|
55
|
+
"TeamActor:#{@team.id}:#{@actor.id}"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
jnunemaker = User.new(1)
|
60
|
+
jbarnette = User.new(2)
|
61
|
+
aroben = User.new(3)
|
62
|
+
|
63
|
+
core_app = Team.new(:core_app, [jbarnette, jnunemaker])
|
64
|
+
feature_flags = Team.new(:feature_flags, [aroben, jnunemaker])
|
65
|
+
|
66
|
+
core_nunes = TeamActor.new(core_app, jnunemaker)
|
67
|
+
core_roben = TeamActor.new(core_app, aroben)
|
68
|
+
|
69
|
+
if stats.enabled?(core_nunes)
|
70
|
+
puts "stats are enabled for jnunemaker"
|
71
|
+
else
|
72
|
+
puts "stats are NOT enabled for jnunemaker"
|
73
|
+
end
|
74
|
+
|
75
|
+
if stats.enabled?(core_roben)
|
76
|
+
puts "stats are enabled for aroben"
|
77
|
+
else
|
78
|
+
puts "stats are NOT enabled for aroben"
|
79
|
+
end
|
80
|
+
|
81
|
+
puts "enabling team_actor group"
|
82
|
+
stats.enable_group :team_actor
|
83
|
+
|
84
|
+
if stats.enabled?(core_nunes)
|
85
|
+
puts "stats are enabled for jnunemaker"
|
86
|
+
else
|
87
|
+
puts "stats are NOT enabled for jnunemaker"
|
88
|
+
end
|
89
|
+
|
90
|
+
if stats.enabled?(core_roben)
|
91
|
+
puts "stats are enabled for aroben"
|
92
|
+
else
|
93
|
+
puts "stats are NOT enabled for aroben"
|
94
|
+
end
|
data/lib/flipper/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flipper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Nunemaker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Feature flipper is the act of enabling/disabling features in your application,
|
14
14
|
ideally without re-deploying or changing anything in your code base. Flipper makes
|
@@ -33,6 +33,7 @@ files:
|
|
33
33
|
- examples/dsl.rb
|
34
34
|
- examples/example_setup.rb
|
35
35
|
- examples/group.rb
|
36
|
+
- examples/group_with_members.rb
|
36
37
|
- examples/individual_actor.rb
|
37
38
|
- examples/instrumentation.rb
|
38
39
|
- examples/percentage_of_actors.rb
|