bravtroller 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/bravtroller/remote.rb +28 -19
- data/lib/bravtroller/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: 1c2771970023d32fc31b1b5f6d886604b66de45e
|
4
|
+
data.tar.gz: 48223252de5d5a1159c952e12a3239d38936b0a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 669b812f605adfa512d048a9990e76f3861d6c507ce478d4009a645f3d704e73ee0616fd743571995c520a5a4ae496841edaca1c2ecc8fdc5b6617d1e3b40ec9
|
7
|
+
data.tar.gz: 4637c6a8e1404b77a92a589a526f70b9642106c809a359b3293465712a916d114643471514ef20987ddb9a707b2573995a33e681ef66b8e9439219cbfd81f93e
|
data/Gemfile.lock
CHANGED
data/lib/bravtroller/remote.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'singleton'
|
1
2
|
require 'easy_upnp/ssdp_searcher'
|
2
3
|
|
3
4
|
require_relative 'authenticator'
|
@@ -14,30 +15,38 @@ module Bravtroller
|
|
14
15
|
version: '1.0'
|
15
16
|
}
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
authenticator = Bravtroller::Authenticator.new(bravia_client)
|
21
|
-
|
22
|
-
if ! authenticator.authorized?
|
23
|
-
raise RuntimeError.new 'Not authorized yet. Please authorize Bravtroller using Bravtroller::Authenticator.'
|
18
|
+
class IrccClientFactory
|
19
|
+
def initialize(client)
|
20
|
+
@client = client
|
24
21
|
end
|
25
22
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
23
|
+
def create
|
24
|
+
if @ircc_client.nil?
|
25
|
+
searcher = EasyUpnp::SsdpSearcher.new
|
26
|
+
results = searcher.search(IRCC_URN)
|
27
|
+
authenticator = Bravtroller::Authenticator.new(@client)
|
28
|
+
|
29
|
+
if !authenticator.authorized?
|
30
|
+
raise RuntimeError.new 'Not authorized yet. Please authorize Bravtroller using Bravtroller::Authenticator.'
|
31
|
+
end
|
32
|
+
|
33
|
+
if results.empty?
|
34
|
+
raise RuntimeError.new "Couldn't find any UPnP devices on the network that looks like a supported Sony device"
|
35
|
+
elsif results.count != 1
|
36
|
+
raise RuntimeError.new "Found more than one supported Sony device. Please construct Remote manually. Found devices: #{results.inspect}"
|
37
|
+
else
|
38
|
+
device = results.first
|
39
|
+
@ircc_client = device.service(IRCC_URN, cookies: HTTPI::Cookie.new(authenticator.authorize {}))
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
@ircc_client
|
35
44
|
end
|
36
45
|
end
|
37
46
|
|
38
|
-
def initialize(
|
39
|
-
@ircc_client = ircc_client
|
47
|
+
def initialize(bravia_client, ircc_client_factory = IrccClientFactory.new(bravia_client))
|
40
48
|
@bravia_client = bravia_client
|
49
|
+
@ircc_client_factory = ircc_client_factory
|
41
50
|
end
|
42
51
|
|
43
52
|
def power_on
|
@@ -53,7 +62,7 @@ module Bravtroller
|
|
53
62
|
def press_button(button_key)
|
54
63
|
raise RuntimeError.new "Undefined button: #{button_key}" if ircc_codes[button_key].nil?
|
55
64
|
|
56
|
-
@
|
65
|
+
@ircc_client_factory.create.X_SendIRCC IRCCCode: ircc_codes[button_key]
|
57
66
|
end
|
58
67
|
|
59
68
|
def buttons
|
data/lib/bravtroller/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bravtroller
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.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: 2015-07-
|
11
|
+
date: 2015-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: easy_upnp
|