beniya 0.2.0 → 0.4.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +99 -0
- data/CHANGELOG_v0.4.0.md +146 -0
- data/README.md +62 -35
- data/README_EN.md +63 -35
- data/lib/beniya/application.rb +1 -0
- data/lib/beniya/file_opener.rb +3 -3
- data/lib/beniya/file_preview.rb +23 -3
- data/lib/beniya/keybind_handler.rb +502 -65
- data/lib/beniya/terminal_ui.rb +55 -9
- data/lib/beniya/version.rb +1 -1
- data/publish_gem.zsh +131 -0
- data/test_delete/test1.txt +1 -0
- data/test_delete/test2.txt +1 -0
- metadata +7 -2
data/lib/beniya/terminal_ui.rb
CHANGED
@@ -75,15 +75,16 @@ module Beniya
|
|
75
75
|
# move cursor to top of screen (don't clear)
|
76
76
|
print "\e[H"
|
77
77
|
|
78
|
-
# header
|
78
|
+
# header (2 lines)
|
79
79
|
draw_header
|
80
|
+
draw_base_directory_info
|
80
81
|
|
81
82
|
# main content (left: directory list, right: preview)
|
82
83
|
entries = get_display_entries
|
83
84
|
selected_entry = entries[@keybind_handler.current_index]
|
84
85
|
|
85
|
-
# calculate height with footer margin
|
86
|
-
content_height = @screen_height -
|
86
|
+
# calculate height with header (2 lines) and footer margin
|
87
|
+
content_height = @screen_height - 4 # ヘッダー(2行)とフッター分を除く
|
87
88
|
left_width = @screen_width / 2
|
88
89
|
right_width = @screen_width - left_width
|
89
90
|
|
@@ -125,13 +126,50 @@ module Beniya
|
|
125
126
|
puts "\e[7m#{header.ljust(@screen_width)}\e[0m" # reverse display
|
126
127
|
end
|
127
128
|
|
129
|
+
def draw_base_directory_info
|
130
|
+
# 強制的に表示 - デバッグ用に安全チェックを緩和
|
131
|
+
if @keybind_handler && @keybind_handler.instance_variable_get(:@base_directory)
|
132
|
+
base_dir = @keybind_handler.instance_variable_get(:@base_directory)
|
133
|
+
selected_count = @keybind_handler.selected_items.length
|
134
|
+
base_info = "📋 Base Directory: #{base_dir}"
|
135
|
+
|
136
|
+
# 選択されたアイテム数を表示
|
137
|
+
if selected_count > 0
|
138
|
+
base_info += " | Selected: #{selected_count} item(s)"
|
139
|
+
end
|
140
|
+
else
|
141
|
+
# keybind_handlerがない場合、またはbase_directoryが設定されていない場合
|
142
|
+
base_info = "📋 Base Directory: #{Dir.pwd}"
|
143
|
+
end
|
144
|
+
|
145
|
+
# 長すぎる場合は省略
|
146
|
+
if base_info.length > @screen_width - 2
|
147
|
+
if base_info.include?(" | Selected:")
|
148
|
+
selected_part = base_info.split(" | Selected:").last
|
149
|
+
available_length = @screen_width - 20 - " | Selected:#{selected_part}".length
|
150
|
+
else
|
151
|
+
available_length = @screen_width - 20
|
152
|
+
end
|
153
|
+
|
154
|
+
if available_length > 10
|
155
|
+
# パスの最後の部分を表示
|
156
|
+
dir_part = base_info.split(": ").last.split(" | ").first
|
157
|
+
short_base_dir = "...#{dir_part[-available_length..-1]}"
|
158
|
+
base_info = base_info.gsub(dir_part, short_base_dir)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
# 2行目に確実に表示
|
163
|
+
print "\e[2;1H\e[44m\e[37m#{base_info.ljust(@screen_width)}\e[0m"
|
164
|
+
end
|
165
|
+
|
128
166
|
def draw_directory_list(entries, width, height)
|
129
167
|
start_index = [@keybind_handler.current_index - height / 2, 0].max
|
130
168
|
[start_index + height - 1, entries.length - 1].min
|
131
169
|
|
132
170
|
(0...height).each do |i|
|
133
171
|
entry_index = start_index + i
|
134
|
-
line_num = i +
|
172
|
+
line_num = i + 3 # skip header (2 lines)
|
135
173
|
|
136
174
|
print "\e[#{line_num};1H" # set cursor position
|
137
175
|
|
@@ -155,16 +193,19 @@ module Beniya
|
|
155
193
|
# 左ペイン専用の安全な幅を計算(右ペインにはみ出さないよう)
|
156
194
|
safe_width = [width - 1, @screen_width / 2 - 1].min
|
157
195
|
|
196
|
+
# 選択マークの追加
|
197
|
+
selection_mark = @keybind_handler.is_selected?(entry[:name]) ? "✓ " : " "
|
198
|
+
|
158
199
|
# ファイル名(必要に応じて切り詰め)
|
159
200
|
name = entry[:name]
|
160
|
-
max_name_length = safe_width -
|
201
|
+
max_name_length = safe_width - 12 # アイコン、選択マーク、サイズ情報分を除く
|
161
202
|
name = name[0...max_name_length - 3] + '...' if max_name_length > 0 && name.length > max_name_length
|
162
203
|
|
163
204
|
# サイズ情報
|
164
205
|
size_info = format_size(entry[:size])
|
165
206
|
|
166
207
|
# 行の内容を構築(安全な幅内で)
|
167
|
-
content_without_size = "#{icon} #{name}"
|
208
|
+
content_without_size = "#{selection_mark}#{icon} #{name}"
|
168
209
|
available_for_content = safe_width - size_info.length
|
169
210
|
|
170
211
|
line_content = if available_for_content > 0
|
@@ -180,7 +221,12 @@ module Beniya
|
|
180
221
|
selected_color = ColorHelper.color_to_selected_ansi(ConfigLoader.colors[:selected])
|
181
222
|
print "#{selected_color}#{line_content}#{ColorHelper.reset}"
|
182
223
|
else
|
183
|
-
|
224
|
+
# 選択されたアイテムは異なる色で表示
|
225
|
+
if @keybind_handler.is_selected?(entry[:name])
|
226
|
+
print "\e[42m\e[30m#{line_content}\e[0m" # 緑背景、黒文字
|
227
|
+
else
|
228
|
+
print "#{color}#{line_content}#{ColorHelper.reset}"
|
229
|
+
end
|
184
230
|
end
|
185
231
|
end
|
186
232
|
|
@@ -226,7 +272,7 @@ module Beniya
|
|
226
272
|
|
227
273
|
def draw_file_preview(selected_entry, width, height, left_offset)
|
228
274
|
(0...height).each do |i|
|
229
|
-
line_num = i + 2
|
275
|
+
line_num = i + 3 # skip header (2 lines)
|
230
276
|
# カーソル位置を左パネルの右端に設定
|
231
277
|
cursor_position = left_offset + 1
|
232
278
|
|
@@ -427,7 +473,7 @@ module Beniya
|
|
427
473
|
input = STDIN.getch
|
428
474
|
rescue Errno::ENOTTY, Errno::ENODEV
|
429
475
|
# ターミナルでない環境(IDE等)では標準入力を使用
|
430
|
-
print "\
|
476
|
+
print "\nOperation: "
|
431
477
|
input = STDIN.gets
|
432
478
|
return 'q' if input.nil?
|
433
479
|
input = input.chomp.downcase
|
data/lib/beniya/version.rb
CHANGED
data/publish_gem.zsh
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
#!/bin/zsh
|
2
|
+
|
3
|
+
# Gem Build & Push Script
|
4
|
+
# Usage: ./publish_gem.zsh [version]
|
5
|
+
|
6
|
+
set -e # Exit on any error
|
7
|
+
|
8
|
+
# Colors for output
|
9
|
+
RED='\033[0;31m'
|
10
|
+
GREEN='\033[0;32m'
|
11
|
+
YELLOW='\033[1;33m'
|
12
|
+
BLUE='\033[0;34m'
|
13
|
+
NC='\033[0m' # No Color
|
14
|
+
|
15
|
+
# Function to print colored output
|
16
|
+
print_status() {
|
17
|
+
echo -e "${BLUE}[INFO]${NC} $1"
|
18
|
+
}
|
19
|
+
|
20
|
+
print_success() {
|
21
|
+
echo -e "${GREEN}[SUCCESS]${NC} $1"
|
22
|
+
}
|
23
|
+
|
24
|
+
print_warning() {
|
25
|
+
echo -e "${YELLOW}[WARNING]${NC} $1"
|
26
|
+
}
|
27
|
+
|
28
|
+
print_error() {
|
29
|
+
echo -e "${RED}[ERROR]${NC} $1"
|
30
|
+
}
|
31
|
+
|
32
|
+
# Check if we're in the correct directory
|
33
|
+
if [[ ! -f "beniya.gemspec" ]]; then
|
34
|
+
print_error "beniya.gemspec not found. Please run this script from the project root directory."
|
35
|
+
exit 1
|
36
|
+
fi
|
37
|
+
|
38
|
+
# Get current version from version.rb
|
39
|
+
CURRENT_VERSION=$(ruby -r ./lib/beniya/version -e "puts Beniya::VERSION")
|
40
|
+
print_status "Current version: $CURRENT_VERSION"
|
41
|
+
|
42
|
+
# Use provided version or current version
|
43
|
+
VERSION=${1:-$CURRENT_VERSION}
|
44
|
+
print_status "Publishing version: $VERSION"
|
45
|
+
|
46
|
+
# Confirm before proceeding
|
47
|
+
echo
|
48
|
+
read "REPLY?Do you want to proceed with publishing version $VERSION? (y/N): "
|
49
|
+
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
50
|
+
print_warning "Aborted by user."
|
51
|
+
exit 0
|
52
|
+
fi
|
53
|
+
|
54
|
+
echo
|
55
|
+
print_status "Starting gem publication process..."
|
56
|
+
|
57
|
+
# Step 1: Run tests
|
58
|
+
print_status "Running tests..."
|
59
|
+
if ! bundle exec rake test; then
|
60
|
+
print_error "Tests failed. Aborting publication."
|
61
|
+
exit 1
|
62
|
+
fi
|
63
|
+
print_success "All tests passed!"
|
64
|
+
|
65
|
+
# Step 2: Clean up old gem files
|
66
|
+
print_status "Cleaning up old gem files..."
|
67
|
+
rm -f *.gem
|
68
|
+
print_success "Cleanup completed."
|
69
|
+
|
70
|
+
# Step 3: Build gem
|
71
|
+
print_status "Building gem..."
|
72
|
+
if ! bundle exec gem build beniya.gemspec; then
|
73
|
+
print_error "Gem build failed."
|
74
|
+
exit 1
|
75
|
+
fi
|
76
|
+
|
77
|
+
# Find the built gem file
|
78
|
+
GEM_FILE=$(ls beniya-*.gem | head -n 1)
|
79
|
+
if [[ -z "$GEM_FILE" ]]; then
|
80
|
+
print_error "No gem file found after build."
|
81
|
+
exit 1
|
82
|
+
fi
|
83
|
+
|
84
|
+
print_success "Gem built successfully: $GEM_FILE"
|
85
|
+
|
86
|
+
# Step 4: Verify gem contents (optional)
|
87
|
+
print_status "Gem contents:"
|
88
|
+
gem contents $GEM_FILE | head -10
|
89
|
+
echo "..."
|
90
|
+
|
91
|
+
# Step 5: Final confirmation
|
92
|
+
echo
|
93
|
+
read "REPLY?Push $GEM_FILE to RubyGems? (y/N): "
|
94
|
+
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
95
|
+
print_warning "Gem build completed but not published."
|
96
|
+
print_status "You can manually push later with: gem push $GEM_FILE"
|
97
|
+
exit 0
|
98
|
+
fi
|
99
|
+
|
100
|
+
# Step 6: Push to RubyGems
|
101
|
+
print_status "Pushing gem to RubyGems..."
|
102
|
+
if ! gem push $GEM_FILE; then
|
103
|
+
print_error "Gem push failed."
|
104
|
+
exit 1
|
105
|
+
fi
|
106
|
+
|
107
|
+
print_success "Gem published successfully!"
|
108
|
+
|
109
|
+
# Step 7: Create git tag if version was provided
|
110
|
+
if [[ -n "$1" ]]; then
|
111
|
+
print_status "Creating git tag v$VERSION..."
|
112
|
+
if git tag "v$VERSION" 2>/dev/null; then
|
113
|
+
print_success "Tag v$VERSION created."
|
114
|
+
read "REPLY?Push tag to remote? (y/N): "
|
115
|
+
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
116
|
+
git push origin "v$VERSION"
|
117
|
+
print_success "Tag pushed to remote."
|
118
|
+
fi
|
119
|
+
else
|
120
|
+
print_warning "Tag v$VERSION already exists or failed to create."
|
121
|
+
fi
|
122
|
+
fi
|
123
|
+
|
124
|
+
# Step 8: Cleanup
|
125
|
+
print_status "Cleaning up gem file..."
|
126
|
+
rm -f $GEM_FILE
|
127
|
+
|
128
|
+
echo
|
129
|
+
print_success "Publication completed!"
|
130
|
+
print_status "Gem should be available at: https://rubygems.org/gems/beniya"
|
131
|
+
print_status "Install with: gem install beniya"
|
@@ -0,0 +1 @@
|
|
1
|
+
test content 1
|
@@ -0,0 +1 @@
|
|
1
|
+
test content 2
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beniya
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- masisz
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-09-13 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: io-console
|
@@ -116,6 +116,8 @@ executables:
|
|
116
116
|
extensions: []
|
117
117
|
extra_rdoc_files: []
|
118
118
|
files:
|
119
|
+
- CHANGELOG.md
|
120
|
+
- CHANGELOG_v0.4.0.md
|
119
121
|
- README.md
|
120
122
|
- README_EN.md
|
121
123
|
- beniya.gemspec
|
@@ -133,6 +135,9 @@ files:
|
|
133
135
|
- lib/beniya/keybind_handler.rb
|
134
136
|
- lib/beniya/terminal_ui.rb
|
135
137
|
- lib/beniya/version.rb
|
138
|
+
- publish_gem.zsh
|
139
|
+
- test_delete/test1.txt
|
140
|
+
- test_delete/test2.txt
|
136
141
|
homepage: https://github.com/masisz/beniya
|
137
142
|
licenses:
|
138
143
|
- MIT
|