wemote 0.2.1 → 0.2.2

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: 88d7829f2bfa8a7892103c87c14696a2efcafcf0
4
- data.tar.gz: 8b7e761fbfde70ab48e0ca55cdd50c388c51a9c6
3
+ metadata.gz: 8fab169b7fb29b3ed90820cfa268951f6a88f28d
4
+ data.tar.gz: cd0c3fd1971486865e170eae94cca933e1558070
5
5
  SHA512:
6
- metadata.gz: f7c758531b285a15f3fa50b0eadf8aae1c56ae746b73909789efa795d08414ca1b5f47f8af8fff56aefb48ac9ccd99c0a8d1844dedc4eb1b53a3e9569f84af12
7
- data.tar.gz: a9ca631f0509ef3a4d8cab76a1e229b1507a003ccfb62f0e8261ea6669be7ff4799e89944732bc1698394a19b7e6f0e9c1d3f70ac8c9dbb04eb95505472acb06
6
+ metadata.gz: f365c6b952fd03d3b38d53081ede3d21ac1d28a1c4568e0d0275d9f3ddc0732a0b8651fbf33a20c0aa43d9335b0d41449906df90f4902e74a064f2f08e304de1
7
+ data.tar.gz: aafdae13551a09dfc8b4ce12336e6a3e3971add9667f7a61c5dd4b57353e5d49e4f69112d0a6945304852e00320d33ef89a2d3029006ae3decd2e42c053274e6
@@ -8,8 +8,8 @@ module Wemote
8
8
 
9
9
  class << self
10
10
 
11
- def discover(broadcast='255.255.255.255')
12
- Wemote::Switch.send(:discover,broadcast)
11
+ def discover
12
+ Wemote::Switch.send(:discover)
13
13
  end
14
14
 
15
15
  end
@@ -10,6 +10,8 @@ module Wemote
10
10
  # to be executed any time the switch changes state.
11
11
  class Switch
12
12
 
13
+ GOOGLE_IP = "64.233.187.99"
14
+
13
15
  GET_HEADERS = {
14
16
  "SOAPACTION" => '"urn:Belkin:service:basicevent:1#GetBinaryState"',
15
17
  "Content-type" => 'text/xml; charset="utf-8"'
@@ -40,8 +42,9 @@ module Wemote
40
42
 
41
43
  private
42
44
 
43
- def discover(broadcast = '255.255.255.255')
44
- `ping -t 1 #{broadcast} > /dev/null && arp -na | grep b4:75`.split("\n").map do |device|
45
+ def discover
46
+ ip = UDPSocket.open {|s| s.connect(GOOGLE_IP, 1); s.addr.last}
47
+ `nmap -sP #{ip.split('.')[0..-2].join('.')}.* > /dev/null && arp -na | grep b4:75`.split("\n").map do |device|
45
48
  self.new(/\((\d+\.\d+\.\d+\.\d+)\)/.match(device)[1])
46
49
  end.reject{|device| device.instance_variable_get(:@port).nil? }
47
50
  end
@@ -1,3 +1,3 @@
1
1
  module Wemote
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wemote
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Gisi