mk_semi_lattice 0.1.1 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fd367913e384f82dbbb7b8db40d35646855a82d5006715a51fc4eaa6601bc0ca
4
- data.tar.gz: fed2c0e74140c8dd15933c13ec8eb4e6466f72ac8f7f5a899c063046e62a6ce8
3
+ metadata.gz: 15f1e816692dca4dce63d49abf961749e3b242f96877a1bc998b2b4208e3eb83
4
+ data.tar.gz: 646e5f22cec25a61c7d2c8c8e9de6e31377a4d8693a1bc14f1f31724d840700c
5
5
  SHA512:
6
- metadata.gz: b44216e9db854f9a28d5f9b27463f0bfd119aaa0dece1e70cdd4e35c0628ee1c5720d5f780985c35e548c32dd63f71c46af9781e7f35960d3d8ec98b680b6a3f
7
- data.tar.gz: 8984c903dc85dcdf6e32bf80405d0ef6aae28718c8e776e5496554f385604a30d73bacecda8af54b7b0b6eadaaaae9ce6ef48e48844898de1adc7407f54e4bda
6
+ metadata.gz: 6379e532b1dd399efd9b41ceae6aff47770520e79d0603fa413da2d4092fc78781ba6bd68af5a05e1a0870030a2fe849695f9737872d24c90835f2850af93767
7
+ data.tar.gz: 35d3e0c85d3a34ec4ac774339703a4026d1ebd2cfb4b2db5e52ea0ce9941f6c01cc9e223bef36d91ccfebb2f5922dd463ce47a945feeb6ba87f2af0972a3daa3
@@ -1,4 +1,4 @@
1
- daddygongon: 描かれたnodeにidも表示するoptionとして-i, -indexを追加.
1
+ **daddygongon**: 描かれたnodeにidも表示するoptionとして-i, -indexを追加.
2
2
 
3
3
  GitHub Copilot: ### [mk_semi_lattice.rb](file:///Users/bob/git_hub/mk_semi_lattice/lib/mk_semi_lattice.rb)
4
4
 
@@ -0,0 +1,197 @@
1
+ # head
2
+ date: 2025-12-08
3
+ author: bob
4
+
5
+ ## User
6
+ 重複してますね.refactorしましょう.
7
+
8
+ ## Copilot
9
+ 重複している`@text`生成部分をまとめて、`dir`/それ以外で分岐する部分を簡潔にリファクタリングできます。
10
+ 以下のように書き換えるとスッキリします。
11
+
12
+ ```ruby
13
+ # ...existing code...
14
+ def create_graphics
15
+ return if @created
16
+ font_path = japanese_font
17
+
18
+ # テキスト生成(共通化)
19
+ if font_path && File.exist?(font_path)
20
+ @text = Text.new(label, x: x-28, y: y-10, size: 18, color: 'black', font: font_path, z: 11)
21
+ else
22
+ @text = Text.new(label, x: x-28, y: y-10, size: 18, color: 'black', z: 11)
23
+ end
24
+
25
+ # アイコン生成
26
+ @circle = if @type == 'dir'
27
+ Folder.new(x: x, y: y, color: NODE_COLOR, z: 10)
28
+ else
29
+ Circle.new(x: x, y: y, radius: 30, color: NODE_COLOR, z: 10)
30
+ end
31
+ @created = true
32
+ end
33
+ # ...existing code...
34
+ ```
35
+
36
+ - `@text`の生成を一度だけにまとめました。
37
+ - `@circle`の分岐のみを残しています。
38
+
39
+ このようにすることで、重複がなくなり、保守性も向上します。
40
+
41
+ ## User
42
+ pngファイルを表示するように変更.
43
+
44
+ ## Copilot
45
+ `Folder`クラスでフォルダアイコンを図形からPNG画像表示に変更するには、`Rectangle`の代わりに`Image`を使います。
46
+ 下記のように修正してください。
47
+
48
+ ```ruby
49
+ # ...existing code...
50
+ class Folder
51
+ # フォルダアイコンをRuby2Dの画像で描画するクラス
52
+ attr_accessor :x, :y, :name, :label, :fixed, :linked, :dx, :dy, :type, :file_path
53
+ def initialize(attrs = {})
54
+ @x = attrs[:x]
55
+ @y = attrs[:y]
56
+ @z = attrs[:z]
57
+ @color = attrs[:color]
58
+ @image = Image.new(
59
+ './icons/folder.png', # PNGファイルのパス
60
+ x: @x-28, y: @y-20, width: 56, height: 32, z: @z
61
+ )
62
+ end
63
+
64
+ def color=(c)
65
+ # 画像には直接色をつけられません。必要なら画像を加工してください。
66
+ end
67
+
68
+ def x=(x)
69
+ @image.x = x - 28
70
+ end
71
+
72
+ def y=(y)
73
+ @image.y = y - 20
74
+ end
75
+ end
76
+ # ...existing code...
77
+ ```
78
+
79
+ - `./icons/folder.png` をプロジェクト内に配置してください。
80
+ - `color=` メソッドは画像には使えません(必要なら画像自体を加工してください)。
81
+
82
+ この修正で、フォルダアイコンがPNG画像で表示されるようになります。
83
+
84
+ ## User
85
+ codeが重複しています.親クラスとしてNodeShapeを作り,派生クラスとしてFolder2, Document, Folderを作成してください.
86
+
87
+ ## Copilot
88
+ 以下のように、共通部分を`NodeShape`親クラスにまとめ、`Folder2`, `Document`, `Folder`を継承する形でリファクタリングできます。
89
+
90
+ ```ruby
91
+ # ...existing code...
92
+ class NodeShape
93
+ attr_accessor :x, :y, :name, :label, :fixed, :linked, :dx, :dy, :type, :file_path
94
+
95
+ def initialize(attrs = {})
96
+ @x = attrs[:x]
97
+ @y = attrs[:y]
98
+ @z = attrs[:z]
99
+ @color = attrs[:color]
100
+ @name = attrs[:name]
101
+ @label = attrs[:label]
102
+ @fixed = attrs[:fixed]
103
+ @linked = attrs[:linked]
104
+ @dx = attrs[:dx]
105
+ @dy = attrs[:dy]
106
+ @type = attrs[:type]
107
+ @file_path = attrs[:file_path]
108
+ setup_shape
109
+ end
110
+
111
+ def color=(c)
112
+ # 派生クラスでオーバーライド
113
+ end
114
+
115
+ def x=(x)
116
+ # 派生クラスでオーバーライド
117
+ end
118
+
119
+ def y=(y)
120
+ # 派生クラスでオーバーライド
121
+ end
122
+
123
+ def setup_shape
124
+ # 派生クラスでオーバーライド
125
+ end
126
+ end
127
+
128
+ class Folder2 < NodeShape
129
+ def setup_shape
130
+ @image = Image.new(
131
+ './icons/folder.png',
132
+ x: @x-28, y: @y-20, width: 56, height: 36, z: @z
133
+ )
134
+ end
135
+
136
+ def color=(c)
137
+ # 画像には直接色をつけられません
138
+ end
139
+
140
+ def x=(x)
141
+ @image.x = x - 28
142
+ end
143
+
144
+ def y=(y)
145
+ @image.y = y - 20
146
+ end
147
+ end
148
+
149
+ class Document < NodeShape
150
+ def setup_shape
151
+ @image = Image.new(
152
+ './icons/document.png',
153
+ x: @x-28, y: @y-20, width: 38, height: 56, z: @z
154
+ )
155
+ end
156
+
157
+ def color=(c)
158
+ # 画像には直接色をつけられません
159
+ end
160
+
161
+ def x=(x)
162
+ @image.x = x - 28
163
+ end
164
+
165
+ def y=(y)
166
+ @image.y = y - 20
167
+ end
168
+ end
169
+
170
+ class Folder < NodeShape
171
+ def setup_shape
172
+ @folder1 = Rectangle.new(x: @x-28, y: @y-10, width: 56, height: 32, color: @color, z: @z)
173
+ @folder2 = Rectangle.new(x: @x-28, y: @y-20, width: 26, height: 12, color: @color, z: @z)
174
+ end
175
+
176
+ def color=(c)
177
+ @folder1.color = c
178
+ @folder2.color = c
179
+ end
180
+
181
+ def x=(x)
182
+ @folder1.x = x - 28
183
+ @folder2.x = x - 28
184
+ end
185
+
186
+ def y=(y)
187
+ @folder1.y = y - 10
188
+ @folder2.y = y - 20
189
+ end
190
+ end
191
+ # ...existing code...
192
+ ```
193
+
194
+ - `NodeShape`で共通属性・初期化をまとめ、`setup_shape`を各派生クラスで実装します。
195
+ - `color=`, `x=`, `y=`も必要に応じてオーバーライドします。
196
+
197
+ この構造で重複が大幅に減り、拡張・保守が容易になります。
Binary file
Binary file
Binary file
data/exe/{sl → mk_sl} RENAMED
@@ -1,5 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "mk_semi_lattice"
4
-
5
-
@@ -0,0 +1,63 @@
1
+ ---
2
+ :nodes:
3
+ - :id: 1
4
+ :name: mk_semi_lattice/
5
+ :type: dir
6
+ :file_path: "."
7
+ - :id: 2
8
+ :name: option_manager.rb
9
+ :type: file
10
+ :file_path: "./option_manager.rb"
11
+ - :id: 3
12
+ :name: ruby2d_action.rb
13
+ :type: file
14
+ :file_path: "./ruby2d_action.rb"
15
+ - :id: 4
16
+ :name: version.rb
17
+ :type: file
18
+ :file_path: "./version.rb"
19
+ - :id: 5
20
+ :name: init_env.rb
21
+ :type: file
22
+ :file_path: "./init_env.rb"
23
+ - :id: 6
24
+ :name: sl_components.rb
25
+ :type: file
26
+ :file_path: "./sl_components.rb"
27
+ - :id: 7
28
+ :name: manage_yaml/
29
+ :type: dir
30
+ :file_path: "./manage_yaml"
31
+ - :id: 8
32
+ :name: mk_semi_lattice.rb
33
+ :type: file
34
+ :file_path: "./manage_yaml/mk_semi_lattice.rb"
35
+ - :id: 9
36
+ :name: mk_node_edge.rb
37
+ :type: file
38
+ :file_path: "./manage_yaml/mk_node_edge.rb"
39
+ :edges:
40
+ - :from: 1
41
+ # from: mk_semi_lattice/, to: option_manager.rb
42
+ :to: 2
43
+ - :from: 1
44
+ # from: mk_semi_lattice/, to: ruby2d_action.rb
45
+ :to: 3
46
+ - :from: 1
47
+ # from: mk_semi_lattice/, to: version.rb
48
+ :to: 4
49
+ - :from: 1
50
+ # from: mk_semi_lattice/, to: init_env.rb
51
+ :to: 5
52
+ - :from: 1
53
+ # from: mk_semi_lattice/, to: sl_components.rb
54
+ :to: 6
55
+ - :from: 1
56
+ # from: mk_semi_lattice/, to: manage_yaml/
57
+ :to: 7
58
+ - :from: 7
59
+ # from: manage_yaml/, to: mk_semi_lattice.rb
60
+ :to: 8
61
+ - :from: 7
62
+ # from: manage_yaml/, to: mk_node_edge.rb
63
+ :to: 9
@@ -0,0 +1,10 @@
1
+ ---
2
+ mk_semi_lattice/:
3
+ option_manager.rb:
4
+ ruby2d_action.rb:
5
+ version.rb:
6
+ init_env.rb:
7
+ sl_components.rb:
8
+ manage_yaml/:
9
+ mk_semi_lattice.rb:
10
+ mk_node_edge.rb:
@@ -0,0 +1,99 @@
1
+ ---
2
+ :nodes:
3
+ - :id: 1
4
+ :name: mk_semi_lattice/
5
+ :type: dir
6
+ :file_path: "."
7
+ :x: 275.02162808595216
8
+ :y: 314.87430515494754
9
+ :color: orange
10
+ :fixed: false
11
+ - :id: 2
12
+ :name: option_manager.rb
13
+ :type: file
14
+ :file_path: "./option_manager.rb"
15
+ :x: 346.9161695907995
16
+ :y: 269.19879019844353
17
+ :color: orange
18
+ :fixed: false
19
+ - :id: 3
20
+ :name: ruby2d_action.rb
21
+ :type: file
22
+ :file_path: "./ruby2d_action.rb"
23
+ :x: 217.6026086862854
24
+ :y: 377.3833947075089
25
+ :color: orange
26
+ :fixed: false
27
+ - :id: 4
28
+ :name: version.rb
29
+ :type: file
30
+ :file_path: "./version.rb"
31
+ :x: 196.70324002652094
32
+ :y: 282.82727426583205
33
+ :color: orange
34
+ :fixed: false
35
+ - :id: 5
36
+ :name: init_env.rb
37
+ :type: file
38
+ :file_path: "./init_env.rb"
39
+ :x: 336.69859191671014
40
+ :y: 373.90134873437574
41
+ :color: orange
42
+ :fixed: false
43
+ - :id: 6
44
+ :name: sl_components.rb
45
+ :type: file
46
+ :file_path: "./sl_components.rb"
47
+ :x: 275.5713052007363
48
+ :y: 230.10419857002472
49
+ :color: orange
50
+ :fixed: false
51
+ - :id: 7
52
+ :name: manage_yaml/
53
+ :type: dir
54
+ :file_path: "./manage_yaml"
55
+ :x: 299.7712906846464
56
+ :y: 399.95204864889575
57
+ :color: orange
58
+ :fixed: false
59
+ - :id: 8
60
+ :name: mk_semi_lattice.rb
61
+ :type: file
62
+ :file_path: "./manage_yaml/mk_semi_lattice.rb"
63
+ :x: 376.1077960220242
64
+ :y: 361.86505364409146
65
+ :color: orange
66
+ :fixed: false
67
+ - :id: 9
68
+ :name: mk_node_edge.rb
69
+ :type: file
70
+ :file_path: "./manage_yaml/mk_node_edge.rb"
71
+ :x: 293.40510780338064
72
+ :y: 484.3912842691303
73
+ :color: orange
74
+ :fixed: false
75
+ :edges:
76
+ - :from: 1
77
+ # from: mk_semi_lattice/, to: option_manager.rb
78
+ :to: 2
79
+ - :from: 1
80
+ # from: mk_semi_lattice/, to: ruby2d_action.rb
81
+ :to: 3
82
+ - :from: 1
83
+ # from: mk_semi_lattice/, to: version.rb
84
+ :to: 4
85
+ - :from: 1
86
+ # from: mk_semi_lattice/, to: init_env.rb
87
+ :to: 5
88
+ - :from: 1
89
+ # from: mk_semi_lattice/, to: sl_components.rb
90
+ :to: 6
91
+ - :from: 1
92
+ # from: mk_semi_lattice/, to: manage_yaml/
93
+ :to: 7
94
+ - :from: 7
95
+ # from: manage_yaml/, to: mk_semi_lattice.rb
96
+ :to: 8
97
+ - :from: 7
98
+ # from: manage_yaml/, to: mk_node_edge.rb
99
+ :to: 9
@@ -0,0 +1,109 @@
1
+ # frozen_string_literal: true
2
+ require 'yaml'
3
+ require 'fileutils'
4
+ require 'colorize'
5
+
6
+ module InitEnv
7
+ def self.init_env(parent_dir)
8
+ Config.setup
9
+ Log.event("started", parent_dir: parent_dir)
10
+ MkSemiLatticeDir.setup(parent_dir)
11
+ end
12
+
13
+ class MkSemiLatticeDir
14
+ SEMI_LATTICE_DIR = ".semi_lattice"
15
+ ICONS_DIR = "icons"
16
+
17
+ def self.setup(parent_dir)
18
+ semi_dir = File.join(parent_dir, SEMI_LATTICE_DIR)
19
+ icons_dir = File.join(semi_dir, ICONS_DIR)
20
+ FileUtils.mkdir_p(icons_dir)
21
+ copy_default_icons(icons_dir)
22
+ end
23
+
24
+ def self.copy_default_icons(icons_dir)
25
+ icons_src_dir = File.expand_path(File.join(__dir__, "..", "..", "app", "assets", "icons"))
26
+ ["folder.png", "document.png"
27
+ ].each do |icon_name|
28
+ src_path = File.join(icons_src_dir, icon_name)
29
+ dest_path = File.join(icons_dir, icon_name)
30
+ FileUtils.cp(src_path, dest_path) unless File.exist?(dest_path)
31
+ end
32
+ end
33
+ end
34
+
35
+ class Config
36
+ CONFIG_DIR = File.expand_path("~/.config/semi_lattice")
37
+ CONF_PATH = File.join(CONFIG_DIR, "semi_lattice.conf")
38
+ LOG_PATH = File.join(CONFIG_DIR, "semi_lattice_history")
39
+
40
+ @conf = { "log" => false }
41
+
42
+ class << self
43
+ attr_reader :conf
44
+
45
+ def setup
46
+ FileUtils.mkdir_p(CONFIG_DIR)
47
+ load_conf
48
+ end
49
+
50
+ def load_conf
51
+ if File.file?(CONF_PATH)
52
+ begin
53
+ loaded = YAML.load_file(CONF_PATH)
54
+ if loaded.is_a?(Hash)
55
+ @conf.merge!(loaded)
56
+ else
57
+ puts "Warning: #{CONF_PATH} is not a hash. Using default config.".yellow
58
+ end
59
+ rescue
60
+ puts "Warning: #{CONF_PATH} is invalid. Using default config.".yellow
61
+ end
62
+ end
63
+ end
64
+
65
+ def save_conf
66
+ File.write(CONF_PATH, @conf.to_yaml)
67
+ end
68
+
69
+ def log_enabled?
70
+ @conf["log"]
71
+ end
72
+
73
+ def set_log(value)
74
+ @conf["log"] = value
75
+ save_conf
76
+ end
77
+
78
+ def log_path
79
+ LOG_PATH
80
+ end
81
+ end
82
+ end
83
+
84
+ require 'yaml'
85
+
86
+ class Log
87
+ class << self
88
+ def event(action, target_dir: nil, parent_dir: Dir.pwd)
89
+ return unless Config.log_enabled?
90
+ log_entry = {
91
+ timestamp: Time.now.strftime('%Y-%m-%d %H:%M:%S'),
92
+ action: action
93
+ }
94
+ log_entry[:target_dir] = target_dir if target_dir
95
+ log_entry[:where] = parent_dir
96
+ logs = []
97
+ if File.exist?(Config.log_path)
98
+ begin
99
+ logs = YAML.load_file(Config.log_path) || []
100
+ rescue
101
+ logs = []
102
+ end
103
+ end
104
+ logs << log_entry
105
+ File.write(Config.log_path, logs.to_yaml)
106
+ end
107
+ end
108
+ end
109
+ end
@@ -1,6 +1,6 @@
1
1
  require 'pathname'
2
2
 
3
- module MkSemiLattice
3
+ module ManageYaml
4
4
  class MkNodeEdge
5
5
  def initialize(input_path:, output_path:)
6
6
  dir_tree = YAML.load_file(input_path)
@@ -99,10 +99,3 @@ module MkSemiLattice
99
99
  end
100
100
  end
101
101
  end
102
-
103
- # 実行部分例(必要なら有効化)
104
- # if __FILE__ == $0
105
- # input_path = File.join(File.dirname(__FILE__), '.semi_lattice', 'dir.yaml')
106
- # output_path = File.join(File.dirname(__FILE__), '.semi_lattice', 'dir_node_edge.yaml')
107
- # SemiLattice::MkNodeEdge.run(input_path: input_path, output_path: output_path)
108
- # end
@@ -0,0 +1,143 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ManageYaml
4
+ class MkSemiLattice
5
+ def initialize(options)
6
+ @parent_dir = options[:parent_dir]
7
+ @semi_dir = options[:semi_dir]
8
+ @semi_lattice_yaml_path = options[:semi_lattice_yaml_path]
9
+ @options = options
10
+ p @options
11
+ end
12
+
13
+ # ARGV[0]とoptionsから初期ファイル・初期ステップを決定
14
+ def select_init_file_and_step
15
+ p ['ARGV', ARGV]
16
+ if (ARGV[0] == '.' || ARGV[0].nil?) && !@options[:file]
17
+ if File.exist?(@semi_lattice_yaml_path)
18
+ [@semi_lattice_yaml_path, :from_semi_lattice]
19
+ else
20
+ ['.', :from_dir]
21
+ end
22
+ else
23
+ [ARGV[0], @options[:init_step]]
24
+ end
25
+ end
26
+
27
+ # 初期ステップに応じて入力ファイルとwith_semi_lattice_yamlを決定
28
+ def select_input_path_and_flag(init_file, init_step)
29
+ case init_step
30
+ when :from_dir
31
+ Dir.mkdir(@semi_dir) unless Dir.exist?(@semi_dir)
32
+ in_path = init_file
33
+ out_path = File.join(@semi_dir, 'dir_tree.yaml')
34
+ MkDirYaml.new(path: in_path, layer: @options[:layer], output_file: out_path)
35
+ in_path = out_path
36
+ out_path = File.join(@semi_dir, 'dir_node_edge.yaml')
37
+ MkNodeEdge.new(input_path: in_path, output_path: out_path)
38
+ [out_path, false]
39
+ when :from_tree
40
+ init_file = @options[:file]
41
+ base = File.basename(init_file, File.extname(init_file))
42
+ in_path = init_file
43
+ out_path = File.join(@parent_dir, "#{base}_node_edge.yaml")
44
+ MkNodeEdge.new(input_path: in_path, output_path: out_path)
45
+ [out_path, false]
46
+ when :from_node_edge
47
+ if File.exist?(File.join(@parent_dir, 'semi_lattice.yaml'))
48
+ puts "Warning: semi_lattice.yaml already exists in current directory.".yellow
49
+ exit 1
50
+ end
51
+ [@options[:file], false]
52
+ when :from_semi_lattice
53
+ [init_file, true]
54
+ else
55
+ raise "Unknown init_step: #{init_step}"
56
+ end
57
+ end
58
+
59
+ # 新メソッド: 初期ファイル・ステップ・入力パス・フラグをまとめて取得
60
+ def prepare_paths_and_flags
61
+ init_file, init_step = select_init_file_and_step
62
+ p ["init_file", init_file, init_step]
63
+ input_path, with_semi_lattice_yaml = select_input_path_and_flag(init_file, init_step)
64
+ p ["input_path", input_path, with_semi_lattice_yaml]
65
+ [input_path, with_semi_lattice_yaml]
66
+ end
67
+
68
+ # アプリ終了時の状態保存
69
+ def self.at_exit_action(app, semi_dir, parent_dir)
70
+ nodes_data = app.nodes.map do |n|
71
+ #p [n.label, n.fixed, n.color]
72
+ {
73
+ id: app.node_table.key(n),
74
+ name: n.name,
75
+ type: n.type,
76
+ file_path: n.file_path,
77
+ icon_path: n.icon_path,
78
+ x: n.x,
79
+ y: n.y,
80
+ color: n.color,
81
+ fixed: n.fixed
82
+ }
83
+ end
84
+ edges_data = app.edges.map do |e|
85
+ {
86
+ from: app.node_table.key(e.from),
87
+ to: app.node_table.key(e.to)
88
+ }
89
+ end
90
+
91
+ yaml_data = { nodes: nodes_data, edges: edges_data }
92
+ yaml_text = MkNodeEdge.add_edge_comments(yaml_data)
93
+ if Dir.exist?(semi_dir)
94
+ File.write(File.join(semi_dir, "semi_lattice.yaml"), yaml_text)
95
+ puts "Semi-lattice state saved to #{File.join(semi_dir, "semi_lattice.yaml")}"
96
+ else
97
+ File.write(File.join('.', "semi_lattice.yaml"), yaml_text)
98
+ puts "Semi-lattice state saved to #{File.join('.', "semi_lattice.yaml")}"
99
+ end
100
+ InitEnv::Log.event("exited", parent_dir: parent_dir)
101
+ end
102
+ end
103
+
104
+ class MkDirYaml
105
+ def initialize(path: '.', layer: 2, output_file: 'dir.yaml')
106
+ abs_path = File.expand_path(path)
107
+ root_key = File.basename(abs_path) + '/'
108
+
109
+ # layerの数だけ深さを調整
110
+ result = { root_key => dir_tree(path, layer - 1) }
111
+ p ["MkDirYaml result", result]
112
+ File.write(output_file, result.to_yaml)
113
+ puts "Directory structure exported to #{output_file}"
114
+ end
115
+
116
+ def dir_tree(path, depth)
117
+ return nil if depth < 0
118
+ tree = {}
119
+ Dir.children(path).each do |entry|
120
+ next if entry.start_with?('.')
121
+ full = File.join(path, entry)
122
+ # .yamlファイルは含めないが、semi_lattice.yamlは含める
123
+ next if File.file?(full) && File.extname(entry) == '.yaml' && entry != 'semi_lattice.yaml'
124
+ next if entry.end_with?('~')
125
+ if File.symlink?(full)
126
+ target = File.readlink(full)
127
+ tree[entry] = "-> #{target}"
128
+ elsif File.directory?(full)
129
+ subtree = dir_tree(full, depth - 1)
130
+ if subtree
131
+ tree["#{entry}/"] = subtree
132
+ else
133
+ tree["#{entry}/"] = nil
134
+ end
135
+ else
136
+ tree[entry] = nil
137
+ end
138
+ end
139
+ tree
140
+ end
141
+ end
142
+
143
+ end
@@ -74,7 +74,7 @@ module Ruby2dAction
74
74
  end
75
75
  end
76
76
  puts comm
77
- Log.event("open", target_dir: abs_path, parent_dir: parent_dir)
77
+ InitEnv::Log.event("open", target_dir: abs_path, parent_dir: parent_dir)
78
78
  system comm
79
79
  else
80
80
  puts "no link error"