obst 0.1.8 → 0.1.10
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/.gitignore +1 -0
- data/exe/obst +2 -0
- data/lib/obst/notes.rb +38 -0
- data/lib/obst/tags_count.rb +25 -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: 7e034c9801c0f95847ebff1b7538619cc3a4d2fd54fcb8b237719ef1ef14b021
|
4
|
+
data.tar.gz: '059acbb56ec335954730fd95dfab999065fd35c20065568ed61338d69b7a007a'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0a819a3308f2cc93e03a358fc52d366ecff5d8ff2eba8042ccb1416919732db129d1206cdcf091c7828ceacbf0e6a09ff5fa5d7f1e253b6461a9e699532ab9f
|
7
|
+
data.tar.gz: 58edfed39383f457dfd4c5739a928f05f39a8c0eb7918ff9597fd4f463de87ca242a6e331bb088159727b08d66c747bfa931274d6d897295509142c25b6fbb70
|
data/.gitignore
CHANGED
data/exe/obst
CHANGED
data/lib/obst/notes.rb
ADDED
@@ -0,0 +1,38 @@
|
|
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
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,25 @@
|
|
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
|
+
|
12
|
+
@notes.map(&:tags).flatten.tally.sort do |t1, t2|
|
13
|
+
if (compare_count = (t2[1] <=> t1[1])) == 0
|
14
|
+
t1[0] <=> t2[0]
|
15
|
+
else
|
16
|
+
compare_count
|
17
|
+
end
|
18
|
+
end.each_with_index do |(tag, count), idx|
|
19
|
+
buffer << "#{idx + 1}. #{tag}: #{count}"
|
20
|
+
end
|
21
|
+
|
22
|
+
buffer.join("\n")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
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.10
|
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-21 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.1
|
64
|
-
signing_key:
|
65
|
+
rubygems_version: 3.4.1
|
66
|
+
signing_key:
|
65
67
|
specification_version: 4
|
66
68
|
summary: Obsidian stats
|
67
69
|
test_files: []
|