Class: Puppet::Property::KeyValue
Constant Summary
Constants included
from Util::Docs
Util::Docs::HEADER_LEVELS
Constants included
from Util
Util::AbsolutePathPosix, Util::AbsolutePathWindows
Instance Attribute Summary
#noop, #shadow, #shouldorig
#parent, #resource
Attributes included from Util::Docs
#doc, #nodoc
Instance Method Summary
collapse
array_matching, array_matching=, #call_provider, #call_valuemethod, #change_to_s, #event, #event_name, #initialize, #log, #match_all?, method_added, #munge, #name, newvalue, #property_matches?, #safe_insync?, #set, #setup_shadow, #should=, #sync, #unsafe_validate, #validate_features_per_value, #value, #value=, value_name, value_option
aliasvalue, defaultto, desc, #devfail, doc, #fail, format_value_for_display, #initialize, initvars, isnamevar, isnamevar?, isrequired, #log, #metaparam?, #munge, munge, #name, newvalues, nodefault, #noop, #pathbuilder, #provider, proxymethods, #remove, required?, #tags, #to_s, unmunge, #unmunge, #unsafe_munge, #unsafe_validate, validate, #validate, #value, #value=
Methods included from Util::Docs
#desc, #dochook, #doctable, #markdown_definitionlist, #markdown_header, #nodoc?, #pad, scrub
Methods included from Util
absolute_path?, activerecord_version, benchmark, binread, chuser, classproxy, #execfail, #execpipe, execute, execute_posix, execute_windows, logmethods, memory, path_to_uri, proxy, replace_file, safe_posix_fork, symbolize, symbolizehash, symbolizehash!, synchronize_on, thinmark, #threadlock, uri_to_path, wait_for_output, which, withumask
#get_posix_field, #gid, #idfield, #methodbyid, #methodbyname, #search_posix_field, #uid
#requiredopts, #set_options, #symbolize_options
#clear_deprecation_warnings, #deprecation_warning, #send_log
#path, #source_descriptors
#adderrorcontext, #devfail, #error_context, #exceptwrap, #fail
Instance Method Details
#delimiter ⇒ Object
66
67
68
|
# File 'lib/vendor/puppet/property/keyvalue.rb', line 66
def delimiter
";"
end
|
#hash_to_key_value_s(hash) ⇒ Object
15
16
17
|
# File 'lib/vendor/puppet/property/keyvalue.rb', line 15
def hash_to_key_value_s(hash)
hash.select { |k,v| true }.map { |pair| pair.join(separator) }.join(delimiter)
end
|
#hashify(key_value_array) ⇒ Object
35
36
37
38
39
40
41
42
|
# File 'lib/vendor/puppet/property/keyvalue.rb', line 35
def hashify(key_value_array)
key_value_array.inject({}) do |hash, key_value|
tmp = key_value.split(separator)
hash[tmp[0].intern] = tmp[1]
hash
end
end
|
#inclusive? ⇒ Boolean
31
32
33
|
# File 'lib/vendor/puppet/property/keyvalue.rb', line 31
def inclusive?
@resource[membership] == :inclusive
end
|
#insync?(is) ⇒ Boolean
79
80
81
82
83
|
# File 'lib/vendor/puppet/property/keyvalue.rb', line 79
def insync?(is)
return true unless is
(is == self.should)
end
|
#is_to_s(current_value) ⇒ Object
23
24
25
|
# File 'lib/vendor/puppet/property/keyvalue.rb', line 23
def is_to_s(current_value)
hash_to_key_value_s(current_value)
end
|
#membership ⇒ Object
27
28
29
|
# File 'lib/vendor/puppet/property/keyvalue.rb', line 27
def membership
:key_value_membership
end
|
#process_current_hash(current) ⇒ Object
44
45
46
47
48
49
50
|
# File 'lib/vendor/puppet/property/keyvalue.rb', line 44
def process_current_hash(current)
return {} if current == :absent
current.each_key { |key| current[key] = nil } if inclusive?
current
end
|
70
71
72
73
74
75
76
77
|
# File 'lib/vendor/puppet/property/keyvalue.rb', line 70
def retrieve
if key_hash = provider.send(name) and key_hash != :absent
return key_hash
else
return :absent
end
end
|
#separator ⇒ Object
62
63
64
|
# File 'lib/vendor/puppet/property/keyvalue.rb', line 62
def separator
"="
end
|
52
53
54
55
56
57
58
59
60
|
# File 'lib/vendor/puppet/property/keyvalue.rb', line 52
def should
return nil unless @should
members = hashify(@should)
current = process_current_hash(retrieve)
current.merge(members)
end
|
#should_to_s(should_value) ⇒ Object
19
20
21
|
# File 'lib/vendor/puppet/property/keyvalue.rb', line 19
def should_to_s(should_value)
hash_to_key_value_s(should_value)
end
|