CppUmlClass 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f7f0347e68b39b11f5e5b6c00d5bba5c8b713de6e8af5a2dd90f78c944763667
4
- data.tar.gz: ef8248ea3089eae00731fd50054a70d8dd65e67f9f16050c35052f976b4eda57
3
+ metadata.gz: 5c8504de4c9118c846499f11af1ef896b3dc88ff8d4f00d3f6011e52a6b1a79f
4
+ data.tar.gz: 0d45624d9d2089800b0bd66cc9e58cdcd69409b903fdc7b84b01b1bac1211d6a
5
5
  SHA512:
6
- metadata.gz: 218c35e46d77a15e77f6377595d9d5667a5bc71618a3f48b9adff2eed2f86da763d62216041ce1d7cb6c51103846ad4266ac1f5bf817c7d8cd26260980f8fac1
7
- data.tar.gz: 45eab9d076867651ef67c850d56738fa4c91248c0e480f2c6ed8369ffc1a7d94d607a837fd83848bb7c99a322dd3cc18acb3e1128511c67eeafc4a8faeaaf382
6
+ metadata.gz: 569cc2d319a77e8e914af09983071b55b1a6d429fa8dae0ed44127e8320b95402f8cacfca8ce0344d0d6d08fd2d615a0f25aeb8a522cf3dba50bf3394e9fdfad
7
+ data.tar.gz: 8440742f0a2628cdfccaf195d8a1ed3621ad2841eafdc0e3059f44649d0eb252f4472e8663a4141d891085e5e2e2c0cdd3e6015922e69141f0b2638740bd9571
data/README.md CHANGED
@@ -4,8 +4,13 @@ CppUmlClass creates a C++ class diagram.
4
4
  PlantUML and rufo commands are used to create class diagrams.
5
5
  The created class diagram is displayed on the browser screen.
6
6
 
7
- ## Setup
7
+ ## ruby setup
8
8
  for ubuntu
9
+ $ sudo apt install ruby ruby-all-dev
10
+
11
+ ## CppUmlClass Setup
12
+ for ubuntu
13
+ $ sudo apt install chromium-browser
9
14
  $ sudo apt install plantuml
10
15
  $ sudo apt install clang-format
11
16
  $ sudo apt install gcc
@@ -14,11 +19,11 @@ The created class diagram is displayed on the browser screen.
14
19
 
15
20
  Install the gem and add to the application's Gemfile by executing:
16
21
 
17
- $ bundle add cpp_uml_class
22
+ $ bundle add CppUmlClass
18
23
 
19
24
  If bundler is not being used to manage dependencies, install the gem by executing:
20
25
 
21
- $ gem install cpp_uml_class
26
+ $ sudo gem install CppUmlClass
22
27
 
23
28
  ## Usage
24
29
 
@@ -32,7 +37,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
37
 
33
38
  ## Contributing
34
39
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/kuwayama1971/RubyUmlClass.
40
+ Bug reports and pull requests are welcome on GitHub at https://github.com/kuwayama1971/CppUmlClass.
36
41
 
37
42
  ## License
38
43
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CppUmlClass
4
- VERSION = "0.2.0"
4
+ VERSION = "0.4.0"
5
5
  end
data/lib/check_word.rb CHANGED
@@ -14,6 +14,10 @@ def check_word(buf, check_word)
14
14
  end
15
15
 
16
16
  if $0 == __FILE__
17
- buf = File.read(ARGV[0])
18
- check_word(buf, ARGV[1])
17
+ File.read(ARGV[0]).each_line do |line|
18
+ puts line
19
+ if check_word(line, ARGV[1])
20
+ puts "ok"
21
+ end
22
+ end
19
23
  end
@@ -120,11 +120,11 @@ def print_uml(out, out_list)
120
120
  out.push "}"
121
121
  # 継承リストの出力
122
122
  o_list.inherit_list.each do |ih|
123
- out.push "#{o_list.name} -[#blue]-|> #{ih}"
123
+ out.push "#{o_list.name} -[#blue]--|> #{ih}"
124
124
  end
125
125
  # compo
126
126
  o_list.composition_list.uniq.each do |co|
127
- out.push "#{o_list.name} *-[#green]- #{co}"
127
+ out.push "#{o_list.name} *-[#green]-- #{co}"
128
128
  end
129
129
  elsif o_list.type == :module_end
130
130
  # インスタンス変数がある場合はモジュール名と同じクラスを定義
@@ -145,11 +145,11 @@ def print_uml(out, out_list)
145
145
  out.push "}"
146
146
  # 継承リストの出力
147
147
  o_list.inherit_list.each do |ih|
148
- out.push "#{o_list.name} -[#blue]-|> #{ih}"
148
+ out.push "#{o_list.name} -[#blue]--|> #{ih}"
149
149
  end
150
150
  # compo
151
151
  o_list.composition_list.uniq.each do |co|
152
- out.push "#{o_list.name} *-[#green]- #{co}"
152
+ out.push "#{o_list.name} *-[#green]-- #{co}"
153
153
  end
154
154
  end
155
155
  out.push "}"
@@ -163,12 +163,12 @@ end
163
163
 
164
164
  def composition_list_create(in_dir, out_list)
165
165
  # composition_list
166
- Dir.glob("#{in_dir}/**/*.{cpp,hpp}") do |file|
167
- if file =~ Regexp.new(@config["exclude_path"])
168
- puts "skip #{file}"
166
+ Dir.glob("#{in_dir}/**/*.{h,cpp,hpp}") do |file|
167
+ if @config["exclude_path"].to_s != "" and file =~ Regexp.new(@config["exclude_path"])
168
+ #puts "skip #{file}"
169
169
  next
170
170
  end
171
- puts file
171
+ #puts file
172
172
  # ソースコードの整形
173
173
  buf = update_source(file)
174
174
  # ソースを解析
@@ -177,7 +177,7 @@ def composition_list_create(in_dir, out_list)
177
177
  buf.each_line do |line|
178
178
  next if line =~ /^[\r\n]*$/ # 空行は対象外
179
179
  next if line =~ /^#/ # #から始まる行は対象外
180
- puts line
180
+ #puts "comp:#{line}"
181
181
 
182
182
  # ブロックの開始/終了
183
183
  if line.match(/\{/)
@@ -186,7 +186,7 @@ def composition_list_create(in_dir, out_list)
186
186
  if line.match(/\}/)
187
187
  block_count -= 1
188
188
  end
189
- puts "block_count=#{block_count}"
189
+ #puts "comp:block_count=#{block_count}"
190
190
 
191
191
  # classの開始
192
192
  #if line =~ /^\s*(class)\s/ and File.extname(file) == ".h"
@@ -194,22 +194,23 @@ def composition_list_create(in_dir, out_list)
194
194
  next if line =~ /;$/
195
195
  work = line.gsub(/(class|struct)/, "")
196
196
  class_name = work.split(" : ")[0].to_s.chomp.match(/ [A-Za-z0-9_:]+/).to_s.split(" ")[0]
197
- base_name = work.split(" : ")[1].to_s.split(" ")[1].to_s.gsub(/<.*>/, "")
198
- puts "start class #{class_name}"
199
- cstruct_list.push CStruct.new(:class_end, class_name, block_count, [], [], [], [])
197
+ #base_name = work.split(" : ")[1].to_s.split(" ")[1].to_s.gsub(/<.*>/, "")
198
+ #puts "start class #{class_name}"
199
+ if class_name.to_s != ""
200
+ cstruct_list.push CStruct.new(:class_end, class_name, block_count, [], [], [], [])
201
+ end
200
202
  end
201
-
202
203
  # 関数の開始
203
204
  #if line =~ /^\S+::\S+/
204
205
  if line.gsub(/<.*>/, "") =~ /^\S.*(\S+)::(\S+).*\(.*{$/ and
205
206
  (File.extname(file) == ".cpp" or File.extname(file) == ".hpp")
206
- puts "method start"
207
+ #puts "comp:method start"
207
208
  #class_name = line.match(/(\w+)(?=<\w*,?\s*\w*>?::\w+\(\))/).to_s
208
209
  #class_name = line.match(/(\w+)(?=::\S+\(\))/).to_s if class_name == ""
209
210
  #class_name = line.match(/(\w+(?:::\w+)*)(?=::\w+\(.*\))/).to_s if class_name == ""
210
211
  #class_name = class_name.split("::")[1] if class_name =~ /::/
211
212
  line.gsub(/<.*>/, "").match(/(\w+)(?=\S+\()/) do |m|
212
- puts "class_name=#{m}"
213
+ #puts "comp:class_name=#{m}"
213
214
  cstruct_list.push CStruct.new(:method_start, m.to_s, block_count, [], [], [], [])
214
215
  break
215
216
  end
@@ -225,10 +226,10 @@ def composition_list_create(in_dir, out_list)
225
226
  class_block_count = cstruct_list[-1].block_count
226
227
  if block_count == (class_block_count - 1) # block_countが一致
227
228
  # 関数の終了
228
- puts "method end #{cstruct_list[-1].name}"
229
+ #puts "comp:method end #{cstruct_list[-1].name}"
229
230
  cstruct_list.slice!(-1) # 最後の要素を削除
230
231
  else
231
- puts "#{File.basename(file)}:#{block_count}:line3=#{line}"
232
+ #puts "comp:#{File.basename(file)}:#{block_count}:line3=#{line}"
232
233
  my_class_name = cstruct_list[-1].name
233
234
  my_cstruct = out_list.select { |m| m.name == my_class_name }[1]
234
235
  #pp my_cstruct
@@ -237,7 +238,7 @@ def composition_list_create(in_dir, out_list)
237
238
  out_list.each do |clist|
238
239
  next if clist.name == my_cstruct.name
239
240
  use_class_name = clist.name
240
- puts "my_class_name=#{my_class_name} : use_class_name=#{use_class_name}"
241
+ #puts "my_class_name=#{my_class_name} : use_class_name=#{use_class_name}"
241
242
  if check_word(line, use_class_name)
242
243
  #if line.include?(use_class_name)
243
244
  my_cstruct.composition_list.push use_class_name
@@ -256,7 +257,7 @@ def create_uml_class(in_dir, out_file)
256
257
  out = []
257
258
  out.push "@startuml"
258
259
 
259
- puts "in_dir = #{in_dir}"
260
+ #puts "in_dir = #{in_dir}"
260
261
  main_composition_list = []
261
262
  main_method_list = []
262
263
  global_var = []
@@ -264,11 +265,11 @@ def create_uml_class(in_dir, out_file)
264
265
  out_list = []
265
266
  #Dir.glob("#{in_dir}/**/*.{cpp,hpp,h}") do |file|
266
267
  Dir.glob("#{in_dir}/**/*.{h}") do |file|
267
- if file =~ Regexp.new(@config["exclude_path"])
268
- puts "skip #{file}"
268
+ if @config["exclude_path"].to_s != "" and file =~ Regexp.new(@config["exclude_path"])
269
+ #puts "skip #{file}"
269
270
  next
270
271
  end
271
- puts file
272
+ #puts file
272
273
  # ソースコードの整形
273
274
  buf = update_source(file)
274
275
 
@@ -280,7 +281,7 @@ def create_uml_class(in_dir, out_file)
280
281
  buf.each_line do |line|
281
282
  next if line =~ /^[\r\n]*$/ # 空行は対象外
282
283
  next if line =~ /^#/ # #から始まる行は対象外
283
- puts line
284
+ #puts line
284
285
 
285
286
  # ブロックの開始/終了
286
287
  if line.match(/\{/)
@@ -292,8 +293,11 @@ def create_uml_class(in_dir, out_file)
292
293
  # ブロックの終了
293
294
  if line.match(/\}/)
294
295
  block_count -= line.each_char.select { |c| c == "}" }.size
296
+ end_block = true
297
+ else
298
+ end_block = false
295
299
  end
296
- puts "block_count=#{block_count}"
300
+ #puts "block_count=#{block_count}"
297
301
 
298
302
  # classの開始
299
303
  #if line =~ /^\s*(class)\s/
@@ -301,11 +305,14 @@ def create_uml_class(in_dir, out_file)
301
305
  next if line =~ /;$/
302
306
  work = line.gsub(/(class|struct)/, "")
303
307
  class_name = work.split(" : ")[0].to_s.chomp.match(/ [A-Za-z0-9_:]+/).to_s.split(" ")[0]
304
- base_name = work.split(" : ")[1].to_s.gsub(/(public |private |protected )/, "").to_s.gsub(/<.*>/, "").split(" ")[0]
305
- puts "start class [#{class_name}]"
306
- if class_name == ""
308
+ base_name = []
309
+ work.split(" : ")[1].to_s.gsub(/(public |private |protected )/, "").to_s.gsub(/<.*>/, "").split(" ").each do |name|
310
+ base_name.push name if name =~ /\w+/
311
+ end
312
+ #puts "start class [#{class_name}]"
313
+ if class_name.to_s == ""
307
314
  puts file
308
- exit
315
+ next
309
316
  end
310
317
  #if out_list.size != 0 and out_list[-1].type == :class_start # classが連続している
311
318
  # class_name = out_list[-1].name + "." + class_name
@@ -316,10 +323,10 @@ def create_uml_class(in_dir, out_file)
316
323
  cstruct_list.push CStruct.new(:class_end, class_name, block_count, [], [], [], [])
317
324
  #end
318
325
  #pp line if class_name == ""
319
- if base_name.to_s != ""
320
- #base_name.gsub!(/::/, ".")
321
- puts "base_name=#{base_name}"
322
- cstruct_list[-1].inherit_list.push base_name
326
+ base_name.each do |name|
327
+ name.gsub!(/,/, "")
328
+ #puts "base_name=#{name}"
329
+ cstruct_list[-1].inherit_list.push name
323
330
  end
324
331
  end
325
332
 
@@ -339,7 +346,7 @@ def create_uml_class(in_dir, out_file)
339
346
  # 関数名を取り出す
340
347
  method = line.split(" : ")[0].gsub(/^\s+/, "")
341
348
  method = method.split(";")[0].split("{")[0]
342
- puts "method=#{method}"
349
+ #puts "method=#{method}"
343
350
  method_list = cstruct_list[-1].method_list
344
351
  case method_type
345
352
  when :public
@@ -354,7 +361,9 @@ def create_uml_class(in_dir, out_file)
354
361
 
355
362
  # class変数
356
363
  # 括弧を含まない、かつtemplateを含まない文字列
357
- if cstruct_list.size != 0 and block_count == cstruct_list[-1].block_count
364
+ if cstruct_list.size != 0 and
365
+ (block_count == cstruct_list[-1].block_count or
366
+ (end_block == true and block_count + 1 == cstruct_list[-1].block_count))
358
367
  if line =~ /^[^(){}]*$/ and
359
368
  line =~ /^((?!\/tmp\/).)*$/ and
360
369
  line =~ /^((?!namespace).)*$/ and
@@ -362,7 +371,7 @@ def create_uml_class(in_dir, out_file)
362
371
  line =~ /^((?!public:).)*$/ and
363
372
  line =~ /^((?!private:).)*$/ and
364
373
  line =~ /^((?!protected:).)*$/
365
- puts "class member=#{line}"
374
+ #puts "class member=#{line}"
366
375
  #val = line.split("=")[0].split(" ")[-1]
367
376
  val = line.split("=")[0]
368
377
  val = val.split(";")[0]
@@ -382,7 +391,7 @@ def create_uml_class(in_dir, out_file)
382
391
  if cstruct_list.size != 0
383
392
  class_block_count = cstruct_list[-1].block_count
384
393
  if block_count == (class_block_count - 1) # block_countが一致
385
- puts "class end #{cstruct_list[-1].name}"
394
+ #puts "class end #{cstruct_list[-1].name}"
386
395
  out_list.push cstruct_list[-1]
387
396
  cstruct_list.slice!(-1) # 最後の要素を削除
388
397
  end
@@ -422,7 +431,7 @@ def create_uml_class(in_dir, out_file)
422
431
  end
423
432
 
424
433
  def search_func(file)
425
- puts file
434
+ #puts file
426
435
  # ソースコードの整形
427
436
  buf = update_source(file)
428
437
  # ソースを解析
@@ -431,9 +440,9 @@ def search_func(file)
431
440
  next if line =~ /^#/ # #から始まる行は対象外
432
441
  #puts line
433
442
  if line.gsub(/<.*>/, "") =~ /^\S.*(\S+)::(\S+).*\(.*{$/
434
- puts line.gsub!(/<.*>/, "")
443
+ #puts line.gsub!(/<.*>/, "")
435
444
  line.match(/(\w+)(?=\S+\()/) do |m|
436
- puts "class_name=#{m}"
445
+ #puts "class_name=#{m}"
437
446
  end
438
447
  end
439
448
  end
data/lib/css/index.css CHANGED
@@ -2,7 +2,7 @@ body {
2
2
  color: #000000;
3
3
  background-color: #cac3ec4f;
4
4
  overflow: hidden;
5
- font-size: 12px;
5
+ font-size: 14px;
6
6
  }
7
7
 
8
8
  hr {
@@ -49,7 +49,7 @@ textarea.long {
49
49
  }
50
50
 
51
51
  .ui-widget {
52
- font-size: 12px;
52
+ font-size: 14px;
53
53
  }
54
54
 
55
55
  .ui-autocomplete {
@@ -88,25 +88,29 @@ textarea.long {
88
88
  }
89
89
 
90
90
  #setting_dialog {
91
- color: #796fe9;
91
+ color: #ffffff;
92
92
  background-color: #000000;
93
+ font-size: 14px;
93
94
  }
94
95
 
95
96
  .setting_name {
96
97
  width: 200px;
97
- color: #796fe9;
98
+ color: #ffffff;
98
99
  background-color: #000000;
100
+ font-size: 14px;
99
101
  }
100
102
 
101
103
  .setting_value {
102
104
  width: 300px;
103
- color: #796fe9;
105
+ color: #ffffff;
104
106
  background-color: #000000;
107
+ font-size: 14px;
105
108
  }
106
109
 
107
110
  .setting_checkbox {
108
- color: #796fe9;
111
+ color: #ffffff;
109
112
  background-color: #000000;
113
+ font-size: 14px;
110
114
  }
111
115
 
112
116
  ul.log {
@@ -130,7 +134,7 @@ input[type="search"]::-webkit-search-cancel-button {
130
134
  list-style-type: none;
131
135
  color: #393737;
132
136
  padding: 0;
133
- font-size: 12px;
137
+ font-size: 14px;
134
138
  font-weight: bold;
135
139
  }
136
140
 
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.2.0
4
+ version: 0.4.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-03 00:00:00.000000000 Z
11
+ date: 2025-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: browser_app_base