repo_dependency_graph 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3b747f1f7904582008138cbceb30e2a2a3806b58
4
- data.tar.gz: 53d83c779792695eabc1779a1e92a4abc7683234
3
+ metadata.gz: 7df4826f35d89bded36eb7421532eff9ce3767c8
4
+ data.tar.gz: 91da00f83ba12d978cbeaf6fb869c6e013bbf2de
5
5
  SHA512:
6
- metadata.gz: 6924b8148a9526cc05989c9a2ec1077a51dd234060949da5fc84db943c85a80c2aad08a7685ad392cbec3bd24d08ed3d5fffcbeda42d03c9d77b042787ca6d29
7
- data.tar.gz: 66d0bdcdc628b3ed70289b31e99294062e237e340620380ff7afc9e93ee7e16147bcc109bd0b5dfd682228209f3621653d737354568c28f204b9b853701839ed
6
+ metadata.gz: c92fe571e36fe8d8e7b2c966f244e5337fe84cb67cae60eae1285b6fdea2bfd6fe93638aa8b556c6a78d62705e5b3832c5db2259117d7c9e2aeb770dd43ff2fc
7
+ data.tar.gz: 3b2a3ceb6ff041a123919b3fec2a69e9a5f7b3bc254641dde781349a559828a188f110da87d844a33ff29ed76f2d01b76085685fc0e6247cd5e3e5adeb26f2ae
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -5,37 +5,4 @@ require "optparse"
5
5
  $LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
6
6
  require "repo_dependency_graph"
7
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 organization") { |organization| options[:organization] = organization }
28
- opts.on("--private", "Only show private repos") { options[:private] = true }
29
- opts.on("--external", "Also include external projects in graph (can get super-messy)") { options[:external] = true }
30
- opts.on("--map SEARCH=REPLACE", "Replace in project name to find them as internal: 'foo=bar' -> replace foo in repo names to bar") do |map|
31
- options[:map] = map.split("=")
32
- options[:map][0] = Regexp.new(options[:map][0])
33
- end
34
- opts.on("--chef", "Parse chef metadata.rb files") { options[:chef] = true }
35
- opts.on("--select REGEX", "Only include repos with matching names") { |regex| options[:select] = Regexp.new(regex) }
36
- opts.on("--reject REGEX", "Exclude repos with matching names") { |regex| options[:reject] = Regexp.new(regex) }
37
- opts.on("-h", "--help", "Show this.") { puts opts; exit }
38
- opts.on("-v", "--version", "Show Version"){ puts RepoDependencyGraph::VERSION; exit}
39
- end.parse!
40
-
41
- exit RepoDependencyGraph.run(options)
8
+ exit RepoDependencyGraph.run(ARGV)
@@ -6,13 +6,50 @@ module RepoDependencyGraph
6
6
  class << self
7
7
  MAX_HEX = 255
8
8
 
9
- def run(options)
10
- draw(dependencies(options))
9
+ def run(argv)
10
+ draw(dependencies(parse_options(argv)))
11
11
  0
12
12
  end
13
13
 
14
14
  private
15
15
 
16
+ def parse_options(argv)
17
+ options = {
18
+ :user => git_config("github.user")
19
+ }
20
+ OptionParser.new do |opts|
21
+ opts.banner = <<-BANNER.gsub(/^ {10}/, "")
22
+ Draw repo dependency graph from your organization
23
+
24
+ Usage:
25
+ repo-dependency-graph
26
+
27
+ Options:
28
+ BANNER
29
+ opts.on("--token TOKEN", "Use token") { |token| options[:token] = token }
30
+ opts.on("--user USER", "Use user") { |user| options[:user] = user }
31
+ opts.on("--organization ORGANIZATION", "Use organization") { |organization| options[:organization] = organization }
32
+ opts.on("--private", "Only show private repos") { options[:private] = true }
33
+ opts.on("--external", "Also include external projects in graph (can get super-messy)") { options[:external] = true }
34
+ opts.on("--map SEARCH=REPLACE", "Replace in project name to find them as internal: 'foo=bar' -> replace foo in repo names to bar") do |map|
35
+ options[:map] = map.split("=")
36
+ options[:map][0] = Regexp.new(options[:map][0])
37
+ options[:map][1] = options[:map][1].to_s
38
+ end
39
+ opts.on("--chef", "Parse chef metadata.rb files") { options[:chef] = true }
40
+ opts.on("--select REGEX", "Only include repos with matching names") { |regex| options[:select] = Regexp.new(regex) }
41
+ opts.on("--reject REGEX", "Exclude repos with matching names") { |regex| options[:reject] = Regexp.new(regex) }
42
+ opts.on("-h", "--help", "Show this.") { puts opts; exit }
43
+ opts.on("-v", "--version", "Show Version"){ puts RepoDependencyGraph::VERSION; exit}
44
+ end.parse!(argv)
45
+ options
46
+ end
47
+
48
+ def git_config(thing)
49
+ result = `git config #{thing}`.strip
50
+ result.empty? ? nil : result
51
+ end
52
+
16
53
  def draw(dependencies)
17
54
  require 'graphviz'
18
55
 
@@ -64,8 +101,8 @@ module RepoDependencyGraph
64
101
  content.scan(/^\s*depends ['"](.*?)['"]/).flatten
65
102
  end
66
103
  else
67
- if repo.gem?
68
- load_spec(repo.gemspec_content).runtime_dependencies.map(&:name)
104
+ if repo.gem? && spec = load_spec(repo.gemspec_content)
105
+ spec.runtime_dependencies.map(&:name)
69
106
  elsif content = repo.content("Gemfile.lock")
70
107
  Bundler::LockfileParser.new(content).specs.map(&:name)
71
108
  elsif content = repo.content("Gemfile")
@@ -77,9 +114,13 @@ module RepoDependencyGraph
77
114
  def load_spec(content)
78
115
  eval content.
79
116
  gsub(/^\s*require .*$/, "").
80
- gsub(/([a-z\d]+::)+version/i, '"1.2.3"').
117
+ gsub(/([a-z\d]+::)+version(::[a-z]+)?/i){|x| x =~ /^Gem::Version$/i ? x : '"1.2.3"' }.
81
118
  gsub(/^\s*\$(:|LOAD_PATH).*/, "").
82
- gsub(/(File|IO)\.read\(.*?\)/, '"1.2.3"')
119
+ gsub(/(File|IO)\.read\(['"]VERSION.*?\)/, '"1.2.3"').
120
+ gsub(/(File|IO)\.read\(.*?\)/, '\' VERSION = "1.2.3"\'')
121
+ rescue Exception
122
+ puts "Error when parsing content:\n#{content}\n\n#{$!}"
123
+ nil
83
124
  end
84
125
 
85
126
  def color(value, range)
@@ -1,3 +1,3 @@
1
1
  module RepoDependencyGraph
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: repo_dependency_graph
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
@@ -29,7 +29,7 @@ cert_chain:
29
29
  y0kCSWmK6D+x/SbfS6r7Ke07MRqziJdB9GuE1+0cIRuFh8EQ+LN6HXCKM5pon/GU
30
30
  ycwMXfl0
31
31
  -----END CERTIFICATE-----
32
- date: 2013-08-18 00:00:00.000000000 Z
32
+ date: 2013-08-23 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: bundler-organization_audit
metadata.gz.sig CHANGED
Binary file