easy_upnp 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 020e9f4c2353eeff4aa98f9027fdb2a2dfbd383f960cfa09786e65a34935a9d1
4
- data.tar.gz: 51f151092a004bcd54e5774cea2633aa126b592165a2ee25599511697072c629
3
+ metadata.gz: 217e192e49ffaeda07523f9d727be2ad627a027c64b45693e50c9efb4058f46f
4
+ data.tar.gz: 62042fd87475783b47e1e4a3b0ebf76e2a7c804200a114c20631f8189c8546a1
5
5
  SHA512:
6
- metadata.gz: d482a6a9acc22cbc7750ec890b733156234ba7d8af6afde8aafd60182c62d22ce0ae2b5889649f16a607970ebccb30318cc779c899a810bc271cf5f506d08581
7
- data.tar.gz: 26cb2b3c2d07ed6f30c5554490824e486b47a20b7a1d915d1a9594a07b3d09157b1c01aea1f9d84c56843e6b187fdca9d622368d0194e1228dbf44932feaca32
6
+ metadata.gz: 9d2b91ed872a3176d78a1ef17225ded757500576ad830a177b8c571b4ee13f2204dd26d4a2e02066b62d487eabae2227d30c832df3d2dd2b09ca743d1dbc3e69
7
+ data.tar.gz: 3cf3e2649d7d2eff1a3ece29e6db5866cf943fd35e7c0a222f39319b86a325527c981122ffcfb857cdb3c7b9a83028aaced5f91a7295a94033bb70f0153af4d2
data/README.md CHANGED
@@ -55,6 +55,22 @@ service.GetSystemUpdateID
55
55
  # => {:Id=>"207"}
56
56
  ```
57
57
 
58
+ #### Get information about a specific device
59
+
60
+ ```ruby
61
+ device.description
62
+ # => { ... } # all available information
63
+
64
+ device.description['friendlyName']
65
+ # => "WeMo Switch"
66
+
67
+ device.description['deviceType']
68
+ # => "urn:Belkin:device:controllee:1"
69
+
70
+ device.description['serialNumber']
71
+ # => "221520K1100836"
72
+ ```
73
+
58
74
  ## Static client construction
59
75
 
60
76
  After you've constructed a client (`DeviceControlPoint`), you probably don't want to have to use SSDP to construct it again the next time you use it. `DeviceControlPoint` is equipped with `#to_params` and `#from_params` methods to make this easy.
@@ -35,7 +35,7 @@ if devices.any?
35
35
  printf "%30s %45s %s\n", "Name", "UUID", "Services"
36
36
 
37
37
  devices.each do |device|
38
- name = device.device_name rescue '*** Error fetching name ***'
38
+ name = device.description[:friendlyName] rescue '*** Error fetching name ***'
39
39
 
40
40
  printf "%30s %45s ", name, device.uuid
41
41
 
@@ -15,6 +15,7 @@ Gem::Specification.new do |gem|
15
15
  gem.add_dependency 'rake'
16
16
  gem.add_dependency 'savon', '~> 2.11'
17
17
  gem.add_dependency 'nokogiri', '~> 1.8'
18
+ gem.add_dependency 'nori', '~> 2.6'
18
19
  gem.add_dependency 'rubyntlm', '~> 0.3'
19
20
 
20
21
  gem.required_ruby_version = '>= 2.1.0'
@@ -1,5 +1,5 @@
1
1
  require 'uri'
2
- require 'nokogiri'
2
+ require 'nori'
3
3
  require 'open-uri'
4
4
  require 'savon'
5
5
 
@@ -37,8 +37,14 @@ module EasyUpnp
37
37
  @host ||= URI.parse(@service_definitions.first[:location]).host
38
38
  end
39
39
 
40
+ def description
41
+ @description ||= fetch_description
42
+ end
43
+
44
+ # @deprecated Use {#description['friendlyName']} instead of this method.
45
+ # It will be removed in the next major release.
40
46
  def device_name
41
- @device_name ||= fetch_device_name
47
+ @device_name ||= description['friendlyName']
42
48
  end
43
49
 
44
50
  def all_services
@@ -65,16 +71,14 @@ module EasyUpnp
65
71
 
66
72
  private
67
73
 
68
- def fetch_device_name
74
+ # @return [Hash]
75
+ def fetch_description
69
76
  if all_services.empty?
70
- raise RuntimeError, "Couldn't resolve device name because no endpoints are defined"
77
+ raise RuntimeError, "Couldn't resolve device description because no endpoints are defined"
71
78
  end
72
79
 
73
- document = open(service_definition(all_services.first)[:location]) { |f| f.read }
74
- xml = Nokogiri::XML(document)
75
- xml.remove_namespaces!
76
-
77
- xml.xpath("//device/friendlyName").text
80
+ location = service_definition(all_services.first)[:location]
81
+ Nori.new.parse(open(location) { |f| f.read })['root']['device']
78
82
  end
79
83
  end
80
84
  end
@@ -1,3 +1,3 @@
1
1
  module EasyUpnp
2
- VERSION = '1.2.1'
2
+ VERSION = '1.2.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy_upnp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Mullins
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-04 00:00:00.000000000 Z
11
+ date: 2018-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.8'
55
+ - !ruby/object:Gem::Dependency
56
+ name: nori
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.6'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.6'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rubyntlm
57
71
  requirement: !ruby/object:Gem::Requirement