inwxupdate 0.3.0 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 01e732ecc8b4eb0888b1b0c12a5961c141f55819
4
- data.tar.gz: 2fdcfc0a819ff787be13a67348874b38651f7a39
3
+ metadata.gz: ca12c4a0d61084e1ca666c3367454555b2dca10d
4
+ data.tar.gz: b6d5006de0d613a30625fe3f65508199287a59ab
5
5
  SHA512:
6
- metadata.gz: 94821898e8e59d13f57f92eeaae5e78e7bfea95c38ce97b6dc317bdf6835d8d7308c1c388f1388194dfca85278c75536cd406258606fe6249a467cb1062beae6
7
- data.tar.gz: 59a006f5174f0037691b162ddbef67f7e43feef574bcccc74fa9c9136843e347e099b5b55052a5c7f75e92351017d4a9622252374e94586570b89fbee31d2dff
6
+ metadata.gz: 65971323673dc858410af80afa53919ee200aa3121b66aa1f40db1e1843a7025dc9809e86c3fa1db219d7e0a8b3a9fc9c026028d99180aea788c15782c3182f8
7
+ data.tar.gz: 85ba97c3d1e92385448572d8325f32addc47d803289e28c2c347c757f04878dba3036d59f26ebe1a24cf625ae94513ec67e0045163cadbc9e14e0b94a3e5b271
@@ -1,11 +1,28 @@
1
+ # Wraps around different detector implementations
1
2
  module Detector
2
- def self.setup(paramters)
3
- if paramters[:type] == 'ifconfig' && paramters[:version] == 6
4
- return Ifconfig.new(paramters[:network_interface], paramters[:version])
5
- end
6
-
7
- if paramters[:type] == 'ipify'
8
- return Ipify.new(paramters[:network_interface], paramters[:version])
9
- end
3
+ def self.setup(params)
4
+ ifconfig(params) ||
5
+ ipify(params) ||
6
+ ruby_sockets(params) ||
7
+ timestamp(params)
8
+ end
9
+
10
+ def self.ifconfig(params)
11
+ return unless params[:type] == 'ifconfig' && params[:version] == 6
12
+
13
+ Ifconfig.new(params[:network_interface], params[:version])
14
+ end
15
+
16
+ def self.ipify(params)
17
+ return unless params[:type] == 'ipify'
18
+ Ipify.new(params[:network_interface], params[:version])
19
+ end
20
+
21
+ def self.ruby_sockets(params)
22
+ Ruby.new(params[:version]) if params[:type] == 'ruby'
23
+ end
24
+
25
+ def self.timestamp(params)
26
+ Timestamp.new if params[:type] == 'timestamp'
10
27
  end
11
28
  end
@@ -7,7 +7,14 @@ class Ifconfig
7
7
  end
8
8
 
9
9
  def detect
10
- raw = `ifconfig #{@network_interface} inet6 | grep inet6 | grep -v fe80 | grep -v deprecated`
10
+ command = [
11
+ "ifconfig #{@network_interface} inet6",
12
+ 'grep inet6',
13
+ 'grep -v fe80',
14
+ 'grep -v deprecated'
15
+ ].join(' | ')
16
+
17
+ raw = `#{command}`
11
18
  ip = raw.lstrip.split(' ')[1]
12
19
 
13
20
  raise 'no ip detected' unless ip
@@ -10,7 +10,15 @@ class Ipify
10
10
  end
11
11
 
12
12
  def detect
13
- ip = `curl -#{@version} --interface #{@network_interface} 'https://api.ipify.org?format=text' -s`
13
+ command = [
14
+ 'curl',
15
+ "-#{@version}",
16
+ "--interface #{@network_interface}",
17
+ "'https://api.ipify.org?format=text'",
18
+ '-s'
19
+ ].join(' ')
20
+
21
+ ip = `#{command}`
14
22
 
15
23
  raise 'no ip detected' unless ip
16
24
 
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+ require 'socket'
3
+
4
+ # Detects your current IP via Ruby Sockets
5
+ class Ruby
6
+ def initialize(version)
7
+ @version = version == 6 ? 6 : 4
8
+ end
9
+
10
+ def detect
11
+ ip_addresses =
12
+ if @version == 6
13
+ Socket.ip_address_list.select(&:ipv6?).reject(&:ipv6_loopback?)
14
+ else
15
+ Socket.ip_address_list.select(&:ipv4?).reject(&:ipv4_loopback?)
16
+ end
17
+
18
+ ip = ip_addresses.first.ip_address
19
+
20
+ raise 'no ip detected' unless ip
21
+
22
+ ip
23
+ end
24
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Detects your current date
4
+ class Timestamp
5
+ def initialize; end
6
+
7
+ def detect
8
+ Time.now.to_s
9
+ end
10
+ end
@@ -22,6 +22,7 @@ end
22
22
 
23
23
  # Implements the convienience
24
24
  class APIObject
25
+ # rubocop:disable Style/MethodMissing
25
26
  def self.method_missing(*args)
26
27
  args = [name.downcase] + args
27
28
 
@@ -31,6 +32,7 @@ class APIObject
31
32
 
32
33
  result['resData']
33
34
  end
35
+ # rubocop:enable Style/MethodMissing
34
36
  end
35
37
 
36
38
  class Account < APIObject; end
@@ -4,9 +4,12 @@ require_relative 'inwx.rb'
4
4
  require_relative 'detectors/detector.rb'
5
5
  require_relative 'detectors/ifconfig.rb'
6
6
  require_relative 'detectors/ipify.rb'
7
+ require_relative 'detectors/ruby.rb'
8
+ require_relative 'detectors/timestamp.rb'
7
9
 
8
10
  require 'simpleidn'
9
11
 
12
+ # Update inwx DNS records
10
13
  class Inwxupdate
11
14
  def run
12
15
  find_config!
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inwxupdate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steffen Schröder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-16 00:00:00.000000000 Z
11
+ date: 2017-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: simpleidn
@@ -35,11 +35,13 @@ files:
35
35
  - lib/detectors/detector.rb
36
36
  - lib/detectors/ifconfig.rb
37
37
  - lib/detectors/ipify.rb
38
+ - lib/detectors/ruby.rb
39
+ - lib/detectors/timestamp.rb
38
40
  - lib/inwx.rb
39
41
  - lib/inwxupdate.rb
40
42
  homepage: https://github.com/ChaosSteffen/inwxupdate
41
43
  licenses:
42
- - BSD
44
+ - BSD-2-Clause
43
45
  metadata: {}
44
46
  post_install_message:
45
47
  rdoc_options: []