obst 0.1.8 → 0.1.10

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: 33dbda872356a5eaec6905a2054093af4a49555183ad517160a8bcb27f0b7ddd
4
- data.tar.gz: 77d38fa97ae8e8319b05f85c3106e3fda15a7c14bb3b737a9ecae874c0a81599
3
+ metadata.gz: 7e034c9801c0f95847ebff1b7538619cc3a4d2fd54fcb8b237719ef1ef14b021
4
+ data.tar.gz: '059acbb56ec335954730fd95dfab999065fd35c20065568ed61338d69b7a007a'
5
5
  SHA512:
6
- metadata.gz: e22696c10025df791b9d11e4b6dac10e3deb965d093bb1b511d8d12cfa22019dee5f8794f0f129da60be3782ed7585afc585880f1dbd5ec49ae5f175cb03cf4d
7
- data.tar.gz: 85721a438531b6028efc7f1680e47a9be127fe199196371cf8459cfd95091bbe1e6d957f39048574575b98a6b826d9cdd09a26e4c4f5cfb0c1b2341fe0d4ab6e
6
+ metadata.gz: f0a819a3308f2cc93e03a358fc52d366ecff5d8ff2eba8042ccb1416919732db129d1206cdcf091c7828ceacbf0e6a09ff5fa5d7f1e253b6461a9e699532ab9f
7
+ data.tar.gz: 58edfed39383f457dfd4c5739a928f05f39a8c0eb7918ff9597fd4f463de87ca242a6e331bb088159727b08d66c747bfa931274d6d897295509142c25b6fbb70
data/.gitignore CHANGED
@@ -8,3 +8,4 @@
8
8
  /tmp/
9
9
  /Gemfile.lock
10
10
  /*.gem
11
+ .ruby-version
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,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
@@ -1,3 +1,3 @@
1
1
  module Obst
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.10"
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.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: 2022-11-29 00:00:00.000000000 Z
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.6
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: []