cxxproject_stats 0.0.8 → 0.0.9

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a239e2180112703eb40f1750dd948d14b4dad99b
4
+ data.tar.gz: 2bab311e33818c95630bb40b105b52d882472d87
5
+ SHA512:
6
+ metadata.gz: 9890d1a3aa5598e0a00781a1c268538be3c40b729884963b272e3f9c5bbab1faf3481e2b728c1422740db4cc894343024c0aa055af31e695568a74697f1a1801
7
+ data.tar.gz: a38d07f2e4c9900c016e27fae797804ee59a93a8dbab8dc79239d7925f16b7cf26423d413806f7d7afa0804c696b54c6b4a2147afcef90f364999b6de5bc6e98
@@ -12,10 +12,14 @@ cxx_plugin do |ruby_dsl, building_blocks, log|
12
12
  io.puts(indent + '%div.details')
13
13
  bbs.each do |bb|
14
14
  if bb.kind_of?(Cxxproject::HasSources)
15
- io.puts(indent + " %p Sources of #{bb.name}: #{bb.sources.size}")
16
- io.puts(indent + ' %ul')
15
+ io.puts(indent + ' %table')
16
+ io.puts(indent + ' %tr')
17
+ io.puts(indent + ' %td')
18
+ io.puts(indent + " %img{:src=>\"#{bb.name}.svg\"}")
19
+ io.puts(indent + ' %td')
20
+ io.puts(indent + ' %ul')
17
21
  bb.sources.each do |s|
18
- io.puts(indent + " %li #{s}")
22
+ io.puts(indent + " %li #{s}")
19
23
  end
20
24
  end
21
25
  end
@@ -32,8 +36,76 @@ cxx_plugin do |ruby_dsl, building_blocks, log|
32
36
 
33
37
  directory ruby_dsl.build_dir
34
38
 
39
+ def dot_for_exe
40
+ "tab"
41
+ end
42
+ def dot_for_static
43
+ "folder"
44
+ end
45
+ def dot_for_shared
46
+ "component"
47
+ end
48
+ def dot_for_binary
49
+ "box"
50
+ end
51
+ def building_block_to_shape(bb, log)
52
+ if bb.is_a?(Cxxproject::Executable)
53
+ return dot_for_exe
54
+ elsif bb.is_a?(Cxxproject::StaticLibrary)
55
+ return dot_for_static
56
+ elsif bb.is_a?(Cxxproject::SharedLibrary)
57
+ return dot_for_shared
58
+ elsif bb.is_a?(Cxxproject::BinaryLibrary)
59
+ return dot_for_binary
60
+ else
61
+ log.error "unknown building block: #{bb}"
62
+ return "plaintext"
63
+ end
64
+ end
65
+
66
+ def write_svg(name, ruby_dsl, &block)
67
+ dot_file = File.join(ruby_dsl.build_dir, "#{name}.dot")
68
+ svg_file = File.join(ruby_dsl.build_dir, "#{name}.svg")
69
+ File.open(dot_file, 'w') do |out|
70
+ block.call(out)
71
+ end
72
+ sh "dot -Tsvg #{dot_file} -o#{svg_file}"
73
+ end
74
+
35
75
  desc 'print building block stats'
36
76
  task :stats => ruby_dsl.build_dir do
77
+ write_svg('dependencies', ruby_dsl) do |out|
78
+ out.puts("digraph DependencyTree {")
79
+ building_blocks.each do |name, bb|
80
+ out.puts("\"#{name}\" [shape=\"#{building_block_to_shape(bb, log)}\"];")
81
+ bb.dependencies.each do |d|
82
+ out.puts("\"#{name}\" -> \"#{d}\"")
83
+ end
84
+ end
85
+ out.puts(" subgraph cluster_legend {")
86
+ out.puts(" label = \"Legend\";")
87
+ out.puts(" edge [style=invis];")
88
+ out.puts(" graph[style=dotted];")
89
+ out.puts(" \"executables\" [shape=\"#{dot_for_exe}\"];")
90
+ out.puts(" \"static libraries\" [shape=\"#{dot_for_static}\"];")
91
+ out.puts(" \"shared libraries\" [shape=\"#{dot_for_shared}\"];")
92
+ out.puts(" \"binary libraries\" [shape=\"#{dot_for_binary}\"];")
93
+ out.puts(" \"executables\" -> \"static libraries\" -> \"shared libraries\" -> \"binary libraries\";")
94
+ out.puts(" }")
95
+ out.puts("}")
96
+ end
97
+
98
+ building_blocks.each do |name, bb|
99
+ if bb.kind_of?(Cxxproject::HasSources)
100
+ template = "digraph DependencyTree { \"#{name}\" [shape=\"#{building_block_to_shape(bb, log)}\", label=\<\<table border=\"0\"><tr><td align=\"left\">Name:</td><td align=\"left\">#{name}</td></tr><tr><td align=\"left\">Sources:</td><td align=\"left\">#{bb.sources.size}</td></tr></table>> ];}"
101
+ dot_file = File.join(ruby_dsl.build_dir, "#{name}.dot")
102
+ svg_file = File.join(ruby_dsl.build_dir, "#{name}.svg")
103
+ write_svg(name, ruby_dsl) do |io|
104
+ io.puts(template)
105
+ end
106
+ end
107
+ end
108
+
37
109
  io = StringIO.new
38
110
  io.puts('%html')
39
111
  io.puts(' %head')
@@ -44,10 +116,10 @@ cxx_plugin do |ruby_dsl, building_blocks, log|
44
116
  io.puts(' %body')
45
117
  res = building_blocks.inject(io) do |memo, pair|
46
118
  key, bb = pair
47
- log.error building_blocks.size
48
119
  handle_exe(memo, building_blocks, bb, ' '*4, log)
49
120
  memo
50
121
  end
122
+ io.puts(' %img{:src=>"dependencies.svg"}')
51
123
  engine = Haml::Engine.new(io.string)
52
124
  File.open(File.join(ruby_dsl.build_dir, 'stats.out.html'), 'w') do |out|
53
125
  out.puts(engine.render)
@@ -1,3 +1,3 @@
1
1
  module CxxprojectStats
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
metadata CHANGED
@@ -1,46 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cxxproject_stats
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
5
- prerelease:
4
+ version: 0.0.9
6
5
  platform: ruby
7
6
  authors:
8
7
  - Christian Köstlin
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-09-10 00:00:00.000000000 Z
11
+ date: 2016-08-23 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: cxx
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: haml
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  description: creates some stats for cxx-projects
@@ -50,37 +45,32 @@ executables: []
50
45
  extensions: []
51
46
  extra_rdoc_files: []
52
47
  files:
53
- - .gitignore
54
- - Gemfile
55
48
  - LICENSE
56
49
  - README.md
57
- - Rakefile
58
- - cxxproject_stats.gemspec
59
50
  - lib/cxxproject_stats.rb
60
51
  - lib/cxxproject_stats/plugin.rb
61
52
  - lib/cxxproject_stats/version.rb
62
53
  homepage: http://marcmo.github.com/cxxproject/
63
54
  licenses: []
55
+ metadata: {}
64
56
  post_install_message:
65
57
  rdoc_options: []
66
58
  require_paths:
67
59
  - lib
68
60
  required_ruby_version: !ruby/object:Gem::Requirement
69
- none: false
70
61
  requirements:
71
- - - ! '>='
62
+ - - ">="
72
63
  - !ruby/object:Gem::Version
73
64
  version: '0'
74
65
  required_rubygems_version: !ruby/object:Gem::Requirement
75
- none: false
76
66
  requirements:
77
- - - ! '>='
67
+ - - ">="
78
68
  - !ruby/object:Gem::Version
79
69
  version: '0'
80
70
  requirements: []
81
71
  rubyforge_project:
82
- rubygems_version: 1.8.24
72
+ rubygems_version: 2.5.1
83
73
  signing_key:
84
- specification_version: 3
85
- summary: ! '...'
74
+ specification_version: 4
75
+ summary: "..."
86
76
  test_files: []
data/.gitignore DELETED
@@ -1,17 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in cxxproject_stats.gemspec
4
- gemspec
data/Rakefile DELETED
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env rake
2
- require "bundler/gem_tasks"
3
-
4
- task :package => :build
5
- task :clobber_package do
6
- sh 'rm -rf pkg'
7
- end
8
-
9
- task :default => :package
@@ -1,22 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- gem_name = 'cxxproject_stats'
3
- require File.expand_path("lib/#{gem_name}/version")
4
-
5
- Gem::Specification.new do |gem|
6
- gem.name = gem_name
7
- gem.version = CxxprojectStats::VERSION
8
-
9
- gem.authors = ["Christian Köstlin"]
10
- gem.email = ["christian.koestlin@esrlabs.com"]
11
- gem.description = %q{creates some stats for cxx-projects}
12
- gem.summary = %q{...}
13
- gem.homepage = "http://marcmo.github.com/cxxproject/"
14
-
15
- gem.files = `git ls-files`.split($\)
16
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
- gem.require_paths = ["lib"]
19
-
20
- gem.add_dependency 'cxx'
21
- gem.add_dependency 'haml'
22
- end