david 0.4.5 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,7 +10,7 @@ describe Server do
10
10
  let!(:server) { supervised_server(:Port => port) }
11
11
 
12
12
  context 'ordinary request' do
13
- subject { client.get('/hello', '::1') }
13
+ subject { client.get('/hello', localhost) }
14
14
 
15
15
  it 'should be plausible' do
16
16
  expect(subject).to be_a(CoAP::Message)
@@ -22,7 +22,7 @@ describe Server do
22
22
  end
23
23
 
24
24
  context 'missing resource' do
25
- subject { client.get('/404', '::1') }
25
+ subject { client.get('/404', localhost) }
26
26
 
27
27
  it 'should be 4.04' do
28
28
  expect(subject).to be_a(CoAP::Message)
@@ -34,7 +34,7 @@ describe Server do
34
34
  end
35
35
 
36
36
  context 'unsupported method' do
37
- subject { client.delete('/hello', '::1') }
37
+ subject { client.delete('/hello', localhost) }
38
38
 
39
39
  it 'should be 4.05' do
40
40
  expect(subject).to be_a(CoAP::Message)
@@ -135,7 +135,7 @@ describe Server do
135
135
 
136
136
  context 'block' do
137
137
  context 'block2.more set' do
138
- subject { client.get('/', '::1', nil, nil, block2: 14) }
138
+ subject { client.get('/', localhost, nil, nil, block2: 14) }
139
139
 
140
140
  it 'should be an error' do
141
141
  expect(subject).to be_a(CoAP::Message)
@@ -154,7 +154,7 @@ describe Server do
154
154
  recv_timeout: 0.1
155
155
  end
156
156
 
157
- subject { client.get('/hello', '::1', nil, nil, block2: 16) }
157
+ subject { client.get('/hello', localhost, nil, nil, block2: 16) }
158
158
 
159
159
  it 'should be an error' do
160
160
  expect { subject }.to raise_error(Timeout::Error)
@@ -164,7 +164,7 @@ describe Server do
164
164
  context 'transfer' do
165
165
  subject do
166
166
  [0, 16].map do |x|
167
- client.get('/block', '::1', nil, nil, block2: x)
167
+ client.get('/block', localhost, nil, nil, block2: x)
168
168
  end
169
169
  end
170
170
 
@@ -178,7 +178,7 @@ describe Server do
178
178
 
179
179
  context 'accept' do
180
180
  context 'unset' do
181
- subject { client.get('/hello', '::1') }
181
+ subject { client.get('/hello', localhost) }
182
182
 
183
183
  it 'should return resource' do
184
184
  expect(subject).to be_a(CoAP::Message)
@@ -191,7 +191,7 @@ describe Server do
191
191
  end
192
192
 
193
193
  context 'default' do
194
- subject { client.get('/echo/accept', '::1') }
194
+ subject { client.get('/echo/accept', localhost) }
195
195
 
196
196
  it 'should return default' do
197
197
  expect(subject).to be_a(CoAP::Message)
@@ -204,7 +204,7 @@ describe Server do
204
204
  end
205
205
 
206
206
  context 'right' do
207
- subject { client.get('/echo/accept', '::1', nil, nil, accept: 40) }
207
+ subject { client.get('/echo/accept', localhost, nil, nil, accept: 40) }
208
208
 
209
209
  it 'should echo' do
210
210
  expect(subject).to be_a(CoAP::Message)
@@ -217,7 +217,7 @@ describe Server do
217
217
  end
218
218
 
219
219
  context 'wrong' do
220
- subject { client.get('/hello', '::1', nil, nil, accept: 40) }
220
+ subject { client.get('/hello', localhost, nil, nil, accept: 40) }
221
221
 
222
222
  it 'should be an error' do
223
223
  expect(subject).to be_a(CoAP::Message)
@@ -232,7 +232,7 @@ describe Server do
232
232
  context 'deduplication' do
233
233
  context 'duplicates' do
234
234
  let(:a) do
235
- ([0]*3).map { client.get('/value', '::1', nil, nil, mid: 1, token: 1) }
235
+ ([0]*3).map { client.get('/value', localhost, nil, nil, mid: 1, token: 1) }
236
236
  end
237
237
 
238
238
  it 'matching mid' do
@@ -253,7 +253,7 @@ describe Server do
253
253
 
254
254
  context 'different' do
255
255
  let(:a) do
256
- ([0]*3).map { client.get('/value', '::1') }
256
+ ([0]*3).map { client.get('/value', localhost) }
257
257
  end
258
258
 
259
259
  it 'matching mid' do
@@ -274,7 +274,7 @@ describe Server do
274
274
  end
275
275
 
276
276
  context 'proxy' do
277
- subject { client.get('/', '::1', nil, nil, proxy_uri: 'coap://[::1]/') }
277
+ subject { client.get('/', localhost, nil, nil, proxy_uri: 'coap://[::1]/') }
278
278
 
279
279
  it 'should return 5.05' do
280
280
  expect(subject).to be_a(CoAP::Message)
@@ -290,7 +290,7 @@ describe Server do
290
290
 
291
291
  let(:cbor) { {'Hello' => 'World!'}.to_cbor }
292
292
 
293
- subject { client.get('/cbor', '::1', nil, cbor, content_format: 60) }
293
+ subject { client.get('/cbor', localhost, nil, cbor, content_format: 60) }
294
294
 
295
295
  context 'incoming' do
296
296
  context 'string key' do
@@ -326,13 +326,13 @@ describe Server do
326
326
  expect(subject.ver).to eq(1)
327
327
  expect(subject.tt).to eq(:ack)
328
328
  expect(subject.mcode).to eq([2, 5])
329
- expect(subject.payload).to eq('{"Hello"=>"World!"}')
329
+ expect(subject.payload).to eq('{"Hello":"World!"}')
330
330
  end
331
331
  end
332
332
  end
333
333
 
334
334
  context 'outgoing' do
335
- subject { client.get('/json', '::1') }
335
+ subject { client.get('/json', localhost) }
336
336
 
337
337
  it 'should return CBOR' do
338
338
  expect(subject).to be_a(CoAP::Message)
@@ -21,6 +21,14 @@ module David
21
21
  @debug ||= ENV['DEBUG'].nil? ? 'none' : 'debug'
22
22
  end
23
23
 
24
+ def ipv4?
25
+ @ipv4 ||= !ENV['IPV4'].nil?
26
+ end
27
+
28
+ def localhost
29
+ ipv4? ? '127.0.0.1' : '::1'
30
+ end
31
+
24
32
  def random_port
25
33
  rand((2**10+1)..(2**16-1))
26
34
  end
@@ -30,20 +38,21 @@ module David
30
38
 
31
39
  payload = options.delete(:payload)
32
40
  port = options.delete(:port) || random_port
41
+ host = ipv4? ? '127.0.0.1' : '::1'
33
42
 
34
43
  options.merge!(mid: mid)
35
44
 
36
45
  client = CoAP::Client.new(retransmit: false, recv_timeout: 0.1,
37
46
  token: false)
38
47
 
39
- response = client.send(method, path, '::1', port, payload, options)
48
+ response = client.send(method, path, host, port, payload, options)
40
49
 
41
50
  [mid, response]
42
51
  end
43
52
 
44
53
  def supervised_server(options)
45
54
  defaults = {
46
- :Host => '::1',
55
+ :Host => localhost,
47
56
  :Port => CoAP::PORT,
48
57
  :Log => debug
49
58
  }
@@ -52,13 +61,15 @@ module David
52
61
 
53
62
  app = options.delete(:app) || Rack::HelloWorld
54
63
 
55
- g = Celluloid::SupervisionGroup.run!
64
+ g = Celluloid::Supervision::Container.run!
65
+
66
+ g.supervise(as: :server, type: ::David::Server,
67
+ args: [app, defaults.merge(options)])
56
68
 
57
- g.supervise_as(:server, ::David::Server, app, defaults.merge(options))
58
- g.supervise_as(:gc, ::David::GarbageCollector)
69
+ g.supervise(as: :gc, type: ::David::GarbageCollector)
59
70
 
60
71
  unless options[:Observe] == 'false'
61
- g.supervise_as(:observe, ::David::Observe)
72
+ g.supervise(as: :observe, type: ::David::Observe)
62
73
  end
63
74
 
64
75
  Celluloid::Actor[:server].async.run
metadata CHANGED
@@ -1,67 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: david
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - henning mueller
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-24 00:00:00.000000000 Z
11
+ date: 2016-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: celluloid
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: 0.16.0
20
- - - "<"
17
+ - - "~>"
21
18
  - !ruby/object:Gem::Version
22
- version: '0.17'
19
+ version: 0.17.3
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: 0.16.0
30
- - - "<"
24
+ - - "~>"
31
25
  - !ruby/object:Gem::Version
32
- version: '0.17'
26
+ version: 0.17.3
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: celluloid-io
35
29
  requirement: !ruby/object:Gem::Requirement
36
30
  requirements:
37
- - - ">="
38
- - !ruby/object:Gem::Version
39
- version: 0.16.1
40
- - - "<"
31
+ - - "~>"
41
32
  - !ruby/object:Gem::Version
42
- version: '0.17'
33
+ version: 0.17.3
43
34
  type: :runtime
44
35
  prerelease: false
45
36
  version_requirements: !ruby/object:Gem::Requirement
46
37
  requirements:
47
- - - ">="
48
- - !ruby/object:Gem::Version
49
- version: 0.16.1
50
- - - "<"
38
+ - - "~>"
51
39
  - !ruby/object:Gem::Version
52
- version: '0.17'
40
+ version: 0.17.3
53
41
  - !ruby/object:Gem::Dependency
54
42
  name: coap
55
43
  requirement: !ruby/object:Gem::Requirement
56
44
  requirements:
57
- - - ">="
45
+ - - "~>"
58
46
  - !ruby/object:Gem::Version
59
47
  version: '0.1'
60
48
  type: :runtime
61
49
  prerelease: false
62
50
  version_requirements: !ruby/object:Gem::Requirement
63
51
  requirements:
64
- - - ">="
52
+ - - "~>"
65
53
  - !ruby/object:Gem::Version
66
54
  version: '0.1'
67
55
  - !ruby/object:Gem::Dependency
@@ -70,26 +58,26 @@ dependencies:
70
58
  requirements:
71
59
  - - "~>"
72
60
  - !ruby/object:Gem::Version
73
- version: '1.6'
61
+ version: '2.0'
74
62
  type: :runtime
75
63
  prerelease: false
76
64
  version_requirements: !ruby/object:Gem::Requirement
77
65
  requirements:
78
66
  - - "~>"
79
67
  - !ruby/object:Gem::Version
80
- version: '1.6'
68
+ version: '2.0'
81
69
  - !ruby/object:Gem::Dependency
82
70
  name: rake
83
71
  requirement: !ruby/object:Gem::Requirement
84
72
  requirements:
85
- - - ">="
73
+ - - "~>"
86
74
  - !ruby/object:Gem::Version
87
75
  version: '0'
88
76
  type: :development
89
77
  prerelease: false
90
78
  version_requirements: !ruby/object:Gem::Requirement
91
79
  requirements:
92
- - - ">="
80
+ - - "~>"
93
81
  - !ruby/object:Gem::Version
94
82
  version: '0'
95
83
  - !ruby/object:Gem::Dependency
@@ -180,6 +168,7 @@ files:
180
168
  - lib/david/etsi/mandatory/hobbit.rb
181
169
  - lib/david/etsi/mandatory/nyny.rb
182
170
  - lib/david/etsi/mandatory/rack.rb
171
+ - lib/david/etsi/mandatory/roda.rb
183
172
  - lib/david/etsi/mandatory/sinatra.rb
184
173
  - lib/david/etsi/optional.rb
185
174
  - lib/david/etsi/optional/rack.rb
@@ -234,7 +223,6 @@ files:
234
223
  - spec/dummy/config/environments/development.rb
235
224
  - spec/dummy/config/environments/production.rb
236
225
  - spec/dummy/config/environments/test.rb
237
- - spec/dummy/config/initializers/assets.rb
238
226
  - spec/dummy/config/initializers/backtrace_silencers.rb
239
227
  - spec/dummy/config/initializers/cookies_serializer.rb
240
228
  - spec/dummy/config/initializers/filter_parameter_logging.rb
@@ -282,7 +270,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
282
270
  version: '0'
283
271
  requirements: []
284
272
  rubyforge_project:
285
- rubygems_version: 2.5.0
273
+ rubygems_version: 2.5.1
286
274
  signing_key:
287
275
  specification_version: 4
288
276
  summary: CoAP server with Rack interface.
@@ -312,7 +300,6 @@ test_files:
312
300
  - spec/dummy/config/environments/development.rb
313
301
  - spec/dummy/config/environments/production.rb
314
302
  - spec/dummy/config/environments/test.rb
315
- - spec/dummy/config/initializers/assets.rb
316
303
  - spec/dummy/config/initializers/backtrace_silencers.rb
317
304
  - spec/dummy/config/initializers/cookies_serializer.rb
318
305
  - spec/dummy/config/initializers/filter_parameter_logging.rb
@@ -1,8 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Version of your assets, change this if you want to expire all your assets.
4
- Rails.application.config.assets.version = '1.0'
5
-
6
- # Precompile additional assets.
7
- # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
8
- # Rails.application.config.assets.precompile += %w( search.js )