easy_upnp 0.2.5 → 0.3.1
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 +12 -0
- data/lib/easy_upnp/device_control_point.rb +38 -8
- data/lib/easy_upnp/upnp_device.rb +2 -2
- data/lib/easy_upnp/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 09a7cd37e19fa3000aba9c64319d21705c2baec4
|
4
|
+
data.tar.gz: 4bd49da3316961699db45017841c6ec125c07114
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8727fe45dbd3888450c601afff69901ab18493d839afd49a4f6e1a460c1b29ad292ab0d4dba86d4ba7fea1f2fb03dbc033389032a7a713ff6f02aedd5c455d2
|
7
|
+
data.tar.gz: c1a7e693d5ce5b119e793a29f5f8cc1f1835d1430509fbb2a7e3000e121385d3b49c745289b8e6b452a20df01e1d24a3ac908f4591968a4084c98ad051eccf13
|
data/README.md
CHANGED
@@ -72,3 +72,15 @@ client = EasyUpnp::DeviceControlPoint.from_params(params)
|
|
72
72
|
client.GetSystemUpdateID
|
73
73
|
=> {:Id=>"258"}
|
74
74
|
```
|
75
|
+
|
76
|
+
## Logging
|
77
|
+
|
78
|
+
By default, logs will be printed to `$stdout` at the `:info` level. To change this behavior, you can use the following:
|
79
|
+
|
80
|
+
```ruby
|
81
|
+
# Disable logging
|
82
|
+
EasyUpnp::Log.enabled = false
|
83
|
+
|
84
|
+
# Change log level (only has an effect if logging is enabled)
|
85
|
+
EasyUpnp::Log.level = :debug
|
86
|
+
```
|
@@ -8,11 +8,36 @@ module EasyUpnp
|
|
8
8
|
class DeviceControlPoint
|
9
9
|
attr_reader :service_methods, :service_endpoint
|
10
10
|
|
11
|
-
|
11
|
+
class Options
|
12
|
+
DEFAULTS = {
|
13
|
+
advanced_typecasting: true
|
14
|
+
}
|
15
|
+
|
16
|
+
attr_reader :options
|
17
|
+
|
18
|
+
def initialize(o = {}, &block)
|
19
|
+
@options = o.merge(DEFAULTS)
|
20
|
+
|
21
|
+
@options.map do |k, v|
|
22
|
+
define_singleton_method(k) do
|
23
|
+
@options[k]
|
24
|
+
end
|
25
|
+
|
26
|
+
define_singleton_method("#{k}=") do |v|
|
27
|
+
@options[k] = v
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
block.call(self) unless block.nil?
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def initialize(urn, service_endpoint, definition, call_options, &block)
|
12
36
|
@urn = urn
|
13
37
|
@service_endpoint = service_endpoint
|
14
|
-
@
|
38
|
+
@call_options = call_options
|
15
39
|
@definition = definition
|
40
|
+
@options = Options.new(&block)
|
16
41
|
|
17
42
|
@client = Savon.client(log: EasyUpnp::Log.enabled?, log_level: EasyUpnp::Log.level) do |c|
|
18
43
|
c.endpoint service_endpoint
|
@@ -44,7 +69,8 @@ module EasyUpnp
|
|
44
69
|
urn: @urn,
|
45
70
|
service_endpoint: @service_endpoint,
|
46
71
|
definition: @definition,
|
47
|
-
|
72
|
+
call_options: @call_options,
|
73
|
+
options: @options.options
|
48
74
|
}
|
49
75
|
end
|
50
76
|
|
@@ -53,11 +79,13 @@ module EasyUpnp
|
|
53
79
|
params[:urn],
|
54
80
|
params[:service_endpoint],
|
55
81
|
params[:definition],
|
56
|
-
params[:
|
57
|
-
)
|
82
|
+
params[:call_options]
|
83
|
+
) { |c|
|
84
|
+
params[:options].map { |k, v| c.options[k] = v }
|
85
|
+
}
|
58
86
|
end
|
59
87
|
|
60
|
-
def self.from_service_definition(definition,
|
88
|
+
def self.from_service_definition(definition, call_options = {}, &block)
|
61
89
|
urn = definition[:st]
|
62
90
|
root_uri = definition[:location]
|
63
91
|
|
@@ -77,7 +105,8 @@ module EasyUpnp
|
|
77
105
|
urn,
|
78
106
|
URI.join(root_uri, service.xpath('service/controlURL').text).to_s,
|
79
107
|
service_definition,
|
80
|
-
|
108
|
+
call_options,
|
109
|
+
&block
|
81
110
|
)
|
82
111
|
end
|
83
112
|
end
|
@@ -114,9 +143,10 @@ module EasyUpnp
|
|
114
143
|
attributes: {
|
115
144
|
:'xmlns:u' => @urn
|
116
145
|
},
|
117
|
-
}.merge(@
|
146
|
+
}.merge(@call_options)
|
118
147
|
|
119
148
|
response = @client.call action['name'], attrs do
|
149
|
+
advanced_typecasting @options.advanced_typecasting
|
120
150
|
message(args_hash)
|
121
151
|
end
|
122
152
|
|
@@ -53,11 +53,11 @@ module EasyUpnp
|
|
53
53
|
!service_definition(urn).nil?
|
54
54
|
end
|
55
55
|
|
56
|
-
def service(urn, options = {})
|
56
|
+
def service(urn, options = {}, &block)
|
57
57
|
definition = service_definition(urn)
|
58
58
|
|
59
59
|
if !definition.nil?
|
60
|
-
DeviceControlPoint.from_service_definition(definition, options)
|
60
|
+
DeviceControlPoint.from_service_definition(definition, options, &block)
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
data/lib/easy_upnp/version.rb
CHANGED
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: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christopher Mullins
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|