repo_dependency_graph 0.1.1 → 0.1.2

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: 8f1a26045d0b94cabc0caeb7415be53c913fafa4
4
- data.tar.gz: 244ea25f2123ab0ec616ddddf8218b831f0b72e4
3
+ metadata.gz: 3b747f1f7904582008138cbceb30e2a2a3806b58
4
+ data.tar.gz: 53d83c779792695eabc1779a1e92a4abc7683234
5
5
  SHA512:
6
- metadata.gz: b0e1e081ced8f8840fe666be5fc9564a03367488eaa2ba9e551ca98f79818fc38458b116329477d90fce06e90ecbaa75654c902fb2dcb6262c528728d8b2723a
7
- data.tar.gz: d98badb12c110eac67a196000cd8ad0162365e87a0ee149778282fe087431e8a41fb00f4a037fb88422847ba2ef882093c34c18f659dcb8f6fa831f2d228c479
6
+ metadata.gz: 6924b8148a9526cc05989c9a2ec1077a51dd234060949da5fc84db943c85a80c2aad08a7685ad392cbec3bd24d08ed3d5fffcbeda42d03c9d77b042787ca6d29
7
+ data.tar.gz: 66d0bdcdc628b3ed70289b31e99294062e237e340620380ff7afc9e93ee7e16147bcc109bd0b5dfd682228209f3621653d737354568c28f204b9b853701839ed
checksums.yaml.gz.sig CHANGED
Binary file
@@ -1,3 +1,3 @@
1
1
  module RepoDependencyGraph
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -4,7 +4,7 @@ require "bundler" # get all dependency for lockfile_parser
4
4
 
5
5
  module RepoDependencyGraph
6
6
  class << self
7
- MAX_SATURATION = 255
7
+ MAX_HEX = 255
8
8
 
9
9
  def run(options)
10
10
  draw(dependencies(options))
@@ -18,16 +18,15 @@ module RepoDependencyGraph
18
18
 
19
19
  g = GraphViz.new(:G, :type => :digraph)
20
20
 
21
- all = (dependencies.keys + dependencies.values.flatten).uniq
22
- counts = Hash[all.map { |k| [k, dependencies.values.count { |v| v.include?(k) }] }]
23
- puts counts.inspect
24
- max = counts.values.max
21
+ counts = dependency_counts(dependencies)
22
+ range = counts.values.min..counts.values.max
25
23
 
26
- nodes = Hash[all.map do |k|
27
- [k, g.add_node(k, :color => color(counts[k] - 1, max), :style => "filled")]
24
+ nodes = Hash[counts.map do |project, count|
25
+ node = g.add_node(project, :color => color(count, range), :style => "filled")
26
+ [project, node]
28
27
  end]
29
28
 
30
- dependencies.each do |project,dependencies|
29
+ dependencies.each do |project, dependencies|
31
30
  dependencies.each do |dependency|
32
31
  g.add_edge(nodes[project], nodes[dependency])
33
32
  end
@@ -37,7 +36,9 @@ module RepoDependencyGraph
37
36
  end
38
37
 
39
38
  def dependencies(options)
40
- raise ArgumentError, "Map only makes sense when searching for internal repos" if options[:map] && options[:external]
39
+ if options[:map] && options[:external]
40
+ raise ArgumentError, "Map only makes sense when searching for internal repos"
41
+ end
41
42
 
42
43
  all = Bundler::OrganizationAudit::Repo.all(options).sort_by(&:project)
43
44
  all = all.select(&:private?) if options[:private]
@@ -81,12 +82,22 @@ module RepoDependencyGraph
81
82
  gsub(/(File|IO)\.read\(.*?\)/, '"1.2.3"')
82
83
  end
83
84
 
84
- def color(value, max)
85
- value *= 0.6 # change green to green to green to blue
86
- i = (value * MAX_SATURATION / max);
87
- a,b = MAX_SATURATION / 2, MAX_SATURATION - MAX_SATURATION / 2
88
- values = [0,2,4].map { |v| (Math.sin(0.024 * i + v) * a + b).round.to_s(16).rjust(2,"0") }
85
+ def color(value, range)
86
+ value -= range.min # lowest -> green
87
+ max = range.max - range.min
88
+
89
+ i = (value * MAX_HEX / max);
90
+ i *= 0.6 # green-blue gradient instead of green-green
91
+ half = MAX_HEX * 0.5
92
+ values = [0,2,4].map { |v| (Math.sin(0.024 * i + v) * half + half).round.to_s(16).rjust(2, "0") }
89
93
  "##{values.join}"
90
94
  end
95
+
96
+ def dependency_counts(dependencies)
97
+ all = (dependencies.keys + dependencies.values.flatten).uniq
98
+ Hash[all.map do |k|
99
+ [k, dependencies.values.count { |v| v.include?(k) } ]
100
+ end]
101
+ end
91
102
  end
92
103
  end
data.tar.gz.sig CHANGED
Binary file
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.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
metadata.gz.sig CHANGED
Binary file