autoremote 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.pullreview.yml +5 -0
- data/.travis.yml +35 -0
- data/Gemfile +2 -0
- data/README.md +8 -5
- data/bin/autoremote +41 -9
- data/lib/autoremote.rb +89 -65
- data/lib/autoremote/exceptions.rb +2 -14
- data/lib/autoremote/net.rb +25 -0
- data/lib/autoremote/version.rb +1 -1
- data/spec/autoremote_spec.rb +57 -11
- data/spec/spec_helper.rb +1 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2b9cbfdd54c4ff05c1075eabe8b2ddf8ac1af82
|
4
|
+
data.tar.gz: 9d3f433333b4e827c8755a016bcc074e0ab02890
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7f8e03824393a70fe0a5a6f4d329667c2b9a965149ff082555c816888d9c8264f0078e09c7827fa02b947ea4e472009489ff67f758f657b303d63924900297d
|
7
|
+
data.tar.gz: 67ab0febc0d4a344803dc6c4f2cf9c788b7511250d390c658523a36f2f7b2cb9c8a2ec6241b7ac1a0095e6250aadc145a364bc88d4e2afe8692f9ae2e3106a0b
|
data/.gitignore
CHANGED
data/.pullreview.yml
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 1.9.3
|
4
|
+
- 2.0.0
|
5
|
+
- 2.1.5
|
6
|
+
- 2.2.0
|
7
|
+
- rbx-2.1.1
|
8
|
+
- rbx-2.2.0
|
9
|
+
- rbx-2.3.0
|
10
|
+
- rbx
|
11
|
+
- jruby-19mode
|
12
|
+
- jruby
|
13
|
+
|
14
|
+
matrix:
|
15
|
+
fast_finish: true
|
16
|
+
allow_failures:
|
17
|
+
- rvm: rbx-2.1.1
|
18
|
+
- rvm: rbx-2.2.0
|
19
|
+
- rvm: rbx-2.3.0
|
20
|
+
- rvm: rbx
|
21
|
+
- rvm: jruby-19mode
|
22
|
+
- rvm: jruby
|
23
|
+
|
24
|
+
addons:
|
25
|
+
code_climate:
|
26
|
+
repo_token:
|
27
|
+
secure: "DUVG31yOL3GfE9FASaTXuTKWibxuGgiJItSXAFoSjQU3QYDcC/f/MH/58jfZnMy7Vrt36/RcuwBifCgBWNMkH0jHdYUtZyKkEyDxc98nKXD8R02uKFMhBVBvInakmDnAPfl75OO0A4peibZ+feHzv5NoK2wL4p3+eR3wLGWwLV4="
|
28
|
+
|
29
|
+
before_install:
|
30
|
+
- gem update --system
|
31
|
+
- gem --version
|
32
|
+
|
33
|
+
bundler_args: --jobs=1 --retry=3
|
34
|
+
|
35
|
+
script: bundle exec rspec
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -40,25 +40,28 @@ Since version 0.1.0 you can use the goo.gl url instead of the key when adding de
|
|
40
40
|
require 'autoremote'
|
41
41
|
|
42
42
|
# Adding devices can be done either with the key
|
43
|
-
AutoRemote.
|
43
|
+
AutoRemote.add_device( name, "A VERY LONG STRING OF CHARACTERS" )
|
44
44
|
# Or with your 'goo.gl' address
|
45
|
-
AutoRemote.
|
45
|
+
AutoRemote.add_device( name, "http://goo.gl/XXXXXX" )
|
46
46
|
|
47
47
|
# Removes a device
|
48
|
-
AutoRemote.
|
48
|
+
AutoRemote.remove_device( name )
|
49
49
|
|
50
50
|
# List all saved devices
|
51
51
|
AutoRemote.list
|
52
52
|
|
53
|
+
# Get a specific device
|
54
|
+
AutoRemote.get_device( name )
|
55
|
+
|
53
56
|
# Send a message to a device
|
54
57
|
# The parameter device can either be a Device object or the name of the device
|
55
|
-
AutoRemote.
|
58
|
+
AutoRemote.send_message( device, message )
|
56
59
|
|
57
60
|
# Register on the device.
|
58
61
|
# This has the same effect as following the guide on http://joaoapps.com/autoremote/linux/)
|
59
62
|
# device can either be a Device object or the name of the device
|
60
63
|
# host can be either a hostname or ip-address, but they have to be public (i.e. reachable from the internet)
|
61
|
-
AutoRemote.
|
64
|
+
AutoRemote.register_on_device( device, host )
|
62
65
|
```
|
63
66
|
|
64
67
|
## Contributing
|
data/bin/autoremote
CHANGED
@@ -8,6 +8,19 @@ def to_bool(string)
|
|
8
8
|
raise ArgumentError, "Invalid value: #{string}"
|
9
9
|
end
|
10
10
|
|
11
|
+
# Prints the header for the list of devices
|
12
|
+
def print_list_head(withkey)
|
13
|
+
puts 'Listing devices'
|
14
|
+
|
15
|
+
print 'Name'.rjust(18)
|
16
|
+
print ' Key' if withkey
|
17
|
+
puts
|
18
|
+
|
19
|
+
print '--------'.rjust(18)
|
20
|
+
print ' --------' if withkey
|
21
|
+
puts
|
22
|
+
end
|
23
|
+
|
11
24
|
## Prints help
|
12
25
|
def print_help
|
13
26
|
puts 'AutoRemote v' + AutoRemote::VERSION
|
@@ -23,41 +36,58 @@ end
|
|
23
36
|
|
24
37
|
arg0 = ARGV[0].downcase if ARGV[0]
|
25
38
|
|
39
|
+
# Prints help
|
26
40
|
if arg0 == 'help' || arg0 == '-h' || arg0 == '--help'
|
27
41
|
print_help
|
42
|
+
|
43
|
+
# Add device
|
28
44
|
elsif arg0 == 'add' && ARGV[1] && ARGV[2]
|
45
|
+
|
29
46
|
puts 'Adding device'
|
30
47
|
begin
|
31
48
|
AutoRemote.addDevice(ARGV[1], ARGV[2])
|
32
49
|
puts 'Device added successfully'
|
33
|
-
rescue
|
50
|
+
rescue StandardError => e
|
34
51
|
puts "Error: #{e.message}"
|
35
52
|
end
|
53
|
+
|
54
|
+
# Remove device
|
36
55
|
elsif ( arg0 == 'remove' || arg0 == 'delete' ) && ARGV[1]
|
56
|
+
|
37
57
|
puts 'Removing device'
|
38
58
|
begin
|
39
59
|
AutoRemote.removeDevice(ARGV[1])
|
40
60
|
puts 'Device removed successfully'
|
41
|
-
rescue
|
61
|
+
rescue StandardError => e
|
42
62
|
puts "Error: #{e.message}"
|
43
63
|
end
|
64
|
+
|
65
|
+
# List all devices
|
44
66
|
elsif arg0 == 'list'
|
67
|
+
|
45
68
|
withkey = to_bool(ARGV[1])
|
46
|
-
|
47
|
-
|
69
|
+
print_list_head(withkey)
|
70
|
+
|
48
71
|
AutoRemote.listDevices.each do|device|
|
49
|
-
print "
|
50
|
-
print "
|
72
|
+
print "#{device.name}".rjust(18)
|
73
|
+
print " #{device.key}" if withkey
|
51
74
|
puts
|
52
75
|
end
|
76
|
+
|
77
|
+
# Send a message to a device
|
53
78
|
elsif arg0 == 'message' && ARGV[1] && ARGV[2]
|
79
|
+
|
54
80
|
begin
|
55
81
|
AutoRemote.sendMessage(ARGV[1], ARGV[2])
|
56
82
|
puts 'Message sent successfully'
|
57
|
-
rescue
|
83
|
+
rescue StandardError => e
|
58
84
|
puts "Error: #{e.message}"
|
59
85
|
end
|
86
|
+
|
87
|
+
# Register on a device
|
60
88
|
elsif arg0 == 'register' && ARGV[1] && ARGV[2]
|
89
|
+
|
90
|
+
# Display a prompt if registering on windows
|
61
91
|
if RbConfig::CONFIG['host_os'] =~ /mswin|msys|mingw|cygwin|bccwin|wince|emc/i
|
62
92
|
puts 'Are you sure you want to register a windows computer?'
|
63
93
|
print 'You will need an SSH server on the computer. (y/n)'
|
@@ -66,13 +96,15 @@ elsif arg0 == 'register' && ARGV[1] && ARGV[2]
|
|
66
96
|
exit
|
67
97
|
end
|
68
98
|
end
|
69
|
-
|
99
|
+
|
70
100
|
begin
|
71
101
|
AutoRemote.registerOnDevice(ARGV[1], ARGV[2])
|
72
102
|
puts 'Device registered successfully'
|
73
|
-
rescue
|
103
|
+
rescue StandardError => e
|
74
104
|
puts "Error: #{e.message}"
|
75
105
|
end
|
106
|
+
|
107
|
+
# Display help if arguments are invalid
|
76
108
|
else
|
77
109
|
print_help
|
78
110
|
end
|
data/lib/autoremote.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
|
+
require 'autoremote/net'
|
1
2
|
require 'autoremote/version'
|
2
3
|
require 'autoremote/exceptions'
|
3
4
|
require 'sqlite3'
|
4
5
|
require 'active_record'
|
5
|
-
require 'net/http'
|
6
6
|
require 'socket'
|
7
|
-
require 'httparty'
|
8
7
|
|
9
8
|
## Establish the database connection
|
10
9
|
ActiveRecord::Base.establish_connection(
|
@@ -25,21 +24,17 @@ ActiveRecord::Schema.define do
|
|
25
24
|
end
|
26
25
|
|
27
26
|
module AutoRemote
|
28
|
-
REGURL = 'http://autoremotejoaomgcd.appspot.com/registerpc?key=%YOUR_KEY%&name=%DISPLAY_NAME%&id=%UNIQUE_ID%&type=linux&publicip=%PUBLIC_HOST%&localip=%IP_ADDRESS%'
|
29
|
-
MSGURL = 'http://autoremotejoaomgcd.appspot.com/sendmessage?key=%YOUR_KEY%&message=%MESSAGE%&sender=%SENDER_ID%'
|
30
|
-
VALIDATIONURL = 'http://autoremotejoaomgcd.appspot.com/sendmessage?key=%YOUR_KEY%'
|
31
|
-
|
32
27
|
# Add a device
|
33
28
|
# @param name [String] The name of the device
|
34
29
|
# @param input [String] Can either be the 'goo.gl' url or the personal key of the device
|
35
|
-
# @raise [AutoRemote::DeviceAlreadyExist] if the device already exits
|
36
30
|
# @raise [AutoRemote::InvalidKey] if the key or url is invalid
|
37
|
-
# @return [
|
38
|
-
|
31
|
+
# @return [Device] the device that was was created
|
32
|
+
# @return [nil] if the device already exists
|
33
|
+
def AutoRemote::add_device(name, input)
|
39
34
|
|
40
35
|
## Validation if input is a 'goo.gl' url
|
41
36
|
if input.match(/^(https?:\/{2})?(goo.gl\/[\S]*)$/i)
|
42
|
-
result =
|
37
|
+
result = AutoRemoteRequest.validate_url(input)
|
43
38
|
|
44
39
|
## Get the key from the resulting url
|
45
40
|
begin
|
@@ -51,119 +46,148 @@ module AutoRemote
|
|
51
46
|
## If not a 'goo.gl' url, check if it is a valid key
|
52
47
|
else
|
53
48
|
## Validate key
|
54
|
-
result =
|
49
|
+
result = AutoRemoteRequest.validate_key(input)
|
55
50
|
|
56
51
|
## Check result
|
57
|
-
if result.body != 'OK'
|
58
|
-
raise self::InvalidKey
|
59
|
-
end
|
52
|
+
raise self::InvalidKey if result.body != 'OK'
|
60
53
|
end
|
61
54
|
|
62
55
|
## Check if the device already exist
|
63
|
-
if Device.find_by_name(name)
|
64
|
-
|
56
|
+
if Device.find_by_name(name)
|
57
|
+
return nil
|
58
|
+
else
|
59
|
+
## Save the device
|
60
|
+
return Device.create(:name => name, :key => input)
|
65
61
|
end
|
66
|
-
|
67
|
-
## Save the device
|
68
|
-
Device.create(:name => name, :key => input)
|
69
62
|
end
|
70
63
|
|
71
64
|
# Remove a specific device
|
72
65
|
# @param name [String] The name of the device
|
73
|
-
# @
|
74
|
-
# @return [
|
75
|
-
def AutoRemote::
|
66
|
+
# @return [true] if the device was deleted
|
67
|
+
# @return [false] if the device wasn't found
|
68
|
+
def AutoRemote::remove_device(name)
|
76
69
|
if device = Device.find_by_name(name)
|
77
70
|
## Remove the device
|
78
71
|
Device.delete(device.id)
|
72
|
+
return true
|
79
73
|
else
|
80
|
-
|
74
|
+
return false
|
81
75
|
end
|
82
76
|
end
|
83
77
|
|
84
78
|
# Returns a list with all devices
|
85
79
|
# @return [Device::ActiveRecord_Relation]
|
86
|
-
def AutoRemote::
|
80
|
+
def AutoRemote::list_devices
|
87
81
|
return Device.order('name').all
|
88
82
|
end
|
89
83
|
|
90
84
|
# Returns one specific device
|
91
|
-
# @return [Device]
|
92
|
-
|
85
|
+
# @return [Device] if the device was found
|
86
|
+
# @return [nil] if the device wasn't found
|
87
|
+
def AutoRemote::get_device(name)
|
93
88
|
return Device.find_by_name(name)
|
94
89
|
end
|
95
90
|
|
96
91
|
# Sends a message to a device
|
97
92
|
# @param device [Device, String] A device object or the name of the device
|
98
93
|
# @param message [String] The message to send
|
99
|
-
# @raise [
|
100
|
-
# @
|
101
|
-
# @return [
|
102
|
-
def AutoRemote::
|
103
|
-
|
104
|
-
raise self::DeviceNotFound
|
105
|
-
elsif ! message.kind_of?(String)
|
106
|
-
raise TypeError, 'Message must be a string'
|
107
|
-
end
|
94
|
+
# @raise [ArgumentError] if message isn't a string
|
95
|
+
# @return [true] if the message was sent
|
96
|
+
# @return [false] if the message wasn't sent
|
97
|
+
def AutoRemote::send_message(device, message)
|
98
|
+
device = self.validate_device(device)
|
108
99
|
|
109
|
-
|
100
|
+
if !device
|
101
|
+
return false
|
102
|
+
elsif ! message.is_a?(String)
|
103
|
+
raise ArgumentError, 'Message must be a string'
|
104
|
+
end
|
110
105
|
|
111
106
|
## Send the message
|
112
|
-
result =
|
107
|
+
result = AutoRemoteRequest.message(device.key, `hostname`.strip, CGI.escape(message))
|
113
108
|
|
114
109
|
## Check result
|
115
|
-
if result.body
|
116
|
-
|
110
|
+
if result.body == 'OK'
|
111
|
+
return true
|
112
|
+
else
|
113
|
+
return false
|
117
114
|
end
|
118
115
|
end
|
119
116
|
|
120
117
|
# Register on the device
|
121
118
|
# @param device [Device, String] A device object or the name of the device
|
122
119
|
# @param remotehost [String] The public hostname or ip-address
|
123
|
-
# @raise [
|
124
|
-
# @
|
125
|
-
# @
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
120
|
+
# @raise [ArgumentError] if message isn't a string or less than 5 characters
|
121
|
+
# @return [true] if the registration was successful
|
122
|
+
# @return [false] if the registration failed
|
123
|
+
def AutoRemote::register_on_device(device, remotehost)
|
124
|
+
device = self.validate_device(device)
|
125
|
+
|
126
|
+
if !device
|
127
|
+
return false
|
128
|
+
elsif ! remotehost.is_a?(String) || remotehost.length < 5
|
131
129
|
raise ArgumentError, 'remotehost must be a string of 5 chars or more'
|
132
130
|
end
|
133
131
|
|
134
132
|
hostname = `hostname`.strip
|
135
|
-
ipAddress = AutoRemote::
|
133
|
+
ipAddress = AutoRemote::get_ip_address.ip_address
|
136
134
|
|
137
135
|
## Perform the registration
|
138
|
-
result =
|
136
|
+
result = AutoRemoteRequest.register(device.key, hostname, hostname, remotehost, ipAddress)
|
139
137
|
|
140
138
|
## Check result
|
141
|
-
if result.body
|
142
|
-
|
139
|
+
if result.body == 'OK'
|
140
|
+
return true
|
141
|
+
else
|
142
|
+
return false
|
143
143
|
end
|
144
144
|
end
|
145
145
|
|
146
146
|
## Define alases for some methods
|
147
147
|
class << AutoRemote
|
148
|
-
|
149
|
-
alias :
|
150
|
-
alias :
|
151
|
-
alias :
|
148
|
+
# Add
|
149
|
+
alias :addDevice :add_device
|
150
|
+
alias :saveDevice :add_device
|
151
|
+
alias :save_device :add_device
|
152
|
+
# Remove
|
153
|
+
alias :removeDevice :remove_device
|
154
|
+
alias :deleteDevice :remove_device
|
155
|
+
alias :delete_device :remove_device
|
156
|
+
# List
|
157
|
+
alias :listDevices :list_devices
|
158
|
+
# Get
|
159
|
+
alias :getDevice :get_device
|
160
|
+
# Message
|
161
|
+
alias :sendMessage :send_message
|
162
|
+
alias :sendMsg :send_message
|
163
|
+
alias :send_msg :send_message
|
164
|
+
# Register
|
165
|
+
alias :registerOnDevice :register_on_device
|
166
|
+
alias :regOnDevice :register_on_device
|
167
|
+
alias :reg_on_device :register_on_device
|
152
168
|
end
|
153
169
|
|
154
170
|
private
|
171
|
+
# Validates device
|
172
|
+
# @param input the input to validate
|
173
|
+
# @return [Device] if the input is valid
|
174
|
+
# @return [nil] if the input is not valid
|
175
|
+
def AutoRemote::validate_device(input)
|
176
|
+
if input.is_a?(Device)
|
177
|
+
return input
|
178
|
+
else
|
179
|
+
device = Device.find_by_name(input)
|
180
|
+
if device.kind_of?(Device)
|
181
|
+
return device
|
182
|
+
else
|
183
|
+
return nil
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
155
188
|
# Gets the ip address of the system
|
156
189
|
# @return [String]
|
157
|
-
def AutoRemote::
|
190
|
+
def AutoRemote::get_ip_address
|
158
191
|
return Socket.ip_address_list.detect { |ipInfo| ipInfo.ipv4_private? }
|
159
192
|
end
|
160
|
-
|
161
|
-
# Performs a http request
|
162
|
-
# @param url [String]
|
163
|
-
def AutoRemote::urlRequest(url)
|
164
|
-
## Add http:// to the url if not present
|
165
|
-
url = 'http://' + url unless url.match(/^https?:\/{2}/i)
|
166
|
-
|
167
|
-
return HTTParty.get(url)
|
168
|
-
end
|
169
193
|
end
|
@@ -1,23 +1,11 @@
|
|
1
1
|
module AutoRemote
|
2
2
|
class AutoRemoteException < StandardError
|
3
3
|
end
|
4
|
-
|
5
|
-
class DeviceNotFound < AutoRemoteException
|
6
|
-
def message
|
7
|
-
"Device doesn't exist"
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
class DeviceAlreadyExist < AutoRemoteException
|
12
|
-
def message
|
13
|
-
"Device already exist"
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
4
|
+
|
17
5
|
class InvalidKey < AutoRemoteException
|
18
6
|
def message
|
19
7
|
"The key is invalid"
|
20
8
|
end
|
21
9
|
end
|
22
|
-
|
10
|
+
|
23
11
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
class AutoRemoteRequest
|
4
|
+
include HTTParty
|
5
|
+
base_uri 'https://autoremotejoaomgcd.appspot.com'
|
6
|
+
|
7
|
+
def self.register(key, id, name, publicip, localip)
|
8
|
+
get('/registerpc', query: { key: key, id: id, name: name, publicip: publicip, localip: localip })
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.message(key, sender, message)
|
12
|
+
get('/sendmessage', query: { key: key, sender: sender, message: message })
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.validate_key(key)
|
16
|
+
get('/sendmessage', query: { key: key })
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.validate_url(url)
|
20
|
+
## Add https:// to the url if not present
|
21
|
+
url.prepend 'https://' unless url.match(/^https?:\/{2}/i)
|
22
|
+
get(url)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
data/lib/autoremote/version.rb
CHANGED
data/spec/autoremote_spec.rb
CHANGED
@@ -1,38 +1,84 @@
|
|
1
|
+
require 'codeclimate-test-reporter'
|
2
|
+
CodeClimate::TestReporter.start
|
3
|
+
|
1
4
|
require 'spec_helper.rb'
|
2
5
|
require 'autoremote'
|
3
6
|
|
4
7
|
TEST_NAME = 'TestDevice'
|
5
8
|
TEST_URL = 'http://goo.gl/CyA66h'
|
6
9
|
TEST_KEY = 'APA91bFKEjtBfVU5WoJJ8KyfmR3LfmUpcVrePdQQ_T5oN1h8KcLptzhCvDE-FP1IQPimb9bk4Osm2FzTUvUT5YRylgjTMTHbS7HqbveHE-ZhgwtJEsfoKvo_JAN8Oh5NLpk-mvWEMBaZtpZVXqb3oP-G_7iKmY4UrNhXhrx9CNKOEWjhuluM0Js'
|
7
|
-
TEST_MSG = 'This is a test message'
|
10
|
+
TEST_MSG = 'This is a test message from the autoremote ruby gem'
|
8
11
|
|
9
12
|
describe AutoRemote do
|
10
|
-
describe '#
|
11
|
-
it 'adds a device' do
|
12
|
-
AutoRemote.
|
13
|
+
describe '#add_device(key)' do
|
14
|
+
it 'adds a device with a key' do
|
15
|
+
device = AutoRemote.add_device(TEST_NAME, TEST_KEY)
|
16
|
+
expect(device).to be_instance_of(Device)
|
17
|
+
expect(device.name).to eq(TEST_NAME)
|
18
|
+
expect(device.key).to eq(TEST_KEY)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#get_device' do
|
23
|
+
it 'returns a device' do
|
24
|
+
device = AutoRemote.get_device(TEST_NAME)
|
25
|
+
expect(device).to be_instance_of(Device)
|
26
|
+
expect(device.name).to eq(TEST_NAME)
|
27
|
+
expect(device.key).to eq(TEST_KEY)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#remove_device' do
|
32
|
+
it 'removes a device after adding with key' do
|
33
|
+
result = AutoRemote.remove_device(TEST_NAME)
|
34
|
+
expect(result).to eq(true)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#add_device(url)' do
|
39
|
+
it 'adds a device with url' do
|
40
|
+
device = AutoRemote.add_device(TEST_NAME, TEST_URL)
|
41
|
+
expect(device).to be_instance_of(Device)
|
42
|
+
expect(device.name).to eq(TEST_NAME)
|
43
|
+
expect(device.key).to eq(TEST_KEY)
|
13
44
|
end
|
14
45
|
end
|
15
46
|
|
16
|
-
describe '#
|
47
|
+
describe '#list_devices' do
|
17
48
|
it 'returns a list of devices' do
|
18
|
-
list = AutoRemote.
|
49
|
+
list = AutoRemote.list_devices
|
19
50
|
expect(list).not_to eq(nil)
|
20
51
|
expect(list.count).to be > 0
|
21
52
|
end
|
22
53
|
end
|
23
54
|
|
24
|
-
describe '#
|
55
|
+
describe '#get_device' do
|
25
56
|
it 'returns a device' do
|
26
|
-
device = AutoRemote.
|
57
|
+
device = AutoRemote.get_device(TEST_NAME)
|
27
58
|
expect(device).to be_instance_of(Device)
|
28
59
|
expect(device.name).to eq(TEST_NAME)
|
29
60
|
expect(device.key).to eq(TEST_KEY)
|
30
61
|
end
|
31
62
|
end
|
32
63
|
|
33
|
-
describe '
|
34
|
-
it do
|
35
|
-
AutoRemote.
|
64
|
+
describe '#send_message' do
|
65
|
+
it 'sends a message to the device' do
|
66
|
+
result = AutoRemote.send_message(TEST_NAME, TEST_MSG)
|
67
|
+
expect(result).to eq(true)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe '#register_on_device' do
|
72
|
+
it 'register computer on the device' do
|
73
|
+
result = AutoRemote.register_on_device(TEST_NAME, 'autoremote.example.test')
|
74
|
+
expect(result).to eq(true)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe '#remove_device' do
|
79
|
+
it 'removes a device at the end of the test' do
|
80
|
+
result = AutoRemote.remove_device(TEST_NAME)
|
81
|
+
expect(result).to eq(true)
|
36
82
|
end
|
37
83
|
end
|
38
84
|
end
|
data/spec/spec_helper.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.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Magnus Smedberg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -103,6 +103,8 @@ extensions: []
|
|
103
103
|
extra_rdoc_files: []
|
104
104
|
files:
|
105
105
|
- ".gitignore"
|
106
|
+
- ".pullreview.yml"
|
107
|
+
- ".travis.yml"
|
106
108
|
- Gemfile
|
107
109
|
- LICENSE.txt
|
108
110
|
- README.md
|
@@ -111,6 +113,7 @@ files:
|
|
111
113
|
- bin/autoremote
|
112
114
|
- lib/autoremote.rb
|
113
115
|
- lib/autoremote/exceptions.rb
|
116
|
+
- lib/autoremote/net.rb
|
114
117
|
- lib/autoremote/version.rb
|
115
118
|
- spec/autoremote_spec.rb
|
116
119
|
- spec/spec_helper.rb
|