gmsec 0.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.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +76 -0
- data/Rakefile +2 -0
- data/examples/example_publisher_config.xml +1609 -0
- data/examples/gm_msg_config +87 -0
- data/examples/gmconfig +57 -0
- data/examples/gmconfig.xml +45 -0
- data/examples/gmpub +76 -0
- data/gmsec.gemspec +29 -0
- data/lib/gmsec.rb +15 -0
- data/lib/gmsec/api.rb +157 -0
- data/lib/gmsec/config.rb +89 -0
- data/lib/gmsec/config_file.rb +64 -0
- data/lib/gmsec/connection.rb +208 -0
- data/lib/gmsec/definitions.rb +189 -0
- data/lib/gmsec/field.rb +231 -0
- data/lib/gmsec/message.rb +211 -0
- data/lib/gmsec/status.rb +30 -0
- data/lib/gmsec/version.rb +3 -0
- data/spec/gmsec/config_spec.rb +43 -0
- data/spec/gmsec/connection_spec.rb +12 -0
- data/spec/gmsec/field_spec.rb +82 -0
- data/spec/integration/connection_spec.rb +110 -0
- data/spec/spec_helper.rb +2 -0
- metadata +174 -0
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GMSEC::Config do
|
4
|
+
|
5
|
+
context "a new Config object" do
|
6
|
+
it "add persists new configuration options" do
|
7
|
+
subject["foo"] = "bar"
|
8
|
+
expect(subject["foo"]).to eq("bar")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
context "a Config object with mixed data types" do
|
13
|
+
subject do
|
14
|
+
described_class.new.tap do |config|
|
15
|
+
config["foo"] = "foo"
|
16
|
+
config[:bar] = :bar
|
17
|
+
config[42] = 42
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
it "returns nil for config entries that do not exist" do
|
22
|
+
expect(subject["nope"]).to be_nil
|
23
|
+
end
|
24
|
+
|
25
|
+
it "outputs all values as strings" do
|
26
|
+
expect(subject["foo"]).to eq("foo")
|
27
|
+
expect(subject[:bar]).to eq("bar")
|
28
|
+
expect(subject[42]).to eq("42")
|
29
|
+
end
|
30
|
+
|
31
|
+
it "interprets keys as strings" do
|
32
|
+
expect(subject["foo"]).to eq("foo")
|
33
|
+
expect(subject["bar"]).to eq("bar")
|
34
|
+
expect(subject["42"]).to eq("42")
|
35
|
+
end
|
36
|
+
|
37
|
+
it "returns all configuration options via #values" do
|
38
|
+
expect(subject).to respond_to(:values)
|
39
|
+
expect(subject.values).to be_a(Enumerator)
|
40
|
+
expect(subject.values.to_a).to eq([["42", "42"], ["bar", "bar"], ["foo", "foo"]])
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GMSEC::Connection do
|
4
|
+
|
5
|
+
context 'a Connection instance instantiated with configuration options' do
|
6
|
+
subject { described_class.new(foo: :bar) }
|
7
|
+
|
8
|
+
it 'interprets arguments as configuration options' do
|
9
|
+
expect(subject.config[:foo]).to eq("bar")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GMSEC::Field do
|
4
|
+
context "when specifying value and type" do
|
5
|
+
|
6
|
+
def self.it_persists_data
|
7
|
+
it 'persists the correct field name' do
|
8
|
+
expect(subject.name).to eq(name)
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'persists the correct value' do
|
12
|
+
expect(subject.value).to eq(value)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'persists the correct type' do
|
16
|
+
expect(subject.type).to eq(type)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
let(:name){"Test"}
|
21
|
+
|
22
|
+
subject do
|
23
|
+
described_class.new(name, value, type: type)
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'of type :char' do
|
27
|
+
let(:type){:char}
|
28
|
+
let(:value){"x"}
|
29
|
+
it_persists_data
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'of type :str' do
|
33
|
+
let(:type){:str}
|
34
|
+
let(:value){"Test"}
|
35
|
+
it_persists_data
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'of type :bool' do
|
39
|
+
let(:type){:bool}
|
40
|
+
|
41
|
+
context 'with value of true' do
|
42
|
+
let(:value){true}
|
43
|
+
it_persists_data
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'with value of false' do
|
47
|
+
let(:value){false}
|
48
|
+
it_persists_data
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'of type :i16' do
|
53
|
+
let(:type){:i16}
|
54
|
+
let(:value){42}
|
55
|
+
it_persists_data
|
56
|
+
end
|
57
|
+
|
58
|
+
context 'of type :i32' do
|
59
|
+
let(:type){:i32}
|
60
|
+
let(:value){42}
|
61
|
+
it_persists_data
|
62
|
+
end
|
63
|
+
|
64
|
+
context 'of type :u32' do
|
65
|
+
let(:type){:u32}
|
66
|
+
let(:value){42}
|
67
|
+
it_persists_data
|
68
|
+
end
|
69
|
+
|
70
|
+
context 'of type :f32' do
|
71
|
+
let(:type){:f32}
|
72
|
+
let(:value){42}
|
73
|
+
it_persists_data
|
74
|
+
end
|
75
|
+
|
76
|
+
context 'of type :f64' do
|
77
|
+
let(:type){:f64}
|
78
|
+
let(:value){42}
|
79
|
+
it_persists_data
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
describe GMSEC::Connection do
|
2
|
+
|
3
|
+
context "configured for a local instance of MBServer" do
|
4
|
+
before(:each) do
|
5
|
+
subject.config[:connectiontype] = :gmsec_mb
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should connect and disconnect successfully", integration: true do
|
9
|
+
expect(subject.connected?).to be false
|
10
|
+
|
11
|
+
subject.connect
|
12
|
+
expect(subject.connected?).to be true
|
13
|
+
|
14
|
+
subject.disconnect
|
15
|
+
expect(subject.connected?).to be false
|
16
|
+
end
|
17
|
+
|
18
|
+
context "publishing and subscribing a simple message" do
|
19
|
+
let(:payload) do
|
20
|
+
{ foo: "foo",
|
21
|
+
int: 2,
|
22
|
+
double: 1.2 }
|
23
|
+
end
|
24
|
+
|
25
|
+
before(:each) do
|
26
|
+
subject.connect
|
27
|
+
end
|
28
|
+
|
29
|
+
after(:each) do
|
30
|
+
subject.disconnect
|
31
|
+
end
|
32
|
+
|
33
|
+
it "publishes and subscribes to messages", integration: true do
|
34
|
+
subject.subscribe("GMSEC.TEST.*")
|
35
|
+
|
36
|
+
subject.publish(payload, subject: "GMSEC.TEST.HELLO")
|
37
|
+
|
38
|
+
message = subject.messages.first
|
39
|
+
|
40
|
+
expect(message.subject).to eq("GMSEC.TEST.HELLO")
|
41
|
+
|
42
|
+
# Message and payload should agree.
|
43
|
+
payload.keys.each do |key|
|
44
|
+
expect(message[key]).to eq(payload[key])
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
it "interprets blocks as callbacks to messages", integration: true do
|
49
|
+
subject.subscribe("GMSEC.TEST.*") do |message|
|
50
|
+
expect(message.subject).to eq("GMSEC.TEST.HELLO")
|
51
|
+
|
52
|
+
# Message and payload should agree.
|
53
|
+
payload.keys.each do |key|
|
54
|
+
expect(message[key]).to eq(payload[key])
|
55
|
+
end
|
56
|
+
|
57
|
+
@pass = true
|
58
|
+
end
|
59
|
+
|
60
|
+
subject.publish(payload, subject: "GMSEC.TEST.HELLO")
|
61
|
+
|
62
|
+
# Need to dispatch first message
|
63
|
+
subject.messages.first
|
64
|
+
|
65
|
+
expect(@pass).to be(true)
|
66
|
+
end
|
67
|
+
|
68
|
+
it "enumerates received message via #messages", integration: true do
|
69
|
+
subject.subscribe("GMSEC.TEST.*")
|
70
|
+
|
71
|
+
5.times do
|
72
|
+
subject.publish(payload, subject: "GMSEC.TEST.FOO")
|
73
|
+
end
|
74
|
+
|
75
|
+
expect(subject.messages.to_a.length).to be(5)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
context "using autodispatching", integration: true do
|
80
|
+
before(:each) do
|
81
|
+
subject.connect
|
82
|
+
end
|
83
|
+
|
84
|
+
after(:each) do
|
85
|
+
subject.stop_auto_dispatch
|
86
|
+
subject.disconnect
|
87
|
+
end
|
88
|
+
|
89
|
+
it "correctly autodispatches messages as they are received", integration: true do
|
90
|
+
@pass = 0
|
91
|
+
|
92
|
+
subject.subscribe("GMSEC.TEST.*") do |message|
|
93
|
+
@pass += 1
|
94
|
+
end
|
95
|
+
|
96
|
+
subject.subscribe("GMSEC.TEST.FOO") do |message|
|
97
|
+
@pass += 1
|
98
|
+
end
|
99
|
+
|
100
|
+
subject.start_auto_dispatch
|
101
|
+
|
102
|
+
subject.publish({foo: :bar}, subject: "GMSEC.TEST.FOO")
|
103
|
+
|
104
|
+
sleep 1
|
105
|
+
|
106
|
+
expect(@pass).to eq(2)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,174 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gmsec
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Stefan Novak
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: commander
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 4.2.1
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 4.2.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.10.1
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.10.1
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 3.1.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 3.1.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: ffi
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 1.9.6
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.9.6
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: terminal-table
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 1.4.5
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 1.4.5
|
111
|
+
description: Unofficial Ruby wrapper for NASA's GMSEC. For more information, visit
|
112
|
+
http://gmsec.gsfc.nasa.gov/.
|
113
|
+
email:
|
114
|
+
- stefan@novak.io
|
115
|
+
executables: []
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- ".gitignore"
|
120
|
+
- Gemfile
|
121
|
+
- LICENSE.txt
|
122
|
+
- README.md
|
123
|
+
- Rakefile
|
124
|
+
- examples/example_publisher_config.xml
|
125
|
+
- examples/gm_msg_config
|
126
|
+
- examples/gmconfig
|
127
|
+
- examples/gmconfig.xml
|
128
|
+
- examples/gmpub
|
129
|
+
- gmsec.gemspec
|
130
|
+
- lib/gmsec.rb
|
131
|
+
- lib/gmsec/api.rb
|
132
|
+
- lib/gmsec/config.rb
|
133
|
+
- lib/gmsec/config_file.rb
|
134
|
+
- lib/gmsec/connection.rb
|
135
|
+
- lib/gmsec/definitions.rb
|
136
|
+
- lib/gmsec/field.rb
|
137
|
+
- lib/gmsec/message.rb
|
138
|
+
- lib/gmsec/status.rb
|
139
|
+
- lib/gmsec/version.rb
|
140
|
+
- spec/gmsec/config_spec.rb
|
141
|
+
- spec/gmsec/connection_spec.rb
|
142
|
+
- spec/gmsec/field_spec.rb
|
143
|
+
- spec/integration/connection_spec.rb
|
144
|
+
- spec/spec_helper.rb
|
145
|
+
homepage: http://gmsec.gsfc.nasa.gov/
|
146
|
+
licenses:
|
147
|
+
- MIT
|
148
|
+
metadata: {}
|
149
|
+
post_install_message:
|
150
|
+
rdoc_options: []
|
151
|
+
require_paths:
|
152
|
+
- lib
|
153
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
154
|
+
requirements:
|
155
|
+
- - ">="
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
159
|
+
requirements:
|
160
|
+
- - ">="
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: '0'
|
163
|
+
requirements: []
|
164
|
+
rubyforge_project:
|
165
|
+
rubygems_version: 2.2.2
|
166
|
+
signing_key:
|
167
|
+
specification_version: 4
|
168
|
+
summary: Unofficial Ruby wrapper for NASA's GMSEC.
|
169
|
+
test_files:
|
170
|
+
- spec/gmsec/config_spec.rb
|
171
|
+
- spec/gmsec/connection_spec.rb
|
172
|
+
- spec/gmsec/field_spec.rb
|
173
|
+
- spec/integration/connection_spec.rb
|
174
|
+
- spec/spec_helper.rb
|