Class: ProcessWanker::ConfigClientHost

Inherits:
ConfigNode
  • Object
show all
Defined in:
lib/config/config_client_host.rb

Instance Attribute Summary collapse

Attributes inherited from ConfigNode

#container

Instance Method Summary collapse

Methods inherited from ConfigNode

#find_attributes, #get_auth

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

#authObject

Returns the value of attribute auth.



35
36
37
# File 'lib/config/config_client_host.rb', line 35

def auth
  @auth
end

#hostnameObject

Returns the value of attribute hostname.



32
33
34
# File 'lib/config/config_client_host.rb', line 32

def hostname
  @hostname
end

#nameObject

Returns the value of attribute name.



31
32
33
# File 'lib/config/config_client_host.rb', line 31

def name
  @name
end

#portObject

Returns the value of attribute port.



33
34
35
# File 'lib/config/config_client_host.rb', line 33

def port
  @port
end

#tagsObject

Returns the value of attribute tags.



34
35
36
# File 'lib/config/config_client_host.rb', line 34

def tags
  @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(tags.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