Sha256: acf8d09079c8875570a3405d781a41e68bf38e622eaec84a689dd52b8ec6cf1d
Contents?: true
Size: 848 Bytes
Versions: 2
Compression:
Stored size: 848 Bytes
Contents
require 'open-uri' require 'tempfile' require 'uri' require 'zlib' module GPS_PVT module Util class << self def inflate(src) Zlib::GzipReader.send(*(src.kind_of?(IO) ? [:new, src] : [:open, src])) end def get_txt(fname_or_uri) is_uri = fname_or_uri.kind_of?(URI) ((is_uri && (RUBY_VERSION >= "2.5.0")) ? URI : Kernel) \ .send(:open, fname_or_uri){|src| is_gz = (src.content_type =~ /gzip/) if is_uri is_gz ||= (fname_or_uri.to_s =~ /\.gz$/) is_file = src.kind_of?(File) || src.kind_of?(Tempfile) return src.path if ((!is_gz) and is_file) Tempfile::open(File::basename($0, '.*')){|dst| dst.binmode dst.write((is_gz ? inflate(is_file ? src.path : src) : src).read) dst.rewind dst.path } } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gps_pvt-0.5.1 | lib/gps_pvt/util.rb |
gps_pvt-0.5.0 | lib/gps_pvt/util.rb |