autoremote 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/lib/autoremote.rb +23 -13
- data/lib/autoremote/version.rb +1 -1
- metadata +2 -2
- data/autoremote-0.0.1.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9731d389f8581ca589e4c475195e809d40fe684
|
4
|
+
data.tar.gz: 7a1088fd196ed63d7f9574c0159b3ae76c14ae8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: afed78c4605eefccd392e72e9ec91e1381d7bb4b1f836d9fd8858f98b051fd1cde59eb562f941d0a5770136f0ef0302ba86549a81aeaef066d987cc2eaabb6de
|
7
|
+
data.tar.gz: 42dadd06118f24ed4a18892ff9124b69c3a70566ff8dbeea80bbaa676871761459e20b7496559da1cea8fa9add5e4a2b9b0341f3372ef02e02b3d9fd2151806f
|
data/.gitignore
CHANGED
data/lib/autoremote.rb
CHANGED
@@ -27,11 +27,14 @@ module AutoRemote
|
|
27
27
|
MSGURL = "http://autoremotejoaomgcd.appspot.com/sendmessage?key=%YOUR_KEY%&message=%MESSAGE%&sender=%SENDER_ID%"
|
28
28
|
VALIDATIONURL = "http://autoremotejoaomgcd.appspot.com/sendmessage?key=%YOUR_KEY%"
|
29
29
|
|
30
|
-
|
30
|
+
# Add a device
|
31
|
+
# @param name [String] The name of the device
|
32
|
+
# @param key [String] The personal key of the device
|
33
|
+
# @raise [AutoRemote::DeviceAlreadyExist] if the device already exits
|
31
34
|
def AutoRemote::addDevice( name, key )
|
32
35
|
## Check if the name is taken
|
33
36
|
if Device.find_by_name( name ) || Device.find_by_key(key)
|
34
|
-
raise self::DeviceAlreadyExist
|
37
|
+
raise self::DeviceAlreadyExist
|
35
38
|
end
|
36
39
|
|
37
40
|
## Validate key
|
@@ -45,31 +48,38 @@ module AutoRemote
|
|
45
48
|
|
46
49
|
## Save the device
|
47
50
|
Device.create(:name => name, :key => key)
|
48
|
-
return true
|
49
51
|
end
|
50
52
|
|
51
|
-
|
53
|
+
# Remove a specific device
|
54
|
+
# @param name [String] The name of the device
|
55
|
+
# @raise [AutoRemote::DeviceNotFound] if the device didn't exist
|
52
56
|
def AutoRemote::removeDevice( name )
|
53
57
|
if device = Device.find_by_name(name)
|
54
58
|
|
55
59
|
## Remove the device
|
56
|
-
|
60
|
+
Device.delete(device.id)
|
57
61
|
else
|
58
62
|
raise self::DeviceNotFound
|
59
63
|
end
|
60
64
|
end
|
61
65
|
|
62
|
-
|
66
|
+
# Returns a list with all devices
|
67
|
+
# @return [Device::ActiveRecord_Relation]
|
63
68
|
def AutoRemote::listDevices
|
64
69
|
return Device.order("name").all
|
65
70
|
end
|
66
71
|
|
67
|
-
|
72
|
+
# Returns one specific device
|
73
|
+
# @return [Device]
|
68
74
|
def AutoRemote::getDevice( name )
|
69
75
|
return Device.find_by_name( name )
|
70
76
|
end
|
71
77
|
|
72
|
-
|
78
|
+
# Sends a message to a device
|
79
|
+
# @param device [Device, String] A device object or the name of the device
|
80
|
+
# @param message [String] The message to send
|
81
|
+
# @raise [AutoRemote::DeviceNotFound] if the device didn't exits
|
82
|
+
# @raise [TypeError] if message isn't a string
|
73
83
|
def AutoRemote::sendMessage( device, message )
|
74
84
|
if ! device.kind_of?( Device ) && ! ( device = Device.find_by_name( device ) )
|
75
85
|
raise self::DeviceNotFound
|
@@ -89,11 +99,13 @@ module AutoRemote
|
|
89
99
|
if result.body != "OK"
|
90
100
|
raise self::InvalidKey
|
91
101
|
end
|
92
|
-
|
93
|
-
return true
|
94
102
|
end
|
95
103
|
|
96
|
-
|
104
|
+
# Register on the device
|
105
|
+
# @param device [Device, String] A device object or the name of the device
|
106
|
+
# @param remotehost [String] The public hostname or ip-address
|
107
|
+
# @raise [AutoRemote::DeviceNotFound] if the device didn't exits
|
108
|
+
# @raise [TypeError] if message isn't a string or less than 5 characters
|
97
109
|
def AutoRemote::registerOnDevice( device, remotehost )
|
98
110
|
|
99
111
|
if ! device.kind_of?( Device ) && ! ( device = Device.find_by_name( device ) )
|
@@ -113,8 +125,6 @@ module AutoRemote
|
|
113
125
|
if ! result
|
114
126
|
raise self::AutoRemoteException, "Something went wrong when registering on the device"
|
115
127
|
end
|
116
|
-
|
117
|
-
return true
|
118
128
|
end
|
119
129
|
|
120
130
|
## Define alases for some methods
|
data/lib/autoremote/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yurij
|
@@ -79,7 +79,6 @@ files:
|
|
79
79
|
- LICENSE.txt
|
80
80
|
- README.md
|
81
81
|
- Rakefile
|
82
|
-
- autoremote-0.0.1.gem
|
83
82
|
- autoremote-devices.db
|
84
83
|
- autoremote.gemspec
|
85
84
|
- bin/autoremote
|
@@ -111,3 +110,4 @@ signing_key:
|
|
111
110
|
specification_version: 4
|
112
111
|
summary: A library for interacting with autoremote devices http://joaoapps.com/autoremote/
|
113
112
|
test_files: []
|
113
|
+
has_rdoc:
|
data/autoremote-0.0.1.gem
DELETED
Binary file
|