doxie-scanner 1.1.0 → 1.2.0
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 +9 -0
- data/doxie-scanner.gemspec +4 -4
- data/lib/doxie/scanner.rb +18 -0
- data/spec/doxie/scanner_spec.rb +54 -21
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40d9bc6a4652f5e0583fa1afa774bd4da8923d73478b7da3eac9412767d2a5f8
|
4
|
+
data.tar.gz: 6d6e799b5bb6420d97dd6efd284ca7cdef53bd31a565c54c285730da0478ab90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd4bbddd1fb17295e71de69a64d1e4ce9de5961233eb6df7ba13d49ac651be6b788d42aa0f3b4101b107b376c5218e23fd788ceb63c74977aa6f7ee1b390a3bd
|
7
|
+
data.tar.gz: 6abc7acd5698f9b4c655898e5b226104bb5e16e589fed90e0f4f9033d5f2fccb986889c1f12ef8ca2ae6db4555e45d7e982c7fcf7aa734116756a27d65494ea8
|
data/README.md
CHANGED
@@ -26,6 +26,15 @@ Doxie::Scanner.ips
|
|
26
26
|
]
|
27
27
|
```
|
28
28
|
|
29
|
+
For usage with the [Doxie client library](https://github.com/cbetta/doxie) you can use the `.devices` method to automatically detect the model number and IP.
|
30
|
+
|
31
|
+
```rb
|
32
|
+
require 'doxie'
|
33
|
+
require 'doxie/scanner'
|
34
|
+
|
35
|
+
client = Doxie::Client.new(Doxie::Scanner.devices.first)
|
36
|
+
```
|
37
|
+
|
29
38
|
## Contributing
|
30
39
|
|
31
40
|
1. **Fork** the repo on GitHub
|
data/doxie-scanner.gemspec
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'doxie-scanner'
|
3
|
-
s.version = '1.
|
4
|
-
s.summary = "A simple scanner for your Doxie
|
5
|
-
s.description = "A simple scanner for your Doxie
|
3
|
+
s.version = '1.2.0'
|
4
|
+
s.summary = "A simple scanner for your Wifi enabled Doxie scanner"
|
5
|
+
s.description = "A simple scanner for your Wifi enabled Doxie scanner"
|
6
6
|
s.authors = ["Cristiano Betta"]
|
7
|
-
s.email = '
|
7
|
+
s.email = 'cristiano@betta.io'
|
8
8
|
s.files = Dir.glob('{lib,spec}/**/*') + %w(LICENSE README.md doxie-scanner.gemspec)
|
9
9
|
s.homepage = 'https://github.com/cbetta/doxie-scanner'
|
10
10
|
s.license = 'MIT'
|
data/lib/doxie/scanner.rb
CHANGED
@@ -8,5 +8,23 @@ module Doxie
|
|
8
8
|
hosts = doxies.map {|doxie| URI.parse(doxie[:location]).host }
|
9
9
|
hosts.uniq
|
10
10
|
end
|
11
|
+
|
12
|
+
def self.devices(frisky = Frisky::SSDP)
|
13
|
+
root_devices = frisky.search 'upnp:rootdevices'
|
14
|
+
doxies = root_devices.select { |device| device[:location].include?('doxie')}
|
15
|
+
hosts = doxies.map do |doxie|
|
16
|
+
{
|
17
|
+
ip: URI.parse(doxie[:location]).host,
|
18
|
+
model: Doxie::Scanner.api_version(doxie[:server])
|
19
|
+
}
|
20
|
+
end
|
21
|
+
hosts.uniq
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def self.api_version server
|
27
|
+
server.include?('DX250') ? "API_V1" : "API_V2"
|
28
|
+
end
|
11
29
|
end
|
12
30
|
end
|
data/spec/doxie/scanner_spec.rb
CHANGED
@@ -4,32 +4,65 @@ require 'doxie/scanner'
|
|
4
4
|
describe 'Doxie::Scanner' do
|
5
5
|
before do
|
6
6
|
@frisky = Minitest::Mock.new
|
7
|
-
@return_value = []
|
8
7
|
@args = ['upnp:rootdevices']
|
8
|
+
@return_value = []
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
describe '.ips' do
|
12
|
+
it 'should search for upnp:rootdevices' do
|
13
|
+
@frisky.expect :search, @return_value, @args
|
14
|
+
ips = Doxie::Scanner.ips(@frisky)
|
15
|
+
@frisky.verify
|
16
|
+
assert_equal ips, @return_value
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should extract the host names for doxie devices' do
|
20
|
+
@frisky.expect :search, [
|
21
|
+
{ location: "http://127.0.0.1/doxie/foo" },
|
22
|
+
{ location: "http://127.0.0.2/doksy/foo" },
|
23
|
+
], @args
|
24
|
+
ips = Doxie::Scanner.ips(@frisky)
|
25
|
+
assert_equal ips, ['127.0.0.1']
|
26
|
+
end
|
17
27
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
28
|
+
it 'should only find unique host names' do
|
29
|
+
@frisky.expect :search, [
|
30
|
+
{ location: "http://127.0.0.1/doxie/foo" },
|
31
|
+
{ location: "http://127.0.0.1/doxie/foo" },
|
32
|
+
], @args
|
33
|
+
ips = Doxie::Scanner.ips(@frisky)
|
34
|
+
assert_equal ips.length, 1
|
35
|
+
end
|
25
36
|
end
|
26
37
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
38
|
+
describe '.devices' do
|
39
|
+
it 'should search for upnp:rootdevices' do
|
40
|
+
@frisky.expect :search, @return_value, @args
|
41
|
+
devices = Doxie::Scanner.devices(@frisky)
|
42
|
+
@frisky.verify
|
43
|
+
assert_equal devices, @return_value
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should extract the host names and api version number for doxie devices' do
|
47
|
+
@frisky.expect :search, [
|
48
|
+
{ location: "http://127.0.0.1/doxie/foo", server: 'Linux/2.6.30.9, UPnP/1.0, DoxieDX300/1.08' },
|
49
|
+
{ location: "http://127.0.0.2/doxie/foo", server: 'Linux/2.6.30.9, UPnP/1.0, DoxieDX250/1.08' },
|
50
|
+
{ location: "http://127.0.0.3/noxie/foo", server: 'Linux/2.6.30.9, UPnP/1.0, Noxie/1.08' },
|
51
|
+
], @args
|
52
|
+
devices = Doxie::Scanner.devices(@frisky)
|
53
|
+
assert_equal devices, [
|
54
|
+
{ ip: '127.0.0.1', model: 'API_V2' },
|
55
|
+
{ ip: '127.0.0.2', model: 'API_V1' },
|
56
|
+
]
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should only find unique host names' do
|
60
|
+
@frisky.expect :search, [
|
61
|
+
{ location: "http://127.0.0.1/doxie/foo", server: 'Linux/2.6.30.9, UPnP/1.0, DoxieDX300/1.08' },
|
62
|
+
{ location: "http://127.0.0.1/doxie/foo", server: 'Linux/2.6.30.9, UPnP/1.0, DoxieDX300/1.08' },
|
63
|
+
], @args
|
64
|
+
devices = Doxie::Scanner.devices(@frisky)
|
65
|
+
assert_equal devices.length, 1
|
66
|
+
end
|
34
67
|
end
|
35
68
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: doxie-scanner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cristiano Betta
|
@@ -52,8 +52,8 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
description: A simple scanner for your Doxie
|
56
|
-
email:
|
55
|
+
description: A simple scanner for your Wifi enabled Doxie scanner
|
56
|
+
email: cristiano@betta.io
|
57
57
|
executables: []
|
58
58
|
extensions: []
|
59
59
|
extra_rdoc_files: []
|
@@ -86,5 +86,5 @@ requirements: []
|
|
86
86
|
rubygems_version: 3.0.2
|
87
87
|
signing_key:
|
88
88
|
specification_version: 4
|
89
|
-
summary: A simple scanner for your Doxie
|
89
|
+
summary: A simple scanner for your Wifi enabled Doxie scanner
|
90
90
|
test_files: []
|