File: config.rb

package info (click to toggle)
ruby-listen 3.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 544 kB
  • sloc: ruby: 5,033; makefile: 9
file content (31 lines) | stat: -rw-r--r-- 822 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# frozen_string_literal: true

require 'pathname'

module Listen
  module Adapter
    class Config
      attr_reader :directories, :silencer, :queue, :adapter_options

      def initialize(directories, queue, silencer, adapter_options)
        # Default to current directory if no directories are supplied
        directories = [Dir.pwd] if directories.to_a.empty?

        # TODO: fix (flatten, array, compact?)
        @directories = directories.map do |directory|
          Pathname.new(directory.to_s).realpath
        end

        @directories.each do |pathname|
          unless pathname.directory?
            fail ArgumentError, "must be a directory: #{pathname}"
          end
        end

        @silencer = silencer
        @queue = queue
        @adapter_options = adapter_options
      end
    end
  end
end