easy_upnp 0.1.2 → 0.1.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 +4 -4
- data/.gitignore +3 -0
- data/README.md +14 -0
- data/lib/easy_upnp/device_control_point.rb +15 -5
- data/lib/easy_upnp/upnp_device.rb +4 -0
- data/lib/easy_upnp/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9f368715acba835a38294efd1ec026e8e53400e
|
4
|
+
data.tar.gz: 309a486292c2ce750fe1a25bb3b5bb6af30cba06
|
5
5
|
!binary "U0hBNTEy":
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 312b61519e68d976d089b7195fe2aad9dd57d5d5f35bcf5bfd9c615c3bb4049ba37edbba3baae0d10e8e4db69536fe5f0da1cd5dc38de322a571fcb912686efa
|
7
|
+
data.tar.gz: 8d1cdd7f049db09b24f29cfb49b3f2f79c9d5378550ecc86649f8394b625a3d2d405eebb0216c6eed685dbd798cf14512ce1083d52f03dc4b044bf84e6845b5e
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,2 +1,16 @@
|
|
1
1
|
# easy_upnp
|
2
2
|
A super simple UPnP control point client for Ruby
|
3
|
+
|
4
|
+
## Installing
|
5
|
+
|
6
|
+
easy_upnp is available on [Rubygems](https://rubygems.org). You can install it with:
|
7
|
+
|
8
|
+
```
|
9
|
+
$ gem install easy_upnp
|
10
|
+
```
|
11
|
+
|
12
|
+
You can also add it to your Gemfile:
|
13
|
+
|
14
|
+
```
|
15
|
+
gem 'easy_upnp'
|
16
|
+
```
|
@@ -4,21 +4,26 @@ require 'nori'
|
|
4
4
|
|
5
5
|
module EasyUpnp
|
6
6
|
class DeviceControlPoint
|
7
|
-
|
7
|
+
attr_reader :service_methods
|
8
|
+
|
9
|
+
def initialize(client, service_type, definition_url)
|
8
10
|
@client = client
|
9
11
|
@service_type = service_type
|
10
12
|
|
13
|
+
service_methods = []
|
11
14
|
definition = Nokogiri::XML(open(definition_url))
|
12
15
|
definition.remove_namespaces!
|
13
16
|
|
14
17
|
definition.xpath('//actionList/action').map do |action|
|
15
|
-
define_action
|
18
|
+
service_methods.push define_action(action)
|
16
19
|
end
|
20
|
+
|
21
|
+
@service_methods = service_methods
|
17
22
|
end
|
18
23
|
|
19
24
|
private
|
20
25
|
|
21
|
-
def define_action
|
26
|
+
def define_action(action)
|
22
27
|
action = Nori.new.parse(action.to_xml)['action']
|
23
28
|
action_name = action['name']
|
24
29
|
args = action['argumentList']['argument']
|
@@ -31,8 +36,11 @@ module EasyUpnp
|
|
31
36
|
reject { |x| x['direction'] != 'out' }.
|
32
37
|
map { |x| x['name'].to_sym }
|
33
38
|
|
34
|
-
define_singleton_method(action['name']) do |args_hash|
|
35
|
-
if
|
39
|
+
define_singleton_method(action['name']) do |args_hash = {}|
|
40
|
+
if !args_hash.is_a? Hash
|
41
|
+
raise RuntimeError.new "Input arg must be a hash"
|
42
|
+
elsif
|
43
|
+
(args_hash.keys - input_args).any?
|
36
44
|
raise RuntimeError.new "Unsupported arguments: #{(args_hash.keys - input_args)}." <<
|
37
45
|
" Supported args: #{input_args}"
|
38
46
|
end
|
@@ -64,6 +72,8 @@ module EasyUpnp
|
|
64
72
|
|
65
73
|
output
|
66
74
|
end
|
75
|
+
|
76
|
+
action['name']
|
67
77
|
end
|
68
78
|
|
69
79
|
# This is included in ActiveSupport, but don't want to pull that in for just this method...
|
data/lib/easy_upnp/version.rb
CHANGED