repo_dependency_graph 0.5.0 → 0.6.0

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
  SHA256:
3
- metadata.gz: 9eb02ec4a7791f157956976b1bc3556f320baeccdcd94a427061c752508aaffb
4
- data.tar.gz: 50ab88bc34a1ecd98aae758e96e152517bb01add9268abefadc6e6ef383f172a
3
+ metadata.gz: fcae82e09e603259bf440462660251915622ca5fd5c0c09964b9dc8a32af93a9
4
+ data.tar.gz: 21b413b03a5d6bda6af03531cf2128560ad80c988f94eb2a499d555c184c28b2
5
5
  SHA512:
6
- metadata.gz: ca3dd51e05369ba9b9dab42d6c34e3a50371d4d5fb5199b7961762ff6914775e6e38b7bdc4d357a140cb9ba43a2a70dfae0d92b6a2caf6072d0e10bb3d4b38b8
7
- data.tar.gz: 824a88b4294365f3aaefc04e6d89ebb8f819fbb160f48cc42946ec53c1eef2b1020e4f50062c98d3dea11d3743522d72b41cbfcd1d51d4d4f42b047fb1ce3360
6
+ metadata.gz: ea7f863be8ffe68e240e75a1944bcb53a98663486b2cd660bb1086e9f24c33fc594068bd2b93916c78d1e0d21787717948c5b75b27a2b190a047c8bd9adfd58b
7
+ data.tar.gz: fb63dff1d601c3397d7be6203cd2c0feb25f9060df2e2b29b254bc0ae4949b4f9f2ab0929cdfd68279c6dff0afc82844a309684f0e319e47395917a4da00912f
@@ -11,7 +11,7 @@ module RepoDependencyGraph
11
11
  raise ArgumentError, "Map only makes sense when searching for internal repos"
12
12
  end
13
13
 
14
- all = OrganizationAudit::Repo.all(options).sort_by(&:name)
14
+ all = OrganizationAudit::Repo.all(options.slice(:user, :organization, :token, :max_pages)).sort_by(&:name)
15
15
  all.select!(&:private?) if options[:private]
16
16
  all.select! { |r| r.name =~ options[:select] } if options[:select]
17
17
  all.reject! { |r| r.name =~ options[:reject] } if options[:reject]
@@ -41,17 +41,14 @@ module RepoDependencyGraph
41
41
  end
42
42
 
43
43
  if !options[:only] || options[:only] == "gem"
44
- gems = if repo.gem? && spec = load_gemspec(repo.name, repo.gemspec_content)
45
- spec.runtime_dependencies.map do |d|
46
- r = d.requirement.to_s
47
- r = nil if r == ">= 0"
48
- [d.name, r].compact
44
+ gems =
45
+ if repo.gem?
46
+ scan_gemspec(repo.name, repo.gemspec_content)
47
+ elsif content = content_from_any(repo, ["gems.locked", "Gemfile.lock"])
48
+ scan_gemfile_lock(repo.name, content)
49
+ elsif content = content_from_any(repo, ["gems.rb", "Gemfile"])
50
+ scan_gemfile(repo.name, content)
49
51
  end
50
- elsif content = content_from_any(repo, ["gems.locked", "Gemfile.lock"])
51
- scan_gemfile_lock(repo.name, content)
52
- elsif content = content_from_any(repo, ["gems.rb", "Gemfile"])
53
- scan_gemfile(repo.name, content)
54
- end
55
52
  repos.concat gems if gems
56
53
  end
57
54
 
@@ -71,23 +68,15 @@ module RepoDependencyGraph
71
68
  end
72
69
 
73
70
  def scan_gemfile_lock(repo_name, content)
71
+ content = content.gsub(/BUNDLED WITH\n.*\n/, "")
74
72
  Bundler::LockfileParser.new(content).specs.map { |d| [d.name, d.version.to_s] }
75
73
  rescue
76
74
  $stderr.puts "Error parsing #{repo_name} Gemfile.lock:\n#{content}\n\n#{$!}"
77
75
  nil
78
76
  end
79
77
 
80
- def load_gemspec(repo_name, content)
81
- content = content.
82
- gsub(/^\s*(require|require_relative) .*$/, "").
83
- gsub(/([a-z\d]+::)+version(::[a-z]+)?/i){|x| x =~ /^Gem::Version$/i ? x : '"1.2.3"' }.
84
- gsub(/^\s*\$(:|LOAD_PATH).*/, "").
85
- gsub(/(File|IO)\.read\(['"]VERSION.*?\)/, '"1.2.3"').
86
- gsub(/(File|IO)\.read\(.*?\)/, '\' VERSION = "1.2.3"\'')
87
- eval content
88
- rescue StandardError, SyntaxError
89
- $stderr.puts "Error parsing #{repo_name} gemspec:\n#{content}\n\n#{$!}"
90
- nil
78
+ def scan_gemspec(_, content)
79
+ content.scan(/add(?:_runtime)?_dependency[\s(]+['"]([^'"]*)['"](?:,\s*['"]([^'"]*)['"])*/).map(&:compact)
91
80
  end
92
81
  end
93
82
  end
@@ -39,6 +39,7 @@ module RepoDependencyGraph
39
39
  options[:map][1] = options[:map][1].to_s
40
40
  end
41
41
  opts.on("--only TYPE", String, "Only this type (chef,gem), default: all") { |t| options[:only] = t }
42
+ opts.on("--max-pages PAGES", Integer, "") { |p| options[:max_pages] = p }
42
43
  opts.on("--select REGEX", "Only include repos with matching names") { |regex| options[:select] = Regexp.new(regex) }
43
44
  opts.on("--reject REGEX", "Exclude repos with matching names") { |regex| options[:reject] = Regexp.new(regex) }
44
45
  opts.on("-h", "--help", "Show this.") { puts opts; exit }
@@ -1,3 +1,3 @@
1
1
  module RepoDependencyGraph
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: repo_dependency_graph
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-15 00:00:00.000000000 Z
11
+ date: 2019-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: organization_audit