hiiro 0.1.64 → 0.1.66

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: 26230a22dcc41666062bbd486f5c5f0f289f1c0f901890ff8eded9184fff6d1d
4
- data.tar.gz: 49a1d56f36ba069d0738533f1ac26b649534e7dc999822d6d44cc5bb7a9ce626
3
+ metadata.gz: faccc5bdf44ff09a979a082a288539bba108912bde19b854cdc88a7c64484323
4
+ data.tar.gz: 7ecd4b4b79589a042e37188d6fa2355c755e066830a2e7b2250f925d3bc8a13c
5
5
  SHA512:
6
- metadata.gz: 7bf0a65e90a7e97d940eae54c2734f496161294b9d4518cca53e652594244cd5a1f7c4c36e27dfa45dc8ce1fe0e6f1db2fe01431c262a7e7647197d0675fdaca
7
- data.tar.gz: 1551df9b3fb4b018a085b2deffcd774f7677fbc9337fef7e050024162c6b8cfa402d04b1cbc32baed2304e3adb22272e09332c72698c9341fd59ba43073def78
6
+ metadata.gz: 434536b4f52e7a87e4e6f9ec9d02f67c216dc0055cf5027c86b57ae40d33cc1bd018aa83f0a72c97497d9d69124f40d985b072b71447172a7e29dd9fe540864f
7
+ data.tar.gz: 36290dcf8e5a58047bf79abe6701ba4e522254ed9da923f6cdd87ee48fa9e2e75bd08d92c3022a0541331688a33762671c36974757e090639841f5ba419ae963
data/editboth ADDED
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ home_map = {
4
+ 'plugins' => File.join(Dir.home, '.config', 'hiiro', 'plugins'),
5
+ 'bin' => File.join(Dir.home, 'bin'),
6
+ 'exe' => File.join(Dir.home, 'bin'),
7
+ 'lib' => File.dirname(`gem which hiiro`),
8
+ }
9
+
10
+ files = ARGV.flat_map do |fname|
11
+ key, *_ = fname.split(?/)
12
+
13
+ [fname, fname.sub(key, home_map[key])]
14
+ end
15
+
16
+ editor = ENV['EDITOR'] || 'safe_nvim' || 'nvim'
17
+
18
+ system(editor, '-O2', *files)
19
+
data/lib/hiiro/sk.rb CHANGED
@@ -13,5 +13,13 @@ class Hiiro
13
13
 
14
14
  result
15
15
  end
16
+
17
+ def self.map_select(mapping)
18
+ keys = mapping.keys
19
+
20
+ key = select(keys)
21
+
22
+ mapping[key.to_s.chomp]
23
+ end
16
24
  end
17
25
  end
data/lib/hiiro/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Hiiro
2
- VERSION = "0.1.64"
2
+ VERSION = "0.1.66"
3
3
  end
data/lib/hiiro.rb CHANGED
@@ -163,6 +163,10 @@ class Hiiro
163
163
  @git ||= Git.new(self, Dir.pwd)
164
164
  end
165
165
 
166
+ def attach_method(name, &block)
167
+ define_singleton_method(name.to_sym, &block)
168
+ end
169
+
166
170
  def load_plugins(*plugins)
167
171
  plugins.flatten.each { |plugin| load_plugin(plugin) }
168
172
  end
data/plugins/tasks.rb CHANGED
@@ -517,9 +517,10 @@ class TaskManager
517
517
  branch_name = nil
518
518
 
519
519
  if task_name.nil?
520
- selected_task = select_branch_interactive
521
- return unless selected_task
522
- task_name, branch_name = selected_task.split(/\s\s*[|]\s\s*/)
520
+ branch = select_branch_interactive
521
+ return unless branch
522
+ print branch
523
+ return
523
524
  end
524
525
 
525
526
  task = task_by_name(task_name)
@@ -630,14 +631,14 @@ class TaskManager
630
631
  end
631
632
 
632
633
  def select_branch_interactive(prompt = nil)
633
- names = if scope == :subtask
634
- tasks.map { |t| format('%-25s | %s', t.short_name, t.branch) }
634
+ name_map = if scope == :subtask
635
+ tasks.sort_by(&:short_name).each_with_object({}) { |t,h| h[format('%-25s | %s', t.short_name, t.branch)] = t.branch }
635
636
  else
636
- environment.all_tasks.map { |t| format('%-25s | %s', t.name, t.branch) }
637
+ environment.all_tasks.sort_by(&:name).each_with_object({}) { |t,h| h[format('%-25s | %s', t.name, t.branch)] = t.branch }
637
638
  end
638
- return nil if names.empty?
639
+ return nil if name_map.empty?
639
640
 
640
- sk_select(names.sort)
641
+ Hiiro::Sk.map_select(name_map)
641
642
  end
642
643
 
643
644
  # --- Private helpers ---
@@ -809,33 +810,36 @@ module Tasks
809
810
  add_subcommands(hiiro)
810
811
  end
811
812
 
812
- def self.attach_methods(hiiro)
813
- hiiro.instance_eval do
814
- def environment
815
- @environment ||= Environment.current
816
- end
817
- end
813
+ def self.attach_methods(hiiro, task_manager=nil)
814
+ environment = Environment.current
815
+
816
+ hiiro.attach_method(:environment) { environment }
817
+ hiiro.attach_method(:env) { environment }
818
+ hiiro.attach_method(:task_manager) { task_manager }
819
+ hiiro.attach_method(:tm) { task_manager }
820
+
821
+ hiiro
818
822
  end
819
823
 
820
824
  def self.add_subcommands(hiiro)
821
825
  hiiro.add_subcmd(:task) do |*args|
822
- mgr = TaskManager.new(hiiro, scope: :task)
823
- task_hiiro = Tasks.build_hiiro(hiiro, mgr)
824
- task_hiiro.run
826
+ tm = TaskManager.new(hiiro, scope: :task)
827
+ build_hiiro(hiiro, tm).run
825
828
  end
826
829
 
827
830
  hiiro.add_subcmd(:subtask) do |*args|
828
- mgr = TaskManager.new(hiiro, scope: :subtask)
829
- task_hiiro = Tasks.build_hiiro(hiiro, mgr)
830
- task_hiiro.run
831
+ tm = TaskManager.new(hiiro, scope: :subtask)
832
+ build_hiiro(hiiro, tm).run
831
833
  end
832
834
  end
833
835
 
834
- def self.build_hiiro(parent_hiiro, mgr)
836
+ def self.build_hiiro(parent_hiiro, tm)
835
837
  bin_name = [parent_hiiro.bin, parent_hiiro.subcmd || ''].join('-')
836
838
 
837
- Hiiro.init(bin_name:, args: parent_hiiro.args, task_manager: mgr) do |h|
838
- tm = mgr
839
+ task_hiiro = Hiiro.init(
840
+ bin_name:,
841
+ args: parent_hiiro.args,
842
+ ) do |h|
839
843
  h.add_subcmd(:list) { tm.list }
840
844
  h.add_subcmd(:ls) { tm.list }
841
845
 
@@ -893,5 +897,7 @@ module Tasks
893
897
  system(ENV['EDITOR'] || 'nvim', __FILE__)
894
898
  end
895
899
  end
900
+
901
+ attach_methods task_hiiro, tm
896
902
  end
897
903
  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.64
4
+ version: 0.1.66
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Toyota
@@ -95,6 +95,7 @@ files:
95
95
  - docs/h-session.md
96
96
  - docs/h-video.md
97
97
  - docs/h-window.md
98
+ - editboth
98
99
  - exe/h
99
100
  - hiiro.gemspec
100
101
  - lib/hiiro.rb