Module: Fog::Hyperv
- Extended by:
- Provider
- Defined in:
- lib/fog/model.rb,
lib/fog/hyperv.rb,
lib/fog/collection.rb,
lib/fog/hyperv/version.rb
Defined Under Namespace
Modules: Errors, ModelExtends, ModelIncludes
Classes: Collection, ComputerCollection, Model, VMCollection
Constant Summary
collapse
- VERSION =
'0.0.9'.freeze
Class Method Summary
collapse
Class Method Details
.camelize(data) ⇒ Object
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
# File 'lib/fog/hyperv.rb', line 82
def self.camelize(data)
case data
when Array
data.collect { |d| camelize(d) }
when Hash
data.each_with_object({}) do |(k, v), hash|
value = v
value = camelize(v) if v.is_a?(Hash) || (v.is_a?(Array) && v.all? { |h| h.is_a?(Hash) })
hash[camelize(k)] = value
end
when Symbol
camelize(data.to_s).to_sym
when String
data.split('_').collect(&:capitalize).join
else
data
end
end
|
.shell_quoted(data, always = false) ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/fog/hyperv.rb', line 57
def self.shell_quoted(data, always = false)
case data
when String
if !data.start_with?('$') && (data =~ /(^$)|\s/ || always)
data.gsub(/`/, '``')
.gsub(/\0/, '`0')
.gsub(/\n/, '`n')
.gsub(/\r/, '`r')
.inspect
.gsub(/\\"/, '`"')
.gsub(/\\\\/, '\\')
else
data
end
when Array
'@(' + data.map { |e| shell_quoted(e, true) }.join(', ') + ')'
when FalseClass
'$false'
when TrueClass
'$true'
else
shell_quoted data.to_s
end
end
|
.uncamelize(data) ⇒ Object
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
# File 'lib/fog/hyperv.rb', line 101
def self.uncamelize(data)
case data
when Array
data.collect { |d| uncamelize(d) }
when Hash
data.each_with_object({}) do |(k, v), hash|
value = v
value = uncamelize(v) if v.is_a?(Hash) || (v.is_a?(Array) && v.all? { |h| h.is_a?(Hash) })
hash[uncamelize(k)] = value
end
when Symbol
uncamelize(data.to_s).to_sym
when String
data.to_s
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
.tr('-', '_')
.downcase.to_sym
else
data
end
end
|