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/README_EN.md ADDED
@@ -0,0 +1,561 @@
1
+ # rufio
2
+
3
+ A terminal-based file manager written in Ruby
4
+
5
+ [日本語版](./README.md) | **English**
6
+
7
+ ## Overview
8
+
9
+ rufio is a terminal-based file manager inspired by Yazi. It's implemented in Ruby with plugin support, providing lightweight and fast operations for file browsing, management, and searching.
10
+
11
+ ## Features
12
+
13
+ - **Lightweight & Simple**: A lightweight file manager written in Ruby
14
+ - **Intuitive Operation**: Vim-like key bindings
15
+ - **Plugin System**: Extensible plugin architecture
16
+ - **File Preview**: View text file contents on the fly
17
+ - **File Selection & Operations**: Select multiple files, move, copy, and delete
18
+ - **Base Directory Operations**: Batch file operations to startup directory
19
+ - **Real-time Filter**: Filter files by name using s key
20
+ - **Advanced Search**: Powerful search using fzf and rga
21
+ - **Multi-platform**: Runs on macOS, Linux, and Windows
22
+ - **External Editor Integration**: Open files with your favorite editor
23
+ - **English Interface**: Clean English interface
24
+ - **Health Check**: System dependency verification
25
+
26
+ ## Installation
27
+
28
+ ```bash
29
+ gem install rufio
30
+ ```
31
+
32
+ Or add it to your Gemfile:
33
+
34
+ ```ruby
35
+ gem 'rufio'
36
+ ```
37
+
38
+ ## Usage
39
+
40
+ ### Basic Launch
41
+
42
+ ```bash
43
+ rufio # Launch in current directory
44
+ rufio /path/to # Launch in specified directory
45
+ ```
46
+
47
+ ### Health Check
48
+
49
+ ```bash
50
+ rufio -c # Check system dependencies
51
+ rufio --check-health # Same as above
52
+ rufio --help # Show help message
53
+ ```
54
+
55
+ ### Key Bindings
56
+
57
+ #### Basic Navigation
58
+
59
+ | Key | Function |
60
+ | ------------- | ----------------------------- |
61
+ | `j` | Move down |
62
+ | `k` | Move up |
63
+ | `h` | Move to parent directory |
64
+ | `l` / `Enter` | Enter directory / Select file |
65
+
66
+ #### Quick Navigation
67
+
68
+ | Key | Function |
69
+ | --- | ---------------------- |
70
+ | `g` | Move to top of list |
71
+ | `G` | Move to bottom of list |
72
+
73
+ #### File Operations
74
+
75
+ | Key | Function |
76
+ | --- | --------------------------------------- |
77
+ | `o` | Open selected file with external editor |
78
+ | `e` | Open current directory in file explorer |
79
+ | `r` | Refresh directory contents |
80
+ | `a` | Create new file |
81
+ | `A` | Create new directory |
82
+
83
+ #### File Selection & Operations
84
+
85
+ | Key | Function |
86
+ | ------- | ------------------------------------------- |
87
+ | `Space` | Select/deselect files and directories |
88
+ | `m` | Move selected items to base directory |
89
+ | `p` | Copy selected items to base directory |
90
+ | `x` | Delete selected items |
91
+
92
+ #### Real-time Filter
93
+
94
+ | Key | Function |
95
+ | ----------- | -------------------------------------- |
96
+ | `s` | Start filter mode / Re-edit filter |
97
+ | Text input | Filter files by name (in filter mode) |
98
+ | `Enter` | Keep filter and return to normal mode |
99
+ | `ESC` | Clear filter and return to normal mode |
100
+ | `Backspace` | Delete character (in filter mode) |
101
+
102
+ #### Search Functions
103
+
104
+ | Key | Function |
105
+ | --- | ---------------------------------------- |
106
+ | `f` | File name search with fzf (with preview) |
107
+ | `F` | File content search with rga |
108
+
109
+ #### Bookmark Functions
110
+
111
+ | Key | Function |
112
+ | ------- | ------------------------------- |
113
+ | `b` | Show bookmark menu |
114
+ | `1`-`9` | Go to corresponding bookmark |
115
+
116
+ #### zoxide Integration
117
+
118
+ | Key | Function |
119
+ | --- | ---------------------------------- |
120
+ | `z` | Select directory from zoxide history |
121
+
122
+ #### System Operations
123
+
124
+ | Key | Function |
125
+ | --- | ----------- |
126
+ | `q` | Quit rufio |
127
+
128
+ ### File Selection & Operations
129
+
130
+ #### File and Directory Selection (`Space`)
131
+
132
+ - **Select/Deselect**: Use `Space` key to select or deselect files and directories
133
+ - **Multiple Selection**: Select multiple files and directories simultaneously
134
+ - **Visual Display**: Selected items are marked with ✓ and highlighted in green
135
+ - **Selection Counter**: The number of selected items is shown on the second line of the screen
136
+
137
+ #### Base Directory Operations
138
+
139
+ The directory where rufio starts becomes the **base directory**, which serves as the destination for move and copy operations.
140
+
141
+ | Operation | Key | Function |
142
+ | --------- | --- | --------------------------------------- |
143
+ | **Move** | `m` | Move selected items to base directory |
144
+ | **Copy** | `p` | Copy selected items to base directory |
145
+ | **Delete** | `x` | Delete selected items |
146
+
147
+ #### Delete Operation Details
148
+
149
+ - **Floating Dialog Confirmation**: Modern floating window with clear options
150
+ - **Visual Feedback**: Red border and warning colors for attention
151
+ - **Safe Operation**: Double confirmation before deletion
152
+ - **Comprehensive Error Handling**: Detailed error messages for failed deletions
153
+ - **Real-time Result Display**: Shows success/failure count in floating dialog
154
+ - **File System Verification**: Confirms actual deletion before reporting success
155
+ - **Debug Support**: Optional debug logging with BENIYA_DEBUG=1
156
+
157
+ #### Operation Workflow
158
+
159
+ ```
160
+ 1. Space → Select files/directories (multiple selection possible)
161
+ 2. Choose operation key:
162
+ - m → Move to base directory
163
+ - p → Copy to base directory
164
+ - x → Delete
165
+ 3. Floating Dialog → Confirm with Y/N, ESC to cancel
166
+ 4. Result Display → Review operation results in floating window
167
+ ```
168
+
169
+ #### Safety Features
170
+
171
+ - **Floating Confirmation Dialog**: Modern floating window interface for confirmations
172
+ - **Visual Warning System**: Red borders and colors for dangerous operations
173
+ - **Duplicate Check**: Automatically skip files with same names
174
+ - **Error Handling**: Proper handling of permission errors and other issues
175
+ - **Operation Log**: Detailed display of operation results in floating dialogs
176
+ - **Post-deletion Verification**: Confirms files are actually deleted from filesystem
177
+
178
+ ### Filter Feature
179
+
180
+ #### Real-time Filter (`s`)
181
+
182
+ - **Start Filter**: Press `s` to enter filter mode
183
+ - **Text Input Filtering**: Supports Japanese, English, numbers, and symbols
184
+ - **Real-time Updates**: Display updates with each character typed
185
+ - **Keep Filter**: Press `Enter` to maintain filter while returning to normal operations
186
+ - **Clear Filter**: Press `ESC` to clear filter and return to normal display
187
+ - **Re-edit**: Press `s` again while filter is active to re-edit
188
+ - **Character Deletion**: Use `Backspace` to delete characters, auto-clear when empty
189
+
190
+ #### Usage Example
191
+
192
+ ```
193
+ 1. s → Start filter mode
194
+ 2. ".rb" → Show only Ruby files
195
+ 3. Enter → Keep filter, return to normal operations
196
+ 4. j/k → Navigate within filtered results
197
+ 5. s → Re-edit filter
198
+ 6. ESC → Clear filter
199
+ ```
200
+
201
+ ### Search Features
202
+
203
+ #### File Name Search (`f`)
204
+
205
+ - Interactive file name search using `fzf`
206
+ - Real-time preview display
207
+ - Selected files automatically open in external editor
208
+
209
+ #### File Content Search (`F`)
210
+
211
+ - Advanced file content search using `rga` (ripgrep-all)
212
+ - Searches PDFs, Word documents, text in images, and more
213
+ - Filter results with fzf and jump to specific lines
214
+
215
+ ### Bookmark Features
216
+
217
+ #### Bookmark Operations (`b`)
218
+
219
+ - **Add Bookmark**: `[A]` - Add current directory to bookmarks
220
+ - **List Bookmarks**: `[L]` - Display registered bookmarks
221
+ - **Remove Bookmark**: `[R]` - Remove a bookmark
222
+ - **Number Jump**: `1-9` - Jump directly to corresponding bookmark
223
+
224
+ #### Quick Navigation (`1`-`9`)
225
+
226
+ - Jump directly to bookmarks without going through the bookmark menu
227
+ - Supports up to 9 bookmarks
228
+ - Bookmark information is displayed at the top of the screen
229
+
230
+ #### Bookmark Persistence
231
+
232
+ - Bookmark information is automatically saved to `~/.config/rufio/bookmarks.json`
233
+ - Bookmark information is preserved after rufio restarts
234
+ - JSON file can be edited directly
235
+
236
+ ### zoxide Integration Features
237
+
238
+ #### zoxide History Navigation (`z`)
239
+
240
+ - **Smart History**: Display directory navigation history recorded by zoxide
241
+ - **Frequency Order**: More frequently used directories appear higher in the list
242
+ - **Interactive Selection**: Select from history using floating window
243
+ - **Quick Navigation**: Select directories directly with number keys
244
+ - **Abbreviated Path Display**: Home directory shown as `~` for readability
245
+
246
+ #### Usage Example
247
+
248
+ ```
249
+ 1. z → Display zoxide history menu
250
+ 2. 1-20 → Select directory by displayed number
251
+ 3. ESC → Cancel and return to original screen
252
+ ```
253
+
254
+ #### About zoxide
255
+
256
+ [zoxide](https://github.com/ajeetdsouza/zoxide) is a smart cd command that learns your directory navigation habits.
257
+
258
+ ```bash
259
+ # Installing zoxide
260
+ # macOS (Homebrew)
261
+ brew install zoxide
262
+
263
+ # Ubuntu/Debian
264
+ apt install zoxide
265
+
266
+ # For other installation methods, see official documentation
267
+ # https://github.com/ajeetdsouza/zoxide#installation
268
+ ```
269
+
270
+ #### Requirements
271
+
272
+ - zoxide must be installed on the system
273
+ - Appropriate message is displayed when zoxide is not available
274
+ - Empty history is handled gracefully
275
+
276
+ ### Required External Tools
277
+
278
+ The following tools are required for search and history functionality:
279
+
280
+ ```bash
281
+ # macOS (Homebrew)
282
+ brew install fzf rga zoxide
283
+
284
+ # Ubuntu/Debian
285
+ apt install fzf zoxide
286
+ # rga requires separate installation: https://github.com/phiresky/ripgrep-all
287
+
288
+ # Other Linux distributions
289
+ # Installation via package manager or manual installation required
290
+ ```
291
+
292
+ #### Tool Usage
293
+
294
+ - **fzf**: File name search functionality (`f` key)
295
+ - **rga**: File content search functionality (`F` key)
296
+ - **zoxide**: Directory history navigation functionality (`z` key)
297
+
298
+ ## Configuration
299
+
300
+ ### Color Configuration (Customization)
301
+
302
+ rufio allows you to customize colors for file types and UI elements. It supports intuitive color specification using the HSL color model.
303
+
304
+ #### Supported Color Formats
305
+
306
+ ```ruby
307
+ # HSL (Hue, Saturation, Lightness) - Recommended format
308
+ {hsl: [220, 80, 60]} # Hue 220°, Saturation 80%, Lightness 60%
309
+
310
+ # RGB (Red, Green, Blue)
311
+ {rgb: [100, 150, 200]}
312
+
313
+ # HEX (Hexadecimal)
314
+ {hex: "#6496c8"}
315
+
316
+ # Traditional symbols
317
+ :blue, :red, :green, :yellow, :cyan, :magenta, :white, :black
318
+
319
+ # ANSI color codes
320
+ "34" or 34
321
+ ```
322
+
323
+ #### Configuration Example
324
+
325
+ ```ruby
326
+ # ~/.config/rufio/config.rb
327
+ COLORS = {
328
+ # HSL color specification (intuitive and easy to adjust)
329
+ directory: {hsl: [220, 80, 60]}, # Blue-ish for directories
330
+ file: {hsl: [0, 0, 90]}, # Light gray for regular files
331
+ executable: {hsl: [120, 70, 50]}, # Green-ish for executable files
332
+ selected: {hsl: [50, 90, 70]}, # Yellow for selected items
333
+ preview: {hsl: [180, 60, 65]}, # Cyan for preview panel
334
+
335
+ # You can also mix different formats
336
+ # directory: :blue, # Symbol
337
+ # file: {rgb: [200, 200, 200]}, # RGB
338
+ # executable: {hex: "#00aa00"}, # HEX
339
+ }
340
+ ```
341
+
342
+ #### About HSL Color Model
343
+
344
+ - **Hue**: 0-360 degrees (0=red, 120=green, 240=blue)
345
+ - **Saturation**: 0-100% (0=gray, 100=vivid)
346
+ - **Lightness**: 0-100% (0=black, 50=normal, 100=white)
347
+
348
+ #### Configurable Items
349
+
350
+ - `directory`: Directory color
351
+ - `file`: Regular file color
352
+ - `executable`: Executable file color
353
+ - `selected`: Selected item color
354
+ - `preview`: Preview panel color
355
+
356
+ ## Plugin System
357
+
358
+ rufio features an extensible plugin system that allows you to easily add custom functionality.
359
+
360
+ ### Plugin Locations
361
+
362
+ #### 1. Built-in Plugins
363
+ ```
364
+ lib/rufio/plugins/*.rb
365
+ ```
366
+ Plugins included with rufio by default. Provides basic functionality without external gem dependencies.
367
+
368
+ #### 2. User Plugins
369
+ ```
370
+ ~/.rufio/plugins/*.rb
371
+ ```
372
+ Plugins you can freely add. Can be obtained from GitHub Gist or raw URLs.
373
+
374
+ ### Creating Plugins
375
+
376
+ #### Simple Plugin Example
377
+
378
+ ```ruby
379
+ # ~/.rufio/plugins/hello.rb
380
+ module Rufio
381
+ module Plugins
382
+ class Hello < Plugin
383
+ def name
384
+ 'Hello'
385
+ end
386
+
387
+ def description
388
+ 'Simple greeting plugin'
389
+ end
390
+
391
+ def commands
392
+ {
393
+ hello: method(:say_hello)
394
+ }
395
+ end
396
+
397
+ private
398
+
399
+ def say_hello
400
+ puts "Hello from rufio!"
401
+ end
402
+ end
403
+ end
404
+ end
405
+ ```
406
+
407
+ #### Plugin with External Gem Dependencies
408
+
409
+ ```ruby
410
+ # ~/.rufio/plugins/ai_helper.rb
411
+ module Rufio
412
+ module Plugins
413
+ class AiHelper < Plugin
414
+ requires 'anthropic' # Declare gem dependency
415
+
416
+ def name
417
+ 'AiHelper'
418
+ end
419
+
420
+ def description
421
+ 'AI assistant using Claude API'
422
+ end
423
+
424
+ def commands
425
+ {
426
+ ai: method(:ask_ai)
427
+ }
428
+ end
429
+
430
+ def initialize
431
+ super # Run dependency check
432
+ @client = Anthropic::Client.new(
433
+ api_key: ENV['ANTHROPIC_API_KEY']
434
+ )
435
+ end
436
+
437
+ private
438
+
439
+ def ask_ai(question)
440
+ # AI processing
441
+ end
442
+ end
443
+ end
444
+ end
445
+ ```
446
+
447
+ ### Plugin Management
448
+
449
+ #### Enable/Disable Plugins
450
+
451
+ You can control plugin activation in `~/.rufio/config.yml`:
452
+
453
+ ```yaml
454
+ plugins:
455
+ fileoperations:
456
+ enabled: true
457
+ ai_helper:
458
+ enabled: true
459
+ my_custom:
460
+ enabled: false
461
+ ```
462
+
463
+ #### Default Behavior
464
+
465
+ - No `config.yml` → All plugins enabled
466
+ - Plugin not in config → Enabled by default
467
+ - `enabled: false` explicitly set → Disabled
468
+
469
+ ### Plugin Distribution
470
+
471
+ #### Share via GitHub Gist
472
+
473
+ ```bash
474
+ # Plugin author
475
+ 1. Upload .rb file to GitHub Gist
476
+ 2. Share Raw URL with users
477
+
478
+ # User
479
+ $ mkdir -p ~/.rufio/plugins
480
+ $ curl -o ~/.rufio/plugins/my_plugin.rb [RAW_URL]
481
+ $ rufio
482
+ ✓ my_plugin loaded successfully
483
+ ```
484
+
485
+ #### Share via GitHub Repository
486
+
487
+ ```bash
488
+ # Plugin author
489
+ rufio-plugins/
490
+ ├── plugin1.rb
491
+ └── plugin2.rb
492
+
493
+ # User
494
+ $ curl -o ~/.rufio/plugins/plugin1.rb https://raw.githubusercontent.com/user/rufio-plugins/main/plugin1.rb
495
+ ```
496
+
497
+ ### Plugin Key Features
498
+
499
+ #### Required Methods
500
+
501
+ - `name`: Plugin name (required)
502
+ - `description`: Plugin description (optional, default: "")
503
+ - `version`: Plugin version (optional, default: "1.0.0")
504
+ - `commands`: Command definitions (optional, default: {})
505
+
506
+ #### Dependency Management
507
+
508
+ - `requires 'gem_name'`: Declare gem dependencies
509
+ - If dependencies are missing, displays warning and disables plugin
510
+ - rufio continues to start normally
511
+
512
+ #### Auto-registration
513
+
514
+ - Inheriting from `Plugin` class automatically registers with `PluginManager`
515
+ - No complex registration process needed
516
+
517
+ ## Development
518
+
519
+ ### Requirements
520
+
521
+ - Ruby 2.7.0 or later
522
+ - Required gems: io-console, pastel, tty-cursor, tty-screen
523
+
524
+ ### Running Development Version
525
+
526
+ ```bash
527
+ git clone https://github.com/masisz/rufio
528
+ cd rufio
529
+ bundle install
530
+ ./exe/rufio
531
+ ```
532
+
533
+ ### Running Tests
534
+
535
+ ```bash
536
+ bundle exec rake test
537
+ ```
538
+
539
+ ## Supported Platforms
540
+
541
+ - **macOS**: Native support
542
+ - **Linux**: Native support
543
+ - **Windows**: Basic functionality supported
544
+
545
+ ## Contributing
546
+
547
+ Bug reports and feature requests are welcome at [GitHub Issues](https://github.com/masisz/rufio/issues).
548
+
549
+ Pull requests are also welcome!
550
+
551
+ ### Development Guidelines
552
+
553
+ 1. Follow existing code style and conventions
554
+ 2. Add tests for new features
555
+ 3. Update documentation as needed
556
+ 4. Test on multiple platforms when possible
557
+
558
+ ## License
559
+
560
+ MIT License
561
+
data/Rakefile ADDED
@@ -0,0 +1,156 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rake/testtask'
5
+ require_relative 'lib/rufio/version'
6
+
7
+ # Test task
8
+ Rake::TestTask.new(:test) do |t|
9
+ t.libs << 'test'
10
+ t.libs << 'lib'
11
+ t.test_files = FileList['test/test_*.rb']
12
+ end
13
+
14
+ # Default task
15
+ task default: :test
16
+
17
+ # Gem build and push tasks
18
+ namespace :gem do
19
+ desc 'Build the gem file'
20
+ task :build do
21
+ puts "Building rufio v#{Rufio::VERSION}..."
22
+
23
+ # Clean old gem files
24
+ FileUtils.rm_f(Dir.glob('*.gem'))
25
+
26
+ # Build the gem
27
+ result = system('gem build rufio.gemspec')
28
+
29
+ if result
30
+ gem_file = "rufio-#{Rufio::VERSION}.gem"
31
+ puts "✅ Successfully built #{gem_file}"
32
+ else
33
+ puts "❌ Failed to build gem"
34
+ exit 1
35
+ end
36
+ end
37
+
38
+ desc 'Push the gem to RubyGems.org'
39
+ task :push => :build do
40
+ gem_file = "rufio-#{Rufio::VERSION}.gem"
41
+
42
+ unless File.exist?(gem_file)
43
+ puts "❌ Gem file not found: #{gem_file}"
44
+ exit 1
45
+ end
46
+
47
+ puts "Pushing #{gem_file} to RubyGems.org..."
48
+
49
+ result = system("gem push #{gem_file}")
50
+
51
+ if result
52
+ puts "✅ Successfully pushed #{gem_file} to RubyGems.org"
53
+ puts "🎉 rufio v#{Rufio::VERSION} is now available!"
54
+ puts "📦 Install with: gem install rufio"
55
+ else
56
+ puts "❌ Failed to push gem to RubyGems.org"
57
+ exit 1
58
+ end
59
+ end
60
+
61
+ desc 'Check if current version already exists on RubyGems.org'
62
+ task :check_version do
63
+ puts "Checking if version #{Rufio::VERSION} exists on RubyGems.org..."
64
+
65
+ result = system("gem list rufio --remote --exact --all | grep '#{Rufio::VERSION}'", out: File::NULL, err: File::NULL)
66
+
67
+ if result
68
+ puts "⚠️ Version #{Rufio::VERSION} already exists on RubyGems.org"
69
+ puts "💡 Please update the version in lib/rufio/version.rb before publishing"
70
+ exit 1
71
+ else
72
+ puts "✅ Version #{Rufio::VERSION} is available for publishing"
73
+ end
74
+ end
75
+
76
+ desc 'Clean built gem files'
77
+ task :clean do
78
+ puts "Cleaning gem files..."
79
+ removed_files = Dir.glob('*.gem')
80
+ FileUtils.rm_f(removed_files)
81
+
82
+ if removed_files.any?
83
+ puts "🗑️ Removed: #{removed_files.join(', ')}"
84
+ else
85
+ puts "✨ No gem files to clean"
86
+ end
87
+ end
88
+
89
+ desc 'Build and publish gem (with version check)'
90
+ task :publish => [:check_version, :test, :push] do
91
+ puts "🚀 Gem publishing completed successfully!"
92
+ end
93
+ end
94
+
95
+ # Release tasks
96
+ namespace :release do
97
+ desc 'Tag the current version in git'
98
+ task :tag do
99
+ version = "v#{Rufio::VERSION}"
100
+
101
+ puts "Creating git tag #{version}..."
102
+
103
+ # Check if tag already exists
104
+ if system("git tag -l | grep -q '^#{version}$'", out: File::NULL, err: File::NULL)
105
+ puts "⚠️ Tag #{version} already exists"
106
+ exit 1
107
+ end
108
+
109
+ # Create and push tag
110
+ system("git tag #{version}")
111
+ system("git push origin #{version}")
112
+
113
+ puts "✅ Created and pushed tag #{version}"
114
+ end
115
+
116
+ desc 'Prepare release (tag + gem publish)'
117
+ task :prepare => ['gem:publish', :tag] do
118
+ puts "🎉 Release v#{Rufio::VERSION} completed!"
119
+ puts "📋 Don't forget to:"
120
+ puts " - Update CHANGELOG.md"
121
+ puts " - Create GitHub release from tag"
122
+ puts " - Announce the release"
123
+ end
124
+ end
125
+
126
+ # Utility tasks
127
+ desc 'Display current version'
128
+ task :version do
129
+ puts "rufio v#{Rufio::VERSION}"
130
+ end
131
+
132
+ desc 'Run simple test for basic functionality'
133
+ task :simple_test do
134
+ puts "Running simple functionality test..."
135
+ result = system('ruby test/simple_test.rb')
136
+
137
+ if result
138
+ puts "✅ Simple test passed"
139
+ else
140
+ puts "❌ Simple test failed"
141
+ exit 1
142
+ end
143
+ end
144
+
145
+ desc 'Run bookmark tests'
146
+ task :test_bookmark do
147
+ puts "Running bookmark functionality test..."
148
+ result = system('ruby test/test_bookmark_simple.rb')
149
+
150
+ if result
151
+ puts "✅ Bookmark tests passed"
152
+ else
153
+ puts "❌ Bookmark tests failed"
154
+ exit 1
155
+ end
156
+ end