Sha256: df249a4ad518c2e9f864a5104e97251bfcd447ffa0500e9d50ed6d98633ae3da

Contents?: true

Size: 742 Bytes

Versions: 2

Compression:

Stored size: 742 Bytes

Contents

require "ostruct"

module Fontist
  module Helpers
    def self.parse_to_object(data)
      JSON.parse(data.to_json, object_class: OpenStruct)
    end

    def self.run(command)
      Fontist.ui.debug("Run `#{command}`")

      result = `#{command}`
      unless $CHILD_STATUS.to_i.zero?
        raise Errors::BinaryCallError,
              "Failed to run #{command}, status: #{$CHILD_STATUS}"
      end

      result
    end

    def self.silence_stream(stream)
      old_stream = stream.dup
      stream.reopen(RbConfig::CONFIG["host_os"] =~ /mswin|mingw/ ? "NUL:" : "/dev/null") # rubocop:disable Performance/RegexpMatch, Metrics/LineLength
      stream.sync = true
      yield
    ensure
      stream.reopen(old_stream)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fontist-1.21.2 lib/fontist/helpers.rb
fontist-1.21.1 lib/fontist/helpers.rb