Sha256: 8eb88a55843dc7d0e0d9a2a264562be291f37d8bb20682be6f89585f7b12a55b
Contents?: true
Size: 1.06 KB
Versions: 1
Compression:
Stored size: 1.06 KB
Contents
# frozen_string_literal: true module Libexec module Exec def run(cmd) # https://docs.ruby-lang.org/en/master/IO.html#method-c-popen IO.popen(cmd) do |pipe| print pipe.gets until pipe.eof? end nil end def each_line(cmd, &block) # https://docs.ruby-lang.org/en/master/IO.html#method-i-each_line IO.popen(cmd) do |pipe| pipe.each_line(&block) end end def by_ls_1(dir) arr = [] each_line("ls -1 #{dir}") do |line| arr.push line.chomp end arr end def each_ls_1(dir, &block) each_line("ls -1 #{dir}", &block) end def code(cmd, *opt, **args) catch_error = opt.nil? || args[:catch_error] || false code = opt[0] || args[:code] # https://docs.ruby-lang.org/en/master/Kernel.html#method-i-system result = system cmd exit code if catch_error && !result result end def output(cmd) # https://docs.ruby-lang.org/en/master/Kernel.html#method-i-60 output = `#{cmd}` output.chomp end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
libexec-0.1.1 | lib/libexec/exec.rb |