hiiro 0.1.209 → 0.1.211
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/lib/hiiro/paths.rb +12 -0
- data/lib/hiiro/queue.rb +10 -15
- data/lib/hiiro/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 93161b29e527a19a17c9e478558ab0d33a925e27ac04851151d4d86fd1f59f49
|
|
4
|
+
data.tar.gz: 775639bdc0be84af6ea30e8edf33251c5ed769614e51c59c12ab1c681be33ebc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 30c25c505dc5bfcc956a3be84245f3c3a680f6fe326963083a101f41781cb8a4437fa94d5655cb99fe40a9b0a051b9db73c3eeac3bf1fbbe4f42c2011f4dace2
|
|
7
|
+
data.tar.gz: e09c57d45a81c8c2334ab779d96da3ce024ad01904213895d874889697cc26ec6773d8f1589d43cc192a15a99d9da97d206215e725494af92ce6cbf4398bfb2b
|
data/lib/hiiro/paths.rb
CHANGED
|
@@ -25,6 +25,18 @@ class Hiiro
|
|
|
25
25
|
.map { |link| Symlink.new(link, hiiro) }
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
+
# Returns [full_path, unique_name] — appends -2, -3, etc. if a file
|
|
29
|
+
# with the same base_name already exists in dir.
|
|
30
|
+
def self.unique_path(dir, base_name, ext: '.md')
|
|
31
|
+
name = base_name
|
|
32
|
+
counter = 1
|
|
33
|
+
while File.exist?(File.join(dir, "#{name}#{ext}"))
|
|
34
|
+
counter += 1
|
|
35
|
+
name = "#{base_name}-#{counter}"
|
|
36
|
+
end
|
|
37
|
+
[File.join(dir, "#{name}#{ext}"), name]
|
|
38
|
+
end
|
|
39
|
+
|
|
28
40
|
class Symlink < SimpleDelegator
|
|
29
41
|
attr_reader :hiiro
|
|
30
42
|
|
data/lib/hiiro/queue.rb
CHANGED
|
@@ -289,18 +289,6 @@ class Hiiro
|
|
|
289
289
|
text.downcase.gsub(/[^a-z0-9]+/, '-').gsub(/^-|-$/, '')[0, 60]
|
|
290
290
|
end
|
|
291
291
|
|
|
292
|
-
# Returns [dest_path, unique_name] — appends -2, -3, etc. if a file
|
|
293
|
-
# with the same base_name already exists in dest_dir.
|
|
294
|
-
def unique_dest_path(dest_dir, base_name)
|
|
295
|
-
name = base_name
|
|
296
|
-
counter = 1
|
|
297
|
-
while File.exist?(File.join(dest_dir, "#{name}.md"))
|
|
298
|
-
counter += 1
|
|
299
|
-
name = "#{base_name}-#{counter}"
|
|
300
|
-
end
|
|
301
|
-
[File.join(dest_dir, "#{name}.md"), name]
|
|
302
|
-
end
|
|
303
|
-
|
|
304
292
|
def add_with_frontmatter(content, task_info: nil)
|
|
305
293
|
queue_dirs # ensure dirs exist
|
|
306
294
|
|
|
@@ -323,7 +311,7 @@ class Hiiro
|
|
|
323
311
|
name += '-' + task_info[:task_name] if task_info&.key?(:task_name)
|
|
324
312
|
end
|
|
325
313
|
|
|
326
|
-
path, name =
|
|
314
|
+
path, name = Hiiro::Paths.unique_path(queue_dirs[:pending], name)
|
|
327
315
|
File.write(path, content + "\n")
|
|
328
316
|
{ name: name, path: path }
|
|
329
317
|
end
|
|
@@ -335,11 +323,18 @@ class Hiiro
|
|
|
335
323
|
h.add_subcmd(:watch) {
|
|
336
324
|
q.queue_dirs
|
|
337
325
|
current_version = Gem.loaded_specs['hiiro']&.version&.to_s
|
|
326
|
+
puts current_version:;
|
|
338
327
|
puts "Watching #{File.join(DIR, 'pending')} ..."
|
|
339
328
|
puts "Press Ctrl-C to stop"
|
|
329
|
+
loops = 0
|
|
340
330
|
loop do
|
|
331
|
+
loops += 1
|
|
341
332
|
if current_version
|
|
342
333
|
latest = Gem::Specification.find_by_name('hiiro')&.version&.to_s rescue nil
|
|
334
|
+
if loops % 50 == 0
|
|
335
|
+
puts current_version:, latest:;
|
|
336
|
+
end
|
|
337
|
+
|
|
343
338
|
if latest && latest != current_version
|
|
344
339
|
puts "New hiiro version detected (#{latest}), restarting..."
|
|
345
340
|
exec('h', 'queue', 'watch')
|
|
@@ -584,7 +579,7 @@ class Hiiro
|
|
|
584
579
|
next
|
|
585
580
|
end
|
|
586
581
|
|
|
587
|
-
dst, dest_name =
|
|
582
|
+
dst, dest_name = Hiiro::Paths.unique_path(q.queue_dirs[:pending], name)
|
|
588
583
|
if dest_name != name
|
|
589
584
|
FileUtils.mv(src, File.join(q.queue_dirs[:wip], "#{dest_name}.md"))
|
|
590
585
|
src = File.join(q.queue_dirs[:wip], "#{dest_name}.md")
|
|
@@ -640,7 +635,7 @@ class Hiiro
|
|
|
640
635
|
|
|
641
636
|
dirs = q.queue_dirs
|
|
642
637
|
src_dir = dirs[found[:status].to_sym]
|
|
643
|
-
dst, dest_name =
|
|
638
|
+
dst, dest_name = Hiiro::Paths.unique_path(dirs[:pending], name)
|
|
644
639
|
FileUtils.mv(File.join(src_dir, "#{name}.md"), dst)
|
|
645
640
|
meta_path = File.join(src_dir, "#{name}.meta")
|
|
646
641
|
FileUtils.rm_f(meta_path) if File.exist?(meta_path)
|
data/lib/hiiro/version.rb
CHANGED