plug 0.1.6 → 0.1.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 25df9b528b96ec6331000a4af562b944d44abb16
4
- data.tar.gz: 0066303fb3632685c4f247d9a04866a9672eca19
3
+ metadata.gz: abca8d64bea6f07000560960f761ef8cf9685ab1
4
+ data.tar.gz: 0f607e0b63a90f7abdba554aac17c97cd240d5e9
5
5
  SHA512:
6
- metadata.gz: 105ecdff267844e970a739005a943f141df9c8eba59c80b5761e8dbfe18322519197a4b9cf744ed575cefa7483a5a839ffad89f53ffe6084f5cdcd663f2a99d9
7
- data.tar.gz: 9bb217a1a8b2390ba74d09679cd5da5ed377ef5b8ecbadf4628c867648d04c7e32324c92d9f90d32defc27473377c2ef07faca69a3c5bb3df724d7ae4f1ab506
6
+ metadata.gz: e7731f594219d50f5134b6a00a668b41af41b2bb80a8b7a5a51cbbf56ae5ccf743eafb8658ebb46cd9cf7350eb7b949ab1833ae7dbbbdfb9fc5209a0103fe19f
7
+ data.tar.gz: 7ffd23598f9f7f70727d344a1693d95632e4a7cd948235046cfdc1c87c23a43f504b86dd93a56334ecd85211fe1c60502911f5d5a2c5f6ffe5a987116333f7e6
data/lib/plug.rb CHANGED
@@ -1,15 +1,23 @@
1
1
  require 'plug/engine'
2
2
  require 'plug/configuration'
3
+ require 'plug/constraint'
3
4
 
4
5
  module Plug
5
6
  extend self
6
7
  extend Configuration
7
8
 
9
+ #
10
+ # [enabled? returns true of false]
11
+ # @param arg [String, Symbol] The slug or name of the Feature
12
+ #
13
+ # @return [Boolean] true - feature found and enabled | true - feature not found (We don't want to block) | false - feature was set to disabled
8
14
  def enabled?(arg)
9
15
  arg = arg.to_s if arg.is_a? Symbol
10
16
  feature = Plug::Feature.slug_and_name(arg).first
11
17
 
12
- return false unless feature
18
+ return true unless feature
13
19
  return feature.enabled?
20
+ rescue
21
+ return true
14
22
  end
15
23
  end
@@ -0,0 +1,13 @@
1
+ module Plug
2
+ class Constraint
3
+ def initialize(feature)
4
+ @feature = feature
5
+ end
6
+
7
+ def matches?(request)
8
+ Plug.enabled?(@feature)
9
+ rescue
10
+ true
11
+ end
12
+ end
13
+ end
data/lib/plug/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Plug
2
- VERSION = '0.1.6'
2
+ VERSION = '0.1.7'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plug
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben
@@ -224,6 +224,7 @@ files:
224
224
  - db/migrate/20171207020316_create_plug_features.rb
225
225
  - lib/plug.rb
226
226
  - lib/plug/configuration.rb
227
+ - lib/plug/constraint.rb
227
228
  - lib/plug/engine.rb
228
229
  - lib/plug/version.rb
229
230
  - lib/tasks/plug_tasks.rake