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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d9731d389f8581ca589e4c475195e809d40fe684
4
- data.tar.gz: 7a1088fd196ed63d7f9574c0159b3ae76c14ae8a
3
+ metadata.gz: 65f03c0bc3a9456d9a59737a15346bafffbdd567
4
+ data.tar.gz: cb47099496f1c2bb2990c9858061a2fe3a44fcdc
5
5
  SHA512:
6
- metadata.gz: afed78c4605eefccd392e72e9ec91e1381d7bb4b1f836d9fd8858f98b051fd1cde59eb562f941d0a5770136f0ef0302ba86549a81aeaef066d987cc2eaabb6de
7
- data.tar.gz: 42dadd06118f24ed4a18892ff9124b69c3a70566ff8dbeea80bbaa676871761459e20b7496559da1cea8fa9add5e4a2b9b0341f3372ef02e02b3d9fd2151806f
6
+ metadata.gz: 6763d9e3e898fae41f26da4687f63d95c053fa6f0a3df8b691b25927345dce99918592762b0210ef4a298aff63c5ccc2af72689edaf043d37d0eba694f3fe8a0
7
+ data.tar.gz: be3d51e59593f49c8926a61418a89e9f4c48d5c121934524a96652c828b66d907ab2963801cec46c8b1baeb18e46b09322d19d35eca33797c6ca6a83734067ee
@@ -1,4 +1,4 @@
1
- Copyright (c) 2015 TODO: Write your name
1
+ Copyright (c) 2015 AltonV (https://github.com/AltonV)
2
2
 
3
3
  MIT License
4
4
 
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.
@@ -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 = ["Yurij"]
10
- spec.email = ["yurij@yurijware.com"]
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"
@@ -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
- url = URI.parse( VALIDATIONURL.sub( /%YOUR_KEY%/, key ) )
42
- result = Net::HTTP.start(url.host, url.port) {|http|
43
- http.request( Net::HTTP::Get.new( url.to_s ) )
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
- url = URI.parse( MSGURL.sub( /%YOUR_KEY%/, device.key ).sub( /%MESSAGE%/, message ).sub( /%SENDER_ID%/, hostname ) )
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
@@ -1,3 +1,3 @@
1
1
  module AutoRemote
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
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.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
- - Yurij
7
+ - AltonV
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-16 00:00:00.000000000 Z
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
- - yurij@yurijware.com
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
Binary file