CppUmlClass 0.6.0 → 0.7.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: a663be325a0c0bc0a2737ee6a80d28e36ceb82e797dd280c7a6dcd2e8622de1f
4
- data.tar.gz: f52916b31de6c3bf8c9c2d1ae98d3c64863109a07d2bae0a792bc8dba26e9003
3
+ metadata.gz: d91adb75b0a5641d9f10d7555a21cd5deb3286062305f05d381c8293b4dde212
4
+ data.tar.gz: 598cf985599e675fe3143c1df39bf931975b54f9eabda4f69eb7b7c5dd864622
5
5
  SHA512:
6
- metadata.gz: f12f7c88cce03eb7ab4cbcdcf247c807fb5390d12dc7c7fae4e20bf0147da888a9b5f386e1e54d86e698694ef0adec9e63b2993779498dfe40ce425dd919aba0
7
- data.tar.gz: ae7103faad064ddceacd6d5062c401f0d82e7d90a9be860d093bd6fc589735b7c5fca88816afcb4349d446746472638e10ba59093f075750f092325ade11cd8f
6
+ metadata.gz: 86d1b0f57c6caf5b6a730bf8a1835876480460f7220d958f6c157d14f6c3043d013b256a10729752770a2ccb1c9da507e2271d19ef71d0ba80ae4d7e78468713
7
+ data.tar.gz: 466a3db42c822f71df2ea2c840ebd107c620333f8cdd4096d4d7e453b1e452384bda2ca1949d6d758162867d4fa4d60cf04afff40914fdca5aec6bd5fdac663b
data/README.md CHANGED
@@ -25,12 +25,47 @@ If bundler is not being used to manage dependencies, install the gem by executin
25
25
 
26
26
  $ sudo gem install CppUmlClass
27
27
 
28
- ## Usage
28
+ ## Usage(GUI)
29
+ A browser-based GUI opens.
29
30
 
30
31
  $ start_cpp_uml_class.rb
31
32
 
32
33
  https://github.com/user-attachments/assets/dfd68556-bf4d-43b7-8fef-b6f951c9147d
33
34
 
35
+ ## Usage(command line)
36
+ command line interface
37
+ ```
38
+ Usage: create_cpp_uml_class.rb [options] cpp_source_directory out_file
39
+ -c config_file
40
+ ```
41
+ config_file defaults to CppUmlClass/config/setting.json in your home directory.
42
+
43
+ Example
44
+
45
+ $ create_cpp_uml_class.rb ~/tool/cpp_test /tmp/test.pu
46
+
47
+
48
+ ## clsss color support
49
+
50
+ ![class_color](img/class_color.png)
51
+
52
+ ## Setting
53
+
54
+ - plant uml command
55
+ - editor to open plant uml file
56
+ - default class color 1
57
+ - source path of the class that sets the color 1
58
+ - default class color 2
59
+ - source path of the class that sets the color 2
60
+ - default class color 3
61
+ - source path of the class that sets the color 2
62
+
63
+ The setting file is saved in the home directory under CppUmlClass/config/setting.json.
64
+
65
+ ![setting](img/setting.png)
66
+
67
+
68
+
34
69
  ## Development
35
70
 
36
71
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "json"
4
+ require "optparse"
5
+
6
+ def config_json_hash(json)
7
+ config = {}
8
+ json["setting_list"].each do |j|
9
+ config[j["name"]] = j["value"]
10
+ end
11
+ return config
12
+ end
13
+
14
+ opt = Hash.new
15
+ opts = OptionParser.new
16
+ opts.banner = "Usage: create_cpp_uml_class.rb [options] cpp_source_directory out_file"
17
+
18
+ opts.on("-c config_file") { |v| opt[:config_file] = v } # config file path
19
+ opts.parse!(ARGV)
20
+ in_dir = ARGV[0]
21
+ out_file = ARGV[1]
22
+ if in_dir == nil or out_file == nil
23
+ puts opts.help
24
+ exit
25
+ end
26
+
27
+ dir = File.dirname(File.expand_path(__FILE__ + "/../"))
28
+ puts "dir=#{dir}"
29
+ home_dir = ENV["HOME"] + "/" + dir.split("/")[-1].gsub(/-[0-9\.-]+/, "")
30
+ puts "home_dir=#{home_dir}"
31
+
32
+ if opt[:config_file] == nil
33
+ json = JSON.parse(File.read("#{home_dir}/config/setting.json"))
34
+ else
35
+ json = JSON.parse(File.read(opt[:config_file]))
36
+ end
37
+ json_config = config_json_hash(json)
38
+
39
+ file = "#{dir}/lib/create_uml_class.rb"
40
+ puts file
41
+ load file
42
+
43
+ @config = json_config
44
+ uml = create_uml_class(in_dir, out_file)
45
+
46
+ File.open(out_file, "w") do |f|
47
+ f.puts uml
48
+ end
49
+
50
+ # PlantUMLの実行
51
+ out_svg = out_file.gsub(File.extname(out_file), "") + ".svg"
52
+ FileUtils.rm_f out_svg
53
+ cmd = "#{@config["plantuml"]} #{out_file}"
54
+ puts cmd
55
+ system cmd
56
+ if File.exist? out_svg
57
+ puts File.binread out_file
58
+ puts "create #{out_svg}"
59
+ else
60
+ puts "plantuml error"
61
+ puts cmd
62
+ end
@@ -0,0 +1 @@
1
+ *.mp4 filter=lfs diff=lfs merge=lfs -text
@@ -0,0 +1,3 @@
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:43fb6dce6aa5c9aeee337d06b1eff8dd56235077773f7380a464a256b93d9e40
3
+ size 37373705
Binary file
data/img/setting.png ADDED
Binary file
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CppUmlClass
4
- VERSION = "0.6.0"
4
+ VERSION = "0.7.0"
5
5
  end
@@ -15,9 +15,58 @@
15
15
  "select": "",
16
16
  "description": "UMLを開くエディタ"
17
17
  },
18
+ {
19
+ "name": "default_class_color",
20
+ "value": "#LightGray",
21
+ "type": "input",
22
+ "select": "",
23
+ "description": "デフォルトのクラス色"
24
+ },
25
+ {
26
+ "name": "class_color_path1",
27
+ "value": "(path1)",
28
+ "type": "input",
29
+ "select": "",
30
+ "description": "色を付けるクラスのソースパス1(正規表現)"
31
+ },
32
+ {
33
+ "name": "class_color1",
34
+ "value": "#LightBlue",
35
+ "type": "input",
36
+ "select": "",
37
+ "description": "ソースパスと一致するクラス色1"
38
+ },
39
+ {
40
+ "name": "class_color_path2",
41
+ "value": "(path2)",
42
+ "type": "input",
43
+ "select": "",
44
+ "description": "色を付けるクラスのソースパス2(正規表現)"
45
+ },
46
+ {
47
+ "name": "class_color2",
48
+ "value": "#LightGreen",
49
+ "type": "input",
50
+ "select": "",
51
+ "description": "ソースパスと一致するクラス色2"
52
+ },
53
+ {
54
+ "name": "class_color_path3",
55
+ "value": "(path3)",
56
+ "type": "input",
57
+ "select": "",
58
+ "description": "色を付けるクラスのソースパス3(正規表現)"
59
+ },
60
+ {
61
+ "name": "class_color3",
62
+ "value": "#orange",
63
+ "type": "input",
64
+ "select": "",
65
+ "description": "ソースパスと一致するクラス色3"
66
+ },
18
67
  {
19
68
  "name": "exclude_path",
20
- "value": "(/test/)",
69
+ "value": "(exclude_path)",
21
70
  "type": "input",
22
71
  "select": "",
23
72
  "description": "除外するパス(正規表現)"
@@ -10,7 +10,8 @@ CStruct = Struct.new(:type,
10
10
  :var_list,
11
11
  :method_list,
12
12
  :inherit_list,
13
- :composition_list)
13
+ :composition_list,
14
+ :class_color)
14
15
 
15
16
  def get_gcc_path
16
17
  kernel = Facter.value(:kernel)
@@ -43,18 +44,20 @@ def get_unifdef_path
43
44
  end
44
45
 
45
46
  def get_clang_format_path
47
+ dir = File.dirname(File.expand_path(__FILE__)) + "/"
46
48
  kernel = Facter.value(:kernel)
47
49
  if kernel == "windows"
48
50
  ENV["PATH"].split(";").each do |path|
49
51
  clang_format_path = "#{path}\\clang-format"
50
52
  if File.exists? clang_format_path
51
- return "rubyw " + clang_format_path + " --style=file:'.clang-format' "
53
+ return "rubyw " + clang_format_path + " --style=file:'#{dir}.clang-format' "
52
54
  end
53
55
  end
54
56
  return ""
55
57
  else
56
58
  end
57
- return "clang-format --style=file:'.clang-format' "
59
+ #puts "clang-format --style=file:'#{dir}.clang-format' "
60
+ return "clang-format --style=file:'#{dir}.clang-format' "
58
61
  end
59
62
 
60
63
  # ソースコードの整形
@@ -108,7 +111,7 @@ def print_uml(out, out_list)
108
111
  out.push "namespace #{o_list.name} {"
109
112
  elsif o_list.type == :class_end
110
113
  pp o_list if o_list.name == ""
111
- out.push "class #{o_list.name} {"
114
+ out.push "class #{o_list.name} #{o_list.class_color}{"
112
115
  # インスタンス変数の出力
113
116
  o_list.var_list.uniq.each do |iv|
114
117
  out.push iv
@@ -120,11 +123,11 @@ def print_uml(out, out_list)
120
123
  out.push "}"
121
124
  # 継承リストの出力
122
125
  o_list.inherit_list.each do |ih|
123
- out.push "#{o_list.name} -[#blue]--|> #{ih}"
126
+ out.push "#{o_list.name} -[#black]--|> #{ih}"
124
127
  end
125
128
  # compo
126
129
  o_list.composition_list.uniq.each do |co|
127
- out.push "#{o_list.name} *-[#green]-- #{co}"
130
+ out.push "#{o_list.name} *-[#{o_list.class_color}]-- #{co}"
128
131
  end
129
132
  elsif o_list.type == :module_end
130
133
  # インスタンス変数がある場合はモジュール名と同じクラスを定義
@@ -145,11 +148,11 @@ def print_uml(out, out_list)
145
148
  out.push "}"
146
149
  # 継承リストの出力
147
150
  o_list.inherit_list.each do |ih|
148
- out.push "#{o_list.name} -[#blue]--|> #{ih}"
151
+ out.push "#{o_list.name} -[#black]--|> #{ih}"
149
152
  end
150
153
  # compo
151
154
  o_list.composition_list.uniq.each do |co|
152
- out.push "#{o_list.name} *-[#green]-- #{co}"
155
+ out.push "#{o_list.name} *-[#{o_list.class_color}]-- #{co}"
153
156
  end
154
157
  end
155
158
  out.push "}"
@@ -204,7 +207,7 @@ def composition_list_create(in_dir, out_list)
204
207
  #base_name = work.split(" : ")[1].to_s.split(" ")[1].to_s.gsub(/<.*>/, "")
205
208
  #puts "start class #{class_name}"
206
209
  if class_name.to_s != ""
207
- cstruct_list.push CStruct.new(:class_end, class_name, block_count, [], [], [], [])
210
+ cstruct_list.push CStruct.new(:class_start, class_name, block_count, [], [], [], [])
208
211
  end
209
212
  end
210
213
  # 関数の開始
@@ -318,7 +321,16 @@ def create_uml_class(in_dir, out_file)
318
321
  next
319
322
  end
320
323
  out_list.push CStruct.new(:class_start, class_name, block_count, [], [], [], [])
321
- cstruct_list.push CStruct.new(:class_end, class_name, block_count, [], [], [], [])
324
+ if @config["class_color_path1"].to_s != "" and file =~ Regexp.new(@config["class_color_path1"])
325
+ cstruct_list.push CStruct.new(:class_end, class_name, block_count, [], [], [], [], @config["class_color1"])
326
+ elsif @config["class_color_path2"].to_s != "" and file =~ Regexp.new(@config["class_color_path2"])
327
+ cstruct_list.push CStruct.new(:class_end, class_name, block_count, [], [], [], [], @config["class_color2"])
328
+ elsif @config["class_color_path3"].to_s != "" and file =~ Regexp.new(@config["class_color_path3"])
329
+ pp file
330
+ cstruct_list.push CStruct.new(:class_end, class_name, block_count, [], [], [], [], @config["class_color3"])
331
+ else
332
+ cstruct_list.push CStruct.new(:class_end, class_name, block_count, [], [], [], [], @config["default_class_color"])
333
+ end
322
334
  base_name.each do |name|
323
335
  name.gsub!(/,/, "")
324
336
  #puts "base_name=#{name}"
data/lib/css/index.css CHANGED
@@ -94,7 +94,7 @@ textarea.long {
94
94
  }
95
95
 
96
96
  .setting_name {
97
- width: 200px;
97
+ width: 300px;
98
98
  color: #ffffff;
99
99
  background-color: #000000;
100
100
  font-size: 14px;
data/lib/js/main.js CHANGED
@@ -252,8 +252,8 @@ function setting_dialog(open_id, dialog_id, json_file) {
252
252
  , show: "slide" //表示時のアニメーション
253
253
  , hide: "explode" //閉じた時のアニメーション
254
254
  , title: "Setting" //ダイアログのタイトル
255
- , width: 580 //ダイアログの横幅
256
- , height: 400 //ダイアログの高さ
255
+ , width: 650 //ダイアログの横幅
256
+ , height: 500 //ダイアログの高さ
257
257
  , resizable: true //リサイズ可
258
258
  , closeOnEscape: false //[ESC]キーで閉じられなくする
259
259
  , draggable: true //ダイアログの移動を可に
@@ -384,10 +384,10 @@ function openFile(file) {
384
384
  $(document).ready(function () {
385
385
 
386
386
  // サーバに接続
387
- server_connect("ws://localhost:38249/wsserver")
387
+ server_connect("ws://localhost:34731/wsserver")
388
388
  window.onload = function (e) {
389
389
  // サーバに接続
390
- //server_connect("ws://localhost:38249/wsserver")
390
+ //server_connect("ws://localhost:34731/wsserver")
391
391
  }
392
392
 
393
393
  // menu
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: CppUmlClass
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masataka Kuwayama
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-03-18 00:00:00.000000000 Z
11
+ date: 2025-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: browser_app_base
@@ -28,6 +28,7 @@ description: Create a C++ UML class diagram.
28
28
  email:
29
29
  - masataka.kuwayama@gmail.com
30
30
  executables:
31
+ - create_cpp_uml_class.rb
31
32
  - start_cpp_uml_class.rb
32
33
  - start_cpp_uml_class.rbw
33
34
  extensions: []
@@ -44,8 +45,13 @@ files:
44
45
  - Rakefile
45
46
  - bin/console
46
47
  - bin/setup
48
+ - exe/create_cpp_uml_class.rb
47
49
  - exe/start_cpp_uml_class.rb
48
50
  - exe/start_cpp_uml_class.rbw
51
+ - img/.gitattributes
52
+ - img/CppUMLClass.mp4
53
+ - img/class_color.png
54
+ - img/setting.png
49
55
  - lib/.clang-format
50
56
  - lib/CppUmlClass.rb
51
57
  - lib/CppUmlClass/version.rb