obst 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/exe/obst +2 -0
- data/lib/obst/last_seen.rb +28 -0
- data/lib/obst/long_time_no_see.rb +31 -0
- data/lib/obst/pack_log.rb +22 -0
- data/lib/obst/touched_files.rb +13 -26
- data/lib/obst/version.rb +1 -1
- data/lib/obst.rb +1 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc318da9a56d9fd4593627a727f36a2ff01ab2e9ba5d1f4969bc4d299acce702
|
4
|
+
data.tar.gz: 6f649344c285a743333d35d7bd4cf11844a38f810fee94040c3de7a46e75f8f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21c1eea8e6a53ba8c9f94d09d3996eee64f522bd503458600d4db87d584ceb1b2496d55fcb031123a8bcd0b3a3b957c9e6b36772921e8f7f71e19f537fe13b98
|
7
|
+
data.tar.gz: b44b1782a1e95a5d791b90538e2023515a3da8d69432b76a93bd376d5ef65699190972675354c1c6a76a6233b6e5bf1e1bf171c0f78655a0dfd9917df39c0621
|
data/exe/obst
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
require "set"
|
2
|
+
require "obst/group_by_days"
|
3
|
+
|
4
|
+
module Obst
|
5
|
+
class LastSeen
|
6
|
+
include Enumerable
|
7
|
+
|
8
|
+
def initialize(**opts)
|
9
|
+
@groups = Obst::GroupByDays.new(**opts)
|
10
|
+
end
|
11
|
+
|
12
|
+
def each(&block)
|
13
|
+
return self unless block
|
14
|
+
|
15
|
+
seen = Set.new
|
16
|
+
@groups.each do |record|
|
17
|
+
record.file_changes.keys.each do |file|
|
18
|
+
if seen.include?(file)
|
19
|
+
record.file_changes.delete(file)
|
20
|
+
else
|
21
|
+
seen << file
|
22
|
+
end
|
23
|
+
end
|
24
|
+
block.call(record)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require "obst/last_seen"
|
2
|
+
|
3
|
+
module Obst
|
4
|
+
class LongTimeNoSee
|
5
|
+
def initialize(**opts)
|
6
|
+
opts = opts.merge(days: 7)
|
7
|
+
@weekly = LastSeen.new(**opts)
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_s
|
11
|
+
@buffer = ["# Long time no see\n"]
|
12
|
+
@weekly.each_with_index do |record, i|
|
13
|
+
@buffer << "- #{record.time} #{week_count(i)} (#{record.file_changes.count})"
|
14
|
+
list_files(record)
|
15
|
+
end
|
16
|
+
@buffer.join("\n")
|
17
|
+
end
|
18
|
+
|
19
|
+
def list_files(record)
|
20
|
+
record.group_inlines do |line|
|
21
|
+
@buffer << "\t- #{line}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def week_count(i)
|
26
|
+
return 'today' if i == 0
|
27
|
+
return '1.week.ago' if i == 1
|
28
|
+
"#{i}.weeks.ago"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/obst/pack_log.rb
CHANGED
@@ -46,6 +46,28 @@ module Obst
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
49
|
+
|
50
|
+
def group_by_final_status
|
51
|
+
groups = Hash.new{ |h, k| h[k] = [] }
|
52
|
+
file_changes.each_pair{ |file, changes| groups[changes.final] << file }
|
53
|
+
groups
|
54
|
+
end
|
55
|
+
|
56
|
+
def group_inlines(&block)
|
57
|
+
gbfs = group_by_final_status
|
58
|
+
|
59
|
+
[
|
60
|
+
[:new, :a, '#2db7b5'],
|
61
|
+
[:mod, :m, '#d3be03'],
|
62
|
+
[:del, :d, '#c71585'],
|
63
|
+
[:nil, nil, 'grey']
|
64
|
+
].each do |long, short, color|
|
65
|
+
files = gbfs[short]
|
66
|
+
next if files.empty?
|
67
|
+
inline_str = files.sort!.map{ |name| "[[#{name}]]" }.join(' / ')
|
68
|
+
block.call("<font color='#{color}'>#{long} #{files.count}:</font> #{inline_str}")
|
69
|
+
end
|
70
|
+
end
|
49
71
|
end
|
50
72
|
|
51
73
|
# yield PackLog::Record(
|
data/lib/obst/touched_files.rb
CHANGED
@@ -4,23 +4,21 @@ module Obst
|
|
4
4
|
class TouchedFiles
|
5
5
|
def initialize(**opts)
|
6
6
|
@path = opts[:C]
|
7
|
-
@buffer = []
|
7
|
+
@buffer = ["# Touch files in periods\n"]
|
8
8
|
end
|
9
9
|
|
10
10
|
def to_s
|
11
11
|
last_7_days
|
12
|
-
@buffer << ''
|
13
12
|
last_4_weeks_without_last_7_days
|
14
|
-
@buffer << ''
|
15
13
|
last_3_months_without_last_4_weeks
|
16
14
|
@buffer.join("\n")
|
17
15
|
end
|
18
16
|
|
19
17
|
def last_7_days
|
20
|
-
@buffer << "
|
18
|
+
@buffer << "- Last 7 days"
|
21
19
|
|
22
20
|
GroupByDays.new(C: @path).take(7).each do |record|
|
23
|
-
@buffer << "- #{record.date_wday} (#{record.file_changes.count})"
|
21
|
+
@buffer << "\t- #{record.date_wday} (#{record.file_changes.count})"
|
24
22
|
list_files(record)
|
25
23
|
end
|
26
24
|
end
|
@@ -28,10 +26,10 @@ module Obst
|
|
28
26
|
def last_4_weeks_without_last_7_days
|
29
27
|
before = (Time.now - (60 * 60 * 24 * 7)).strftime('%FT23:59:59')
|
30
28
|
|
31
|
-
@buffer << "
|
29
|
+
@buffer << "- 1 week ago"
|
32
30
|
|
33
|
-
GroupByDays.new(C: @path, before: before, days: 7).take(3).
|
34
|
-
@buffer << "- #{record.time} (#{record.file_changes.count})"
|
31
|
+
GroupByDays.new(C: @path, before: before, days: 7).take(3).each_with_index do |record, i|
|
32
|
+
@buffer << "\t- #{record.time} is #{1+i}.week#{suffix_s(i)}.ago (#{record.file_changes.count})"
|
35
33
|
list_files(record)
|
36
34
|
end
|
37
35
|
end
|
@@ -39,33 +37,22 @@ module Obst
|
|
39
37
|
def last_3_months_without_last_4_weeks
|
40
38
|
before = (Time.now - (60 * 60 * 24 * 28)).strftime('%FT23:59:59')
|
41
39
|
|
42
|
-
@buffer << "
|
40
|
+
@buffer << "- 1 month ago"
|
43
41
|
|
44
|
-
GroupByDays.new(C: @path, before: before, days: 28).take(2).
|
45
|
-
@buffer << "- #{record.time} (#{record.file_changes.count})"
|
42
|
+
GroupByDays.new(C: @path, before: before, days: 28).take(2).each_with_index do |record, i|
|
43
|
+
@buffer << "\t- #{record.time} is #{1+i}.month#{suffix_s(i)}.ago (#{record.file_changes.count})"
|
46
44
|
list_files(record)
|
47
45
|
end
|
48
46
|
end
|
49
47
|
|
50
48
|
def list_files(record)
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
[
|
55
|
-
[:new, :a, '#2db7b5'],
|
56
|
-
[:mod, :m, '#d3be03'],
|
57
|
-
[:del, :d, '#c71585'],
|
58
|
-
[:nil, nil, 'grey']
|
59
|
-
].each do |long, short, color|
|
60
|
-
files = group_by_final_status[short]
|
61
|
-
next if files.empty?
|
62
|
-
inline_str = inline(files)
|
63
|
-
@buffer << "\t- <font color='#{color}'>#{long} #{files.count}:</font> #{inline_str}"
|
49
|
+
record.group_inlines do |line|
|
50
|
+
@buffer << "\t\t- #{line}"
|
64
51
|
end
|
65
52
|
end
|
66
53
|
|
67
|
-
def
|
68
|
-
|
54
|
+
def suffix_s(i)
|
55
|
+
i == 0 ? '' : 's'
|
69
56
|
end
|
70
57
|
end
|
71
58
|
end
|
data/lib/obst/version.rb
CHANGED
data/lib/obst.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: obst
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ken
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-11-
|
11
|
+
date: 2022-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -34,6 +34,8 @@ files:
|
|
34
34
|
- lib/obst/daily_increment.rb
|
35
35
|
- lib/obst/git_log.rb
|
36
36
|
- lib/obst/group_by_days.rb
|
37
|
+
- lib/obst/last_seen.rb
|
38
|
+
- lib/obst/long_time_no_see.rb
|
37
39
|
- lib/obst/pack_log.rb
|
38
40
|
- lib/obst/touched_files.rb
|
39
41
|
- lib/obst/version.rb
|