Class: Gitchefsync::AuditItem
- Inherits:
-
Object
- Object
- Gitchefsync::AuditItem
- Defined in:
- lib/gitchefsync/audit.rb
Overview
contains functionality associated to audit information gathering TODO: just reference Cookbook clas in knife_util
Instance Method Summary collapse
- #ex ⇒ Object
- #from_hash(h) ⇒ Object
-
#initialize(name, version, exception = nil, action = 'UPDATE', ts = Time.now) ⇒ AuditItem
constructor
A new instance of AuditItem.
- #name ⇒ Object
-
#setAction(action) ⇒ Object
TODO action should be an enumeration.
- #setCookbook(cb) ⇒ Object
-
#setType(type) ⇒ Object
types are CB and ENV.
-
#to_hash ⇒ Object
this method doesn’t work when called when exception is created from json (from_hash).
Constructor Details
#initialize(name, version, exception = nil, action = 'UPDATE', ts = Time.now) ⇒ AuditItem
161 162 163 164 165 166 167 |
# File 'lib/gitchefsync/audit.rb', line 161 def initialize(name, version, exception = nil, action = 'UPDATE', ts = Time.now) @name = name @version = version @ts = ts.to_i @exception = exception @action = action end |
Instance Method Details
#ex ⇒ Object
172 173 174 |
# File 'lib/gitchefsync/audit.rb', line 172 def ex @exception end |
#from_hash(h) ⇒ Object
208 209 210 211 212 213 214 215 216 217 |
# File 'lib/gitchefsync/audit.rb', line 208 def from_hash(h) @name = h['name'] @ts = h['ts'] @exception = h['exception'] @version = h['version'] @type = h['type'] @action = h['action'] @cookbook = Cookbook.new(@name,@version,h['maintainer'],h['maintainer_email']) return self end |
#name ⇒ Object
169 170 171 |
# File 'lib/gitchefsync/audit.rb', line 169 def name @name end |
#setAction(action) ⇒ Object
TODO action should be an enumeration
186 187 188 |
# File 'lib/gitchefsync/audit.rb', line 186 def setAction action @action = action end |
#setCookbook(cb) ⇒ Object
181 182 183 |
# File 'lib/gitchefsync/audit.rb', line 181 def setCookbook(cb) @cookbook = cb end |
#setType(type) ⇒ Object
types are CB and ENV
177 178 179 |
# File 'lib/gitchefsync/audit.rb', line 177 def setType type @type = type end |
#to_hash ⇒ Object
this method doesn’t work when called when exception is created from json (from_hash)
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/gitchefsync/audit.rb', line 191 def to_hash h = Hash.new h[:name] = @name h[:ts] = @ts if @exception.is_a? Exception h[:exception] = @exception. unless @exception == nil else h[:exception] = @exception unless @exception == nil end h[:version] = @version unless @version == nil h[:type] = @type unless @type == nil h[:action] = @action unless @action == nil h[:maintainer] = @cookbook.maintainer unless @cookbook == nil h[:maintainer_email] = @cookbook.maintainer_email unless @cookbook == nil h end |