argos-ruby 1.0.0 → 1.0.1

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.
data/bin/argos-ruby CHANGED
@@ -87,9 +87,13 @@ Dir[glob].select {|f|
87
87
 
88
88
  case param[:action]
89
89
  when "source"
90
+
90
91
  result << Argos.source(argos).merge(glob: glob, bundle: bundle)
92
+
91
93
  when "parse"
94
+
92
95
  arr = argos.parse(filename)
96
+
93
97
  unless param[:dest].nil?
94
98
  jsonfile = "#{param[:dest].gsub(/\$/, "")}/#{argos.source}.json"
95
99
  File.open(jsonfile, "w") { |file| file.write(arr.to_json) }
data/lib/argos/diag.rb CHANGED
@@ -17,7 +17,7 @@ module Argos
17
17
 
18
18
  LOCATION_CLASS = ["3", "2", "1", "0", "A", "B", "Z"]
19
19
 
20
- attr_accessor :log, :filename, :programs
20
+ attr_accessor :log, :filename, :programs, :multiplicates
21
21
 
22
22
  attr_reader :filename, :filter, :filtername, :sha1, :valid, :filesize
23
23
 
@@ -142,7 +142,14 @@ module Argos
142
142
  else
143
143
  log.info "Parsed #{self.size} Argos DIAG segments sha1:#{sha1} #{filename}"
144
144
  end
145
-
145
+
146
+ @multiplicates = group_by { |e| e }.select { |k, v| v.size > 1 }.map(&:first)
147
+ if multiplicates.any?
148
+ log.warn "Multiplicates (source sha1 #{sha1} #{filename}): #{multiplicates.to_json}"
149
+ self.uniq!
150
+ log.info "Unique DIAG messages: #{self.size} sha1: #{sha1} #{filename}"
151
+ end
152
+
146
153
  self
147
154
  end
148
155
 
data/lib/argos/ds.rb CHANGED
@@ -19,7 +19,7 @@ module Argos
19
19
 
20
20
  attr_writer :log, :filename
21
21
 
22
- attr_reader :filename, :filter, :filtername, :valid, :filesize, :sha1, :messages
22
+ attr_reader :filename, :filter, :filtername, :valid, :filesize, :sha1, :messages, :multiplicates
23
23
 
24
24
  START_REGEX = /^\d{5} \d{5,6} +\d+ +\d+/
25
25
 
@@ -146,6 +146,14 @@ module Argos
146
146
  unfold.each do |d|
147
147
  self << d
148
148
  end
149
+
150
+ @multiplicates = group_by { |e| e }.select { |k, v| v.size > 1 }.map(&:first)
151
+ if multiplicates.any?
152
+ log.warn "Multiplicates (source sha1 #{sha1} #{filename}): #{multiplicates.to_json}"
153
+ self.uniq!
154
+ log.info "Unique DS messages: #{self.size} sha1: #{sha1} #{filename}"
155
+ end
156
+
149
157
  self
150
158
  end
151
159
 
data/lib/argos.rb CHANGED
@@ -16,7 +16,7 @@ require_relative "argos/diag"
16
16
  #
17
17
  # For information about Argos, see: http://www.argos-system.org
18
18
  module Argos
19
- VERSION = "1.0.0"
19
+ VERSION = "1.0.1"
20
20
  # Detect Argos type ("ds" or "diag" or nil)
21
21
  #
22
22
  # @param filename [String] Argos (DS or DIAG) file
@@ -101,7 +101,10 @@ module Argos
101
101
  end
102
102
 
103
103
 
104
- { id: argos.source,
104
+ source = {
105
+ id: argos.source,
106
+ technology: "argos",
107
+ collection: "tracking",
105
108
  type: argos.type,
106
109
  programs: argos.programs,
107
110
  platforms: argos.platforms,
@@ -117,8 +120,13 @@ module Argos
117
120
  filesize: argos.filesize,
118
121
  messages: argos.messages.size,
119
122
  filter: argos.filtername.nil? ? argos.filter : argos.filtername,
120
- size: argos.size,
123
+ size: argos.size
121
124
  }
125
+ if argos.multiplicates.any?
126
+ source[:multiplicates] = argos.multiplicates.map {|a| a[:id]}
127
+ end
128
+ source
129
+
122
130
  end
123
131
 
124
132
 
@@ -137,6 +145,5 @@ module Argos
137
145
  def programs
138
146
  map {|a| a[:program]}.uniq.sort
139
147
  end
140
-
141
-
148
+
142
149
  end
@@ -0,0 +1,12 @@
1
+ 074776 Date : 21.08.12 13:49:05 LC : Z IQ : 00
2
+ Lat1 : ??????? Lon1 : ???????? Lat2 : ??????? Lon2 : ????????
3
+ Nb mes : 001 Nb mes>-120dB : 000 Best level : -128 dB
4
+ Pass duration : ???s NOPC : ?
5
+ Calcul freq : 401 631510.3 Hz Altitude : 0 m
6
+ 01 52 00 83
7
+ 074776 Date : 21.08.12 13:49:05 LC : Z IQ : 00
8
+ Lat1 : ??????? Lon1 : ???????? Lat2 : ??????? Lon2 : ????????
9
+ Nb mes : 001 Nb mes>-120dB : 000 Best level : -128 dB
10
+ Pass duration : ???s NOPC : ?
11
+ Calcul freq : 401 631510.3 Hz Altitude : 0 m
12
+ 01 52 00 83
@@ -0,0 +1,8 @@
1
+ 09660 10783 4 3 K 3 1999-12-24 16:52:54 79.826 22.326 0.000 401649689
2
+ 1999-12-24 16:50:29 1 76 00 00
3
+ 1999-12-24 16:54:21 4 76 00 00
4
+ 1999-12-24 16:55:19 1 76 00 32
5
+ 09660 10783 4 3 K 3 1999-12-24 16:52:54 79.826 22.326 0.000 401649689
6
+ 1999-12-24 16:50:29 1 76 00 00
7
+ 1999-12-24 16:54:21 4 76 00 00
8
+ 1999-12-24 16:55:19 1 76 00 32
@@ -3,8 +3,8 @@ require 'spec_helper.rb'
3
3
  module Argos
4
4
 
5
5
  describe Diag do
6
-
7
- VALID_DIAG = File.expand_path(File.dirname(__FILE__)+"/_diag/990660_A.DIA")
6
+
7
+ VALID_DIAG = diagfile("990660_A.DIA")
8
8
 
9
9
  describe "#type" do
10
10
  it do
@@ -24,6 +24,10 @@ module Argos
24
24
  @diag.filter = lambda{|a| true}
25
25
  @diag.parse(VALID_DIAG).should be_kind_of Diag
26
26
  end
27
+
28
+ it "should return unique elements" do
29
+ @diag.parse(diagfile("dup.diag")).size.should == 1
30
+ end
27
31
 
28
32
  describe "#size" do
29
33
  it "should == number messages" do
@@ -1,10 +1,11 @@
1
1
  require 'spec_helper.rb'
2
2
 
3
3
  module Argos
4
+
4
5
 
5
6
  describe Ds do
6
-
7
- VALID_DS = File.expand_path(File.dirname(__FILE__)+"/_ds/990660_A.DAT")
7
+
8
+ VALID_DS = dsfile("990660_A.DAT")
8
9
 
9
10
  before (:each) do
10
11
  @ds = Ds.new
@@ -37,6 +38,34 @@ module Argos
37
38
  @ds.filter = lambda {|ds|true}
38
39
  @ds.parse(VALID_DS).should be_kind_of Ds
39
40
  end
41
+
42
+ it "should return unique elements" do
43
+ @ds.parse(dsfile("dup.ds")).size.should == 3 # file contains 6
44
+ end
45
+
46
+
47
+ it "should store multiplicates" do
48
+ @ds.parse(dsfile("dup.ds")).multiplicates.map {|m| m.keys }.should==3.times.map{[:program,
49
+ :platform,
50
+ :lines,
51
+ :sensors,
52
+ :satellite,
53
+ :lc,
54
+ :positioned,
55
+ :latitude,
56
+ :longitude,
57
+ :altitude,
58
+ :headers,
59
+ :measured,
60
+ :identical,
61
+ :sensor_data,
62
+ :technology,
63
+ :type,
64
+ :filename,
65
+ :source,
66
+ :parser,
67
+ :id]}
68
+ end
40
69
 
41
70
  it "should sort ascending on positioned, measured" do
42
71
  positions = @ds.select {|ds|
@@ -95,7 +124,7 @@ module Argos
95
124
  context "warn" do
96
125
 
97
126
  before(:each) do
98
- @file = File.expand_path(File.dirname(__FILE__)+"/_ds/sensor_mismatch_ds.txt")
127
+ @file = dsfile("sensor_mismatch_ds.txt")
99
128
  end
100
129
 
101
130
  it "sensors-count-mismatch" do
data/spec/spec_helper.rb CHANGED
@@ -11,4 +11,11 @@ RSpec.configure do |config|
11
11
  config.formatter = :documentation #:progress, :html, :textmate
12
12
  end
13
13
 
14
+ def dsfile(filename)
15
+ File.expand_path(File.dirname(__FILE__)+"/argos/_ds/#{filename}")
16
+ end
17
+
18
+ def diagfile(filename)
19
+ File.expand_path(File.dirname(__FILE__)+"/argos/_diag/#{filename}")
20
+ end
14
21
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: argos-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-12-05 00:00:00.000000000 Z
13
+ date: 2013-12-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
@@ -47,8 +47,10 @@ files:
47
47
  - lib/argos/ds.rb
48
48
  - lib/argos/exception.rb
49
49
  - spec/argos/_diag/990660_A.DIA
50
+ - spec/argos/_diag/dup.diag
50
51
  - spec/argos/_diag/valid_2009-03-02_DB_DIAG.txt
51
52
  - spec/argos/_ds/990660_A.DAT
53
+ - spec/argos/_ds/dup.ds
52
54
  - spec/argos/_ds/sensor_mismatch_ds.txt
53
55
  - spec/argos/diag_spec.rb
54
56
  - spec/argos/ds_spec.rb