Sha256: 1639928913b1b78c31003c4ee2f3e4418799afcb64903e5a52f7711d0e9645d3

Contents?: true

Size: 723 Bytes

Versions: 16

Compression:

Stored size: 723 Bytes

Contents

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

16 entries across 16 versions & 1 rubygems

Version Path
fontist-1.20.0 lib/fontist/helpers.rb
fontist-1.19.0 lib/fontist/helpers.rb
fontist-1.18.2 lib/fontist/helpers.rb
fontist-1.17.1 lib/fontist/helpers.rb
fontist-1.17.0 lib/fontist/helpers.rb
fontist-1.16.0 lib/fontist/helpers.rb
fontist-1.15.2 lib/fontist/helpers.rb
fontist-1.15.1 lib/fontist/helpers.rb
fontist-1.15.0 lib/fontist/helpers.rb
fontist-1.14.6 lib/fontist/helpers.rb
fontist-1.14.5 lib/fontist/helpers.rb
fontist-1.14.4 lib/fontist/helpers.rb
fontist-1.14.3 lib/fontist/helpers.rb
fontist-1.14.2 lib/fontist/helpers.rb
fontist-1.14.1 lib/fontist/helpers.rb
fontist-1.14.0 lib/fontist/helpers.rb