show_dependency 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 044ccbeff0b392c005136e2c38e84da36a19b199
4
+ data.tar.gz: 2f7420004936a96bf6ee2f555c29d8000ebd4429
5
+ SHA512:
6
+ metadata.gz: d093d6ca032cdb6b947a9ceb37a692ccb067fb5a638f853bd1e36bd37505550859624f07282c3132dd2283deab50143c2997bdaee2120fa276310b7b8f16c096
7
+ data.tar.gz: 8429c20843790d27256df82886f03ead111b9f423695764eea85e3ed398bd6f9148c139d934d252184f23626e52d043935584788fb33821c9f623bb1022020f5
data/.gitignore ADDED
@@ -0,0 +1,17 @@
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 ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in show_dependency.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 windwiny
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # ShowDependency
2
+
3
+ create dependency digraph
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'show_dependency'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install show_dependency
18
+
19
+ ## Usage
20
+
21
+ ruby bin/show_xxx.rb --help
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( http://github.com/<my-github-username>/show_dependency/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env ruby -w
2
+
3
+ require "set"
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
+ COLOR_MISSING = 'red'
17
+ COLOR_NODEP = 'green'
18
+ COLOR_NOTE = 'brown'
19
+
20
+ pgs = %x{brew list}.split.sort
21
+ gr_edges = Set.new
22
+ node_deps = Set.new
23
+
24
+ pgs.each do |pg|
25
+ deps = %x{brew deps --1 #{pg}}.split rescue next
26
+ node_deps += deps
27
+ deps.each do |x|
28
+ gr_edges << %Q{ "#{pg}" -> "#{x}"}
29
+ end
30
+ end
31
+ gr_edges = gr_edges.to_a.sort
32
+ node_deps = node_deps.to_a.sort
33
+
34
+ gr_indep_nodes = (pgs - node_deps).map { |x| %Q{ "#{x}" [color=#{COLOR_NODEP}]} }
35
+ gr_mis_nodes = (node_deps - pgs).map { |x| %Q{ "#{x}" [color=#{COLOR_MISSING}]} }
36
+
37
+ msg = "Program Count: #{pgs.size}. Independed: #{gr_indep_nodes.size}; Missed: #{gr_mis_nodes.size}"
38
+ gr_box_summary = %Q{ summary [shape=note, color=#{COLOR_NOTE}, label="#{msg}"]}
39
+ #---------
40
+
41
+
42
+ if $auto_create_png
43
+ dotfn = "#{File.basename(__FILE__, '.rb')}_#{Time.now.strftime '%Y%m%d%H%M%S'}.dot"
44
+ o = File.open(dotfn, 'w')
45
+ pngfn = dotfn + ".png"
46
+ else
47
+ o = $stdout
48
+ end
49
+ o.puts "digraph G {"
50
+ o.puts gr_box_summary
51
+ o.puts
52
+ o.puts gr_edges
53
+ o.puts
54
+ o.puts gr_indep_nodes
55
+ o.puts
56
+ o.puts gr_mis_nodes
57
+ o.puts
58
+ o.puts "}"
59
+
60
+ if pngfn
61
+ o.close
62
+ system "dot -Tpng -o#{pngfn} #{dotfn}"
63
+ end
@@ -0,0 +1,121 @@
1
+ #!/usr/bin/env ruby -w
2
+
3
+ require "set"
4
+
5
+ unless (ARGV & ['-h', '--help']).empty?
6
+ abort <<-EOS
7
+ Syntax:
8
+ #{__FILE__} [--dev] [-O]
9
+ --dev show development dependency
10
+ -O auto create png file
11
+ EOS
12
+ end
13
+
14
+ $create_development = ARGV.delete('--dev')
15
+ $auto_create_png = ARGV.delete('-O')
16
+
17
+ COLOR_MISSING = 'red'
18
+ COLOR_NODEP = 'green'
19
+ COLOR_DEVELOPMENT = 'blue'
20
+ COLOR_NOTE = 'brown'
21
+
22
+ gr_edges = Set.new
23
+ node_all = Set.new
24
+ node_in_left = Set.new
25
+ node_in_right = Set.new
26
+
27
+ def find_latest_gem(dependency)
28
+ $gems ||= Gem::Specification.group_by { |spec| spec.name }
29
+ gems = $gems[dependency.name]
30
+ return if !gems
31
+
32
+ gems.reverse.find do |spec|
33
+ dependency.matches_spec?(spec)
34
+ end
35
+ end
36
+
37
+
38
+ Gem::Specification.each do |spec|
39
+ namever = %Q{"#{spec.name}-#{spec.version}"}
40
+ node_all << namever
41
+ spec.dependencies.each do |d|
42
+ if d.type == :runtime
43
+ g1 = find_latest_gem(d)
44
+ if g1
45
+ dep_namever = %Q{"#{g1.name}-#{g1.version}"}
46
+ node_in_left << namever
47
+ node_in_right << dep_namever
48
+ gr_edges << " #{namever} -> #{dep_namever}"
49
+ else
50
+ req_list = %Q{"#{d.name}\\n#{d.requirement.as_list.to_s.gsub '"', '\"'}"}
51
+ gr_edges << " #{namever} -> #{req_list} [color=#{COLOR_MISSING}]"
52
+ end
53
+ elsif d.type == :development && $create_development != nil
54
+ g1 = find_latest_gem(d)
55
+ if g1
56
+ dep_namever = %Q{"#{g1.name}-#{g1.version}"}
57
+ node_in_left << namever
58
+ node_in_right << dep_namever
59
+ gr_edges << " #{namever} -> #{dep_namever} [color=#{COLOR_DEVELOPMENT}]"
60
+ else
61
+ req_list = %Q{"#{d.name}\\n#{d.requirement.as_list.to_s.gsub '"', '\"'}"}
62
+ gr_edges << " #{namever} -> #{req_list} [color=#{COLOR_MISSING}]"
63
+ end
64
+ end
65
+ end
66
+
67
+ end
68
+
69
+ =begin
70
+ a -> b
71
+ b -> c
72
+ a -> d
73
+
74
+ all = a b c d e
75
+ left = a b
76
+ right = b c d
77
+
78
+ [a] == all & left - right # indep_node1
79
+ [e] == all - left - right # indep_node2
80
+ =end
81
+ gr_indep_nodes1 = (node_all&node_in_left-node_in_right).to_a.sort.map { |x| " #{x} [color=#{COLOR_NODEP}]" }
82
+ gr_indep_nodes2 = (node_all-node_in_left-node_in_right).to_a.sort# .map { |x| " #{x} [shape=box, color=#{COLOR_NODEP}]" }
83
+
84
+ tmp1 = []
85
+ tmp1 << "color=#{COLOR_NODEP} independent gems"
86
+ tmp1 << "color=#{COLOR_MISSING} missed gems"
87
+ tmp1 << "color=#{COLOR_DEVELOPMENT} development dependent gems"
88
+ msg = tmp1.join("\\n")
89
+ gr_box_readme = %Q{ readme [shape=note, color=#{COLOR_NOTE}, label="README\\n#{msg}"]}
90
+
91
+ msg = node_in_right.to_a.join("\\n").gsub('"', '')
92
+ gr_box_deped_nodes = %Q{ deped_nodes [shape=box, color=#{COLOR_NODEP}, fontsize=8, label="deped_nodes\\n#{msg}"]}
93
+
94
+ msg = gr_indep_nodes2.join("\\n").gsub('"', '')
95
+ gr_box_indep_nodes = %Q{ indep_nodes [shape=box, color=#{COLOR_NODEP}, fontsize=8, label="indep_nodes\\n#{msg}"]}
96
+
97
+
98
+ if $auto_create_png
99
+ dotfn = "#{File.basename(__FILE__, '.rb')}_#{Time.now.strftime '%Y%m%d%H%M%S'}.dot"
100
+ o = File.open(dotfn, 'w')
101
+ pngfn = dotfn + ".png"
102
+ else
103
+ o = $stdout
104
+ end
105
+ o.puts "digraph G {"
106
+ o.puts gr_box_deped_nodes
107
+ o.puts gr_box_indep_nodes
108
+ o.puts " #{(0..9).to_a.join(' -> ')} -> deped_nodes -> indep_nodes"
109
+ o.puts
110
+ o.puts gr_box_readme
111
+ o.puts
112
+ o.puts gr_edges.to_a.sort
113
+ o.puts
114
+ o.puts gr_indep_nodes1
115
+ o.puts
116
+ o.puts "}"
117
+
118
+ if pngfn
119
+ o.close
120
+ system "dot -Tpng -o#{pngfn} #{dotfn}"
121
+ end
@@ -0,0 +1,5 @@
1
+ require "show_dependency/version"
2
+
3
+ module ShowDependency
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,3 @@
1
+ module ShowDependency
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'show_dependency/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "show_dependency"
8
+ spec.version = ShowDependency::VERSION
9
+ spec.authors = ["windwiny"]
10
+ spec.email = ["windwiny.ubt@gmail.com"]
11
+ spec.summary = %q{create dependency digraph}
12
+ spec.description = %q{create dependency digraph.}
13
+ spec.homepage = "https://github.com/windwiny/show_dependency"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.5"
22
+ spec.add_development_dependency "rake"
23
+ end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: show_dependency
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - windwiny
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: create dependency digraph.
42
+ email:
43
+ - windwiny.ubt@gmail.com
44
+ executables:
45
+ - show_brew_depend.rb
46
+ - show_gems_depend.rb
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - ".gitignore"
51
+ - Gemfile
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Rakefile
55
+ - bin/show_brew_depend.rb
56
+ - bin/show_gems_depend.rb
57
+ - lib/show_dependency.rb
58
+ - lib/show_dependency/version.rb
59
+ - show_dependency.gemspec
60
+ homepage: https://github.com/windwiny/show_dependency
61
+ licenses:
62
+ - MIT
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubyforge_project:
80
+ rubygems_version: 2.2.1
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: create dependency digraph
84
+ test_files: []