obst 0.1.8 → 0.1.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 33dbda872356a5eaec6905a2054093af4a49555183ad517160a8bcb27f0b7ddd
4
- data.tar.gz: 77d38fa97ae8e8319b05f85c3106e3fda15a7c14bb3b737a9ecae874c0a81599
3
+ metadata.gz: 8ceae774176f6f2f1ce1b638f7d3dcfd316405421f4942a5d0bb87f9c45a3e74
4
+ data.tar.gz: 1a4499843d98a6d4b41cb918c9afc7cabf00ab4a1a82bf10ef40af2a22c688f7
5
5
  SHA512:
6
- metadata.gz: e22696c10025df791b9d11e4b6dac10e3deb965d093bb1b511d8d12cfa22019dee5f8794f0f129da60be3782ed7585afc585880f1dbd5ec49ae5f175cb03cf4d
7
- data.tar.gz: 85721a438531b6028efc7f1680e47a9be127fe199196371cf8459cfd95091bbe1e6d957f39048574575b98a6b826d9cdd09a26e4c4f5cfb0c1b2341fe0d4ab6e
6
+ metadata.gz: ee87ab6d88d959604b220cb9a59203f53ade814af0ad0a6449f182785639891ce6dbcc85e6612394f8427a1a1127bea8137d94a0adf510a48049871bf33d95fc
7
+ data.tar.gz: ed0485c9bb2e1b7d07b7efac59ac88819e8290df741878d1e0d5772405690e3722baafb49ffb63d3bf4ad07f335f3567c4c7c95c7f7617d9615b03ad3cf4fa0e
data/exe/obst CHANGED
@@ -23,4 +23,6 @@ File.open(obst_md, 'w') do |f|
23
23
  f.puts Obst::LongTimeNoSee.new(C: path, cfg: cfg).to_s
24
24
  f.puts "\n"
25
25
  f.puts Obst::TouchedFiles.new(C: path, cfg: cfg).to_s
26
+ f.puts "\n"
27
+ f.puts Obst::TagsCount.new(C: path, cfg: cfg).to_s
26
28
  end
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
@@ -1,3 +1,3 @@
1
1
  module Obst
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  end
data/lib/obst.rb CHANGED
@@ -6,6 +6,7 @@ require "obst/touched_files"
6
6
  require "obst/long_time_no_see"
7
7
  require "obst/daily_gauge"
8
8
  require "obst/chart"
9
+ require "obst/tags_count"
9
10
 
10
11
  module Obst
11
12
  end
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.8
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: 2022-11-29 00:00:00.000000000 Z
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.1.6
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: []