treefell 0.2.1 → 0.2.2
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 +7 -11
- data/lib/treefell/version.rb +1 -1
- data/lib/treefell.rb +14 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b320702819874e40877795f4d957ea40005f1d5
|
4
|
+
data.tar.gz: f1465485137b21ef81b966d8f52445e8d061e3eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb745fcba0d098d68bc6178c0463efcdc1587b716571b4b78759e07c0cdcb62456e27123dfd773c97cc3b73ed1ccfd5fdbe6e9c1cd90edabb847dec13cfd9b3a
|
7
|
+
data.tar.gz: 037a0b798d1ec0274683282ad90127b440b0ef672201bb4354ad00cd428707922d9f46366485a17fd0b89813bd0ff0086d605de72904c941a89299f70544b126
|
@@ -1,33 +1,29 @@
|
|
1
1
|
module Treefell
|
2
2
|
module Filters
|
3
3
|
class EnvFilter
|
4
|
+
ENV_VAR_KEY = 'DEBUG'
|
5
|
+
ENV_VAR_LOOKUP = -> { ENV[ENV_VAR_KEY] }
|
4
6
|
WILDCARD = '*'
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
def initialize(var_name:)
|
9
|
-
@var_name = var_name
|
8
|
+
def initialize(value: ENV_VAR_LOOKUP)
|
9
|
+
@value_proc = value
|
10
10
|
end
|
11
11
|
|
12
12
|
def call(namespace, message)
|
13
|
-
value =
|
13
|
+
@value = @value_proc.call
|
14
14
|
is_mentioned?(namespace)
|
15
15
|
is_mentioned?(namespace) || is_mentioned?(WILDCARD)
|
16
16
|
end
|
17
17
|
|
18
18
|
def ==(other)
|
19
19
|
other.is_a?(self.class) &&
|
20
|
-
other.
|
20
|
+
other.instance_variable_get(:@value_proc) == @value_proc
|
21
21
|
end
|
22
22
|
|
23
23
|
private
|
24
24
|
|
25
|
-
def var_value
|
26
|
-
@var_value ||= ENV[@var_name]
|
27
|
-
end
|
28
|
-
|
29
25
|
def is_mentioned?(str)
|
30
|
-
|
26
|
+
@value.to_s.split(/\s*,\s*/).include?(str)
|
31
27
|
end
|
32
28
|
end
|
33
29
|
end
|
data/lib/treefell/version.rb
CHANGED
data/lib/treefell.rb
CHANGED
@@ -5,21 +5,31 @@ require 'treefell/debug_logger'
|
|
5
5
|
require 'treefell/filters/env_filter'
|
6
6
|
|
7
7
|
module Treefell
|
8
|
-
|
8
|
+
ENV_VAR_LOOKUP = -> { ENV[Treefell.env_var] }
|
9
9
|
|
10
10
|
def self.env_var=(env_var)
|
11
11
|
@env_var = env_var
|
12
12
|
end
|
13
13
|
|
14
14
|
def self.env_var
|
15
|
-
@env_var ||
|
15
|
+
@env_var || Treefell::EnvFilter::ENV_VAR_KEY
|
16
16
|
end
|
17
17
|
|
18
18
|
def self.debug(namespace=nil, io: $stdout, filter: nil)
|
19
|
-
|
19
|
+
filter ||= Filters::EnvFilter.new(value: ENV_VAR_LOOKUP)
|
20
|
+
@debug_loggers ||= {}
|
21
|
+
@debug_loggers[namespace] ||= DebugLogger.new(
|
20
22
|
namespace: namespace,
|
21
23
|
io: io,
|
22
|
-
filter:
|
24
|
+
filter: filter
|
23
25
|
)
|
24
26
|
end
|
27
|
+
|
28
|
+
def self.reset
|
29
|
+
@debug_loggers.clear
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.[](namespace)
|
33
|
+
debug(namespace)
|
34
|
+
end
|
25
35
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: treefell
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zach Dennis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: term-ansicolor
|