autoremote 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +11 -0
- data/autoremote.gemspec +2 -2
- data/lib/autoremote.rb +19 -8
- data/lib/autoremote/version.rb +1 -1
- metadata +4 -5
- data/autoremote-devices.db +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65f03c0bc3a9456d9a59737a15346bafffbdd567
|
4
|
+
data.tar.gz: cb47099496f1c2bb2990c9858061a2fe3a44fcdc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6763d9e3e898fae41f26da4687f63d95c053fa6f0a3df8b691b25927345dce99918592762b0210ef4a298aff63c5ccc2af72689edaf043d37d0eba694f3fe8a0
|
7
|
+
data.tar.gz: be3d51e59593f49c8926a61418a89e9f4c48d5c121934524a96652c828b66d907ab2963801cec46c8b1baeb18e46b09322d19d35eca33797c6ca6a83734067ee
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,15 @@
|
|
1
1
|
# Autoremote
|
2
|
+
[![Licence](https://img.shields.io/badge/license-MIT-blue.svg)][licence]
|
3
|
+
[![Gem Version](http://img.shields.io/gem/v/autoremote.svg)][gem]
|
4
|
+
[![Dependency Status](http://img.shields.io/gemnasium/AltonV/autoremote.svg)][gemnasium]
|
5
|
+
[![Gem Downloads](https://img.shields.io/gem/dt/autoremote.svg)][gem]
|
6
|
+
[![Code Climate](https://codeclimate.com/github/AltonV/autoremote/badges/gpa.svg)][codeclimate]
|
7
|
+
|
8
|
+
[licence]: http://choosealicense.com/licenses/mit/
|
9
|
+
[gem]: https://rubygems.org/gems/autoremote
|
10
|
+
[gemnasium]: https://gemnasium.com/AltonV/autoremote
|
11
|
+
[bitdeli]: https://bitdeli.com/free "Bitdeli Badge"
|
12
|
+
[codeclimate]: https://codeclimate.com/github/AltonV/autoremote
|
2
13
|
|
3
14
|
A library that makes it easier to interact with your other autoremote devices.
|
4
15
|
This project incudes both a library and an executable that uses the library.
|
data/autoremote.gemspec
CHANGED
@@ -6,8 +6,8 @@ require 'autoremote/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "autoremote"
|
8
8
|
spec.version = AutoRemote::VERSION
|
9
|
-
spec.authors = ["
|
10
|
-
spec.email = ["
|
9
|
+
spec.authors = [ "AltonV" ]
|
10
|
+
spec.email = [ "altonv@yurijware.com" ]
|
11
11
|
spec.summary = %q{A library for interacting with autoremote devices http://joaoapps.com/autoremote/}
|
12
12
|
spec.homepage = "https://github.com/AltonV/autoremote"
|
13
13
|
spec.license = "MIT"
|
data/lib/autoremote.rb
CHANGED
@@ -31,6 +31,7 @@ module AutoRemote
|
|
31
31
|
# @param name [String] The name of the device
|
32
32
|
# @param key [String] The personal key of the device
|
33
33
|
# @raise [AutoRemote::DeviceAlreadyExist] if the device already exits
|
34
|
+
# @return [void]
|
34
35
|
def AutoRemote::addDevice( name, key )
|
35
36
|
## Check if the name is taken
|
36
37
|
if Device.find_by_name( name ) || Device.find_by_key(key)
|
@@ -38,10 +39,9 @@ module AutoRemote
|
|
38
39
|
end
|
39
40
|
|
40
41
|
## Validate key
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
}
|
42
|
+
result = self.urlRequest( VALIDATIONURL.sub( /%YOUR_KEY%/, key ) )
|
43
|
+
|
44
|
+
## Check result
|
45
45
|
if result.body != "OK"
|
46
46
|
raise self::InvalidKey
|
47
47
|
end
|
@@ -53,6 +53,7 @@ module AutoRemote
|
|
53
53
|
# Remove a specific device
|
54
54
|
# @param name [String] The name of the device
|
55
55
|
# @raise [AutoRemote::DeviceNotFound] if the device didn't exist
|
56
|
+
# @return [void]
|
56
57
|
def AutoRemote::removeDevice( name )
|
57
58
|
if device = Device.find_by_name(name)
|
58
59
|
|
@@ -80,6 +81,7 @@ module AutoRemote
|
|
80
81
|
# @param message [String] The message to send
|
81
82
|
# @raise [AutoRemote::DeviceNotFound] if the device didn't exits
|
82
83
|
# @raise [TypeError] if message isn't a string
|
84
|
+
# @return [void]
|
83
85
|
def AutoRemote::sendMessage( device, message )
|
84
86
|
if ! device.kind_of?( Device ) && ! ( device = Device.find_by_name( device ) )
|
85
87
|
raise self::DeviceNotFound
|
@@ -90,10 +92,7 @@ module AutoRemote
|
|
90
92
|
hostname = `hostname`.strip
|
91
93
|
|
92
94
|
## Send the message
|
93
|
-
|
94
|
-
result = Net::HTTP.start(url.host, url.port) {|http|
|
95
|
-
http.request( Net::HTTP::Get.new( url.to_s ) )
|
96
|
-
}
|
95
|
+
result = self.urlRequest( MSGURL.sub( /%YOUR_KEY%/, device.key ).sub( /%MESSAGE%/, message ).sub( /%SENDER_ID%/, hostname ) )
|
97
96
|
|
98
97
|
## Check result
|
99
98
|
if result.body != "OK"
|
@@ -106,6 +105,7 @@ module AutoRemote
|
|
106
105
|
# @param remotehost [String] The public hostname or ip-address
|
107
106
|
# @raise [AutoRemote::DeviceNotFound] if the device didn't exits
|
108
107
|
# @raise [TypeError] if message isn't a string or less than 5 characters
|
108
|
+
# @return [void]
|
109
109
|
def AutoRemote::registerOnDevice( device, remotehost )
|
110
110
|
|
111
111
|
if ! device.kind_of?( Device ) && ! ( device = Device.find_by_name( device ) )
|
@@ -134,4 +134,15 @@ module AutoRemote
|
|
134
134
|
alias :sendMsg :sendMessage
|
135
135
|
alias :regOnDevice :registerOnDevice
|
136
136
|
end
|
137
|
+
|
138
|
+
private
|
139
|
+
# Performs a http request
|
140
|
+
# @param url [String]
|
141
|
+
def AutoRemote::urlRequest( url )
|
142
|
+
url = URI.parse( url )
|
143
|
+
result = Net::HTTP.start(url.host, url.port) {|http|
|
144
|
+
http.request( Net::HTTP::Get.new( url.to_s ) )
|
145
|
+
}
|
146
|
+
return result
|
147
|
+
end
|
137
148
|
end
|
data/lib/autoremote/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: autoremote
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- AltonV
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -68,7 +68,7 @@ dependencies:
|
|
68
68
|
version: '1.3'
|
69
69
|
description:
|
70
70
|
email:
|
71
|
-
-
|
71
|
+
- altonv@yurijware.com
|
72
72
|
executables:
|
73
73
|
- autoremote
|
74
74
|
extensions: []
|
@@ -79,7 +79,6 @@ files:
|
|
79
79
|
- LICENSE.txt
|
80
80
|
- README.md
|
81
81
|
- Rakefile
|
82
|
-
- autoremote-devices.db
|
83
82
|
- autoremote.gemspec
|
84
83
|
- bin/autoremote
|
85
84
|
- lib/autoremote.rb
|
data/autoremote-devices.db
DELETED
Binary file
|