flipper 0.10.2 → 0.11.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +42 -0
  3. data/.rubocop_todo.yml +188 -0
  4. data/Changelog.md +10 -0
  5. data/Gemfile +6 -3
  6. data/README.md +4 -3
  7. data/Rakefile +13 -13
  8. data/docs/Adapters.md +2 -1
  9. data/docs/DockerCompose.md +6 -3
  10. data/docs/Gates.md +25 -3
  11. data/docs/Optimization.md +27 -5
  12. data/docs/api/README.md +73 -32
  13. data/docs/http/README.md +34 -0
  14. data/docs/read-only/README.md +22 -0
  15. data/examples/percentage_of_actors_group.rb +49 -0
  16. data/flipper.gemspec +15 -15
  17. data/lib/flipper.rb +2 -5
  18. data/lib/flipper/adapter.rb +10 -0
  19. data/lib/flipper/adapters/http.rb +147 -0
  20. data/lib/flipper/adapters/http/client.rb +83 -0
  21. data/lib/flipper/adapters/http/error.rb +14 -0
  22. data/lib/flipper/adapters/instrumented.rb +36 -36
  23. data/lib/flipper/adapters/memoizable.rb +2 -6
  24. data/lib/flipper/adapters/memory.rb +10 -9
  25. data/lib/flipper/adapters/operation_logger.rb +1 -1
  26. data/lib/flipper/adapters/pstore.rb +12 -11
  27. data/lib/flipper/adapters/read_only.rb +6 -6
  28. data/lib/flipper/dsl.rb +1 -3
  29. data/lib/flipper/feature.rb +11 -16
  30. data/lib/flipper/gate.rb +3 -3
  31. data/lib/flipper/gate_values.rb +6 -6
  32. data/lib/flipper/gates/group.rb +2 -2
  33. data/lib/flipper/gates/percentage_of_actors.rb +2 -2
  34. data/lib/flipper/instrumentation/log_subscriber.rb +2 -4
  35. data/lib/flipper/instrumentation/metriks.rb +1 -1
  36. data/lib/flipper/instrumentation/statsd.rb +1 -1
  37. data/lib/flipper/instrumentation/statsd_subscriber.rb +1 -3
  38. data/lib/flipper/instrumentation/subscriber.rb +11 -10
  39. data/lib/flipper/instrumenters/memory.rb +1 -5
  40. data/lib/flipper/instrumenters/noop.rb +1 -1
  41. data/lib/flipper/middleware/memoizer.rb +11 -27
  42. data/lib/flipper/middleware/setup_env.rb +44 -0
  43. data/lib/flipper/registry.rb +8 -10
  44. data/lib/flipper/spec/shared_adapter_specs.rb +45 -67
  45. data/lib/flipper/test/shared_adapter_test.rb +25 -31
  46. data/lib/flipper/typecast.rb +2 -2
  47. data/lib/flipper/types/actor.rb +2 -4
  48. data/lib/flipper/types/group.rb +1 -1
  49. data/lib/flipper/types/percentage.rb +2 -1
  50. data/lib/flipper/version.rb +1 -1
  51. data/spec/fixtures/feature.json +31 -0
  52. data/spec/flipper/adapters/http_spec.rb +148 -0
  53. data/spec/flipper/adapters/instrumented_spec.rb +20 -20
  54. data/spec/flipper/adapters/memoizable_spec.rb +59 -59
  55. data/spec/flipper/adapters/operation_logger_spec.rb +16 -16
  56. data/spec/flipper/adapters/pstore_spec.rb +6 -6
  57. data/spec/flipper/adapters/read_only_spec.rb +28 -34
  58. data/spec/flipper/dsl_spec.rb +73 -84
  59. data/spec/flipper/feature_check_context_spec.rb +27 -27
  60. data/spec/flipper/feature_spec.rb +186 -196
  61. data/spec/flipper/gate_spec.rb +11 -11
  62. data/spec/flipper/gate_values_spec.rb +46 -45
  63. data/spec/flipper/gates/actor_spec.rb +2 -2
  64. data/spec/flipper/gates/boolean_spec.rb +24 -23
  65. data/spec/flipper/gates/group_spec.rb +19 -19
  66. data/spec/flipper/gates/percentage_of_actors_spec.rb +10 -10
  67. data/spec/flipper/gates/percentage_of_time_spec.rb +2 -2
  68. data/spec/flipper/instrumentation/log_subscriber_spec.rb +20 -20
  69. data/spec/flipper/instrumentation/metriks_subscriber_spec.rb +20 -20
  70. data/spec/flipper/instrumentation/statsd_subscriber_spec.rb +11 -11
  71. data/spec/flipper/instrumenters/memory_spec.rb +5 -5
  72. data/spec/flipper/instrumenters/noop_spec.rb +6 -6
  73. data/spec/flipper/middleware/memoizer_spec.rb +83 -100
  74. data/spec/flipper/middleware/setup_env_spec.rb +76 -0
  75. data/spec/flipper/registry_spec.rb +35 -39
  76. data/spec/flipper/typecast_spec.rb +18 -18
  77. data/spec/flipper/types/actor_spec.rb +30 -29
  78. data/spec/flipper/types/boolean_spec.rb +8 -8
  79. data/spec/flipper/types/group_spec.rb +28 -28
  80. data/spec/flipper/types/percentage_spec.rb +14 -14
  81. data/spec/flipper_spec.rb +61 -54
  82. data/spec/helper.rb +26 -21
  83. data/spec/integration_spec.rb +121 -113
  84. data/spec/support/fake_udp_socket.rb +1 -1
  85. data/spec/support/spec_helpers.rb +32 -4
  86. data/test/adapters/pstore_test.rb +3 -3
  87. data/test/test_helper.rb +1 -1
  88. metadata +20 -5
@@ -5,7 +5,7 @@ class FakeUDPSocket
5
5
  @buffer = []
6
6
  end
7
7
 
8
- def send(message, *rest)
8
+ def send(message, *_rest)
9
9
  @buffer.push [message]
10
10
  end
11
11
 
@@ -9,9 +9,9 @@ module SpecHelpers
9
9
  end
10
10
 
11
11
  def build_app(flipper)
12
- Flipper::UI.app(flipper) { |builder|
13
- builder.use Rack::Session::Cookie, secret: "test"
14
- }
12
+ Flipper::UI.app(flipper) do |builder|
13
+ builder.use Rack::Session::Cookie, secret: 'test'
14
+ end
15
15
  end
16
16
 
17
17
  def build_api(flipper)
@@ -27,7 +27,35 @@ module SpecHelpers
27
27
  end
28
28
 
29
29
  def json_response
30
- JSON.load(last_response.body)
30
+ JSON.parse(last_response.body)
31
+ end
32
+
33
+ def api_error_code_reference_url
34
+ 'https://github.com/jnunemaker/flipper/tree/master/docs/api#error-code-reference'
35
+ end
36
+
37
+ def api_not_found_response
38
+ {
39
+ 'code' => 1,
40
+ 'message' => 'Feature not found.',
41
+ 'more_info' => api_error_code_reference_url,
42
+ }
43
+ end
44
+
45
+ def api_flipper_id_is_missing_response
46
+ {
47
+ 'code' => 4,
48
+ 'message' => 'Required parameter flipper_id is missing.',
49
+ 'more_info' => api_error_code_reference_url,
50
+ }
51
+ end
52
+
53
+ def api_positive_percentage_error_response
54
+ {
55
+ 'code' => 3,
56
+ 'message' => 'Percentage must be a positive number less than or equal to 100.',
57
+ 'more_info' => api_error_code_reference_url,
58
+ }
31
59
  end
32
60
  end
33
61
 
@@ -5,13 +5,13 @@ class PstoreTest < MiniTest::Test
5
5
  prepend Flipper::Test::SharedAdapterTests
6
6
 
7
7
  def setup
8
- dir = FlipperRoot.join("tmp").tap { |d| d.mkpath }
9
- pstore_file = dir.join("flipper.pstore")
8
+ dir = FlipperRoot.join('tmp').tap(&:mkpath)
9
+ pstore_file = dir.join('flipper.pstore')
10
10
  pstore_file.unlink if pstore_file.exist?
11
11
  @adapter = Flipper::Adapters::PStore.new(pstore_file)
12
12
  end
13
13
 
14
14
  def test_defaults_path_to_flipper_pstore
15
- assert_equal Flipper::Adapters::PStore.new.path, "flipper.pstore"
15
+ assert_equal Flipper::Adapters::PStore.new.path, 'flipper.pstore'
16
16
  end
17
17
  end
@@ -1,6 +1,6 @@
1
1
  require 'flipper'
2
2
  require 'minitest/autorun'
3
3
  require 'minitest/unit'
4
- Dir["./lib/flipper/test/*.rb"].each { |f| require(f) }
4
+ Dir['./lib/flipper/test/*.rb'].each { |f| require(f) }
5
5
 
6
6
  FlipperRoot = Pathname(__FILE__).dirname.join('..').expand_path
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.10.2
4
+ version: 0.11.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Nunemaker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-08 00:00:00.000000000 Z
11
+ date: 2017-04-02 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
@@ -19,6 +19,8 @@ executables: []
19
19
  extensions: []
20
20
  extra_rdoc_files: []
21
21
  files:
22
+ - ".rubocop.yml"
23
+ - ".rubocop_todo.yml"
22
24
  - Changelog.md
23
25
  - Dockerfile
24
26
  - Gemfile
@@ -33,6 +35,8 @@ files:
33
35
  - docs/Instrumentation.md
34
36
  - docs/Optimization.md
35
37
  - docs/api/README.md
38
+ - docs/http/README.md
39
+ - docs/read-only/README.md
36
40
  - examples/basic.rb
37
41
  - examples/dsl.rb
38
42
  - examples/enabled_for_actor.rb
@@ -44,10 +48,14 @@ files:
44
48
  - examples/instrumentation.rb
45
49
  - examples/percentage_of_actors.rb
46
50
  - examples/percentage_of_actors_enabled_check.rb
51
+ - examples/percentage_of_actors_group.rb
47
52
  - examples/percentage_of_time.rb
48
53
  - flipper.gemspec
49
54
  - lib/flipper.rb
50
55
  - lib/flipper/adapter.rb
56
+ - lib/flipper/adapters/http.rb
57
+ - lib/flipper/adapters/http/client.rb
58
+ - lib/flipper/adapters/http/error.rb
51
59
  - lib/flipper/adapters/instrumented.rb
52
60
  - lib/flipper/adapters/memoizable.rb
53
61
  - lib/flipper/adapters/memory.rb
@@ -74,6 +82,7 @@ files:
74
82
  - lib/flipper/instrumenters/memory.rb
75
83
  - lib/flipper/instrumenters/noop.rb
76
84
  - lib/flipper/middleware/memoizer.rb
85
+ - lib/flipper/middleware/setup_env.rb
77
86
  - lib/flipper/registry.rb
78
87
  - lib/flipper/spec/shared_adapter_specs.rb
79
88
  - lib/flipper/test/shared_adapter_test.rb
@@ -86,6 +95,8 @@ files:
86
95
  - lib/flipper/types/percentage_of_actors.rb
87
96
  - lib/flipper/types/percentage_of_time.rb
88
97
  - lib/flipper/version.rb
98
+ - spec/fixtures/feature.json
99
+ - spec/flipper/adapters/http_spec.rb
89
100
  - spec/flipper/adapters/instrumented_spec.rb
90
101
  - spec/flipper/adapters/memoizable_spec.rb
91
102
  - spec/flipper/adapters/memory_spec.rb
@@ -108,6 +119,7 @@ files:
108
119
  - spec/flipper/instrumenters/memory_spec.rb
109
120
  - spec/flipper/instrumenters/noop_spec.rb
110
121
  - spec/flipper/middleware/memoizer_spec.rb
122
+ - spec/flipper/middleware/setup_env_spec.rb
111
123
  - spec/flipper/registry_spec.rb
112
124
  - spec/flipper/typecast_spec.rb
113
125
  - spec/flipper/types/actor_spec.rb
@@ -140,16 +152,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
140
152
  version: '0'
141
153
  required_rubygems_version: !ruby/object:Gem::Requirement
142
154
  requirements:
143
- - - ">="
155
+ - - ">"
144
156
  - !ruby/object:Gem::Version
145
- version: '0'
157
+ version: 1.3.1
146
158
  requirements: []
147
159
  rubyforge_project:
148
- rubygems_version: 2.4.5.1
160
+ rubygems_version: 2.5.2
149
161
  signing_key:
150
162
  specification_version: 4
151
163
  summary: Feature flipper for ANYTHING
152
164
  test_files:
165
+ - spec/fixtures/feature.json
166
+ - spec/flipper/adapters/http_spec.rb
153
167
  - spec/flipper/adapters/instrumented_spec.rb
154
168
  - spec/flipper/adapters/memoizable_spec.rb
155
169
  - spec/flipper/adapters/memory_spec.rb
@@ -172,6 +186,7 @@ test_files:
172
186
  - spec/flipper/instrumenters/memory_spec.rb
173
187
  - spec/flipper/instrumenters/noop_spec.rb
174
188
  - spec/flipper/middleware/memoizer_spec.rb
189
+ - spec/flipper/middleware/setup_env_spec.rb
175
190
  - spec/flipper/registry_spec.rb
176
191
  - spec/flipper/typecast_spec.rb
177
192
  - spec/flipper/types/actor_spec.rb