Sha256: a79e274f97b8669f2501f14825340fd95d4808facd9ac02188e2b581a5836905
Contents?: true
Size: 1.48 KB
Versions: 1
Compression:
Stored size: 1.48 KB
Contents
require "obst/group_by_days" module Obst class TouchedFiles def initialize(**opts) @path = opts[:C] @buffer = ["# Touch files in periods\n"] end def to_s last_7_days last_4_weeks_without_last_7_days last_3_months_without_last_4_weeks @buffer.join("\n") end def last_7_days @buffer << "- Last 7 days" GroupByDays.new(C: @path).take(7).each do |record| @buffer << "\t- #{record.date_wday} (#{record.file_changes.count})" list_files(record) end end def last_4_weeks_without_last_7_days before = (Time.now - (60 * 60 * 24 * 7)).strftime('%FT23:59:59') @buffer << "- 1 week ago" GroupByDays.new(C: @path, before: before, days: 7).take(3).each_with_index do |record, i| @buffer << "\t- #{record.time} is #{1+i}.week#{suffix_s(i)}.ago (#{record.file_changes.count})" list_files(record) end end def last_3_months_without_last_4_weeks before = (Time.now - (60 * 60 * 24 * 28)).strftime('%FT23:59:59') @buffer << "- 1 month ago" GroupByDays.new(C: @path, before: before, days: 28).take(2).each_with_index do |record, i| @buffer << "\t- #{record.time} is #{1+i}.month#{suffix_s(i)}.ago (#{record.file_changes.count})" list_files(record) end end def list_files(record) record.group_inlines do |line| @buffer << "\t\t- #{line}" end end def suffix_s(i) i == 0 ? '' : 's' end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
obst-0.1.7 | lib/obst/touched_files.rb |