obst 0.1.2 → 0.1.3

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: 98098746bf391bc2ef384eb8fd5f5a16ed462ecb2392aedafa4ad817a173afb6
4
+ data.tar.gz: a96c73fed2dcf4f6a14c695f8da6e08fb8f62e6e93d579d867971453b40b6dd5
5
5
  SHA512:
6
- metadata.gz: eea44c54b0be8db9911ce89a05a89df918a563ad1adfd266b24f28285b067a22f3923d5cb3003c1994e90a4d74047aa5a7440973a9f1864a7d5761bdb78098d6
7
- data.tar.gz: ec792740ca69bf79d39ef1b12a2c66903c55f8e51dbbcd78c83c207bb600f036244c2ad7c21941b0af9ebae7f9fb3a28ae76dda4338eec07fe751c0c97fa8949
6
+ metadata.gz: 2a168e81dc31da12781806ebd4ab199ef5554d9293b39d3d7578085fc9bd3b5f1dcb7a0a8cacca5f2af655ba8111e1b4299690c14c7a7573e0ef0413a6468061
7
+ data.tar.gz: 5bd90a681ea26bf5b8f599465ab6a47b3a8b51baf913df9211b26792418122294228f7aff8848ed1f25d109e4242409f3aa779e9f08b199c6ab0eebc07f246fe
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,58 @@
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
+ record.statuses.each_pair do |name, status|
53
+ entry = status.final == :a ? "\t- [[#{name}]] *new !*" : "\t- [[#{name}]]"
54
+ @buffer << entry
55
+ end
56
+ end
57
+ end
58
+ end
data/lib/obst/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Obst
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
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.3
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-25 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