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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5745e3caccbe0ff653e2c344026449e89f25b9a8
4
- data.tar.gz: d1a56ec23c658d3667861fff6cc6e68f0536a9b9
3
+ metadata.gz: ea76363254edab4bb829968b2c0fb9d2dc90fde6
4
+ data.tar.gz: 74e9362162ccda25940714e018b09f2f4edd9fb6
5
5
  SHA512:
6
- metadata.gz: e651ebdc9de8a59613b497d1d1f30acc7ffa1718ce37248454b8e9c3f434c4479f08e33a367842bc2efb396a4f19c7e0eeedb49ecaa81fcfd2d8f306f7b7d496
7
- data.tar.gz: 1f947d9dd519d4d7898ca603cafb1090d35ac81c182bbdbc0c85d70b636de6d6708fcf7819884cdfaa75eecc2c168ebad33131dc38d9dad4e7925f60c626dbc3
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
- return true if is_namespace_mentioned_in_env_var?(namespace)
12
- false
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 is_namespace_mentioned_in_env_var?(namespace)
23
- ENV[@var_name].to_s.split(/\s*,\s*/).include?(namespace)
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
@@ -1,3 +1,3 @@
1
1
  module Treefell
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: treefell
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zach Dennis