Class: Apt::History
- Inherits:
-
Object
- Object
- Apt::History
- Defined in:
- lib/apt/history.rb
Constant Summary collapse
- FILEPATH =
"/var/log/apt/history.log"
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#commandline ⇒ Object
Returns the value of attribute commandline.
-
#end_date ⇒ Object
Returns the value of attribute end_date.
-
#package ⇒ Object
Returns the value of attribute package.
-
#requested_by ⇒ Object
Returns the value of attribute requested_by.
-
#start_date ⇒ Object
Returns the value of attribute start_date.
Class Method Summary collapse
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
7 8 9 |
# File 'lib/apt/history.rb', line 7 def action @action end |
#commandline ⇒ Object
Returns the value of attribute commandline.
7 8 9 |
# File 'lib/apt/history.rb', line 7 def commandline @commandline end |
#end_date ⇒ Object
Returns the value of attribute end_date.
7 8 9 |
# File 'lib/apt/history.rb', line 7 def end_date @end_date end |
#package ⇒ Object
Returns the value of attribute package.
7 8 9 |
# File 'lib/apt/history.rb', line 7 def package @package end |
#requested_by ⇒ Object
Returns the value of attribute requested_by.
7 8 9 |
# File 'lib/apt/history.rb', line 7 def requested_by @requested_by end |
#start_date ⇒ Object
Returns the value of attribute start_date.
7 8 9 |
# File 'lib/apt/history.rb', line 7 def start_date @start_date end |
Class Method Details
.parse(reader) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/apt/history.rb', line 9 def self.parse(reader) result = [] current = nil reader.each do |line| line.chomp! if line.length == 0 if current result <<= current current = nil end next end current = new unless current tag, data = line.split(/: /, 2) case tag when /^(Start|End)-Date$/ r = tag.downcase.gsub("-","_").concat("=").to_sym d = DateTime.parse(data) current.send(r, d) when /^(Commandline|Requested-By)$/ r = tag.downcase.gsub("-","_").concat("=").to_sym current.send(r, data) when /^(Install|Upgrade|Reinstall|Remove|Purge)$/ current.package = data.split(/(?<=\)), /) current.action = tag.downcase.to_sym end end return result end |