Sha256: cfa9b65a115a7a291ab2c6ab3bde33eabf1f6970009cf2c2a8f0ae121f5393d4
Contents?: true
Size: 737 Bytes
Versions: 6
Compression:
Stored size: 737 Bytes
Contents
require "open3" require "obst/daily_increment" module Obst class DailyGauge include Enumerable def initialize(**opts) @path = opts[:C] || '.' end ONE_DAY = 60 * 60 * 24 TimeCount = Struct.new(:time, :count) def each(&block) return self unless block time = Time.parse(Time.now.strftime('%F')) tot = total_now block.call(TimeCount.new(time, tot)) DailyIncrement.new(C: @path).each do |incr| time -= ONE_DAY tot -= incr block.call(TimeCount.new(time, tot)) end end def total_now total = 0 Open3.pipeline_r(['git', '-C', @path, 'ls-files'], ['wc', '-l']){ |stdout| total = stdout.read.to_i } total end end end
Version data entries
6 entries across 6 versions & 1 rubygems