Sha256: 141bb60c3a30c5885eda7409d692629a8fca8582008fe228f43142bbad6c6962

Contents?: true

Size: 692 Bytes

Versions: 1

Compression:

Stored size: 692 Bytes

Contents

module LearnOpen
  module Adapters
    class SystemAdapter
      def self.open_editor(editor, path:)
        system("#{editor} .")
      end

      def self.open_login_shell(shell)
        exec("#{shell} -l")
      end

      def self.watch_dir(dir, action)
        spawn("while inotifywait -qre create,delete,move,close_write #{dir}; do #{action}; done")
      end

      def self.spawn(command, block: false)
        pid = Process.spawn(command, [:out, :err] => File::NULL)
        Process.waitpid(pid) if block
      end

      def self.run_command(command)
        system(command)
      end

      def self.change_context_directory(dir)
        Dir.chdir(dir)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
learn-open-1.2.21 lib/learn_open/adapters/system_adapter.rb