Class: Obst::PackLog::Record
- Inherits:
-
Struct
- Object
- Struct
- Obst::PackLog::Record
- Defined in:
- lib/obst/pack_log.rb
Instance Attribute Summary collapse
-
#file_changes ⇒ Object
Returns the value of attribute file_changes.
-
#time ⇒ Object
Returns the value of attribute time.
Instance Method Summary collapse
- #date_wday ⇒ Object
- #group_by_final_status ⇒ Object
- #group_inlines(&block) ⇒ Object
- #increment ⇒ Object
Instance Attribute Details
#file_changes ⇒ Object
Returns the value of attribute file_changes
31 32 33 |
# File 'lib/obst/pack_log.rb', line 31 def file_changes @file_changes end |
#time ⇒ Object
Returns the value of attribute time
31 32 33 |
# File 'lib/obst/pack_log.rb', line 31 def time @time end |
Instance Method Details
#date_wday ⇒ Object
32 33 34 |
# File 'lib/obst/pack_log.rb', line 32 def date_wday Time.parse(time).strftime('%F %a') end |
#group_by_final_status ⇒ Object
50 51 52 53 54 |
# File 'lib/obst/pack_log.rb', line 50 def group_by_final_status groups = Hash.new{ |h, k| h[k] = [] } file_changes.each_pair{ |file, changes| groups[changes.final] << file } groups end |
#group_inlines(&block) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/obst/pack_log.rb', line 56 def group_inlines(&block) gbfs = group_by_final_status [ [:new, :a, '#2db7b5'], [:mod, :m, '#d3be03'], [:del, :d, '#c71585'], [:nil, nil, 'grey'] ].each do |long, short, color| files = gbfs[short].compact next if files.empty? inline_str = files.sort!.map{ |name| "[[#{name}]]" }.join(' / ') block.call("<font color='#{color}'>#{long} #{files.count}:</font> #{inline_str}") end end |
#increment ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/obst/pack_log.rb', line 36 def increment file_changes.each_value.reduce(0) do |sum, changes| sum += case changes.final when :a 1 when :d -1 else 0 end end end |