easy_upnp 1.1.5 → 1.1.6

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
  SHA1:
3
- metadata.gz: 9209faea08950a09fa2eef669db9699df33261ae
4
- data.tar.gz: f5c2205e3f58bb10ebb08f704c606519f80f87da
3
+ metadata.gz: c66af83dcc88342a62f3853bc9645da68d853efe
4
+ data.tar.gz: 709d7760d76927f10218e1cc409d88881d28b6b1
5
5
  SHA512:
6
- metadata.gz: 9151ea10e480a8323983dcf386d7977e32b4fb9b2a8a0bf1e075bd62dce7578258da25bb8ea52435fcc8f933a5319926486dd7a8a80240ce49b2e9f7540440ad
7
- data.tar.gz: 0a11da3fb37f4a3d0fb7cc596ad680212ced68d3612ecc8e8d1a6be0642d7451fdc4767ffccd1690618a3eb492dc4875946597ea2ef25eb79e99d1a06770bb92
6
+ metadata.gz: 254d60281f8155868cc274cc367d2b1c3800384e01a4b371a43fdf1612d4cc07b58bda99f25275de66b1b1c1fb402deea785957283cff8b281498aaa9e9ef3b8
7
+ data.tar.gz: b4a9f81494418c9bb837fa09efb8f5f53d7d2f35bbae1137d458ebdb22c087893ef85ca325820ce166c95f63788adbe90bd66e0d133a67ea1313c0ca9e5ea7bd
@@ -1,5 +1,3 @@
1
- require_relative '../options_base'
2
-
3
1
  module EasyUpnp
4
2
  class ClientWrapper
5
3
  def initialize(endpoint,
@@ -2,15 +2,13 @@ require 'nokogiri'
2
2
  require 'open-uri'
3
3
  require 'nori'
4
4
 
5
- require_relative '../options_base'
5
+ require 'easy_upnp/control_point/validator_provider'
6
+ require 'easy_upnp/control_point/client_wrapper'
7
+ require 'easy_upnp/control_point/service_method'
6
8
 
7
- require_relative 'validator_provider'
8
- require_relative 'client_wrapper'
9
- require_relative 'service_method'
10
-
11
- require_relative '../events/event_client'
12
- require_relative '../events/http_listener'
13
- require_relative '../events/subscription_manager'
9
+ require 'easy_upnp/events/event_client'
10
+ require 'easy_upnp/events/http_listener'
11
+ require 'easy_upnp/events/subscription_manager'
14
12
 
15
13
  module EasyUpnp
16
14
  class DeviceControlPoint
@@ -1,4 +1,4 @@
1
- require_relative 'argument_validator'
1
+ require 'easy_upnp/control_point/argument_validator'
2
2
 
3
3
  module EasyUpnp
4
4
  module ValidatorProvider
@@ -1,7 +1,5 @@
1
1
  require 'net/http'
2
2
 
3
- require_relative '../options_base'
4
-
5
3
  module EasyUpnp
6
4
  class EventClient
7
5
  class SubscriptionError < StandardError; end
@@ -0,0 +1,14 @@
1
+ require 'nokogiri'
2
+
3
+ module EasyUpnp
4
+ class EventParser
5
+ def parse(event_xml)
6
+ x = Nokogiri::XML(event_xml)
7
+ prop_changes = x.xpath('//e:propertyset/e:property/*', e: 'urn:schemas-upnp-org:event-1-0').map do |n|
8
+ [n.name.to_sym, n.text]
9
+ end
10
+
11
+ Hash[prop_changes]
12
+ end
13
+ end
14
+ end
@@ -1,7 +1,7 @@
1
1
  require 'webrick'
2
2
  require 'thread'
3
3
 
4
- require_relative '../options_base'
4
+ require 'easy_upnp/events/event_parser'
5
5
 
6
6
  module EasyUpnp
7
7
  class HttpListener
@@ -15,8 +15,10 @@ module EasyUpnp
15
15
  # interfaces.
16
16
  bind_address: '0.0.0.0',
17
17
 
18
- # By default, event callback just prints the request body
19
- callback: ->(request) { puts request.body }
18
+ # By default, event callback just prints the changed state vars
19
+ callback: ->(state_vars) {
20
+ puts state_vars.inspect
21
+ }
20
22
  }
21
23
 
22
24
  def initialize(options)
@@ -67,10 +69,11 @@ module EasyUpnp
67
69
  class NotifyServlet < WEBrick::HTTPServlet::AbstractServlet
68
70
  def initialize(_server, block)
69
71
  @callback = block
72
+ @parser = EasyUpnp::EventParser.new
70
73
  end
71
74
 
72
75
  def do_NOTIFY(request, response)
73
- @callback.call(request)
76
+ @callback.call(@parser.parse(request.body))
74
77
  end
75
78
  end
76
79
  end
@@ -1,5 +1,3 @@
1
- require_relative '../options_base'
2
-
3
1
  module EasyUpnp
4
2
  class Options < EasyUpnp::OptionsBase
5
3
  DEFAULTS = {
@@ -2,7 +2,7 @@ require 'socket'
2
2
  require 'ipaddr'
3
3
  require 'timeout'
4
4
 
5
- require_relative 'upnp_device'
5
+ require 'easy_upnp/upnp_device'
6
6
 
7
7
  module EasyUpnp
8
8
  class SsdpSearcher
@@ -3,7 +3,7 @@ require 'nokogiri'
3
3
  require 'open-uri'
4
4
  require 'savon'
5
5
 
6
- require_relative 'control_point/device_control_point'
6
+ require 'easy_upnp/control_point/device_control_point'
7
7
 
8
8
  module EasyUpnp
9
9
  class UpnpDevice
@@ -1,3 +1,3 @@
1
1
  module EasyUpnp
2
- VERSION = '1.1.5'
2
+ VERSION = '1.1.6'
3
3
  end
data/lib/easy_upnp.rb ADDED
@@ -0,0 +1,7 @@
1
+ require 'easy_upnp/options_base'
2
+
3
+ require 'easy_upnp/ssdp_searcher'
4
+ require 'easy_upnp/upnp_device'
5
+ require 'easy_upnp/version'
6
+
7
+ require 'easy_upnp/control_point/device_control_point'
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.1.5
4
+ version: 1.1.6
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-04-18 00:00:00.000000000 Z
11
+ date: 2016-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -66,12 +66,14 @@ files:
66
66
  - Rakefile
67
67
  - bin/upnp-list
68
68
  - easy_upnp.gemspec
69
+ - lib/easy_upnp.rb
69
70
  - lib/easy_upnp/control_point/argument_validator.rb
70
71
  - lib/easy_upnp/control_point/client_wrapper.rb
71
72
  - lib/easy_upnp/control_point/device_control_point.rb
72
73
  - lib/easy_upnp/control_point/service_method.rb
73
74
  - lib/easy_upnp/control_point/validator_provider.rb
74
75
  - lib/easy_upnp/events/event_client.rb
76
+ - lib/easy_upnp/events/event_parser.rb
75
77
  - lib/easy_upnp/events/http_listener.rb
76
78
  - lib/easy_upnp/events/subscription_manager.rb
77
79
  - lib/easy_upnp/options_base.rb