treefell 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/treefell/filters/env_filter.rb +11 -4
- data/lib/treefell/version.rb +1 -1
- data/lib/treefell.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea76363254edab4bb829968b2c0fb9d2dc90fde6
|
4
|
+
data.tar.gz: 74e9362162ccda25940714e018b09f2f4edd9fb6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42bb9c5006d8b891d60239a9ab0f52221b7fd2de543be7815978fd074d9b220a748b643371c3235b9bbc50360958e7f9c6450728f7c49ac10b1d4b286444d0d6
|
7
|
+
data.tar.gz: f9779ffb54792922170e4af30c8f4edbe160255f9c75732b99657fc16fc9da9bccfb991310f9ca9768638c34ef0fc58ca51a1e3e38fb6ff273914cfa3eb7b259
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module Treefell
|
2
2
|
module Filters
|
3
3
|
class EnvFilter
|
4
|
+
WILDCARD = '*'
|
5
|
+
|
4
6
|
attr_reader :var_name
|
5
7
|
|
6
8
|
def initialize(var_name:)
|
@@ -8,8 +10,9 @@ module Treefell
|
|
8
10
|
end
|
9
11
|
|
10
12
|
def call(namespace, message)
|
11
|
-
|
12
|
-
|
13
|
+
value = ENV[@var_name]
|
14
|
+
is_mentioned?(namespace)
|
15
|
+
is_mentioned?(namespace) || is_mentioned?(WILDCARD)
|
13
16
|
end
|
14
17
|
|
15
18
|
def ==(other)
|
@@ -19,8 +22,12 @@ module Treefell
|
|
19
22
|
|
20
23
|
private
|
21
24
|
|
22
|
-
def
|
23
|
-
ENV[@var_name]
|
25
|
+
def var_value
|
26
|
+
@var_value ||= ENV[@var_name]
|
27
|
+
end
|
28
|
+
|
29
|
+
def is_mentioned?(str)
|
30
|
+
var_value.to_s.split(/\s*,\s*/).include?(str)
|
24
31
|
end
|
25
32
|
end
|
26
33
|
end
|
data/lib/treefell/version.rb
CHANGED
data/lib/treefell.rb
CHANGED
@@ -15,11 +15,11 @@ module Treefell
|
|
15
15
|
@env_var || DEFAULT_ENV_VAR
|
16
16
|
end
|
17
17
|
|
18
|
-
def self.debug(namespace=nil, io: $stdout)
|
18
|
+
def self.debug(namespace=nil, io: $stdout, filter: nil)
|
19
19
|
DebugLogger.new(
|
20
20
|
namespace: namespace,
|
21
21
|
io: io,
|
22
|
-
filter: Filters::EnvFilter.new(var_name: env_var)
|
22
|
+
filter: (filter || Filters::EnvFilter.new(var_name: env_var))
|
23
23
|
)
|
24
24
|
end
|
25
25
|
end
|