mk_semi_lattice 0.4.5 → 0.4.7

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: 0c82ca311d171778531ddf25c26e0d7b3228e358a5c77ee3308100ae788d8787
4
- data.tar.gz: 33590bb27ad318428025207187e6f3126d24fa6546fe886cf9d9393d8323d4f4
3
+ metadata.gz: 73c951dc8aa9c65f917a599ae454a14f3e40460c0e7b8f0f28f094715a1eb3d5
4
+ data.tar.gz: 8438bbdb21808ff6d4ac7dbaea8c8871ce831fa4554fa4fea6f2ec5aa0f79592
5
5
  SHA512:
6
- metadata.gz: 58608e9f2cba2911dc8787b87351a709e332a502f2160422dd94d686633a54d2c63cacfbc41a288c1df65acb5c316d16d4c249876df7f389aa3c6d8e5d5e2020
7
- data.tar.gz: ae3ccad4bf58d0f28ef50c080f702826bf3c9f03a763c079a8fa2fe4aa46c0c2395202b8aec5d35cc65a47df8eaf71a93f7fb353ef60c414ed6fba47d4ab6fa9
6
+ metadata.gz: e06dfb0d5f70c855055acb2499847a4fedb4344b2c1e991b5acb3c2f07b12fb0805c0612eb0b7b887dd7f57584718d449d8e8d1d196dbdde95f2f847601d50e4
7
+ data.tar.gz: fa615d8465e981c22930e99f73beadcaaf8864be2bf9e1fe011cad8ac1846053abd732aff49fdb3611a7f1614e8742c6338c08228c083377291b93fcdb92b898
@@ -84,9 +84,9 @@ module AbbrevCheck
84
84
  end
85
85
 
86
86
  class InstallCheckSample < VocaBuil::InstallCheckSample
87
- def initialize(tgz_file = 'abbrev_sample.tgz')
88
- # abbrev_checker ディレクトリを基準にパスを解決
89
- @tgz_file = File.join(File.dirname(__FILE__), tgz_file)
87
+ def initialize(tgz_file = nil)
88
+ tgz_file ||= File.join(File.dirname(__FILE__), 'abbrev_sample.tgz')
89
+ super(tgz_file)
90
90
  end
91
91
  end
92
92
  end
Binary file
@@ -18,8 +18,12 @@
18
18
  ssh=secure shell=安全なremote shell接続:
19
19
  #path=path=パス,小径:
20
20
  full_path=full path=フルパス:
21
- abs_oath=abosolute path=絶対(absolute)パス:
21
+ abs_path=abosolute path=絶対(absolute)パス:
22
22
  rel_path=relative path=相対パス:
23
+ # etc:
24
+ fish=friendly interactive shell:
25
+ apt=advanced package tool:
26
+ sudo=super user do:
23
27
  #c-keys=controll-keys=fishコマンド編集keyバインド:
24
28
  c-a/ahead=行頭へ移動:
25
29
  c-e/end=行末へ移動:
@@ -0,0 +1,13 @@
1
+ ---
2
+ #c-keys=controll-keys=fishコマンド編集keyバインド:
3
+ c-a/ahead=行頭へ移動:
4
+ c-e/end=行末へ移動:
5
+ c-p/previous=前行へ移動:
6
+ c-n/next=次行へ移動:
7
+ c-f/forward=一字進む:
8
+ c-b/backward=一字戻る:
9
+ c-d/delete=一字削除:
10
+ c-k/kill line=一行削除:
11
+
12
+
13
+
@@ -12,5 +12,6 @@ IP=internet protocol:
12
12
  OS=operating system:
13
13
  pdf=portable document format:
14
14
  tar=tape archive:
15
+ wsl=windows subsystem fro linux:
15
16
 
16
17
 
@@ -0,0 +1,20 @@
1
+ ---
2
+ #key name:
3
+ ~=tilde:
4
+ `=back quote:
5
+ '\#'=sharp:
6
+ \=back slash:
7
+ /=slash:
8
+ $=dollar:
9
+ %=percent:
10
+ ^=hat:
11
+ &=ampersand:
12
+ *=asterisk:
13
+ -=hyphen:
14
+ ()=round bracket=丸括弧:
15
+ []=square bracket=鉤括弧:
16
+ {}=curly bracket=波括弧:
17
+ ':'=colon:
18
+ ;=semicolon:
19
+ '=single quote:
20
+ "=double quote:
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MkSemiLattice
4
- VERSION = "0.4.5"
4
+ VERSION = "0.4.7"
5
5
  end
Binary file
@@ -4,36 +4,79 @@ require 'fileutils'
4
4
  require 'optparse'
5
5
  require 'date'
6
6
 
7
+
7
8
  module StackOperations
8
9
  class OptionParserWrapper
9
10
  attr_reader :options, :args
10
11
 
11
12
  def initialize(argv)
12
- @options = { flatten: false, nest: false, dryrun: true, reverse: false }
13
+ @options = { flatten: false, nest: false, dryrun: true, reverse: false, empty: false, no_dir_move: false }
13
14
  @args = []
14
- OptionParser.new do |opts|
15
- opts.banner = "Usage: hc stack [options]"
16
- opts.on('-o ORDINAL', '--ordinal=ORDINAL', 'Add ordinal number') { |ord| @options[:ordinal] = ord }
17
- opts.on('-d', '--dryrun', 'Dry run (do not move or create anything)') { @options[:dryrun] = true }
18
- opts.on('-D', 'Do not move directories (only move files)') { @options[:no_dir_move] = true }
19
- opts.on('-A', 'Do not move hidden files and directories') { @options[:no_hidden] = true }
20
- opts.on('-c', '--create', 'Create (empty) stack only') { @options[:empty] = true }
21
- opts.on('-e', '--exec', 'Execute stack making') { @options[:dryrun] = false }
22
- opts.on('-f', '--flatten', 'Flatten stacks') { @options[:flatten] = true }
23
- opts.on('-n', '--nest', 'Nest stacks by _yymmdd') { @options[:nest] = true }
24
- opts.on('-r', '--reverse', 'Reverse _yymmdd order for nest') { @options[:reverse] = true }
25
- end.parse!(argv)
15
+ begin
16
+ OptionParser.new do |opts|
17
+ opts.banner = "Usage: hc stack [options]"
18
+ opts.on('-o ORDINAL', '--ordinal=ORDINAL', 'Add ordinal number') { |ord| @options[:ordinal] = ord }
19
+ opts.on('-d', '--dryrun', 'Dry run (do not move or create anything)') { @options[:dryrun] = true }
20
+ opts.on('-D', 'Do not move directories (only move files)') { @options[:no_dir_move] = true }
21
+ opts.on('-A', 'Do not move hidden files and directories') { @options[:no_hidden] = true }
22
+ opts.on('-c', '--create', 'Create (empty) stack only') { @options[:empty] = true }
23
+ opts.on('-e', '--exec', 'Execute stack making') { @options[:dryrun] = false }
24
+ opts.on('-f', '--flatten', 'Flatten stacks') { @options[:flatten] = true }
25
+ opts.on('-n', '--nest', 'Nest stacks by _yymmdd') { @options[:nest] = true }
26
+ opts.on('-r', '--reverse', 'Reverse _yymmdd order for nest') { @options[:reverse] = true }
27
+ end.parse!(argv)
28
+ rescue OptionParser::InvalidOption => e
29
+ puts "Error: #{e.message}"
30
+ exit 1
31
+ end
26
32
  @args = argv
27
33
  end
28
34
  end
29
35
 
30
- class MkStack
36
+ class MkTree
37
+ def mk_dir_tree(dir, current_level = 1, max_level = 2, dirs_only: false)
38
+ tree = {}
39
+ return tree unless File.directory?(dir)
40
+
41
+ Dir.children(dir).sort.each do |entry|
42
+ path = File.join(dir, entry)
43
+ is_dir = File.directory?(path)
44
+ next if dirs_only && !is_dir
45
+
46
+ if is_dir
47
+ tree[entry] = current_level < max_level ? mk_dir_tree(path, current_level + 1, max_level, dirs_only: dirs_only) : {}
48
+ else
49
+ tree[entry] = nil
50
+ end
51
+ end
52
+ tree
53
+ end
54
+
55
+ def print_tree(tree, is_last_arr = [])
56
+ entries = tree.keys
57
+ entries.each_with_index do |entry, idx|
58
+ is_last = idx == entries.size - 1
59
+ prefix = ""
60
+ is_last_arr.each { |last| prefix += last ? " " : "│ " }
61
+ prefix += is_last ? "└── " : "├── "
62
+
63
+ is_dir = tree[entry].is_a?(Hash)
64
+ name = is_dir ? "#{entry}/" : entry
65
+ puts "#{prefix}#{name}"
66
+
67
+ if is_dir
68
+ print_tree(tree[entry], is_last_arr + [is_last])
69
+ end
70
+ end
71
+ end
72
+ end
73
+
74
+ class MkStack < MkTree
31
75
  def initialize(options, args)
32
76
  @options = options
33
77
  @root_name = args[0]
34
78
  @date = args[1] || Date.today.strftime('%y%m%d')
35
79
  end
36
-
37
80
  def ordinal(n)
38
81
  abs_n = n.to_i.abs
39
82
  if (11..13).include?(abs_n % 100)
@@ -47,7 +90,6 @@ module StackOperations
47
90
  end
48
91
  end
49
92
  end
50
-
51
93
  def pull_root_name(dir_name)
52
94
  if dir_name =~ /^_stack_(.+)_(\d{6})$/
53
95
  $1
@@ -55,7 +97,6 @@ module StackOperations
55
97
  dir_name
56
98
  end
57
99
  end
58
-
59
100
  def next_available_dir(root_name, date)
60
101
  n = 1
61
102
  if root_name =~ /^(\d+)(st|nd|rd|th)$/
@@ -82,218 +123,213 @@ module StackOperations
82
123
  dir = "_stack_#{base_name}_#{date}"
83
124
  [base_name, dir]
84
125
  end
85
-
86
126
  def find_max_ordinal
87
127
  candidates = Dir.glob("_stack_*_*").select { |d| d =~ /^_stack_(\d+)(st|nd|rd|th)_(\d{6})$/ }
88
- ordinals = candidates.map do |d|
89
- if d =~ /^_stack_(\d+)(st|nd|rd|th)_(\d{6})$/
90
- $1.to_i
91
- else
92
- nil
93
- end
94
- end.compact
128
+ ordinals = candidates.map { |d| d[/^_stack_(\d+)/, 1].to_i }.compact
95
129
  ordinals.any? ? ordinals.max : 0
96
130
  end
97
-
98
131
  def ensure_root_name
99
- if @root_name.nil? || @root_name.strip.empty?
132
+ if @root_name.nil? || @root_name.empty?
100
133
  max_num = find_max_ordinal
101
- @root_name = max_num > 0 ? ordinal(max_num) : "1st"
134
+ @root_name = max_num > 0 ? "#{max_num}th" : "1st"
102
135
  end
103
136
  end
137
+ def run
138
+ ensure_root_name
139
+ @root_name, dir = next_available_dir(@root_name, @date)
104
140
 
105
- def create_dir(dir)
106
- if @options[:dryrun]
107
- puts "[Dry Run] mkdir #{dir}"
108
- else
109
- Dir.mkdir(dir) unless Dir.exist?(dir)
110
- puts "Created directory: #{dir}"
141
+ # 1. 現在のツリーを取得
142
+ current_tree = mk_dir_tree(".", 1, 1)
143
+
144
+ # 2. 移動対象の決定
145
+ exclude = ['.', '..', dir, '.vscode', 'project.code-workspace', '.git']
146
+ all_entries = Dir.glob('*', File::FNM_DOTMATCH) - exclude
147
+ moved_entries = []
148
+
149
+ unless @options[:empty]
150
+ all_entries.each do |entry|
151
+ next if @options[:no_dir_move] && File.directory?(entry)
152
+ moved_entries << entry
153
+ end
111
154
  end
112
- end
113
-
114
- def move_entries(dir)
115
- exclude = ['.', '..', dir, '.vscode', 'project.code-workspace']
116
- entries = Dir.glob('*', File::FNM_DOTMATCH) - exclude
117
155
 
118
- if @options[:no_hidden]
119
- entries.reject! { |entry| entry.start_with?('.') }
156
+ # 3. 仮想ツリーの構築 (Hashの操作としてmvをシミュレート)
157
+ virtual_tree = {}
158
+ current_tree.each do |k, v|
159
+ virtual_tree[k] = v unless moved_entries.include?(k)
120
160
  end
121
-
122
- if @options[:empty]
123
- entries.select! { |entry| File.directory?(entry) && entry.start_with?('_stack') }
161
+
162
+ moved_tree = {}
163
+ moved_entries.each do |entry|
164
+ moved_tree[entry] = current_tree[entry]
124
165
  end
166
+ virtual_tree[dir] = moved_tree
167
+ virtual_tree = virtual_tree.sort.to_h
125
168
 
126
- entries.each do |entry|
127
- next if @options[:no_dir_move] && File.directory?(entry)
128
- if @options[:dryrun]
129
- puts "[Dry Run] mv #{entry} (to) #{dir}"
130
- else
131
- FileUtils.mv(entry, dir, force: true)
169
+ # 4. Before表示
170
+ puts "Before stack:"
171
+ puts "."
172
+ print_tree(current_tree)
173
+
174
+ # 5. 操作の表示 (Dry Run or Execute)
175
+ puts "\nOperations:"
176
+ prefix = @options[:dryrun] ? "[Dry Run] " : ""
177
+ puts "#{prefix}mkdir #{dir}"
178
+ if moved_entries.empty?
179
+ puts "#{prefix}mv nothing (to) #{dir}"
180
+ else
181
+ moved_entries.each do |entry|
182
+ puts "#{prefix}mv #{entry} (to) #{dir}"
132
183
  end
133
184
  end
134
185
 
135
- if @options[:dryrun]
136
- puts "[Dry Run] mv #{entries.empty? ? 'nothing' : entries.join(', ')} (to) #{dir}"
137
- else
138
- puts "Moved #{entries.empty? ? 'nothing' : entries.join(', ')} to #{dir}"
139
- end
140
- end
186
+ # 6. After表示
187
+ puts "\nAfter stack:"
188
+ puts "."
189
+ print_tree(virtual_tree)
141
190
 
142
- def run
143
- ensure_root_name
144
- @root_name, dir = next_available_dir(@root_name, @date)
145
- create_dir(dir)
146
- move_entries(dir)
191
+ # 7. 実行 (-e 指定時)
192
+ unless @options[:dryrun]
193
+ Dir.mkdir(dir) unless Dir.exist?(dir)
194
+ moved_entries.each do |entry|
195
+ FileUtils.mv(entry, dir)
196
+ end
197
+ puts "\nExecution completed."
198
+ end
147
199
  end
148
200
  end
149
201
 
150
- class MkFlatten
202
+ class MkFlatten < MkTree
151
203
  def initialize(options, args)
152
204
  @options = options
153
205
  @target_dir = args[0] || "."
154
206
  @target_dir = @target_dir.chomp("/")
155
207
  end
156
-
157
- # 指定ディレクトリ以下のtree構造を表示(ディレクトリのみ)
158
- def print_tree(dir, prefix = "", is_last_arr = [])
159
- puts "#{prefix}#{File.basename(dir)}"
160
- if File.directory?(dir)
161
- entries = Dir.children(dir).sort.select { |entry| File.directory?(File.join(dir, entry)) }
162
- entries.each_with_index do |entry, idx|
163
- path = File.join(dir, entry)
164
- is_last = idx == entries.size - 1
165
- # インデント生成
166
- new_prefix = ""
167
- is_last_arr.each { |last| new_prefix += last ? " " : "│ " }
168
- new_prefix += is_last ? "└── " : "├── "
169
- print_tree(path, new_prefix, is_last_arr + [is_last])
170
- end
171
- end
172
- end
173
-
174
- # flatten後のtree構造を表示(@target_dir直下に全ての_stack_*_*ディレクトリを並べる)
175
- def print_flattened_tree
176
- stacks = []
208
+ def build_virtual_tree
177
209
  search_dirs = Dir.glob(File.join(@target_dir, "**/_stack_*_*")).select { |d| File.directory?(d) }
178
- # ルート直下の_stack_*_*も含める
179
210
  root_stacks = Dir.glob(File.join(@target_dir, "_stack_*_*")).select { |d| File.directory?(d) }
180
211
  all_stacks = (root_stacks + search_dirs).uniq
181
- all_stacks.map! { |d| File.basename(d) }
182
- all_stacks.each do |d|
183
- puts "└── #{d}"
212
+
213
+ tree = {}
214
+ all_stacks.map { |d| File.basename(d) }.sort.each do |d|
215
+ tree[d] = {}
184
216
  end
217
+ tree
185
218
  end
186
-
187
- # flattenで移動するディレクトリのmvコマンドをdryrun表示
188
- def print_flatten_moves
189
- flatten_moves.each do |src, dest|
190
- puts "[Dry Run] mv '#{src}' '#{dest}'"
219
+ def flatten_moves
220
+ search_dirs = Dir.glob(File.join(@target_dir, "**/_stack_*_*")).select { |d| File.directory?(d) }
221
+ root_stacks = Dir.glob(File.join(@target_dir, "_stack_*_*")).select { |d| File.directory?(d) }
222
+ stacks = (root_stacks + search_dirs).uniq
223
+
224
+ # 深い階層から順に移動させるため、パスの深さで降順ソート
225
+ stacks.sort_by! { |d| -d.count('/') }
226
+
227
+ moves = []
228
+ stacks.each do |src|
229
+ dest = File.join(@target_dir, File.basename(src))
230
+ moves << [src, dest] unless src == dest
191
231
  end
232
+ moves
192
233
  end
234
+ def run
235
+ puts "Before flatten:"
236
+ puts @target_dir == "." ? "." : "#{File.basename(@target_dir)}/"
237
+ print_tree(mk_dir_tree(@target_dir, 1, 999, dirs_only: true))
193
238
 
194
- def flatten_moves
195
- stacks = Dir.glob(File.join(@target_dir, "**/_stack_*_*")).select { |d| File.directory?(d) }
196
- stacks.sort_by! { |d| -d.count(File::SEPARATOR) }
197
- stacks.map { |src| [src, File.join(".", File.basename(src))] }
198
- end
239
+ moves = flatten_moves
199
240
 
200
- def execute_flatten_moves
201
- flatten_moves.each do |src, dest|
202
- # mv元とmv先が同じ場合はスキップ
203
- if File.expand_path(src) == File.expand_path(dest)
204
- puts "[Skip] mv '#{src}' '#{dest}' (same path)"
205
- next
241
+ puts "\nOperations:"
242
+ prefix = @options[:dryrun] ? "[Dry Run] " : ""
243
+ if moves.empty?
244
+ puts "#{prefix}nothing to flatten"
245
+ else
246
+ moves.each do |src, dest|
247
+ puts "#{prefix}mv #{src} (to) #{dest}"
206
248
  end
207
- puts "mv '#{src}' '#{dest}'"
208
- FileUtils.mv(src, dest)
209
249
  end
210
- end
211
250
 
212
- def run
213
- puts "Before flatten:"
214
- puts "."
215
- print_tree(@target_dir, "", [])
216
251
  puts "\nAfter flatten:"
217
252
  puts "."
218
- print_flattened_tree
219
- puts "\nFlatten moves:"
220
- if @options[:dryrun]
221
- print_flatten_moves
222
- else
223
- execute_flatten_moves
253
+ print_tree(build_virtual_tree)
254
+
255
+ unless @options[:dryrun]
256
+ moves.each do |src, dest|
257
+ FileUtils.mv(src, dest)
258
+ end
259
+ puts "\nExecution completed."
224
260
  end
225
261
  end
226
262
  end
227
263
 
228
- class MkNest
264
+ class MkNest < MkTree
229
265
  def initialize(options, args)
230
266
  @options = options
231
267
  @target_dir = args[0] || "."
232
268
  end
233
-
234
- # yymmdd順に並べ替え(reverseオプションで順序切替)
235
269
  def sorted_stacks
236
- stacks = Dir.glob(File.join(@target_dir, "_stack_*_*"))
237
- .select { |d| File.directory?(d) && d =~ /_stack_.+_\d{6}$/ }
238
- .sort_by { |d| d[/_stack_.+_(\d{6})$/, 1].to_i }
239
- #.select { |d| File.directory?(d) }
240
- #.sort_by { |d| d[/^_stack_(\d+)(st|nd|rd|th)_/, 1].to_i }
270
+ stacks = Dir.glob(File.join(@target_dir, "_stack_*_*")).select { |d| File.directory?(d) }
271
+ stacks = stacks.sort_by { |d| d[/_stack_(\d+)(st|nd|rd|th)_/, 1].to_i }
272
+ # デフォルトはFILO(新しいものがルート: 7th, 6th, 5th...)
273
+ # -r オプションでFIFO(古いものがルート: 1st, 2nd, 3rd...)
241
274
  @options[:reverse] ? stacks : stacks.reverse
242
275
  end
243
-
244
- # ディレクトリのみtree表示
245
- def print_tree(dir, prefix = "", is_last_arr = [])
246
- puts "#{prefix}#{File.basename(dir)}"
247
- if File.directory?(dir)
248
- entries = Dir.children(dir).sort.select { |entry| File.directory?(File.join(dir, entry)) }
249
- entries.each_with_index do |entry, idx|
250
- path = File.join(dir, entry)
251
- is_last = idx == entries.size - 1
252
- # インデント生成
253
- new_prefix = ""
254
- is_last_arr.each { |last| new_prefix += last ? " " : "│ " }
255
- new_prefix += is_last ? "└── " : "├── "
256
- print_tree(path, new_prefix, is_last_arr + [is_last])
257
- end
258
- end
259
- end
260
-
261
- # nest後のtree構造を表示
262
- def print_nested_tree
263
- p stacks = sorted_stacks
264
- return if stacks.empty?
265
- puts "."
266
- stacks.each_with_index do |dir, idx|
267
- indent = " " * idx + "└── "
268
- puts "#{indent}#{File.basename(dir)}"
276
+ def build_virtual_tree
277
+ stacks = sorted_stacks
278
+ tree = {}
279
+ return tree if stacks.empty?
280
+
281
+ current = tree
282
+ stacks.each do |dir|
283
+ name = File.basename(dir)
284
+ current[name] = {}
285
+ current = current[name]
269
286
  end
287
+ tree
270
288
  end
271
-
272
- # nestのmvコマンド生成&実行/表示
273
289
  def nest_moves
274
290
  stacks = sorted_stacks
275
- # 子から親へ(パスが変わらないように逆順でmv)
276
- moves = stacks.each_cons(2).to_a.reverse
277
- moves.each do |parent, child|
291
+ moves = []
292
+ return moves if stacks.size < 2
293
+
294
+ # ENOENTエラーを防ぐため、一番奥(深い階層)に入るものから順に親へ移動する
295
+ # 例: stacks = [7th, 6th, 5th] の場合
296
+ # 1. 5th を 6th へ移動
297
+ # 2. 6th を 7th へ移動
298
+ (0...stacks.size - 1).to_a.reverse.each do |i|
299
+ parent = stacks[i]
300
+ child = stacks[i + 1]
278
301
  dest = File.join(parent, File.basename(child))
279
- if @options[:dryrun]
280
- puts "[Dry Run] mv '#{child}' '#{dest}'"
281
- else
282
- puts "mv '#{child}' '#{dest}'"
283
- FileUtils.mkdir_p(parent) unless Dir.exist?(parent)
284
- FileUtils.mv(child, dest)
285
- end
302
+ moves << [child, dest]
286
303
  end
304
+ moves
287
305
  end
288
-
289
306
  def run
290
307
  puts "Before nest:"
291
- puts "."
292
- print_tree(@target_dir, "", [])
308
+ puts @target_dir == "." ? "." : "#{File.basename(@target_dir)}/"
309
+ print_tree(mk_dir_tree(@target_dir, 1, 999, dirs_only: true))
310
+
311
+ moves = nest_moves
312
+
313
+ puts "\nOperations:"
314
+ prefix = @options[:dryrun] ? "[Dry Run] " : ""
315
+ if moves.empty?
316
+ puts "#{prefix}nothing to nest"
317
+ else
318
+ moves.each do |child, dest|
319
+ puts "#{prefix}mv #{child} (to) #{dest}"
320
+ end
321
+ end
322
+
293
323
  puts "\nAfter nest:"
294
- print_nested_tree
295
- puts "\nNest moves:"
296
- nest_moves
324
+ puts "."
325
+ print_tree(build_virtual_tree)
326
+
327
+ unless @options[:dryrun]
328
+ moves.each do |child, dest|
329
+ FileUtils.mv(child, dest)
330
+ end
331
+ puts "\nExecution completed."
332
+ end
297
333
  end
298
334
  end
299
335
  end
@@ -217,8 +217,16 @@ module VocaBuil
217
217
  def parse_word_file(filepath)
218
218
  lines = File.readlines(filepath)
219
219
  words = lines[1..-1].each_with_object([]) do |line, arr|
220
- line = line.split('#', 2)[0]
221
- next if line.strip == ''
220
+ # エスケープされた'#'は一時的に置換
221
+ if line.include?("\\#")
222
+ line = line.gsub("\\#", "__ESCAPED_HASH__")
223
+ line = line.split('#', 2)[0]
224
+ next if line.strip == ''
225
+ line = line.gsub('__ESCAPED_HASH__', '#')
226
+ else
227
+ line = line.split('#', 2)[0]
228
+ next if line.strip == ''
229
+ end
222
230
  line_strip = if line.strip[0] == ':'
223
231
  line.strip[1..-2]
224
232
  else
@@ -227,7 +235,7 @@ module VocaBuil
227
235
  tmp = line_strip.split("=")
228
236
  arr << (@options[:reverse] ? tmp.reverse : tmp)
229
237
  end
230
- words # ← ここを元に戻す
238
+ words
231
239
  end
232
240
 
233
241
  def shuffle_words(words, w_num)
@@ -345,20 +353,18 @@ module VocaBuil
345
353
  end
346
354
 
347
355
  class InstallCheckSample
348
- def initialize(tgz_files = '*.tgz')
349
- @tgz_files = File.join(__dir__, 'tgz_dir', tgz_files)
356
+ def initialize(tgz_file = nil)
357
+ @tgz_file = tgz_file || File.join(__dir__, 'etymological_builder_check_sample.tgz')
350
358
  end
351
359
 
352
360
  def run
353
- if Dir.glob(@tgz_files).size == 0
354
- puts "#{@tgz_files} not found.".red
361
+ unless File.exist?(@tgz_file)
362
+ puts "#{@tgz_file} not found.".red
355
363
  return
356
364
  end
357
- Dir.glob(@tgz_files).each do |file|
358
- puts "Extracting #{file} to current directory...".green
359
- system("tar", "xf", file)
360
- puts "Extraction complete.".green
361
- end
365
+ puts "Extracting #{@tgz_file} to current directory...".green
366
+ system("tar", "xzf", @tgz_file)
367
+ puts "Extraction complete.".green
362
368
  end
363
369
  end
364
370
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mk_semi_lattice
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.4.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shigeto R. Nishitani
@@ -125,12 +125,10 @@ files:
125
125
  - lib/.semi_lattice/icons/folder.png
126
126
  - lib/abbrev_checker/abbrev_check.rb
127
127
  - lib/abbrev_checker/abbrev_sample.tgz
128
- - lib/abbrev_checker/abbrev_yamls/.semi_lattice/icons/document.png
129
- - lib/abbrev_checker/abbrev_yamls/.semi_lattice/icons/folder.png
130
- - lib/abbrev_checker/abbrev_yamls/.semi_lattice/semi_lattice.yaml
131
- - lib/abbrev_checker/abbrev_yamls/command_tree.yaml
132
- - lib/abbrev_checker/abbrev_yamls/command_tree_node_edge.yaml
133
- - lib/abbrev_checker/abbrev_yamls/initialism_tree.yaml
128
+ - lib/abbrev_checker/abbrev_yamls/command/dir_tree.yaml
129
+ - lib/abbrev_checker/abbrev_yamls/edit_short_cut/dir_tree.yaml
130
+ - lib/abbrev_checker/abbrev_yamls/initialism/dir_tree.yaml
131
+ - lib/abbrev_checker/abbrev_yamls/key_char/dir_tree.yaml
134
132
  - lib/abbrev_checker/docs/abbrev_checker.key
135
133
  - lib/abbrev_checker/docs/abbrev_checker/abbrev_checker.001.png
136
134
  - lib/abbrev_checker/docs/abbrev_checker/abbrev_checker.002.png
@@ -1,304 +0,0 @@
1
- ---
2
- :nodes:
3
- - :id: 1
4
- :name: file=file=ファイル操作
5
- :type: dir
6
- :file_path: "."
7
- :icon_path:
8
- :x: 74
9
- :y: 211
10
- :color: green
11
- :fixed: true
12
- - :id: 2
13
- :name: ls=list=cwdのファイル,dirの表示
14
- :type: dir
15
- :file_path: "./ls=list=cwdのファイル,dirの表示"
16
- :icon_path:
17
- :x: 174
18
- :y: 251
19
- :color: green
20
- :fixed: true
21
- - :id: 3
22
- :name: ls -lat=list long all time
23
- :type: file
24
- :file_path: "./ls=list=cwdのファイル,dirの表示/ls -lat=list long all time"
25
- :icon_path:
26
- :x: 208
27
- :y: 273
28
- :color: green
29
- :fixed: true
30
- - :id: 4
31
- :name: mv=move=ファイルの移動
32
- :type: file
33
- :file_path: "./mv=move=ファイルの移動"
34
- :icon_path:
35
- :x: 168
36
- :y: 298
37
- :color: green
38
- :fixed: true
39
- - :id: 5
40
- :name: cp=copy=ファイルの複製
41
- :type: file
42
- :file_path: "./cp=copy=ファイルの複製"
43
- :icon_path:
44
- :x: 166
45
- :y: 321
46
- :color: green
47
- :fixed: true
48
- - :id: 6
49
- :name: rm=remove=ファイルの削除
50
- :type: file
51
- :file_path: "./rm=remove=ファイルの削除"
52
- :icon_path:
53
- :x: 165
54
- :y: 347
55
- :color: green
56
- :fixed: true
57
- - :id: 7
58
- :name: cat=catenate=ファイルの中身を出力
59
- :type: file
60
- :file_path: "./cat=catenate=ファイルの中身を出力"
61
- :icon_path:
62
- :x: 80
63
- :y: 381
64
- :color: green
65
- :fixed: true
66
- - :id: 8
67
- :name: dir=directory=フォルダ
68
- :type: dir
69
- :file_path: "../dir=directory=フォルダ"
70
- :icon_path:
71
- :x: 425
72
- :y: 88
73
- :color: green
74
- :fixed: true
75
- - :id: 9
76
- :name: pwd=print working directory=cwd PATHを表示
77
- :type: dir
78
- :file_path: "../dir=directory=フォルダ/pwd=print working directory=cwd PATHを表示"
79
- :icon_path:
80
- :x: 351
81
- :y: 36
82
- :color: green
83
- :fixed: true
84
- - :id: 10
85
- :name: mkdir=make directory=dir作成
86
- :type: file
87
- :file_path: "../dir=directory=フォルダ/pwd=print working directory=cwd PATHを表示/mkdir=make
88
- directory=dir作成"
89
- :icon_path:
90
- :x: 414
91
- :y: 137
92
- :color: green
93
- :fixed: true
94
- - :id: 11
95
- :name: rm -rf=remove recursively forcefully=PATHを再帰的で強制的に削除
96
- :type: file
97
- :file_path: "../dir=directory=フォルダ/rm -rf=remove recursively forcefully=PATHを再帰的で強制的に削除"
98
- :icon_path:
99
- :x: 468
100
- :y: 104
101
- :color: green
102
- :fixed: true
103
- - :id: 12
104
- :name: cwd=current working directory=ファイル操作をしているPATH,基準となる場所
105
- :type: file
106
- :file_path: "../dir=directory=フォルダ/cwd=current working directory=ファイル操作をしているPATH,基準となる場所"
107
- :icon_path:
108
- :x: 314
109
- :y: 18
110
- :color: green
111
- :fixed: true
112
- - :id: 13
113
- :name: cd=change directory=cwdの移動
114
- :type: file
115
- :file_path: "../dir=directory=フォルダ/cd=change directory=cwdの移動"
116
- :icon_path:
117
- :x: 418
118
- :y: 167
119
- :color: green
120
- :fixed: true
121
- - :id: 14
122
- :name: tree=tree=ディレクトリのツリー表示
123
- :type: file
124
- :file_path: "../dir=directory=フォルダ/tree=tree=ディレクトリのツリー表示"
125
- :icon_path:
126
- :x: 340
127
- :y: 193
128
- :color: green
129
- :fixed: true
130
- - :id: 15
131
- :name: path=path=パス,小径
132
- :type: dir
133
- :file_path: "../path=path=パス,小径"
134
- :icon_path:
135
- :x: 70
136
- :y: 33
137
- :color: green
138
- :fixed: true
139
- - :id: 16
140
- :name: full_path=full path=絶対パス
141
- :type: file
142
- :file_path: "../path=path=パス,小径/full_path=full path=絶対パス"
143
- :icon_path:
144
- :x: 97
145
- :y: 52
146
- :color: green
147
- :fixed: true
148
- - :id: 17
149
- :name: rel_path=relative path=相対パス
150
- :type: file
151
- :file_path: "../path=path=パス,小径/rel_path=relative path=相対パス"
152
- :icon_path:
153
- :x: 95
154
- :y: 76
155
- :color: green
156
- :fixed: true
157
- - :id: 18
158
- :name: c-keys=controll-keys=ファイル編集のkeyバインド
159
- :type: dir
160
- :file_path: "../c-keys=controll-keys=ファイル編集のkeyバインド"
161
- :icon_path:
162
- :x: 403
163
- :y: 412
164
- :color: green
165
- :fixed: true
166
- - :id: 19
167
- :name: c-a=ahead=行頭へ移動
168
- :type: file
169
- :file_path: "../c-keys=controll-keys=ファイル編集のkeyバインド/c-a=ahead=行頭へ移動"
170
- :icon_path:
171
- :x: 198
172
- :y: 464
173
- :color: green
174
- :fixed: true
175
- - :id: 20
176
- :name: c-e=end=行末へ移動
177
- :type: file
178
- :file_path: "../c-keys=controll-keys=ファイル編集のkeyバインド/c-e=end=行末へ移動"
179
- :icon_path:
180
- :x: 572
181
- :y: 454
182
- :color: green
183
- :fixed: true
184
- - :id: 21
185
- :name: c-p=previous=前行へ移動
186
- :type: file
187
- :file_path: "../c-keys=controll-keys=ファイル編集のkeyバインド/c-p=previous=前行へ移動"
188
- :icon_path:
189
- :x: 401
190
- :y: 344
191
- :color: green
192
- :fixed: true
193
- - :id: 22
194
- :name: c-n=next=次行へ移動
195
- :type: file
196
- :file_path: "../c-keys=controll-keys=ファイル編集のkeyバインド/c-n=next=次行へ移動"
197
- :icon_path:
198
- :x: 403
199
- :y: 475
200
- :color: green
201
- :fixed: true
202
- - :id: 23
203
- :name: c-f=forward=一字進む
204
- :type: file
205
- :file_path: "../c-keys=controll-keys=ファイル編集のkeyバインド/c-f=forward=一字進む"
206
- :icon_path:
207
- :x: 272
208
- :y: 444
209
- :color: green
210
- :fixed: true
211
- - :id: 24
212
- :name: c-b=backward=一字戻る
213
- :type: file
214
- :file_path: "../c-keys=controll-keys=ファイル編集のkeyバインド/c-b=backward=一字戻る"
215
- :icon_path:
216
- :x: 474
217
- :y: 439
218
- :color: green
219
- :fixed: true
220
- - :id: 25
221
- :name: c-d=delete=一字削除
222
- :type: file
223
- :file_path: "../c-keys=controll-keys=ファイル編集のkeyバインド/c-d=delete=一字削除"
224
- :icon_path:
225
- :x: 263
226
- :y: 546
227
- :color: green
228
- :fixed: true
229
- - :id: 26
230
- :name: c-k=kill line=一行削除
231
- :type: file
232
- :file_path: "../c-keys=controll-keys=ファイル編集のkeyバインド/c-k=kill line=一行削除"
233
- :icon_path:
234
- :x: 262
235
- :y: 564
236
- :color: green
237
- :fixed: true
238
- :edges:
239
- - :from: 1
240
- # from: file=file=ファイル操作, to: ls=list=cwdのファイル,dirの表示
241
- :to: 2
242
- - :from: 2
243
- # from: ls=list=cwdのファイル,dirの表示, to: ls -lat=list long all time
244
- :to: 3
245
- - :from: 1
246
- # from: file=file=ファイル操作, to: mv=move=ファイルの移動
247
- :to: 4
248
- - :from: 1
249
- # from: file=file=ファイル操作, to: cp=copy=ファイルの複製
250
- :to: 5
251
- - :from: 1
252
- # from: file=file=ファイル操作, to: rm=remove=ファイルの削除
253
- :to: 6
254
- - :from: 1
255
- # from: file=file=ファイル操作, to: cat=catenate=ファイルの中身を出力
256
- :to: 7
257
- - :from: 8
258
- # from: dir=directory=フォルダ, to: pwd=print working directory=cwd PATHを表示
259
- :to: 9
260
- - :from: 9
261
- # from: pwd=print working directory=cwd PATHを表示, to: mkdir=make directory=dir作成
262
- :to: 10
263
- - :from: 8
264
- # from: dir=directory=フォルダ, to: rm -rf=remove recursively forcefully=PATHを再帰的で強制的に削除
265
- :to: 11
266
- - :from: 8
267
- # from: dir=directory=フォルダ, to: cwd=current working directory=ファイル操作をしているPATH,基準となる場所
268
- :to: 12
269
- - :from: 8
270
- # from: dir=directory=フォルダ, to: cd=change directory=cwdの移動
271
- :to: 13
272
- - :from: 8
273
- # from: dir=directory=フォルダ, to: tree=tree=ディレクトリのツリー表示
274
- :to: 14
275
- - :from: 15
276
- # from: path=path=パス,小径, to: full_path=full path=絶対パス
277
- :to: 16
278
- - :from: 15
279
- # from: path=path=パス,小径, to: rel_path=relative path=相対パス
280
- :to: 17
281
- - :from: 18
282
- # from: c-keys=controll-keys=ファイル編集のkeyバインド, to: c-a=ahead=行頭へ移動
283
- :to: 19
284
- - :from: 18
285
- # from: c-keys=controll-keys=ファイル編集のkeyバインド, to: c-e=end=行末へ移動
286
- :to: 20
287
- - :from: 18
288
- # from: c-keys=controll-keys=ファイル編集のkeyバインド, to: c-p=previous=前行へ移動
289
- :to: 21
290
- - :from: 18
291
- # from: c-keys=controll-keys=ファイル編集のkeyバインド, to: c-n=next=次行へ移動
292
- :to: 22
293
- - :from: 18
294
- # from: c-keys=controll-keys=ファイル編集のkeyバインド, to: c-f=forward=一字進む
295
- :to: 23
296
- - :from: 18
297
- # from: c-keys=controll-keys=ファイル編集のkeyバインド, to: c-b=backward=一字戻る
298
- :to: 24
299
- - :from: 18
300
- # from: c-keys=controll-keys=ファイル編集のkeyバインド, to: c-d=delete=一字削除
301
- :to: 25
302
- - :from: 18
303
- # from: c-keys=controll-keys=ファイル編集のkeyバインド, to: c-k=kill line=一行削除
304
- :to: 26
@@ -1,174 +0,0 @@
1
- ---
2
- :nodes:
3
- - :id: 1
4
- :name: file=file=ファイル操作
5
- :type: dir
6
- :file_path: "."
7
- - :id: 2
8
- :name: ls=list=cwdのファイル,dirの表示
9
- :type: dir
10
- :file_path: "./ls=list=cwdのファイル,dirの表示"
11
- - :id: 3
12
- :name: ls -lat=list long all time
13
- :type: file
14
- :file_path: "./ls=list=cwdのファイル,dirの表示/ls -lat=list long all time"
15
- - :id: 4
16
- :name: mv=move=ファイルの移動
17
- :type: file
18
- :file_path: "./mv=move=ファイルの移動"
19
- - :id: 5
20
- :name: cp=copy=ファイルの複製
21
- :type: file
22
- :file_path: "./cp=copy=ファイルの複製"
23
- - :id: 6
24
- :name: rm=remove=ファイルの削除
25
- :type: file
26
- :file_path: "./rm=remove=ファイルの削除"
27
- - :id: 7
28
- :name: cat=catenate=ファイルの中身を出力
29
- :type: file
30
- :file_path: "./cat=catenate=ファイルの中身を出力"
31
- - :id: 8
32
- :name: dir=directory=フォルダ
33
- :type: dir
34
- :file_path: "../dir=directory=フォルダ"
35
- - :id: 9
36
- :name: pwd=print working directory=cwd PATHを表示
37
- :type: dir
38
- :file_path: "../dir=directory=フォルダ/pwd=print working directory=cwd PATHを表示"
39
- - :id: 10
40
- :name: mkdir=make directory=dir作成
41
- :type: file
42
- :file_path: "../dir=directory=フォルダ/pwd=print working directory=cwd PATHを表示/mkdir=make
43
- directory=dir作成"
44
- - :id: 11
45
- :name: rm -rf=remove recursively forcefully=PATHを再帰的で強制的に削除
46
- :type: file
47
- :file_path: "../dir=directory=フォルダ/rm -rf=remove recursively forcefully=PATHを再帰的で強制的に削除"
48
- - :id: 12
49
- :name: cwd=current working directory=ファイル操作をしているPATH,基準となる場所
50
- :type: file
51
- :file_path: "../dir=directory=フォルダ/cwd=current working directory=ファイル操作をしているPATH,基準となる場所"
52
- - :id: 13
53
- :name: cd=change directory=cwdの移動
54
- :type: file
55
- :file_path: "../dir=directory=フォルダ/cd=change directory=cwdの移動"
56
- - :id: 14
57
- :name: tree=tree=ディレクトリのツリー表示
58
- :type: file
59
- :file_path: "../dir=directory=フォルダ/tree=tree=ディレクトリのツリー表示"
60
- - :id: 15
61
- :name: path=path=パス,小径
62
- :type: dir
63
- :file_path: "../path=path=パス,小径"
64
- - :id: 16
65
- :name: full_path=full path=絶対パス
66
- :type: file
67
- :file_path: "../path=path=パス,小径/full_path=full path=絶対パス"
68
- - :id: 17
69
- :name: rel_path=relative path=相対パス
70
- :type: file
71
- :file_path: "../path=path=パス,小径/rel_path=relative path=相対パス"
72
- - :id: 18
73
- :name: c-keys=controll-keys=ファイル編集のkeyバインド
74
- :type: dir
75
- :file_path: "../c-keys=controll-keys=ファイル編集のkeyバインド"
76
- - :id: 19
77
- :name: c-a=ahead=行頭へ移動
78
- :type: file
79
- :file_path: "../c-keys=controll-keys=ファイル編集のkeyバインド/c-a=ahead=行頭へ移動"
80
- - :id: 20
81
- :name: c-e=end=行末へ移動
82
- :type: file
83
- :file_path: "../c-keys=controll-keys=ファイル編集のkeyバインド/c-e=end=行末へ移動"
84
- - :id: 21
85
- :name: c-p=previous=前行へ移動
86
- :type: file
87
- :file_path: "../c-keys=controll-keys=ファイル編集のkeyバインド/c-p=previous=前行へ移動"
88
- - :id: 22
89
- :name: c-n=next=次行へ移動
90
- :type: file
91
- :file_path: "../c-keys=controll-keys=ファイル編集のkeyバインド/c-n=next=次行へ移動"
92
- - :id: 23
93
- :name: c-f=forward=一字進む
94
- :type: file
95
- :file_path: "../c-keys=controll-keys=ファイル編集のkeyバインド/c-f=forward=一字進む"
96
- - :id: 24
97
- :name: c-b=backward=一字戻る
98
- :type: file
99
- :file_path: "../c-keys=controll-keys=ファイル編集のkeyバインド/c-b=backward=一字戻る"
100
- - :id: 25
101
- :name: c-d=delete=一字削除
102
- :type: file
103
- :file_path: "../c-keys=controll-keys=ファイル編集のkeyバインド/c-d=delete=一字削除"
104
- - :id: 26
105
- :name: c-k=kill line=一行削除
106
- :type: file
107
- :file_path: "../c-keys=controll-keys=ファイル編集のkeyバインド/c-k=kill line=一行削除"
108
- :edges:
109
- - :from: 1
110
- # from: file=file=ファイル操作, to: ls=list=cwdのファイル,dirの表示
111
- :to: 2
112
- - :from: 2
113
- # from: ls=list=cwdのファイル,dirの表示, to: ls -lat=list long all time
114
- :to: 3
115
- - :from: 1
116
- # from: file=file=ファイル操作, to: mv=move=ファイルの移動
117
- :to: 4
118
- - :from: 1
119
- # from: file=file=ファイル操作, to: cp=copy=ファイルの複製
120
- :to: 5
121
- - :from: 1
122
- # from: file=file=ファイル操作, to: rm=remove=ファイルの削除
123
- :to: 6
124
- - :from: 1
125
- # from: file=file=ファイル操作, to: cat=catenate=ファイルの中身を出力
126
- :to: 7
127
- - :from: 8
128
- # from: dir=directory=フォルダ, to: pwd=print working directory=cwd PATHを表示
129
- :to: 9
130
- - :from: 9
131
- # from: pwd=print working directory=cwd PATHを表示, to: mkdir=make directory=dir作成
132
- :to: 10
133
- - :from: 8
134
- # from: dir=directory=フォルダ, to: rm -rf=remove recursively forcefully=PATHを再帰的で強制的に削除
135
- :to: 11
136
- - :from: 8
137
- # from: dir=directory=フォルダ, to: cwd=current working directory=ファイル操作をしているPATH,基準となる場所
138
- :to: 12
139
- - :from: 8
140
- # from: dir=directory=フォルダ, to: cd=change directory=cwdの移動
141
- :to: 13
142
- - :from: 8
143
- # from: dir=directory=フォルダ, to: tree=tree=ディレクトリのツリー表示
144
- :to: 14
145
- - :from: 15
146
- # from: path=path=パス,小径, to: full_path=full path=絶対パス
147
- :to: 16
148
- - :from: 15
149
- # from: path=path=パス,小径, to: rel_path=relative path=相対パス
150
- :to: 17
151
- - :from: 18
152
- # from: c-keys=controll-keys=ファイル編集のkeyバインド, to: c-a=ahead=行頭へ移動
153
- :to: 19
154
- - :from: 18
155
- # from: c-keys=controll-keys=ファイル編集のkeyバインド, to: c-e=end=行末へ移動
156
- :to: 20
157
- - :from: 18
158
- # from: c-keys=controll-keys=ファイル編集のkeyバインド, to: c-p=previous=前行へ移動
159
- :to: 21
160
- - :from: 18
161
- # from: c-keys=controll-keys=ファイル編集のkeyバインド, to: c-n=next=次行へ移動
162
- :to: 22
163
- - :from: 18
164
- # from: c-keys=controll-keys=ファイル編集のkeyバインド, to: c-f=forward=一字進む
165
- :to: 23
166
- - :from: 18
167
- # from: c-keys=controll-keys=ファイル編集のkeyバインド, to: c-b=backward=一字戻る
168
- :to: 24
169
- - :from: 18
170
- # from: c-keys=controll-keys=ファイル編集のkeyバインド, to: c-d=delete=一字削除
171
- :to: 25
172
- - :from: 18
173
- # from: c-keys=controll-keys=ファイル編集のkeyバインド, to: c-k=kill line=一行削除
174
- :to: 26