Sha256: 16cda514fb3622642c07cef545775cbd7fe3f718a352ca01676ee8ce2cc07295

Contents?: true

Size: 646 Bytes

Versions: 10

Compression:

Stored size: 646 Bytes

Contents

# frozen_string_literal: true

module CodeKindly
  module Utils
    class Command
      include Presence

      class << self
        def run(command)
          new(command).run
        end
      end

      attr_reader :command

      def initialize(command)
        @command = command
      end

      def run
        require 'open3'
        command = @command
        command.join(' ') if command.is_a?(Array)
        @std_in, @std_out, @std_err = Open3.capture3(command)
        self
      end

      def result
        return nil if blank? @std_out
        @std_out.chomp!
        blank? @std_out ? nil : @std_out
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
codekindly-utils-0.1.0 lib/code_kindly/utils/command.rb
codekindly-utils-0.0.14 lib/code_kindly/utils/command.rb
codekindly-utils-0.0.13 lib/code_kindly/utils/command.rb
codekindly-utils-0.0.12 lib/code_kindly/utils/command.rb
codekindly-utils-0.0.11 lib/code_kindly/utils/command.rb
codekindly-utils-0.0.10 lib/code_kindly/utils/command.rb
codekindly-utils-0.0.9 lib/code_kindly/utils/command.rb
codekindly-utils-0.0.8 lib/code_kindly/utils/command.rb
codekindly-utils-0.0.7 lib/code_kindly/utils/command.rb
codekindly-utils-0.0.6 lib/code_kindly/utils/command.rb