obst 0.1.2 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 43dc48712314838bb19c932cd61c53196acfba4d1850192048f0946ba8a2bf90
4
- data.tar.gz: 7498633a8f52ad0c9651b9e1a7a17361ee3aca822594ea42d96ac9dede0b713a
3
+ metadata.gz: c1ea9ec553aec1048f197a4313bb6f5bdb82767e78fe793764127e1b798ee5b7
4
+ data.tar.gz: 8cfa17989074c75b146f5979cd30e33ea05a062cc3e1347efb1677dd6c4c2a44
5
5
  SHA512:
6
- metadata.gz: eea44c54b0be8db9911ce89a05a89df918a563ad1adfd266b24f28285b067a22f3923d5cb3003c1994e90a4d74047aa5a7440973a9f1864a7d5761bdb78098d6
7
- data.tar.gz: ec792740ca69bf79d39ef1b12a2c66903c55f8e51dbbcd78c83c207bb600f036244c2ad7c21941b0af9ebae7f9fb3a28ae76dda4338eec07fe751c0c97fa8949
6
+ metadata.gz: 13b20ea98bc4cedacfee5a11b267f3f2a263fbcadd9d7a3de83061c17af55257701801dca6cabb687236b2c193bd2accfd99d53a9a8ed121471486e6484473c8
7
+ data.tar.gz: a2cda68907af8dd8c15f1f31d00afb977e297e3461bf5bbafc7adbccfc9c06801407dd7a68c0898b19a6585e0c8d6ffa86e598e7be2961e09d5a40cb8d1f8df6
data/exe/obst CHANGED
@@ -9,15 +9,7 @@ File.open(gitignore, 'a+') do |f|
9
9
  f.puts("# Obst\nobst.md") unless f.read =~ /# Obst/
10
10
  end
11
11
 
12
- buffer = []
13
- Obst::GroupByDays.new(C: path, days: 1).take(7).each do |record|
14
- buffer << "- #{record.time} (#{record.statuses.size})"
15
- record.statuses.each_key do |name|
16
- buffer << "\t- [[#{name}]]"
17
- end
18
- end
19
-
20
12
  obst_md = File.join(path, 'obst.md')
21
13
  File.open(obst_md, 'w') do |f|
22
- f.puts(buffer.join("\n"))
14
+ f.puts Obst::TouchedFiles.new(C: path).to_s
23
15
  end
@@ -8,7 +8,7 @@ module Obst
8
8
  ONE_DAY = 60 * 60 * 24
9
9
 
10
10
  def initialize(**opts)
11
- duration = ONE_DAY* (opts[:days] || 1)
11
+ duration = ONE_DAY * (opts[:days] || 1)
12
12
  latest = opts[:before] ? Time.parse(opts[:before]) : Time.parse(Time.now.strftime('%F 23:59:59'))
13
13
 
14
14
  @timeline = Enumerator.new do |y|
data/lib/obst/pack_log.rb CHANGED
@@ -18,9 +18,31 @@ module Obst
18
18
  def inspect
19
19
  @arr
20
20
  end
21
+
22
+ def final
23
+ return :d if @arr[0] == :d
24
+ return :a if @arr[-1] == :a
25
+ :m
26
+ end
21
27
  end
22
28
 
23
- Record = Struct.new(:time, :statuses)
29
+ Record = Struct.new(:time, :statuses) do
30
+ def status_sum
31
+ sum = Hash.new{ |h, k| h[k] = 0 }
32
+ statuses.each_value do |status|
33
+ sum[status.final] += 1
34
+ end
35
+ sum
36
+ end
37
+
38
+ def str_status_sum
39
+ sb = []
40
+ status_sum.each_pair do |st, count|
41
+ sb << "#{st}: #{count}"
42
+ end
43
+ sb.join(', ')
44
+ end
45
+ end
24
46
 
25
47
  def each(&block)
26
48
  current_time = nil
@@ -0,0 +1,71 @@
1
+ require "obst/group_by_days"
2
+
3
+ module Obst
4
+ class TouchedFiles
5
+ def initialize(**opts)
6
+ @path = opts[:C]
7
+ @buffer = []
8
+ end
9
+
10
+ def to_s
11
+ last_7_days
12
+ @buffer << ''
13
+ last_4_weeks_without_last_7_days
14
+ @buffer << ''
15
+ last_3_months_without_last_4_weeks
16
+ @buffer.join("\n")
17
+ end
18
+
19
+ def last_7_days
20
+ @buffer << "# Last 7 days\n"
21
+
22
+ GroupByDays.new(C: @path).take(7).each do |record|
23
+ wday = Time.parse(record.time).strftime('%a')
24
+ @buffer << "- #{record.time} #{wday} (#{record.statuses.size})"
25
+ list_files(record)
26
+ end
27
+ end
28
+
29
+ def last_4_weeks_without_last_7_days
30
+ before = (Time.now - (60 * 60 * 24 * 7)).strftime('%FT23:59:59')
31
+
32
+ @buffer << "# 3 weeks earlier\n"
33
+
34
+ GroupByDays.new(C: @path, before: before, days: 7).take(3).each do |record|
35
+ @buffer << "- #{record.time} (#{record.statuses.size})"
36
+ list_files(record)
37
+ end
38
+ end
39
+
40
+ def last_3_months_without_last_4_weeks
41
+ before = (Time.now - (60 * 60 * 24 * 28)).strftime('%FT23:59:59')
42
+
43
+ @buffer << "# 1 month earlier\n"
44
+
45
+ GroupByDays.new(C: @path, before: before, days: 28).take(2).each do |record|
46
+ @buffer << "- #{record.time} (#{record.statuses.size})"
47
+ list_files(record)
48
+ end
49
+ end
50
+
51
+ def list_files(record)
52
+ group_by_final_status = Hash.new{ |h, k| h[k] = [] }
53
+ record.statuses.each_pair{ |name, status| group_by_final_status[status.final] << name }
54
+
55
+ [
56
+ [:new, :a, '#2db7b5'],
57
+ [:mod, :m, '#d3be03'],
58
+ [:del, :d, '#c71585']
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}"
64
+ end
65
+ end
66
+
67
+ def inline(files)
68
+ files.sort!.map{ |name| "[[#{name}]]" }.join(' / ')
69
+ end
70
+ end
71
+ end
data/lib/obst/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Obst
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.4"
3
3
  end
data/lib/obst.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require "obst/version"
2
2
  require "obst/git_log"
3
3
  require "obst/group_by_days"
4
+ require "obst/touched_files"
4
5
 
5
6
  module Obst
6
7
  end
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.2
4
+ version: 0.1.4
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-24 00:00:00.000000000 Z
11
+ date: 2022-11-26 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -32,6 +32,7 @@ files:
32
32
  - lib/obst/git_log.rb
33
33
  - lib/obst/group_by_days.rb
34
34
  - lib/obst/pack_log.rb
35
+ - lib/obst/touched_files.rb
35
36
  - lib/obst/version.rb
36
37
  - obst.gemspec
37
38
  homepage: https://github.com/turnon/obst