pr2gpx 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.md +7 -0
  2. data/lib/pr2gpx.rb +15 -10
  3. data/lib/pr2gpx/options.rb +6 -4
  4. metadata +1 -1
data/README.md CHANGED
@@ -18,6 +18,8 @@ The output is either one track for each station, a list of waypoints for every p
18
18
 
19
19
  The results can either be saved into a single file containing everything, or it can be split into one file for each station.
20
20
 
21
+ If no input path is given, pr2gpx reads from STDIN. If no output path is given, pr2gpx writes to STDOUT.
22
+
21
23
 
22
24
  Installing
23
25
  ----------
@@ -52,6 +54,11 @@ Writes the most recent position report of CALL1, CALL2 and CALL3 into positions.
52
54
  Writes the 10 most recent position reports of CALL1, CALL2 and CALL3 into PR_CALL1.gpx, PR_CALL2.gpx and PR_CALL3.gpx in C:\ProgramData\opencpn\layers.
53
55
 
54
56
 
57
+ curl http://www.winlink.org/dotnet/maps/RSSPositionReports.aspx?callsign=CALL1 | pr2gpx --last 5 --output C:\ProgramData\opencpn\layers --split
58
+
59
+ Downloads the data for CALL1 from Winlink and writes the 5 most recent position reports into PR_CALL1.gpx in C:\ProgramData\opencpn\layers.
60
+
61
+
55
62
  Developing
56
63
  ----------
57
64
 
@@ -75,21 +75,26 @@ if errors
75
75
  exit
76
76
  end
77
77
 
78
- # normalize path separators
79
- options[:input].gsub!('\\', '/')
80
- options[:output].gsub!('\\', '/') if options[:output]
81
-
82
78
  filter = ReportFilter.new options[:callsign]
83
79
 
84
- search_path = if File.directory?(options[:input])
85
- "#{options[:input]}/#{options[:recurse] ? '**/' : ''}*.*"
80
+ stations = if options[:input]
81
+ # normalize path separators
82
+ options[:input].gsub!('\\', '/')
83
+ options[:output].gsub!('\\', '/') if options[:output]
84
+
85
+ search_path = if File.directory?(options[:input])
86
+ "#{options[:input]}/#{options[:recurse] ? '**/' : ''}*.*"
87
+ else
88
+ options[:input]
89
+ end
90
+
91
+ $stderr.puts "Searching #{search_path}" if $verbose
92
+
93
+ load_data(enumerate_files(search_path), filter)
86
94
  else
87
- options[:input]
95
+ load_data([$stdin.read()], filter)
88
96
  end
89
97
 
90
- $stderr.puts "Searching #{search_path}" if $verbose
91
-
92
- stations = load_data(enumerate_files(search_path), filter)
93
98
  filter_data! stations, options[:last]
94
99
 
95
100
  if options[:split] # create one document for each station
@@ -3,7 +3,7 @@ require 'optparse'
3
3
  # If options are valid, returns a hash of options, otherwise nil.
4
4
  def parse_options argv
5
5
  options = {}
6
- mandatory = [:input]
6
+ mandatory = []
7
7
 
8
8
  def set_option options, name
9
9
  ->(options, name, value) { options[name] = value }.curry.(options, name)
@@ -11,7 +11,7 @@ def parse_options argv
11
11
 
12
12
  OptionParser.new do |o|
13
13
  options[:input] = nil
14
- o.on '-i', '--input PATH',
14
+ o.on '-i', '--input [PATH]',
15
15
  'Specifies the path to be searched for files containing position reports.',
16
16
  set_option(options, :input)
17
17
 
@@ -102,8 +102,10 @@ end
102
102
  def validate_options options
103
103
  errors = []
104
104
 
105
- if not File.exists?(options[:input])
106
- errors << 'Path specified in --input does not exist.'
105
+ if options[:input]
106
+ if not File.exists?(options[:input])
107
+ errors << 'Path specified in --input does not exist.'
108
+ end
107
109
  end
108
110
 
109
111
  if options[:split]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pr2gpx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: