Class: Obst::LongTimeNoSee
- Inherits:
-
Object
- Object
- Obst::LongTimeNoSee
- Defined in:
- lib/obst/long_time_no_see.rb
Instance Method Summary collapse
-
#initialize(**opts) ⇒ LongTimeNoSee
constructor
A new instance of LongTimeNoSee.
- #list_files(record) ⇒ Object
- #to_s ⇒ Object
- #week_count(i) ⇒ Object
Constructor Details
#initialize(**opts) ⇒ LongTimeNoSee
5 6 7 8 9 10 11 |
# File 'lib/obst/long_time_no_see.rb', line 5 def initialize(**opts) opts = opts.merge(days: 7) if cfg = opts[:cfg] opts[:pathspec] ||= cfg.dig('long_time_no_see', 'pathspec') end @weekly = LastSeen.new(**opts) end |
Instance Method Details
#list_files(record) ⇒ Object
22 23 24 25 26 |
# File 'lib/obst/long_time_no_see.rb', line 22 def list_files(record) record.group_inlines do |line| @buffer << "\t- #{line}" end end |
#to_s ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/obst/long_time_no_see.rb', line 13 def to_s @buffer = ["# Long time no see\n"] @weekly.each_with_index do |record, i| @buffer << "- #{record.time} #{week_count(i)} (#{record.file_changes.count})" list_files(record) end @buffer.join("\n") end |
#week_count(i) ⇒ Object
28 29 30 31 32 |
# File 'lib/obst/long_time_no_see.rb', line 28 def week_count(i) return 'today' if i == 0 return '1.week.ago' if i == 1 "#{i}.weeks.ago" end |