Skip to content

Commit 755309a

Browse files
committed
plumb Silencer#initialize(options) to configure(options) and update deprecation comments
1 parent 8b17254 commit 755309a

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

lib/listen/silencer.rb

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,23 +57,21 @@ class Silencer
5757
| ~
5858
)$}x.freeze
5959

60+
# TODO: deprecate these mutators; use attr_reader instead
6061
attr_accessor :only_patterns, :ignore_patterns
6162

62-
def initialize
63-
configure({})
63+
def initialize(options = {})
64+
configure(options)
6465
end
6566

67+
# TODO: deprecate this mutator
6668
def configure(options)
6769
@only_patterns = options[:only] ? Array(options[:only]) : nil
6870
@ignore_patterns = _init_ignores(options[:ignore], options[:ignore!])
6971
end
7072

71-
# Note: relative_path is temporarily expected to be a relative Pathname to
72-
# make refactoring easier (ideally, it would take a string)
73-
74-
# TODO: switch type and path places - and verify
7573
def silenced?(relative_path, type)
76-
path = relative_path.to_s
74+
path = relative_path.to_s # in case it is a Pathname
7775

7876
_ignore?(path) || (only_patterns && type == :file && !_only?(path))
7977
end

spec/lib/listen/silencer_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
RSpec.describe Listen::Silencer do
88
let(:options) { {} }
9-
before { subject.configure(options) }
9+
subject { described_class.new(options) }
1010

1111
describe '#silenced?' do
1212
it { should accept(:file, Pathname('some_dir').join("some_file.rb")) }

0 commit comments

Comments
 (0)