obst 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/obst +2 -0
- data/lib/obst/notes.rb +42 -0
- data/lib/obst/tags_count.rb +17 -0
- data/lib/obst/version.rb +1 -1
- data/lib/obst.rb +1 -0
- metadata +9 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ceae774176f6f2f1ce1b638f7d3dcfd316405421f4942a5d0bb87f9c45a3e74
|
4
|
+
data.tar.gz: 1a4499843d98a6d4b41cb918c9afc7cabf00ab4a1a82bf10ef40af2a22c688f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee87ab6d88d959604b220cb9a59203f53ade814af0ad0a6449f182785639891ce6dbcc85e6612394f8427a1a1127bea8137d94a0adf510a48049871bf33d95fc
|
7
|
+
data.tar.gz: ed0485c9bb2e1b7d07b7efac59ac88819e8290df741878d1e0d5772405690e3722baafb49ffb63d3bf4ad07f335f3567c4c7c95c7f7617d9615b03ad3cf4fa0e
|
data/exe/obst
CHANGED
data/lib/obst/notes.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require "obst/group_by_days"
|
2
|
+
|
3
|
+
module Obst
|
4
|
+
class Notes
|
5
|
+
include Enumerable
|
6
|
+
|
7
|
+
def initialize(**opts)
|
8
|
+
location = opts[:C] || '.'
|
9
|
+
|
10
|
+
@notes = Enumerator.new do |enum|
|
11
|
+
note_klass = Struct.new(:name, :dates, :tags, :refs)
|
12
|
+
files = Dir.glob(File.join(location, '*.md')).map{|n| File.basename(n)}.to_set
|
13
|
+
file_dates = Hash.new{ |h, k| h[k] = [] }
|
14
|
+
|
15
|
+
GroupByDays.new(**opts).each do |log|
|
16
|
+
log.file_changes.each do |name, op|
|
17
|
+
file_dates[name] << log.time if files.include?(name)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
file_dates.each_pair do |file, dates|
|
22
|
+
lines = File.foreach(File.join(location, file))
|
23
|
+
tags = lines.first&.scan(/#(\w+)/)&.flatten || []
|
24
|
+
refs = lines.each_with_object([]) do |line, arr|
|
25
|
+
line.scan(/\[\[(.+?)\]\]/).flatten.each do |n|
|
26
|
+
arr << n if files.include?("#{n}.md")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
enum.yield(note_klass.new(file, dates, tags, refs))
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def each(&block)
|
35
|
+
@notes.each(&block)
|
36
|
+
end
|
37
|
+
|
38
|
+
def tags
|
39
|
+
@gitlog.map(&:tags).flatten.tally.sort{ |t1, t2| [t2[1], t2[0]] <=> [t1[1], t1[0]] }.to_h
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'obst/notes'
|
2
|
+
|
3
|
+
module Obst
|
4
|
+
class TagsCount
|
5
|
+
def initialize(**opts)
|
6
|
+
@notes = Notes.new(**opts)
|
7
|
+
end
|
8
|
+
|
9
|
+
def to_s
|
10
|
+
buffer = ["# Tags\n"]
|
11
|
+
@notes.map(&:tags).flatten.tally.sort{ |t1, t2| [t2[1], t2[0]] <=> [t1[1], t1[0]] }.each do |(tag, count)|
|
12
|
+
buffer << "- #{tag}: #{count}"
|
13
|
+
end
|
14
|
+
buffer.join("\n")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/obst/version.rb
CHANGED
data/lib/obst.rb
CHANGED
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
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.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ken
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
13
|
+
description:
|
14
14
|
email:
|
15
15
|
- block24block@gmail.com
|
16
16
|
executables:
|
@@ -37,7 +37,9 @@ files:
|
|
37
37
|
- lib/obst/group_by_days.rb
|
38
38
|
- lib/obst/last_seen.rb
|
39
39
|
- lib/obst/long_time_no_see.rb
|
40
|
+
- lib/obst/notes.rb
|
40
41
|
- lib/obst/pack_log.rb
|
42
|
+
- lib/obst/tags_count.rb
|
41
43
|
- lib/obst/touched_files.rb
|
42
44
|
- lib/obst/version.rb
|
43
45
|
- obst.gemspec
|
@@ -45,7 +47,7 @@ homepage: https://github.com/turnon/obst
|
|
45
47
|
licenses:
|
46
48
|
- MIT
|
47
49
|
metadata: {}
|
48
|
-
post_install_message:
|
50
|
+
post_install_message:
|
49
51
|
rdoc_options: []
|
50
52
|
require_paths:
|
51
53
|
- lib
|
@@ -60,8 +62,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
60
62
|
- !ruby/object:Gem::Version
|
61
63
|
version: '0'
|
62
64
|
requirements: []
|
63
|
-
rubygems_version: 3.
|
64
|
-
signing_key:
|
65
|
+
rubygems_version: 3.4.10
|
66
|
+
signing_key:
|
65
67
|
specification_version: 4
|
66
68
|
summary: Obsidian stats
|
67
69
|
test_files: []
|