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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 682986f0fe061c64a51e17710cc46a49e7227980af6765715a0db8e896cee7d2
4
- data.tar.gz: 2bc5edffca82cb8f46e1cec99c5d0d3fefd49f5a6ec9ab7f46a8c810224acdbf
3
+ metadata.gz: 93161b29e527a19a17c9e478558ab0d33a925e27ac04851151d4d86fd1f59f49
4
+ data.tar.gz: 775639bdc0be84af6ea30e8edf33251c5ed769614e51c59c12ab1c681be33ebc
5
5
  SHA512:
6
- metadata.gz: 8444324b5e67717a8533e1135bb54612b6ae85e0ae4e616692a6c87e715c22a6a92de79534468eb87de0c386b75fe202ad2b4f6df67c25662b7fac3229d207c3
7
- data.tar.gz: 584c422ce992a137eea834db02bba83450ee8b90bb32d511057fdc55714c9a56a7edc67d6112318803e3d656cd25405306eb6a2190536fef22f795897036f074
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 = unique_dest_path(queue_dirs[:pending], 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 = q.unique_dest_path(q.queue_dirs[:pending], 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 = q.unique_dest_path(dirs[:pending], 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
@@ -1,3 +1,3 @@
1
1
  class Hiiro
2
- VERSION = "0.1.209"
2
+ VERSION = "0.1.211"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hiiro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.209
4
+ version: 0.1.211
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Toyota