Module: Lug::Helpers
- Defined in:
- lib/lug/logger.rb
Class Method Summary collapse
-
.device_from(io) ⇒ Device
Create a Device instance from an
io
. -
.parse_namespace_filter(filter) ⇒ Array<Regexp>
Parse a namespace
filter
string and build a list of Regexp filters.
Class Method Details
.device_from(io) ⇒ Device
Create a Device instance from an io
306 307 308 |
# File 'lib/lug/logger.rb', line 306 def self.device_from(io) io.isatty ? TtyDevice.new(io) : Device.new(io) end |
.parse_namespace_filter(filter) ⇒ Array<Regexp>
Parse a namespace filter
string and build a list of Regexp filters
315 316 317 318 319 320 321 322 323 |
# File 'lib/lug/logger.rb', line 315 def self.parse_namespace_filter(filter) res = [] filter.split(/[\s,]+/).each do |ns| next if ns.empty? ns = ns.gsub('*'.freeze, '.*?'.freeze) res << /^#{ns}$/ end res end |