repo_dependency_graph 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 01e2c01278bbf6e49d232e3ba2565cb1fb94664b
4
+ data.tar.gz: f4f43571cda21bb4c0c5847e15627181bb9d0219
5
+ SHA512:
6
+ metadata.gz: 288ea662bb0f323273b8175c6df68c21b564ff5beb9a68f2cf4f14bb7d5e7926844c4b604fb8fb6fa08f6b8dd19fba27ef4a4f894f2964bf8885254bfef14307
7
+ data.tar.gz: e9bf2f56c5e91c58c0a48bc4da35dbe0c0678842105026b607ac9e7fa877a4b0feeca948c901a284bab1329354d7a65006546d7ea3f7849f60d99b727532bbe6
checksums.yaml.gz.sig ADDED
Binary file
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env ruby
2
+ require "rubygems"
3
+ require "optparse"
4
+
5
+ $LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
6
+ require "repo_dependency_graph"
7
+
8
+ def git_config(thing)
9
+ result = `git config #{thing}`.strip
10
+ result.empty? ? nil : result
11
+ end
12
+
13
+ options = {
14
+ :user => git_config("github.user")
15
+ }
16
+ OptionParser.new do |opts|
17
+ opts.banner = <<BANNER
18
+ Draw repo dependency graph from your organization
19
+
20
+ Usage:
21
+ repo-dependency-graph
22
+
23
+ Options:
24
+ BANNER
25
+ opts.on("--token TOKEN", "Use token") { |token| options[:token] = token }
26
+ opts.on("--user USER", "Use user") { |user| options[:user] = user }
27
+ opts.on("--organization ORGANIZATION", "Use user") { |organization| options[:organization] = organization }
28
+ opts.on("-h", "--help", "Show this.") { puts opts; exit }
29
+ opts.on("-v", "--version", "Show Version"){ puts RepoDependencyGraph::VERSION; exit}
30
+ end.parse!
31
+
32
+ exit RepoDependencyGraph.run(options)
@@ -0,0 +1,3 @@
1
+ module RepoDependencyGraph
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,66 @@
1
+ require "repo_dependency_graph/version"
2
+ require "bundler/organization_audit/repo"
3
+ require "bundler" # get all dependency for lockfile_parser
4
+
5
+ module RepoDependencyGraph
6
+ class << self
7
+ def run(options)
8
+ dependencies = dependencies(options)
9
+ dependencies.map do |project, dependencies|
10
+ puts "#{project}: #{dependencies.join(",")}"
11
+ end
12
+ draw(dependencies)
13
+ 0
14
+ end
15
+
16
+ private
17
+
18
+ def draw(dependencies)
19
+ require 'graphviz'
20
+
21
+ g = GraphViz.new(:G, :type => :digraph)
22
+
23
+ all = (dependencies.keys + dependencies.values.flatten).uniq
24
+ nodes = Hash[all.map { |k| [k, g.add_node(k)] }]
25
+
26
+ dependencies.each do |project,dependencies|
27
+ dependencies.each do |dependency|
28
+ g.add_edge(nodes[project], nodes[dependency])
29
+ end
30
+ end
31
+
32
+ g.output(:png => "out.png")
33
+ end
34
+
35
+ def dependencies(options)
36
+ all = Bundler::OrganizationAudit::Repo.all(options).select(&:private?).sort_by(&:project)
37
+ possible = all.map(&:project)
38
+ dependencies = all.map do |repo|
39
+ found = dependent_gems(repo) || []
40
+ found = found & possible
41
+ next if found.empty?
42
+ puts "#{repo.project}: #{found.join(", ")}"
43
+ [repo.project, found]
44
+ end.compact
45
+ Hash[dependencies]
46
+ end
47
+
48
+ def dependent_gems(repo)
49
+ if repo.gem?
50
+ load_spec(repo.gemspec_content).runtime_dependencies.map(&:name)
51
+ elsif content = repo.content("Gemfile.lock")
52
+ Bundler::LockfileParser.new(content).specs.map(&:name)
53
+ elsif content = repo.content("Gemfile")
54
+ content.scan(/gem ['"](.*?)['"]/).flatten
55
+ end
56
+ end
57
+
58
+ def load_spec(content)
59
+ eval content.
60
+ gsub(/^\s*require .*$/, "").
61
+ gsub(/([a-z\d]+::)+version/i, '"1.2.3"').
62
+ gsub(/^\s*\$(:|LOAD_PATH).*/, "").
63
+ gsub(/File\.read\(.*?\)/, '"1.2.3"')
64
+ end
65
+ end
66
+ end
data.tar.gz.sig ADDED
Binary file
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: repo_dependency_graph
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Michael Grosser
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDMjCCAhqgAwIBAgIBADANBgkqhkiG9w0BAQUFADA/MRAwDgYDVQQDDAdtaWNo
14
+ YWVsMRcwFQYKCZImiZPyLGQBGRYHZ3Jvc3NlcjESMBAGCgmSJomT8ixkARkWAml0
15
+ MB4XDTEzMDIwMzE4MTMxMVoXDTE0MDIwMzE4MTMxMVowPzEQMA4GA1UEAwwHbWlj
16
+ aGFlbDEXMBUGCgmSJomT8ixkARkWB2dyb3NzZXIxEjAQBgoJkiaJk/IsZAEZFgJp
17
+ dDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMorXo/hgbUq97+kII9H
18
+ MsQcLdC/7wQ1ZP2OshVHPkeP0qH8MBHGg6eYisOX2ubNagF9YTCZWnhrdKrwpLOO
19
+ cPLaZbjUjljJ3cQR3B8Yn1veV5IhG86QseTBjymzJWsLpqJ1UZGpfB9tXcsFtuxO
20
+ 6vHvcIHdzvc/OUkICttLbH+1qb6rsHUceqh+JrH4GrsJ5H4hAfIdyS2XMK7YRKbh
21
+ h+IBu6dFWJJByzFsYmV1PDXln3UBmgAt65cmCu4qPfThioCGDzbSJrGDGLmw/pFX
22
+ FPpVCm1zgYSb1v6Qnf3cgXa2f2wYGm17+zAVyIDpwryFru9yF/jJxE38z/DRsd9R
23
+ /88CAwEAAaM5MDcwCQYDVR0TBAIwADAdBgNVHQ4EFgQUsiNnXHtKeMYYcr4yJVmQ
24
+ WONL+IwwCwYDVR0PBAQDAgSwMA0GCSqGSIb3DQEBBQUAA4IBAQAlyN7kKo/NQCQ0
25
+ AOzZLZ3WAePvStkCFIJ53tsv5Kyo4pMAllv+BgPzzBt7qi605mFSL6zBd9uLou+W
26
+ Co3s48p1dy7CjjAfVQdmVNHF3MwXtfC2OEyvSQPi4xKR8iba8wa3xp9LVo1PuLpw
27
+ /6DsrChWw74HfsJN6qJOK684hJeT8lBYAUfiC3wD0owoPSg+XtyAAddisR+KV5Y1
28
+ NmVHuLtQcNTZy+gRht3ahJRMuC6QyLmkTsf+6MaenwAMkAgHdswGsJztOnNnBa3F
29
+ y0kCSWmK6D+x/SbfS6r7Ke07MRqziJdB9GuE1+0cIRuFh8EQ+LN6HXCKM5pon/GU
30
+ ycwMXfl0
31
+ -----END CERTIFICATE-----
32
+ date: 2013-08-10 00:00:00.000000000 Z
33
+ dependencies:
34
+ - !ruby/object:Gem::Dependency
35
+ name: bundler-organization_audit
36
+ requirement: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ type: :runtime
42
+ prerelease: false
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ description:
49
+ email: michael@grosser.it
50
+ executables:
51
+ - repo-dependency-graph
52
+ extensions: []
53
+ extra_rdoc_files: []
54
+ files:
55
+ - bin/repo-dependency-graph
56
+ - lib/repo_dependency_graph.rb
57
+ - lib/repo_dependency_graph/version.rb
58
+ homepage: http://github.com/grosser/repo_dependency_graph
59
+ licenses:
60
+ - MIT
61
+ metadata: {}
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 2.0.6
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: Show the dependencies of your private repos
82
+ test_files: []
metadata.gz.sig ADDED
Binary file