Class: ProcessWanker::ConfigClientHost
- Inherits:
-
ConfigNode
- Object
- ConfigNode
- ProcessWanker::ConfigClientHost
- Defined in:
- lib/config/config_client_host.rb
Instance Attribute Summary collapse
-
#auth ⇒ Object
Returns the value of attribute auth.
-
#hostname ⇒ Object
Returns the value of attribute hostname.
-
#name ⇒ Object
Returns the value of attribute name.
-
#port ⇒ Object
Returns the value of attribute port.
-
#tags ⇒ Object
Returns the value of attribute tags.
Attributes inherited from ConfigNode
Instance Method Summary collapse
-
#initialize(name) ⇒ ConfigClientHost
constructor
A new instance of ConfigClientHost.
- #matches_single(p, prev) ⇒ Object
- #matches_spec(spec) ⇒ Object
Methods inherited from ConfigNode
Constructor Details
#initialize(name) ⇒ ConfigClientHost
Returns a new instance of ConfigClientHost.
37 38 39 40 41 42 |
# File 'lib/config/config_client_host.rb', line 37 def initialize(name) @name=name @hostname=name @tags={} @port=NetUtil::DEFAULT_PORT end |
Instance Attribute Details
#auth ⇒ Object
Returns the value of attribute auth.
35 36 37 |
# File 'lib/config/config_client_host.rb', line 35 def auth @auth end |
#hostname ⇒ Object
Returns the value of attribute hostname.
32 33 34 |
# File 'lib/config/config_client_host.rb', line 32 def hostname @hostname end |
#name ⇒ Object
Returns the value of attribute name.
31 32 33 |
# File 'lib/config/config_client_host.rb', line 31 def name @name end |
#port ⇒ Object
Returns the value of attribute port.
33 34 35 |
# File 'lib/config/config_client_host.rb', line 33 def port @port end |
#tags ⇒ Object
Returns the value of attribute tags.
34 35 36 |
# File 'lib/config/config_client_host.rb', line 34 def @tags end |
Instance Method Details
#matches_single(p, prev) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/config/config_client_host.rb', line 75 def matches_single(p,prev) if(p == "all") return(true) elsif(p[0..0] == "/") r=Regexp.new(p.split("/")[1]) return(true) if(hostname =~ r) return(true) if(name =~ r) elsif(p[0..0] == "~") return(prev && !matches_single(p[1..-1],false)) elsif(p[0..3] == "tag:") tag=p[4..-1] return(true) if(.include?(tag)) elsif(p == name) return(true) elsif(p == hostname) return(true) end prev end |
#matches_spec(spec) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/config/config_client_host.rb', line 50 def matches_spec(spec) # ensure it's in array form spec=spec.split(",") # check for inversion on first item if(spec.first[0..0]=="~") # insert implicit "all" at front spec=["all"] + spec end matches=false spec.each do |p| matches = matches_single(p,matches) end matches end |