easy_upnp 0.1.2 → 0.1.3

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
  !binary "U0hBMQ==":
3
- metadata.gz: 0586271b5f97b95dd0e0324a45475003116ae487
4
- data.tar.gz: 14d2670ecaaa2a9a071fbce42e025e393bc79bfe
3
+ metadata.gz: e9f368715acba835a38294efd1ec026e8e53400e
4
+ data.tar.gz: 309a486292c2ce750fe1a25bb3b5bb6af30cba06
5
5
  !binary "U0hBNTEy":
6
- metadata.gz: b047b3560b6202c104482b595c81b1ec83ac50a0241d02bfbadf7fb77ff7068ba4f7c2f1e8afeed6c9e34957f85be71fc1797d21c4e6c4a9bb70937353ecac35
7
- data.tar.gz: e60ab29c75b3e5704cb3c5e422f089eeed6d057d27d69ff2462c6f921ba4c12610fef4c712d5d82346eae8447f7542794ec67828ef1d7d83e42e9d2ada5b4020
6
+ metadata.gz: 312b61519e68d976d089b7195fe2aad9dd57d5d5f35bcf5bfd9c615c3bb4049ba37edbba3baae0d10e8e4db69536fe5f0da1cd5dc38de322a571fcb912686efa
7
+ data.tar.gz: 8d1cdd7f049db09b24f29cfb49b3f2f79c9d5378550ecc86649f8394b625a3d2d405eebb0216c6eed685dbd798cf14512ce1083d52f03dc4b044bf84e6845b5e
data/.gitignore CHANGED
@@ -33,3 +33,6 @@ Gemfile.lock
33
33
 
34
34
  # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35
35
  .rvmrc
36
+
37
+ # IntelliJ
38
+ *.iml
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
- def initialize client, service_type, definition_url
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 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 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 (args_hash.keys - input_args).any?
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...
@@ -28,6 +28,10 @@ module EasyUpnp
28
28
  end
29
29
  end
30
30
 
31
+ def all_services
32
+ @service_definitions.map { |x| x[:st] }
33
+ end
34
+
31
35
  def has_service?(urn)
32
36
  !service_definition(urn).nil?
33
37
  end
@@ -1,3 +1,3 @@
1
1
  module EasyUpnp
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy_upnp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Mullins