vagrant-dnsdock-hostupdater 0.0.33 → 0.0.35
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/version.rb +1 -1
- metadata +1 -29
- data/Gemfile.lock +0 -29
- data/lib/hosts/aef/hosts.rb +0 -51
- data/lib/hosts/aef/hosts/comment.rb +0 -73
- data/lib/hosts/aef/hosts/element.rb +0 -108
- data/lib/hosts/aef/hosts/empty_element.rb +0 -50
- data/lib/hosts/aef/hosts/entry.rb +0 -123
- data/lib/hosts/aef/hosts/file.rb +0 -252
- data/lib/hosts/aef/hosts/helpers.rb +0 -121
- data/lib/hosts/aef/hosts/section.rb +0 -141
- data/lib/hosts/aef/hosts/version.rb +0 -29
- data/lib/hosts/aef/linebreak/linebreak.rb +0 -148
- data/lib/hosts/hosts.rb +0 -25
- data/lib/hosts/hosts/bare.rb +0 -23
- data/lib/vagrant-dnsdock-hostupdater/command.rb +0 -12
- data/lib/vagrant-dnsdock-hostupdater/plugin.rb +0 -90
- data/vagrant-dnsdock-hostupdater.gemspec +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33366277863508bb4241d570af0e1fa3f481540c
|
4
|
+
data.tar.gz: e05a7f8d007cf6c255768e0caf2964d0efc6ae7b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2cc0a990b91a079e9685d234b93073427d80318f200f96a04b624cde5ca9496aefdfa9704379bf6c30d4c56951f1929cd17040782e0e05356694abc364b4562e
|
7
|
+
data.tar.gz: 417e2b17d5534e128c946213611e16338d022e0b6db475c03a219c7f2bfbd422a6fe5af1a06295bd2de602a439ab21361ed72e6be979f5696952fee88d15ed0b
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-dnsdock-hostupdater
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.35
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Coit
|
@@ -31,9 +31,6 @@ dependencies:
|
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.1'
|
34
|
-
- - ">="
|
35
|
-
- !ruby/object:Gem::Version
|
36
|
-
version: 1.1.10
|
37
34
|
type: :runtime
|
38
35
|
prerelease: false
|
39
36
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -41,9 +38,6 @@ dependencies:
|
|
41
38
|
- - "~>"
|
42
39
|
- !ruby/object:Gem::Version
|
43
40
|
version: '1.1'
|
44
|
-
- - ">="
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: 1.1.10
|
47
41
|
- !ruby/object:Gem::Dependency
|
48
42
|
name: linebreak
|
49
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -51,9 +45,6 @@ dependencies:
|
|
51
45
|
- - "~>"
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '2.1'
|
54
|
-
- - ">="
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
version: 2.1.0
|
57
48
|
type: :runtime
|
58
49
|
prerelease: false
|
59
50
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -61,9 +52,6 @@ dependencies:
|
|
61
52
|
- - "~>"
|
62
53
|
- !ruby/object:Gem::Version
|
63
54
|
version: '2.1'
|
64
|
-
- - ">="
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version: 2.1.0
|
67
55
|
description: |
|
68
56
|
vagrant-dnsdock-hostupdater is a Vagrant plugin which provides the ability to keep the host machines hosts file
|
69
57
|
configured to point at bridged docker containers based on container names: e.g. <container_name>.local.signal.sh.
|
@@ -74,30 +62,14 @@ extensions: []
|
|
74
62
|
extra_rdoc_files: []
|
75
63
|
files:
|
76
64
|
- Gemfile
|
77
|
-
- Gemfile.lock
|
78
65
|
- Rakefile
|
79
66
|
- lib/client.rb
|
80
67
|
- lib/event-watcher.rb
|
81
68
|
- lib/host-manager.rb
|
82
|
-
- lib/hosts/aef/hosts.rb
|
83
|
-
- lib/hosts/aef/hosts/comment.rb
|
84
|
-
- lib/hosts/aef/hosts/element.rb
|
85
|
-
- lib/hosts/aef/hosts/empty_element.rb
|
86
|
-
- lib/hosts/aef/hosts/entry.rb
|
87
|
-
- lib/hosts/aef/hosts/file.rb
|
88
|
-
- lib/hosts/aef/hosts/helpers.rb
|
89
|
-
- lib/hosts/aef/hosts/section.rb
|
90
|
-
- lib/hosts/aef/hosts/version.rb
|
91
|
-
- lib/hosts/aef/linebreak/linebreak.rb
|
92
|
-
- lib/hosts/hosts.rb
|
93
|
-
- lib/hosts/hosts/bare.rb
|
94
69
|
- lib/launch-control
|
95
70
|
- lib/server.rb
|
96
71
|
- lib/vagrant-dnsdock-hostupdater.rb
|
97
|
-
- lib/vagrant-dnsdock-hostupdater/command.rb
|
98
|
-
- lib/vagrant-dnsdock-hostupdater/plugin.rb
|
99
72
|
- lib/version.rb
|
100
|
-
- vagrant-dnsdock-hostupdater.gemspec
|
101
73
|
homepage: https://bitbucket.org/briancoit
|
102
74
|
licenses:
|
103
75
|
- ISC
|
data/Gemfile.lock
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
vagrant-dnsdock-hostupdater (0.0.30)
|
5
|
-
bundler (~> 1.3)
|
6
|
-
docker-api (~> 1.33)
|
7
|
-
linebreak (~> 2.1.0)
|
8
|
-
log4r (~> 1.1.10)
|
9
|
-
|
10
|
-
GEM
|
11
|
-
remote: http://rubygems.org/
|
12
|
-
specs:
|
13
|
-
docker-api (1.33.2)
|
14
|
-
excon (>= 0.38.0)
|
15
|
-
json
|
16
|
-
excon (0.54.0)
|
17
|
-
json (2.0.3)
|
18
|
-
linebreak (2.1.0)
|
19
|
-
log4r (1.1.10)
|
20
|
-
|
21
|
-
PLATFORMS
|
22
|
-
ruby
|
23
|
-
x64-mingw32
|
24
|
-
|
25
|
-
DEPENDENCIES
|
26
|
-
vagrant-dnsdock-hostupdater!
|
27
|
-
|
28
|
-
BUNDLED WITH
|
29
|
-
1.14.6
|
data/lib/hosts/aef/hosts.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
=begin
|
3
|
-
Copyright Alexander E. Fischer <aef@raxys.net>, 2012
|
4
|
-
|
5
|
-
This file is part of Hosts.
|
6
|
-
|
7
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
8
|
-
purpose with or without fee is hereby granted, provided that the above
|
9
|
-
copyright notice and this permission notice appear in all copies.
|
10
|
-
|
11
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
12
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
13
|
-
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
14
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
15
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
16
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
17
|
-
PERFORMANCE OF THIS SOFTWARE.
|
18
|
-
=end
|
19
|
-
|
20
|
-
require 'set'
|
21
|
-
require 'pathname'
|
22
|
-
require_relative 'linebreak/linebreak'
|
23
|
-
|
24
|
-
# Namespace for projects of Alexander E. Fischer <aef@raxys.net>.
|
25
|
-
#
|
26
|
-
# If you want to be able to simply type Example instead of Aef::Example to
|
27
|
-
# address classes in this namespace simply write the following before using the
|
28
|
-
# classes.
|
29
|
-
#
|
30
|
-
# @example Including the namespace
|
31
|
-
# include Aef
|
32
|
-
# @author Alexander E. Fischer
|
33
|
-
module Aef
|
34
|
-
|
35
|
-
# Namespace for the hosts library
|
36
|
-
module Hosts
|
37
|
-
|
38
|
-
# An exception for errors happening while parsing a hosts file
|
39
|
-
class ParserError < RuntimeError; end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
require_relative 'hosts/version'
|
44
|
-
require_relative 'hosts/helpers'
|
45
|
-
require_relative 'hosts/file'
|
46
|
-
require_relative 'hosts/element'
|
47
|
-
require_relative 'hosts/section'
|
48
|
-
require_relative 'hosts/entry'
|
49
|
-
require_relative 'hosts/comment'
|
50
|
-
require_relative 'hosts/empty_element'
|
51
|
-
|
@@ -1,73 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
=begin
|
3
|
-
Copyright Alexander E. Fischer <aef@raxys.net>, 2012
|
4
|
-
|
5
|
-
This file is part of Hosts.
|
6
|
-
|
7
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
8
|
-
purpose with or without fee is hereby granted, provided that the above
|
9
|
-
copyright notice and this permission notice appear in all copies.
|
10
|
-
|
11
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
12
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
13
|
-
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
14
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
15
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
16
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
17
|
-
PERFORMANCE OF THIS SOFTWARE.
|
18
|
-
=end
|
19
|
-
|
20
|
-
require_relative '../hosts'
|
21
|
-
|
22
|
-
module Aef
|
23
|
-
module Hosts
|
24
|
-
|
25
|
-
# Represents a comment-only line as element of a hosts file
|
26
|
-
class Comment < Element
|
27
|
-
|
28
|
-
# The comment
|
29
|
-
#
|
30
|
-
# @return [String]
|
31
|
-
attr_reader :comment
|
32
|
-
|
33
|
-
# Initializes a comment
|
34
|
-
#
|
35
|
-
# @param comment [String] the comment
|
36
|
-
# @param options [Hash]
|
37
|
-
# @option options [String] :cache sets a cached String representation
|
38
|
-
def initialize(comment, options = {})
|
39
|
-
validate_options(options, :cache)
|
40
|
-
|
41
|
-
raise ArgumentError, 'Comment cannot be empty' unless comment
|
42
|
-
|
43
|
-
@comment = comment.to_s
|
44
|
-
@cache = options[:cache].to_s unless options[:cache].nil?
|
45
|
-
end
|
46
|
-
|
47
|
-
# Sets the comment
|
48
|
-
def comment=(comment)
|
49
|
-
set_if_changed(:comment, comment.to_s) do
|
50
|
-
invalidate_cache!
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
# A String representation for debugging purposes
|
55
|
-
#
|
56
|
-
# @return [String]
|
57
|
-
def inspect
|
58
|
-
generate_inspect(self, :comment, :cache)
|
59
|
-
end
|
60
|
-
|
61
|
-
protected
|
62
|
-
|
63
|
-
# Defines the algorithm to generate a String representation from scratch.
|
64
|
-
#
|
65
|
-
# @return [String] a generated String representation
|
66
|
-
def generate_string(options = {})
|
67
|
-
"##{comment}\n"
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
@@ -1,108 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
=begin
|
3
|
-
Copyright Alexander E. Fischer <aef@raxys.net>, 2012
|
4
|
-
|
5
|
-
This file is part of Hosts.
|
6
|
-
|
7
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
8
|
-
purpose with or without fee is hereby granted, provided that the above
|
9
|
-
copyright notice and this permission notice appear in all copies.
|
10
|
-
|
11
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
12
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
13
|
-
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
14
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
15
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
16
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
17
|
-
PERFORMANCE OF THIS SOFTWARE.
|
18
|
-
=end
|
19
|
-
|
20
|
-
require_relative '../hosts'
|
21
|
-
|
22
|
-
module Aef
|
23
|
-
module Hosts
|
24
|
-
|
25
|
-
# The base class for elements which are aggregated by the Aef::Hosts::File
|
26
|
-
# class.
|
27
|
-
#
|
28
|
-
# @abstract This class is not supposed to be instantiated.
|
29
|
-
class Element
|
30
|
-
|
31
|
-
include Helpers
|
32
|
-
|
33
|
-
# Cached String representation
|
34
|
-
#
|
35
|
-
# @return [String, Hash, nil]
|
36
|
-
attr_reader :cache
|
37
|
-
|
38
|
-
# Deletes the cached String representation
|
39
|
-
#
|
40
|
-
# @return [Aef::Hosts::Element] a self reference
|
41
|
-
def invalidate_cache!
|
42
|
-
@cache = nil
|
43
|
-
|
44
|
-
self
|
45
|
-
end
|
46
|
-
|
47
|
-
# Tells if a String representation is cached or not
|
48
|
-
#
|
49
|
-
# @return [true, false] true if cache is not empty
|
50
|
-
def cache_filled?
|
51
|
-
@cache ? true : false
|
52
|
-
end
|
53
|
-
|
54
|
-
# A String representation for debugging purposes
|
55
|
-
#
|
56
|
-
# @return [String]
|
57
|
-
def inspect
|
58
|
-
generate_inspect(self, :cache)
|
59
|
-
end
|
60
|
-
|
61
|
-
# Provides a String representation of the element
|
62
|
-
#
|
63
|
-
# @param [Hash] options
|
64
|
-
# @option options [true, false] :force_generation if set to true, the
|
65
|
-
# cache won't be used, even if it not empty
|
66
|
-
# @option options [:unix, :windows, :mac] :linebreak_encoding the
|
67
|
-
# linebreak encoding of the result. If nothing is specified the result
|
68
|
-
# will be encoded as if :unix was specified.
|
69
|
-
# @see Aef::Linebreak#encode
|
70
|
-
def to_s(options = {})
|
71
|
-
validate_options(options, :force_generation, :linebreak_encoding)
|
72
|
-
|
73
|
-
string = ''
|
74
|
-
|
75
|
-
if !cache_filled? || options[:force_generation]
|
76
|
-
string << generate_string(options)
|
77
|
-
else
|
78
|
-
string << cache_string(options)
|
79
|
-
end
|
80
|
-
|
81
|
-
if options[:linebreak_encoding]
|
82
|
-
string = Aef::Linebreak.encode(string, options[:linebreak_encoding])
|
83
|
-
end
|
84
|
-
|
85
|
-
string
|
86
|
-
end
|
87
|
-
|
88
|
-
protected
|
89
|
-
|
90
|
-
# Defines the algorithm to generate a String representation from scratch.
|
91
|
-
#
|
92
|
-
# @abstract This method needs to be implemented in descendant classes.
|
93
|
-
# @return [String] a generated String representation
|
94
|
-
def generate_string(options = {})
|
95
|
-
raise NotImplementedError
|
96
|
-
end
|
97
|
-
|
98
|
-
# Defines the algorithm to construct the String representation from cache
|
99
|
-
#
|
100
|
-
# @return [String] the cached String representation
|
101
|
-
def cache_string(options = {})
|
102
|
-
@cache.dup
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
@@ -1,50 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
=begin
|
3
|
-
Copyright Alexander E. Fischer <aef@raxys.net>, 2012
|
4
|
-
|
5
|
-
This file is part of Hosts.
|
6
|
-
|
7
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
8
|
-
purpose with or without fee is hereby granted, provided that the above
|
9
|
-
copyright notice and this permission notice appear in all copies.
|
10
|
-
|
11
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
12
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
13
|
-
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
14
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
15
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
16
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
17
|
-
PERFORMANCE OF THIS SOFTWARE.
|
18
|
-
=end
|
19
|
-
|
20
|
-
require_relative '../hosts'
|
21
|
-
|
22
|
-
module Aef
|
23
|
-
module Hosts
|
24
|
-
|
25
|
-
# Represents an empty line as element of a hosts file
|
26
|
-
class EmptyElement < Element
|
27
|
-
|
28
|
-
# Initializes an empty Element
|
29
|
-
#
|
30
|
-
# @param [Hash] options
|
31
|
-
# @option options [String] :cache sets a cached String representation
|
32
|
-
def initialize(options = {})
|
33
|
-
validate_options(options, :cache)
|
34
|
-
|
35
|
-
@cache = options[:cache].to_s unless options[:cache].nil?
|
36
|
-
end
|
37
|
-
|
38
|
-
protected
|
39
|
-
|
40
|
-
# Defines the algorithm to generate a String representation from scratch.
|
41
|
-
#
|
42
|
-
# @return [String] a generated String representation
|
43
|
-
def generate_string(options = {})
|
44
|
-
"\n"
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
@@ -1,123 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
=begin
|
3
|
-
Copyright Alexander E. Fischer <aef@raxys.net>, 2012
|
4
|
-
|
5
|
-
This file is part of Hosts.
|
6
|
-
|
7
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
8
|
-
purpose with or without fee is hereby granted, provided that the above
|
9
|
-
copyright notice and this permission notice appear in all copies.
|
10
|
-
|
11
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
12
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
13
|
-
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
14
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
15
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
16
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
17
|
-
PERFORMANCE OF THIS SOFTWARE.
|
18
|
-
=end
|
19
|
-
|
20
|
-
require_relative '../hosts'
|
21
|
-
|
22
|
-
module Aef
|
23
|
-
module Hosts
|
24
|
-
|
25
|
-
# Represents an entry line as element of a hosts file
|
26
|
-
class Entry < Element
|
27
|
-
|
28
|
-
# The network address
|
29
|
-
#
|
30
|
-
# @return [String]
|
31
|
-
attr_reader :address
|
32
|
-
|
33
|
-
# The primary hostname for the address
|
34
|
-
#
|
35
|
-
# @return [String]
|
36
|
-
attr_reader :name
|
37
|
-
|
38
|
-
# Optional comment
|
39
|
-
#
|
40
|
-
# @return [String]
|
41
|
-
attr_reader :comment
|
42
|
-
|
43
|
-
# Optional alias hostnames
|
44
|
-
#
|
45
|
-
# @return [Array<String>]
|
46
|
-
attr_reader :aliases
|
47
|
-
|
48
|
-
# Initializes an entry.
|
49
|
-
#
|
50
|
-
# @param [String] address the network address
|
51
|
-
# @param [String] name the primary hostname for the address
|
52
|
-
# @param [Hash] options
|
53
|
-
# @option options [Array<String>] :aliases a list of aliases for the
|
54
|
-
# address
|
55
|
-
# @option options [String] :comment a comment for the entry
|
56
|
-
# @option options [String] :cache a cached String representation
|
57
|
-
def initialize(address, name, options = {})
|
58
|
-
validate_options(options, :aliases, :comment, :cache)
|
59
|
-
|
60
|
-
raise ArgumentError, 'Address cannot be empty' unless address
|
61
|
-
raise ArgumentError, 'Name cannot be empty' unless name
|
62
|
-
|
63
|
-
@address = address.to_s
|
64
|
-
@name = name.to_s
|
65
|
-
@aliases = options[:aliases] || []
|
66
|
-
@comment = options[:comment].to_s unless options[:comment].nil?
|
67
|
-
@cache = options[:cache].to_s unless options[:cache].nil?
|
68
|
-
end
|
69
|
-
|
70
|
-
# Sets the network address
|
71
|
-
def address=(address)
|
72
|
-
set_if_changed(:address, address.to_s) do
|
73
|
-
invalidate_cache!
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
# Sets the primary hostname for the address
|
78
|
-
def name=(name)
|
79
|
-
set_if_changed(:name, name.to_s) do
|
80
|
-
invalidate_cache!
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
# Sets the optional comment
|
85
|
-
def comment=(comment)
|
86
|
-
set_if_changed(:comment, comment.to_s) do
|
87
|
-
invalidate_cache!
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
# Sets the optional alias hostnames
|
92
|
-
def aliases=(aliases)
|
93
|
-
set_if_changed(:aliases, [*aliases]) do
|
94
|
-
invalidate_cache!
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
# A String representation for debugging purposes
|
99
|
-
#
|
100
|
-
# @return [String]
|
101
|
-
def inspect
|
102
|
-
generate_inspect(self, :address, :name, :aliases, :comment, :cache)
|
103
|
-
end
|
104
|
-
|
105
|
-
protected
|
106
|
-
|
107
|
-
# Defines the algorithm to generate a String representation from scratch.
|
108
|
-
#
|
109
|
-
# @abstract This method needs to be implemented in descendant classes.
|
110
|
-
# @return [String] a generated String representation
|
111
|
-
def generate_string(options = nil)
|
112
|
-
if comment
|
113
|
-
suffix = " ##{comment}\n"
|
114
|
-
else
|
115
|
-
suffix = "\n"
|
116
|
-
end
|
117
|
-
|
118
|
-
[address, name, *aliases].join(' ') << suffix
|
119
|
-
end
|
120
|
-
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|