Sha256: d56f43b2fb8ce9d83a9b94bdf06eab20578ba5f2e637a5413c232ea1726561f9

Contents?: true

Size: 1.71 KB

Versions: 9

Compression:

Stored size: 1.71 KB

Contents

#!/usr/bin/env ruby

require 'gps_pvt/util'
require 'uri'

$stderr.puts <<__STRING__
Usage: #{__FILE__} file_or_URI(s) ...
This utility outputs GNSS data specified with file_or_URI(s).
A file_or_URI having additional ".gz" or ".Z" extension is recognized as a compressed file, and the decompression is performed before output.
In addition to a local file, major URIs such as http(s)://..., ftp://..., and ntrip:// are supported.
Serial port (COMn for Windows, /dev/tty* for *NIX) is also acceptable as an input file name.
__STRING__

options = []

files = ARGV.collect{|arg|
  next arg unless arg =~ /^--([^=]+)=?/
  k, v = [$1.downcase.to_sym, $']
  options << [$1.to_sym, $']
  nil
}.compact

spec2io = proc{|spec, mode_r|
  mode_r = ((nil == mode_r) || mode_r)
  is_stream = false
  if (!(uri = URI::parse(spec)).instance_of?(URI::Generic) rescue false) then
    spec = uri
    is_stream = true if uri.kind_of?(URI::Ntrip)
  else
    is_stream = GPS_PVT::Util::special_stream?(spec)
  end
  if is_stream || (!mode_r) then
    GPS_PVT::Util::open(spec, mode_r ? 'r' : 'a+')
  else
    open(GPS_PVT::Util::get_txt(spec), 'r')
  end
}

STDIN.binmode
STDOUT.binmode
dst, io_dst = proc{|spec| [spec, spec2io.call(spec, false)]}.call('-')

options.reject!{|k, v|
  case k
  when :out
    dst, io_dst = [v, spec2io.call(v, false)]
    next true
  end
  false
}
raise "Unknown option: #{options.first}" unless options.empty?

$stderr.puts "out: #{{'-' => '(stdout)'}[dst] || dst}"
threads = files.collect{|src|
  $stderr.puts "in: #{{'-' => '(stdin)'}[src] || src}"
  io_src = spec2io.call(src)
  Thread.start{
    io_dst.write(io_src.read(128)) until io_src.eof?
  }
}
threads.each{|t| t.join}

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
gps_pvt-0.10.4 exe/gps_get
gps_pvt-0.10.3 exe/gps_get
gps_pvt-0.10.2 exe/gps_get
gps_pvt-0.10.1 exe/gps_get
gps_pvt-0.10.0 exe/gps_get
gps_pvt-0.9.4 exe/gps_get
gps_pvt-0.9.3 exe/gps_get
gps_pvt-0.9.2 exe/gps_get
gps_pvt-0.9.1 exe/gps_get