coap 0.1.1 → 0.1.2
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 +4 -4
- data/README.md +13 -3
- data/coap.gemspec +1 -1
- data/lib/core/coap/client.rb +2 -0
- data/lib/core/coap/resolver.rb +2 -2
- data/lib/core/coap/transmission.rb +2 -1
- data/lib/core/coap/version.rb +1 -1
- data/spec/client_spec.rb +8 -6
- data/spec/resolver_spec.rb +16 -9
- data/spec/transmission_spec.rb +2 -4
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4fa88769ab252aa9e46a96259925a550baa4b31
|
4
|
+
data.tar.gz: d44c5df8e6655814f7c94ff9154556f74e26dc7b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfc70277f16981ea5418b8e4a445761ae49d47c6379d1027a36380f87b1001ee29890eeb4df8e87068b09a6667374633908e07f9b81505c834eae5603aba8d53
|
7
|
+
data.tar.gz: 1642b287ef80007426bee50b503c5c8cf3859e9e31d426384a09da99c5c42993ec532464b1bc9c4a846f868b961fbc5272070f5d4a480e9de97614ad5aa81bd2
|
data/README.md
CHANGED
@@ -40,14 +40,24 @@ Or install it yourself as:
|
|
40
40
|
|
41
41
|
## Usage
|
42
42
|
|
43
|
-
### In your
|
43
|
+
### In your Application
|
44
44
|
|
45
45
|
require 'coap'
|
46
|
+
|
46
47
|
CoAP::Client.new.get_by_uri('coap://coap.me/hello').payload
|
48
|
+
=> "world"
|
49
|
+
|
50
|
+
CoAP::Client.new.get('/hello', 'coap.me')
|
51
|
+
=> #<struct CoRE::CoAP::Message ver=1, tt=:ack, mcode=[2, 5], mid=51490, options={:max_age=>60, :token=>366862489, :content_format=>0}, payload="world">
|
52
|
+
|
53
|
+
c = CoAP::Client.new(host: 'coap.me')
|
54
|
+
c.get('/hello')
|
47
55
|
|
48
|
-
See
|
56
|
+
See [the API documentation at
|
57
|
+
rubydoc.info](http://www.rubydoc.info/github/nning/coap/master/CoRE/CoAP/Client)
|
58
|
+
or `test/test_client.rb` for more examples.
|
49
59
|
|
50
|
-
### Command Line
|
60
|
+
### On the Command Line
|
51
61
|
|
52
62
|
The command line client supports the basic CoAP methods.
|
53
63
|
|
data/coap.gemspec
CHANGED
@@ -33,6 +33,6 @@ Gem::Specification.new do |s|
|
|
33
33
|
s.add_development_dependency 'rake', '~> 10.3'
|
34
34
|
s.add_development_dependency 'rspec', '~> 3.0'
|
35
35
|
|
36
|
-
s.add_dependency 'celluloid-io', '
|
36
|
+
s.add_dependency 'celluloid-io', '>= 0.16.1', '< 0.17'
|
37
37
|
s.add_dependency 'resolv-ipv6favor', '~> 0'
|
38
38
|
end
|
data/lib/core/coap/client.rb
CHANGED
@@ -217,6 +217,8 @@ module CoRE
|
|
217
217
|
# Preserve user options.
|
218
218
|
message.options[:block2] = options[:block2] unless options[:block2] == nil
|
219
219
|
message.options[:observe] = options[:observe] unless options[:observe] == nil
|
220
|
+
|
221
|
+
options.delete(:block1)
|
220
222
|
message.options.merge!(options)
|
221
223
|
|
222
224
|
log_message(:sending_message, message)
|
data/lib/core/coap/resolver.rb
CHANGED
@@ -11,6 +11,7 @@ module CoRE
|
|
11
11
|
@max_retransmit = options[:max_retransmit] || 4
|
12
12
|
@recv_timeout = options[:recv_timeout] || DEFAULT_RECV_TIMEOUT
|
13
13
|
@socket = options[:socket]
|
14
|
+
@force_ipv6 = !!options[:force_ipv6]
|
14
15
|
|
15
16
|
@retransmit = if options[:retransmit].nil?
|
16
17
|
true
|
@@ -128,7 +129,7 @@ module CoRE
|
|
128
129
|
end
|
129
130
|
# MRI throws IPAddr::InvalidAddressError, JRuby an ArgumentError
|
130
131
|
rescue ArgumentError
|
131
|
-
host = Resolver.address(host)
|
132
|
+
host = Resolver.address(host, options[:force_ipv6])
|
132
133
|
retry
|
133
134
|
end
|
134
135
|
|
data/lib/core/coap/version.rb
CHANGED
data/spec/client_spec.rb
CHANGED
@@ -17,6 +17,8 @@ describe Client do
|
|
17
17
|
|
18
18
|
describe 'modifying methods' do
|
19
19
|
subject { Client.new(max_payload: 512) }
|
20
|
+
|
21
|
+
let(:host) { 'coap.me' }
|
20
22
|
let(:payload) { Faker::Lorem.paragraphs(5).join("\n") }
|
21
23
|
let(:payload_utf8) { '♥' + payload }
|
22
24
|
|
@@ -24,19 +26,19 @@ describe Client do
|
|
24
26
|
describe 'with block1 option' do
|
25
27
|
describe 'creating resource' do
|
26
28
|
it 'should work with ASCII payload' do
|
27
|
-
answer = subject.post('/large-create',
|
29
|
+
answer = subject.post('/large-create', host, nil, payload)
|
28
30
|
expect(answer.mcode).to eq([2, 1])
|
29
31
|
|
30
|
-
answer = subject.get('/large-create',
|
32
|
+
answer = subject.get('/large-create', host)
|
31
33
|
expect(answer.mcode).to eq([2, 5])
|
32
34
|
expect(answer.payload).to eq(payload)
|
33
35
|
end
|
34
36
|
|
35
37
|
it 'should work with UTF8 payload' do
|
36
|
-
answer = subject.post('/large-create',
|
38
|
+
answer = subject.post('/large-create', host, nil, payload_utf8)
|
37
39
|
expect(answer.mcode).to eq([2, 1])
|
38
40
|
|
39
|
-
answer = subject.get('/large-create',
|
41
|
+
answer = subject.get('/large-create', host)
|
40
42
|
expect(answer.mcode).to eq([2, 5])
|
41
43
|
expect(answer.payload.force_encoding('utf-8')).to eq(payload_utf8)
|
42
44
|
end
|
@@ -48,10 +50,10 @@ describe Client do
|
|
48
50
|
describe 'with block1 option' do
|
49
51
|
describe 'updating resource' do
|
50
52
|
it 'should work with ASCII payload' do
|
51
|
-
answer = subject.put('/large-update',
|
53
|
+
answer = subject.put('/large-update', host, nil, payload)
|
52
54
|
expect(answer.mcode).to eq([2, 4])
|
53
55
|
|
54
|
-
answer = subject.get('/large-update',
|
56
|
+
answer = subject.get('/large-update', host)
|
55
57
|
expect(answer.mcode).to eq([2, 5])
|
56
58
|
expect(answer.payload).to eq(payload)
|
57
59
|
end
|
data/spec/resolver_spec.rb
CHANGED
@@ -1,19 +1,26 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Resolver do
|
4
|
-
|
5
|
-
|
6
|
-
subject { IPAddr.new(Resolver.address('orgizm.net')) }
|
4
|
+
context 'ipv6' do
|
5
|
+
subject { IPAddr.new(Resolver.address('orgizm.net', true)) }
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
end
|
7
|
+
it { expect { subject }.not_to raise_error }
|
8
|
+
it { expect(subject.ipv6?).to be(true) }
|
11
9
|
end
|
12
10
|
|
13
11
|
context 'ipv4' do
|
14
|
-
|
12
|
+
context 'from dns' do
|
13
|
+
subject { IPAddr.new(Resolver.address('ipv4.orgizm.net')) }
|
15
14
|
|
16
|
-
|
17
|
-
|
15
|
+
it { expect { subject }.not_to raise_error }
|
16
|
+
it { expect(subject.ipv4?).to be(true) }
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'default' do
|
20
|
+
subject { IPAddr.new(Resolver.address('orgizm.net')) }
|
21
|
+
|
22
|
+
it { expect { subject }.not_to raise_error }
|
23
|
+
it { expect(subject.ipv4?).to be(true) }
|
24
|
+
end
|
18
25
|
end
|
19
26
|
end
|
data/spec/transmission_spec.rb
CHANGED
@@ -59,10 +59,8 @@ describe Transmission do
|
|
59
59
|
expect(Transmission.from_host('ipv4.orgizm.net').ipv6?).to be(false)
|
60
60
|
end
|
61
61
|
|
62
|
-
|
63
|
-
|
64
|
-
expect(Transmission.from_host('orgizm.net').ipv6?).to be(true)
|
65
|
-
end
|
62
|
+
it 'ipv6' do
|
63
|
+
expect(Transmission.from_host('orgizm.net', force_ipv6: true).ipv6?).to be(true)
|
66
64
|
end
|
67
65
|
end
|
68
66
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carsten Bormann
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-
|
13
|
+
date: 2015-10-17 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -100,22 +100,22 @@ dependencies:
|
|
100
100
|
name: celluloid-io
|
101
101
|
requirement: !ruby/object:Gem::Requirement
|
102
102
|
requirements:
|
103
|
-
- - "~>"
|
104
|
-
- !ruby/object:Gem::Version
|
105
|
-
version: '0.16'
|
106
103
|
- - ">="
|
107
104
|
- !ruby/object:Gem::Version
|
108
105
|
version: 0.16.1
|
106
|
+
- - "<"
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0.17'
|
109
109
|
type: :runtime
|
110
110
|
prerelease: false
|
111
111
|
version_requirements: !ruby/object:Gem::Requirement
|
112
112
|
requirements:
|
113
|
-
- - "~>"
|
114
|
-
- !ruby/object:Gem::Version
|
115
|
-
version: '0.16'
|
116
113
|
- - ">="
|
117
114
|
- !ruby/object:Gem::Version
|
118
115
|
version: 0.16.1
|
116
|
+
- - "<"
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0.17'
|
119
119
|
- !ruby/object:Gem::Dependency
|
120
120
|
name: resolv-ipv6favor
|
121
121
|
requirement: !ruby/object:Gem::Requirement
|
@@ -207,7 +207,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
207
207
|
version: '0'
|
208
208
|
requirements: []
|
209
209
|
rubyforge_project:
|
210
|
-
rubygems_version: 2.
|
210
|
+
rubygems_version: 2.5.0
|
211
211
|
signing_key:
|
212
212
|
specification_version: 4
|
213
213
|
summary: Pure Ruby implementation of RFC 7252 (Constrained Application Protocol (CoAP))
|