rufio 0.9.0

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.
Files changed (47) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +188 -0
  3. data/CHANGELOG_v0.4.0.md +146 -0
  4. data/CHANGELOG_v0.5.0.md +26 -0
  5. data/CHANGELOG_v0.6.0.md +182 -0
  6. data/CHANGELOG_v0.7.0.md +280 -0
  7. data/CHANGELOG_v0.8.0.md +267 -0
  8. data/CHANGELOG_v0.9.0.md +279 -0
  9. data/README.md +631 -0
  10. data/README_EN.md +561 -0
  11. data/Rakefile +156 -0
  12. data/bin/rufio +34 -0
  13. data/config_example.rb +88 -0
  14. data/docs/PLUGIN_GUIDE.md +431 -0
  15. data/docs/plugin_example.rb +119 -0
  16. data/lib/rufio/application.rb +32 -0
  17. data/lib/rufio/bookmark.rb +115 -0
  18. data/lib/rufio/bookmark_manager.rb +173 -0
  19. data/lib/rufio/color_helper.rb +150 -0
  20. data/lib/rufio/command_mode.rb +72 -0
  21. data/lib/rufio/command_mode_ui.rb +168 -0
  22. data/lib/rufio/config.rb +199 -0
  23. data/lib/rufio/config_loader.rb +110 -0
  24. data/lib/rufio/dialog_renderer.rb +127 -0
  25. data/lib/rufio/directory_listing.rb +113 -0
  26. data/lib/rufio/file_opener.rb +140 -0
  27. data/lib/rufio/file_operations.rb +231 -0
  28. data/lib/rufio/file_preview.rb +200 -0
  29. data/lib/rufio/filter_manager.rb +114 -0
  30. data/lib/rufio/health_checker.rb +246 -0
  31. data/lib/rufio/keybind_handler.rb +828 -0
  32. data/lib/rufio/logger.rb +103 -0
  33. data/lib/rufio/plugin.rb +89 -0
  34. data/lib/rufio/plugin_config.rb +59 -0
  35. data/lib/rufio/plugin_manager.rb +84 -0
  36. data/lib/rufio/plugins/file_operations.rb +44 -0
  37. data/lib/rufio/selection_manager.rb +79 -0
  38. data/lib/rufio/terminal_ui.rb +630 -0
  39. data/lib/rufio/text_utils.rb +108 -0
  40. data/lib/rufio/version.rb +5 -0
  41. data/lib/rufio/zoxide_integration.rb +188 -0
  42. data/lib/rufio.rb +33 -0
  43. data/publish_gem.zsh +131 -0
  44. data/rufio.gemspec +40 -0
  45. data/test_delete/test1.txt +1 -0
  46. data/test_delete/test2.txt +1 -0
  47. metadata +189 -0
data/bin/rufio ADDED
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative '../lib/rufio'
5
+
6
+ # プラグインを読み込む
7
+ Rufio::PluginManager.load_all
8
+
9
+ # コマンドライン引数の処理
10
+ if ARGV.include?('--check-health') || ARGV.include?('-c')
11
+ # ヘルスチェック実行
12
+ health_checker = Rufio::HealthChecker.new
13
+ success = health_checker.run_check
14
+ exit(success ? 0 : 1)
15
+ elsif ARGV.include?('--help')
16
+ puts "rufio - Terminal-based file manager"
17
+ puts ""
18
+ puts "Usage:"
19
+ puts " rufio [DIRECTORY] Start rufio in specified directory"
20
+ puts " rufio -c, --check-health Check system dependencies"
21
+ puts " rufio --help Show this help message"
22
+ puts ""
23
+ puts "Examples:"
24
+ puts " rufio # Start in current directory"
25
+ puts " rufio /path/to/dir # Start in specific directory"
26
+ puts " rufio -c # Check if all dependencies are available"
27
+ exit(0)
28
+ else
29
+ start_directory = ARGV[0] || Dir.pwd
30
+
31
+ # アプリケーション開始
32
+ app = Rufio::Application.new(start_directory)
33
+ app.run
34
+ end
data/config_example.rb ADDED
@@ -0,0 +1,88 @@
1
+ # frozen_string_literal: true
2
+
3
+ # rufio configuration example
4
+ # Copy this file to ~/.config/rufio/config.rb to customize your settings
5
+
6
+ # Cross-platform file opener method
7
+ def get_system_open_command
8
+ case RbConfig::CONFIG['host_os']
9
+ when /mswin|mingw|cygwin/
10
+ 'start' # Windows
11
+ when /darwin/
12
+ 'open' # macOS
13
+ when /linux|bsd/
14
+ 'xdg-open' # Linux/BSD
15
+ else
16
+ 'open' # Fallback to open
17
+ end
18
+ end
19
+
20
+ # Get the appropriate open command for current platform
21
+ SYSTEM_OPEN = get_system_open_command
22
+
23
+ # Language setting
24
+ # Available languages: 'en' (English), 'ja' (Japanese)
25
+ # If not specified, language will be auto-detected from environment variables
26
+ LANGUAGE = 'en' # or 'ja'
27
+
28
+ # Application associations
29
+ # Define which applications to use for opening different file types
30
+ APPLICATIONS = {
31
+ # Text files - open with 'code' (VS Code)
32
+ %w[txt md rb py js ts html css json xml yaml yml] => 'code',
33
+
34
+ # Image files - open with default system app
35
+ %w[jpg jpeg png gif bmp svg webp] => SYSTEM_OPEN,
36
+
37
+ # Video files - open with default system app
38
+ %w[mp4 avi mkv mov wmv] => SYSTEM_OPEN,
39
+
40
+ # Documents - open with default system app
41
+ %w[pdf doc docx xls xlsx ppt pptx] => SYSTEM_OPEN,
42
+
43
+ # Default application for unspecified file types
44
+ :default => SYSTEM_OPEN
45
+ }
46
+
47
+ # Color scheme
48
+ # Define colors for different types of files and UI elements
49
+ # You can use various color formats:
50
+ # - Symbols: :blue, :red, :green, :yellow, :cyan, :magenta, :white, :black
51
+ # - HSL: {hsl: [hue(0-360), saturation(0-100), lightness(0-100)]}
52
+ # - RGB: {rgb: [red(0-255), green(0-255), blue(0-255)]}
53
+ # - HEX: {hex: "#ff0000"}
54
+ # - ANSI codes: "34" or 34
55
+ COLORS = {
56
+ # HSL color examples (Hue: 0-360, Saturation: 0-100%, Lightness: 0-100%)
57
+ directory: { hsl: [220, 80, 60] }, # Blue directory entries
58
+ file: { hsl: [0, 0, 90] }, # Light gray regular files
59
+ executable: { hsl: [120, 70, 50] }, # Green executable files
60
+ selected: { hsl: [50, 90, 70] }, # Yellow currently selected item
61
+ preview: { hsl: [180, 60, 65] }, # Cyan preview panel
62
+
63
+ # You can also mix different formats:
64
+ # directory: :blue, # Traditional symbol
65
+ # file: {rgb: [200, 200, 200]}, # RGB format
66
+ # executable: {hex: "#00ff00"}, # HEX format
67
+ # selected: "93", # ANSI code (bright yellow)
68
+ }
69
+
70
+ # Key bindings
71
+ # Customize keyboard shortcuts (not yet fully implemented)
72
+ KEYBINDS = {
73
+ quit: %w[q ESC],
74
+ up: %w[k UP],
75
+ down: %w[j DOWN],
76
+ left: %w[h LEFT],
77
+ right: %w[l RIGHT ENTER],
78
+ top: %w[g],
79
+ bottom: %w[G],
80
+ refresh: %w[r],
81
+ search: %w[/],
82
+ open_file: %w[o SPACE]
83
+ }
84
+
85
+ # You can also set language via environment variable:
86
+ # export BENIYA_LANG=ja # Set to 'ja' for Japanese, 'en' for English
87
+ # Note: Only BENIYA_LANG is used for language detection
88
+ # System LANG variable is ignored to ensure English is the default
@@ -0,0 +1,431 @@
1
+ # Rufio プラグインガイド
2
+
3
+ Rufioのプラグインシステムを使って、機能を拡張する方法を説明します。
4
+
5
+ ## 目次
6
+
7
+ 1. [プラグインの基本](#プラグインの基本)
8
+ 2. [プラグインの作成](#プラグインの作成)
9
+ 3. [プラグインの設定](#プラグインの設定)
10
+ 4. [高度な機能](#高度な機能)
11
+ 5. [トラブルシューティング](#トラブルシューティング)
12
+
13
+ ## プラグインの基本
14
+
15
+ ### プラグインとは?
16
+
17
+ プラグインは、Rufioに新しい機能を追加するためのRubyモジュールです。
18
+
19
+ ### プラグインの種類
20
+
21
+ 1. **組み込みプラグイン**: Rufio本体に含まれる
22
+ - 場所: `lib/rufio/plugins/`
23
+ - 例: `FileOperations`
24
+
25
+ 2. **ユーザープラグイン**: ユーザーが作成する
26
+ - 場所: `~/.rufio/plugins/`
27
+ - 自由にカスタマイズ可能
28
+
29
+ ## プラグインの作成
30
+
31
+ ### ステップ1: ディレクトリの準備
32
+
33
+ ```bash
34
+ # プラグインディレクトリを作成
35
+ mkdir -p ~/.rufio/plugins
36
+ ```
37
+
38
+ ### ステップ2: プラグインファイルの作成
39
+
40
+ `~/.rufio/plugins/my_plugin.rb`を作成:
41
+
42
+ ```ruby
43
+ # frozen_string_literal: true
44
+
45
+ module Rufio
46
+ module Plugins
47
+ class MyPlugin < Plugin
48
+ # プラグイン名(必須)
49
+ def name
50
+ "MyPlugin"
51
+ end
52
+
53
+ # 説明(オプション)
54
+ def description
55
+ "私のカスタムプラグイン"
56
+ end
57
+
58
+ # バージョン(オプション)
59
+ def version
60
+ "1.0.0"
61
+ end
62
+
63
+ # コマンドの定義(オプション)
64
+ def commands
65
+ {
66
+ hello: method(:say_hello)
67
+ }
68
+ end
69
+
70
+ private
71
+
72
+ def say_hello
73
+ puts "Hello from MyPlugin!"
74
+ end
75
+ end
76
+ end
77
+ end
78
+ ```
79
+
80
+ ### ステップ3: プラグインの読み込み
81
+
82
+ Rufioを起動すると、自動的に`~/.rufio/plugins/`内のプラグインが読み込まれます。
83
+
84
+ ## プラグインの設定
85
+
86
+ ### 設定ファイルの作成
87
+
88
+ `~/.rufio/config.yml`:
89
+
90
+ ```yaml
91
+ plugins:
92
+ # プラグイン名を小文字で指定
93
+ myplugin:
94
+ enabled: true
95
+
96
+ # 無効化したいプラグイン
97
+ fileoperations:
98
+ enabled: false
99
+ ```
100
+
101
+ ### 設定のルール
102
+
103
+ - **プラグイン名**: 大文字小文字を区別せず、小文字に統一されます
104
+ - `MyPlugin`, `myplugin`, `MYPLUGIN` → すべて `myplugin` として扱われます
105
+ - **デフォルト**: 設定に記載のないプラグインは**有効**です
106
+ - **enabled**: `true`で有効、`false`で無効
107
+
108
+ ## 高度な機能
109
+
110
+ ### 外部gemへの依存
111
+
112
+ プラグインが外部gemに依存する場合、`requires`を使用:
113
+
114
+ ```ruby
115
+ module Rufio
116
+ module Plugins
117
+ class AdvancedPlugin < Plugin
118
+ # 依存するgemを宣言
119
+ requires 'httparty', 'nokogiri'
120
+
121
+ def name
122
+ "AdvancedPlugin"
123
+ end
124
+
125
+ def description
126
+ "HTTPartyとNokogiriを使用"
127
+ end
128
+
129
+ private
130
+
131
+ def fetch_and_parse
132
+ require 'httparty'
133
+ require 'nokogiri'
134
+
135
+ response = HTTParty.get('https://example.com')
136
+ doc = Nokogiri::HTML(response.body)
137
+ # 処理...
138
+ end
139
+ end
140
+ end
141
+ end
142
+ ```
143
+
144
+ gemが不足している場合、以下のメッセージが表示されます:
145
+
146
+ ```
147
+ ⚠️ Plugin 'AdvancedPlugin' は以下のgemに依存していますが、インストールされていません:
148
+ - httparty
149
+ - nokogiri
150
+
151
+ 以下のコマンドでインストールしてください:
152
+ gem install httparty nokogiri
153
+ ```
154
+
155
+ ### コマンドの定義
156
+
157
+ プラグインは複数のコマンドを提供できます:
158
+
159
+ ```ruby
160
+ def commands
161
+ {
162
+ search: method(:search_files),
163
+ count: method(:count_files),
164
+ list: method(:list_files)
165
+ }
166
+ end
167
+
168
+ private
169
+
170
+ def search_files
171
+ # 検索処理
172
+ end
173
+
174
+ def count_files
175
+ # カウント処理
176
+ end
177
+
178
+ def list_files
179
+ # 一覧表示
180
+ end
181
+ ```
182
+
183
+ ## プラグインの例
184
+
185
+ ### 1. ファイル検索プラグイン
186
+
187
+ ```ruby
188
+ module Rufio
189
+ module Plugins
190
+ class FileSearchPlugin < Plugin
191
+ def name
192
+ "FileSearch"
193
+ end
194
+
195
+ def description
196
+ "ファイル名で検索"
197
+ end
198
+
199
+ def commands
200
+ {
201
+ search: method(:search_files),
202
+ find_ext: method(:find_by_extension)
203
+ }
204
+ end
205
+
206
+ private
207
+
208
+ def search_files(query = "*")
209
+ Dir.glob("**/*#{query}*").each do |file|
210
+ puts file if File.file?(file)
211
+ end
212
+ end
213
+
214
+ def find_by_extension(ext)
215
+ Dir.glob("**/*.#{ext}").each do |file|
216
+ puts file
217
+ end
218
+ end
219
+ end
220
+ end
221
+ end
222
+ ```
223
+
224
+ ### 2. Git統合プラグイン
225
+
226
+ ```ruby
227
+ module Rufio
228
+ module Plugins
229
+ class GitPlugin < Plugin
230
+ def name
231
+ "Git"
232
+ end
233
+
234
+ def description
235
+ "Git操作の統合"
236
+ end
237
+
238
+ def commands
239
+ {
240
+ status: method(:git_status),
241
+ branch: method(:current_branch),
242
+ log: method(:git_log)
243
+ }
244
+ end
245
+
246
+ private
247
+
248
+ def git_status
249
+ system('git status') if git_available?
250
+ end
251
+
252
+ def current_branch
253
+ if git_available?
254
+ branch = `git branch --show-current`.strip
255
+ puts "ブランチ: #{branch}"
256
+ end
257
+ end
258
+
259
+ def git_log
260
+ system('git log --oneline -10') if git_available?
261
+ end
262
+
263
+ def git_available?
264
+ if system('which git > /dev/null 2>&1')
265
+ true
266
+ else
267
+ puts "⚠️ gitがインストールされていません"
268
+ false
269
+ end
270
+ end
271
+ end
272
+ end
273
+ end
274
+ ```
275
+
276
+ ### 3. システム情報プラグイン
277
+
278
+ ```ruby
279
+ module Rufio
280
+ module Plugins
281
+ class SystemInfoPlugin < Plugin
282
+ def name
283
+ "SystemInfo"
284
+ end
285
+
286
+ def description
287
+ "システム情報を表示"
288
+ end
289
+
290
+ def commands
291
+ {
292
+ info: method(:show_system_info),
293
+ disk: method(:show_disk_usage)
294
+ }
295
+ end
296
+
297
+ private
298
+
299
+ def show_system_info
300
+ puts "OS: #{RbConfig::CONFIG['host_os']}"
301
+ puts "Ruby: #{RUBY_VERSION}"
302
+ puts "ホームディレクトリ: #{ENV['HOME']}"
303
+ end
304
+
305
+ def show_disk_usage
306
+ puts "ディスク使用量:"
307
+ system('df -h .')
308
+ end
309
+ end
310
+ end
311
+ end
312
+ ```
313
+
314
+ ## プラグインの仕組み
315
+
316
+ ### 自動登録
317
+
318
+ プラグインは`Rufio::Plugin`を継承すると、自動的に`PluginManager`に登録されます:
319
+
320
+ ```ruby
321
+ class MyPlugin < Plugin
322
+ # 継承した時点で自動登録される
323
+ end
324
+ ```
325
+
326
+ ### 初期化時の依存チェック
327
+
328
+ プラグインがインスタンス化されるとき、`requires`で宣言したgemがインストールされているかチェックされます:
329
+
330
+ ```ruby
331
+ def initialize
332
+ check_dependencies! # 自動的に呼ばれる
333
+ end
334
+ ```
335
+
336
+ ## トラブルシューティング
337
+
338
+ ### プラグインが読み込まれない
339
+
340
+ **症状**: プラグインを作成したのに動作しない
341
+
342
+ **確認事項**:
343
+ 1. ファイルの場所: `~/.rufio/plugins/` に配置されているか
344
+ 2. ファイル名: `.rb`拡張子がついているか
345
+ 3. 構文エラー: Rubyの構文が正しいか
346
+ 4. 設定ファイル: `config.yml`で無効化されていないか
347
+
348
+ ### 依存gemが見つからない
349
+
350
+ **症状**: プラグイン起動時にエラーが出る
351
+
352
+ **解決方法**:
353
+ ```bash
354
+ # エラーメッセージに表示されたgemをインストール
355
+ gem install <gem名>
356
+ ```
357
+
358
+ ### プラグインが無効化されている
359
+
360
+ **症状**: プラグインが読み込まれない(エラーなし)
361
+
362
+ **確認**: `~/.rufio/config.yml`を確認
363
+
364
+ ```yaml
365
+ plugins:
366
+ myplugin:
367
+ enabled: false # ← これを true に変更
368
+ ```
369
+
370
+ ## ベストプラクティス
371
+
372
+ ### 1. わかりやすい名前をつける
373
+
374
+ ```ruby
375
+ def name
376
+ "MyAwesomePlugin" # 明確で分かりやすい名前
377
+ end
378
+ ```
379
+
380
+ ### 2. 説明を書く
381
+
382
+ ```ruby
383
+ def description
384
+ "このプラグインは〇〇の機能を提供します"
385
+ end
386
+ ```
387
+
388
+ ### 3. エラーハンドリング
389
+
390
+ ```ruby
391
+ def my_command
392
+ # エラーが起きる可能性のある処理
393
+ result = some_operation
394
+ rescue StandardError => e
395
+ puts "⚠️ エラーが発生しました: #{e.message}"
396
+ end
397
+ ```
398
+
399
+ ### 4. 外部コマンドの確認
400
+
401
+ ```ruby
402
+ def command_available?(cmd)
403
+ system("which #{cmd} > /dev/null 2>&1")
404
+ end
405
+
406
+ def my_feature
407
+ unless command_available?('git')
408
+ puts "⚠️ gitがインストールされていません"
409
+ return
410
+ end
411
+
412
+ # 処理...
413
+ end
414
+ ```
415
+
416
+ ## 参考
417
+
418
+ - サンプルプラグイン: `docs/plugin_example.rb`
419
+ - 組み込みプラグイン: `lib/rufio/plugins/file_operations.rb`
420
+ - プラグイン基底クラス: `lib/rufio/plugin.rb`
421
+ - プラグインマネージャー: `lib/rufio/plugin_manager.rb`
422
+
423
+ ## まとめ
424
+
425
+ 1. `~/.rufio/plugins/` にRubyファイルを作成
426
+ 2. `Rufio::Plugin`を継承したクラスを定義
427
+ 3. 必須メソッド`name`を実装
428
+ 4. オプションで`description`、`version`、`commands`を実装
429
+ 5. Rufio起動時に自動読み込み
430
+
431
+ プラグインシステムを使って、Rufioを自分好みにカスタマイズしてください!
@@ -0,0 +1,119 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Rufio プラグイン実装例
4
+ # このファイルを ~/.rufio/plugins/ にコピーして使用してください
5
+
6
+ module Rufio
7
+ module Plugins
8
+ # ファイル検索プラグインの例
9
+ class FileSearchPlugin < Plugin
10
+ def name
11
+ "FileSearch"
12
+ end
13
+
14
+ def description
15
+ "ファイル名で検索する機能"
16
+ end
17
+
18
+ def version
19
+ "1.0.0"
20
+ end
21
+
22
+ def commands
23
+ {
24
+ search: method(:search_files),
25
+ find_by_ext: method(:find_by_extension)
26
+ }
27
+ end
28
+
29
+ private
30
+
31
+ # ファイル名で検索
32
+ def search_files(query)
33
+ Dir.glob("**/*#{query}*").each do |file|
34
+ puts file
35
+ end
36
+ end
37
+
38
+ # 拡張子でファイルを検索
39
+ def find_by_extension(ext)
40
+ Dir.glob("**/*.#{ext}").each do |file|
41
+ puts file
42
+ end
43
+ end
44
+ end
45
+
46
+ # Git統合プラグインの例(外部gem依存)
47
+ class GitIntegrationPlugin < Plugin
48
+ # gitコマンドが必要
49
+ # requires 'git' # gemが必要な場合
50
+
51
+ def name
52
+ "GitIntegration"
53
+ end
54
+
55
+ def description
56
+ "Git操作を統合"
57
+ end
58
+
59
+ def commands
60
+ {
61
+ git_status: method(:show_git_status),
62
+ git_branch: method(:show_current_branch)
63
+ }
64
+ end
65
+
66
+ private
67
+
68
+ def show_git_status
69
+ if system('which git > /dev/null 2>&1')
70
+ system('git status')
71
+ else
72
+ puts "⚠️ gitがインストールされていません"
73
+ end
74
+ end
75
+
76
+ def show_current_branch
77
+ if system('which git > /dev/null 2>&1')
78
+ branch = `git branch --show-current`.strip
79
+ puts "現在のブランチ: #{branch}"
80
+ else
81
+ puts "⚠️ gitがインストールされていません"
82
+ end
83
+ end
84
+ end
85
+
86
+ # シンプルなユーティリティプラグイン
87
+ class UtilityPlugin < Plugin
88
+ def name
89
+ "Utility"
90
+ end
91
+
92
+ def description
93
+ "便利なユーティリティ機能"
94
+ end
95
+
96
+ def commands
97
+ {
98
+ disk_usage: method(:show_disk_usage),
99
+ count_files: method(:count_files_in_directory)
100
+ }
101
+ end
102
+
103
+ private
104
+
105
+ def show_disk_usage
106
+ puts "ディスク使用量:"
107
+ system('df -h .')
108
+ end
109
+
110
+ def count_files_in_directory
111
+ files = Dir.glob('*').select { |f| File.file?(f) }
112
+ dirs = Dir.glob('*').select { |f| File.directory?(f) }
113
+
114
+ puts "ファイル数: #{files.count}"
115
+ puts "ディレクトリ数: #{dirs.count}"
116
+ end
117
+ end
118
+ end
119
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rufio
4
+ class Application
5
+ # Error display constants
6
+ BACKTRACE_LINES = 5 # Number of backtrace lines to show
7
+
8
+ def initialize(start_directory = Dir.pwd)
9
+ @start_directory = File.expand_path(start_directory)
10
+ # Load configuration including language settings
11
+ ConfigLoader.load_config
12
+ end
13
+
14
+ def run
15
+ # 各コンポーネントを初期化
16
+ directory_listing = DirectoryListing.new(@start_directory)
17
+ keybind_handler = KeybindHandler.new
18
+ keybind_handler.set_base_directory(@start_directory)
19
+ file_preview = FilePreview.new
20
+ terminal_ui = TerminalUI.new
21
+
22
+ # アプリケーション開始
23
+ terminal_ui.start(directory_listing, keybind_handler, file_preview)
24
+ rescue Interrupt
25
+ puts "\n\n#{ConfigLoader.message('app.interrupted')}"
26
+ rescue StandardError => e
27
+ puts "\n#{ConfigLoader.message('app.error_occurred')}: #{e.message}"
28
+ puts e.backtrace.first(BACKTRACE_LINES).join("\n")
29
+ end
30
+ end
31
+ end
32
+