show_dependency 0.0.3 → 0.0.4

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
  SHA1:
3
- metadata.gz: 9639b93dfd59e4eafc396ee52bcc7514712c808a
4
- data.tar.gz: 5afc9ad199161b2117bf32541c5eae1a54b546d5
3
+ metadata.gz: 23ca1e3116090d45fd324e18d99f1eec8d3f9e04
4
+ data.tar.gz: 758745e1c423ff30d5a6edcf1d68e2d8bbf7a490
5
5
  SHA512:
6
- metadata.gz: 0f93c9f87308f6a2d4b4cdc3b920419bd2535752ffd892773b133a72d6e9a9d193d298819de6e76db6bc846e7f703c2d46a21645d716f43a76aa84049a81bab9
7
- data.tar.gz: 44c6eb5ba59660f2905a60a0ea17f1be1db13ac85706a4dfa4ef3376ad1154bcc235bff18d67fe78dc0695cc8f4adf2d70a93fc589583222638d68003471e8d0
6
+ metadata.gz: 53cf3cae951b433dd4cf0b7cb75fb86b116282aff4238d790510c39159f0394c647ad5c21808f171d36b5110f9004651dc420f90714c963c8451215a2862772b
7
+ data.tar.gz: 0d9fb3d1c311720d3c4f9837510f3a93dcb0f398ca0704c3b924b70101c42a11b855c1b89f16a98bfa861c05ae2388a29c5c4ea1a6fbc4646cf1656120c29459
data/.gitignore CHANGED
@@ -15,3 +15,5 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ /*.dot
19
+ /*.dot.???
@@ -6,7 +6,7 @@ unless (ARGV & ['-h', '--help']).empty?
6
6
  abort <<-EOS
7
7
  Syntax:
8
8
  #{__FILE__} [-O]
9
- -O auto create png file
9
+ -O auto create png file
10
10
  EOS
11
11
  end
12
12
 
@@ -1,12 +1,13 @@
1
1
  #!/usr/bin/env ruby -w
2
2
 
3
3
  require "ffi"
4
+ require "set"
4
5
 
5
6
  unless (ARGV & ['-h', '--help']).empty?
6
7
  abort <<-EOS
7
8
  Syntax:
8
9
  #{__FILE__} [-O]
9
- -O auto create png file
10
+ -O auto create png file
10
11
  EOS
11
12
  end
12
13
 
@@ -21,15 +22,20 @@ cls = FFI.constants.uniq.select{ |x| x !~ /Error/i }
21
22
 
22
23
  cls.sort_by! { |x| [x.ancestors.size, x.ancestors[1..-1].to_s] }
23
24
 
24
- gr_edges = []
25
- cls.each do |m|
26
- v = m.ancestors
27
- v.each_cons(2) do |x, y|
25
+ gr_edges = Set.new
26
+ gr_mods = Set.new
27
+ cls.each do |cl1|
28
+ ances = cl1.ancestors
29
+ ances.select { |x| x.class == Class }.each_cons(2) do |x, y|
28
30
  gr_edges << " #{format '%-22s', x.name.split('::')[-1]} -> #{y.name.split('::')[-1]}"
29
31
  end
32
+ ances[1..-1].each do |m|
33
+ break if m.class == Class
34
+ gr_edges << " #{format '%-22s', cl1.name.split('::')[-1]} -> #{m.name.split('::')[-1]} [color=green]"
35
+ gr_mods << " #{m.name.split('::')[-1]} [color=green]"
36
+ end
30
37
  end
31
38
 
32
- gr_edges.uniq!
33
39
  gr_most_use = %w{MemoryPointer Struct Union Enums Buffer }.map { |x| " #{x} [color=blue]" }
34
40
  #---------
35
41
 
@@ -42,7 +48,9 @@ else
42
48
  o = $stdout
43
49
  end
44
50
  o.puts "digraph G {"
45
- o.puts gr_edges
51
+ o.puts gr_edges.to_a.sort
52
+ o.puts
53
+ o.puts gr_mods.to_a.sort
46
54
  o.puts
47
55
  o.puts gr_most_use
48
56
  o.puts
@@ -7,7 +7,7 @@ unless (ARGV & ['-h', '--help']).empty?
7
7
  Syntax:
8
8
  #{__FILE__} [--dev] [-O]
9
9
  --dev show development dependency
10
- -O auto create png file
10
+ -O auto create png file
11
11
  EOS
12
12
  end
13
13
 
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "tk"
4
+
5
+ unless (ARGV & ['-h', '--help']).empty?
6
+ abort <<-EOS
7
+ Syntax:
8
+ #{__FILE__} [-O]
9
+ -O auto create png file
10
+ EOS
11
+ end
12
+
13
+ $auto_create_png = ARGV.delete('-O')
14
+
15
+ #---------
16
+ cls = []
17
+
18
+ Object.constants.each do |x|
19
+ if /(Tk|Ttk)/ =~ x
20
+ c = Object.const_get( x) rescue next
21
+ cls << c if Class === c
22
+ end
23
+ end
24
+ Tk.constants.each do |x|
25
+ c= Tk.const_get( x) rescue next
26
+ cls << c if Class === c
27
+ end
28
+ Ttk.constants.each do |x|
29
+ c = Ttk.const_get( x)
30
+ cls << c if Class === c
31
+ end
32
+ Tk::Tile.constants.each do |x|
33
+ c = Tk::Tile.const_get( x)
34
+ cls << c if Class === c
35
+ end
36
+
37
+ cls=cls.uniq.sort_by(&:name)
38
+
39
+
40
+ require "set"
41
+ ass = Set.new
42
+ mods = Set.new
43
+
44
+ cls.each do |cl1|
45
+ # [C1, M1, M2, M3, Object] --> add C1 -> Object and C1 -> M1 / C1->M2 / C1->M3
46
+ ances = cl1.ancestors
47
+ ances.select { |x| Class == x.class }.each_cons(2) do |x, y|
48
+ ass << %Q{ "#{x.name}" -> "#{y.name}"}
49
+ end
50
+ ances[1..-1].each do |m|
51
+ break if m.class == Class
52
+ ass << %Q{ "#{cl1.name}" -> "#{m.name}" [color=blue]}
53
+ mods << %Q{ "#{m.name}" [color=blue]}
54
+ end
55
+ end
56
+
57
+ #---------
58
+ if $auto_create_png
59
+ dotfn = "tk_cls.dot"
60
+ o = File.open(dotfn, 'w')
61
+ pngfn = dotfn + ".png"
62
+ else
63
+ o = $stdout
64
+ end
65
+ o.puts "digraph G {"
66
+ o.puts ass.to_a.sort
67
+ o.puts
68
+ o.puts mods.sort
69
+ o.puts
70
+ o.puts "}"
71
+
72
+ if pngfn
73
+ o.close
74
+ system "dot -Tpng -o#{pngfn} #{dotfn}"
75
+ end
@@ -1,3 +1,3 @@
1
1
  module ShowDependency
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: show_dependency
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - windwiny
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-16 00:00:00.000000000 Z
11
+ date: 2014-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -45,6 +45,7 @@ executables:
45
45
  - show_brew_depend.rb
46
46
  - show_ffi_inherit.rb
47
47
  - show_gems_depend.rb
48
+ - show_tk_inherit.rb
48
49
  extensions: []
49
50
  extra_rdoc_files: []
50
51
  files:
@@ -56,6 +57,7 @@ files:
56
57
  - bin/show_brew_depend.rb
57
58
  - bin/show_ffi_inherit.rb
58
59
  - bin/show_gems_depend.rb
60
+ - bin/show_tk_inherit.rb
59
61
  - lib/show_dependency.rb
60
62
  - lib/show_dependency/version.rb
61
63
  - show_dependency.gemspec