argos-ruby 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/bin/argos-ruby +12 -2
- data/lib/argos/command.rb +0 -42
- data/lib/argos/diag.rb +24 -7
- data/lib/argos/ds.rb +1 -1
- data/lib/argos.rb +2 -2
- data/spec/argos/_diag/Prog_header.ds +52 -0
- data/spec/argos/diag_spec.rb +10 -1
- data/spec/argos/ds_spec.rb +2 -2
- data/spec/argos_spec.rb +2 -2
- metadata +6 -9
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MDNkNTlmYzhjMjk2YzhlNGMzNjVjNDY3NDM5MjZjNzE4YzYwMzMxZA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MzVlNThiZTM1NzUxMTQ1ODQwMDZiNjU2NGFjYzIwMDY4MDRjZTIyMA==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
Zjc1OWM3ZjE1MmI3ZDZiMzIyYThkMzYwODZhZTMxNjM3MWRiMTQ0MTY4YTFh
|
10
|
+
YzU1YTY0NzZjNmE1YmQxYTgwOGZlMWM5YTgwNTczZjJmNGIzODkxOGI0NmNl
|
11
|
+
ODk3ZTAwY2FhNGZkMTA1YjFkMDdlMGM4ZmY5MjY5ZjYyMmJlZjI=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NmY0NDdmM2NmYzc2ODdjNjQwZmQ1NzQ4N2M3YzBhYTg2YTMwZWVmMzg3MDNm
|
14
|
+
ODNlNDJlNTRiNTY3YzM2ZmI0YmM5NTFkODEzODJjMjk1MjRmN2ZhYWRlMDg3
|
15
|
+
OGE5M2M3MGE1MDFiYjY0MDM5NjYyYjg0ZTcxNTNiM2E2Zjk5NDE=
|
data/bin/argos-ruby
CHANGED
@@ -5,6 +5,7 @@
|
|
5
5
|
require_relative "../lib/argos"
|
6
6
|
require "optparse"
|
7
7
|
require "yaml"
|
8
|
+
require "fileutils"
|
8
9
|
|
9
10
|
param = { format: "json",
|
10
11
|
action: "parse",
|
@@ -93,8 +94,9 @@ Dir[glob].reject {|f| File.directory? f}.select {|f|
|
|
93
94
|
argos.log = log
|
94
95
|
|
95
96
|
case param[:action]
|
96
|
-
when "source"
|
97
|
+
when "source","metadata"
|
97
98
|
result << Argos.source(argos).merge(glob: glob, bundle: bundle)
|
99
|
+
|
98
100
|
when "parse"
|
99
101
|
|
100
102
|
arr = argos.parse(filename)
|
@@ -119,13 +121,21 @@ if ["parse", "messages"].include? param[:action]
|
|
119
121
|
log.info "Documents: #{result.size}, ds: #{ds_count}, diag: #{diag_count}, bundle: #{bundle}, glob: #{glob}"
|
120
122
|
|
121
123
|
|
122
|
-
elsif
|
124
|
+
elsif /source|metadata/ =~ param[:action]
|
125
|
+
# Count the total number of files in the bundle
|
123
126
|
result = result.select {|s| s[:size] > 0 }
|
124
127
|
sum_count = result.map {|s| s[:size]}.inject { |sum, c| sum + c }
|
125
128
|
result = result.map {|s|
|
126
129
|
s[:total] = sum_count
|
127
130
|
s
|
128
131
|
}
|
132
|
+
unless param[:dest].nil?
|
133
|
+
jsonfile = "#{param[:dest].gsub(/\$/, "")}/bundle-#{bundle}-metadata.json"
|
134
|
+
FileUtils.mkpath(File.dirname(jsonfile))
|
135
|
+
log.debug "Argos bundle metadata: #{jsonfile}"
|
136
|
+
File.open(jsonfile, "w") { |file| file.write(result.to_json) }
|
137
|
+
|
138
|
+
end
|
129
139
|
if argosfiles != result.size
|
130
140
|
log.warn "Argos file count: #{argosfiles} differs from parsed files: #{result.size}"
|
131
141
|
end
|
data/lib/argos/command.rb
CHANGED
@@ -16,49 +16,7 @@ module Argos
|
|
16
16
|
@param = PARAM_DEFAULT
|
17
17
|
end
|
18
18
|
|
19
|
-
def param(argv=ARGV)
|
20
|
-
optparser = OptionParser.new(ARGV) do |opts|
|
21
19
|
|
22
|
-
opts.banner = "argos-ruby [OPTIONS] {filename|glob}
|
23
|
-
For more information and source: https://github.com/npolar/argos-ruby
|
24
|
-
|
25
|
-
Options:\n
|
26
|
-
"
|
27
|
-
|
28
|
-
opts.on_tail("--version", "-v", "Library version") do
|
29
|
-
puts Argos.library_version
|
30
|
-
exit
|
31
|
-
end
|
32
|
-
|
33
|
-
opts.on("--action=ACTION", "-a", "Action") do |action|
|
34
|
-
param[:action] = action
|
35
|
-
end
|
36
|
-
|
37
|
-
opts.on("--filter=FILTER", "-f", "Filter") do |filter|
|
38
|
-
param[:filter] = filter
|
39
|
-
end
|
40
|
-
|
41
|
-
opts.on("--level=LEVEL", "-l=LEVEL", "Log level") do |level|
|
42
|
-
|
43
|
-
param[:level] = case level
|
44
|
-
when /debug|0/i
|
45
|
-
Logger::DEBUG
|
46
|
-
when /info|1/i
|
47
|
-
Logger::INFO
|
48
|
-
when /warn|2/i
|
49
|
-
Logger::WARN
|
50
|
-
when /error|3/i
|
51
|
-
Logger::ERROR
|
52
|
-
when /fatal|4/i
|
53
|
-
Logger::FATAL
|
54
|
-
else
|
55
|
-
param[:level]
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
60
|
-
optparser.parse!
|
61
|
-
end
|
62
20
|
|
63
21
|
end
|
64
22
|
end
|
data/lib/argos/diag.rb
CHANGED
@@ -21,7 +21,7 @@ module Argos
|
|
21
21
|
|
22
22
|
attr_reader :bundle, :filename, :filter, :filtername, :sha1, :valid, :filesize, :updated, :multiplicates, :errors
|
23
23
|
|
24
|
-
START_REGEX =
|
24
|
+
START_REGEX = /^(\s*Prog\s\d{4,}|\s*\d{5,6}\s+Date : \d{2}.\d{2}.\d{2} \d{2}:\d{2}:\d{2})/
|
25
25
|
$start_diag ='^\s*\d{5,6}\s+Date : \d{2}.\d{2}.\d{2} \d{2}:\d{2}:\d{2}'
|
26
26
|
|
27
27
|
# Diag format 1
|
@@ -54,7 +54,8 @@ module Argos
|
|
54
54
|
|
55
55
|
|
56
56
|
def initialize
|
57
|
-
@errors = []
|
57
|
+
@errors = []
|
58
|
+
@programs = []
|
58
59
|
end
|
59
60
|
|
60
61
|
def filter?
|
@@ -80,7 +81,7 @@ module Argos
|
|
80
81
|
@total = linecount = 0
|
81
82
|
@valid = false
|
82
83
|
|
83
|
-
|
84
|
+
filename = File.realpath(filename)
|
84
85
|
@filename = filename
|
85
86
|
if filename.nil? or not File.exists? filename
|
86
87
|
raise ArgumentError, "Missing ARGOS DS file: \"#{filename}\""
|
@@ -109,7 +110,14 @@ module Argos
|
|
109
110
|
File.open(filename, :encoding => "iso-8859-1").each do |line|
|
110
111
|
line = line.to_s.strip
|
111
112
|
linecount+=1
|
112
|
-
|
113
|
+
|
114
|
+
if line =~ /Prog\s(\d{4,})$/
|
115
|
+
@program = line.split(" ").last
|
116
|
+
log.info "Program: #{@program}"
|
117
|
+
@programs << @program
|
118
|
+
end
|
119
|
+
|
120
|
+
if line =~ START_REGEX
|
113
121
|
match+=1
|
114
122
|
if contact !=""
|
115
123
|
check_format(contact.strip, startline)
|
@@ -120,14 +128,16 @@ module Argos
|
|
120
128
|
contact = contact + " " +line
|
121
129
|
end
|
122
130
|
end
|
131
|
+
|
123
132
|
check_format(contact.strip, startline)
|
124
|
-
|
133
|
+
|
134
|
+
@programs = @programs.uniq
|
125
135
|
if filter?
|
126
136
|
total = self.size
|
127
137
|
filtered = self.select{|diag| filter.call(diag)}
|
128
138
|
log.info "Selected #{filtered.size}/#{total} Argos DIAG segments sha1:#{sha1} #{filename}"
|
129
139
|
self.clear
|
130
|
-
|
140
|
+
# programs may be wrong now!
|
131
141
|
filtered.each do |filtered|
|
132
142
|
self << filtered
|
133
143
|
end
|
@@ -152,6 +162,8 @@ module Argos
|
|
152
162
|
if contact =~ /#{$FORMAT_1}/ or contact =~ /#{$FORMAT_2}/ or contact =~ /#{$FORMAT_2}/
|
153
163
|
self << create_diag_hash(contact)
|
154
164
|
true
|
165
|
+
elsif contact =~ /Prog\s\d{5,}$/
|
166
|
+
true
|
155
167
|
else
|
156
168
|
error = "#{filename}:#{line_num} sha1:#{@sha1} Invalid format:\n" + contact
|
157
169
|
@errors << error
|
@@ -228,12 +240,17 @@ module Argos
|
|
228
240
|
}
|
229
241
|
|
230
242
|
idbase = diag.clone
|
231
|
-
idbase.delete :
|
243
|
+
idbase.delete :location
|
232
244
|
id = Digest::SHA1.hexdigest(idbase.to_json)
|
233
245
|
|
234
246
|
diag[:parser] = Argos.library_version
|
235
247
|
diag[:id] = id
|
236
248
|
diag[:bundle] = bundle
|
249
|
+
if @program
|
250
|
+
diag[:program] = @program
|
251
|
+
end
|
252
|
+
|
253
|
+
|
237
254
|
diag
|
238
255
|
end
|
239
256
|
|
data/lib/argos/ds.rb
CHANGED
data/lib/argos.rb
CHANGED
@@ -17,7 +17,7 @@ require_relative "argos/diag"
|
|
17
17
|
#
|
18
18
|
# For information about Argos, see: http://www.argos-system.org
|
19
19
|
module Argos
|
20
|
-
VERSION = "1.0.
|
20
|
+
VERSION = "1.0.5"
|
21
21
|
# Detect Argos type ("ds" or "diag" or nil)
|
22
22
|
#
|
23
23
|
# @param filename [String] Argos (DS or DIAG) file
|
@@ -119,7 +119,7 @@ module Argos
|
|
119
119
|
longitude_mean: longitude_mean,
|
120
120
|
location: "file://"+argos.filename,
|
121
121
|
bytes: argos.filesize,
|
122
|
-
|
122
|
+
modified: argos.updated.utc.iso8601,
|
123
123
|
messages: argos.messages.size,
|
124
124
|
filter: argos.filtername.nil? ? argos.filter : argos.filtername,
|
125
125
|
size: argos.size,
|
@@ -0,0 +1,52 @@
|
|
1
|
+
Prog 14660
|
2
|
+
|
3
|
+
080683 Date : 03.05.08 10:50:50 LC : 1 IQ : 50
|
4
|
+
Lat1 : 78.246N Lon1 : 15.533E Lat2 : 74.710N Lon2 : 33.046E
|
5
|
+
Nb mes : 008 Nb mes>-120dB : 000 Best level : -124 dB
|
6
|
+
Pass duration : 420s NOPC : 1
|
7
|
+
Calcul freq : 401 651795.4 Hz Altitude : 0 m
|
8
|
+
03 01 146 144
|
9
|
+
|
10
|
+
080683 Date : 03.05.08 10:57:20 LC : 1 IQ : 56
|
11
|
+
Lat1 : 78.207N Lon1 : 15.519E Lat2 : 81.674N Lon2 : 23.273E
|
12
|
+
Nb mes : 007 Nb mes>-120dB : 000 Best level : -122 dB
|
13
|
+
Pass duration : 601s NOPC : 3
|
14
|
+
Calcul freq : 401 651801.5 Hz Altitude : 500 m
|
15
|
+
03 01 146 144
|
16
|
+
|
17
|
+
Prog 9999
|
18
|
+
|
19
|
+
02170 Date : 03.02.09 17:47:56 LC : 3 IQ : 66
|
20
|
+
Lat1 : 33.385N Lon1 : 111.811W Lat2 : 35.397N Lon2 : 121.727W
|
21
|
+
Nb mes : 009 Nb mes>-120dB : 000 Best level : -126 dB
|
22
|
+
Pass duration : 811s NOPC : 3
|
23
|
+
Calcul freq : 401 637664.9 Hz Altitude : 352 m
|
24
|
+
00 7B 5D E0
|
25
|
+
C2 51 81 51
|
26
|
+
14 6A 30 00
|
27
|
+
3F FC 03 00
|
28
|
+
03 FF C0 30
|
29
|
+
00 3F FC 0C
|
30
|
+
3F FF FF C0
|
31
|
+
02170 Date : 03.02.09 18:04:26 LC : 3 IQ : 66
|
32
|
+
Lat1 : 33.385N Lon1 : 111.810W Lat2 : 37.544N Lon2 : 131.878W
|
33
|
+
Nb mes : 007 Nb mes>-120dB : 000 Best level : -123 dB
|
34
|
+
Pass duration : 630s NOPC : 3
|
35
|
+
Calcul freq : 401 637664.6 Hz Altitude : 352 m
|
36
|
+
00 0D DD E0
|
37
|
+
C2 51 81 51
|
38
|
+
14 86 AC 01
|
39
|
+
FF 00 00 00
|
40
|
+
00 0E 7F E0
|
41
|
+
00 2B 00 7F
|
42
|
+
C0 00 00 00
|
43
|
+
03 80 E9 7F
|
44
|
+
|
45
|
+
Prog 14660
|
46
|
+
|
47
|
+
080683 Date : 03.05.08 10:59:59 LC : 1 IQ : 50
|
48
|
+
Lat1 : 78.246N Lon1 : 15.533E Lat2 : 74.710N Lon2 : 33.046E
|
49
|
+
Nb mes : 008 Nb mes>-120dB : 000 Best level : -124 dB
|
50
|
+
Pass duration : 420s NOPC : 1
|
51
|
+
Calcul freq : 401 651795.4 Hz Altitude : 0 m
|
52
|
+
03 01 146 144
|
data/spec/argos/diag_spec.rb
CHANGED
@@ -60,13 +60,22 @@ module Argos
|
|
60
60
|
:technology=>"argos",
|
61
61
|
:type=>"diag",
|
62
62
|
:location=>"file://"+VALID_DIAG,
|
63
|
-
:id => "
|
63
|
+
:id => "a4e59580432b7b621f66c0cdc3087127554acd1d",
|
64
64
|
:parser => "argos-ruby-#{Argos::VERSION}",
|
65
65
|
:bundle => nil,
|
66
66
|
:source =>"f53ae3ab454f3e210347439aa440c084f775f9a4"}
|
67
67
|
end
|
68
68
|
end
|
69
|
+
|
70
|
+
it "should parse program from Prog header if present" do
|
71
|
+
@diag.parse(diagfile("Prog_header.ds")).map {|diag|
|
72
|
+
diag[:program]||nil }. should == ["14660", "9999", "14660", "9999", "14660"]
|
73
|
+
end
|
74
|
+
|
75
|
+
|
69
76
|
end
|
77
|
+
|
78
|
+
|
70
79
|
#describe '#check_format' do
|
71
80
|
# it 'should return true if this is a recognized Diag format' do
|
72
81
|
# str ="02170 Date : 03.02.09 17:47:56 LC : 3 IQ : 66 Lat1 : 33.385N Lon1 : 111.811W Lat2 : 35.397N Lon2 : 121.727W Nb mes : 009 Nb mes>-120dB : 000 Best level : -126 dB Pass duration : 811s NOPC : 3 Calcul freq : 401 637664.9 Hz Altitude : 352 m 00 7B 5D E0 C2 51 81 51 14 6A 30 00 3F FC 03 00 03 FF C0 30 00 3F FC 0C 3F FF FF C0"
|
data/spec/argos/ds_spec.rb
CHANGED
@@ -92,7 +92,7 @@ module Argos
|
|
92
92
|
:longitude=>22.319, :altitude=>0.0, :headers=>12,
|
93
93
|
:measured=>"1999-12-30T18:43:52Z", :identical=>3, :sensor_data=>["78", "00", "00"],
|
94
94
|
:technology=>"argos", :type=>"ds", :location=>"file://"+VALID_DS, :parser => "argos-ruby-#{Argos::VERSION}",
|
95
|
-
:source=>"3a39e0bd0b944dca4f4fbf17bc0680704cde2994", :id=>"
|
95
|
+
:source=>"3a39e0bd0b944dca4f4fbf17bc0680704cde2994", :id=>"4369c31c191bd55a998e6293ff4639da3984a95d",
|
96
96
|
:bundle=>nil}]
|
97
97
|
end
|
98
98
|
end
|
@@ -117,7 +117,7 @@ module Argos
|
|
117
117
|
:warn=>["missing-position", "sensors-count-mismatch"],
|
118
118
|
:parser=>"argos-ruby-#{Argos::VERSION}",
|
119
119
|
:bundle=>nil,
|
120
|
-
:id=>"
|
120
|
+
:id=>"f2c82a5ca1330b312925949a15ac300d07452a12"}]
|
121
121
|
end
|
122
122
|
|
123
123
|
end
|
data/spec/argos_spec.rb
CHANGED
@@ -28,7 +28,7 @@ module Argos
|
|
28
28
|
:messages=>449,
|
29
29
|
:filter=>nil,
|
30
30
|
:size=>843,
|
31
|
-
:
|
31
|
+
:modified => "2013-10-21T17:02:32Z",
|
32
32
|
:parser=>Argos.library_version }
|
33
33
|
end
|
34
34
|
end
|
@@ -53,7 +53,7 @@ module Argos
|
|
53
53
|
:longitude_mean=>30.752,
|
54
54
|
:location=>"file://#{diagfile("990660_A.DIA")}",
|
55
55
|
:bytes=>222056,
|
56
|
-
:
|
56
|
+
:modified=>"2013-10-21T18:31:55Z",
|
57
57
|
:messages=>448,
|
58
58
|
:filter=>nil,
|
59
59
|
:size=>448,
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: argos-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.5
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Espen Egeland
|
@@ -10,12 +9,11 @@ authors:
|
|
10
9
|
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date: 2014-01-
|
12
|
+
date: 2014-01-21 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: rspec
|
17
16
|
requirement: !ruby/object:Gem::Requirement
|
18
|
-
none: false
|
19
17
|
requirements:
|
20
18
|
- - ! '>='
|
21
19
|
- !ruby/object:Gem::Version
|
@@ -23,7 +21,6 @@ dependencies:
|
|
23
21
|
type: :development
|
24
22
|
prerelease: false
|
25
23
|
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
none: false
|
27
24
|
requirements:
|
28
25
|
- - ! '>='
|
29
26
|
- !ruby/object:Gem::Version
|
@@ -48,6 +45,7 @@ files:
|
|
48
45
|
- lib/argos/ds.rb
|
49
46
|
- lib/argos/exception.rb
|
50
47
|
- spec/argos/_diag/990660_A.DIA
|
48
|
+
- spec/argos/_diag/Prog_header.ds
|
51
49
|
- spec/argos/_diag/dup.diag
|
52
50
|
- spec/argos/_diag/error.diag
|
53
51
|
- spec/argos/_diag/valid_2009-03-02_DB_DIAG.txt
|
@@ -62,26 +60,25 @@ files:
|
|
62
60
|
homepage: http://github.com/npolar/argos-ruby
|
63
61
|
licenses:
|
64
62
|
- GPL-3.0
|
63
|
+
metadata: {}
|
65
64
|
post_install_message:
|
66
65
|
rdoc_options: []
|
67
66
|
require_paths:
|
68
67
|
- lib
|
69
68
|
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
-
none: false
|
71
69
|
requirements:
|
72
70
|
- - ! '>='
|
73
71
|
- !ruby/object:Gem::Version
|
74
72
|
version: '0'
|
75
73
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
-
none: false
|
77
74
|
requirements:
|
78
75
|
- - ! '>='
|
79
76
|
- !ruby/object:Gem::Version
|
80
77
|
version: '0'
|
81
78
|
requirements: []
|
82
79
|
rubyforge_project:
|
83
|
-
rubygems_version:
|
80
|
+
rubygems_version: 2.2.1
|
84
81
|
signing_key:
|
85
|
-
specification_version:
|
82
|
+
specification_version: 4
|
86
83
|
summary: Argos satellite tracking data parsers
|
87
84
|
test_files: []
|