hiiro 0.1.33.pre.2 → 0.1.34

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: fcfae77d18ac4bf22f781a841bd6410867a8f2d6b3326845a6a4fcab79229175
4
- data.tar.gz: e6677f372a9442aa0cccbb888f7ee9da8a8568543bad42e7485b674ed30d2af4
3
+ metadata.gz: 8746a15f85121b84a7fcebefcbd7b1b63e5f289190d8bb75a230c27df3ce0279
4
+ data.tar.gz: fc0faa4d8bf9dde3de151b1a2d59e536010f31cd44e8ec6a18a062a735f4c49f
5
5
  SHA512:
6
- metadata.gz: 4b87d2d1eeec269aae9371f93b8ba28c68a2eba03817d6b667289c5178d799b5c86ce0802f0d8dec3f02ecb7d5687745e6b132b354bf32c5ce8ed0656b5ecc29
7
- data.tar.gz: c0789c1f694680700927d7301a587775e655a3ebe0d07137bcb812314614edb2da07b4f1148a3ec2db178e1f64ae2e03ebda565bbd0bada47c4f439f634ad27b
6
+ metadata.gz: ffde10d22c1385fb63333a0679d911c0a062e15a74d4979980c7b2946060add058570db64c52bfeae385b47d488e2b36dbc0bff1604751750d8b1a26a7bd4730
7
+ data.tar.gz: 77d81a271282525001a763fe7ee88e3a92b1fd6804a92ca59ff77a07dce08fb9a9f50b1fa7703f717ea4378bd9c679f7472ec07113529de6771f753ecfada4ce
data/bin/g-pr CHANGED
@@ -6,7 +6,8 @@ require "fileutils"
6
6
  require "yaml"
7
7
  require "json"
8
8
 
9
- hiiro = Hiiro.init(*ARGV, plugins: [:OldTask, :Tmux, :Pins])
9
+ Hiiro.load_env
10
+ hiiro = Hiiro.init(*ARGV, plugins: [OldTask, Tmux, Pins])
10
11
 
11
12
  class PRManager
12
13
  attr_reader :hiiro
data/bin/h-branch CHANGED
@@ -4,7 +4,8 @@ require "hiiro"
4
4
  require "fileutils"
5
5
  require "yaml"
6
6
 
7
- hiiro = Hiiro.init(*ARGV, plugins: [:OldTask])
7
+ Hiiro.load_env
8
+ hiiro = Hiiro.init(*ARGV, plugins: [OldTask])
8
9
 
9
10
  class BranchManager
10
11
  attr_reader :hiiro
data/bin/h-buffer CHANGED
@@ -12,7 +12,7 @@ def find_buffer(partial)
12
12
  buffer
13
13
  end
14
14
 
15
- o = Hiiro.init(*ARGV, plugins: [:Pins])
15
+ o = Hiiro.init(*ARGV, plugins: [Pins])
16
16
 
17
17
  o.add_subcmd(:ls) { |*args|
18
18
  system('tmux', 'list-buffers', *args)
data/bin/h-link CHANGED
@@ -193,7 +193,7 @@ class LinkManager
193
193
  end
194
194
 
195
195
  lm = LinkManager.new
196
- o = Hiiro.init(*ARGV, plugins: [:Tmux, :Pins], links_file: lm.links_file)
196
+ o = Hiiro.init(*ARGV, plugins: [Tmux, Pins], links_file: lm.links_file)
197
197
 
198
198
  o.add_subcmd(:add) do |*args|
199
199
  links = lm.load_links
data/bin/h-osubtask CHANGED
@@ -7,7 +7,8 @@ require "fileutils"
7
7
  require "yaml"
8
8
  require "time"
9
9
 
10
- hiiro = Hiiro.init(*ARGV, plugins: [:Tmux, :OldTask])
10
+ Hiiro.load_env
11
+ hiiro = Hiiro.init(*ARGV, plugins: [Tmux, OldTask])
11
12
 
12
13
  tasks = hiiro.task_manager
13
14
 
data/bin/h-otask CHANGED
@@ -5,7 +5,7 @@ require "fileutils"
5
5
  require "yaml"
6
6
  require "pathname"
7
7
 
8
- hiiro = Hiiro.init(*ARGV, plugins: [:Tmux])
8
+ hiiro = Hiiro.init(*ARGV, plugins: [Tmux])
9
9
 
10
10
  class TaskManager
11
11
  attr_reader :hiiro
data/bin/h-pane CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  load File.join(Dir.home, 'bin', 'h')
4
4
 
5
- o = Hiiro.init(*ARGV, plugins: [:Pins])
5
+ o = Hiiro.init(*ARGV, plugins: [Pins])
6
6
 
7
7
  o.add_subcmd(:ls) { |*args|
8
8
  system('tmux', 'list-panes', *args)
data/bin/h-plugin CHANGED
@@ -5,7 +5,7 @@ require 'json'
5
5
  require 'hiiro'
6
6
 
7
7
  BASE_DIR = File.join(Dir.home, '.config/hiiro/plugins')
8
- o = Hiiro.init(*ARGV, plugins: [:Tmux, :Pins], dir: BASE_DIR)
8
+ o = Hiiro.init(*ARGV, plugins: [Tmux, Pins], dir: BASE_DIR)
9
9
 
10
10
  def plugin_files
11
11
  Dir.glob(File.join(BASE_DIR, '**/*'))
data/bin/h-pr CHANGED
@@ -6,7 +6,8 @@ require "fileutils"
6
6
  require "yaml"
7
7
  require "json"
8
8
 
9
- hiiro = Hiiro.init(*ARGV, plugins: [:OldTask, :Tmux, :Pins])
9
+ Hiiro.load_env
10
+ hiiro = Hiiro.init(*ARGV, plugins: [OldTask, Tmux, Pins])
10
11
 
11
12
  class PRManager
12
13
  attr_reader :hiiro
data/bin/h-session CHANGED
@@ -22,7 +22,7 @@ require 'rspec'
22
22
  # has (subcommand) /Users/unixsuperhero/bin/h-session:139
23
23
  # info (subcommand) /Users/unixsuperhero/bin/h-session:143
24
24
 
25
- o = Hiiro.init(*ARGV, plugins: [:Pins])
25
+ o = Hiiro.init(*ARGV, plugins: [Pins])
26
26
 
27
27
  o.add_subcmd(:ls) { |*args|
28
28
  system('tmux', 'list-sessions', *args)
data/bin/h-sha CHANGED
@@ -4,7 +4,7 @@ require 'hiiro'
4
4
 
5
5
  BASE_DIR = File.join(Dir.home, 'work/carrot')
6
6
 
7
- Hiiro.init(*ARGV, plugins: [:Tmux, :Pins, :Project]) { |hiiro|
7
+ Hiiro.init(*ARGV, plugins: [Tmux, Pins, Project]) { |hiiro|
8
8
 
9
9
  }.run
10
10
 
data/bin/h-vim CHANGED
@@ -5,7 +5,7 @@ require 'hiiro'
5
5
  BASE_DIR = CONFIG_DIR = File.join(Dir.home, '.config/nvim')
6
6
  TMUX_SESSION_NAME = 'vim'
7
7
 
8
- o = Hiiro.init(*ARGV, plugins: [:Tmux, :Pins, :Project])
8
+ o = Hiiro.init(*ARGV, plugins: [Tmux, Pins, Project])
9
9
 
10
10
  o.add_subcmd(:edit) { |*args|
11
11
  nvim = ENV['EDITOR']
data/bin/h-window CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  load File.join(Dir.home, 'bin', 'h')
4
4
 
5
- o = Hiiro.init(*ARGV, plugins: [:Pins])
5
+ o = Hiiro.init(*ARGV, plugins: [Pins])
6
6
 
7
7
  o.add_subcmd(:ls) { |*args|
8
8
  system('tmux', 'list-windows', *args)
data/exe/h CHANGED
@@ -3,7 +3,7 @@
3
3
  require "hiiro"
4
4
  require "fileutils"
5
5
 
6
- hiiro = Hiiro.init(*ARGV, cwd: Dir.pwd, plugins: [:Tasks])
6
+ hiiro = Hiiro.init(*ARGV, cwd: Dir.pwd, plugins: [Tasks])
7
7
 
8
8
  hiiro.add_subcommand(:version) { |*args|
9
9
  puts Hiiro::VERSION
data/lib/hiiro/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Hiiro
2
- VERSION = "0.1.33.pre.2"
2
+ VERSION = "0.1.34"
3
3
  end
data/lib/hiiro.rb CHANGED
@@ -4,7 +4,6 @@ require "shellwords"
4
4
 
5
5
  require_relative "hiiro/version"
6
6
  require_relative "hiiro/history"
7
- require_relative "hiiro/plugins"
8
7
 
9
8
  class String
10
9
  def underscore(camel_cased_word=self)
@@ -21,12 +20,12 @@ end
21
20
 
22
21
  class Hiiro
23
22
  def self.init(*args, plugins: [], logging: false, **values, &block)
24
- load_plugins(plugins)
23
+ load_env
25
24
  args = ARGV if args.empty?
26
25
 
27
26
  new($0, *args, logging: logging, **values).tap do |hiiro|
28
27
  History.load(hiiro)
29
- hiiro.init_plugins(*plugins)
28
+ hiiro.load_plugins(*plugins)
30
29
 
31
30
  hiiro.add_subcmd(:edit, **values) { |*args|
32
31
  system(ENV['EDITOR'] || 'nvim', hiiro.bin)
@@ -42,10 +41,12 @@ class Hiiro
42
41
  hiiro.run
43
42
  end
44
43
 
45
- def self.load_plugins(plugin_list)
46
- plugin_list.each do |name|
47
- Plugins.load_plugin(name.to_s)
44
+ def self.load_env
45
+ Config.plugin_files.each do |plugin_file|
46
+ require plugin_file
48
47
  end
48
+
49
+ self
49
50
  end
50
51
 
51
52
  attr_reader :bin, :bin_name, :all_args, :full_command
@@ -131,24 +132,11 @@ class Hiiro
131
132
 
132
133
  def pins = @pins ||= Pin.new(self)
133
134
 
134
- def init_plugins(*names)
135
- names.flatten.each do |name|
136
- plugin_const = Hiiro::Plugins.const_get(name.to_s) rescue nil
137
- next unless plugin_const
138
- load_plugin(plugin_const)
139
- end
140
- end
141
-
142
135
  def load_plugins(*plugins)
143
136
  plugins.flatten.each { |plugin| load_plugin(plugin) }
144
137
  end
145
138
 
146
- def load_plugin(plugin)
147
- plugin_const = case plugin
148
- when Module then plugin
149
- when String, Symbol then Hiiro::Plugins.load_plugin(plugin.to_s)
150
- end
151
- return unless plugin_const
139
+ def load_plugin(plugin_const)
152
140
  return if @loaded_plugins.include?(plugin_const)
153
141
 
154
142
  plugin_const.load(self)
@@ -205,6 +193,22 @@ class Hiiro
205
193
 
206
194
  class Config
207
195
  class << self
196
+ def plugin_files
197
+ user_files = Dir.glob(File.join(plugin_dir, '*.rb'))
198
+ user_basenames = user_files.map { |f| File.basename(f) }
199
+
200
+ gem_plugin_dir = File.join(File.expand_path('../..', __FILE__), 'plugins')
201
+ gem_files = Dir.exist?(gem_plugin_dir) ? Dir.glob(File.join(gem_plugin_dir, '*.rb')) : []
202
+
203
+ fallback_files = gem_files.reject { |f| user_basenames.include?(File.basename(f)) }
204
+
205
+ user_files + fallback_files
206
+ end
207
+
208
+ def plugin_dir
209
+ config_dir('plugins')
210
+ end
211
+
208
212
  def config_dir(subdir=nil)
209
213
  File.join(Dir.home, '.config/hiiro', *[subdir].compact).tap do |config_path|
210
214
  FileUtils.mkdir_p(config_path) unless Dir.exist?(config_path)
@@ -454,4 +458,6 @@ class Hiiro
454
458
  end
455
459
  end
456
460
  end
461
+
462
+ load_env
457
463
  end
data/plugins/notify.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Notify
4
4
  def self.load(hiiro)
5
- hiiro.load_plugin('Tmux')
5
+ hiiro.load_plugin(Tmux)
6
6
  attach_methods(hiiro)
7
7
  add_subcommands(hiiro)
8
8
  end
data/plugins/old_task.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  module OldTask
4
4
  def self.load(hiiro)
5
- hiiro.load_plugin('Tmux')
5
+ hiiro.load_plugin(Tmux)
6
6
  attach_methods(hiiro)
7
7
  add_subcommands(hiiro)
8
8
  end
data/plugins/project.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Project
4
4
  def self.load(hiiro)
5
- hiiro.load_plugin('Tmux')
5
+ hiiro.load_plugin(Tmux)
6
6
  attach_methods(hiiro)
7
7
  add_subcommands(hiiro)
8
8
  end
data/plugins/tasks.rb CHANGED
@@ -741,7 +741,7 @@ end
741
741
 
742
742
  module Tasks
743
743
  def self.load(hiiro)
744
- hiiro.load_plugin('Tmux')
744
+ hiiro.load_plugin(Tmux)
745
745
  add_subcommands(hiiro)
746
746
  end
747
747
 
data/script/publish CHANGED
@@ -2,24 +2,9 @@
2
2
 
3
3
  require "hiiro"
4
4
 
5
- pre_release = ARGV.include?("-t")
6
- parts = Hiiro::VERSION.split(?.)
7
-
8
- if parts.length == 5 && parts[3] == "pre"
9
- major, minor, patch, _, pre_num = parts
10
- if pre_release
11
- new_version = [major, minor, patch, "pre", pre_num.to_i + 1].join(?.)
12
- else
13
- new_version = [major, minor, patch].join(?.)
14
- end
15
- else
16
- major, minor, patch = parts
17
- if pre_release
18
- new_version = [major, minor, patch.to_i + 1, "pre", 1].join(?.)
19
- else
20
- new_version = [major, minor, patch.to_i + 1].join(?.)
21
- end
22
- end
5
+ major, minor, patch = Hiiro::VERSION.split(?.)
6
+
7
+ new_version = [major, minor, patch.to_i + 1].join(?.)
23
8
 
24
9
  File.open('lib/hiiro/version.rb', 'w+') do |f|
25
10
  f.puts 'class Hiiro'
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.33.pre.2
4
+ version: 0.1.34
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Toyota
@@ -77,7 +77,6 @@ files:
77
77
  - hiiro.gemspec
78
78
  - lib/hiiro.rb
79
79
  - lib/hiiro/history.rb
80
- - lib/hiiro/plugins.rb
81
80
  - lib/hiiro/version.rb
82
81
  - links.backup.yml
83
82
  - notes
@@ -109,9 +108,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
109
108
  version: 2.7.0
110
109
  required_rubygems_version: !ruby/object:Gem::Requirement
111
110
  requirements:
112
- - - ">"
111
+ - - ">="
113
112
  - !ruby/object:Gem::Version
114
- version: 1.3.1
113
+ version: '0'
115
114
  requirements: []
116
115
  rubygems_version: 3.3.7
117
116
  signing_key:
data/lib/hiiro/plugins.rb DELETED
@@ -1,64 +0,0 @@
1
- class Hiiro
2
- class Plugins
3
- class << self
4
- def load_plugin(name)
5
- name_str = name.to_s
6
- return const_get(name_str) if plugin_loaded?(name_str)
7
-
8
- path = plugin_path(name_str)
9
- unless path
10
- warn "[hiiro] plugin not found: #{name_str}"
11
- return nil
12
- end
13
-
14
- module_eval(File.read(path), path, 1)
15
-
16
- unless const_defined?(name_str, false)
17
- warn "[hiiro] plugin #{name_str} did not define expected constant"
18
- return nil
19
- end
20
-
21
- @loaded_plugins ||= []
22
- @loaded_plugins << name_str
23
- const_get(name_str)
24
- end
25
-
26
- def plugin_loaded?(name_str)
27
- (@loaded_plugins || []).include?(name_str.to_s)
28
- end
29
-
30
- def plugin_path(name_str)
31
- plugin_filename = name_str.underscore + '.rb'
32
-
33
- paths_to_check = [
34
- File.join(Dir.home, '.config/hiiro/plugins'),
35
- File.join(File.expand_path('../..', __FILE__), 'plugins'),
36
- ]
37
-
38
- paths_to_check.each do |dir|
39
- full_path = File.join(dir, plugin_filename)
40
- return full_path if File.exist?(full_path)
41
- end
42
-
43
- nil
44
- end
45
-
46
- def load_all
47
- user_dir = File.join(Dir.home, '.config/hiiro/plugins')
48
- gem_dir = File.join(File.expand_path('../..', __FILE__), 'plugins')
49
-
50
- FileUtils.mkdir_p(user_dir) unless Dir.exist?(user_dir)
51
-
52
- user_files = Dir.glob(File.join(user_dir, '*.rb'))
53
- user_basenames = user_files.map { |f| File.basename(f) }
54
-
55
- gem_files = Dir.exist?(gem_dir) ? Dir.glob(File.join(gem_dir, '*.rb')) : []
56
- fallback_files = gem_files.reject { |f| user_basenames.include?(File.basename(f)) }
57
-
58
- (user_files + fallback_files).each do |path|
59
- module_eval(File.read(path), path, 1)
60
- end
61
- end
62
- end
63
- end
64
- end