module Octodown
  module Support
    module Services
      class Riposter
        def self.call(file, &listener_callback)
          require 'listen'

          path = File.dirname(File.expand_path(file.path))
          regex = Regexp.new(file.path)

          @listener ||= Listen.to(path, only: regex) do
            listener_callback.call
          end

          @listener.start
        end
      end
    end
  end
end

module Octodown
  module Support
    module Services
      class Riposter
        def self.call(file, &listener_callback)
          require 'listen'

          path = File.dirname(File.expand_path(file.path))
          regex = Regexp.new("^#{File.basename(file.path)}$")

          @listener ||= Listen.to(path, only: regex) do
            listener_callback.call
          end

          @listener.start
        end
      end
    end
  end
end

Fix regex from listen :only
Fix regex from listen :only

The readme from listen warns about this:
Note: :only regexp patterns are evaluated only against relative file paths.

This was causing funky behaviour. Forcing unecessary updates if files
that share the same name were present under the same directory tree.

This also caused octodown to ignore changes if used with files outside
the directory octodown is run.
