rmuh 0.2.2 → 0.2.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b63c73ace7a1211a2f87a68c08d9eb59214a5735
4
- data.tar.gz: 6c8be181f4208f9d26c280af1b3247937fafcac8
3
+ metadata.gz: b1efcd96775d658f86be3870b112469b3ae99da4
4
+ data.tar.gz: e7939dee509616b41531fd5a0dcf060b3f7856c3
5
5
  SHA512:
6
- metadata.gz: cb90e1fa7a2be37278be469d1fca17011907eec6f3abdb00c738dca5b78f0d8e85871a5da8b7336c3be766e0c8c4671d21f2d0b3b558a007146788845ee7ed7b
7
- data.tar.gz: 40aacc1f5594affb5790f186a77c4b4f11e6a46df9f5f0ff4853af359b348873f132845d323015aa0f04b0152deb72aa110454aba44c7d11799b81b3ac7baa4e
6
+ metadata.gz: 121493c2971439083cd1f428744afdbe5fba3016b8a0f71d69703bd5fd31392682ea6782d53a13d1bef6da429b29b46f9ac06ccdb80eb0880b65852ce701b42b
7
+ data.tar.gz: a6cf4b907b19d28769db62182af8f0223874010d8db3be68ad0273697f8c5b635dba7070dd064221d05f9a350501db2a3e04f3ea32ef64b28b1fd890c400dcfb
@@ -6,7 +6,7 @@
6
6
  module RMuh
7
7
  VERSION_MAJ ||= 0
8
8
  VERSION_MIN ||= 2
9
- VERSION_REV ||= 2
9
+ VERSION_REV ||= 3
10
10
 
11
11
  VERSION ||= "#{VERSION_MAJ}.#{VERSION_MIN}.#{VERSION_REV}"
12
12
  end
@@ -8,7 +8,7 @@ require 'rmuh/version'
8
8
  Gem::Specification.new do |g|
9
9
  g.name = 'rmuh'
10
10
  g.version = RMuh::VERSION
11
- g.date = '2014-02-18'
11
+ g.date = Time.now.strftime('%Y-%m-%d')
12
12
  g.description = 'ArmA 2 Ruby Library for RPT, Log, and GameSpy'
13
13
  g.summary = 'ArmA 2 Ruby Library'
14
14
  g.authors = ['Tim Heckman']
@@ -3,6 +3,8 @@ require 'rspec'
3
3
  require 'simplecov'
4
4
  require 'coveralls'
5
5
 
6
+ $LOAD_PATH.unshift '.' unless $LOAD_PATH.include?('.')
7
+
6
8
  def repo_root
7
9
  File.expand_path('../../..', __FILE__)
8
10
  end
@@ -0,0 +1,27 @@
1
+ # -*- coding: UTF-8 -*-
2
+ require 'rspec'
3
+ require 'helpers/spec_helper'
4
+ require File.join(repo_root, 'lib/rmuh/serverstats/advanced')
5
+ require 'rmuh_serverstats_base'
6
+
7
+ describe RMuh::ServerStats::Advanced do
8
+ let(:s) do
9
+ RMuh::ServerStats::Advanced.new(host: 'srv1.unitedoperations.net')
10
+ end
11
+
12
+ it_should_behave_like 'RMuh::ServerStats::Base'
13
+
14
+ context '::method_missing' do
15
+ it 'should not raise an error when given a valid key' do
16
+ expect { s.gamever }.to_not raise_error
17
+ end
18
+
19
+ it 'should raise an error when given an invalid key' do
20
+ expect { s.kjsnfsfidnfjsnfisun }.to raise_error NoMethodError
21
+ end
22
+
23
+ it 'should return a String when gamever is requested' do
24
+ expect(s.gamever).to be_an_instance_of String
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,201 @@
1
+ # -*- coding: UTF-8 -*-
2
+
3
+ shared_examples 'RMuh::ServerStats::Base' do
4
+ context '::DEFAULT_PORT' do
5
+ let(:port) { RMuh::ServerStats::Base::DEFAULT_PORT }
6
+
7
+ it 'should be an instance of Fixnum' do
8
+ expect(port).to be_an_instance_of Fixnum
9
+ end
10
+
11
+ it 'should be the default ArmA 2 port' do
12
+ expect(port).to eql 2_302
13
+ end
14
+ end
15
+
16
+ context '::validate_opts' do
17
+ let(:srv_hash) { { host: '127.0.0.1' } }
18
+
19
+ it 'should take no more than one arg' do
20
+ expect do
21
+ RMuh::ServerStats::Base.validate_opts(nil, nil)
22
+ end.to raise_error ArgumentError
23
+ end
24
+
25
+ it 'should take no less than one arg' do
26
+ expect do
27
+ RMuh::ServerStats::Base.validate_opts
28
+ end.to raise_error ArgumentError
29
+ end
30
+
31
+ it 'should fail if arg 1 does not contain host' do
32
+ expect do
33
+ RMuh::ServerStats::Base.validate_opts({})
34
+ end.to raise_error ArgumentError
35
+ end
36
+
37
+ it 'should set the default port if not provided' do
38
+ h = srv_hash.dup
39
+ RMuh::ServerStats::Base.validate_opts(h)
40
+ expect(h.key?(:port)).to be_true
41
+ expect(h[:port]).to eql RMuh::ServerStats::Base::DEFAULT_PORT
42
+ end
43
+
44
+ it 'should set the auto_cache key to true if not provided' do
45
+ h = srv_hash.dup
46
+ RMuh::ServerStats::Base.validate_opts(h)
47
+ expect(h.key?(:auto_cache)).to be_true
48
+ expect(h[:auto_cache]).to be_true
49
+ end
50
+
51
+ it 'should return nil' do
52
+ x = RMuh::ServerStats::Base.validate_opts(host: '127.0.0.1')
53
+ expect(x).to be_nil
54
+ end
55
+ end
56
+
57
+ context '#opts_to_instance' do
58
+ let(:b) { RMuh::ServerStats::Base.new(host: '127.0.0.1') }
59
+
60
+ it 'should take no more than one arg' do
61
+ expect do
62
+ b.send(:opts_to_instance, nil, nil)
63
+ end.to raise_error ArgumentError
64
+ end
65
+
66
+ it 'should take no less than one arg' do
67
+ expect do
68
+ b.send(:opts_to_instance)
69
+ end.to raise_error ArgumentError
70
+ end
71
+
72
+ it 'should convert each key to an instance variable' do
73
+ h = { one: 1, two: '2', three: :three }
74
+ expect(b.instance_variable_get(:@one)).to be_nil
75
+ expect(b.instance_variable_get(:@two)).to be_nil
76
+ expect(b.instance_variable_get(:@three)).to be_nil
77
+ b.send(:opts_to_instance, h)
78
+ expect(b.instance_variable_get(:@one)).to eql h[:one]
79
+ expect(b.instance_variable_get(:@two)).to eql h[:two]
80
+ expect(b.instance_variable_get(:@three)).to eql h[:three]
81
+ end
82
+ end
83
+
84
+ context '::new' do
85
+ it 'should take no more than one arg' do
86
+ expect do
87
+ RMuh::ServerStats::Base.new(nil, nil)
88
+ end.to raise_error ArgumentError
89
+ end
90
+
91
+ it 'should return an instance of itself if arg 1 is a Hash' do
92
+ s = RMuh::ServerStats::Base.new(host: '127.0.0.1')
93
+ expect(s).to be_an_instance_of RMuh::ServerStats::Base
94
+ end
95
+
96
+ it 'should require the host attribute' do
97
+ expect do
98
+ RMuh::ServerStats::Base.new({})
99
+ end.to raise_error ArgumentError
100
+ end
101
+
102
+ it 'should set an instance variable for each thing in Hash' do
103
+ h = { host: '1.2.3.4', port: 2_303, cache: false }
104
+ s = RMuh::ServerStats::Base.new(h)
105
+ expect(s.instance_variable_get(:@host)).to eql h[:host]
106
+ expect(s.instance_variable_get(:@port)).to eql h[:port]
107
+ expect(s.instance_variable_get(:@cache)).to eql h[:cache]
108
+ end
109
+
110
+ it 'should create an instance of GamespyQuery::Socket' do
111
+ s = RMuh::ServerStats::Base.new(host: '127.0.0.1')
112
+ x = s.instance_variable_get(:@gsq)
113
+ expect(x).to be_an_instance_of GamespyQuery::Socket
114
+ end
115
+
116
+ it 'should specify default values for @port and @cache' do
117
+ s = RMuh::ServerStats::Base.new(host: '127.0.0.1')
118
+ expect(s.instance_variable_get(:@cache)).to be true
119
+ expect(s.instance_variable_get(:@port)).to eql 2_302
120
+ end
121
+ end
122
+
123
+ context '#sync' do
124
+ before do
125
+ GamespyQuery::Socket.any_instance.stub(:sync).and_return(one: 1)
126
+ end
127
+ let(:b) { RMuh::ServerStats::Base.new(host: '127.0.0.1') }
128
+
129
+ it 'should take no args' do
130
+ expect { b.send(:sync, nil) }.to raise_error ArgumentError
131
+ end
132
+
133
+ it 'should return a Hash' do
134
+ expect(b.send(:sync)).to be_an_instance_of Hash
135
+ end
136
+ end
137
+
138
+ context '#remote_stats' do
139
+ let(:b) { RMuh::ServerStats::Base.new(host: '127.0.0.1') }
140
+
141
+ it 'should take no args' do
142
+ expect { b.send(:remote_stats, nil) }.to raise_error ArgumentError
143
+ end
144
+
145
+ it 'should return the content of @servicestats if cache == true' do
146
+ b.instance_variable_set(:@serverstats, one: 'two')
147
+ expect(b.send(:remote_stats)).to eql(one: 'two')
148
+ end
149
+
150
+ it 'should return the return value from the #sync method if cache true' do
151
+ n = RMuh::ServerStats::Base.new(host: '127.0.0.1', cache: false)
152
+ n.stub(:sync).and_return(one: 'two')
153
+ expect(n.send(:remote_stats)).to eql(one: 'two')
154
+ end
155
+ end
156
+
157
+ context '#update_cache' do
158
+ before(:each) do
159
+ @b = RMuh::ServerStats::Base.new(host: '127.0.0.1')
160
+ @bf = RMuh::ServerStats::Base.new(host: '127.0.0.1', cache: false)
161
+ @b.stub(:sync).and_return(one: 'two')
162
+ @bf.stub(:sync).and_return(one: 'two')
163
+ end
164
+
165
+ it 'should take no args' do
166
+ expect { @b.update_cache(nil) }.to raise_error ArgumentError
167
+ end
168
+
169
+ it 'should set the contents of @serverstats if caching' do
170
+ @b.update_cache
171
+ expect(@b.instance_variable_get(:@serverstats)).to eql(one: 'two')
172
+ end
173
+
174
+ it 'should not set the contents of @serverstats if no caching' do
175
+ @bf.update_cache
176
+ expect(@bf.instance_variable_get(:@serverstats)).to be_nil
177
+ end
178
+ end
179
+
180
+ context '#stats' do
181
+ before(:each) do
182
+ @b = RMuh::ServerStats::Base.new(host: '127.0.0.1')
183
+ @bf = RMuh::ServerStats::Base.new(host: '127.0.0.1', cache: false)
184
+ @b.stub(:sync).and_return(one: 'two')
185
+ @bf.stub(:sync).and_return(one: 'two')
186
+ @b.update_cache
187
+ end
188
+
189
+ it 'should take no args' do
190
+ expect { @b.stats(nil) }.to raise_error ArgumentError
191
+ end
192
+
193
+ it 'should return the contents of @serverstats if caching enabled' do
194
+ expect(@b.stats).to eql @b.instance_variable_get(:@serverstats)
195
+ end
196
+
197
+ it 'should return the contents of sync if caching is disabled' do
198
+ expect(@bf.stats).to eql(one: 'two')
199
+ end
200
+ end
201
+ end
@@ -4,203 +4,8 @@ require 'rspec'
4
4
  require 'gamespy_query'
5
5
  require 'helpers/spec_helper'
6
6
  require File.join(repo_root, 'lib/rmuh/serverstats/base')
7
+ require 'rmuh_serverstats_base'
7
8
 
8
9
  describe RMuh::ServerStats::Base do
9
- context '::DEFAULT_PORT' do
10
- let(:port) { RMuh::ServerStats::Base::DEFAULT_PORT }
11
-
12
- it 'should be an instance of Fixnum' do
13
- expect(port).to be_an_instance_of Fixnum
14
- end
15
-
16
- it 'should be the default ArmA 2 port' do
17
- expect(port).to eql 2_302
18
- end
19
- end
20
-
21
- context '::validate_opts' do
22
- let(:srv_hash) { { host: '127.0.0.1' } }
23
-
24
- it 'should take no more than one arg' do
25
- expect do
26
- RMuh::ServerStats::Base.validate_opts(nil, nil)
27
- end.to raise_error ArgumentError
28
- end
29
-
30
- it 'should take no less than one arg' do
31
- expect do
32
- RMuh::ServerStats::Base.validate_opts
33
- end.to raise_error ArgumentError
34
- end
35
-
36
- it 'should fail if arg 1 does not contain host' do
37
- expect do
38
- RMuh::ServerStats::Base.validate_opts({})
39
- end.to raise_error ArgumentError
40
- end
41
-
42
- it 'should set the default port if not provided' do
43
- h = srv_hash.dup
44
- RMuh::ServerStats::Base.validate_opts(h)
45
- expect(h.key?(:port)).to be_true
46
- expect(h[:port]).to eql RMuh::ServerStats::Base::DEFAULT_PORT
47
- end
48
-
49
- it 'should set the auto_cache key to true if not provided' do
50
- h = srv_hash.dup
51
- RMuh::ServerStats::Base.validate_opts(h)
52
- expect(h.key?(:auto_cache)).to be_true
53
- expect(h[:auto_cache]).to be_true
54
- end
55
-
56
- it 'should return nil' do
57
- x = RMuh::ServerStats::Base.validate_opts(host: '127.0.0.1')
58
- expect(x).to be_nil
59
- end
60
- end
61
-
62
- context '#opts_to_instance' do
63
- let(:b) { RMuh::ServerStats::Base.new(host: '127.0.0.1') }
64
-
65
- it 'should take no more than one arg' do
66
- expect do
67
- b.send(:opts_to_instance, nil, nil)
68
- end.to raise_error ArgumentError
69
- end
70
-
71
- it 'should take no less than one arg' do
72
- expect do
73
- b.send(:opts_to_instance)
74
- end.to raise_error ArgumentError
75
- end
76
-
77
- it 'should convert each key to an instance variable' do
78
- h = { one: 1, two: '2', three: :three }
79
- expect(b.instance_variable_get(:@one)).to be_nil
80
- expect(b.instance_variable_get(:@two)).to be_nil
81
- expect(b.instance_variable_get(:@three)).to be_nil
82
- b.send(:opts_to_instance, h)
83
- expect(b.instance_variable_get(:@one)).to eql h[:one]
84
- expect(b.instance_variable_get(:@two)).to eql h[:two]
85
- expect(b.instance_variable_get(:@three)).to eql h[:three]
86
- end
87
- end
88
-
89
- context '::new' do
90
- it 'should take no more than one arg' do
91
- expect do
92
- RMuh::ServerStats::Base.new(nil, nil)
93
- end.to raise_error ArgumentError
94
- end
95
-
96
- it 'should return an instance of itself if arg 1 is a Hash' do
97
- s = RMuh::ServerStats::Base.new(host: '127.0.0.1')
98
- expect(s).to be_an_instance_of RMuh::ServerStats::Base
99
- end
100
-
101
- it 'should require the host attribute' do
102
- expect do
103
- RMuh::ServerStats::Base.new({})
104
- end.to raise_error ArgumentError
105
- end
106
-
107
- it 'should set an instance variable for each thing in Hash' do
108
- h = { host: '1.2.3.4', port: 2_303, cache: false }
109
- s = RMuh::ServerStats::Base.new(h)
110
- expect(s.instance_variable_get(:@host)).to eql h[:host]
111
- expect(s.instance_variable_get(:@port)).to eql h[:port]
112
- expect(s.instance_variable_get(:@cache)).to eql h[:cache]
113
- end
114
-
115
- it 'should create an instance of GamespyQuery::Socket' do
116
- s = RMuh::ServerStats::Base.new(host: '127.0.0.1')
117
- x = s.instance_variable_get(:@gsq)
118
- expect(x).to be_an_instance_of GamespyQuery::Socket
119
- end
120
-
121
- it 'should specify default values for @port and @cache' do
122
- s = RMuh::ServerStats::Base.new(host: '127.0.0.1')
123
- expect(s.instance_variable_get(:@cache)).to be true
124
- expect(s.instance_variable_get(:@port)).to eql 2_302
125
- end
126
- end
127
-
128
- context '#sync' do
129
- before do
130
- GamespyQuery::Socket.any_instance.stub(:sync).and_return(one: 1)
131
- end
132
- let(:b) { RMuh::ServerStats::Base.new(host: '127.0.0.1') }
133
-
134
- it 'should take no args' do
135
- expect { b.send(:sync, nil) }.to raise_error ArgumentError
136
- end
137
-
138
- it 'should return a Hash' do
139
- expect(b.send(:sync)).to be_an_instance_of Hash
140
- end
141
- end
142
-
143
- context '#remote_stats' do
144
- let(:b) { RMuh::ServerStats::Base.new(host: '127.0.0.1') }
145
-
146
- it 'should take no args' do
147
- expect { b.send(:remote_stats, nil) }.to raise_error ArgumentError
148
- end
149
-
150
- it 'should return the content of @servicestats if cache == true' do
151
- b.instance_variable_set(:@serverstats, one: 'two')
152
- expect(b.send(:remote_stats)).to eql(one: 'two')
153
- end
154
-
155
- it 'should return the return value from the #sync method if cache true' do
156
- n = RMuh::ServerStats::Base.new(host: '127.0.0.1', cache: false)
157
- n.stub(:sync).and_return(one: 'two')
158
- expect(n.send(:remote_stats)).to eql(one: 'two')
159
- end
160
- end
161
-
162
- context '#update_cache' do
163
- before(:each) do
164
- @b = RMuh::ServerStats::Base.new(host: '127.0.0.1')
165
- @bf = RMuh::ServerStats::Base.new(host: '127.0.0.1', cache: false)
166
- @b.stub(:sync).and_return(one: 'two')
167
- @bf.stub(:sync).and_return(one: 'two')
168
- end
169
-
170
- it 'should take no args' do
171
- expect { @b.update_cache(nil) }.to raise_error ArgumentError
172
- end
173
-
174
- it 'should set the contents of @serverstats if caching' do
175
- @b.update_cache
176
- expect(@b.instance_variable_get(:@serverstats)).to eql(one: 'two')
177
- end
178
-
179
- it 'should not set the contents of @serverstats if no caching' do
180
- @bf.update_cache
181
- expect(@bf.instance_variable_get(:@serverstats)).to be_nil
182
- end
183
- end
184
-
185
- context '#stats' do
186
- before(:each) do
187
- @b = RMuh::ServerStats::Base.new(host: '127.0.0.1')
188
- @bf = RMuh::ServerStats::Base.new(host: '127.0.0.1', cache: false)
189
- @b.stub(:sync).and_return(one: 'two')
190
- @bf.stub(:sync).and_return(one: 'two')
191
- @b.update_cache
192
- end
193
-
194
- it 'should take no args' do
195
- expect { @b.stats(nil) }.to raise_error ArgumentError
196
- end
197
-
198
- it 'should return the contents of @serverstats if caching enabled' do
199
- expect(@b.stats).to eql @b.instance_variable_get(:@serverstats)
200
- end
201
-
202
- it 'should return the contents of sync if caching is disabled' do
203
- expect(@bf.stats).to eql(one: 'two')
204
- end
205
- end
10
+ it_should_behave_like 'RMuh::ServerStats::Base'
206
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rmuh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Heckman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-18 00:00:00.000000000 Z
11
+ date: 2014-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -252,6 +252,8 @@ files:
252
252
  - spec/rmuh_rpt_log_util_unitedoperationslog_spec.rb
253
253
  - spec/rmuh_rpt_log_util_unitedoperationsrpt_spec.rb
254
254
  - spec/rmuh_rpt_spec.rb
255
+ - spec/rmuh_serverstats_advanced_spec.rb
256
+ - spec/rmuh_serverstats_base.rb
255
257
  - spec/rmuh_serverstats_base_spec.rb
256
258
  homepage: https://github.com/theckman/rmuh
257
259
  licenses:
@@ -290,4 +292,6 @@ test_files:
290
292
  - spec/rmuh_rpt_log_util_unitedoperationslog_spec.rb
291
293
  - spec/rmuh_rpt_log_util_unitedoperationsrpt_spec.rb
292
294
  - spec/rmuh_rpt_spec.rb
295
+ - spec/rmuh_serverstats_advanced_spec.rb
296
+ - spec/rmuh_serverstats_base.rb
293
297
  - spec/rmuh_serverstats_base_spec.rb