hover 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 15ed26a7f13fb33d8743eac249d4862d1e1d68e4
4
- data.tar.gz: ca9286fbf9cc8ac54114d63463855e2e7da0298f
3
+ metadata.gz: cb17f2689084081199895642c2b44998a5d78e93
4
+ data.tar.gz: a76592e80b06e17700b1dd7930b85f47c79b1982
5
5
  SHA512:
6
- metadata.gz: c61675068403c45323dbf963ec626f3140610ff436ae7d5b0c4a4daef30b2662a158ab006278ef779de6b278bc15a05dd8ea597fa5e0cd6e38dd8516749f376e
7
- data.tar.gz: 6d921d3d5bdb9d46409a7b7d1d22fbcbf6d14d40fb03d1bf9091dd4f6da2089051fcabffddb097ee0d18a2368774630fa0513835d4378dec1f3760e4d7ca32b3
6
+ metadata.gz: e5a8742c571e8f410c7364416d3e044a36b3fa83b4d0a28af3e9cb392a7bb50a65fb7d0be17316f973cd031d2df6c2edd29209ce94648db5fe30aced7af34fbf
7
+ data.tar.gz: 91d2198c7709463fd10ec91154766314e03f81245b40ac9ced76988c79eeaaab1a7091c93a0e161c7d97c77daddc9d2c70dc715d863556b86031510532a1a841
@@ -1 +1 @@
1
- 2.0.0
1
+ 2.0.0-p247
data/README.md CHANGED
@@ -28,6 +28,10 @@ Fire up irb and you're good to go:
28
28
  # Hash with domains
29
29
  ```
30
30
 
31
+ ## Dynamically updating your DNS records
32
+
33
+ See the [example script included in the project](script/dns).
34
+
31
35
  ## Contributing
32
36
 
33
37
  1. Fork it
@@ -2,7 +2,7 @@ require "hover/version"
2
2
  require "hover/api"
3
3
 
4
4
  # rest-client doesn't allow use to ssl_version (as of 1.6.7)
5
- OpenSSL::SSL::SSLContext::DEFAULT_PARAMS[:ssl_version] = 'SSLv3'
5
+ OpenSSL::SSL::SSLContext::DEFAULT_PARAMS[:ssl_version] = :TLSv1_2
6
6
 
7
7
  module Hover
8
8
  # Your code goes here...
@@ -4,7 +4,7 @@ require 'json'
4
4
  module Hover
5
5
  class Api
6
6
  URL = 'https://www.hover.com/api/'
7
- AUTH_URL = 'https://www.hover.com/signin'
7
+ AUTH_URL = 'https://www.hover.com/api/login'
8
8
 
9
9
  attr_accessor :client, :username, :password
10
10
 
@@ -19,7 +19,7 @@ module Hover
19
19
  def authenticate(username, password)
20
20
  auth = {username: username, password: password}
21
21
  RestClient.post(AUTH_URL, auth) do |response, request, result|
22
- if response.code == 302
22
+ if [302,200].include?(response.code)
23
23
  return response.cookies["hoverauth"]
24
24
  else
25
25
  raise "Failed to authenticate"
@@ -1,3 +1,3 @@
1
1
  module Hover
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ #
4
+ # DNS update
5
+ # Example script for updating hover domains
6
+ #
7
+ # This should be pretty self explanatory. Domains should
8
+ # just be in the format www.google.com or so. Also, this
9
+ # requires curl if you don't set IP_ADDRESS in your env.
10
+ #
11
+
12
+ require 'rubygems'
13
+ require 'hover'
14
+
15
+ current_ip = ENV['IP_ADDRESS'] || %x{curl icanhazip.com}
16
+ username = ENV['HOVER_USER'] or fail "No hover username supplied"
17
+ password = ENV['HOVER_PASS'] or fail "No hover password supplied"
18
+ domains = ENV['HOVER_DOMAINS'].split(",") or fail "No hover domains supplied"
19
+
20
+ $api = Hover::Api.new(username, password)
21
+
22
+ def update_domain(full_name, ip)
23
+ subdomain = full_name[/^[^.]*/, 0]
24
+ domain_name = full_name[/^[^.]*\.(.*)$/, 1]
25
+
26
+ domains = $api.dns
27
+ domains.each do |domain|
28
+ if domain["domain_name"] == domain_name
29
+ domain["entries"].each do |entry|
30
+ next if entry["type"] != "A"
31
+
32
+ if entry["name"] == subdomain
33
+ dns_id = entry["id"]
34
+ $api.update_record(dns_id, {content: ip})
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+
41
+ domains.each do |domain|
42
+ update_domain(domain, current_ip)
43
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hover
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Davis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-02 00:00:00.000000000 Z
11
+ date: 2017-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -84,6 +84,7 @@ files:
84
84
  - lib/hover.rb
85
85
  - lib/hover/api.rb
86
86
  - lib/hover/version.rb
87
+ - script/dns
87
88
  homepage: https://github.com/daviddavis/hover
88
89
  licenses:
89
90
  - MIT
@@ -104,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
105
  version: '0'
105
106
  requirements: []
106
107
  rubyforge_project:
107
- rubygems_version: 2.0.3
108
+ rubygems_version: 2.6.10
108
109
  signing_key:
109
110
  specification_version: 4
110
111
  summary: Gem for using Hover.com's API.