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
- #extra_info ⇒ Object
- #from_hash(h) ⇒ Object
-
#initialize(name, version, exception = nil, action = 'UPDATE', extra_info = nil, ts = Time.now) ⇒ AuditItem
constructor
A new instance of AuditItem.
- #name ⇒ Object
- #set_extra_info(hash) ⇒ 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).
- #version ⇒ Object
Constructor Details
#initialize(name, version, exception = nil, action = 'UPDATE', extra_info = nil, ts = Time.now) ⇒ AuditItem
Returns a new instance of AuditItem.
255 256 257 258 259 260 261 262 |
# File 'lib/gitchefsync/audit.rb', line 255 def initialize(name, version, exception = nil, action = 'UPDATE', extra_info = nil, ts = Time.now) @name = name @version = version @ts = ts.to_i @exception = exception @action = action @extra_info = extra_info end |
Instance Method Details
#ex ⇒ Object
270 271 272 |
# File 'lib/gitchefsync/audit.rb', line 270 def ex @exception end |
#extra_info ⇒ Object
288 289 290 |
# File 'lib/gitchefsync/audit.rb', line 288 def extra_info @extra_info end |
#from_hash(h) ⇒ Object
313 314 315 316 317 318 319 320 321 322 323 |
# File 'lib/gitchefsync/audit.rb', line 313 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']) @extra_info = h['extra_info'] return self end |
#name ⇒ Object
264 265 266 |
# File 'lib/gitchefsync/audit.rb', line 264 def name @name end |
#set_extra_info(hash) ⇒ Object
291 292 293 |
# File 'lib/gitchefsync/audit.rb', line 291 def set_extra_info hash @extra_info = hash end |
#setAction(action) ⇒ Object
TODO action should be an enumeration
284 285 286 |
# File 'lib/gitchefsync/audit.rb', line 284 def setAction action @action = action end |
#setCookbook(cb) ⇒ Object
279 280 281 |
# File 'lib/gitchefsync/audit.rb', line 279 def setCookbook(cb) @cookbook = cb end |
#setType(type) ⇒ Object
types are CB and ENV
275 276 277 |
# File 'lib/gitchefsync/audit.rb', line 275 def setType type @type = type end |
#to_hash ⇒ Object
this method doesn’t work when called when exception is created from json (from_hash)
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 |
# File 'lib/gitchefsync/audit.rb', line 295 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[:extra_info] = @extra_info unless @extra_info == nil h end |
#version ⇒ Object
267 268 269 |
# File 'lib/gitchefsync/audit.rb', line 267 def version @version end |